/* ═══════════════════════════════════════════════════════════════
   Retainr — Unified Design System
   Neutral surfaces, one accent, dense data-first layout.
   ═══════════════════════════════════════════════════════════════ */

/* ── 0. Fonts ── */
html, body {
  font-family: var(--font-sans);
}

/* ── 1. Design Tokens ──────────────────────────────────────────
   Neutral graphite surfaces, one restrained blue for action.
   Colour carries meaning here — status, direction, focus — and
   nothing else, so a red cell or a blue button reads instantly.
   Every theme below restates the same names, so component rules
   never spell a colour out.
   ─────────────────────────────────────────────────────────── */
:root {
  /* Surfaces — page, raised, sunken */
  --bg:          #0E1114;
  --bg-2:        #14181D;
  --bg-3:        #1B2026;
  --paper:       #14181D;
  --paper-2:     #1B2026;

  /* Text — four steps, each still legible on --bg */
  --ink:         #E7EBF0;
  --ink-2:       #BFC6CF;
  --ink-3:       #9CA4AE;
  --ink-4:       #808993;

  /* Rules */
  --line:        #232A32;
  --line-soft:   #1A2026;
  --line-strong: #36404B;

  /* Action */
  --accent:      #2F6FE0;
  --accent-2:    #6FA6F5;
  --accent-hover: #2B66CE;
  --accent-3:    #2FA97C;
  --accent-rgb:  47, 111, 224;

  /* Status */
  --green:       #35B37E;
  --red:         #E5534B;
  --yellow:      #D9A32B;
  --blue:        #4C9AFF;

  --font-sans:   'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif:  'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-mono:   'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shadows stay shallow — depth marks hierarchy, it isn't decoration */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.30);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.20);
  --shadow-lg:   0 16px 48px rgba(0,0,0,0.50), 0 2px 8px rgba(0,0,0,0.30);

  --radius:      8px;
  --radius-sm:   6px;

  /* Spacing scale. Layout spacing comes from these steps; the dense data
     views (table cells, chips, nav rows) keep their own tighter 5/7/9px
     rhythm, which is deliberate and consistent within those components. */
  --sp-1:  4px;   --sp-2:  8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px;   --sp-6: 24px;   --sp-7: 32px;  --sp-8: 40px;
  --sp-9: 48px;   --sp-10: 64px;  --sp-11: 80px; --sp-12: 96px;

  /* Legacy aliases — old code keeps working */
  --surface:     #14181D;
  --surface2:    #1B2026;
  --border:      #232A32;
  --border-hi:   #36404B;
  --text:        #E7EBF0;
  --muted:       #9CA4AE;
  --danger:      #E5534B;
  --success:     #35B37E;
  --shadow:      0 16px 48px rgba(0,0,0,0.55);
  --shadow-soft: 0 4px 12px rgba(0,0,0,0.35);
  --hover:       rgba(255,255,255,0.045);
  --fg:          #E7EBF0;
  --ks-border:   #232A32;
  --ks-card:     #14181D;
  --ks-muted:    #9CA4AE;
  --ks-accent:   #2F6FE0;
  --accent2:     #6FA6F5;
  --accent2-rgb: 111, 166, 245;
  --success-rgb: 53, 179, 126;
  color-scheme: dark;
}

/* ── 1b. Theme overrides (class set on <html> by retainrSetTheme) ──
   Keys are unchanged so existing cookies keep resolving; only the
   palettes and their display names moved. Each theme restates the
   full ink/line ramp rather than just the accent, because a warm or
   navy surface needs its own neutrals to stay readable. */

/* Carbon — neutral near-black, teal action */
html.theme-onyx {
  --bg:        #0B0C0D;  --bg-2:    #121415;  --bg-3:    #191C1E;
  --paper:     #121415;  --paper-2: #191C1E;
  --ink:       #E9EBEC;  --ink-2:   #C1C4C8;  --ink-3:   #9BA0A4;  --ink-4: #7F858B;
  --line:      #23262A;  --line-soft: #191C1F;  --line-strong: #363B40;
  --accent:    #10806F;  --accent-2:#45C2AE;  --accent-hover: #0F7666;  --accent-rgb: 16,128,111;
  --accent-3:  #4C9AFF;
  --surface:   #121415;  --surface2:#191C1E;  --ks-card: #121415;
  --border:    #23262A;  --border-hi: #363B40;  --ks-border: #23262A;
  --text:      #E9EBEC;  --muted:   #9BA0A4;  --fg: #E9EBEC;  --ks-muted: #9BA0A4;
  --ks-accent: #10806F;  --accent2: #45C2AE;  --accent2-rgb: 69,194,174;
  color-scheme: dark;
}

/* Navy — deep blue surfaces, azure action */
html.theme-arctic {
  --bg:        #0A1018;  --bg-2:    #101823;  --bg-3:    #17212E;
  --paper:     #101823;  --paper-2: #17212E;
  --ink:       #E5EBF2;  --ink-2:   #BDC7D2;  --ink-3:   #9BA5B1;  --ink-4: #7F8A93;
  --line:      #1E2A38;  --line-soft: #16202B;  --line-strong: #31404F;
  --accent:    #1273C4;  --accent-2:#5AAEEA;  --accent-hover: #116AB4;  --accent-rgb: 18,115,196;
  --accent-3:  #2FA97C;
  --surface:   #101823;  --surface2:#17212E;  --ks-card: #101823;
  --border:    #1E2A38;  --border-hi: #31404F;  --ks-border: #1E2A38;
  --text:      #E5EBF2;  --muted:   #9BA5B1;  --fg: #E5EBF2;  --ks-muted: #9BA5B1;
  --ks-accent: #1273C4;  --accent2: #5AAEEA;  --accent2-rgb: 90,174,234;
  color-scheme: dark;
}

/* Ember — warm charcoal, copper action */
html.theme-rose {
  --bg:        #121110;  --bg-2:    #1A1816;  --bg-3:    #221F1C;
  --paper:     #1A1816;  --paper-2: #221F1C;
  --ink:       #EFEAE4;  --ink-2:   #CCC4BD;  --ink-3:   #A9A29A;  --ink-4: #8E877E;
  --line:      #2C2825;  --line-soft: #201D1B;  --line-strong: #423C37;
  --accent:    #A75F2B;  --accent-2:#DE9757;  --accent-hover: #9A5728;  --accent-rgb: 167,95,43;
  --accent-3:  #2FA97C;
  --surface:   #1A1816;  --surface2:#221F1C;  --ks-card: #1A1816;
  --border:    #2C2825;  --border-hi: #423C37;  --ks-border: #2C2825;
  --text:      #EFEAE4;  --muted:   #A9A29A;  --fg: #EFEAE4;  --ks-muted: #A9A29A;
  --ks-accent: #A75F2B;  --accent2: #DE9757;  --accent2-rgb: 222,151,87;
  color-scheme: dark;
}

/* Daylight — the light theme. Accents darken here: --accent-2 is link
   text, so on white it has to carry contrast rather than glow. */
