/* 白细胞管理后台 — "明视野" light theme. No build step; served as-is. */

:root {
  --bg: #F4F5F9;
  --card: #FFFFFF;
  --raised: #EEF0F6;
  --inset: #E6E8EF;
  --off: #D5D9E3;
  --line: rgba(20, 24, 38, .08);
  --line-2: rgba(20, 24, 38, .14);
  --line-3: rgba(20, 24, 38, .24);
  --t1: #141826;
  --t2: #4B5367;
  --t3: #666E82;
  --t4: #A3A9B7;
  --acc: #1673C4;
  --acc-hi: #4FA3F0;
  --acc-lo: #0F5FA8;
  --acc-hover: #1C7DD2;
  --acc-tint: rgba(22, 115, 196, .09);
  --acc-ring: rgba(22, 115, 196, .18);
  --ok: #0A7F52;
  --ok-tint: rgba(10, 127, 82, .10);
  --warn: #9A6100;
  --warn-tint: rgba(154, 97, 0, .10);
  --bad: #D33547;
  --bad-tint: rgba(211, 53, 71, .09);
  --bad-ring: rgba(211, 53, 71, .16);
  --shadow-card: 0 1px 2px rgba(20, 24, 38, .05), 0 6px 16px -10px rgba(20, 24, 38, .22);
  --shadow-pop: 0 2px 4px rgba(20, 24, 38, .06), 0 16px 40px -12px rgba(20, 24, 38, .30);
  --radius-card: 14px;
  --radius-ctl: 10px;
  --f-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Microsoft YaHei", monospace;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-press: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}
html:has(.shell) { scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 400 14px/1.55 var(--f-sans);
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-lo); }
svg { flex-shrink: 0; }
h1, h2, h3, p { margin: 0; }
code, .mono { font-family: var(--f-mono); font-size: .92em; }

:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.skip-link:focus {
  position: fixed !important; left: 12px; top: 12px; z-index: 200; width: auto; height: auto; clip: auto; margin: 0;
  padding: 8px 14px; border-radius: 10px; background: var(--t1); color: #fff; font-size: 13px; white-space: nowrap;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- boot splash ---------- */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.boot-logo { animation: boot-pulse 1.6s var(--ease-out) infinite; filter: drop-shadow(0 4px 10px rgba(20, 24, 38, .10)); }
@keyframes boot-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .75; } }
.noscript { text-align: center; color: var(--t2); padding: 40px 16px; }

