/* BKO Mail admin console.
   Design tokens live on :root; dark mode is selected by the device unless data-theme overrides it.
   Brand: navy #0A1F44, blue #0A84FF, light #E8F1FF, slate #64748B. */

:root {
  /* Surfaces and ink */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --surface-3: #eef2f8;
  --text: #0a1f44;
  --text-2: #33415c;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --hover: rgba(10, 31, 68, 0.045);
  --overlay: rgba(6, 18, 42, 0.55);

  /* Brand accent (overridden by white-label branding through CSSOM) */
  --accent: #0a6fe8;
  --accent-text: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent) 38%, transparent);

  /* Status — always shown with an icon or label too */
  --ok: #0f7a55; --ok-soft: #e3f5ec;
  --warn: #965400; --warn-soft: #fff3df;
  --bad: #c2312a; --bad-soft: #fdecea;
  --info: #0a5fc8; --info-soft: #e8f1ff;
  --danger: var(--bad); --danger-soft: var(--bad-soft);

  /* Chart series (validated: lightness band, CVD separation, contrast) */
  --c1: #0a84ff; --c2: #c26a00; --c3: #8b5cf6;
  --grid: #e8edf4;

  /* Sidebar is navy in both themes */
  --side-bg: #0a1f44;
  --side-bg-2: #0d2654;
  --side-text: #dbe6f8;
  --side-muted: #8fa3c4;
  --side-hover: rgba(255, 255, 255, 0.07);
  --side-active: rgba(10, 132, 255, 0.22);
  --side-border: rgba(255, 255, 255, 0.08);

  /* Scales */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --r-sm: 6px; --r-md: 9px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 26px; --fs-3xl: 32px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, 0.1), 0 2px 6px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.28);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 160ms;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #061127; --surface: #0b1a36; --surface-2: #0e2042; --surface-3: #13284f;
    --text: #e8eefb; --text-2: #c3d0e6; --muted: #91a2bf;
    --border: #1b2f55; --border-strong: #2a4272; --hover: rgba(255, 255, 255, 0.05); --overlay: rgba(1, 6, 18, 0.7);
    --accent: #3d9bff; --accent-text: #03122b;
    --ok: #3ccf91; --ok-soft: rgba(60, 207, 145, 0.13);
    --warn: #f3c27a; --warn-soft: rgba(243, 194, 122, 0.13);
    --bad: #f47a73; --bad-soft: rgba(244, 122, 115, 0.14);
    --info: #6cb4ff; --info-soft: rgba(61, 155, 255, 0.15);
    --c1: #2f8ff5; --c2: #c4760e; --c3: #9a7af5; --grid: #17294d;
    --side-bg: #050e22; --side-bg-2: #08152e; --side-border: rgba(255, 255, 255, 0.06);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #061127; --surface: #0b1a36; --surface-2: #0e2042; --surface-3: #13284f;
  --text: #e8eefb; --text-2: #c3d0e6; --muted: #91a2bf;
  --border: #1b2f55; --border-strong: #2a4272; --hover: rgba(255, 255, 255, 0.05); --overlay: rgba(1, 6, 18, 0.7);
  --accent: #3d9bff; --accent-text: #03122b;
  --ok: #3ccf91; --ok-soft: rgba(60, 207, 145, 0.13);
  --warn: #f3c27a; --warn-soft: rgba(243, 194, 122, 0.13);
  --bad: #f47a73; --bad-soft: rgba(244, 122, 115, 0.14);
  --info: #6cb4ff; --info-soft: rgba(61, 155, 255, 0.15);
  --c1: #2f8ff5; --c2: #c4760e; --c3: #9a7af5; --grid: #17294d;
  --side-bg: #050e22; --side-bg-2: #08152e; --side-border: rgba(255, 255, 255, 0.06);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fs-md)/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-md); margin: var(--sp-5) 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
