/* WG-Guard design system — one stylesheet for fa/en (logical properties),
 * light/dark (data-theme + prefers-color-scheme), desktop/mobile.
 * Budget: ≤ 25 KB gzip (docs/product/ui-ux.md). No arbitrary values:
 * everything comes from the tokens below. */

/* ---------- fonts (self-hosted Vazirmatn, OFL; covers fa + Latin) ---------- */

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/Vazirmatn-SemiBold.woff2") format("woff2");
}

/* ---------- tokens ---------- */

:root {
  /* spacing — 4px grid */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* radii */
  --r-sm: 6px; --r-md: 8px; --r-lg: 14px; --r-full: 999px;

  /* type */
  --fs-xs: 11px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 19px; --fs-2xl: 24px;
  --lh-tight: 1.25; --lh-normal: 1.6;

  /* motion — transform/opacity only */
  --t-fast: 120ms; --t-med: 180ms; --t-slow: 240ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* layout */
  --sidebar-w: 244px;
  --topbar-h: 56px;
  --content-max: 1400px;
  --z-drawer: 60; --z-modal: 70; --z-toast: 80; --z-menu: 75;

  /* light theme (default) — shadcn-style zinc neutrals: white surfaces,
   * near-black ink primary, semantic status tones as the only color */
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-hover: #f4f4f5;
  --fg: #09090b;
  --fg-muted: #71717a;
  --fg-subtle: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #18181b;
  --accent-hover: #27272a;
  --accent-fg: #fafafa;
  --accent-soft: #f4f4f5;
  --brand: #18181b;
  --brand-hover: #3f3f46;
  --brand-soft: #f4f4f5;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --ring: rgba(24, 24, 27, 0.18);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-3: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

[data-theme="dark"] {
  /* near-black dark — shadcn zinc: black base, border-separated surfaces,
   * white ink primary, lifted semantic tones */
  --bg: #09090b;
  --bg-elev: #0d0d0f;
  --bg-subtle: #18181b;
  --bg-hover: #232327;
  --fg: #fafafa;
  --fg-muted: #a1a1aa;
  --fg-subtle: #71717a;
  --border: #232328;
  --border-strong: #35353b;
  --accent: #fafafa;
  --accent-hover: #e4e4e7;
  --accent-fg: #18181b;
  --accent-soft: rgba(250, 250, 250, 0.08);
  --brand: #fafafa;
  --brand-hover: #d4d4d8;
  --brand-soft: rgba(250, 250, 250, 0.08);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #7dd3fc;
  --info-soft: rgba(125, 211, 252, 0.12);
  --ring: rgba(250, 250, 250, 0.25);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 4px 6px -1px rgba(0, 0, 0, 0.55), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* theme = system: follow the OS while no explicit choice is set.
 * Same values as [data-theme="dark"] above — kept in sync by review. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #09090b;
    --bg-elev: #0d0d0f;
    --bg-subtle: #18181b;
    --bg-hover: #232327;
    --fg: #fafafa;
    --fg-muted: #a1a1aa;
    --fg-subtle: #71717a;
    --border: #232328;
    --border-strong: #35353b;
    --accent: #fafafa;
    --accent-hover: #e4e4e7;
    --accent-fg: #18181b;
    --accent-soft: rgba(250, 250, 250, 0.08);
    --brand: #fafafa;
    --brand-hover: #d4d4d8;
    --brand-soft: rgba(250, 250, 250, 0.08);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --info: #7dd3fc;
    --info-soft: rgba(125, 211, 252, 0.12);
    --ring: rgba(250, 250, 250, 0.25);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 4px 6px -1px rgba(0, 0, 0, 0.55), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* ---------- reset & base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Vazirmatn", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    sans-serif;
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p  { margin: 0; }
a  { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
img, svg { display: block; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

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

::selection { background: var(--brand-soft); }

.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;
}

/* the embedded sprite sheet is never rendered directly */
.svg-sprite { display: none; }

.icon {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 22px; height: 22px; }

/* data is always LTR with Latin digits, embedded inside RTL prose */
.ltr-data {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

/* ---------- shell layout ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-inline-end: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-3);
  gap: var(--sp-4);
  z-index: var(--z-drawer);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2);
  color: var(--fg);
  font-weight: 600;
  font-size: var(--fs-lg);
  letter-spacing: 0.01em;
}
.brand .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.brand small {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--fg-subtle);
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; overflow-y: auto; }
.nav-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
}
.nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-size: var(--fs-md);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav a:hover { background: var(--bg-hover); color: var(--fg); }
.nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.foot-row { display: flex; align-items: center; gap: var(--sp-1); }
.foot-row .spacer { flex: 1 1 auto; }

/* --- desktop collapsed rail (data-collapsed on .shell) ---
 * width animates via the grid track; labels fade/slide out. */
.shell { transition: grid-template-columns var(--t-slow) var(--ease); }
.shell[data-collapsed] { --sidebar-w: 68px; }
.shell[data-collapsed] .brand { justify-content: center; padding-inline: 0; }
.shell[data-collapsed] .brand-text,
.shell[data-collapsed] .nav-label,
.shell[data-collapsed] .nav a span,
.shell[data-collapsed] .user-row .user-name {
  display: none;
}
.shell[data-collapsed] .nav a { justify-content: center; padding: 10px 0; }
.shell[data-collapsed] .user-row { justify-content: center; padding: var(--sp-1); }
.shell[data-collapsed] .foot-row { flex-direction: column; }
.shell[data-collapsed] .foot-row .spacer { display: none; }
/* expanded nav never shows tooltips (labels are visible) */
.shell:not([data-collapsed]) .nav [data-tip]::after { display: none; }

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: var(--sp-2) var(--sp-5);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-subtle);
}
.topbar .spacer { flex: 1 1 auto; }
.topbar .subtitle { color: var(--fg-subtle); font-size: var(--fs-sm); }

.content {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--sp-5);
  flex: 1 1 auto;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-block-end: var(--sp-5);
}
.page-head h1 { font-size: var(--fs-xl); }
.page-head p { color: var(--fg-muted); font-size: var(--fs-sm); margin-block-start: 2px; }
.page-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn--primary { border-color: transparent; }
.btn--primary:hover { border-color: transparent; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn--primary { background: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); }
.btn--danger-soft { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn--danger-soft:hover { background: var(--danger); color: #fff; }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--bg-hover); }
.btn--sm { padding: 5px 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-block-end: var(--sp-4); }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
.field .hint { font-size: var(--fs-xs); color: var(--fg-subtle); line-height: 1.5; }
.field .error { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.field--invalid input, .field--invalid select { border-color: var(--danger); }

.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: var(--fs-md);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.input:hover, .select:hover { border-color: var(--fg-subtle); }
.input:read-only { background: var(--bg-subtle); color: var(--fg-muted); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
.input::placeholder { color: var(--fg-subtle); }
.input:disabled, .select:disabled { background: var(--bg-subtle); color: var(--fg-subtle); }

.select {
  appearance: none;
  padding-inline-end: 32px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
[dir="rtl"] .select { background-position: left 10px center; }

.search-box { position: relative; }
.search-box .icon {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  translate: 0 -50%;
  color: var(--fg-subtle);
  pointer-events: none;
}
.search-box .input { padding-inline-start: 34px; }

/* toggle switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 36px; height: 20px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background var(--t-med) var(--ease);
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  inset-inline-start: 22px;
  top: 50%;
  translate: 0 -50%;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: inset-inline-start var(--t-med) var(--ease);
}
[dir="rtl"] .switch .track::after { inset-inline-start: auto; inset-inline-end: 22px; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { inset-inline-start: 2px; }
[dir="rtl"] .switch input:checked + .track::after { inset-inline-start: auto; inset-inline-end: 2px; }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* checkbox */
.checkbox {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
  background: var(--bg-subtle);
  color: var(--fg-muted);
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge--pulse .dot { animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- cards & metrics ---------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card--pad { padding: var(--sp-5); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-block-end: 1px solid var(--border);
}
.card-head h2 { font-size: var(--fs-md); }
.card-body { padding: var(--sp-5); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.metric {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.metric .label {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--fg-subtle);
  letter-spacing: 0.02em;
}
.metric .label .icon {
  width: 24px; height: 24px;
  padding: 4px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
}
.metric .value {
  font-size: var(--fs-2xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric .meta { font-size: var(--fs-xs); color: var(--fg-muted); }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-block-end: var(--sp-4);
}
.toolbar .search-box { flex: 1 1 240px; max-width: 380px; }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar .select { width: auto; }

/* ---------- tables ---------- */

.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow-x: auto;
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th, .table td {
  text-align: start;
  padding: 10px 14px;
  border-block-end: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.table th {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-subtle);
  background: color-mix(in srgb, var(--bg-subtle) 55%, var(--bg-elev));
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-block-end: none; }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table .cell-main { font-weight: 600; color: var(--fg); }
.table .cell-sub { font-size: var(--fs-xs); color: var(--fg-subtle); }
.table .row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.table a.row-link { color: inherit; }
.table a.row-link:hover { color: var(--accent); }

/* identity cell in list rows (avatar + name stack + plan chip) */
.id-cell {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}
.id-cell .avatar { width: 32px; height: 32px; }
.id-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

/* ---------- meter / traffic bar ---------- */

.meter {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}
.meter .bar {
  flex: 1 1 40px;
  min-width: 24px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  overflow: hidden;
}
.meter .bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width var(--t-slow) var(--ease);
}
.meter .bar > .is-warn { background: var(--warn); }
.meter .bar > .is-danger { background: var(--danger); }
.meter .num {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}

/* width steps for CSP-safe meters (server picks the nearest) */
.w0 .bar > span { width: 0%; }   .w5 .bar > span { width: 5%; }    .w10 .bar > span { width: 10%; }
.w15 .bar > span { width: 15%; } .w20 .bar > span { width: 20%; }  .w25 .bar > span { width: 25%; }
.w30 .bar > span { width: 30%; } .w35 .bar > span { width: 35%; }  .w40 .bar > span { width: 40%; }
.w45 .bar > span { width: 45%; } .w50 .bar > span { width: 50%; }  .w55 .bar > span { width: 55%; }
.w60 .bar > span { width: 60%; } .w65 .bar > span { width: 65%; }  .w70 .bar > span { width: 70%; }
.w75 .bar > span { width: 75%; } .w80 .bar > span { width: 80%; }  .w85 .bar > span { width: 85%; }
.w90 .bar > span { width: 90%; } .w95 .bar > span { width: 95%; }  .w100 .bar > span { width: 100%; }

/* ---------- dropdown menu ---------- */

.menu-anchor { position: relative; display: inline-flex; }
.menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 6px;
  z-index: var(--z-menu);
  opacity: 0;
  visibility: hidden;
  translate: 0 -4px;
  transition: opacity var(--t-fast) var(--ease), translate var(--t-fast) var(--ease),
    visibility var(--t-fast);
}
.menu.is-open { opacity: 1; visibility: visible; translate: 0 0; }
/* Positioning is owned by app.js (fixed coordinates + viewport flipping) so
 * menus can never be clipped by overflow ancestors — no CSS inset rules. */
.menu button, .menu a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-sm);
  text-align: start;
  cursor: pointer;
  text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--bg-hover); }
.menu .is-danger { color: var(--danger); }
.menu .is-danger:hover { background: var(--danger-soft); }
.menu hr { border: 0; border-block-start: 1px solid var(--border); margin: 6px 4px; }

/* ---------- dialog / modal ---------- */

dialog.modal {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow-3);
  padding: 0;
}
dialog.modal::backdrop {
  background: rgba(9, 9, 11, 0.55);
  backdrop-filter: blur(2px);
}
dialog.modal[open] { animation: modal-in var(--t-med) var(--ease); }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-block-end: 1px solid var(--border);
}
.modal-head h2 { font-size: var(--fs-lg); }
.modal-body { padding: var(--sp-5); max-height: 70vh; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-block-start: 1px solid var(--border);
}
.modal--danger .modal-head { border-inline-start: 3px solid var(--danger); }

/* ---------- drawer (mobile nav + sheets) ---------- */

.drawer-toggle { display: none; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.55);
  z-index: calc(var(--z-drawer) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-med) var(--ease), visibility var(--t-med);
}
.scrim.is-open { opacity: 1; visibility: visible; }

/* ---------- toast ---------- */

.toasts {
  position: fixed;
  inset-block-end: var(--sp-4);
  inset-inline-start: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  animation: toast-in var(--t-med) var(--ease);
}
.toast .icon { width: 16px; height: 16px; }
.toast--ok .icon { color: var(--ok); }
.toast--err .icon { color: var(--danger); }
.toast.is-leaving { opacity: 0; translate: 0 6px; transition: opacity var(--t-med), translate var(--t-med); }
@keyframes toast-in {
  from { opacity: 0; translate: 0 8px; }
  to   { opacity: 1; translate: 0 0; }
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: var(--sp-1);
  border-block-end: 1px solid var(--border);
  margin-block-end: var(--sp-4);
  overflow-x: auto;
}
.tabs a, .tabs button {
  padding: 8px 14px;
  border: 0;
  border-block-end: 2px solid transparent;
  margin-block-end: -1px;
  background: transparent;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.tabs a:hover, .tabs button:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--brand); border-block-end-color: var(--brand); }

/* ---------- pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 2px 0;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}
.pagination .links { display: flex; gap: var(--sp-2); }
.pagination .links a, .pagination .links span {
  min-width: 32px;
  display: inline-grid;
  place-items: center;
  height: 32px;
  padding-inline: 8px;
  border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
}
.pagination .links a:hover { background: var(--bg-hover); }
.pagination .links .is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pagination .links .is-disabled { opacity: 0.4; }

/* ---------- empty / skeleton / loading ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-5);
  color: var(--fg-muted);
}
.empty .icon {
  width: 44px; height: 44px;
  padding: 10px;
  stroke-width: 1.6;
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
  color: var(--fg-subtle);
  margin-block-end: var(--sp-2);
  box-sizing: border-box;
}
.empty h3 { color: var(--fg); font-size: var(--fs-lg); }
.empty p { max-width: 400px; font-size: var(--fs-sm); }
.empty .btn { margin-block-start: var(--sp-2); }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-hover) 45%, var(--bg-subtle) 65%);
  background-size: 240% 100%;
  animation: shimmer 1.4s linear infinite;
  min-height: 14px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -40% 0; }
}

/* htmx request indicator (config includeIndicatorStyles=false under CSP) */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }

/* ---------- tooltip (CSS-only, logical) ---------- */

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 50%;
  translate: -50% 0;
  background: var(--fg);
  color: var(--bg-elev);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.4;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  width: max-content;
  display: none; /* hidden tooltips must not contribute scrollable overflow */
  pointer-events: none;
  z-index: var(--z-menu);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; }

/* ---------- auth screens ---------- */

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-6);
}
.auth-card .brand { justify-content: center; margin-block-end: var(--sp-2); }
.auth-card > h1 { font-size: var(--fs-xl); text-align: center; }
.auth-card > .sub {
  text-align: center;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  margin-block-end: var(--sp-5);
}
.auth-foot {
  margin-block-start: var(--sp-5);
  padding-block-start: var(--sp-4);
  border-block-start: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
}
.auth-alert {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-block-end: var(--sp-4);
}
.auth-alert--err { background: var(--danger-soft); color: var(--danger); }
.auth-alert--ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- onboarding steps ---------- */

.steps {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  margin-block-end: var(--sp-5);
}
.steps .step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-subtle);
}
.steps .step .n {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.steps .step.is-current { color: var(--accent); }
.steps .step.is-current .n { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.steps .step.is-done { color: var(--ok); }
.steps .step.is-done .n { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* ---------- misc ---------- */

.kbd {
  font-size: var(--fs-xs);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-block-end-width: 2px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
  flex: none;
}

.inline-actions { display: inline-flex; gap: var(--sp-1); align-items: center; }

.callout {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.callout .icon { margin-block-start: 2px; }
.callout--warn { background: var(--warn-soft); color: var(--warn); }
.callout--info { background: var(--info-soft); color: var(--info); }
.callout--danger { background: var(--danger-soft); color: var(--danger); }

.divider { border: 0; border-block-start: 1px solid var(--border); margin-block: var(--sp-4); }

.detail-list {
  display: grid;
  grid-template-columns: minmax(max-content, 200px) minmax(0, 1fr);
  gap: 8px var(--sp-5);
  font-size: var(--fs-sm);
}
.detail-list dt { color: var(--fg-subtle); font-weight: 600; }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-muted);
}

.text-muted { color: var(--fg-muted); }
.text-subtle { color: var(--fg-subtle); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-end { text-align: end; }
.nowrap { white-space: nowrap; }
.mt-4 { margin-block-start: var(--sp-4); }
.hidden { display: none !important; }

/* sidebar user row */
.user-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.user-row .user-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.3;
}
.user-row .user-name .cell-main {
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* inputs with an inline action (password reveal) */
.input-adj { position: relative; }
.input-adj .input { padding-inline-end: 42px; }
.input-adj .icon-btn {
  position: absolute;
  inset-inline-end: 4px;
  top: 50%;
  translate: 0 -50%;
  width: 30px;
  height: 30px;
}
/* reveal state lives on aria-pressed so the initial render is correct too */
[data-toggle-password][aria-pressed="false"] svg:nth-of-type(2) { display: none; }
[data-toggle-password][aria-pressed="true"] svg:nth-of-type(1) { display: none; }

/* two-column field rows (stack on small screens) */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--sp-4);
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

/* value + unit inputs (quota, duration) */
.unit-group { display: flex; gap: var(--sp-2); }
.unit-group .input { flex: 1 1 auto; min-width: 0; }
.unit-group .select { width: 104px; flex: none; }

/* generate username button sits inside the unit-group row */
.gen-btn { flex: none; padding: 8px 10px; }

/* preset quick-fill chips */
.chips-row { margin-block-start: 2px; }
.chip-btn {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-elev);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}
.chip-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-btn.is-active {
  background: var(--brand);
  color: var(--accent-fg);
  border-color: transparent;
}

/* segmented mode panels (create-user form): the visible mode's controls */
[data-panel] { margin-block-start: var(--sp-2); }
[data-panel] .unit-group { margin-block-start: var(--sp-2); }
.seg-group + [data-panel] { margin-block-start: var(--sp-3); }
.unit-group--narrow { max-width: 148px; }
/* static unit suffix next to an input (settings page) */
.unit-static {
  align-self: center;
  flex: none;
  color: var(--fg-muted);
  font-size: var(--fs-sm);
}

/* advanced collapse inside forms */
details.form-advanced { margin-block-start: calc(-1 * var(--sp-2)); }
details.form-advanced > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
details.form-advanced > summary::-webkit-details-marker { display: none; }
details.form-advanced > summary:hover { background: var(--bg-hover); color: var(--fg); }
details.form-advanced[open] > summary { border-style: solid; color: var(--fg); }
details.form-advanced .collapse-body { padding: var(--sp-4) 0 0; }

/* form sections (create/edit pages + drawer) */
fieldset.form-section {
  border: 0;
  border-block-start: 1px solid var(--border);
  padding: var(--sp-4) 0 0;
  margin: 0 0 var(--sp-5);
}
fieldset.form-section legend {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-muted);
  padding: 0;
  margin-block-end: var(--sp-3);
}
fieldset.form-section .field:last-child { margin-block-end: 0; }