/* ---------- logo / brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { display: block; filter: drop-shadow(0 2px 4px rgba(20, 24, 38, .08)); }
.brand-text { display: grid; gap: 1px; min-width: 0; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: .02em; color: var(--t1); line-height: 1.2; }
.brand-tag {
  font-size: 11px; font-weight: 600; color: var(--acc); background: var(--acc-tint);
  border-radius: 6px; padding: 1px 6px; line-height: 18px; white-space: nowrap;
}
.brand-latin { font-size: 10px; letter-spacing: .24em; color: var(--t4); font-weight: 600; line-height: 1.3; }

/* ---------- buttons ---------- */
.btn {
  --btn-h: 38px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 16px; border: 0; border-radius: var(--radius-ctl);
  font-size: 14px; font-weight: 550; line-height: 1; white-space: nowrap;
  text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .18s var(--ease-press), opacity .16s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { cursor: not-allowed; opacity: .5; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--acc); color: #fff; box-shadow: 0 1px 2px rgba(15, 95, 168, .28), inset 0 1px 0 rgba(255, 255, 255, .10); }
.btn-primary:hover:not(:disabled) { background: var(--acc-hover); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--acc-lo); }
.btn-secondary { background: var(--raised); color: var(--t1); box-shadow: inset 0 0 0 1px var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--inset); color: var(--t1); }
.btn-danger { background: var(--bad-tint); color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: rgba(211, 53, 71, .15); color: #B92838; }
.btn-danger-solid { background: var(--bad); color: #fff; box-shadow: 0 1px 2px rgba(160, 30, 45, .28); }
.btn-danger-solid:hover:not(:disabled) { background: #C42C3E; color: #fff; }
.btn-ghost { background: transparent; color: var(--t2); }
.btn-ghost:hover:not(:disabled) { background: var(--raised); color: var(--t1); }
.btn-sm { --btn-h: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { --btn-h: 42px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after, .btn-danger-solid.is-loading::after { border-color: #fff; border-right-color: transparent; }
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--t2); border-right-color: transparent; }
.btn-danger.is-loading::after { border-color: var(--bad); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 4px 2px;
  color: var(--acc); font-size: 13px; font-weight: 550; border-radius: 6px;
}
.link-btn:hover { color: var(--acc-lo); }
.link-btn svg { width: 15px; height: 15px; transition: transform .18s var(--ease-out); }
.link-btn:hover svg { transform: translateX(2px); }

/* ---------- forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 550; color: var(--t2); line-height: 1.3; }
.field-label .opt { color: var(--t4); font-weight: 400; margin-left: 4px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-ctl);
  border: 1px solid var(--line-2); background: #fff; color: var(--t1);
  font-size: 14px; line-height: 1.2; outline: none; appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.input::placeholder { color: var(--t4); }
.input:hover { border-color: var(--line-3); }
.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-ring); }
.input:disabled { background: var(--raised); color: var(--t3); cursor: not-allowed; }
.input.mono { font-family: var(--f-mono); font-size: 13.5px; letter-spacing: .02em; }
.input[type="number"] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.input[type="number"]::-webkit-inner-spin-button, .input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input[type="date"] { min-width: 0; }
.input-wrap .input.has-action { padding-right: 44px; }
.input-action {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--t3); transition: background-color .15s ease, color .15s ease;
}
.input-action:hover { background: var(--raised); color: var(--t1); }
.input-action svg { width: 17px; height: 17px; }
.input-suffix { position: absolute; right: 12px; color: var(--t3); font-size: 13px; pointer-events: none; }
.input-wrap .input.has-suffix { padding-right: 40px; }
.input-wrap .input.has-suffix-wide { padding-right: 76px; }
.field-hint { font-size: 12px; color: var(--t3); line-height: 1.5; }
.field.is-invalid .field-hint { display: none; }
.field-error { display: none; font-size: 12px; color: var(--bad); line-height: 1.45; }
.field.is-invalid .field-error { display: block; }
.field.is-invalid .input { border-color: var(--bad); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 3px var(--bad-ring); }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }

.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.strength i { height: 4px; border-radius: 2px; background: var(--inset); transition: background-color .2s ease; }
.strength[data-level="1"] i:nth-child(-n+1) { background: var(--bad); }
.strength[data-level="2"] i:nth-child(-n+2) { background: #D9822B; }
.strength[data-level="3"] i:nth-child(-n+3) { background: var(--acc); }
.strength[data-level="4"] i { background: var(--ok); }

/* ---------- alerts ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.55; color: var(--t2); background: var(--raised);
}
.alert svg { width: 18px; height: 18px; margin-top: 1px; }
.alert-danger { background: var(--bad-tint); color: #A82434; }
.alert-danger svg { color: var(--bad); }
.alert-warning { background: var(--warn-tint); color: #7A4D00; }
.alert-warning svg { color: var(--warn); }
.alert-info { background: var(--acc-tint); color: #0F4F8A; }
.alert-info svg { color: var(--acc); }
.alert-success { background: var(--ok-tint); color: #08643F; }
.alert-success svg { color: var(--ok); }
.alert .alert-body { flex: 1; min-width: 0; }
.alert .alert-action { margin: -4px -6px -4px 0; }

/* ---------- auth pages (login / setup) ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 32px 16px;
  background:
    radial-gradient(900px 520px at 50% -12%, rgba(79, 163, 240, .16), transparent 62%),
    radial-gradient(720px 420px at 100% 110%, rgba(22, 115, 196, .07), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%); background: var(--card); border-radius: 18px;
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(20, 24, 38, .05), 0 22px 48px -24px rgba(20, 24, 38, .32);
  padding: 32px 32px 28px;
}
.auth-card.wide { width: min(460px, 100%); }
.auth-head { display: grid; justify-items: center; gap: 12px; text-align: center; margin-bottom: 24px; }
.auth-head .brand-logo { width: 56px; height: 56px; }
.auth-title { font-size: 20px; font-weight: 650; letter-spacing: .01em; }
.auth-sub { font-size: 13px; color: var(--t3); line-height: 1.6; }
.auth-latin { font-size: 10.5px; letter-spacing: .3em; color: var(--t4); font-weight: 600; margin-top: -6px; }
.auth-foot { margin-top: 20px; font-size: 12px; color: var(--t3); text-align: center; line-height: 1.7; }
.auth-foot code { background: var(--raised); padding: 1px 6px; border-radius: 5px; color: var(--t2); white-space: nowrap; }
.auth .alert { margin-bottom: 4px; }
.cmd {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 10px;
  background: #F7F8FB; box-shadow: inset 0 0 0 1px var(--line); font-family: var(--f-mono); font-size: 12.5px;
  color: var(--t2); overflow: hidden;
}
.cmd span { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.5; }

/* ---------- app shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w);
  display: flex; flex-direction: column; background: #FFFFFF;
  box-shadow: inset -1px 0 0 var(--line);
}
.sidebar-head { padding: 20px 20px 18px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; display: grid; align-content: start; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--t4); letter-spacing: .08em; padding: 12px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--t2); font-size: 14px; font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.nav-link svg { width: 19px; height: 19px; color: var(--t3); transition: color .15s ease; }
.nav-link:hover { background: var(--bg); color: var(--t1); }
.nav-link:hover svg { color: var(--t2); }
.nav-link[aria-current="page"] { background: var(--acc-tint); color: var(--acc); font-weight: 600; }
.nav-link[aria-current="page"] svg { color: var(--acc); }
.sidebar-foot { padding: 12px; box-shadow: inset 0 1px 0 var(--line); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 8px; border-radius: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--acc-tint); color: var(--acc); font-weight: 650; font-size: 14px; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(22, 115, 196, .14);
}
.user-meta { flex: 1; min-width: 0; display: grid; }
.user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--t3); }
.version { font-size: 11px; color: var(--t4); padding: 6px 8px 2px; font-variant-numeric: tabular-nums; }

.main { margin-left: var(--sidebar-w); min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; padding: 28px 32px 56px; outline: none; }
.scrim { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; min-height: 44px; }
.page-title { font-size: 20px; font-weight: 650; letter-spacing: .01em; line-height: 1.35; outline: none; }
.page-sub { font-size: 13px; color: var(--t3); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.updated { font-size: 12px; color: var(--t4); font-variant-numeric: tabular-nums; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; min-height: 48px; }
.card-head.ruled { padding-bottom: 14px; box-shadow: inset 0 -1px 0 var(--line); }
.card-title { font-size: 13px; font-weight: 600; color: var(--t2); display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 16px; height: 16px; color: var(--t3); }
.card-meta { font-size: 12px; color: var(--t3); font-variant-numeric: tabular-nums; }
.card-body { padding: 16px 20px 20px; }
.card-desc { font-size: 13px; color: var(--t2); line-height: 1.7; }
.card-desc strong { color: var(--t1); font-weight: 600; }
.card-clip { overflow: hidden; }
.card-table { padding-top: 14px; overflow: hidden; border-radius: 0 0 var(--radius-card) var(--radius-card); }
.card-table > .empty { box-shadow: inset 0 1px 0 var(--line); }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-2.stretch { align-items: stretch; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.tile { padding: 18px 20px 18px; display: grid; gap: 8px; align-content: start; min-height: 128px; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-label { font-size: 13px; font-weight: 600; color: var(--t2); }
.tile-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--raised); color: var(--t3); }
.tile-icon svg { width: 17px; height: 17px; }
.tile.primary .tile-icon { background: var(--acc); color: #fff; box-shadow: 0 2px 6px -2px rgba(22, 115, 196, .6); }
.tile-value { font-size: 30px; font-weight: 650; letter-spacing: -.01em; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--t1); }
.tile.primary .tile-value { color: var(--acc); }
.tile-caption { font-size: 12px; color: var(--t3); font-variant-numeric: tabular-nums; line-height: 1.5; }
.tile-caption b { color: var(--t2); font-weight: 600; }

/* ---------- chart ---------- */
.chart { position: relative; height: 240px; outline: none; border-radius: 10px; }
.chart:focus-visible { box-shadow: 0 0 0 2px var(--acc); }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: rgba(20, 24, 38, .07); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base-line { stroke: rgba(20, 24, 38, .18); stroke-width: 1; shape-rendering: crispEdges; }
.chart .y-label, .chart .x-label { font: 500 11px var(--f-sans); fill: var(--t4); font-variant-numeric: tabular-nums; }
.chart .x-label.today { fill: var(--acc); font-weight: 650; }
.chart .bar { fill: var(--acc); transition: opacity .15s ease, fill .15s ease; }
.chart .bar.zero { fill: var(--inset); }
.chart .band { fill: transparent; }
.chart .band.active { fill: rgba(22, 115, 196, .06); }
.chart.has-active .bar:not(.active) { opacity: .38; }
.chart .bar.active { fill: var(--acc-lo); }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, -100%);
  background: var(--t1); color: #fff; border-radius: 9px; padding: 7px 10px 6px; min-width: 92px;
  box-shadow: 0 8px 20px -8px rgba(20, 24, 38, .5); white-space: nowrap; text-align: center;
  opacity: 0; transition: opacity .12s ease;
}
.chart-tip.show { opacity: 1; }
.chart-tip .tip-date { font-size: 11.5px; color: rgba(255, 255, 255, .7); }
.chart-tip .tip-value { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-empty { position: absolute; inset: 0 0 28px 40px; display: grid; place-items: center; color: var(--t4); font-size: 13px; pointer-events: none; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--t3); font-variant-numeric: tabular-nums; }
.chart-legend b { color: var(--t1); font-weight: 650; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--t3); padding: 10px 20px; white-space: nowrap;
  background: #F8F9FB; box-shadow: inset 0 -1px 0 var(--line), inset 0 1px 0 var(--line);
}
.table td { padding: 12px 20px; box-shadow: inset 0 -1px 0 var(--line); vertical-align: middle; }
.table tbody tr:last-child td { box-shadow: none; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:hover { background: #FAFBFD; }
.table .col-num { text-align: right; }
.table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.table .fp { font-family: var(--f-mono); font-size: 13px; color: var(--t2); letter-spacing: .02em; }
.table .ip { font-family: var(--f-mono); font-size: 13px; color: var(--t2); }
.table .muted { color: var(--t3); }
.table .time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .time small { display: inline; margin-left: 8px; font-size: 12px; color: var(--t4); }
.table .detail { color: var(--t2); min-width: 220px; line-height: 1.5; }
.table-compact td { padding: 10px 20px; }
.card > .table-wrap:first-child .table th, .card-head + .table-wrap .table th { box-shadow: inset 0 -1px 0 var(--line); }
.card-head + .table-wrap { margin-top: 14px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1; background: var(--raised); color: var(--t2);
}
.badge-accent { background: var(--acc-tint); color: var(--acc); }
.badge-success { background: var(--ok-tint); color: var(--ok); }
.badge-warning { background: var(--warn-tint); color: var(--warn); }
.badge-danger { background: var(--bad-tint); color: var(--bad); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- pager / filters ---------- */
.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 16px 20px; box-shadow: inset 0 -1px 0 var(--line); }
.toolbar .field { width: 168px; }
.toolbar .input { height: 38px; }
.toolbar .total { margin-left: auto; font-size: 13px; color: var(--t3); align-self: center; font-variant-numeric: tabular-nums; }
.toolbar .total b { color: var(--t1); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; box-shadow: inset 0 1px 0 var(--line); flex-wrap: wrap; }
.pager-info { font-size: 13px; color: var(--t3); font-variant-numeric: tabular-nums; }
.pager-pages { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--t2); font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums;
  display: inline-grid; place-items: center; transition: background-color .15s ease, color .15s ease;
}
.page-btn:hover:not(:disabled) { background: var(--raised); color: var(--t1); }
.page-btn[aria-current="page"] { background: var(--acc); color: #fff; }
.page-btn:disabled { color: var(--t4); cursor: not-allowed; }
.page-btn svg { width: 16px; height: 16px; }
.page-gap { color: var(--t4); padding: 0 4px; }
.select {
  height: 32px; padding: 0 28px 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff;
  font-size: 13px; color: var(--t2); appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--t3) 50%), linear-gradient(135deg, var(--t3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 10px) 13px; background-size: 4px 4px; background-repeat: no-repeat;
}
.select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-ring); }

