/* ==========================================================================
   Combo Gateway · admin design system (spec §13)
   Single stylesheet, no build step, no external fonts / CDN.
   Light is the default theme; [data-theme="dark"] overrides the tokens.
   ========================================================================== */

/* --- Design tokens: light (default) -------------------------------------- */
:root {
  /* colour */
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafb;
  --color-surface-3: #eef2f4;
  --color-border: #e2e7ec;
  --color-border-strong: #cbd4dc;
  --color-text: #161a1f;
  --color-text-soft: #4a5560;
  --color-text-muted: #7a8794;
  --color-accent: #0d9488;
  --color-accent-hover: #0b7f75;
  --color-accent-soft: #d5f0ec;
  --color-accent-fg: #ffffff;
  --color-chart-line: #d97706;
  --color-success: #15803d;
  --color-success-soft: #dcf5e4;
  --color-warning: #b45309;
  --color-warning-soft: #fbeed6;
  --color-danger: #c0392b;
  --color-danger-soft: #fbe2df;
  --color-info: #1d4ed8;
  --color-info-soft: #dfe8fd;

  /* spacing scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* elevation */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .18);

  /* type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --text-xs: 11.5px;
  --text-sm: 12.5px;
  --text-base: 13.5px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;

  --sidebar-w: 16rem;
  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
}

/* --- Design tokens: dark -------------------------------------------------- */
[data-theme="dark"] {
  --color-bg: #0d1015;
  --color-surface: #151a21;
  --color-surface-2: #1a2029;
  --color-surface-3: #212933;
  --color-border: #262e39;
  --color-border-strong: #38424f;
  --color-text: #e7ebf0;
  --color-text-soft: #b3bcc7;
  --color-text-muted: #808c9a;
  --color-accent: #2dd4bf;
  --color-accent-hover: #5eead4;
  --color-accent-soft: #123b37;
  --color-accent-fg: #04211e;
  --color-chart-line: #fbbf24;
  --color-success: #4ade80;
  --color-success-soft: #10321f;
  --color-warning: #fbbf24;
  --color-warning-soft: #3a2c0d;
  --color-danger: #f87171;
  --color-danger-soft: #3a1a1a;
  --color-info: #7aa2f7;
  --color-info-soft: #16233d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
}

/* --- Reset / base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
h4 { font-size: var(--text-sm); color: var(--color-text-soft); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); }
small { font-size: var(--text-xs); }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
.num, .kpi-value, td.num, th.num, .chart-legend { font-variant-numeric: tabular-nums; }
::selection { background: var(--color-accent-soft); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --- Layout --------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-3);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2); }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--radius);
  background: linear-gradient(140deg, var(--color-accent), var(--color-accent-hover));
  color: var(--color-accent-fg);
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: var(--text-base); letter-spacing: -.01em; }
.brand-text small { color: var(--color-text-muted); font-size: var(--text-xs); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--color-text-soft);
  text-decoration: none;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item:hover { background: var(--color-surface-3); color: var(--color-text); }
.nav-item.active { background: var(--color-accent); color: var(--color-accent-fg); box-shadow: var(--shadow-sm); }
.nav-item.active svg { opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-muted); }
.dot.ok { background: var(--color-success); box-shadow: 0 0 0 3px var(--color-success-soft); }
.dot.bad { background: var(--color-danger); box-shadow: 0 0 0 3px var(--color-danger-soft); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }
.user-name { color: var(--color-text-soft); font-size: var(--text-sm); }
.view { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  font: inherit; font-weight: 550;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:hover { background: var(--color-surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-fg); }
.btn.primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn.ghost, .btn-ghost { background: transparent; border-color: transparent; color: var(--color-text-soft); }
.btn.ghost:hover, .btn-ghost:hover { background: var(--color-surface-3); color: var(--color-text); }
.btn.danger { color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 45%, var(--color-border)); }
.btn.danger:hover { background: var(--color-danger-soft); }
.btn.sm { padding: 3px var(--space-2); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent; color: var(--color-text-soft); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--color-surface-3); color: var(--color-text); }
.icon-btn svg { width: 19px; height: 19px; }
.only-mobile { display: none; }
[data-theme="light"] .icon-moon, :root:not([data-theme="dark"]) .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* --- Cards / grid --------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head h4 { margin: 0; }
.card-sub { color: var(--color-text-muted); font-size: var(--text-sm); }
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.kpi { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--color-text-muted); }
.soft { color: var(--color-text-soft); }

/* --- KPI ------------------------------------------------------------------ */
.kpi {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-1);
}
.kpi-label { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: var(--text-2xl); font-weight: 680; letter-spacing: -.02em; }
.kpi-value.sm { font-size: var(--text-xl); }
.kpi-foot { font-size: var(--text-xs); color: var(--color-text-muted); }
.kpi.accent { background: linear-gradient(150deg, var(--color-accent-soft), var(--color-surface-2)); }

