/* ── Shared severity colours (not theme-driven, same in every theme) ─── */
:root {
  --danger: #DC2626;
  --warning: #D97706;
  --success: #059669;
}

/* ── 14 themes ─────────────────────────────────────────────────────────── */

/* 1. current — dark blue-gray + lime (main-site brand default) */
[data-theme="current"], :root {
  --bg: #1B2030;
  --surface: #222638;
  --surface-hover: #2E3447;
  --border: #374050;
  --border-light: #2A3040;
  --text: #FAFAFA;
  --text-secondary: #909AB0;
  --text-muted: #596070;
  --primary: #84D600;
  --primary-light: #1A280A;
  --primary-muted: #253614;
  --on-primary: #141824;
  --is-dark: 1;
  color-scheme: dark;
}

/* 2. soft-dark — warm dark + olive */
[data-theme="soft-dark"] {
  --bg: #1C1A17;
  --surface: #242118;
  --surface-hover: #2E2B22;
  --border: #3A362C;
  --border-light: #302D24;
  --text: #F5F0E8;
  --text-secondary: #A09880;
  --text-muted: #6A6254;
  --primary: #8B9A2E;
  --primary-light: #212610;
  --primary-muted: #2A3014;
  --on-primary: #F5F0E8;
  --is-dark: 1;
  color-scheme: dark;
}