html.theme-light {
  --bg:          #F5F6F8;  --bg-2:       #FFFFFF;   --bg-3:       #ECEFF3;
  --paper:       #FFFFFF;  --paper-2:    #F4F6F9;
  --ink:         #14181D;  --ink-2:      #313840;
  --ink-3:       #4D5560;  --ink-4:      #666C74;
  --line:        #E3E7EC;  --line-soft:  #EDF0F4;
  --line-strong: #C7CDD5;
  --accent:      #1F63D1;  --accent-2:   #1A55B8;  --accent-hover: #1D5BC0;  --accent-rgb: 31,99,209;
  --accent-3:    #17805C;
  --green:       #17805C;  --red:        #C0362E;
  --yellow:      #9A6B08;  --blue:       #1F63D1;
  --surface:     #FFFFFF;  --surface2:   #F4F6F9;
  --ks-card:     #FFFFFF;  --ks-border:  #E3E7EC;
  --ks-muted:    #6B7684;  --ks-accent:  #1F63D1;
  --accent2:     #1A55B8;  --accent2-rgb: 26,85,184;
  --border:      #E3E7EC;  --border-hi:  #C7CDD5;
  --text:        #14181D;  --muted:      #6B7684;
  --fg:          #14181D;  --hover:      rgba(0,0,0,0.04);
  --danger:      #C0362E;  --success:    #17805C;
  --success-rgb: 23,128,92;
  --shadow-sm:   0 1px 2px rgba(16,24,40,0.06);
  --shadow-md:   0 4px 12px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.05);
  --shadow-lg:   0 16px 40px rgba(16,24,40,0.12), 0 2px 8px rgba(16,24,40,0.06);
  --shadow:      0 16px 40px rgba(16,24,40,0.14);
  --shadow-soft: 0 4px 12px rgba(16,24,40,0.08);
  color-scheme: light;
}

/* ── 2. Base reset ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }
body {
  font-size: 14px; line-height: 1.55;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--ink); }
/* <em> is emphasis, not an accent-coloured flourish. Pages that wrap
   half a heading in <em> now render as one flat, readable line. */
em { font-style: normal; color: inherit; font-weight: inherit; }
::selection { background: rgba(var(--accent-rgb), 0.35); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* Sidebar nav: thin, unobtrusive scrollbar so it doesn't bleed into the footer */
.sidebar nav::-webkit-scrollbar { width: 3px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; border: none; background-clip: unset; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }

/* ══════════════════════════════════════════════════════
   SHELL LAYOUT
══════════════════════════════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  width: 256px;
  flex-shrink: 0;
}
.brand-row {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-weight: 700; font-size: 22px;
  letter-spacing: -0.03em; color: var(--ink);
  text-decoration: none;
}
.brand .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  display: inline-block; transform: translateY(-2px);
}
.workspace-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11px; font-weight: 500;
  color: var(--ink-3);
  max-width: 130px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.workspace-pill::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-3);
}

.sidebar-section { padding: 16px 14px 4px; }
.sidebar-section h5 {
  margin: 0 0 6px; padding: 0 8px;
  font-size: 11px; font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Collapsible section header — same look as h5 but clickable, with a chevron. */
.sidebar-group-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; margin: 0 0 6px; padding: 4px 8px;
  background: none; border: none; cursor: pointer; border-radius: 5px;
  font-size: 11px; font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.05em;
  transition: color 0.12s, background 0.12s;
}
.sidebar-group-toggle:hover { color: var(--ink-2); background: var(--bg-2); }
.group-chevron {
  width: 11px; height: 11px; flex-shrink: 0; opacity: 0.7;
  transform: rotate(-90deg); transition: transform 0.15s ease;
}
.group-chevron.open { transform: rotate(0deg); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  position: relative; font-weight: 500;
  background: transparent; border: none; cursor: pointer;
  width: 100%;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--bg-3); color: var(--ink); }
.nav-item.active::before {
  content: "";
  position: absolute; left: -14px; top: 6px; bottom: 6px;
  width: 2px; background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item.active .nav-label { font-weight: 600; }
.nav-item .nav-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.65; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item .nav-label { flex: 1; }
.nav-count { font-size: 11px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.nav-badge {
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 99px;
  background: var(--accent); color: #fff;
  letter-spacing: 0.02em;
}

.sidebar-section-label {
  font-size: 11px; font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 16px 18px 8px;
  display: block;
}

.sidebar-foot-actions {
  margin-top: auto; padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1px;
  background: var(--bg);
  position: sticky; bottom: 0;
}
/* No second border-top — foot-actions already draws the separator */
.sidebar-foot-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 0; width: 100%;
  background: transparent; border: none;
  border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-family: inherit; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.sidebar-foot-btn:hover { background: var(--hover); color: var(--ink); }
.user-block { flex: 1; min-width: 0; text-align: left; }
.user-name { display: block; font-size: 13px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { display: block; font-size: 11px; color: var(--ink-3); }

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

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 32px; height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
}
.topbar-spacer { flex: 1; }
.topbar-meta { font-size: 12px; color: var(--ink-3); }
.topbar-meta strong { color: var(--ink-2); font-weight: 500; }

.crumbs { font-size: 12.5px; color: var(--ink-3); }
.crumbs strong { color: var(--ink); font-weight: 500; }
.crumbs a { color: var(--ink-3); text-decoration: none; transition: color 0.12s; }
.crumbs a:hover { color: var(--accent-2); }
.crumbs .sep { color: var(--ink-4); margin: 0 6px; }

.page-wrap {
  padding: 28px 32px 80px;
  max-width: 1440px; width: 100%;
  margin: 0 auto;
}

/* ─── Page header ─── */
/* A page header is a label, not a magazine cover: one line of context,
   one heading at reading size, and the controls on the same baseline. */
.page-head {
  display: grid; grid-template-columns: 1fr auto;
  gap: 24px; align-items: center;
  padding-bottom: 16px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.page-eyebrow {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.page-eyebrow .ch { color: var(--ink-3); }
.page-eyebrow .ch::after { content: " /"; color: var(--ink-4); }
.page-title {
  font-size: 22px; font-weight: 650;
  letter-spacing: -0.015em; line-height: 1.25;
  margin: 0; color: var(--ink);
}
.page-title em { font-style: normal; color: inherit; font-weight: inherit; }
.page-sub {
  margin: 6px 0 0; font-size: 13px; line-height: 1.55;
  color: var(--ink-3); max-width: 72ch;
}
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ─── Filter bar ─── */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 24px; flex-wrap: wrap;
  padding-bottom: 18px; border-bottom: 1px solid var(--line-soft);
}
.search-box {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px;
  flex: 1; min-width: 220px; max-width: 380px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15); }
.search-box input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--ink);
}
.search-box input::placeholder { color: var(--ink-4); }
.search-box svg { color: var(--ink-3); flex-shrink: 0; }
.chip-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; transition: all 0.12s; font-family: inherit;
}
.chip-filter:hover { border-color: var(--line-strong); color: var(--ink); background: var(--hover); }
.chip-filter.on { background: rgba(var(--accent-rgb), 0.14); color: var(--accent-2); border-color: rgba(var(--accent-rgb), 0.45); }
.chip-filter .ct { font-size: 11px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.chip-filter.on .ct { color: var(--accent-2); opacity: 0.75; }

/* Compact tag chip used in sidebar tag filter and note editor */
.tag-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; background: transparent;
  border: 1px solid var(--line); border-radius: 5px;
  font-size: 11px; color: var(--ink-3);
  cursor: pointer; font-family: inherit;
  transition: all 0.12s; line-height: 1.4;
}
.tag-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.tag-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tag-chip-remove { margin-left: 4px; opacity: 0.6; }
.tag-chip-remove:hover { opacity: 1; }