.sprite { display: none; }
.muted { color: var(--muted); }
.small-text { font-size: var(--fs-sm); }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.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; }
.error { color: var(--bad); margin: var(--sp-2) 0; }
.mono, code, pre, kbd { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 6px; overflow-wrap: anywhere; color: var(--text-2); }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; max-height: 60vh; line-height: 1.55; }
::selection { background: var(--accent-ring); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
[data-icon] { display: inline-flex; align-items: center; }

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

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); white-space: nowrap;
  min-height: var(--btn-h); padding: 0 var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; font-size: 13.5px; cursor: pointer; text-decoration: none; box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), filter var(--dur);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(10, 60, 140, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.solid:hover { filter: brightness(1.08); background: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { --btn-h: 34px; padding: 0 var(--sp-3); font-size: 13px; }
.btn.small .icon { width: 16px; height: 16px; }
.btn.lg { --btn-h: 44px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: default; transform: none; }
.btn[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none;
  border: 1px solid transparent; background: transparent; border-radius: var(--r-md); cursor: pointer; color: var(--text-2); text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger { color: var(--bad); }
.icon-btn.danger:hover { background: var(--bad-soft); }
.icon-btn.bordered { border-color: var(--border); background: var(--surface); }
.row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 34px; height: 34px; }
.row-actions .icon-btn .icon { width: 17px; height: 17px; }

/* ------------------------------------------------------------------ forms */
.input, .select, textarea.input {
  min-height: 40px; width: auto; min-width: 0; padding: 8px 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.select { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input::placeholder { color: var(--muted); opacity: 0.85; }
.input:hover, .select:hover { border-color: var(--muted); }
.input:focus, .select:focus, .input:focus-visible, .select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--bad-soft); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
input[type="file"] { max-width: 100%; font-size: 13px; color: var(--muted); }
input[type="file"]::file-selector-button { margin-right: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--r-md); padding: 7px 12px; cursor: pointer; font: inherit; font-weight: 550; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--sp-4); min-width: 0; }
.field > label, .field-label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .input, .field .select { width: 100%; }
.hint { font-size: var(--fs-sm); color: var(--muted); margin: 0; }
.field-error { font-size: var(--fs-sm); color: var(--bad); margin: 0; display: flex; align-items: center; gap: 6px; }
.field-error .icon { width: 14px; height: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
.check-row { display: flex; align-items: flex-start; gap: 10px; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; font-weight: 500; }
label.stacked { display: block; margin: var(--sp-3) 0; font-weight: 600; font-size: 13px; }
label.stacked .input, label.stacked .select { display: block; width: 100%; margin-top: 6px; font-weight: 400; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { width: 100%; padding-left: 38px; }
.input-group .input-icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.input-group .input-icon .icon { width: 17px; height: 17px; }
.input-group .reveal { position: absolute; right: 4px; width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: var(--r-sm); cursor: pointer; }
.input-group .reveal:hover { color: var(--text); background: var(--hover); }
.input-group:has(.reveal) .input { padding-right: 42px; }
.address-group { display: flex; align-items: stretch; }
.address-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1 1 50%; }
.address-group .select { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; flex: 1 1 50%; }
.with-suffix { position: relative; }
.with-suffix .input { padding-right: 46px; width: 100%; }
.with-suffix .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }

.search { position: relative; flex: 1 1 240px; max-width: 360px; min-width: 0; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search .input { width: 100%; padding-left: 34px; }

.strength { height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; background: var(--bad); transition: width var(--dur) var(--ease), background var(--dur); }
.strength.s2 span { background: var(--warn); }
.strength.s3 span { background: var(--ok); }

/* ------------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; color: inherit; text-decoration: none; min-width: 0; }
.brand-sub { font-weight: 600; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-full); margin-left: 2px; }
.brand-large { font-size: 34px; gap: 14px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; color: #fff; font-weight: 800; border-radius: 50%; overflow: hidden; background: none; }
.brand-large .brand-mark { width: 56px; height: 56px; font-size: 26px; }
.brand-mark .bko-mark { width: 100%; height: 100%; display: block; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; background: #fff; }
.brand-mark.has-logo { border-radius: var(--r-md); background: #fff; }
.brand-mark.branded { border-radius: var(--r-md); background: var(--accent); color: #fff; }
.bko-core { fill: #ffffff; }
.bko-chevron { fill: none; stroke: #0a84ff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .bko-core { fill: #0a1f44; }
:root[data-theme="dark"] .bko-chevron { stroke: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bko-core { fill: #0a1f44; }
  :root:not([data-theme="light"]) .bko-chevron { stroke: #ffffff; }
}
.brand-hero .bko-core, .sidebar .bko-core { fill: #0a1f44; }
.brand-hero .bko-chevron, .sidebar .bko-chevron { stroke: #ffffff; }
.brand-name { display: inline-flex; align-items: baseline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-bko { font-weight: 900; letter-spacing: -0.03em; color: var(--text); }
.wm-mail { margin-left: 0.45em; font-size: 0.62em; font-weight: 650; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.brand-hero .wm-bko, .sidebar .wm-bko { color: #fff; }
.brand-hero .wm-mail, .sidebar .wm-mail { color: rgba(232, 241, 255, 0.72); }

/* ------------------------------------------------------------------ auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art {
  position: relative; overflow: hidden; color: #fff; display: grid; place-items: center; padding: var(--sp-10);
  background:
    radial-gradient(circle at 80% 15%, rgba(10, 132, 255, 0.55), transparent 42%),
    radial-gradient(circle at 10% 90%, rgba(42, 165, 255, 0.28), transparent 45%),
    linear-gradient(155deg, #050f24, #0a1f44 52%, #0b3a8a);
}
.auth-glow { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 50% 45%, #000 20%, transparent 75%); -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 20%, transparent 75%); }
.brand-hero { position: relative; max-width: 440px; }
.brand-hero .tagline { margin: var(--sp-5) 0 var(--sp-8); font-size: 13px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(232, 241, 255, 0.85); }
.hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); }
.hero-points li { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4); border-radius: var(--r-lg); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); backdrop-filter: blur(4px); }
.hero-points li > span:first-child { width: 36px; height: 36px; border-radius: var(--r-md); background: rgba(10, 132, 255, 0.28); display: inline-grid; place-items: center; flex: none; color: #cfe5ff; }
.hero-points strong { display: block; font-size: 14.5px; margin-bottom: 2px; color: #fff; }
.hero-points li > span:last-child { font-size: 13px; color: rgba(232, 241, 255, 0.75); line-height: 1.45; }
.brand-hero .pillars { margin: var(--sp-8) 0 0; font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: rgba(232, 241, 255, 0.5); }

.auth-panel { display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.auth-top { display: flex; justify-content: flex-end; padding: var(--sp-4) var(--sp-5); }
.auth-card { margin: auto; width: 100%; max-width: 440px; padding: var(--sp-6) var(--sp-6) var(--sp-10); }
.auth-card form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-8); box-shadow: var(--shadow-md); }
.auth-card h1 { margin: 6px 0 4px; font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.auth-card form > .muted { margin-bottom: var(--sp-6); }
.eyebrow { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.auth-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin: var(--sp-4) 0 0; text-align: center; }
.auth-foot .icon { width: 14px; height: 14px; }
.mfa-field { padding: var(--sp-3); margin-left: calc(-1 * var(--sp-3)); margin-right: calc(-1 * var(--sp-3)); background: var(--accent-soft); border-radius: var(--r-md); animation: rise 0.25s var(--ease); }
.code-input { letter-spacing: 0.12em; font-family: var(--mono); }
.steps { list-style: none; display: flex; gap: var(--sp-2); padding: 0; margin: 0 0 var(--sp-5); counter-reset: step; }
.steps li { flex: 1; font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 8px; border-top: 3px solid var(--surface-3); counter-increment: step; }
.steps li::before { content: counter(step) ". "; }
.steps li.done { border-top-color: var(--ok); color: var(--ok); }
.steps li.current { border-top-color: var(--accent); color: var(--text); }

/* ------------------------------------------------------------------ alerts / banners */
.alert, .banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r-md); margin: 0 0 var(--sp-4);
  border: 1px solid transparent; font-size: 13.5px; line-height: 1.45;
}
.alert .icon, .banner .icon { margin-top: 1px; }
.banner > .spacer { flex: 1; }
.alert.ok, .banner.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.bad, .banner.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert.warn, .banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert.info, .banner.info { background: var(--info-soft); color: var(--text); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.banner.info .icon { color: var(--info); }

/* ------------------------------------------------------------------ app shell */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--side-bg), var(--side-bg-2)); color: var(--side-text); border-right: 1px solid var(--side-border);
}
.sidebar-head { display: flex; align-items: center; gap: var(--sp-2); height: var(--topbar-h); padding: 0 var(--sp-4) 0 var(--sp-5); border-bottom: 1px solid var(--side-border); flex: none; }
.sidebar-head .brand { flex: 1; }
.sidebar .brand-sub { background: rgba(10, 132, 255, 0.22); color: #cfe5ff; }
.sidebar .icon-btn { color: var(--side-text); }
.sidebar .icon-btn:hover { background: var(--side-hover); color: #fff; }
.nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-4); scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--sp-3); }
.nav-label { margin: var(--sp-3) var(--sp-3) var(--sp-1); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--side-muted); }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-md);
  color: var(--side-text); text-decoration: none; font-weight: 500; font-size: 14px; transition: background var(--dur) var(--ease), color var(--dur);
}
.nav a .icon { width: 18px; height: 18px; color: var(--side-muted); transition: color var(--dur); }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a:hover .icon { color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 650; }
.nav a.active .icon { color: #6fb6ff; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #0a84ff; }
.nav a:focus-visible { outline-color: #6fb6ff; }
.sidebar-foot { flex: none; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--side-border); }
.sidebar-foot p { margin: var(--sp-2) 0 0; color: var(--side-muted); }
.server-status { display: flex; align-items: center; gap: 10px; min-width: 0; }
.server-text { display: flex; flex-direction: column; min-width: 0; font-size: 12.5px; line-height: 1.3; }
.server-text #hostname { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-text .muted { color: var(--side-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2); }
.dot.ok { background: #3ccf91; box-shadow: 0 0 0 3px rgba(60, 207, 145, 0.22); }
.dot.bad { background: #f47a73; box-shadow: 0 0 0 3px rgba(244, 122, 115, 0.25); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(244, 122, 115, 0.08); } }

.workspace { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-6); background: color-mix(in srgb, var(--surface) 86%, transparent); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.6) blur(10px); -webkit-backdrop-filter: saturate(1.6) blur(10px);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; }
.crumb-group { color: var(--muted); white-space: nowrap; }
.crumb-sep { color: var(--border-strong); }
.crumb-sep .icon { width: 15px; height: 15px; }
.crumb-group:empty, .crumb-group:empty + .crumb-sep { display: none; }
.crumb-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 12px 4px 4px; border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface); margin-left: var(--sp-1); min-width: 0; max-width: 280px; transition: background var(--dur), border-color var(--dur); }
.user-chip:hover { background: var(--surface-2); border-color: var(--border-strong); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none; background: linear-gradient(135deg, #2aa5ff, #0a5bff); color: #fff; font-weight: 700; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
#user-name { font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { display: block; font-size: 11.5px; color: var(--muted); text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: var(--sp-6) var(--sp-8) 64px; min-width: 0; }
.main:focus { outline: none; }
.view-enter { animation: rise 0.22s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 25; opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease); }
.only-mobile { display: none !important; }

/* ------------------------------------------------------------------ page structure */
.page-head { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head h1 { margin: 0; font-size: var(--fs-2xl); font-weight: 750; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; max-width: 70ch; }
.page-head .head-text { min-width: 0; flex: 1 1 320px; }
.page-head .head-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); margin-bottom: var(--sp-5); box-shadow: var(--shadow-sm); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2, .card-head h2 { font-size: 15px; font-weight: 650; margin: 0 0 var(--sp-4); display: flex; align-items: center; gap: var(--sp-2); }
.card > h2 .icon, .card-head h2 .icon { color: var(--muted); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.card-head h2 { margin: 0; }
.card-head .sub { font-size: var(--fs-sm); color: var(--muted); font-weight: 400; }
.card.flush > .card-head { padding: var(--sp-4) var(--sp-5); margin: 0; border-bottom: 1px solid var(--border); }
.card-foot { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; padding-top: var(--sp-4); margin-top: var(--sp-4); border-top: 1px solid var(--border); }
.card.flush > .card-foot { margin: 0; padding: var(--sp-3) var(--sp-5); }
.grid { display: grid; gap: var(--sp-5); margin-bottom: var(--sp-5); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }

/* KPI stat cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.tile { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-4) var(--sp-3); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-top { display: flex; align-items: center; gap: var(--sp-2); }
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-icon { width: 32px; height: 32px; border-radius: var(--r-md); display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tile-icon .icon { width: 17px; height: 17px; }
.tile .value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 6px; overflow-wrap: anywhere; }
.tile .sub { font-size: 12px; color: var(--muted); min-height: 18px; }
.tile.t-bad .value { color: var(--bad); }
.tile.t-bad .tile-icon { background: var(--bad-soft); color: var(--bad); }
.tile.t-good .tile-icon { background: var(--ok-soft); color: var(--ok); }
.tile.t-caution .tile-icon { background: var(--warn-soft); color: var(--warn); }
.spark { display: block; width: 100%; height: 30px; margin-top: 6px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark path.area { fill: var(--accent-soft); stroke: none; }
.tile.t-bad .spark path { stroke: var(--bad); }
.tile.t-bad .spark path.area { fill: var(--bad-soft); }

/* Meters and gauges */
.meter { display: grid; grid-template-columns: 110px 1fr auto; gap: var(--sp-3); align-items: center; margin: var(--sp-3) 0; font-size: 13px; }
.meter .small-text { font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: var(--r-full); background: var(--accent); transition: width 0.5s var(--ease); }
.bar.warn span { background: #e8a400; }
.bar.high span { background: var(--bad); }
.bar.empty span { background: transparent; }
.gauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.gauge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: var(--sp-3) var(--sp-2); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.gauge-ring { position: relative; width: 84px; height: 84px; }
.gauge-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-ring .track { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.gauge-ring .value-arc { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }
.gauge.warn .value-arc { stroke: #e8a400; }
.gauge.high .value-arc { stroke: var(--bad); }
.gauge-ring strong { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }
.gauge-label { font-weight: 650; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.gauge-label .icon { width: 15px; height: 15px; color: var(--muted); }
.gauge .small-text { color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 0; margin: 0; font-size: 13.5px; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--muted); padding-right: var(--sp-4); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.counter-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: var(--sp-5); }
.counter-group h3 { margin: 0 0 var(--sp-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.counters { display: grid; gap: 0; }
.counters div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 7px 0; font-size: 13.5px; }
.counters div:last-child { border-bottom: 0; }
.counters strong { font-variant-numeric: tabular-nums; }
.counters .hot strong { color: var(--bad); }

/* Charts */
.chart-box { position: relative; }
.chart-frame { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 250px auto; column-gap: 8px; }
.chart-frame.short { grid-template-rows: 130px auto; }
.y-axis { position: relative; width: 34px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.y-axis span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.plot { position: relative; min-width: 0; }
.plot svg.chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart path.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart path.area { stroke: none; opacity: 0.1; }
.chart .s1 { stroke: var(--c1); } .chart .s2 { stroke: var(--c2); } .chart .s3 { stroke: var(--c3); }
.chart path.area.s1 { fill: var(--c1); } .chart path.area.s2 { fill: var(--c2); } .chart path.area.s3 { fill: var(--c3); }
.chart rect.bar-mark { fill: var(--c1); }
.chart rect.bar-mark.s3 { fill: var(--c3); }
.chart rect.bar-mark.dim { opacity: 0.45; }
.chart.hide-s1 .s1, .chart.hide-s2 .s2, .chart.hide-s3 .s3 { display: none; }
.x-axis { grid-column: 2; position: relative; height: 22px; font-size: 11px; color: var(--muted); }
.x-axis span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; }
.x-axis span:first-child { transform: none; }
.x-axis span:last-child { transform: translateX(-100%); }
.crosshair { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-strong); pointer-events: none; }
.chart-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--surface); transform: translate(-50%, -50%); pointer-events: none; }
.chart-dot.s1 { background: var(--c1); } .chart-dot.s2 { background: var(--c2); } .chart-dot.s3 { background: var(--c3); }
.chart-tip {
  position: absolute; top: 0; z-index: 3; pointer-events: none; min-width: 160px; padding: 9px 11px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); font-size: 12.5px;
}
.chart-tip .tip-title { font-weight: 650; margin-bottom: 4px; color: var(--text); }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.chart-tip .tip-row strong { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; color: var(--text); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; background: currentColor; }
.swatch.s1 { background: var(--c1); } .swatch.s2 { background: var(--c2); } .swatch.s3 { background: var(--c3); }
.legend { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-3); }
.legend-item { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 10px; border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.legend-item strong { font-variant-numeric: tabular-nums; color: var(--text); }
.legend-item[aria-pressed="false"] { opacity: 0.5; }
.legend-item[aria-pressed="false"] .swatch { background: transparent; border: 1.5px solid var(--muted); }
.legend em { color: var(--muted); font-style: normal; font-size: 12px; margin-left: auto; }

/* Lists (events, license) */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.event-list li:last-child { border-bottom: 0; }
.event-list .ev-who { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-list .ev-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.steps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.steps-list li { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.steps-list p { margin: 2px 0 0; font-size: 13px; }
.dns-actions { margin: var(--sp-4) 0; }
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.license-summary { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.license-summary .tile-icon { width: 42px; height: 42px; }
.license-summary strong { display: block; font-size: 16px; }

/* ------------------------------------------------------------------ tables */
.toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); }
.card.flush > .toolbar { padding: var(--sp-3) var(--sp-5); margin: 0; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.count-label { font-size: 12.5px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.table-wrap { overflow: auto; max-height: min(72vh, 860px); -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: var(--sp-5); }
.table th:last-child, .table td:last-child { padding-right: var(--sp-5); }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table .wrap { overflow-wrap: anywhere; max-width: 420px; min-width: 170px; }
.table td.num { font-variant-numeric: tabular-nums; }
.dialog .table th:first-child, .dialog .table td:first-child { padding-left: 12px; }
.dialog .table th:last-child, .dialog .table td:last-child { padding-right: 12px; }
.dialog .table-wrap { border: 1px solid var(--border); border-radius: var(--r-md); max-height: 50vh; }
.dialog .table td.wrap { min-width: 170px; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }
.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.identity .avatar { width: 32px; height: 32px; font-size: 12.5px; }
.identity .avatar.soft { background: var(--accent-soft); color: var(--accent); }
.usage { display: grid; gap: 5px; min-width: 150px; }
.log-row td { font-size: 12.5px; vertical-align: top; }
.log-fields { color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.table td.mono, .log-row .mono { white-space: nowrap; }

/* Empty states */
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--sp-10) var(--sp-5); color: var(--muted); }
.empty-state .empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: var(--sp-3); }
.empty-state .empty-icon .icon { width: 24px; height: 24px; }
.empty-state strong { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty-state p { margin: 0 0 var(--sp-4); max-width: 46ch; font-size: 13.5px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.6; text-transform: capitalize; }
.badge.plain { text-transform: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge .icon { width: 13px; height: 13px; }
.badge.dot-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.mono { font-family: var(--mono); text-transform: none; font-weight: 500; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--surface-3); border-radius: var(--r-md); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: none; background: transparent; min-height: 32px; padding: 0 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--muted); transition: background var(--dur), color var(--dur); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.toggle-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); font-size: 13px; font-weight: 550; cursor: pointer; }

.inline-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end; }
.inline-form .input, .inline-form .select { flex: 1 1 170px; }

/* DNS checks */
.checks { display: grid; gap: 10px; }
.check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; padding: 12px 14px; border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-md); background: var(--surface); }
.check .status { grid-row: 1 / 4; }
.check .status .icon { width: 22px; height: 22px; }
.check.pass { border-left-color: var(--ok); } .check.pass .status { color: var(--ok); }
.check.fail { border-left-color: var(--bad); } .check.fail .status { color: var(--bad); }
.check.warn { border-left-color: #e8a400; } .check.warn .status { color: #e8a400; }
.check.info { border-left-color: var(--info); } .check.info .status { color: var(--info); }
.check .title { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check .detail { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; display: grid; gap: 4px; }
.record-value { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.record-value code { flex: 1; min-width: 0; }

.qr { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-3); }
.qr img { width: 200px; height: 200px; background: #fff; border-radius: var(--r-md); padding: 8px; border: 1px solid var(--border); }
.qr > div { flex: 1 1 200px; min-width: 0; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; font-family: var(--mono); font-size: 15px; padding: var(--sp-4); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-md); }

/* Account profile */
.profile { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.profile h2 { margin: 0 0 4px; font-size: 18px; }
.profile .badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* Skeletons */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--r-md); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); animation: shimmer 1.3s infinite; }
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); } }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-title { height: 30px; width: 260px; max-width: 70%; margin-bottom: 10px; }
.sk-line { height: 14px; width: 420px; max-width: 90%; margin-bottom: var(--sp-6); }
.sk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.sk-tile { height: 112px; border-radius: var(--r-lg); }
.sk-card { height: 280px; border-radius: var(--r-lg); }