/* slide-over drawer (create-user sheet) */
dialog.drawer {
  width: min(560px, calc(100vw - 16px));
  height: min(100dvh - 24px, 860px);
  max-height: none;
  margin: 12px auto;
  margin-inline-end: max(12px, calc((100vw - 560px) / 2));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow-3);
  padding: 0;
}
dialog.drawer::backdrop {
  background: rgba(9, 9, 11, 0.55);
  backdrop-filter: blur(2px);
}
dialog.drawer[open] { animation: drawer-in var(--t-slow) var(--ease); }
@keyframes drawer-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.drawer-form { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.drawer-body { padding: var(--sp-5); overflow-y: auto; flex: 1 1 auto; }
/* rtl drawers anchor to the same side (end = left in rtl via margin trick) */
[dir="rtl"] dialog.drawer { margin-inline-end: auto; margin-inline-start: max(12px, calc((100vw - 560px) / 2)); }

/* calendar popover */
.calendar {
  position: fixed;
  z-index: calc(var(--z-menu) + 5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: var(--sp-2);
  display: none;
  user-select: none;
}
.calendar.is-open { display: block; animation: modal-in var(--t-fast) var(--ease); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 2px 4px var(--sp-2); }
.cal-title { font-size: var(--fs-sm); font-weight: 600; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-wd {
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-subtle);
  padding: 2px 0;
}
.cal-day {
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  min-height: 32px;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  color: var(--fg);
  transition: background var(--t-fast) var(--ease);
}
.cal-day:hover:not(:disabled) { background: var(--bg-hover); }
.cal-day:disabled { opacity: 0.35; cursor: not-allowed; }
.cal-day.is-today { box-shadow: inset 0 0 0 1px var(--border-strong); }
.cal-day.is-selected { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.cal-foot { display: flex; justify-content: flex-end; padding: var(--sp-1) 2px 0; border-block-start: 1px solid var(--border); margin-block-start: var(--sp-2); }

/* forms on dedicated pages */
.form-card { max-width: 760px; }

/* per-page width tiers: the layout picks the class from the route —
 * narrow for settings + forms, default for tables/dashboards */
.content--narrow { max-width: 880px; }

/* user detail: overview + devices side by side, stacked on mobile */
.user-detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 1400px) {
  .user-detail-grid { grid-template-columns: 1fr; }
}
.user-detail-grid .card + .card { margin-block-start: var(--sp-4); }

/* table nested inside a card */
.table-wrap--flush {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* QR dialog */
.qr-body { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }
.qr-body img {
  width: 280px;
  height: 280px;
  background: #fff;
  border-radius: var(--r-md);
  padding: 8px;
}

/* skip link becomes visible on keyboard focus */
a.skip-link:focus {
  position: fixed;
  inset-block-start: var(--sp-2);
  inset-inline-start: var(--sp-2);
  width: auto;
  height: auto;
  margin: 0;
  clip: auto;
  z-index: 100;
  background: var(--bg-elev);
  color: var(--fg);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}

/* onboarding fieldsets */
fieldset.onboard-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin: 0 0 var(--sp-4);
}
fieldset.onboard-section legend {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-muted);
  padding-inline: 6px;
}
fieldset.onboard-section .field:last-child { margin-block-end: 0; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .shell, .shell[data-collapsed] { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(300px, 84vw);
    translate: -100% 0;
    transition: translate var(--t-slow) var(--ease);
    box-shadow: var(--shadow-3);
    padding-inline-start: max(var(--sp-3), env(safe-area-inset-left));
    padding-bottom: env(safe-area-inset-bottom);
  }
  [dir="rtl"] .sidebar { translate: 100% 0; }
  .sidebar.is-open { translate: 0 0; }
  .drawer-toggle { display: inline-grid; }
  .content { padding: var(--sp-4); }
  .topbar { padding: var(--sp-2) var(--sp-4); }
}

/* large displays keep a centered composition instead of stretching */
@media (min-width: 1920px) {
  :root { --content-max: 1560px; }
  .content { padding: var(--sp-6); }
}

/* table → card adaptation (one component, two shapes) */
@media (max-width: 800px) {
  table.table--cards, .table--cards thead, .table--cards tbody,
  .table--cards tr, .table--cards th, .table--cards td { display: block; }
  .table--cards thead { display: none; }
  .table--cards tr {
    padding: var(--sp-3) var(--sp-4);
    border-block-end: 1px solid var(--border);
  }
  .table--cards tr:last-child { border-block-end: none; }
  .table--cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-3);
    padding: 4px 0;
    border: 0;
    white-space: normal;
  }
  .table--cards td::before {
    content: attr(data-label);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--fg-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .table--cards td.card-title {
    padding-block-end: var(--sp-2);
    margin-block-end: var(--sp-2);
    border-block-end: 1px dashed var(--border);
  }
  .table--cards td.card-title::before { display: none; }
  .table--cards td.card-hide { display: none; }
  /* stacked definition lists: label above value (the two-column track starves values) */
  .detail-list { grid-template-columns: minmax(0, 1fr); }
  .detail-list dt { margin-block-start: var(--sp-2); }
  .detail-list dt:first-child { margin-block-start: 0; }
}