/* Markdown preview inside the notes editor */
.note-preview {
  padding: 8px 0 64px;
  font-size: 15px; line-height: 1.65; color: var(--ink);
  font-family: var(--font-body, inherit);
}
.note-preview h1 { font-size: 28px; font-weight: 700; margin: 24px 0 12px; letter-spacing: -0.02em; }
.note-preview h2 { font-size: 22px; font-weight: 700; margin: 22px 0 10px; letter-spacing: -0.01em; }
.note-preview h3 { font-size: 18px; font-weight: 600; margin: 18px 0 8px; }
.note-preview p  { margin: 10px 0; }
.note-preview ul, .note-preview ol { margin: 10px 0; padding-left: 28px; }
.note-preview li { margin: 4px 0; }
.note-preview blockquote {
  border-left: 3px solid var(--accent); margin: 14px 0; padding: 4px 14px;
  color: var(--ink-2); background: var(--bg-2); border-radius: 0 4px 4px 0;
}
.note-preview code {
  background: var(--bg-2); padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 13px; color: var(--accent);
}
.note-preview pre {
  background: var(--bg-2); padding: 14px; border-radius: 8px;
  overflow-x: auto; margin: 14px 0; border: 1px solid var(--line);
}
.note-preview pre code { background: transparent; padding: 0; color: var(--ink); font-size: 13px; }
.note-preview a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.note-preview hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.note-preview table { border-collapse: collapse; margin: 14px 0; }
.note-preview th, .note-preview td { border: 1px solid var(--line); padding: 6px 10px; font-size: 13px; }
.note-preview th { background: var(--bg-2); }
.note-preview input[type="checkbox"] { margin-right: 8px; transform: translateY(1px); }

.entity-ref {
  display: inline-flex; align-items: center;
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.30);
  border-radius: 4px; padding: 0 6px;
  text-decoration: none !important; font-size: 90%;
  color: var(--accent) !important;
}
.entity-ref:hover { background: rgba(var(--accent-rgb), 0.20); }

/* ─── Command Palette (Cmd/Ctrl+K) ─── */
.cmdk-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 2000; display: flex; align-items: flex-start;
  justify-content: center; padding-top: 14vh;
}
.cmdk {
  width: 100%; max-width: 580px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  color: var(--ink-3);
}
.cmdk-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 15px; color: var(--ink); font-family: inherit;
}
.cmdk-kbd {
  display: inline-flex; align-items: center; padding: 2px 6px;
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg-3);
}
.cmdk-results { max-height: 380px; overflow-y: auto; padding: 6px 0; }
.cmdk-group {
  font-size: 11px; font-weight: 600;
  color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 16px 4px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 16px; background: transparent; border: none;
  text-align: left; cursor: pointer; color: var(--ink); font-family: inherit;
  font-size: 14px; transition: background 0.08s;
}
.cmdk-item:hover, .cmdk-item.active { background: var(--bg-3); }
.cmdk-item-icon { width: 18px; flex-shrink: 0; display: inline-flex; align-items: center;
                  justify-content: center; color: var(--ink-3); }
.cmdk-item.active .cmdk-item-icon, .cmdk-item:hover .cmdk-item-icon { color: var(--ink); }
.cmdk-item-label { flex: 1; }
.cmdk-item-hint { font-size: 12px; color: var(--ink-4); }
.cmdk-empty { padding: 24px 16px; text-align: center; color: var(--ink-4); font-size: 13px; }
.cmdk-footer {
  display: flex; gap: 16px; padding: 10px 16px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-4);
}

/* ─── Empty state ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 56px 24px;
  color: var(--ink-3);
}
.empty-state-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); margin-bottom: 18px;
}
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--ink); }
.empty-state-sub { font-size: 13px; margin-top: 6px; max-width: 44ch; line-height: 1.55; }

/* ─── Activity feed (dashboard) ─── */
.activity-feed { display: flex; flex-direction: column; }
.activity-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  transition: background 0.08s;
}
.activity-row:last-child { border-bottom: none; }
.activity-row[role="button"] { cursor: pointer; }
.activity-row[role="button"]:hover { background: var(--hover); }
.activity-icon {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-3);
}
.activity-icon.ok     { background: rgba(var(--success-rgb),.12); border-color: rgba(var(--success-rgb),.32); color: var(--green); }
.activity-icon.danger { background: rgba(229,83,75,.12);  border-color: rgba(229,83,75,.32);  color: var(--red); }
.activity-icon.info   { background: rgba(var(--accent-rgb),.12); border-color: rgba(var(--accent-rgb),.30); color: var(--accent); }
.activity-body { flex: 1; min-width: 0; }
.activity-main { font-size: 13px; color: var(--ink); }
.activity-main strong { font-weight: 600; }
.activity-action { color: var(--ink-2); margin-left: 4px; }
.activity-details {
  font-size: 11px; color: var(--ink-4); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity-time { font-size: 11px; color: var(--ink-4); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ─── Onboarding wizard ─── */
.wizard-modal { width: 560px; max-width: 95vw; }
.wizard-steps {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 8px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.wizard-step { display: flex; align-items: center; gap: 8px; }
.wizard-step + .wizard-step::before {
  content: ""; width: 22px; height: 1px; background: var(--line); margin: 0 2px;
}
.wizard-step-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-3);
  transition: all 0.15s;
}
.wizard-step.current .wizard-step-dot {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.wizard-step.done .wizard-step-dot {
  background: rgba(var(--success-rgb),.15); border-color: rgba(var(--success-rgb),.4); color: var(--green);
}
.wizard-step-label { font-size: 12px; color: var(--ink-3); }
.wizard-step.current .wizard-step-label { color: var(--ink); font-weight: 600; }
.wizard-pane { padding: 6px 0; }
.wizard-h { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--ink); }
.wizard-p { font-size: 13px; color: var(--ink-2); margin: 0; line-height: 1.55; }

/* ─── Bulk action bar ─── */
.bulk-bar {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; z-index: 500;
  animation: bulkBarIn 0.18s ease-out;
}
@keyframes bulkBarIn { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.bulk-bar-count { font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; }
.bulk-bar-actions { display: flex; gap: 6px; }
.bulk-checkbox-col { width: 32px; }
.bulk-checkbox-col input { transform: translateY(1px); cursor: pointer; }

/* ─── Stat strip ─── */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0; margin-bottom: 36px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.stat-card {
  padding: 16px 20px 18px;
  border-right: 1px solid var(--line);
  background: transparent; position: relative;
}
.stat-card:last-child { border-right: none; }
.stat-label {
  font-size: 12px; font-weight: 500;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.1;
}
.stat-value em { color: inherit; font-style: normal; }
.stat-delta {
  margin-top: 6px; font-size: 12px;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ─── Table ─── */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  overflow-x: auto; /* table content can scroll horizontally on narrow screens */
  overflow-y: hidden;
}
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data thead th {
  text-align: left;
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 16px; background: var(--bg-3);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data tbody tr { transition: background 0.1s; }
table.data tbody tr:hover { background: var(--hover); }
table.data td {
  padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; color: var(--ink-2);
}
table.data tbody tr:last-child td { border-bottom: none; }
/* Figures line up column-to-column: mono digits, right-aligned, tabular. */
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
table.data .em { color: var(--ink); font-weight: 600; }

/* ─── Status chips ─── */
/* Status chips stay pill-shaped — they read as labels, not controls. */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.chip.ok    { background: rgba(var(--success-rgb),0.14); color: var(--green); }
.chip.warn  { background: rgba(217,163,43,0.16); color: var(--yellow); }
.chip.bad   { background: rgba(229,83,75,0.16); color: var(--red); }
.chip.muted { background: var(--bg-3); color: var(--ink-3); border: 1px solid var(--line-soft); }
.chip.blue  { background: rgba(76,154,255,0.14); color: var(--blue); }
.chip.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ─── Avatars ─── */
.av { display: inline-flex; align-items: center; gap: 10px; }
.av-circle {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0;
}
/* Flat, desaturated initials — an avatar identifies a person, it
   doesn't need to be the brightest thing in the row. */
.av-c1 { background: #3E5C8A; }
.av-c2 { background: #3B6E63; }
.av-c3 { background: #6B5B8A; }
.av-c4 { background: #8A6A4A; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line-strong);
  color: var(--ink-2); font-weight: 600; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Buttons ─── */
/* Rectangles with a small radius. Pills read as tags; these are controls. */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--ink);
  cursor: pointer; text-decoration: none; transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: var(--bg-3); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35); }
.btn-primary, .btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover, .btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); border-color: transparent; }
.btn-danger { background: rgba(229,83,75,0.14); color: var(--red); border-color: rgba(229,83,75,0.32); }
.btn-danger:hover { background: rgba(229,83,75,0.22); border-color: rgba(229,83,75,0.45); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn .arrow { transition: transform 0.18s; }
.btn:hover .arrow { transform: translateX(3px); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ─── Panel ─── */
.panel {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 20px 22px;
}
.panel-title {
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 12px;
}
.panel-h {
  font-size: 22px; font-weight: 600; letter-spacing: -0.015em;
  margin: 0 0 4px; color: var(--ink); font-variant-numeric: tabular-nums;
}
.panel-h em { font-style: normal; color: inherit; }
.panel-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 16px; max-width: 72ch; }

/* ─── Form / Drawer ─── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity 0.18s; z-index: 50;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 580px; max-width: 92vw;
  background: var(--paper); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.32,0.72,0.28,1);
  z-index: 51; overflow-y: auto; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--paper); z-index: 1;
}
.drawer-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.drawer-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2); transition: all 0.12s;
}
.drawer-close:hover { background: var(--bg-3); color: var(--ink); border-color: var(--line-strong); }
.drawer-body { padding: 28px; flex: 1; }
.drawer-foot {
  padding: 16px 28px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--paper); position: sticky; bottom: 0;
}

.form-grid { display: grid; gap: 18px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 0; }
/* Sentence case. Uppercase micro-caps on every field turns a form
   into a wall of shouting; save them for table headers. */
.field label, .field-label {
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-2);
}
.field input, .field select, .field textarea,
.input, .inputx {
  padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; font-size: 13.5px; outline: none;
  color: var(--ink); transition: border-color 0.12s, box-shadow 0.12s;
  font-family: inherit; width: 100%;
}
.field input::placeholder, .field textarea::placeholder,
.input::placeholder, .inputx::placeholder { color: var(--ink-4); }
.field input:focus, .field select:focus, .field textarea:focus,
.input:focus, .inputx:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.20);
}
.field textarea { resize: vertical; min-height: 88px; }