/* ------------------------------------------------------------------ dialog */
.dialog {
  border: 1px solid var(--border); border-radius: var(--r-xl); padding: 0; width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: pop 0.2s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog.wide { width: min(900px, calc(100vw - 24px)); }
.dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dialog-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3) var(--sp-6); }
.dialog-head h2 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dialog-icon { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--bad-soft); color: var(--bad); flex: none; }
.dialog-body { padding: var(--sp-1) var(--sp-6) var(--sp-2); overflow-y: auto; min-height: 0; }
.dialog-body > p:last-child { margin-bottom: 0; }
.dialog > form > .alert { margin: var(--sp-2) var(--sp-6) 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); margin-top: var(--sp-3); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); flex-wrap: wrap; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; width: 380px; max-width: 100%;
  padding: 12px 12px 12px 14px; border-radius: var(--r-lg); background: #0f1c36; color: #f1f5fd; box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13.5px; animation: toast-in 0.25s var(--ease);
}
.toast > span { flex: 1; padding-top: 1px; overflow-wrap: anywhere; }
.toast .t-icon { color: #6fb6ff; flex: none; margin-top: 1px; }
.toast.ok .t-icon { color: #3ccf91; }
.toast.bad .t-icon { color: #f47a73; }
.toast .icon-btn { width: 28px; height: 28px; color: #c3d0e6; margin: -4px -4px -4px 0; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.license-banner {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: min(440px, calc(100vw - 32px)); display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 12px 12px 14px; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); background: var(--surface); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); border-left: 4px solid var(--warn); font-size: 13.5px;
}
.license-banner > div { color: var(--text); flex: 1; }
.license-banner > .icon { margin-top: 2px; }
.license-banner.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); border-left-color: var(--bad); }
.license-banner a { color: var(--accent); font-weight: 700; }
.license-banner .icon-btn { width: 28px; height: 28px; color: var(--muted); margin: -4px -4px 0 0; }
.app:has(~ .toasts:not(:empty)) .license-banner { visibility: hidden; }

/* ------------------------------------------------------------------ branding */
.color-row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.color-row input[type=color] { width: 52px; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 3px; background: var(--surface); cursor: pointer; }
.logo-preview { width: 64px; height: 64px; border-radius: var(--r-lg); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; background: #fff; flex: none; }
.logo-preview img { max-width: 100%; max-height: 100%; }
.brand-preview { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--bg); }
.bp-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--side-bg); color: #fff; font-weight: 750; }
.bp-bar .brand-mark { width: 30px; height: 30px; }
.bp-body { padding: var(--sp-4); display: grid; gap: var(--sp-3); }
.bp-line { height: 10px; border-radius: var(--r-full); background: var(--surface-3); }
.bp-line.short { width: 60%; }
.bp-row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.bp-button { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: var(--r-md); color: #fff; font-weight: 650; font-size: 13px; }
.bp-link { font-weight: 600; font-size: 13px; }
.bp-chip { display: inline-flex; padding: 3px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 650; }
textarea.license-input { width: 100%; min-height: 150px; font-family: var(--mono); font-size: 12px; resize: vertical; line-height: 1.5; }
.dropzone { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3); margin-top: var(--sp-3); border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .grid.main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .only-mobile { display: inline-flex !important; }
  .hide-mobile { display: none !important; }
  .sidebar { transform: translateX(-102%); transition: transform 0.24s var(--ease); box-shadow: none; width: min(var(--sidebar-w), 86vw); }
  .app.menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.menu-open .backdrop { opacity: 1; pointer-events: auto; }
  .workspace { margin-left: 0; }
  .topbar { padding: 0 var(--sp-3) 0 var(--sp-2); }
  .main { padding: var(--sp-5) var(--sp-5) 56px; }
  .icon-btn { width: 40px; height: 40px; }
  .row-actions .icon-btn { width: 40px; height: 40px; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: var(--sp-8) var(--sp-5); }
  .hero-points, .brand-hero .pillars { display: none; }
  .brand-hero .tagline { margin-bottom: 0; }
  .brand-large { font-size: 28px; }
  .brand-large .brand-mark { width: 46px; height: 46px; }
  .auth-top { position: absolute; top: 0; right: 0; }
  .auth-top .icon-btn { color: #fff; }
  .auth-top .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
  .auth-card { padding: var(--sp-5) var(--sp-4) var(--sp-8); margin-top: 0; }
}
@media (max-width: 720px) {
  .user-text, .crumb-group, .crumb-sep { display: none !important; }
  .user-chip { padding: 3px; }
  .page-head { margin-bottom: var(--sp-5); }
  .page-head h1 { font-size: 22px; }
  .page-head .head-actions { width: 100%; }
  .page-head .head-actions .btn { flex: 1 1 auto; }
  .gauges { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
  .gauge-ring { width: 68px; height: 68px; }
  .gauge-ring strong { font-size: 14px; }
  .meter { grid-template-columns: 80px 1fr; }
  .meter > :last-child { grid-column: 2; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .search { max-width: none; flex-basis: 100%; }
  .count-label { margin-left: 0; }
  .tile .value { font-size: 24px; }
  .chart-frame { grid-template-rows: 190px auto; }
  .x-axis span:nth-child(2), .x-axis span:nth-child(4) { display: none; }
  .codes { grid-template-columns: minmax(0, 1fr); }

  /* Data tables become stacked cards */
  .table-wrap.stack { max-height: none; overflow: visible; }
  .stack table.table, .stack .table tbody, .stack .table tr, .stack .table td { display: block; width: 100%; }
  .stack .table thead { display: none; }
  .stack .table tr { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
  .stack .table tbody tr:last-child { border-bottom: 0; }
  .stack .table tbody tr:hover td { background: transparent; }
  .stack .table td { border: 0; padding: 4px 0 !important; display: flex; gap: var(--sp-3); align-items: flex-start; justify-content: space-between; text-align: right; max-width: none; }
  .stack .table td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; text-align: left; padding-top: 2px; }
  .stack .table td:first-child { justify-content: flex-start; text-align: left; padding-bottom: 6px !important; }
  .stack .table td:first-child::before, .stack .table td[data-label=""]::before { display: none; }
  .stack .table td.actions { width: 100%; justify-content: flex-end; padding-top: 6px !important; }
  .stack .table td > * { min-width: 0; }
  .stack .table td.wrap { min-width: 0; }
  .stack .usage { min-width: 0; flex: 1; max-width: 220px; }
  .dialog-head { padding: var(--sp-4) var(--sp-4) var(--sp-2) var(--sp-5); }
  .dialog-body { padding: var(--sp-1) var(--sp-5) var(--sp-2); }
  .dialog > form > .alert { margin: var(--sp-2) var(--sp-5) 0; }
  .dialog-actions { padding: var(--sp-3) var(--sp-5); }
  .dialog-actions .btn { flex: 1 1 auto; }
  .toasts { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { width: auto; }
  .license-banner { right: 16px; left: 16px; bottom: 16px; max-width: none; }
}
@media (max-width: 420px) {
  .main { padding: var(--sp-4) var(--sp-4) 48px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .tile { padding: var(--sp-3); }
  .tile-icon { display: none; }
  .tile .value { font-size: 21px; }
  .card { padding: var(--sp-4); }
  .card.flush > .card-head, .card.flush > .toolbar { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .auth-card form { padding: var(--sp-5); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { border-bottom: 0; padding-bottom: 0; }
  .kv dd { padding-top: 2px; }
  .gauge-ring { width: 58px; height: 58px; }
}

@media (forced-colors: active) {
  .bar span, .gauge-ring .value-arc, .swatch { forced-color-adjust: none; }
  .nav a.active { outline: 2px solid CanvasText; }
}
@media print {
  .sidebar, .topbar, .toasts, .license-banner, .head-actions { display: none !important; }
  .workspace { margin: 0; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
}
