/* Gọn panel — one stylesheet. Every color, radius and shadow is a token on
   :root; dark tokens apply via prefers-color-scheme unless [data-theme=light],
   or always with [data-theme=dark]. Spacing scale: 4 / 8 / 12 / 16 / 24 / 32. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs: 14px; --fs-sm: 13px; --fs-xs: 12px; --fs-lg: 16px; --fs-xl: 20px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-sm: 4px; --r: 6px; --r-lg: 10px; --r-pill: 999px;
  --sidebar-w: 216px; --content-max: 1200px; --topbar-h: 52px;
  --ctl-h: 32px; --ctl-h-sm: 26px;
  --ease: cubic-bezier(.2, .7, .3, 1);

  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --surface-3: #e6e9ec;
  --sidebar-bg: #fbfbfc;
  --border: #dfe3e7;
  --border-strong: #c5ccd3;
  --text: #182026;
  --text-muted: #56616c;
  --text-faint: #6f7a85;
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-soft: #e0f2ef;
  --accent-text: #0c6b63;
  --on-accent: #ffffff;
  --ok: #15803d;      --ok-soft: #e3f5e8;
  --warn: #a35a00;    --warn-soft: #fdf1dc;
  --error: #c0262d;   --error-soft: #fde8e8;
  --info: #1d5fd6;    --info-soft: #e5eefc;
  --muted: #6b7682;   --muted-soft: #eceff2;
  --focus: #0f766e;
  --overlay: rgba(15, 22, 28, .45);
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, .06);
  --shadow: 0 1px 3px rgba(16, 24, 32, .08), 0 4px 12px rgba(16, 24, 32, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 32, .18), 0 2px 6px rgba(16, 24, 32, .08);
  --code-bg: #f3f5f7;
  --skeleton: #e8ebee;
  --skeleton-hi: #f4f6f7;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1215; --surface: #151a1e; --surface-2: #1b2126; --surface-3: #232a30;
    --sidebar-bg: #11161a; --border: #283037; --border-strong: #3a444d;
    --text: #e4e9ec; --text-muted: #9ba7b1; --text-faint: #87939d;
    --accent: #2cc4b0; --accent-hover: #4fd6c4; --accent-soft: #11302d; --accent-text: #4fd6c4; --on-accent: #062621;
    --ok: #4ccf7c; --ok-soft: #12291b; --warn: #f0b03e; --warn-soft: #2e2410;
    --error: #ff7a7a; --error-soft: #341617; --info: #6aa5ff; --info-soft: #14233b;
    --muted: #8d99a3; --muted-soft: #20272d; --focus: #4fd6c4; --overlay: rgba(0, 0, 0, .6);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .4);
    --code-bg: #10151a; --skeleton: #20272d; --skeleton-hi: #283037;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1215; --surface: #151a1e; --surface-2: #1b2126; --surface-3: #232a30;
  --sidebar-bg: #11161a; --border: #283037; --border-strong: #3a444d;
  --text: #e4e9ec; --text-muted: #9ba7b1; --text-faint: #87939d;
  --accent: #2cc4b0; --accent-hover: #4fd6c4; --accent-soft: #11302d; --accent-text: #4fd6c4; --on-accent: #062621;
  --ok: #4ccf7c; --ok-soft: #12291b; --warn: #f0b03e; --warn-soft: #2e2410;
  --error: #ff7a7a; --error-soft: #341617; --info: #6aa5ff; --info-soft: #14233b;
  --muted: #8d99a3; --muted-soft: #20272d; --focus: #4fd6c4; --overlay: rgba(0, 0, 0, .6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .4);
  --code-bg: #10151a; --skeleton: #20272d; --skeleton-hi: #283037;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.45;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: var(--fs-xl); letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs); }
p { margin: 0 0 var(--s2); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s4); }
.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.noscript { padding: var(--s5); }

.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; stroke: currentColor; fill: none; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 32px; height: 32px; }

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); animation: pulse 1.2s ease-in-out infinite; }
.boot-mark .icon { width: 28px; height: 28px; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.96); } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--border); padding: var(--s3) var(--s2);
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2) var(--s3); color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.brand-mark .icon { width: 20px; height: 20px; stroke-width: 2.4; }
.brand-host { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.nav { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding: var(--s1) 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r);
  color: var(--text-muted); font-weight: 500; white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item:focus-visible { outline-offset: -2px; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-item[aria-current="page"] .icon { color: var(--accent-text); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: var(--s2); margin-top: var(--s2); }
.user-btn { width: 100%; justify-content: flex-start; color: var(--text-muted); }
.user-btn .avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--text-muted); display: grid; place-items: center; }
.user-btn .avatar .icon { width: 14px; height: 14px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s5) var(--s5) var(--s6); flex: 1 1 auto; }
.content.wide { max-width: none; }
.drawer-backdrop { display: none; }

@media (max-width: 760px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; gap: var(--s2); position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h); padding: 0 var(--s2); padding-top: env(safe-area-inset-top);
    box-sizing: content-box; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; font-size: 16px; }
  .topbar-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(82vw, 280px);
    transform: translateX(-102%); transition: transform .22s var(--ease), visibility .22s; visibility: hidden;
    padding-top: calc(var(--s3) + env(safe-area-inset-top)); padding-bottom: calc(var(--s2) + env(safe-area-inset-bottom));
  }
  .shell.drawer-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .table .col-hide-sm { display: none; }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .shell.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  .nav-item { height: 40px; }
  .content { padding: var(--s4) var(--s4) var(--s5); }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.page-head-text { flex: 1 1 260px; min-width: 0; }
.page-head-sub { color: var(--text-muted); margin-top: 2px; }
.page-head-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.page-head .back { margin-left: -6px; margin-bottom: 2px; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong); --btn-hover: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ctl-h); padding: 0 12px; border-radius: var(--r); border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg); font: inherit; font-weight: 500; line-height: 1;
  cursor: pointer; white-space: nowrap; user-select: none; position: relative; text-decoration: none;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bd: var(--accent); --btn-hover: var(--accent-hover); }
.btn-primary:hover { border-color: var(--accent-hover); }
.btn-danger { --btn-bg: var(--error); --btn-fg: #fff; --btn-bd: var(--error); --btn-hover: var(--error); }
.btn-danger:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .btn-danger { --btn-fg: #2a0b0c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { --btn-fg: #2a0b0c; } }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-ghost.btn-danger-text, .btn-danger-text { color: var(--error); }
.btn-sm { height: var(--ctl-h-sm); padding: 0 8px; font-size: var(--fs-sm); border-radius: var(--r-sm); gap: 4px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 15px; }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-sm.btn-icon { width: var(--ctl-h-sm); }
.btn-lg.btn-icon { width: 40px; }
.btn-block { width: 100%; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.btn-group .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); z-index: 1; border-color: var(--accent); }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--s3); }
.form-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s1); }
.form-row { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-weight: 500; font-size: var(--fs-sm); color: var(--text); }
.field-label .req { color: var(--error); margin-left: 2px; }
.field-help { font-size: var(--fs-xs); color: var(--text-muted); }
.field-error { font-size: var(--fs-xs); color: var(--error); display: flex; gap: 4px; align-items: flex-start; }
.field-error:empty { display: none; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl-h); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: inherit; min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 80px; padding: 7px 10px; resize: vertical; line-height: 1.45; }
.textarea.mono, .input.mono { font-family: var(--mono); font-size: 13px; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--error); }
.field.has-error .input:focus, .field.has-error .textarea:focus { box-shadow: 0 0 0 3px var(--error-soft); }
.input-sm { height: var(--ctl-h-sm); font-size: var(--fs-sm); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { flex: 1; }
.input-wrap .input-icon { position: absolute; left: 9px; color: var(--text-faint); pointer-events: none; width: 16px; height: 16px; }
.input-wrap .input-icon ~ .input { padding-left: 32px; }
.input-wrap .input-addon { position: absolute; right: 3px; }
.input-wrap.has-addon .input { padding-right: 36px; }
.input-code { font-family: var(--mono); font-size: 18px; letter-spacing: .3em; text-align: center; height: 42px; }
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; user-select: none; line-height: 1.35; }
.check input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin-top: 1px; cursor: pointer; }
.check-text small { display: block; color: var(--text-muted); font-size: var(--fs-xs); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; transition: background-color .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.strength { display: flex; gap: 4px; margin-top: 2px; }
.strength span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.strength[data-level="1"] span:nth-child(-n+1) { background: var(--error); }
.strength[data-level="2"] span:nth-child(-n+2) { background: var(--warn); }
.strength[data-level="3"] span:nth-child(-n+3) { background: var(--ok); }
.strength[data-level="4"] span { background: var(--ok); }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r); border: 1px solid transparent; background: var(--info-soft); color: var(--text); font-size: var(--fs-sm); }
.alert > .icon { color: var(--info); margin-top: 1px; }
.alert-title { font-weight: 600; display: block; margin-bottom: 1px; }
.alert-body { min-width: 0; flex: 1; }
.alert-body > :last-child { margin-bottom: 0; }
.alert-ok { background: var(--ok-soft); } .alert-ok > .icon { color: var(--ok); }
.alert-warn { background: var(--warn-soft); } .alert-warn > .icon { color: var(--warn); }
.alert-error { background: var(--error-soft); } .alert-error > .icon { color: var(--error); }

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--s2); padding: 12px var(--s4); border-bottom: 1px solid var(--border); min-height: 48px; flex-wrap: wrap; }
.card-title { font-size: var(--fs); font-weight: 600; flex: 1 1 auto; min-width: 0; }
.card-sub { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 400; margin-top: 1px; }
.card-actions { display: flex; gap: var(--s1); align-items: center; }
.card-body { padding: var(--s4); }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px var(--s4); border-top: 1px solid var(--border); display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; }
.card > .table-wrap { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.section-title { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 0 0 var(--s2); }

/* ---------- badges & dots ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--muted-soft); color: var(--muted);
}
.badge .icon { width: 12px; height: 12px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.dot-wrap { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-error { background: var(--error); } .dot-info { background: var(--info); }
.dot-pulse { box-shadow: 0 0 0 0 currentColor; animation: dotpulse 1.8s infinite; }
.dot-ok.dot-pulse { color: var(--ok); }
@keyframes dotpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 50%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); max-width: 100%; -webkit-overflow-scrolling: touch; }
.table-wrap.scroll-y { max-height: var(--table-max-h, 520px); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th, .table td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; font-size: var(--fs-xs);
  color: var(--text-muted); white-space: nowrap; text-transform: none; letter-spacing: .01em; height: 34px;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tr.is-selected td, .table tr.is-current td { background: var(--accent-soft); }
.table tr.clickable { cursor: pointer; }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; padding-top: 3px; padding-bottom: 3px; }
.table .col-actions .row { flex-wrap: nowrap; justify-content: flex-end; gap: 2px; }
.table .cell-mono { font-family: var(--mono); font-size: 12.5px; }
.table .cell-muted { color: var(--text-muted); }
.table .cell-truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-sm); }
.th-sort:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.th-sort .icon { width: 12px; height: 12px; opacity: 0; transition: opacity .1s; }
.th-sort:hover .icon { opacity: .5; }
th[aria-sort="ascending"] .th-sort .icon, th[aria-sort="descending"] .th-sort .icon { opacity: 1; color: var(--accent-text); }
th[aria-sort="ascending"] .th-sort { color: var(--text); }
th[aria-sort="descending"] .th-sort { color: var(--text); }
.table-empty td { padding: 0 !important; }
.table-empty:hover td { background: none !important; }
.table-foot { display: flex; justify-content: center; padding: var(--s3); }
.table-compact th, .table-compact td { padding: 4px 10px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--s4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; margin-bottom: -1px; color: var(--text-muted);
  border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tab:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab .badge { height: 17px; padding: 0 5px; }
.tab .icon { width: 16px; height: 16px; }

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--s4); background: var(--overlay); animation: fade .15s ease-out; overflow-y: auto; }
.modal {
  width: 100%; max-width: 460px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); display: flex; flex-direction: column; max-height: calc(100dvh - 32px);
  animation: pop .18s var(--ease);
}
.modal-sm { max-width: 380px; } .modal-lg { max-width: 680px; } .modal-xl { max-width: 960px; }
.modal-head { display: flex; align-items: center; gap: var(--s2); padding: 14px var(--s4) 4px; }
.modal-title { font-size: var(--fs-lg); font-weight: 600; flex: 1; }
.modal-body { padding: var(--s2) var(--s4) var(--s4); overflow-y: auto; }
.modal-body > p:last-child { margin-bottom: 0; }
.modal-foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: 12px var(--s4); border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--info-soft); color: var(--info); flex: none; }
.modal-icon.danger { background: var(--error-soft); color: var(--error); }
.modal-icon.accent { background: var(--accent-soft); color: var(--accent-text); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (max-width: 520px) {
  .modal-root { place-items: end center; padding: 0; }
  .modal { max-width: none !important; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation: slideup .22s var(--ease); }
  .modal-foot .btn { flex: 1 1 0; }
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 200; right: var(--s4); bottom: var(--s4); display: flex; flex-direction: column-reverse; gap: var(--s2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 10px 10px 12px; border-radius: var(--r);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--info);
  box-shadow: var(--shadow-lg); pointer-events: auto; animation: toastin .2s var(--ease); font-size: var(--fs-sm);
}
.toast > .icon { color: var(--info); margin-top: 1px; }
.toast-ok { border-left-color: var(--ok); } .toast-ok > .icon { color: var(--ok); }
.toast-error { border-left-color: var(--error); } .toast-error > .icon { color: var(--error); }
.toast-warn { border-left-color: var(--warn); } .toast-warn > .icon { color: var(--warn); }
.toast-msg { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.toast .btn { margin: -4px -2px -4px 0; }
.toast.leaving { animation: toastout .18s ease-in forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastout { to { opacity: 0; transform: translateX(16px); } }
@media (max-width: 760px) { .toasts { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--s3) + env(safe-area-inset-bottom)); } }

/* ---------- dropdown ---------- */
.menu {
  position: fixed; z-index: 150; min-width: 180px; max-width: 280px; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); animation: fade .1s;
}
.menu-item {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 0 10px; height: 32px; border: 0; background: none;
  font: inherit; color: var(--text); border-radius: var(--r-sm); cursor: pointer; text-align: left; white-space: nowrap;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--text-muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--error); } .menu-item.danger .icon { color: var(--error); }