/* Kill the browser autofill repaint that turns inputs light.
   The big inset box-shadow paints over Chrome/Safari's fill colour. */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus,
.input:-webkit-autofill,
.inputx:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
          box-shadow: 0 0 0 1000px var(--bg-2) inset;
  transition: background-color 9999s ease-in-out 0s;
}
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.field-error { font-size: 12px; color: var(--red); display: none; }
.field.has-error input { border-color: var(--red); }
.field.has-error .field-error { display: block; }

/* ─── Detail rows ─── */
.detail-section { margin-bottom: 32px; }
.detail-section h4 {
  margin: 0 0 12px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.detail-row {
  display: grid; grid-template-columns: 150px 1fr;
  gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .l { color: var(--ink-3); }
.detail-row .v { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ─── Empty state ─── */
.empty { text-align: center; padding: 64px 24px; color: var(--ink-3); }
.empty-h { font-size: 18px; font-weight: 600; color: var(--ink); margin-bottom: 8px; letter-spacing: -0.015em; }

/* ─── Burndown ─── */
.bd-row {
  display: grid; grid-template-columns: 150px 1fr 90px;
  gap: 14px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.bd-row:last-child { border-bottom: none; }
.bd-bar { position: relative; height: 6px; background: var(--bg-3); border-radius: 99px; overflow: hidden; }
.bd-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.bd-bar > span.ok   { background: var(--green); }
.bd-bar > span.warn { background: var(--yellow); }
.bd-bar > span.bad  { background: var(--red); }
.bd-num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }

/* ─── Section heading ─── */
.section-h { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin: 24px 0 12px; color: var(--ink); }
.section-h em { font-style: normal; color: inherit; }

/* ─── Split view ─── */
.split-view { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }

/* ═══════════════════════════════════════════════════════════════
   AUTH LAYOUT
═══════════════════════════════════════════════════════════════ */

.auth {
  display: grid; grid-template-columns: 1fr; min-height: 100vh;
}

/* Marketing panel */
.auth-mkt {
  /* Marketing panel hidden — auth pages show a single centered form module. */
  display: none;
}
.auth-brand {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-weight: 700; font-size: 26px; letter-spacing: -0.03em;
  color: var(--ink); text-decoration: none;
  position: relative; z-index: 2;
}
.auth-brand .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  display: inline-block; transform: translateY(-3px);
}
.auth-mkt-eyebrow {
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-3);
  margin: 32px 0 22px;
  display: inline-flex; align-items: center; gap: 12px;
  position: relative; z-index: 2;
}
.auth-mkt-eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--accent); }
.auth-mkt h1 {
  font-size: clamp(36px, 4.4vw, 56px); font-weight: 700;
  letter-spacing: -0.04em; line-height: 1.04; margin: 0;
  text-wrap: balance; max-width: 13ch; position: relative; z-index: 2;
}
.auth-mkt h1 em { color: inherit; font-style: normal; font-weight: inherit; }
.auth-mkt-lede {
  margin: 22px 0 0; font-size: 16px; line-height: 1.55;
  color: var(--ink-2); max-width: 42ch; position: relative; z-index: 2;
}
.auth-quote {
  margin-top: auto; padding: 24px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-2);
  position: relative; z-index: 2; max-width: 520px;
}
.auth-quote-mark {
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.auth-quote-mark::before { content: ""; width: 18px; height: 1px; background: var(--accent); }
.auth-quote-text {
  font-size: 18px; line-height: 1.42; letter-spacing: -0.015em;
  color: var(--ink); margin: 0 0 18px; text-wrap: pretty;
}
.auth-quote-text em { color: inherit; font-style: normal; }
.auth-quote-by { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.auth-quote-by .av {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: var(--ink-2);
}
.auth-quote-by .nm { font-weight: 600; color: var(--ink); }
.auth-quote-by .role { font-size: 12px; color: var(--ink-3); }
.auth-trusted {
  margin-top: 24px;
  font-size: 12px; color: var(--ink-4);
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.auth-trusted .star { color: var(--accent); }

/* Form panel */
.auth-form-wrap {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 48px; position: relative;
}
.auth-form-top {
  position: absolute; top: 32px; right: 48px;
  font-size: 13px; color: var(--ink-3);
}
.auth-form-top a { color: var(--accent-2); font-weight: 500; margin-left: 8px; }
.auth-form-top a:hover { color: var(--accent-2); }
.auth-form { width: 100%; max-width: 380px; }
.auth-eyebrow {
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-3);
  margin-bottom: 10px; display: inline-flex; align-items: center; gap: 8px;
}
.auth-eyebrow .ch { color: var(--ink-3); }
.auth-form h2 {
  font-size: 26px; font-weight: 650; letter-spacing: -0.02em;
  line-height: 1.15; margin: 0 0 6px; color: var(--ink);
}
.auth-form h2 em { color: inherit; font-style: normal; }
.auth-form .sub {
  margin: 0 0 18px; font-size: 14.5px; color: var(--ink-2);
  line-height: 1.5; max-width: 36ch;
}

/* Sep divider */
.sep {
  display: flex; align-items: center; gap: 12px; margin: 16px 0;
  font-size: 11.5px; color: var(--ink-4);
}
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Auth field overrides */
.auth-form .field { margin-bottom: 12px; }
.auth-form .field label {
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2px;
}
.auth-form .field label .hint-link {
  font-size: 12px; font-weight: 400; color: var(--accent-2);
}
.auth-form .field input {
  padding: 11px 15px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 15px; outline: none; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit;
}
.auth-form .field input::placeholder { color: var(--ink-4); }
.auth-form .field input:hover { border-color: var(--line-strong); }
.auth-form .field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.22);
}
/* Autofill focus keeps the surface fill AND the focus ring */
.auth-form .field input:-webkit-autofill { font-size: 15px; }
.auth-form .field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset, 0 0 0 3px rgba(var(--accent-rgb), 0.18);
          box-shadow: 0 0 0 1000px var(--bg-2) inset, 0 0 0 3px rgba(var(--accent-rgb), 0.22);
}