/* 3. editorial-light — Stripe/Linear — pure white + slate + deep teal */
[data-theme="editorial-light"] {
  --bg: #FFFFFF;
  --surface: #FAFAFA;
  --surface-hover: #F4F6F8;
  --border: #E5E9EF;
  --border-light: #F0F2F5;
  --text: #0D1117;
  --text-secondary: #4A5568;
  --text-muted: #94A3B8;
  --primary: #0F766E;
  --primary-light: #F0FDFC;
  --primary-muted: #CCFBF1;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 4. warm-paper — cream paper + warm ink + olive (Stripe Atlas vibe) */
[data-theme="warm-paper"] {
  --bg: #F8F5EE;
  --surface: #FDFAF5;
  --surface-hover: #F2EDE3;
  --border: #E0D9CC;
  --border-light: #EBE5D8;
  --text: #2A2420;
  --text-secondary: #5A5048;
  --text-muted: #9A9088;
  --primary: #6B7C2A;
  --primary-light: #F4F6E8;
  --primary-muted: #E4E8C8;
  --on-primary: #FDFAF5;
  --is-dark: 0;
  color-scheme: light;
}

/* 5. corporate-cool — cool gray + navy + teal (Atlassian/Carbon vibe) */
[data-theme="corporate-cool"] {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-hover: #EEF1F6;
  --border: #DDE3EE;
  --border-light: #E8EDF5;
  --text: #1D2340;
  --text-secondary: #4A5580;
  --text-muted: #8C97B8;
  --primary: #0073B1;
  --primary-light: #E8F4FD;
  --primary-muted: #CCE8FA;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 6. high-contrast — white + near-black + saturated blue (gov.uk vibe) */
[data-theme="high-contrast"] {
  --bg: #FFFFFF;
  --surface: #F8F9FA;
  --surface-hover: #EAECEF;
  --border: #D4D8DD;
  --border-light: #EAECEF;
  --text: #0B0D0F;
  --text-secondary: #3D4043;
  --text-muted: #6B6F73;
  --primary: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-muted: #DBEAFE;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 7. notion-cream — warm near-white + warm near-black + forest green */
[data-theme="notion-cream"] {
  --bg: #FFFEF9;
  --surface: #FFFFFF;
  --surface-hover: #F7F5F0;
  --border: #E5E1DA;
  --border-light: #EEEAE4;
  --text: #1C1B1A;
  --text-secondary: #4A4842;
  --text-muted: #9A9890;
  --primary: #2D6A4F;
  --primary-light: #F0F8F4;
  --primary-muted: #D8EEE6;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 8. sunset-coral — warm cream-peach + deep coral red-orange */
[data-theme="sunset-coral"] {
  --bg: #FFF5F0;
  --surface: #FFFFFF;
  --surface-hover: #FFECE4;
  --border: #F5CFBC;
  --border-light: #FAE0D2;
  --text: #2C1810;
  --text-secondary: #7A4030;
  --text-muted: #B89080;
  --primary: #C94B28;
  --primary-light: #FFF0EB;
  --primary-muted: #FDDDD2;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 9. deep-forest — deep pine-green surface + cream ink + spring-green */
[data-theme="deep-forest"] {
  --bg: #0D1F0F;
  --surface: #142018;
  --surface-hover: #1E3022;
  --border: #2A402E;
  --border-light: #1E3022;
  --text: #F2F8F0;
  --text-secondary: #8AB890;
  --text-muted: #5A8060;
  --primary: #4ADE80;
  --primary-light: #0F2A14;
  --primary-muted: #143020;
  --on-primary: #0D1F0F;
  --is-dark: 1;
  color-scheme: dark;
}

/* 10. harbour-blue — pale slate-blue paper + deep navy + maritime blue */
[data-theme="harbour-blue"] {
  --bg: #EEF3FA;
  --surface: #FAFCFF;
  --surface-hover: #E4ECF5;
  --border: #C8D8EC;
  --border-light: #D8E6F4;
  --text: #0D2040;
  --text-secondary: #3A5580;
  --text-muted: #7A9CC0;
  --primary: #1B69C8;
  --primary-light: #EAF2FD;
  --primary-muted: #CCE2F8;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 11. clean-blue — royal blue on near-white (was: default) */
[data-theme="clean-blue"] {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-hover: #F0F2F5;
  --border: #E8ECF1;
  --border-light: #F0F2F5;
  --text: #1A1D23;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --primary: #2563EB;
  --primary-light: #EFF6FF;
  --primary-muted: #DBEAFE;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 12. sage-forest — forest green + green-tinted paper (was: nexa) */
[data-theme="sage-forest"] {
  --bg: #F6F9F7;
  --surface: #FFFFFF;
  --surface-hover: #F0F5F2;
  --border: #DAE6DE;
  --border-light: #EFF4F1;
  --text: #1A202C;
  --text-secondary: #4F6B58;
  --text-muted: #8CA698;
  --primary: #3F8957;
  --primary-light: #EFF4F1;
  --primary-muted: #DAE6DE;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 13. apricot-terracotta — vivid terracotta + peachy cream (was: firmable) */
[data-theme="apricot-terracotta"] {
  --bg: #FFF7F4;
  --surface: #FFFFFF;
  --surface-hover: #FFF1EC;
  --border: #F2DDD5;
  --border-light: #F9EDE8;
  --text: #2D1B14;
  --text-secondary: #6F4F40;
  --text-muted: #B89A8D;
  --primary: #E15A2C;
  --primary-light: #FFF1EC;
  --primary-muted: #FDDDD2;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

/* 14. heritage-amber — dark gold + warm cream (was: ckm) */
[data-theme="heritage-amber"] {
  --bg: #F9F6F0;
  --surface: #FFFFFF;
  --surface-hover: #F5F1EA;
  --border: #E4DCCF;
  --border-light: #F0EBE3;
  --text: #2C282C;
  --text-secondary: #54484E;
  --text-muted: #9C9498;
  --primary: #B57D26;
  --primary-light: #FDF6E9;
  --primary-muted: #F5E5C4;
  --on-primary: #FFFFFF;
  --is-dark: 0;
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body { min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

::selection { background: var(--primary); color: var(--on-primary); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

svg { width: 1em; height: 1em; flex-shrink: 0; display: inline-block; vertical-align: -2px; }

code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--surface-hover);
  padding: 1px 5px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Header ───────────────────────────────────────────────────────── */
.hdr {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(10px);
}
.hdr-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand-wrap { position: relative; min-width: 0; flex: 1; }
.brand {
  display: flex; align-items: center; gap: 14px;
  min-width: 0; width: 100%;
  padding: 6px 10px 6px 6px;
  margin: -6px -10px -6px -6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: all 0.15s;
}
.brand--clickable { cursor: pointer; }
.brand--clickable:hover { background: var(--surface-hover); border-color: var(--border); }
.brand--clickable.open { background: var(--surface-hover); border-color: var(--primary-muted); }
.brand-glyph {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1;
  background: var(--primary-light);
  border: 1px solid var(--primary-muted);
  flex-shrink: 0;
}
.brand-text { min-width: 0; flex: 1; }
.brand-text h1 {
  font-family: 'Fraunces', 'Sora', serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text p {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-chev {
  width: 14px; height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.brand.open .brand-chev { transform: rotate(180deg); color: var(--primary); }

.vertical-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 4px 8px rgba(0,0,0,0.08);
  z-index: 50;
}
.vertical-menu-eyebrow {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 6px;
}
.vertical-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 12px;
  border-radius: 10px;
  color: var(--text);
  transition: all 0.12s;
}
.vertical-opt:hover { background: var(--surface-hover); }
.vertical-opt.current { background: var(--primary-light); color: var(--primary); }
.v-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  flex-shrink: 0;
}
.vertical-opt.current .v-icon { background: var(--primary-light); border-color: var(--primary-muted); }
.v-name { flex: 1; font-size: 13.5px; font-weight: 600; }
.v-check { width: 16px; height: 16px; color: var(--primary); }

.hdr-tools { display: flex; align-items: center; gap: 10px; }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search input {
  width: 320px;
  padding: 10px 14px 10px 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  transition: all 0.15s;
}
.search input::placeholder { color: var(--text-muted); }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-muted); }

/* ─── Theme picker ─────────────────────────────────────────────────── */
.btn-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s;
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--primary); }

.theme-picker { position: relative; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 12.5px;
  transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--primary); background: var(--surface-hover); }
.theme-toggle:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-muted); }
.theme-toggle-eyebrow {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.theme-toggle .swatches { display: flex; gap: 2px; }
.theme-toggle .swatches span { width: 10px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.theme-toggle-name { font-weight: 600; color: var(--text); white-space: nowrap; }
.theme-toggle .chev { width: 12px; height: 12px; color: var(--text-muted); transition: transform 0.2s; }
.theme-toggle .chev.rot { transform: rotate(180deg); }

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 4px 8px rgba(0,0,0,0.08);
  z-index: 50;
}
.theme-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  text-align: left;
  color: var(--text);
  transition: all 0.12s;
}
.theme-opt:hover { background: var(--surface-hover); }
.theme-opt.active { background: var(--primary-light); color: var(--primary); }
.theme-opt .swatches { display: flex; gap: 2px; flex-shrink: 0; }
.theme-opt .swatches span { width: 12px; height: 18px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.08); }
.theme-opt .theme-name { flex: 1; font-size: 13px; font-weight: 600; }
.theme-opt .check { width: 16px; height: 16px; color: var(--primary); }

/* ─── Stat tiles ───────────────────────────────────────────────────── */
.stats {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 28px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s;
}
.stat-tile:hover { transform: translateY(-1px); border-color: var(--primary-muted); box-shadow: 0 4px 12px rgba(0,0,0,0.04); }
.stat-ico {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-ico svg { width: 18px; height: 18px; }
.stat-body { min-width: 0; flex: 1; }
.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.stat-value {
  font-family: 'Fraunces', 'Sora', serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}
.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Layout ───────────────────────────────────────────────────────── */
.layout {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 288px 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1024px) { .layout { grid-template-columns: 1fr; } }

/* ─── Sidebar ──────────────────────────────────────────────────────── */
.side {
  position: sticky;
  top: 110px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-right: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 1024px) { .side { position: static; max-height: none; } }

.side-hdr { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px; }
.side-hdr h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.side-reset {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
}
.side-reset:hover { text-decoration: underline; }
.side-foot {
  margin-top: auto;
  padding: 12px 4px 0;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  transition: border-color 0.15s;
}
.group:hover { border-color: var(--primary-muted); }
.group.has-active { border-color: var(--primary); }
.group.has-active::before {
  content: '';
  position: absolute;
  left: -1px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 99px;
}

.group-hdr {
  width: 100%;
  padding: 4px 6px 4px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  position: relative;
  min-height: 44px;
  border-radius: 12px;
  transition: background 0.12s;
}
.group:hover .group-hdr { background: var(--surface-hover); }
.group-hdr-main {
  flex: 1;
  text-align: left;
  padding: 8px 0;
  font: inherit;
  color: inherit;
  min-width: 0;
}
.group-label { display: block; }
.group-meta { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.group-active {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--on-primary);
  background: var(--primary);
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.01em;
  min-width: 22px;
  text-align: center;
}
.group-count {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 99px;
  min-width: 24px;
  text-align: center;
}
.group-sort, .group-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.group-sort svg, .group-toggle svg { width: 13px; height: 13px; }
.group-sort:hover, .group-toggle:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.group-sort.name { background: var(--primary-light); border-color: var(--primary-muted); color: var(--primary); }
.group-toggle svg { transition: transform 0.2s; }
.group-toggle svg.rot { transform: rotate(180deg); }

.group-body { border-top: 1px solid var(--border-light); }
.group-scroll { padding: 6px 6px 10px; }
.group-scroll--tall { max-height: 280px; overflow-y: auto; }
.group-scroll::-webkit-scrollbar { width: 6px; }

/* Quick-toggles + tri-state group on top */
.group-quick { padding: 4px; }
.group-quick .opt { padding: 8px 10px; }

/* Tri-state segmented control */
.tri {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border-light);
}
.group-quick .opt + .tri { border-top: 1px solid var(--border-light); }
.tri-label { font-size: 12.5px; color: var(--text); font-weight: 500; flex: 1; }
.tri-counts {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  font-feature-settings: "tnum";
  margin-right: 2px;
  white-space: nowrap;
}
.tri-buttons {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 1px;
}
.tri-buttons button {
  padding: 3px 7px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 5px;
  transition: all 0.12s;
  font-family: inherit;
}
.tri-buttons button:hover { color: var(--text); }
.tri-buttons button.on {
  background: var(--primary);
  color: var(--on-primary);
}

.opt {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.1s;
}
.opt:hover { background: var(--surface-hover); }
.opt input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
  position: relative;
}
.opt input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.opt input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px; left: 4px;
  width: 4px; height: 8px;
  border: solid var(--on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.opt-label {
  font-size: 12.5px;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opt-count {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-hover);
  padding: 1px 7px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* ─── Toolbar ──────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.tb-count { font-size: 13.5px; color: var(--text); }
.tb-count strong { font-weight: 700; color: var(--primary); }
.tb-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-muted);
  border-radius: 99px;
  transition: all 0.12s;
}
.chip:hover { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip svg { width: 11px; height: 11px; }
.tb-spacer { flex: 1; }

.tb-sort { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.tb-sort select {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
}
.tb-sort select:hover { border-color: var(--primary); }
.tb-sort select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-muted); }

.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-toggle button {
  padding: 7px 11px;
  color: var(--text-muted);
  transition: all 0.12s;
}
.view-toggle button svg { width: 16px; height: 16px; }
.view-toggle button:hover { color: var(--text); background: var(--surface-hover); }
.view-toggle button.on { background: var(--primary); color: var(--on-primary); }

/* ─── Empty state ──────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-muted);
}
.empty-mark {
  font-size: 56px;
  font-weight: 300;
  color: var(--border);
  font-family: 'Fraunces', serif;
  margin-bottom: 6px;
}
.empty p { font-size: 14px; margin-bottom: 10px; }
.btn-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}
.btn-link:hover { text-decoration: underline; }

/* ─── Card grid ────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.18s;
  overflow: hidden;
}
.card:hover {
  border-color: var(--primary-muted);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.05);
}
.card-rail {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.2s;
}
.card[data-tier="1"] .card-rail { background: linear-gradient(90deg, var(--primary), var(--success)); }
.card[data-tier="2"] .card-rail { background: var(--primary); opacity: 0.7; }
.card[data-tier="4"] .card-rail { background: var(--warning); opacity: 0.6; }

.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-titles { flex: 1; min-width: 0; }
.card-titles h3 {
  font-family: 'Fraunces', 'Sora', serif;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 4px;
}
.card-loc {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}
.card-loc svg { width: 11px; height: 11px; color: var(--text-muted); }
.card-loc .muted { color: var(--text-muted); }

.tier {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 6px;
  flex-shrink: 0;
}
.tier svg { width: 10px; height: 10px; }
.tier[data-tier="1"] { background: var(--primary); color: var(--on-primary); }
.tier[data-tier="2"] { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-muted); }
.tier[data-tier="3"] { background: var(--surface-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.tier[data-tier="4"] { background: var(--warning); color: #fff; opacity: 0.92; }

.ref-flag {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-c {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  transition: all 0.12s;
  max-width: 220px;
}
.chip-c:hover { background: var(--primary-light); border-color: var(--primary-muted); color: var(--primary); }
.chip-c svg { width: 12px; height: 12px; color: var(--text-secondary); }
.chip-c:hover svg { color: var(--primary); }
.chip-c .trunc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.addr {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
}

.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid transparent;
  border-radius: 99px;
  transition: all 0.12s;
}
.tag:hover { background: var(--primary-muted); }
.tag.on { background: var(--primary); color: var(--on-primary); }
.tag-more {
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 99px;
}
.tag-more:hover { color: var(--text); background: var(--surface-hover); }

.notes {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.notes.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.staff {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.staff-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.12s;
}
.staff-toggle:hover { color: var(--primary); }
.staff-toggle strong { color: var(--text); font-weight: 700; }
.staff-toggle svg { width: 13px; height: 13px; }
.staff-toggle .chev { width: 11px; height: 11px; transition: transform 0.18s; }
.staff-toggle .chev.rot { transform: rotate(180deg); }
.staff-list {
  margin-top: 10px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}
.staff-list li {
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 7px;
  line-height: 1.4;
}
.staff-name { font-weight: 600; color: var(--text); }
.staff-pos { color: var(--text-secondary); }
.staff-spec { color: var(--text-muted); font-style: italic; margin-left: 4px; }

.card-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 4px;
}
.meta-pill {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.meta-hours { font-size: 11px; color: var(--text-muted); }

/* ─── List view ────────────────────────────────────────────────────── */
.list-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  overflow-x: auto;
}
.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.list thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.list th {
  text-align: left;
  padding: 12px 16px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.list th.ar, .list td.ar { text-align: right; }
.list tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
.list tbody tr:last-child { border-bottom: none; }
.list tbody tr:hover { background: var(--surface-hover); }
.list td { padding: 12px 16px; color: var(--text); }
.list-name { font-weight: 600; color: var(--text); }
.list-addr { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-contact { font-size: 12px; }
.list-mail { color: var(--primary); }
.list-mail:hover { text-decoration: underline; }
.list-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.tag-mini {
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--primary-light);
  color: var(--primary);
}
.tag-more-mini { font-size: 9.5px; color: var(--text-muted); font-weight: 600; padding: 2px 6px; }

/* ─── Stage 2 hint ─────────────────────────────────────────────────── */
.stage2 {
  margin-top: 28px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: var(--primary-light);
  border: 1px dashed var(--primary-muted);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}
.stage2 strong { color: var(--primary); font-weight: 700; }
.stage2 svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }

/* ─── Footer ───────────────────────────────────────────────────────── */
.page-foot {
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 28px 48px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}

/* Small refinements */
@media (max-width: 768px) {
  .hdr-inner { padding: 14px 16px; flex-wrap: wrap; }
  .search input { width: 100%; }
  .stats { padding: 16px 16px 0; gap: 8px; }
  .stat-tile { padding: 14px; }
  .layout { padding: 16px; gap: 16px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ─── Loading state ─────────────────────────────────────────────── */
.rd-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-family: 'Sora', ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  color: var(--text-muted, #9CA3AF);
  gap: 10px;
}
.rd-spinner {
  width: 20px; height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: rd-spin 0.7s linear infinite;
}
@keyframes rd-spin { to { transform: rotate(360deg); } }

/* ─── Campaign stage pills ──────────────────────────────────────── */
.stage-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 0;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
  flex-wrap: wrap;
}
.stage-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 2px;
}
.stage-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.stage-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.stage-btn.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.stage-btn[data-stage="contacted"].active { background: #2563EB; border-color: #2563EB; }
.stage-btn[data-stage="responded"].active { background: #7C3AED; border-color: #7C3AED; }
.stage-btn[data-stage="won"].active       { background: #059669; border-color: #059669; }
.stage-btn[data-stage="paused"].active    { background: #D97706; border-color: #D97706; }
.stage-btn[data-stage="dropped"].active   { background: #DC2626; border-color: #DC2626; }

/* ─── Export / Campaign panel ───────────────────────────────────── */
.campaign-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s;
}
.campaign-panel:hover { border-color: var(--primary-muted); }
.cp-hdr {
  padding: 4px 6px 4px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cp-hdr-label { flex: 1; }
.cp-toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-secondary); transition: all 0.15s; cursor: pointer; font-family: inherit;
}
.cp-toggle-btn svg { width: 13px; height: 13px; transition: transform 0.2s; }
.cp-toggle-btn svg.rot { transform: rotate(180deg); }
.cp-body { padding: 10px; }
.cp-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px; }
.cp-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.cp-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.cp-btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.cp-btn.primary:hover { background: color-mix(in srgb, var(--primary) 85%, black); }
.cp-btn svg { width: 13px; height: 13px; }

/* Stage filter pills in sidebar */
.stage-filter-grid {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 10px;
}
.stage-filter-pill {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-secondary); cursor: pointer; transition: all 0.12s; font-family: inherit;
}
.stage-filter-pill:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.stage-filter-pill.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* Letter modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%; max-width: 680px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
}
.modal-hdr {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
}
.modal-title { flex: 1; font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all 0.15s;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-close svg { width: 14px; height: 14px; }
.modal-body { padding: 20px 24px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-help { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.modal-help code { font-family: monospace; background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.modal-textarea {
  width: 100%; min-height: 200px;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.6; resize: vertical;
  transition: border-color 0.15s;
}
.modal-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-muted); }
.modal-foot {
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}

/* Stage counts in sidebar stage section */
.stage-count-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px;
  font-size: 12px; color: var(--text-secondary);
}
.stage-count-row .sc-label { font-weight: 500; }
.stage-count-row .sc-val {
  font-weight: 700; font-size: 11px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 99px;
  color: var(--text-muted);
}

/* ─── Staff social links ─────────────────────────────────────────────────── */
.staff-social { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.staff-social-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  font-size: 9px; font-weight: 800; letter-spacing: -0.02em;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid var(--primary-muted);
  transition: all 0.12s; text-decoration: none;
}
.staff-social-link:hover { background: var(--primary); color: var(--on-primary); }

/* ─── Do Not Contact ─────────────────────────────────────────────────────── */

/* Icon button in card header — hidden until hover, permanent when flagged */
.dnc-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none; background: transparent;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  color: var(--text-muted);
  flex-shrink: 0;
}
.dnc-btn svg { width: 16px; height: 16px; }
.card:hover .dnc-btn                { opacity: 1; }
.dnc-btn:hover                      { background: var(--surface-hover); color: var(--text); }
.dnc-btn[data-status="partial"]     { opacity: 1; color: #D97706; }
.dnc-btn[data-status="partial"]:hover { background: #FEF3C7; color: #B45309; }
.dnc-btn[data-status="full"]        { opacity: 1; color: #DC2626; }
.dnc-btn[data-status="full"]:hover  { background: #FEE2E2; color: #B91C1C; }

/* DNC panel — inline below stage row */
.dnc-panel {
  border-top: 1px solid var(--border-light);
  padding: 10px 0 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dnc-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
}
.dnc-clear-btn {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 2px 6px; border-radius: 5px; transition: all 0.12s;
}
.dnc-clear-btn:hover { background: var(--surface-hover); color: var(--danger, #DC2626); }

.dnc-channels { display: flex; flex-direction: column; gap: 4px; }
.dnc-channel-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text);
}
.dnc-channel-row input[type="checkbox"] { flex-shrink: 0; accent-color: #DC2626; }
.dnc-channel-label { flex: 1; }
.dnc-channel-date {
  font-size: 10px; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px; white-space: nowrap;
  font-feature-settings: "tnum";
}
.dnc-channel-row.is-all { font-weight: 600; color: #DC2626; }
.dnc-channel-row.is-all input { accent-color: #DC2626; }

.dnc-reason {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 12px; line-height: 1.5;
  resize: none; min-height: 52px;
  transition: border-color 0.15s;
}
.dnc-reason:focus { outline: none; border-color: #DC2626; box-shadow: 0 0 0 3px #FEE2E2; }
.dnc-reason::placeholder { color: var(--text-muted); }
.dnc-saved-flash {
  font-size: 11px; font-weight: 700;
  color: var(--success, #059669);
  transition: opacity 0.3s;
}

/* List view DNC indicator */
.list-dnc {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  vertical-align: middle; margin-left: 4px;
}
.list-dnc[data-status="partial"] { color: #D97706; }
.list-dnc[data-status="full"]    { color: #DC2626; }
.list-dnc svg { width: 14px; height: 14px; }

/* Sidebar DNC counts */
.dnc-counts {
  display: flex; gap: 8px; padding: 6px 10px 8px;
  font-size: 11px; color: var(--text-secondary);
}
.dnc-count-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--border);
  font-weight: 600; font-size: 10.5px;
}
.dnc-count-pill.full    { color: #DC2626; border-color: #FECACA; background: #FEF2F2; }
.dnc-count-pill.partial { color: #D97706; border-color: #FDE68A; background: #FFFBEB; }