:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #16202b;
  --ink-2: #5b6b7a;
  --hair: #e4e9ee;
  --navy: #1f2d3d;
  --accent: #14b8a6;
  --accent-ink: #0d9488;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #16a34a;
  --warn: #b45309;
  --shadow: 0 1px 3px rgba(16,32,43,.08), 0 4px 20px rgba(16,32,43,.05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1621; --surface: #16202b; --surface-2: #1b2733;
    --ink: #e6edf3; --ink-2: #97a6b6; --hair: #253341;
    --navy: #0b1219; --accent: #2dd4bf; --accent-ink: #14b8a6; --danger-bg: #2a1414;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 24px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow); padding: 32px 28px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.brand img.logo {
  width: 44px; height: 44px; border-radius: 11px; object-fit: cover;
  background: var(--navy); flex: 0 0 auto;
}
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-card .sub { color: var(--ink-2); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field input[type=text], .field input[type=password], .field input[type=number] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--hair); border-radius: 10px;
  background: var(--surface-2); outline: none;
}
.field input:focus { border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--ink-2); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: 1px solid transparent; border-radius: 10px;
  background: var(--navy); color: #fff; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--hair); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.accent { background: var(--accent-ink); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; font-weight: 500; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side { background: var(--navy); color: #cdd8e3; padding: 18px 14px; display: flex; flex-direction: column; }
.side .brand { color: #fff; margin-bottom: 22px; padding: 0 6px; }
.side .brand .name { font-weight: 700; font-size: 15px; color: #fff; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  color: #b8c6d4; text-decoration: none; font-weight: 500; cursor: pointer;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--accent-ink); color: #fff; }
.nav a .soon { margin-left: auto; font-size: 10px; opacity: .6; border: 1px solid currentColor; border-radius: 6px; padding: 0 5px; }
.side .foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; font-size: 12px; }
.side .foot .who { color: #9fb0c0; margin-bottom: 8px; word-break: break-all; }
.side .foot .row { display: flex; gap: 8px; }
.side .foot .row .btn { flex: 1; padding: 7px; font-size: 12px; }

.main { padding: 24px 28px; overflow: auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h2 { font-size: 20px; margin: 0; flex: 1; }
.page-head .count { color: var(--ink-2); font-size: 13px; margin-right: auto; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=text] {
  padding: 8px 12px; border: 1px solid var(--hair); border-radius: 9px;
  background: var(--surface); min-width: 220px;
}

/* ---------- table ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; }
td.actions .btn { margin-left: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill.active { background: rgba(22,163,74,.12); color: var(--ok); }
.pill.off { background: rgba(220,38,38,.1); color: var(--danger); }
.pill.tag { background: rgba(20,184,166,.12); color: var(--accent-ink); }
.muted { color: var(--ink-2); }
.empty { padding: 40px; text-align: center; color: var(--ink-2); }
.center-more { text-align: center; padding: 14px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10,18,25,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 24px; }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .modal-sub { color: var(--ink-2); font-size: 13px; margin: 0 0 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 60; font-size: 13.5px; max-width: 90vw;
}
.toast.err { background: var(--danger); }

/* ---------- wip placeholder ---------- */
.wip { padding: 60px 20px; text-align: center; color: var(--ink-2); }
.wip .big { font-size: 40px; margin-bottom: 12px; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; padding: 10px 12px; }
  .side .brand { margin: 0 12px 0 0; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a .soon { display: none; }
  .side .foot { display: none; }
}