.menu-item[aria-checked="true"] { color: var(--accent-text); font-weight: 500; }
.menu-item[aria-checked="true"] .icon { color: var(--accent-text); }
.menu-item:disabled { opacity: .5; cursor: not-allowed; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-label { padding: 6px 10px 2px; font-size: var(--fs-xs); color: var(--text-faint); font-weight: 600; }

/* ---------- empty, skeleton, spinner, progress ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s6) var(--s4); color: var(--text-muted); }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-faint); margin-bottom: var(--s1); }
.empty-icon .icon { width: 22px; height: 22px; }
.empty-title { font-weight: 600; color: var(--text); font-size: 15px; }
.empty-text { max-width: 420px; margin: 0; }
.empty.compact { padding: var(--s5) var(--s3); }
.skeleton { display: block; height: 12px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 50%, var(--skeleton) 100%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.skeleton-stack { display: flex; flex-direction: column; gap: 10px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; flex: none; }
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }
.loading-block { display: flex; gap: 10px; align-items: center; justify-content: center; padding: var(--s6); color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.progress-head { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-muted); gap: var(--s2); }
.progress-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 3px; background: var(--accent); transition: width .4s var(--ease); }
.progress-ok .progress-bar { background: var(--ok); } .progress-warn .progress-bar { background: var(--warn); }
.progress-error .progress-bar { background: var(--error); } .progress-info .progress-bar { background: var(--info); }
.progress.indeterminate .progress-bar { width: 35%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* ---------- code, kv, stat ---------- */
.code { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r); }
.code pre { margin: 0; padding: 10px 12px; overflow: auto; font-size: 12.5px; line-height: 1.55; max-height: var(--code-max-h, 420px); color: var(--text); }
.code.wrap pre { white-space: pre-wrap; word-break: break-word; }
.code .copy-btn { position: absolute; top: 5px; right: 5px; background: var(--surface); }
.code.has-copy pre { padding-right: 44px; }
.code-inline { background: var(--code-bg); border: 1px solid var(--border); padding: 1px 5px; border-radius: var(--r-sm); font-size: 12.5px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 6px var(--s4); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; } }
.stat { padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.stat-label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-label .icon { width: 14px; height: 14px; }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; margin-left: 2px; }
.stat-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.stat-ok .stat-value { color: var(--ok); } .stat-warn .stat-value { color: var(--warn); } .stat-error .stat-value { color: var(--error); }
.stat .spark { margin-top: 6px; }