/* Password field with show/hide toggle */
.field-affix { position: relative; display: flex; }
.field-affix input { width: 100%; padding-right: 46px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; border: none; background: transparent;
  color: var(--ink-3); cursor: pointer; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.12s, background 0.12s;
}
.pw-toggle:hover { color: var(--ink); background: var(--bg-3); }
.pw-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.4); }
.pw-toggle svg { width: 18px; height: 18px; display: block; }
.pw-toggle .eye-off { display: none; }
.pw-toggle.is-on .eye-on  { display: none; }
.pw-toggle.is-on .eye-off { display: block; }
[dir="rtl"] .field-affix input { padding-right: 15px; padding-left: 46px; }
[dir="rtl"] .pw-toggle { right: auto; left: 6px; }
.auth-form .field-hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* Password strength */
.pw-strength { display: flex; gap: 4px; margin-top: 8px; }
.pw-strength i { flex: 1; height: 3px; border-radius: 2px; background: var(--bg-3); display: block; }
.pw-strength.s1 i:nth-child(-n+1) { background: var(--red); }
.pw-strength.s2 i:nth-child(-n+2) { background: var(--yellow); }
.pw-strength.s3 i:nth-child(-n+3) { background: var(--green); }
.pw-strength.s4 i { background: var(--green); }

/* Checkbox */
.check { display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; user-select: none; margin: 4px 0 18px; }
.check input { position: absolute; opacity: 0; }
.check .box {
  width: 16px; height: 16px; border: 1.5px solid var(--line-strong);
  border-radius: 4px; background: var(--bg-2); flex-shrink: 0; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center; transition: all 0.12s;
}
.check input:checked ~ .box { background: var(--accent); border-color: var(--accent); }
.check input:checked ~ .box::after {
  content: ""; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg) translateY(-1px);
}
.check .lbl { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.check .lbl a { color: var(--accent-2); }

/* Auth primary button */
.btn-auth-primary {
  width: 100%; padding: 11px 18px; margin-top: 2px;
  background: var(--accent); border: 1px solid var(--accent);
  border-radius: 6px; font-size: 14.5px; font-weight: 600; color: #fff;
  cursor: pointer; font-family: inherit; transition: background 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-auth-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-auth-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.40); }
.btn-auth-primary .arrow { transition: transform 0.15s; }
.btn-auth-primary:hover .arrow { transform: translateX(3px); }
.btn-auth-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* SSO / social sign-in buttons */
.sso-group { display: grid; gap: 8px; }
.btn-sso {
  width: 100%; padding: 10px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--ink); font-size: 14px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: border-color 0.14s, background 0.14s;
}
.btn-sso:hover { border-color: var(--line-strong); background: var(--bg-3); }
.btn-sso:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.25); }
.btn-sso svg, .btn-sso img { width: 18px; height: 18px; flex-shrink: 0; }
.btn-sso-disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sso-disabled:hover { border-color: var(--line); background: var(--bg-2); transform: none; }
.sso-soon {
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 99px; background: var(--bg-3); color: var(--ink-3);
}

/* Remember-me + forgot row */
.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 0 14px; gap: 12px;
}
.auth-row .check { margin: 0; }
.auth-row .forgot { font-size: 13px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.auth-row .forgot:hover { color: var(--accent-2); }

.form-foot { margin-top: 22px; text-align: center; font-size: 13.5px; color: var(--ink-3); }
.form-foot a { color: var(--accent-2); font-weight: 500; }
.form-foot a:hover { color: var(--accent-2); }

.auth-foot {
  position: absolute; bottom: 24px; left: 48px; right: 48px;
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--ink-4);
}
.auth-foot a { color: var(--ink-3); }
.auth-foot a:hover { color: var(--ink); }

/* Envelope illustration */
.envelope {
  width: 84px; height: 84px; margin: 0 auto 24px;
  border: 1.5px solid var(--accent); border-radius: 14px;
  position: relative; background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
}
.envelope::before {
  content: ""; position: absolute; top: 14px; left: 14px; right: 14px; height: 32px;
  border: 1.5px solid var(--accent); border-bottom: none;
  transform: skewY(-12deg); transform-origin: left; border-radius: 4px 4px 0 0;
}
.envelope::after {
  content: ""; width: 32px; height: 32px; background: var(--accent);
  border-radius: 50%; position: absolute; top: -10px; right: -10px;
}
.success-ring {
  width: 84px; height: 84px; margin: 0 auto 24px; border-radius: 50%;
  background: rgba(46,204,154,0.12); border: 1.5px solid var(--accent-3);
  display: flex; align-items: center; justify-content: center; color: var(--accent-3);
}

/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */

.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink); padding: 11px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-lg); z-index: 100;
  display: none; align-items: center; gap: 10px;
}
.toast.show, .toast.toast-ok, .toast.toast-err { display: flex; animation: toastIn 0.22s; }
.toast.toast-ok  { border-left: 3px solid var(--green); }
.toast.toast-err { border-left: 3px solid var(--red); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-x {
  background: none; border: none; color: var(--ink-3); cursor: pointer;
  font-size: 14px; padding: 0 0 0 8px; line-height: 1;
}
.toast-x:hover { color: var(--ink); }

/* ═══════════════════════════════════════════════════════════════
   NOTES EDITOR
═══════════════════════════════════════════════════════════════ */

/* Escape page-wrap padding so the editor fills edge-to-edge vertically.
   Width steps up on bigger screens so the note doesn't float in a sea of
   black on 4K / ultrawide monitors, but stays prose-readable on a laptop. */
.page-view-shell {
  max-width: 760px; margin: -48px auto 0;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 56px);
  padding: 0 8px 80px;
}
@media (min-width: 1400px) { .page-view-shell { max-width: 900px;  } }
@media (min-width: 1800px) { .page-view-shell { max-width: 1080px; } }
@media (min-width: 2400px) { .page-view-shell { max-width: 1240px; } }