/* ---------- motion preferences ---------- */

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

/* ---------- print: keep the data, drop the chrome ---------- */

@media print {
  .sidebar, .topbar, .toasts, .toolbar, .pagination { display: none !important; }
  .shell { grid-template-columns: 1fr; }
}

/* ---------- dashboard: attention lists ---------- */

.dash-attention h2 { font-size: var(--fs-lg); }
.attention-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--sp-4) var(--sp-6);
  margin-block-start: var(--sp-3);
}
.attention-col h3 {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  margin-block-end: var(--sp-2);
}
.attention-col--expiring h3 { color: var(--warn); }
.attention-col--exceeded h3 { color: var(--warn); }
.attention-col--expired h3 { color: var(--danger); }
.attention-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  padding: 6px 0;
  border-block-end: 1px dashed var(--border);
  font-size: var(--fs-sm);
}
.attention-row:last-child { border-block-end: 0; }
.attention-when { color: var(--fg-muted); font-size: var(--fs-xs); white-space: nowrap; }

/* ---------- dashboard: traffic chart ---------- */

.chart-legend {
  display: flex;
  gap: var(--sp-4);
  margin-block-start: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  inline-size: 12px;
  block-size: 12px;
  border-radius: 3px;
  background: var(--brand);
}
.swatch--tx { background: var(--fg-subtle); }