/* ---------- charts ---------- */
.spark { display: block; width: 100%; overflow: visible; color: var(--accent); }
.spark-ok { color: var(--ok); } .spark-warn { color: var(--warn); } .spark-error { color: var(--error); } .spark-info { color: var(--info); }
.spark .line { fill: none; stroke: currentColor; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark .area { fill: currentColor; opacity: .14; stroke: none; }
.chart { position: relative; color: var(--accent); }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .axis-label { font-size: 11px; fill: var(--text-faint); font-family: var(--font); }
.chart .cursor-line { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.chart .series-1 { color: var(--accent); } .chart .series-2 { color: var(--info); } .chart .series-3 { color: var(--warn); }
.chart-tip { position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); box-shadow: var(--shadow); padding: 4px 8px; font-size: var(--fs-xs); white-space: nowrap; transform: translateX(-50%); z-index: 2; }
.chart-tip b { font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: var(--s3); font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; background: currentColor; margin-right: 5px; vertical-align: middle; }

/* ---------- copy, toolbar, misc ---------- */
.toolbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-bottom: var(--s3); }
.toolbar > .field { flex: 0 1 auto; }
.toolbar > .field:first-child { flex: 1 1 220px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 150px; }
.toolbar .field-error { display: none; }
.divider { height: 1px; background: var(--border); margin: var(--s4) 0; border: 0; }
.secret { display: flex; gap: var(--s2); align-items: center; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 6px 6px 12px; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.secret > span { flex: 1; min-width: 0; letter-spacing: .04em; }
.timeago { white-space: nowrap; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--surface-2); }
.placeholder-page .empty { padding: 64px var(--s4); }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--s5) var(--s4); gap: var(--s4);
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: var(--s5); }
.auth-card.wide { max-width: 480px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s4); }
.auth-brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.auth-brand .brand-mark .icon { width: 24px; height: 24px; }
.auth-brand b { font-size: 20px; letter-spacing: -.02em; }
.auth-title { font-size: 18px; margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); margin-bottom: var(--s4); }
.auth-foot { color: var(--text-faint); font-size: var(--fs-xs); text-align: center; display: flex; gap: var(--s3); align-items: center; }
.auth-foot .btn { color: var(--text-faint); }
.steps { display: flex; gap: 6px; margin-bottom: var(--s4); }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); }
.steps span.done { background: var(--accent); }
.steps span.current { background: var(--accent); opacity: .5; }
.step-label { font-size: var(--fs-xs); color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.qr { display: grid; place-items: center; padding: var(--s3); background: #fff; border-radius: var(--r); border: 1px solid var(--border); width: max-content; margin: 0 auto var(--s3); }
.qr img { display: block; width: 184px; height: 184px; image-rendering: pixelated; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; padding: 12px 16px; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r); font-family: var(--mono); font-size: 14px; list-style: none; margin: 0; counter-reset: c; }
.codes li { counter-increment: c; white-space: nowrap; }
.codes li::before { content: counter(c) "."; color: var(--text-faint); display: inline-block; width: 2.2em; font-size: 12px; }
@media (max-width: 380px) { .codes { grid-template-columns: 1fr; } }
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- kit showcase ---------- */
.kit-section { scroll-margin-top: 70px; }
.kit-demo { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.kit-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.kit-swatch { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; font-size: var(--fs-xs); }
.kit-swatch i { display: block; height: 32px; }
.kit-swatch span { display: block; padding: 4px 6px; color: var(--text-muted); font-family: var(--mono); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