.page-view-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.page-view-toolbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-view-toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.page-view-back {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  text-decoration: none; white-space: nowrap;
  transition: color 0.12s;
}
.page-view-back:hover { color: var(--ink); }

.page-view-header { padding: 24px 0 6px; }

/* Explicit dark background — 'transparent' defers to browser field colour (white in light mode) */
.page-view-title {
  width: 100%;
  background: var(--bg); color: var(--ink);
  border: none; outline: none;
  font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em; font-family: inherit;
  line-height: 1.25; padding: 0;
}
.page-view-title::placeholder { color: var(--ink-4); }

.page-view-body { padding: 16px 0; }

.page-view-content {
  width: 100%; display: block;
  background: var(--bg); color: var(--ink);
  border: none; outline: none; resize: none;
  font-size: 15px; line-height: 1.75; font-family: inherit;
  padding: 0; min-height: 480px;
}
.page-view-content::placeholder { color: var(--ink-4); }

.page-view-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3);
}
.page-view-wordcount { font-size: 11.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════════════════════
   LEGACY BACKWARD-COMPAT ALIASES
   Existing page HTML continues to work without changes.
═══════════════════════════════════════════════════════════════ */

/* Old sidebar wrappers */
.main-column { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.main-content { flex: 1; padding: 40px 32px 80px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.sidebar-brand-name { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-agency-name { font-size: 11.5px; color: var(--ink-3); }
.sidebar-collapse-btn { background: none; border: none; color: var(--ink-3); cursor: pointer; padding: 4px; margin-left: auto; border-radius: 4px; }
.sidebar-collapse-btn:hover { color: var(--ink); background: var(--bg-2); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-bottom { border-top: 1px solid var(--line); padding: 8px 0; }
.sidebar-section { padding: 8px 14px 4px; }
.sidebar-section-label {
  font-size: 11px; font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 8px 10px 4px; display: block;
}
.sidebar-section-label-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px; }
.sidebar-pages-add { background: none; border: none; color: var(--ink-4); cursor: pointer; padding: 2px; border-radius: 3px; }
.sidebar-pages-add:hover { color: var(--ink); background: var(--bg-2); }
.sidebar-pages-empty { font-size: 12px; color: var(--ink-4); padding: 4px 10px 8px; }
.sidebar-pages-new { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
.sidebar-pages-input { background: transparent; border: none; outline: none; color: var(--ink); font-size: 13px; font-family: inherit; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2);
  text-decoration: none; transition: background 0.12s, color 0.12s;
  font-weight: 500;
}
.side-link:hover { background: var(--hover); color: var(--ink); }
.side-link.active { background: var(--bg-3); color: var(--ink); font-weight: 600; }
.side-link.active svg { color: var(--accent); }
.side-link svg, .side-icon {
  width: 15px; height: 15px; flex-shrink: 0; opacity: 0.65;
  stroke: currentColor; fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.side-link:hover svg, .side-link.active svg { opacity: 1; }
.side-link--admin { margin-top: 2px; }
.side-link-row { position: relative; display: flex; align-items: center; }
.side-link-row .side-link { flex: 1; }
.side-link-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link--page { font-size: 12.5px; }
.page-menu-btn { background: none; border: none; color: var(--ink-4); cursor: pointer; padding: 4px 6px; font-size: 14px; border-radius: 4px; }
.page-menu-btn:hover { color: var(--ink); background: var(--bg-2); }

/* Sidebar resize handle */
.sidebar-resize-handle {
  position: absolute; right: -3px; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 10;
}
.sidebar-resize-handle:hover, .sidebar-resize-handle.dragging {
  background: var(--accent);
}

/* TabBar */
.tab-bar {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
  overflow-x: auto; flex-shrink: 0; min-height: 0; max-height: 0;
  overflow: hidden; /* hidden by default in new design */
}

/* Sidebar avatar */
.sidebar-avatar-wrap { padding: 4px 14px 8px; }
.sidebar-avatar-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 6px;
  background: transparent; border: none; cursor: pointer; color: var(--ink);
  font-family: inherit; transition: background 0.12s;
}
.sidebar-avatar-btn:hover { background: var(--bg-2); }
.sidebar-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--ink-2); flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* User popup */
.user-popup-overlay { position: fixed; inset: 0; z-index: 100; }
.user-popup {
  position: fixed; bottom: 72px; left: 8px; width: 224px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  z-index: 101; padding: 6px;
}
.user-popup-email {
  padding: 8px 10px 6px;
  font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-popup-divider { height: 1px; background: var(--line); margin: 4px 0; }
.user-popup-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2);
  background: transparent; border: none; cursor: pointer; width: 100%; text-align: left;
  font-family: inherit; text-decoration: none; transition: background 0.1s, color 0.1s;
}
.user-popup-item:hover { background: var(--bg-3); color: var(--ink); }
.user-popup-item--danger { color: var(--red); }
.user-popup-item--danger:hover { background: rgba(229,83,75,0.12); color: var(--red); }

/* Page context menu */
.page-menu-overlay { position: fixed; inset: 0; z-index: 200; }
.page-menu-dropdown {
  position: fixed; background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow-md);
  z-index: 201; min-width: 180px; padding: 4px;
}
.page-menu-header { font-size: 11px; font-weight: 600; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 10px; }
.page-menu-divider { height: 1px; background: var(--line); margin: 3px 0; }
.page-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 5px;
  font-size: 13px; color: var(--ink-2);
  background: transparent; border: none; cursor: pointer; width: 100%; text-align: left;
  font-family: inherit; text-decoration: none; transition: background 0.1s;
}
.page-menu-item:hover { background: var(--bg-3); color: var(--ink); }
.page-menu-item--danger { color: var(--red); }
.page-menu-item--danger:hover { background: rgba(229,83,75,0.12); }

/* Settings modal */
.smodal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.82);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.smodal {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); width: 700px; max-width: 95vw;
  max-height: 90vh; display: flex; overflow: hidden;
}
.smodal--sm { width: 420px; }
.smodal-nav {
  width: 180px; flex-shrink: 0; border-right: 1px solid var(--line);
  padding: 24px 12px;
}
.smodal-nav-section { font-size: 11px; font-weight: 600; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 10px 10px; }
.smodal-nav-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2); background: transparent; border: none;
  cursor: pointer; width: 100%; font-family: inherit; transition: all 0.1s;
}
.smodal-nav-item:hover { background: var(--hover); color: var(--ink); }
.smodal-nav-item.active { background: var(--bg-3); color: var(--ink); font-weight: 600; }
.smodal-nav-icon { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; flex-shrink: 0; }
.smodal-body { flex: 1; overflow-y: auto; padding: 28px 32px; position: relative; }
.smodal-close {
  position: absolute; top: 16px; right: 16px;
  background: transparent; border: 1px solid var(--line); border-radius: 50%;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-3);
}
.smodal-close:hover { color: var(--ink); background: var(--bg-2); }
.smodal-page-title { font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 4px; letter-spacing: -0.02em; }
.smodal-page-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 24px; }
.smodal-section-title { font-size: 11px; font-weight: 600; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.smodal-divider { height: 1px; background: var(--line); margin: 0 0 16px; }
.smodal-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0; }
.smodal-setting-info { flex: 1; }
.smodal-setting-label { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.smodal-setting-sub { font-size: 12px; color: var(--ink-3); }
.smodal-theme-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; cursor: pointer; transition: border-color 0.12s;
}
.theme-swatch:hover { border-color: var(--accent); }
.swatch-active { border-color: var(--accent); }
.theme-swatch-preview { width: 48px; height: 32px; border-radius: 5px; }
/* Each swatch shows its own surface plus a stripe of its accent, so
   the picker previews what actually changes. */
