:root {
  --bg: #16181d; --panel: #1f2228; --panel-2: #262a31; --line: #31353d;
  --text: #e8eaee; --dim: #8d939e; --accent: #5b6cff; --accent-2: #7b3fe4;
  --green: #2fbf8f; --red: #e5484d; --amber: #ffc94a;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.dim { color: var(--dim); }
.sub { color: var(--dim); font-size: 12px; font-weight: normal; }

/* top bar */
.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 16px; }
.brand b { color: var(--dim); font-weight: 500; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { text-decoration: none; padding: 8px 14px; border-radius: 8px; color: var(--dim); }
nav a:hover { background: var(--panel-2); color: var(--text); }
nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 4px 0 16px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.stats { display: flex; gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; color: var(--dim); }
.stat b { color: var(--text); }

/* controls */
input, button { font: inherit; }
input[type=search], input:not([type]), input[type=number], input[type=password] {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-weight: 600; }
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--panel-2); }
button.danger { background: var(--red); }
button.small { padding: 4px 10px; font-size: 12px; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 320px; max-width: 100%; }
.auto { margin-left: auto; color: var(--dim); display: flex; gap: 6px; align-items: center; cursor: pointer; }
form.inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 6px 0; }
form.inline label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 12px; }
form.inline label.grow { flex: 1; min-width: 220px; }
form.stack { display: flex; flex-direction: column; gap: 14px; }
form.stack label { display: flex; flex-direction: column; gap: 4px; }
.unit { display: flex; align-items: center; gap: 8px; color: var(--dim); }
.unit input { width: 120px; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
tr.muted td { opacity: .55; }
tr.warn td { color: var(--amber); }
tr.editrow td { background: var(--panel-2); }
td.note { color: var(--dim); max-width: 280px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
td.arrow { color: var(--dim); width: 20px; }
td.empty { text-align: center; color: var(--dim); padding: 32px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #4a4f58; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(47,191,143,.18); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.tag.green { background: rgba(47,191,143,.15); color: var(--green); }
.tag.red { background: rgba(229,72,77,.15); color: var(--red); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.card .table-wrap { border: 0; background: transparent; margin: 0 -18px -18px; border-radius: 0; border-top: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } .top { flex-wrap: wrap; height: auto; padding: 10px 16px; } }
.iplist { list-style: none; padding: 0; margin: 14px 0 0; }
.iplist li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.iplist form { display: inline; }
.pager { display: flex; gap: 20px; justify-content: center; margin: 14px 0; }
.hint { color: var(--dim); font-size: 12px; line-height: 1.5; margin: 12px 2px; max-width: 900px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: rgba(47,191,143,.12); color: var(--green); border: 1px solid rgba(47,191,143,.3); }
.flash.err { background: rgba(229,72,77,.12); color: #ff8b8e; border: 1px solid rgba(229,72,77,.3); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(59,91,255,.18), transparent), radial-gradient(900px 500px at 100% 100%, rgba(123,63,228,.16), transparent), var(--bg); }
.login-card { width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login-card img { align-self: center; }
.login-card h1 { text-align: center; font-size: 20px; margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--dim); }
.login-card button { margin-top: 6px; padding: 10px; }