/* --- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field > label, .label { font-size: var(--text-sm); font-weight: 550; color: var(--color-text-soft); }
.field .hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.input, .select, textarea.input {
  font: inherit;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
textarea.input { min-height: 84px; resize: vertical; font-family: var(--font-mono); font-size: var(--text-sm); }
.select { appearance: none; padding-right: var(--space-8); background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: right 14px center, right 9px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.inline-field { display: flex; align-items: center; gap: var(--space-2); }
input[type="number"].input { font-variant-numeric: tabular-nums; }

/* --- Toggle --------------------------------------------------------------- */
.toggle { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  width: 40px; height: 22px; border-radius: var(--radius-pill);
  background: var(--color-border-strong);
  position: relative; transition: background var(--transition);
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}
.toggle input:checked + .track { background: var(--color-accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--color-accent-soft); }
.toggle input:disabled + .track { opacity: .5; }
.toggle .toggle-text { font-size: var(--text-sm); color: var(--color-text-soft); }

/* --- Badges / tags -------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600;
  background: var(--color-surface-3); color: var(--color-text-soft);
  white-space: nowrap;
}
.badge.ok, .badge.success { background: var(--color-success-soft); color: var(--color-success); }
.badge.danger, .badge.error { background: var(--color-danger-soft); color: var(--color-danger); }
.badge.warn, .badge.warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.info { background: var(--color-info-soft); color: var(--color-info); }
.badge.accent { background: var(--color-accent-soft); color: var(--color-accent); }
.badge.mono { font-family: var(--font-mono); }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* --- Level bar (probe states) --------------------------------------------- */
.level-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.level-bar .lvl { font-family: var(--font-mono); }
.badge.lvl-ok { background: var(--color-success-soft); color: var(--color-success); }
.badge.lvl-dead { background: var(--color-danger-soft); color: var(--color-danger); }
.badge.lvl-unknown { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.lvl-base { outline: 1px dashed currentColor; outline-offset: -1px; font-weight: 700; }
/* blocked level chip: muted + struck through. The state colour class (lvl-ok/
   lvl-dead/lvl-unknown) is retained for the title but overridden here so a
   blocked 活档 reads as "excluded". */
.badge.lvl-blocked {
  background: var(--color-surface-3);
  color: var(--color-text-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
/* clickable 活(supported) level chips toggle the 屏蔽 blocklist */
.badge.lvl-toggle { cursor: pointer; }
.badge.lvl-toggle:hover { box-shadow: 0 0 0 2px var(--color-accent-soft); }
/* one 档位栏 chip = state badge + a small per-level ⟳ re-probe button */
.lvl-chip { display: inline-flex; align-items: center; gap: var(--space-1); }
.lvl-reprobe {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: transparent; color: var(--color-text-muted);
  font-size: 11px; line-height: 1; cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.lvl-reprobe:hover { color: var(--color-accent); background: var(--color-accent-soft); }
.lvl-reprobe:disabled { opacity: .45; cursor: default; }
.badge.lvl-probing { opacity: .7; font-style: italic; text-decoration: none; }
/* legend: explains baseline + the 活/死/未知 colour mapping once per page */
.level-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.level-legend .legend-title { font-weight: 650; color: var(--color-text-soft); text-transform: uppercase; letter-spacing: .06em; }
.level-legend .legend-item { display: inline-flex; align-items: center; gap: var(--space-2); }
.level-legend .legend-text { color: var(--color-text-muted); }
/* level cell stacks the 档位栏 chips above the probe_error summary line */
.level-cell { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.probe-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Connectivity test result --------------------------------------------- */
.test-result { font-size: var(--text-sm); color: var(--color-text-muted); word-break: break-word; }
.test-result.ok { color: var(--color-success); }
.test-result.err { color: var(--color-danger); }

/* --- Fetched model picker (multi-select) ---------------------------------- */
.fetch-state { font-size: var(--text-sm); color: var(--color-text-muted); }
.fetch-state.err { color: var(--color-danger); }
.model-pick-list {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  max-height: 220px; overflow-y: auto;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
}
.pick-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  cursor: pointer; font-size: var(--text-sm);
}
.pick-item input { accent-color: var(--color-accent); }

/* --- Segmented control ---------------------------------------------------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--color-surface-3); border-radius: var(--radius); }
.segmented button {
  font: inherit; font-size: var(--text-sm); font-weight: 550;
  border: none; background: transparent; color: var(--color-text-soft);
  padding: 4px var(--space-3); border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.segmented button.active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: var(--color-surface-2); }
.table th.num, .table td.num { text-align: right; }
.table .empty-row td { text-align: center; color: var(--color-text-muted); padding: var(--space-6); }

/* --- Modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 20, .55);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--space-6);
  overflow-y: auto;
  animation: fade-in 140ms ease;
}
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  margin: auto;
  animation: rise 160ms cubic-bezier(.2, .8, .2, 1);
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.modal-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --- Draggable member list ------------------------------------------------ */
.member-list { display: flex; flex-direction: column; gap: var(--space-2); }
.member-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2); border: 1px solid var(--color-border);
  border-radius: var(--radius); background: var(--color-surface-2);
}
.member-item.dragging { opacity: .45; }
.member-item.drop-target { border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent-soft); }
.drag-handle { cursor: grab; color: var(--color-text-muted); display: grid; place-items: center; }
.drag-handle:active { cursor: grabbing; }
.member-item .member-ref { flex: 1; font-family: var(--font-mono); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Chart ---------------------------------------------------------------- */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-2); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* --- Toasts / states ------------------------------------------------------ */
.toast-root { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  min-width: 220px; max-width: 360px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius); border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  box-shadow: var(--shadow-lg); font-size: var(--text-sm);
  animation: rise 160ms ease;
}
.toast.ok { border-left: 3px solid var(--color-success); }
.toast.err { border-left: 3px solid var(--color-danger); }
.state { text-align: center; color: var(--color-text-muted); padding: var(--space-8) var(--space-4); }
.state .state-title { font-weight: 600; color: var(--color-text-soft); margin-bottom: var(--space-1); }
.state.error { color: var(--color-danger); }
.skeleton { background: linear-gradient(90deg, var(--color-surface-3), var(--color-surface-2), var(--color-surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); height: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spin { width: 15px; height: 15px; border: 2px solid var(--color-border-strong); border-top-color: var(--color-accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius); font-size: var(--text-sm); }
.alert.error { background: var(--color-danger-soft); color: var(--color-danger); }
.alert.ok { background: var(--color-success-soft); color: var(--color-success); }
.alert.info { background: var(--color-info-soft); color: var(--color-info); }

/* --- Auth screen ---------------------------------------------------------- */
body.is-auth .sidebar, body.is-auth .topbar { display: none; }
body.is-auth .view { min-height: 100vh; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: var(--space-4); }
.auth-note { font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; }
.plaintext-key { font-family: var(--font-mono); font-size: var(--text-sm); word-break: break-all; padding: var(--space-3); border-radius: var(--radius); background: var(--color-accent-soft); color: var(--color-accent); border: 1px dashed var(--color-accent); }

/* --- Utilities ------------------------------------------------------------ */
.hide { display: none !important; }
.w-full { width: 100%; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.divider { height: 1px; background: var(--color-border); border: 0; margin: var(--space-2) 0; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { --sidebar-w: 13rem; }
}

@media (max-width: 640px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: 17rem; flex-basis: 17rem; height: 100vh;
    transform: translateX(-102%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10, 14, 20, .5); z-index: 50; }
  .only-mobile { display: grid; }
  .view { padding: var(--space-4); gap: var(--space-4); }
  .topbar { padding: var(--space-3) var(--space-4); }
  .grid, .grid.kpi, .grid.cards { grid-template-columns: 1fr; }

  /* tables -> stacked cards */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
    background: var(--color-surface-2);
  }
  .table.responsive tr:hover { background: var(--color-surface-2); }
  .table.responsive td { display: flex; justify-content: space-between; gap: var(--space-3); border: 0; padding: 3px 0; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--color-text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; text-align: left; }
  .table.responsive td.num { text-align: right; }
  .table.responsive .empty-row td { justify-content: center; }
  .table.responsive .empty-row td::before { content: none; }
  .modal-backdrop { padding: var(--space-3); }
  .modal-body { max-height: none; }
}