/* ---------- states ---------- */
.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 20px; text-align: center; }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--raised); color: var(--t3); margin-bottom: 4px; }
.empty-icon svg { width: 24px; height: 24px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--t1); }
.empty-desc { font-size: 13px; color: var(--t3); max-width: 360px; line-height: 1.6; }
.empty .btn { margin-top: 8px; }
.state-error { margin: 16px 20px; }
.sk {
  display: block; border-radius: 6px; height: 12px;
  background: linear-gradient(90deg, var(--raised) 25%, #F6F7FA 37%, var(--raised) 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite;
}
.sk[data-w="0"] { width: 72%; }
.sk[data-w="1"] { width: 46%; }
.sk[data-w="2"] { width: 86%; }
.sk-value { height: 30px; width: 60%; border-radius: 8px; margin: 3px 0 2px; }
.sk-text { width: 45%; }
.sk-chart { height: 100%; border-radius: 10px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- key / endpoint boxes ---------- */
.kv { display: grid; gap: 14px; }
.kv-item { display: grid; gap: 6px; }
.kv-label { font-size: 13px; font-weight: 550; color: var(--t2); display: flex; align-items: center; gap: 8px; }
.kv-label .badge { height: 20px; font-size: 11px; font-family: var(--f-mono); }
.copy-box {
  display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 4px 4px 12px; border-radius: 10px;
  background: #F7F8FB; box-shadow: inset 0 0 0 1px var(--line);
}
.copy-box .value { flex: 1; min-width: 0; font-family: var(--f-mono); font-size: 13px; color: var(--t1); overflow-wrap: anywhere; line-height: 1.5; padding: 4px 0; }
.copy-box .value.masked { color: var(--t2); letter-spacing: .08em; }
.copy-box .btn { flex-shrink: 0; }
.key-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.calc { font-size: 12.5px; color: var(--t3); font-variant-numeric: tabular-nums; }
.calc b { color: var(--acc); font-weight: 650; }

/* ---------- sessions list ---------- */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 20px; box-shadow: inset 0 -1px 0 var(--line); }
.list-item:last-child { box-shadow: none; }
.list-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--raised); color: var(--t2); display: grid; place-items: center; flex-shrink: 0; }
.list-icon svg { width: 18px; height: 18px; }
.list-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-sub { font-size: 12px; color: var(--t3); line-height: 1.5; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; z-index: 100; top: 16px; right: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-pop); pointer-events: auto;
  animation: toast-in .2s var(--ease-out);
}
.toast.leaving { animation: toast-out .16s ease forwards; }
.toast svg { width: 18px; height: 18px; margin-top: 1px; }
.toast-success svg { color: var(--ok); }
.toast-error svg { color: var(--bad); }
.toast-info svg { color: var(--acc); }
.toast-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.toast-title { font-size: 14px; font-weight: 550; color: var(--t1); line-height: 1.45; }
.toast-desc { font-size: 12.5px; color: var(--t3); line-height: 1.5; overflow-wrap: anywhere; }
.toast-close { border: 0; background: none; color: var(--t4); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; margin: -2px -4px 0 0; }
.toast-close:hover { color: var(--t2); background: var(--raised); }
.toast-close svg { width: 14px; height: 14px; margin: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- dialogs ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: 16px;
  background: #fff; color: var(--t1); box-shadow: inset 0 0 0 1px var(--line), 0 24px 64px -16px rgba(20, 24, 38, .38);
  overflow: auto;
}
.dialog[open] { animation: dialog-in .2s var(--ease-out); }
.dialog::backdrop { background: rgba(20, 24, 38, .36); animation: fade-in .2s ease; }
.dialog.closing { animation: dialog-out .14s ease forwards; }
.dialog.closing::backdrop { animation: fade-out .14s ease forwards; }
.dialog-form { display: grid; }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; padding: 22px 24px 0; }
.dialog-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--acc-tint); color: var(--acc); }
.dialog-icon svg { width: 20px; height: 20px; }
.dialog-icon.danger { background: var(--bad-tint); color: var(--bad); }
.dialog-icon.warning { background: var(--warn-tint); color: var(--warn); }
.dialog-titles { display: grid; gap: 6px; padding-top: 2px; min-width: 0; }
.dialog-title { font-size: 16px; font-weight: 650; line-height: 1.4; }
.dialog-text { font-size: 13.5px; color: var(--t2); line-height: 1.65; }
.dialog-body { padding: 16px 24px 0; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 22px 24px 22px; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; }
  .sidebar {
    transform: translateX(-100%); visibility: hidden; box-shadow: var(--shadow-pop);
    transition: transform .24s var(--ease-out), visibility 0s linear .24s;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .shell.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .24s var(--ease-out), visibility 0s; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 30; background: rgba(20, 24, 38, .32);
    opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility 0s linear .2s;
  }
  .shell.drawer-open .scrim { opacity: 1; visibility: visible; transition: opacity .2s ease, visibility 0s; }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
    height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 8px;
    background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
    box-shadow: inset 0 -1px 0 var(--line);
  }
  .topbar .brand-name { font-size: 15px; }
  .topbar .brand-logo { width: 28px; height: 28px; }
  .content { padding: 18px 16px 40px; }
  .page-head { margin-bottom: 16px; min-height: 0; align-items: center; }
  .page-title { font-size: 19px; }
  .page-sub { display: none; }
  .updated { display: none; }
  .tiles { gap: 12px; margin-bottom: 12px; }
  .tile { padding: 14px 14px 14px; min-height: 112px; gap: 6px; }
  .tile-value { font-size: 24px; }
  .tile-icon { width: 26px; height: 26px; border-radius: 8px; }
  .tile-icon svg { width: 15px; height: 15px; }
  .tile-label { font-size: 12.5px; }
  .stack, .grid-2 { gap: 12px; }
  .card-head { padding: 14px 16px 0; min-height: 44px; }
  .card-head.ruled { padding-bottom: 12px; }
  .card-body { padding: 14px 16px 16px; }
  .chart { height: 200px; }
  .chart-legend { gap: 10px; }
  .chart-legend .opt { display: none; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .toolbar { padding: 14px 16px; gap: 10px; }
  .toolbar .field { width: calc(50% - 5px); }
  .toolbar .total { margin-left: auto; }
  .pager { padding: 12px 16px; }
  .list-item { padding: 12px 16px; }
  .toasts { top: calc(8px + env(safe-area-inset-top)); right: 12px; left: 12px; width: auto; }
  .auth-card { padding: 28px 22px 24px; }

  /* Tables become stacked cards. */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 10px 16px; box-shadow: inset 0 -1px 0 var(--line); }
  .table-stack tbody tr:last-child { box-shadow: none; }
  .table-stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 4px 0; box-shadow: none !important; text-align: right; }
  .table-stack td::before { content: attr(data-label); color: var(--t3); font-size: 12.5px; text-align: left; flex-shrink: 0; }
  .table-stack td.col-actions { width: 100%; justify-content: flex-end; padding-top: 8px; }
  .table-stack td.col-actions::before { content: none; }
  .table-stack td.detail { min-width: 0; }
  .table-stack td.col-empty { display: none; }

  /* Registration rows: time + version / fingerprint + IP. */
  .table-stack.table-reg tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 16px;
    grid-template-areas: "time ver" "fp ip";
  }
  .table-stack.table-reg td { display: block; padding: 0; text-align: left; min-width: 0; }
  .table-stack.table-reg td::before { content: none; }
  .table-stack.table-reg td:nth-child(1) { grid-area: time; font-size: 13.5px; }
  .table-stack.table-reg td:nth-child(2) { grid-area: fp; }
  .table-stack.table-reg td:nth-child(3) { grid-area: ip; text-align: right; }
  .table-stack.table-reg td:nth-child(4) { grid-area: ver; text-align: right; }
  .table-stack.table-reg td:nth-child(4) .badge::before { content: "版本 "; font-weight: 500; white-space: pre; }
  .table-stack.table-reg .fp, .table-stack.table-reg .ip { font-size: 12.5px; color: var(--t3); }

  /* Audit rows: action + time / detail / actor + IP. */
  .table-stack.table-audit tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 16px;
    grid-template-areas: "op time" "detail detail" "actor ip";
  }
  .table-stack.table-audit td { display: block; padding: 0; text-align: left; min-width: 0; }
  .table-stack.table-audit td::before { content: none; }
  .table-stack.table-audit td:nth-child(1) { grid-area: time; text-align: right; font-size: 12.5px; color: var(--t3); }
  .table-stack.table-audit td:nth-child(1) small { display: none; }
  .table-stack.table-audit td:nth-child(2) { grid-area: actor; font-size: 12.5px; color: var(--t3); }
  .table-stack.table-audit td:nth-child(3) { grid-area: op; }
  .table-stack.table-audit td:nth-child(4) { grid-area: detail; font-size: 13.5px; color: var(--t1); }
  .table-stack.table-audit td:nth-child(5) { grid-area: ip; text-align: right; }
  .table-stack.table-audit .ip { font-size: 12.5px; color: var(--t3); }
}
@media (max-width: 380px) {
  .tile-value { font-size: 22px; }
  .toolbar .field { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  .btn:active:not(:disabled) { transform: none; }
  .sk { animation: none; }
}