.theme-swatch-preview { position: relative; overflow: hidden; border: 1px solid var(--line); }
.theme-swatch-preview::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
}
.theme-swatch-midnight { background: #0E1114; }
.theme-swatch-midnight::after { background: #2F6FE0; }
.theme-swatch-onyx     { background: #0B0C0D; }
.theme-swatch-onyx::after     { background: #10806F; }
.theme-swatch-arctic   { background: #0A1018; }
.theme-swatch-arctic::after   { background: #1273C4; }
.theme-swatch-rose     { background: #121110; }
.theme-swatch-rose::after     { background: #A75F2B; }
.theme-swatch-light    { background: #F5F6F8; }
.theme-swatch-light::after    { background: #1F63D1; }
.theme-swatch-name { font-size: 11.5px; font-weight: 500; color: var(--ink-3); }

/* Desktop app modal */
.desktop-install-steps { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.desktop-install-step { display: flex; gap: 12px; font-size: 13px; color: var(--ink-2); }
.desktop-install-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--bg-3);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--ink-2); flex-shrink: 0;
}

/* ConfirmDialog */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 400; display: flex; align-items: center; justify-content: center;
}
.confirm-box {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; width: 420px; max-width: 92vw; box-shadow: var(--shadow-lg);
}
.confirm-title { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 10px; letter-spacing: -0.02em; }
.confirm-msg { font-size: 14px; color: var(--ink-2); margin-bottom: 24px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Old button classes */
.btnx {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer; font-family: inherit;
  text-decoration: none; transition: background 0.12s, border-color 0.12s, color 0.12s; white-space: nowrap;
}
.btnx:hover { background: var(--bg-3); border-color: var(--line-strong); }
.btnx:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.35); }
.btnx-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btnx-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btnx-danger { background: rgba(229,83,75,0.14); border-color: rgba(229,83,75,0.32); color: var(--red); }
.btnx-danger:hover { background: rgba(229,83,75,0.22); }
.btnx-success { background: rgba(var(--success-rgb),0.14); border-color: rgba(var(--success-rgb),0.32); color: var(--green); }
.btnx-success:hover { background: rgba(var(--success-rgb),0.22); }
.btnx-sm { padding: 5px 10px; font-size: 12px; }
.btnx:disabled, .btnx[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Old card classes */
.cardx { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
.cardx-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.cardx-hd .title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.cardx-bd { padding: 16px 18px; }
.cardx-ft { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* Old table */
.tablex { width: 100%; border-collapse: collapse; font-size: 13px; }
.tablex th {
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 16px; background: var(--bg-3); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tablex td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--ink-2); }
.tablex tbody tr:last-child td { border-bottom: none; }
.tablex tbody tr:hover { background: var(--hover); }
.tablex .right { text-align: right; }
.tablex .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.tablex .muted { color: var(--ink-3); }
.tablex .center { text-align: center; }
.tablex .mono { font-family: var(--font-mono); }
.tablex .bold { font-weight: 600; color: var(--ink); }
.tablex .small { font-size: 12px; }

/* Old badge classes */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
}
.badge.success, .badge-on { background: rgba(var(--success-rgb),0.14); color: var(--green); }
.badge.danger              { background: rgba(229,83,75,0.16); color: var(--red); }
.badge.info                { background: rgba(76,154,255,0.14); color: var(--blue); }
.badge.warning             { background: rgba(217,163,43,0.16); color: var(--yellow); }
.badge-off                 { background: var(--bg-3); color: var(--ink-3); border: 1px solid var(--line-soft); }

/* Spinner */
.spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Button loading state — add class="loading" to show spinner in place of text */
.btn.loading {
  position: relative; color: transparent !important;
  pointer-events: none; cursor: wait;
}
.btn.loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  animation: spin .55s linear infinite;
}
.btn-accent.loading::after {
  border-color: rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.9);
}
.btn-danger.loading::after {
  border-color: rgba(229,83,75,0.25);
  border-top-color: var(--red);
}
/* Disabled buttons get a not-allowed cursor */
.btn[disabled]:not(.loading) { cursor: not-allowed; }

/* Save status indicator (PageView) */
.save-status {
  font-size: 12px; display: inline-flex; align-items: center; gap: 5px;
  transition: opacity .3s;
}
.save-status.idle   { opacity: 0; }
.save-status.saving { opacity: 0.6; color: var(--ink-3); }
.save-status.saved  { opacity: 1;   color: var(--green); }
.save-status.error  { opacity: 1;   color: var(--red); }

/* toast-bad alias */
.toast.toast-bad { border-left: 3px solid var(--red); display: flex; animation: toastIn 0.22s; }

/* Old modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62);
  backdrop-filter: blur(4px); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); width: 480px; max-width: 92vw; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.modal-bd { padding: 20px; flex: 1; overflow-y: auto; }
.modal-ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.iconbtn { background: none; border: none; color: var(--ink-3); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.iconbtn:hover { color: var(--ink); }

/* Old misc */
.stack { display: flex; flex-direction: column; gap: 14px; }
.right { text-align: right; }
.muted { color: var(--ink-3); }
.center { text-align: center; }
.bold, .name { font-weight: 600; color: var(--ink); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.status-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pills button {
  padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 500;
  background: transparent; border: 1px solid var(--line); color: var(--ink-2);
  cursor: pointer; font-family: inherit; transition: all 0.1s;
}
.status-pills button:hover { border-color: var(--line-strong); color: var(--ink); background: var(--hover); }
.status-pills button.active { background: rgba(var(--accent-rgb),0.14); border-color: rgba(var(--accent-rgb),0.45); color: var(--accent-2); }

/* Pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px 0; }
.pager-btn { background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-family: inherit; font-variant-numeric: tabular-nums; }
.pager-btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--bg-3); }
.pager-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Report tabs */
.report-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; }
/* Tabs read as a segmented control: shared row, active one filled. */
.report-tab {
  padding: 6px 14px; background: transparent; border: 1px solid var(--line);
  border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  cursor: pointer; font-family: inherit; transition: all 0.12s;
}
.report-tab:hover { border-color: var(--line-strong); color: var(--ink); background: var(--hover); }
.report-tab.active { background: rgba(var(--accent-rgb),0.14); color: var(--accent-2); border-color: rgba(var(--accent-rgb),0.45); font-weight: 600; }

/* Auth legacy */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.login-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 28px; letter-spacing: -0.02em; }
.login-btn { width: 100%; justify-content: center; border-radius: 8px; padding: 12px 18px; font-size: 14px; }
.login-error { background: rgba(229,83,75,0.12); border: 1px solid rgba(229,83,75,0.30); color: var(--red); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.login-success { background: rgba(var(--success-rgb),0.12); border: 1px solid rgba(var(--success-rgb),0.30); color: var(--green); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.auth-resend { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.auth-resend-prompt { font-size: 13px; color: var(--muted); }
.auth-resend input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--surface); color: var(--text); }
.btn-link { background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; text-align: start; align-self: flex-start; }
.btn-link:hover { color: var(--accent-2); text-decoration: underline; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* Home shell */
.home-shell { padding: 0; }
.home-metrics { margin-bottom: 16px; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.metric { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.metric-label { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.metric-value { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; color: var(--ink); font-variant-numeric: tabular-nums; }
.metric-hint { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.metric.neg .metric-value { color: var(--red); }
.metric.pos .metric-value { color: var(--green); }
.metric-revenue .metric-value { color: var(--ink); }
.skel { border-radius: 4px; background: var(--line); animation: pulse 1.2s ease-in-out infinite; }
.skel-label { height: 12px; width: 80px; margin-bottom: 8px; }
.skel-value { height: 28px; width: 60px; }
@keyframes pulse { 0%,100%{opacity:0.4} 50%{opacity:0.7} }

/* Progress bars (dashboard) */
.prog-list { display: flex; flex-direction: column; gap: 14px; }
.prog-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; gap: 8px; }
.prog-name { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.prog-pct, .prog-amt { font-size: 12px; font-weight: 700; flex-shrink: 0; }
.prog-track { height: 6px; background: var(--bg-3); border-radius: 99px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 99px; transition: width .4s ease; min-width: 2px; }
.prog-sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* Pages */
.page-card {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; color: var(--ink-2); text-decoration: none;
  transition: all 0.12s; background: var(--bg-3);
}
.page-card:hover { border-color: var(--line-strong); color: var(--ink); background: var(--bg-2); }
.page-card-icon { color: var(--ink-3); display: flex; }
.page-card-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pages-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Home hero / tiles */
.home-hero .cardx-bd { padding: 20px; }
.home-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-badges { display: flex; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--ink-3); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.home-tile { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 16px; text-decoration: none; transition: all 0.12s; }
.home-tile:hover { border-color: var(--line-strong); background: var(--bg-2); }
.tile-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.tile-sub { font-size: 12px; color: var(--ink-3); }

/* Error page */
.error-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--bg); }
.error-inner { text-align: center; max-width: 480px; }
.error-code { font-size: 64px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; color: var(--ink-4); margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.error-title { font-size: 26px; font-weight: 700; color: var(--ink); margin-bottom: 12px; letter-spacing: -0.02em; }
.error-msg { font-size: 15px; color: var(--ink-2); margin-bottom: 32px; line-height: 1.55; }

/* SuperAdmin stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-item { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }

/* Responsive */
@media (max-width: 1100px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); border-bottom: none; }
  .stat-card:nth-child(2) { border-right: none; }
  .stat-card:nth-child(1), .stat-card:nth-child(2) { border-bottom: 1px solid var(--line); }
  .split-view { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: repeat(2,1fr); }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; width: 100%; }
  .form-grid.cols-2 { grid-template-columns: 1fr; }
  .page-head { grid-template-columns: 1fr; gap: 18px; }
  .page-actions { justify-self: start; }
  .page-wrap { padding: 32px 20px 80px; }
  .auth { grid-template-columns: 1fr; }
  .auth-mkt { padding: 28px 28px 36px; min-height: auto; }
  .auth-mkt-eyebrow { margin: 28px 0 16px; }
  .auth-mkt h1 { font-size: 32px; }
  .auth-quote { display: none; }
  .auth-form-wrap { padding: 36px 24px 80px; }
  .auth-form-top { top: 14px; right: 24px; }
  .auth-foot { left: 24px; right: 24px; }
  .metrics-grid { grid-template-columns: repeat(2,1fr); }
  .home-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   PHONE INPUT COMPONENT
═══════════════════════════════════════════════════════════════ */

.phone-input-row {
  display: flex; align-items: stretch; gap: 0;
}

.phone-code-wrapper { position: relative; flex-shrink: 0; }

.phone-code-btn {
  display: flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-right: none; border-radius: 6px 0 0 6px;
  color: var(--ink); font-family: inherit; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: border-color 0.12s;
}
.phone-code-btn:hover { border-color: var(--line-strong); color: var(--ink); }

.phone-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 210px; max-height: 252px; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow-md);
  z-index: 500; padding: 4px;
}

.phone-dropdown-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; border: none; border-radius: 5px;
  background: transparent; color: var(--ink);
  font-family: inherit; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: background 0.1s;
}
.phone-dropdown-item:hover { background: var(--bg-3); }
.phone-dropdown-item.active { background: var(--bg-3); color: var(--accent); font-weight: 600; }

.phone-local-input {
  flex: 1; height: 42px; padding: 0 14px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 0 6px 6px 0;
  color: var(--ink); font-family: inherit; font-size: 13.5px;
  outline: none; transition: border-color 0.12s;
}
.phone-local-input:focus { border-color: var(--accent); }
.phone-local-input::placeholder { color: var(--ink-4); }

/* ── Blazor reconnect overlay ──────────────────────────────── */
#components-reconnect-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}
#components-reconnect-modal.components-reconnect-show {
  display: flex;
}
#components-reconnect-modal.components-reconnect-hide {
  display: none;
}
#components-reconnect-modal.components-reconnect-failed .reconnect-message,
#components-reconnect-modal.components-reconnect-rejected .reconnect-message {
  display: none;
}
#components-reconnect-modal.components-reconnect-failed .reconnect-failed-msg,
#components-reconnect-modal.components-reconnect-rejected .reconnect-failed-msg {
  display: block;
}
.reconnect-inner {
  background: var(--bg-2, #14181D);
  border: 1px solid var(--border, #232A32);
  border-radius: 12px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--ink, #e8eaf0);
  font-family: inherit;
}
.reconnect-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border, #2e3138);
  border-top-color: var(--accent, #2F6FE0);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.reconnect-message { font-size: 14px; color: var(--ink-3, #9399a6); }
.reconnect-failed-msg {
  display: none;
  font-size: 14px;
  color: var(--ink-3, #9399a6);
}
.reconnect-failed-msg a { color: var(--accent-2, #6FA6F5); text-decoration: none; }
.reconnect-failed-msg a:hover { text-decoration: underline; }

/* ─── Drag-and-drop reorder for table rows ──────────────────────────────── */
.drag-handle-cell { padding: 0 6px; text-align: center; cursor: grab; user-select: none; width: 32px; }
.drag-handle-cell:active { cursor: grabbing; }
.drag-handle {
  display: inline-block;
  color: var(--ink-4, #5a5f6c);
  font-size: 16px;
  letter-spacing: -2px;
  transform: rotate(90deg);
  transition: color 0.12s ease;
}
.drag-handle-cell:hover .drag-handle { color: var(--ink, #c8cdd6); }
table.data tr.drag-source { opacity: 0.45; background: var(--bg-2, rgba(255,255,255,0.02)); }
table.data tr.drag-over   { border-top: 2px solid var(--accent, #2F6FE0); }

/* ── Top navigation progress bar (driven by js/navprogress.js) ───────────── */
#nav-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2.5px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--accent, #2F6FE0);
  opacity: 0;
  z-index: 10000;
  pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
}
#nav-progress.nav-progress-on { opacity: 1; }
html[dir="rtl"] #nav-progress { transform-origin: 100% 50%; }

/* ── Skeleton placeholder helpers — extend the base `.skel` (pulse) above so
   loading states share one look. Match the final layout to avoid content jump. */
.skel-line  { height: .8rem; margin: .35rem 0; width: 100%; }
.skel-line.sk-60 { width: 60%; }
.skel-line.sk-40 { width: 40%; }
.skel-line.sk-80 { width: 80%; }
.skel-card  { height: 92px; border-radius: 12px; }
.skel-chart { height: 160px; border-radius: 12px; }
.skel-row td { padding: .55rem .6rem; }

/* ── Respect the OS "reduce motion" setting across the whole app ─────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