.chart-wrap { margin-block-start: var(--sp-3); }
.chart { display: block; inline-size: 100%; block-size: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis {
  fill: var(--fg-subtle);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart-rx { fill: var(--brand); opacity: 1; }
.chart-tx { fill: var(--fg-subtle); opacity: 1; }

/* segmented range control (chart period) */
.seg-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
/* inside flex-column fields the inline group must not stretch */
.field > .seg-group { align-self: flex-start; max-width: 100%; }
.seg {
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg:hover { color: var(--fg); }
.seg.is-on {
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow-1);
}

/* ---------- dashboard: host metrics ---------- */

.host-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4) var(--sp-5);
  margin-block-start: var(--sp-2);
}
.host-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.host-item .label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-subtle);
  letter-spacing: 0.02em;
}
.host-item .value { font-weight: 600; }
.host-item .meta { font-size: var(--fs-xs); color: var(--fg-muted); }
.text-md { font-size: var(--fs-md); }

/* ---------- collapsible advanced sections ---------- */

.collapse {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  margin-block: var(--sp-4);
}
.collapse > summary {
  cursor: pointer;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  font-size: var(--fs-md);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border-radius: inherit;
  transition: background var(--t-fast) var(--ease);
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary:hover { background: var(--bg-hover); }
.collapse[open] > summary { border-block-end: 1px solid var(--border); }
.collapse > summary .icon { transition: transform var(--t-fast) var(--ease); }
.collapse[open] > summary .icon { transform: rotate(90deg); }
.collapse > .collapse-body { padding: var(--sp-4); }

/* checkbox with label text (form rows) */
.check-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 500;
  cursor: pointer;
}

/* ---------- ops screens: permission matrix, audit metadata ---------- */

.perm-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--sp-2) var(--sp-4);
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.perm-matrix--single { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.perm-family { display: flex; flex-direction: column; gap: 4px; }
.perm-family-name {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--fg); }
.toolbar .field { margin-block-end: 0; flex: 0 1 auto; }
.toolbar .input { width: auto; min-width: 170px; }
.audit-meta summary { list-style: none; cursor: pointer; }
.audit-meta summary::-webkit-details-marker { display: none; }
.audit-json {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  font-family: ui-monospace, monospace;
  overflow: auto;
  max-width: 420px;
  max-height: 220px;
  white-space: pre-wrap;
  text-align: start;
}

/* ---------- public subscription page (standalone, no shell) ---------- */

.sub-body {
  background: var(--bg);
}
.sub-shell {
  max-width: 660px;
  margin-inline: auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-height: 100vh;
}
.sub-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-block: var(--sp-2);
}
.sub-head .logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  flex: none;
}
.sub-head h1 { font-size: var(--fs-xl); overflow-wrap: anywhere; }
.sub-head p { display: flex; align-items: center; gap: var(--sp-2); margin-block-start: 2px; }
.sub-stats .detail-list { grid-template-columns: minmax(max-content, 140px) minmax(0, 1fr); }
.sub-devices { display: flex; flex-direction: column; margin-block-start: var(--sp-3); }
.sub-device { border-block-end: 1px solid var(--border); }
.sub-device:last-child { border-block-end: none; }
.sub-device summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  cursor: pointer;
  list-style: none;
}
.sub-device summary::-webkit-details-marker { display: none; }
.sub-device summary .cell-main { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-device summary .icon { color: var(--fg-subtle); transition: transform var(--t-fast) var(--ease); }
.sub-device[open] summary .icon { transform: rotate(180deg); }
.sub-device-ip { font-size: var(--fs-xs); color: var(--fg-subtle); }
.sub-device-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  padding: var(--sp-2) 0 var(--sp-4);
}
.sub-qr {
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: var(--r-md);
  padding: 8px;
  border: 1px solid var(--border);
}
.sub-device-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.sub-foot {
  margin-block-start: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-block-start: var(--sp-4);
  border-block-start: 1px solid var(--border);
  color: var(--fg-subtle);
  font-size: var(--fs-xs);
}
.sub-foot .spacer { flex: 1 1 auto; }
.sub-lang { color: var(--fg-muted); font-weight: 600; }
@media (max-width: 480px) {
  .sub-shell { padding-inline: var(--sp-3); }
  .sub-device-body { flex-direction: column; gap: var(--sp-3); }
  .content { padding-inline: var(--sp-3); }
  .topbar { padding-inline: var(--sp-3); padding-inline-end: max(var(--sp-3), env(safe-area-inset-right)); }
  .topbar-brand { display: none; }
  .topbar .subtitle { display: none; }
  .page-head { margin-block-end: var(--sp-4); }
  .page-head h1 { font-size: var(--fs-lg); }
}

.auth-alert--warn { background: var(--warn-soft); color: var(--warn); }
