/* L4Law — Design System (Phase 1 · fatigue-free teal/slate refresh) */
/* Fonts: Plus Jakarta Sans (headings/UI), Inter (body), IBM Plex Mono (mono) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ─── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* Brand — Teal (primary). Calm, professional, low-arousal for long sessions. */
  --teal:          #0E9488;   /* primary    */
  --teal-mid:      #14B8A6;   /* hover/mid  */
  --teal-light:    #99F6E4;   /* accent on dark */
  --teal-dim:      rgba(20,184,166,0.10);
  --teal-border:   rgba(20,184,166,0.24);
  /* Accent — Amber. Token names kept as --gold*. */
  --gold:          #F59E0B;
  --gold-light:    #FBBF24;
  --gold-dim:      rgba(245,158,11,0.14);
  --gold-border:   rgba(245,158,11,0.32);

  /* Gradients (cards, buttons, accents) */
  --grad-teal:     linear-gradient(135deg, #14B8A6 0%, #0E9488 100%);   /* teal (primary) */
  --grad-gold:     linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);   /* amber */
  --grad-rose:     linear-gradient(135deg, #F472B6 0%, #DB2777 100%);   /* pink  */
  --grad-indigo:   linear-gradient(135deg, #818CF8 0%, #4F46E5 100%);
  --grad-mint:     linear-gradient(135deg, #34D399 0%, #059669 100%);   /* emerald */
  --grad-sky:      linear-gradient(135deg, #38BDF8 0%, #0284C7 100%);

  /* Surfaces (light default) — airy off-white, never pure-white glare */
  --bg:            #F4F7FA;
  --surface:       #FFFFFF;
  --surface-2:     #F5F8FA;
  --surface-3:     #EBF0F4;
  --border:        #E8EDF2;
  --border-strong: #D5DDE6;
  --sidebar-bg:    #FDFEFF;
  --topbar-bg:     rgba(255,255,255,0.90);

  /* Text — slate, never pure black (softer contrast = less fatigue) */
  --text:          #1F2A37;
  --text-muted:    #647587;
  --text-faint:    #9AA7B6;

  /* Semantic */
  --success:       #16A34A;
  --success-bg:    rgba(22,163,74,0.11);
  --warning:       #F59E0B;
  --warning-bg:    rgba(245,158,11,0.12);
  --danger:        #EF4444;
  --danger-bg:     rgba(239,68,68,0.11);
  --info:          #14B8A6;
  --info-bg:       rgba(20,184,166,0.11);

  /* Layout */
  --sidebar-w:     258px;
  --topbar-h:      62px;
  --radius-sm:     11px;
  --radius:        16px;
  --radius-lg:     22px;
  --shadow-sm:     0 1px 2px rgba(16,42,67,0.05), 0 1px 2px rgba(16,42,67,0.04);
  --shadow:        0 4px 16px rgba(16,42,67,0.07), 0 2px 6px rgba(16,42,67,0.04);
  --shadow-lg:     0 20px 48px rgba(16,42,67,0.14), 0 6px 16px rgba(16,42,67,0.08);
  --transition:    170ms cubic-bezier(0.4,0,0.2,1);

  /* ── Legacy aliases (map old CRM tokens to the LBM palette) ─────────────
     Keeps pre-Phase-0 views rendering correctly until each is migrated.
     var() resolves at use-time, so theme overrides flow through. */
  --navy:         var(--bg);
  --navy-light:   var(--surface);
  --navy-mid:     var(--surface-2);
  --navy-border:  var(--border-strong);
  --slate:        var(--text-muted);
  --slate-light:  var(--text);
  --white:        var(--text);
  --card-bg:      var(--surface);
  --input-bg:     var(--surface-2);
  --purple:       #7c3aed;
}

/* ─── DARK MODE TOKENS (deep navy, indigo accents) ───────────── */
[data-theme="dark"] {
  --bg:            #0A0E1A;
  --surface:       #141B2D;
  --surface-2:     #1C2540;
  --surface-3:     #283353;
  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);
  --text:          #E8ECF3;
  --text-muted:    #94A2BC;
  --text-faint:    #64748B;
  --teal:          #14B8A6;
  --teal-mid:      #2DD4BF;
  --teal-light:    #5EEAD4;
  --teal-dim:      rgba(20,184,166,0.16);
  --teal-border:   rgba(20,184,166,0.32);
  --gold-dim:      rgba(245,158,11,0.16);
  --gold-border:   rgba(245,158,11,0.30);
  --success-bg:    rgba(34,197,94,0.14);
  --warning-bg:    rgba(245,158,11,0.15);
  --danger-bg:     rgba(239,68,68,0.15);
  --info:          #2DD4BF;
  --info-bg:       rgba(20,184,166,0.16);
  --grad-teal:     linear-gradient(135deg, #2DD4BF 0%, #0E9488 100%);
  --sidebar-bg:    linear-gradient(195deg, #0F1424 0%, #0B0F1B 100%);
  --topbar-bg:     rgba(15,20,36,0.85);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow:        0 8px 22px rgba(0,0,0,0.45);
  --shadow-lg:     0 24px 56px rgba(0,0,0,0.6);
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4,h5 { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: -0.02em; line-height: 1.25; }

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ─── LAYOUT SHELL ───────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100dvh;
}

.app-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  gap: 0.75rem;
}

.app-sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0 2rem;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
}

.app-content {
  grid-column: 2;
  grid-row: 2;
  padding: 1.75rem;
  overflow: auto;
  min-height: calc(100dvh - var(--topbar-h));
  background: var(--bg);
}

/* ─── SIDEBAR NAV ────────────────────────────────────────────── */
.nav-section {
  padding: 0 0.875rem;
  margin-bottom: 1.5rem;
}

.nav-section-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 0.625rem;
  margin-bottom: 0.4rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8375rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}

.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; transition: all var(--transition); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover svg { opacity: 1; transform: scale(1.08); }

/* Colourful nav icons — a repeating palette across each section so the icon
   itself carries colour (matching the Quick Actions bar) instead of
   inheriting the link's plain muted text colour. Icons render via
   stroke="currentColor" in the markup, so setting `color` here recolours
   them with no markup changes. Active/hover states (below) still win via
   higher specificity, so the "current page" pill stays solid white. */
:root {
  --ic-1: #3a8ef6; --ic-2: #2eb87a; --ic-3: #c9922a; --ic-4: #a855f7;
  --ic-5: #ec4899; --ic-6: #06b6d4; --ic-7: #f2542d; --ic-8: #6366f1;
}
.nav-section a.nav-link:nth-of-type(8n+1) svg,
.nav-section button.nav-link:nth-of-type(8n+1) svg { color: var(--ic-1); }
.nav-section a.nav-link:nth-of-type(8n+2) svg,
.nav-section button.nav-link:nth-of-type(8n+2) svg { color: var(--ic-2); }
.nav-section a.nav-link:nth-of-type(8n+3) svg,
.nav-section button.nav-link:nth-of-type(8n+3) svg { color: var(--ic-3); }
.nav-section a.nav-link:nth-of-type(8n+4) svg,
.nav-section button.nav-link:nth-of-type(8n+4) svg { color: var(--ic-4); }
.nav-section a.nav-link:nth-of-type(8n+5) svg,
.nav-section button.nav-link:nth-of-type(8n+5) svg { color: var(--ic-5); }
.nav-section a.nav-link:nth-of-type(8n+6) svg,
.nav-section button.nav-link:nth-of-type(8n+6) svg { color: var(--ic-6); }
.nav-section a.nav-link:nth-of-type(8n+7) svg,
.nav-section button.nav-link:nth-of-type(8n+7) svg { color: var(--ic-7); }
.nav-section a.nav-link:nth-of-type(8n+0) svg,
.nav-section button.nav-link:nth-of-type(8n+0) svg { color: var(--ic-8); }

/* Active = solid indigo pill with glow */
.nav-link.active {
  background: var(--grad-teal);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px -4px var(--teal-border), 0 2px 6px rgba(79,70,229,0.25);
}
.nav-link.active svg { color: #fff !important; opacity: 1; }
[data-theme="dark"] .nav-link.active { color: #fff; box-shadow: 0 6px 18px -4px rgba(99,102,241,0.5); }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.575rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  min-width: 17px;
  text-align: center;
}
.nav-link.active .nav-badge { background: rgba(255,255,255,0.25); }

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal);
  text-decoration: none;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

[data-theme="dark"] .logo { color: var(--teal-light); }

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--teal), var(--teal-mid));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.topbar-search {
  flex: 1;
  max-width: 380px;
  margin: 0 0.5rem;
  position: relative;
}

.topbar-search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.875rem 0.45rem 2.25rem;
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.topbar-search input:focus {
  border-color: var(--teal-mid);
  box-shadow: 0 0 0 3px var(--teal-dim);
}

.topbar-search input::placeholder { color: var(--text-faint); }

.topbar-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}

/* Colourful topbar icons — same palette as the sidebar. Theme toggle and the
   "Your website" globe (which conveys live/offline via colour already) are
   deliberately excluded so their meaning stays intact. */
.topbar-btn[title="Calendar"] svg { color: var(--ic-1); }
.topbar-btn[title="Notifications"] svg { color: var(--ic-5); }

.topbar-btn:hover {
  background: var(--teal-dim);
  border-color: var(--teal-border);
  color: var(--teal);
  transform: translateY(-1px);
}

[data-theme="dark"] .topbar-btn:hover { color: var(--teal-light); }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--grad-teal);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--teal-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.125rem;
  gap: 0.5rem;
}

.card-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── KPI CARDS ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
}

.kpi-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--teal-border);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.kpi-label {
  font-size: 0.675rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.625rem;
}

.kpi-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 0.45rem;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.875rem;
  background: var(--teal-dim);
  color: var(--teal-mid);
}
[data-theme="dark"] .kpi-icon { color: var(--teal-light); }

/* Fatigue-free stat cards: calm white surfaces with a single colored icon
   chip (the .grad-N classes now tint only the icon, not the whole card —
   saturated full-gradient cards were fatiguing for long sessions). */
.kpi-card.grad-1, .kpi-card.grad-2, .kpi-card.grad-3,
.kpi-card.grad-4, .kpi-card.grad-5, .kpi-card.grad-6 {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.kpi-card[class*="grad-"] .kpi-label,
.kpi-card[class*="grad-"] .kpi-sub   { color: var(--text-faint); opacity: 1; }
.kpi-card[class*="grad-"] .kpi-value { color: var(--text); opacity: 1; }
.kpi-card.grad-1 .kpi-icon { background: rgba(20,184,166,0.12); color: #0E9488; }
.kpi-card.grad-2 .kpi-icon { background: rgba(219,39,119,0.12); color: #DB2777; }
.kpi-card.grad-3 .kpi-icon { background: rgba(217,119,6,0.14);  color: #D97706; }
.kpi-card.grad-4 .kpi-icon { background: rgba(5,150,105,0.12);  color: #059669; }
.kpi-card.grad-5 .kpi-icon { background: rgba(2,132,199,0.12);  color: #0284C7; }
.kpi-card.grad-6 .kpi-icon { background: rgba(20,184,166,0.12); color: #0E9488; }
[data-theme="dark"] .kpi-card.grad-1 .kpi-icon,
[data-theme="dark"] .kpi-card.grad-6 .kpi-icon { color: var(--teal-light); }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--teal-mid); outline-offset: 2px; }

.btn-primary {
  background: var(--grad-teal);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px -6px rgba(14,148,136,0.5), 0 2px 5px rgba(14,148,136,0.22);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 10px 22px -6px rgba(14,148,136,0.55); transform: translateY(-1px); }

.btn-gold {
  background: var(--grad-gold);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px -6px rgba(245,158,11,0.5);
}
.btn-gold:hover { filter: brightness(1.06); transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(192,57,43,0.2);
}
.btn-danger:hover { background: rgba(192,57,43,0.16); }

.btn-sm { padding: 0.325rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.675rem 1.375rem; font-size: 0.875rem; }
.btn-icon { padding: 0.45rem; }

/* ── The ONE canonical delete icon/button — every panel (admin, client
   portal, storefront) uses this via View::deleteIcon() instead of each view
   rolling its own mix of emoji/text/inconsistent SVG. Sized up from the
   12-14px range found in the old ad-hoc versions so it reads clearly as a
   delete action, not a faint decoration. */
.icon-btn-delete {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--danger);
  cursor: pointer; transition: all var(--transition);
}
.icon-btn-delete svg { width: 16px; height: 16px; }
.icon-btn-delete:hover { background: var(--danger-bg); border-color: rgba(192,57,43,0.3); transform: translateY(-1px); }
.icon-btn-delete:active { transform: translateY(0); }

/* ─── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.175rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-open       { background: var(--info-bg);    color: var(--info); }
.badge-progress   { background: var(--warning-bg); color: var(--warning); }
.badge-closed     { background: var(--success-bg); color: var(--success); }
.badge-hold       { background: var(--surface-3);  color: var(--text-muted); }
.badge-high       { background: var(--danger-bg);  color: var(--danger); }
.badge-medium     { background: var(--warning-bg); color: var(--warning); }
.badge-low        { background: var(--success-bg); color: var(--success); }
.badge-teal       { background: var(--teal-dim);   color: var(--teal-mid); }
.badge-gold       { background: var(--gold-dim);   color: var(--gold); }
.badge-na         { background: var(--danger-bg);  color: var(--danger); }

[data-theme="dark"] .badge-teal { color: var(--teal-light); }

/* ─── TABLES ─────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: transparent;
}

.data-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tr:hover td { background: var(--surface-2); }
.data-table td a { color: var(--text); text-decoration: none; font-weight: 500; }
.data-table td a:hover { color: var(--teal-mid); }
[data-theme="dark"] .data-table td a:hover { color: var(--teal-light); }

/* ─── FORMS ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text);
}

.form-hint {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: -0.2rem;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.525rem 0.875rem;
  color: var(--text);
  font-size: 0.825rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--teal-mid);
  box-shadow: 0 0 0 3px var(--teal-dim);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-faint); }
.form-select option { background: var(--surface); color: var(--text); }
.form-textarea { resize: vertical; min-height: 88px; }

.form-error {
  font-size: 0.7rem;
  color: var(--danger);
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.form-grid { display: grid; gap: 0.875rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─── MODALS ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11,30,38,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(6px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.375rem 1.625rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-body { padding: 1.375rem 1.625rem; display: flex; flex-direction: column; gap: 0.875rem; }
.modal-footer {
  padding: 1rem 1.625rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ─── TABS ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.375rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.65rem 1.125rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--teal);
  border-bottom-color: var(--teal-mid);
  font-weight: 600;
}
[data-theme="dark"] .tab-btn.active { color: var(--teal-light); border-bottom-color: var(--teal-light); }

/* ─── KANBAN ─────────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  align-items: start;
}

.kanban-column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
}

.kanban-col-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  display: block;
  box-shadow: var(--shadow-sm);
}

.kanban-card:hover {
  border-color: var(--teal-border);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.kanban-card:last-child { margin-bottom: 0; }
.kanban-card.dragging { opacity: 0.5; border-style: dashed; }

/* ─── PAGE HEADER ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* Segmented view toggle (List / Kanban / Calendar) in page headers */
.view-toggle { display: flex; flex-shrink: 0; }

/* ─── FILTERS BAR ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.125rem;
}

.filters-bar .form-input,
.filters-bar .form-select { width: auto; }

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-faint);
}

.empty-state svg { opacity: 0.25; margin-bottom: 1.25rem; }
.empty-state h3 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.8125rem; max-width: 300px; line-height: 1.6; }

/* ─── TIMELINE ───────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; }

.timeline-item {
  display: flex;
  gap: 0.875rem;
  padding-bottom: 1.125rem;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-content { flex: 1; padding-top: 0.4rem; }
.timeline-title { font-size: 0.8125rem; font-weight: 500; color: var(--text); }
.timeline-meta { font-size: 0.7rem; color: var(--text-faint); margin-top: 0.2rem; }

/* Caps a long activity feed to a fixed height instead of letting it push the
   rest of the page down — the card scrolls internally past ~7-8 entries. */
.timeline-scroll { max-height: 420px; overflow-y: auto; padding-right: 0.5rem; }

/* ─── DROPDOWN ───────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 172px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  padding: 0.375rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.525rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-divider { height: 1px; background: var(--border); margin: 0.3rem 0; }

/* ─── TASK ITEMS ─────────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.task-item:last-child { border-bottom: none; }

.task-check {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  transition: all var(--transition);
  position: relative;
}

.task-check:checked {
  background: var(--success);
  border-color: var(--success);
}

.task-check:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 6px; height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.task-check.na-check {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.task-check.na-check::after {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 900;
  color: var(--danger);
  border: none;
  transform: none;
}

.task-label { font-size: 0.8375rem; color: var(--text); line-height: 1.4; }
.task-item.done .task-label { color: var(--text-faint); text-decoration: line-through; }
.task-item.na .task-label { color: var(--text-faint); text-decoration: line-through; }

.task-na-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(192,57,43,0.2);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  letter-spacing: 0.04em;
}

.task-meta { font-size: 0.7rem; color: var(--text-faint); display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.task-overdue { color: var(--danger) !important; font-weight: 600; }
.task-completion-note { font-size: 0.675rem; color: var(--success); font-style: italic; }

/* ─── CALENDAR ───────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cal-day-header {
  background: var(--surface-2);
  padding: 0.5rem;
  text-align: center;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.cal-day {
  background: var(--surface);
  min-height: 96px;
  padding: 0.45rem;
  position: relative;
  transition: background var(--transition);
}

.cal-day:hover { background: var(--surface-2); }
.cal-day.empty { background: var(--bg); }
.cal-day.today { background: var(--teal-dim); }
.cal-day-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  display: block;
}

.cal-day.today .cal-day-num {
  color: var(--teal-mid);
  font-weight: 700;
}
[data-theme="dark"] .cal-day.today .cal-day-num { color: var(--teal-light); }

.cal-event {
  font-size: 0.625rem;
  padding: 0.15rem 0.375rem;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  cursor: pointer;
}

.cal-event.legal        { background: var(--info-bg);    color: var(--info); }
.cal-event.immigration  { background: var(--gold-dim);   color: var(--gold); }
.cal-event.conveyancing { background: var(--success-bg); color: var(--success); }
.cal-event.task         { background: var(--warning-bg); color: var(--warning); }

/* ─── NOTIFICATION BADGE ─────────────────────────────────────── */
.notif-count {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 15px;
  height: 15px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 0.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  line-height: 1;
  border: 1.5px solid var(--surface);
}

/* ─── TOASTS ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1.125rem;
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  animation: toastIn 0.2s ease;
  max-width: 340px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--teal-mid); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── AUTH LAYOUT ────────────────────────────────────────────── */
.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 22% 35%, rgba(99,102,241,0.16) 0%, transparent 55%),
    radial-gradient(ellipse at 82% 75%, rgba(219,39,119,0.10) 0%, transparent 55%),
    var(--bg);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.auth-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--teal), var(--teal-mid));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  box-shadow: var(--shadow);
}

.auth-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--text-faint);
  font-size: 0.75rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── RISK/STATUS INDICATOR BAR ──────────────────────────────── */
.status-bar {
  width: 3px;
  align-self: stretch;
  border-radius: 9999px;
  flex-shrink: 0;
}
.status-legal        { background: var(--teal-mid); }
.status-immigration  { background: var(--gold); }
.status-conveyancing { background: var(--success); }

/* ─── MATTER TYPE PILLS ──────────────────────────────────────── */
.matter-type-legal        { color: var(--teal-mid); background: var(--teal-dim); }
.matter-type-immigration  { color: var(--gold); background: var(--gold-dim); }
.matter-type-conveyancing { color: var(--success); background: var(--success-bg); }
[data-theme="dark"] .matter-type-legal { color: var(--teal-light); }

/* ─── SKELETON ───────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── PWA PROMPT ─────────────────────────────────────────────── */
.pwa-prompt {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-lg);
  padding: 0.875rem 1.375rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  box-shadow: var(--shadow-lg);
  z-index: 9000;
  max-width: 380px;
  width: calc(100% - 2rem);
  animation: toastIn 0.3s ease;
}

/* ─── FOCUS RING ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--teal-mid);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── THEME TOGGLE ───────────────────────────────────────────── */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--teal-dim);
  border-color: var(--teal-border);
  color: var(--teal);
}
[data-theme="dark"] .theme-toggle:hover { color: var(--teal-light); }

/* Theme-toggle icons: default to hidden, then surface the one that matches
   the current theme via a CSS attribute selector. This eliminates the brief
   pre-app.js FOUC where the HTML default (sun visible) flashes for users in
   dark mode on reload. JS still updates the meta-theme-color; icon
   visibility is owned by CSS so initial paint is correct. */
.theme-toggle svg { display: none; }
[data-theme="light"] .theme-toggle #theme-icon-light { display: block; }
[data-theme="dark"]  .theme-toggle #theme-icon-dark  { display: block; }

/* ─── COLLAPSIBLE / PINNABLE SIDEBAR ─────────────────────────────
   Desktop-only (wrapped in min-width so it can never fight the mobile
   slide-in sidebar below, which uses the same .app-sidebar element with
   its own transform-based open/close). Collapsed = icon-only rail;
   hovering a collapsed rail temporarily flies it out full-width as an
   overlay (via JS toggling .flyout, not :hover, so the pin button inside
   it can be clicked without the flyout closing first); the pin button
   locks it open permanently (removes collapsed state entirely). */
@media (min-width: 901px) {
  :root { --sidebar-w-collapsed: 68px; }
  .app-sidebar { transition: width 0.16s ease, box-shadow 0.16s ease; }
  .sidebar-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 0.25rem; padding: 0 0.875rem 0.75rem; }
  .sidebar-toggle-btn, .sidebar-pin-btn {
    width: 26px; height: 26px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-muted); display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
  }
  .sidebar-toggle-btn:hover, .sidebar-pin-btn:hover { background: var(--teal-dim); color: var(--teal-mid); border-color: var(--teal-border); }
  .sidebar-toggle-btn svg, .sidebar-pin-btn svg { width: 14px; height: 14px; }
  .sidebar-pin-btn { display: none; }

  .app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .app-shell.sidebar-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }
  .app-shell.sidebar-collapsed .app-sidebar .sidebar-toolbar { justify-content: center; padding: 0 0 0.75rem; }
  .app-shell.sidebar-collapsed .app-sidebar .sidebar-toggle-btn svg { transform: rotate(180deg); }

  /* Flying out over the content column (grid track stays narrow; the
     sidebar's own width simply exceeds it, which browsers render as an
     overlay rather than clipping, since nothing forces overflow:hidden
     on the shell). */
  .app-shell.sidebar-collapsed .app-sidebar.flyout {
    width: var(--sidebar-w);
    box-shadow: 12px 0 32px rgba(0,0,0,0.24);
    z-index: 150;
  }
  .app-shell.sidebar-collapsed .app-sidebar.flyout .sidebar-toolbar { justify-content: flex-end; padding: 0 0.875rem 0.75rem; }
  .app-shell.sidebar-collapsed .app-sidebar.flyout .sidebar-pin-btn { display: flex; }

  /* Icon-only rail: shrink link/label text to nothing rather than hiding
     it outright, so every nav-link's markup (dozens of them) needs no
     per-link changes — the icon <svg> is explicitly px-sized so it is
     unaffected by the font-size collapse. */
  .app-shell.sidebar-collapsed .app-sidebar:not(.flyout) .nav-link {
    font-size: 0 !important; justify-content: center; padding: 0.65rem 0; gap: 0;
  }
  .app-shell.sidebar-collapsed .app-sidebar:not(.flyout) .nav-section-label {
    font-size: 0 !important; height: 0; margin: 0; padding: 0; overflow: hidden;
  }
  .app-shell.sidebar-collapsed .app-sidebar:not(.flyout) .nav-section { padding: 0 0.5rem; }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar-toolbar { display: none; }
  :root { --sidebar-w: 0px; }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }

  .app-sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    width: 260px;
    height: calc(100dvh - var(--topbar-h));
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    box-shadow: var(--shadow-lg);
  }

  .app-sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(11,30,38,0.4);
    z-index: 79;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.active { display: block; }

  .app-content {
    grid-column: 1;
    padding: 1.125rem;
  }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; gap: 0.75rem; align-items: stretch; }
  /* View toggle: keep it a proper segmented control on mobile — full-width
     group with buttons sharing the row, NOT each forced to 100% (which made
     the List/Kanban buttons overlap). Overrides .page-header .btn{width:100%}. */
  .page-header .view-toggle { width: 100%; }
  .page-header .view-toggle .btn { width: auto; flex: 1 1 0; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .kanban-board { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); overflow-x: auto; }
  .data-table { display: block; overflow-x: auto; }
  .reports-chart-row { grid-template-columns: 1fr !important; }
  .cal-grid { grid-template-columns: repeat(7, minmax(90px, 1fr)); overflow-x: auto; }
  .cal-layout { grid-template-columns: 1fr !important; }

  /* Topbar: tighten so the hamburger + brand + actions fit a tablet */
  .app-topbar { padding: 0 0.85rem; gap: 0.4rem; }
  .topbar-search { max-width: 230px; margin: 0 0.35rem; }
  .topbar-actions { gap: 0.3rem; }
  body { overflow-x: hidden; }
}

/* Phones — declutter the topbar to just the essentials so nothing overflows */
@media (max-width: 640px) {
  .app-topbar { padding: 0 0.6rem; gap: 0.3rem; }
  .logo span { display: none; }                     /* keep the compact LBM mark only */
  .topbar-search { display: none; }                 /* search lives in the menu on phones */
  .topbar-btn[title="Calendar"] { display: none; }  /* redundant with the sidebar nav */
  .topbar-actions { gap: 0.2rem; margin-left: auto; }
  .topbar-btn, .theme-toggle, .avatar { width: 34px; height: 34px; }
  .topbar-btn svg, .theme-toggle svg { width: 15px; height: 15px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .app-content { padding: 0.875rem; }
}

/* ─── PRINT ──────────────────────────────────────────────────── */
@media print {
  .app-sidebar, .app-topbar, .btn, .modal-backdrop, .toast-container { display: none !important; }
  .app-content { padding: 0; }
  .app-shell { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ─── UTILITIES ──────────────────────────────────────────────── */
.text-teal    { color: var(--teal-mid); }
.text-gold    { color: var(--gold); }
.text-muted   { color: var(--text-muted); }
.text-faint   { color: var(--text-faint); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

[data-theme="dark"] .text-teal { color: var(--teal-light); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono     { font-family: 'IBM Plex Mono', monospace; }
.heading  { font-family: 'Plus Jakarta Sans', sans-serif; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ─── GPU HINTS ──────────────────────────────────────────────── */
.nav-link, .btn, .kpi-card, .kanban-card, .modal, .toast { will-change: auto; }
.app-sidebar { will-change: transform; }

/* ─── SECTION DIVIDER ────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ─── INFO PANEL (coloured inset) ────────────────────────────── */
.info-panel {
  border-left: 3px solid var(--teal-mid);
  background: var(--teal-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--text);
}

/* ─── SIGNATURE PAD CONTAINER ────────────────────────────────── */
.sig-pad-wrap {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: crosshair;
  touch-action: none;
}

/* ─── DRAG HANDLE ────────────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  color: var(--text-faint);
  padding: 0 0.25rem;
  display: flex;
  align-items: center;
}
.drag-handle:active { cursor: grabbing; }

/* ─── MOTION / SCROLL REVEAL (driven by public/assets/js/motion.js) ──────
   Progressive enhancement: content is visible by default and only hidden
   once html.js is set (confirms the script actually ran), so nothing
   disappears if JS is blocked. Purely additive — existing markup without
   these attributes is completely unaffected. */
[data-reveal], [data-reveal-stagger] {
  transition: opacity 0.8s cubic-bezier(0.16,1,0.3,1), transform 0.8s cubic-bezier(0.16,1,0.3,1);
}
html.js [data-reveal], html.js [data-reveal-stagger] {
  opacity: 0;
  transform: translateY(36px) scale(0.98);
}
html.js [data-reveal].in, html.js [data-reveal-stagger].in {
  opacity: 1;
  transform: none;
}
[data-reveal-scale] {
  transition: opacity 0.8s cubic-bezier(0.16,1,0.3,1), transform 0.8s cubic-bezier(0.16,1,0.3,1);
}
html.js [data-reveal-scale] { opacity: 0; transform: scale(0.92) translateY(18px); }
html.js [data-reveal-scale].in { opacity: 1; transform: none; }

/* Sticky scroll-progress bar — an element with this class fills width 0-100%
   as the page (or, inside the app shell, .app-content) is scrolled. */
.scroll-progress {
  position: sticky;
  top: 0;
  left: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, var(--teal-mid), var(--teal), var(--gold));
  box-shadow: 0 0 12px rgba(20,184,166,0.5);
  z-index: 60;
  pointer-events: none;
  transition: width 0.08s linear;
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal], [data-reveal-stagger], [data-reveal-scale] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  [data-parallax-speed] { transform: none !important; }
  html { scroll-behavior: auto !important; }
}

/* ─── AI ASSISTANT WIDGET (views/layouts/app.php, every authenticated page) ── */
.ai-assistant-fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 90;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-mid), var(--teal));
  color: #fff;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition), box-shadow var(--transition);
}
.ai-assistant-fab:hover { transform: translateY(-2px) scale(1.04); }
.ai-assistant-fab svg { width: 24px; height: 24px; }

.ai-assistant-backdrop.modal-backdrop {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}
.ai-assistant-panel {
  width: 100%;
  max-width: 400px;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  animation: aiPanelIn 0.28s cubic-bezier(0.16,1,0.3,1);
}
@keyframes aiPanelIn { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.ai-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ai-msg {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.ai-msg.user { align-self: flex-end; background: var(--teal-dim); color: var(--text); border: 1px solid var(--teal-border); }
.ai-msg.assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.ai-msg.pending { color: var(--text-faint); font-style: italic; }
.ai-action-chip {
  margin-top: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--teal-dim);
  border: 1px solid var(--teal-border);
  color: var(--teal-mid);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: normal;
}

.ai-assistant-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: flex-end;
}
.ai-assistant-footer textarea.form-input { flex: 1; resize: none; min-height: 40px; max-height: 120px; }

@media (max-width: 640px) {
  .ai-assistant-panel { max-width: 100%; }
  .ai-assistant-fab { right: 1rem; bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-assistant-panel { animation: none; }
}

/* ── Rich text toolbar (Mail compose, signature editor) ──────────────────
   Modern, colourful, animated: each functional group gets its own accent
   colour (icon fill/hover ring/active glow); icons pop with a spring-style
   scale on hover and a snappy press animation on click, rather than a flat
   plain-text button. Uses inline SVG icons (rendered in views/shared/rich-
   toolbar.php via the shared $ic() helper), no external icon font/CDN. */
.rt-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem;
  padding: 0.45rem; border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
}
.rt-group {
  --rt-accent: var(--teal-mid);
  --rt-accent-dim: var(--teal-dim);
  display: inline-flex; align-items: center; gap: 0.15rem; padding: 0.2rem 0.35rem;
  border-radius: 9px; background: var(--surface); border: 1px solid var(--border);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rt-group:hover { border-color: color-mix(in srgb, var(--rt-accent) 45%, var(--border)); }
/* Per-group accent palette — a small rainbow across the toolbar rather than
   one flat colour everywhere, so groups read as visually distinct clusters. */
.rt-g-history  { --rt-accent: #64748b; --rt-accent-dim: rgba(100,116,139,0.14); }
.rt-g-font     { --rt-accent: #6366f1; --rt-accent-dim: rgba(99,102,241,0.14); }
.rt-g-style    { --rt-accent: #2563eb; --rt-accent-dim: rgba(37,99,235,0.14); }
.rt-g-color    { --rt-accent: #db2777; --rt-accent-dim: rgba(219,39,119,0.14); }
.rt-g-para     { --rt-accent: #0e9488; --rt-accent-dim: rgba(14,148,136,0.14); }
.rt-g-insert   { --rt-accent: #7c3aed; --rt-accent-dim: rgba(124,58,237,0.14); }
.rt-g-more     { --rt-accent: #d97706; --rt-accent-dim: rgba(217,119,6,0.14); }

.rt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  min-width: 27px; height: 27px; padding: 0 0.35rem; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text-muted); font-size: 0.78rem; font-weight: 700; cursor: pointer; position: relative;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.rt-btn svg { width: 15px; height: 15px; transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1); }
.rt-btn:hover { background: var(--rt-accent-dim); color: var(--rt-accent); transform: translateY(-1.5px) scale(1.08); box-shadow: 0 3px 8px -2px var(--rt-accent-dim); }
.rt-btn:hover svg { transform: scale(1.12) rotate(-4deg); }
.rt-btn:active { transform: translateY(0) scale(0.92); transition-duration: 0.06s; }
.rt-btn.active { background: var(--rt-accent-dim); border-color: var(--rt-accent); color: var(--rt-accent); box-shadow: 0 0 0 3px var(--rt-accent-dim); }
.rt-btn.active svg { animation: rtPop 0.28s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes rtPop { 0% { transform: scale(0.7); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .rt-btn, .rt-btn svg { transition: none; animation: none; } }
.rt-btn-wide { min-width: 30px; flex-direction: column; gap: 0; font-size: 0.62rem; line-height: 1; padding: 2px 0.35rem; }
.rt-btn-wide svg { width: 9px; height: 9px; margin-top: 1px; }
.rt-glyph { font-family: 'Plus Jakarta Sans', sans-serif; }
.rt-color { padding: 0 0.35rem; overflow: hidden; }
.rt-color input[type=color] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.rt-select {
  height: 27px; font-size: 0.72rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--input-bg); color: var(--text); padding: 0 0.3rem; cursor: pointer; transition: border-color 0.15s ease;
}
.rt-select:hover { border-color: var(--rt-accent); }
.rt-select:focus { outline: none; border-color: var(--rt-accent); box-shadow: 0 0 0 3px var(--rt-accent-dim); }
.rt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 0.15rem; }
.rt-editor {
  min-height: 200px; max-height: 380px; overflow-y: auto; padding: 0.75rem;
  border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--input-bg); font-size: 0.88rem; line-height: 1.5; color: var(--text);
}
.rt-editor:focus { outline: none; border-color: var(--teal-mid); }
.rt-editor blockquote { border-left: 3px solid var(--border); margin: 0.4rem 0; padding: 0.2rem 0 0.2rem 0.75rem; color: var(--text-muted); }
.rt-editor.rt-small { min-height: 90px; max-height: 200px; }
.rt-editor.rt-dark { background: #1c2126; color: #e7ecf0; }
.rt-btn[data-cmd="dictate"].active { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); box-shadow: 0 0 0 3px var(--danger-bg); animation: rtPulse 1.1s ease-in-out infinite; }
@keyframes rtPulse { 0%, 100% { box-shadow: 0 0 0 3px var(--danger-bg); } 50% { box-shadow: 0 0 0 6px transparent; } }
.rt-btn[data-cmd="importance"].active { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.rt-editor img.rt-img-selected { outline: 2px solid var(--teal-mid); outline-offset: 1px; cursor: pointer; }
.rt-editor img { cursor: pointer; max-width: 100%; }
.rt-imgpop {
  position: fixed; z-index: 200; display: flex; gap: 0.3rem; align-items: center;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 0.35rem 0.5rem;
}
.rt-imgpop button { font-size: 0.72rem; padding: 0.2rem 0.45rem; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); cursor: pointer; }
.rt-imgpop button:hover { background: var(--teal-dim); }
.rt-imgpop button[data-remove] { color: var(--danger); }
.rt-imgpop-w { width: 68px; font-size: 0.72rem; padding: 0.2rem 0.35rem; border: 1px solid var(--border); border-radius: 5px; background: var(--input-bg); color: var(--text); }
.rt-poll-block { border: 1px solid #d8dde2; border-radius: 8px; padding: 0.9rem 1rem; margin: 0.5rem 0; background: #f7f9fa; }
.rt-poll-opt { display: inline-block; margin: 0.25rem 0.4rem 0.25rem 0; padding: 0.4rem 0.9rem; border-radius: 6px; background: #0e9488; color: #fff !important; text-decoration: none !important; font-size: 0.85rem; }

/* ── Resizable mail panes (draggable dividers, width persisted per browser) ── */
.mail-resize-handle { flex: 0 0 5px; cursor: col-resize; background: transparent; position: relative; }
.mail-resize-handle::after { content: ''; position: absolute; top: 0; bottom: 0; left: 2px; width: 1px; background: var(--border); }
.mail-resize-handle:hover::after, .mail-resize-handle.dragging::after { background: var(--teal-mid); width: 2px; left: 1.5px; }
.rt-mention {
  position: absolute; z-index: 40; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); min-width: 220px; max-height: 220px; overflow-y: auto; display: none;
}
.rt-mention-item { padding: 0.45rem 0.7rem; font-size: 0.8rem; cursor: pointer; }
.rt-mention-item.active, .rt-mention-item:hover { background: var(--teal-dim); }

/* ── First-time onboarding tour (public/assets/js/tour.js) ── */
.lbm-tour-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(11,30,38,0.55);
  backdrop-filter: blur(1px);
  pointer-events: none;
}
.lbm-tour-spot {
  position: fixed; z-index: 201;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 4000px rgba(11,30,38,0.55);
  border: 2px solid var(--gold);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
  pointer-events: none;
}
.lbm-tour-bubble {
  position: fixed; z-index: 202;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.1rem;
  transition: top 0.25s ease, left 0.25s ease;
}
.lbm-tour-step-count { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); margin-bottom: 0.35rem; }
.lbm-tour-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.35rem; }
.lbm-tour-body { font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }
.lbm-tour-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.85rem; }

@media (max-width: 640px) {
  .lbm-tour-bubble { left: 10px !important; right: 10px; width: auto !important; max-width: calc(100vw - 20px); }
}
.rt-mention-item .rtm-kw { color: var(--teal-mid); font-weight: 600; font-family: monospace; margin-right: 0.4rem; }

/* ═══ CHAT WIDGET (views/partials/chat-widget.php, public/assets/js/chat.js) ═══
   Built as a sibling of the AI assistant panel above: same right-side
   slide-out, same .modal-backdrop reuse, same token vocabulary. */

.chat-fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 91;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #fff;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition), box-shadow var(--transition);
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }
.chat-fab svg { width: 23px; height: 23px; }
/* Where the AI assistant FAB also exists, stack chat above it rather than
   letting the two overlap in the same corner. */
body.has-ai-assistant .chat-fab { bottom: calc(1.5rem + 52px + 0.75rem); }

.chat-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
}

/* Two classes on purpose: the global @media(max-width:480px) rule turns
   .modal-backdrop into a bottom sheet, and only a higher-specificity
   selector beats it. Same trick .ai-assistant-backdrop uses. */
.modal-backdrop.chat-backdrop {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}
.chat-panel {
  width: 100%;
  max-width: 400px;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  animation: chatPanelIn 0.28s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}
@keyframes chatPanelIn { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.chat-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}
.chat-head-title { font-weight: 600; font-size: 0.92rem; color: var(--text); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-sub { font-size: 0.68rem; color: var(--text-faint); font-weight: 400; }
.chat-icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 0.3rem; border-radius: var(--radius-sm); display: grid; place-items: center;
  transition: background var(--transition), color var(--transition);
}
.chat-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.chat-icon-btn svg { width: 17px; height: 17px; }

.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-view.hidden { display: none; }

/* ── conversation list ── */
.chat-search { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-search input { width: 100%; font-size: 0.82rem; }
.chat-list { flex: 1; overflow-y: auto; padding: 0.4rem; }
.chat-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.65rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}
.chat-row:hover { background: var(--surface-2); }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--teal-dim); color: var(--teal-mid);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.chat-avatar.is-client { background: var(--gold-dim); color: var(--gold); }
.chat-avatar.is-support { background: var(--info-bg, var(--surface-3)); color: var(--text-muted); }
.chat-row-main { flex: 1; min-width: 0; }
.chat-row-name {
  font-size: 0.84rem; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-row-meta { font-size: 0.68rem; color: var(--text-faint); margin-top: 1px; }
.chat-row.unread .chat-row-name { font-weight: 700; }
.chat-row-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 0.6rem; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.chat-empty { padding: 2rem 1.25rem; text-align: center; color: var(--text-faint); font-size: 0.8rem; }

/* ── message thread ── */
.chat-msgs {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.chat-bubble {
  max-width: 82%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.chat-bubble.them {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.chat-bubble.me {
  align-self: flex-end;
  background: var(--teal-dim);
  color: var(--text);
  border: 1px solid var(--teal-border);
  border-bottom-right-radius: 5px;
}
.chat-bubble.system {
  align-self: center; background: none; border: none;
  color: var(--text-faint); font-size: 0.74rem; font-style: italic; max-width: 100%;
}
.chat-bubble.pending { opacity: 0.55; }
.chat-bubble.failed { border-color: var(--danger); }
.chat-bubble-who { font-size: 0.66rem; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
.chat-bubble-at { font-size: 0.62rem; color: var(--text-faint); margin-top: 3px; }
.chat-report {
  background: none; border: none; cursor: pointer; padding: 0;
  font-size: 0.62rem; color: var(--text-faint); margin-top: 2px; text-decoration: underline;
}
.chat-report:hover { color: var(--danger); }
.chat-day {
  align-self: center; font-size: 0.64rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0.4rem 0 0.1rem;
}

.chat-notice {
  padding: 0.45rem 1rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.4rem;
  flex-shrink: 0;
}
.chat-notice svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--gold); }

.chat-composer {
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.5rem; align-items: flex-end;
  flex-shrink: 0;
}
.chat-composer textarea {
  flex: 1; resize: none; min-height: 38px; max-height: 110px;
  font-size: 0.84rem; line-height: 1.4;
}

/* ── new-chat directory ── */
.chat-dir { flex: 1; overflow-y: auto; padding: 0.4rem; }
.chat-dir-group {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint); padding: 0.6rem 0.65rem 0.25rem;
}

@media (max-width: 640px) {
  .chat-panel { max-width: 100%; }
  .chat-fab { right: 1rem; bottom: 1rem; }
  body.has-ai-assistant .chat-fab { bottom: calc(1rem + 52px + 0.75rem); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel { animation: none; }
}

/* ── Legal Radar ─────────────────────────────────────────────────────────────
   Feed rows shared by the dashboard card and the /legal-radar page. Category
   hues are drawn from the existing gradient palette so chips read as native. */
:root {
  --cat-judgment:   #4F46E5;
  --cat-practice:   #0284C7;
  --cat-legislation:#059669;
  --cat-courts:     #DB2777;
  --cat-profession: #F59E0B;
}

.radar-layout { display: grid; grid-template-columns: 190px 1fr; gap: 1.1rem; align-items: start; }
.radar-rail-h {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); margin: 0 0 .5rem;
}
.radar-nav { display: flex; flex-direction: column; gap: 1px; }
.radar-navrow {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .55rem;
  border-radius: 8px; font-size: .82rem; color: var(--text-muted);
  text-decoration: none; transition: background var(--transition), color var(--transition);
}
.radar-navrow:hover { background: var(--surface-2); color: var(--text); }
.radar-navrow.on { background: var(--teal-dim); color: var(--teal); font-weight: 650; }
.radar-navrow .radar-n { margin-left: auto; font-size: .74rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.radar-navrow.on .radar-n { color: var(--teal); }
.radar-sw { width: 7px; height: 7px; border-radius: 2px; flex: none; background: var(--text-faint); }
.radar-sw-judgment    { background: var(--cat-judgment); }
.radar-sw-practice    { background: var(--cat-practice); }
.radar-sw-legislation { background: var(--cat-legislation); }
.radar-sw-courts      { background: var(--cat-courts); }
.radar-sw-profession  { background: var(--cat-profession); }

.radar-health { font-size: .8rem; color: var(--text-muted); padding: .1rem .55rem; }
.radar-health-sub { font-size: .72rem; color: var(--text-faint); margin-top: .1rem; }

.radar-day {
  font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); padding: .3rem .15rem .5rem;
}

.radar-item {
  display: grid; grid-template-columns: 3px 1fr; gap: .8rem;
  padding: .8rem 1.05rem; border-bottom: 1px solid var(--border);
}
.radar-item:last-child { border-bottom: 0; }
.radar-stripe { border-radius: 2px; background: transparent; }
.radar-stripe.high { background: var(--gold); }
.radar-stripe.mid  { background: var(--teal-mid); }

.radar-meta {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin-bottom: .3rem; font-size: .72rem; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.radar-sep { color: var(--text-faint); }
.radar-chip {
  font-size: .63rem; font-weight: 700; letter-spacing: .045em; text-transform: uppercase;
  padding: .15rem .42rem; border-radius: 5px; white-space: nowrap;
  color: var(--text-muted); background: var(--surface-3);
}
.radar-chip-judgment    { color: var(--cat-judgment);    background: color-mix(in srgb, var(--cat-judgment) 13%, transparent); }
.radar-chip-practice    { color: var(--cat-practice);    background: color-mix(in srgb, var(--cat-practice) 13%, transparent); }
.radar-chip-legislation { color: var(--cat-legislation); background: color-mix(in srgb, var(--cat-legislation) 14%, transparent); }
.radar-chip-courts      { color: var(--cat-courts);      background: color-mix(in srgb, var(--cat-courts) 13%, transparent); }
.radar-chip-profession  { color: var(--cat-profession);  background: color-mix(in srgb, var(--cat-profession) 17%, transparent); }

.radar-title {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: .875rem; font-weight: 650; line-height: 1.4; color: var(--text);
  margin: 0 0 .28rem; text-wrap: balance;
}
.radar-cite { font-size: .76rem; color: var(--text-muted); margin-bottom: .35rem; font-variant-numeric: tabular-nums; }
.radar-excerpt { font-size: .78rem; color: var(--text-muted); line-height: 1.5; margin: 0 0 .4rem; }

.radar-why {
  display: flex; gap: .45rem; align-items: flex-start;
  font-size: .78rem; line-height: 1.5; color: var(--text-muted);
  background: var(--surface-2); border-left: 2px solid var(--teal-border);
  padding: .42rem .6rem; border-radius: 0 7px 7px 0; margin-bottom: .45rem;
}
.radar-ai {
  font-size: .6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--teal); flex: none; padding-top: .12rem;
}

.radar-acts { display: flex; gap: .42rem; flex-wrap: wrap; align-items: center; }
.radar-btn {
  font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 7px;
  border: 1px solid var(--border-strong); color: var(--text-muted);
  background: var(--surface); text-decoration: none; white-space: nowrap;
  transition: border-color var(--transition), color var(--transition);
}
.radar-btn:hover { color: var(--text); border-color: var(--text-faint); }
.radar-btn.free { color: var(--teal); border-color: var(--teal-border); background: var(--teal-dim); }
.radar-matched {
  font-size: .69rem; font-weight: 600; color: var(--gold);
  background: var(--gold-dim); border: 1px solid var(--gold-border);
  padding: .15rem .5rem; border-radius: 999px; white-space: nowrap;
}
.radar-src { font-size: .69rem; color: var(--text-faint); margin-left: auto; }

.radar-live {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 0 3px var(--success-bg);
  margin-right: .45rem; vertical-align: middle;
}
.radar-count {
  font-size: .68rem; font-weight: 600; color: var(--teal);
  background: var(--teal-dim); border: 1px solid var(--teal-border);
  padding: .05rem .45rem; border-radius: 999px; margin-left: .4rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .radar-layout { grid-template-columns: 1fr; }
  .radar-rail { display: none; }
  .radar-src { margin-left: 0; }
}

/* ── Court books ─────────────────────────────────────────────────────────── */
.cb-crumb { font-size: .78rem; margin-bottom: .2rem; }
.cb-crumb a { color: var(--text-muted); text-decoration: none; }
.cb-crumb a:hover { color: var(--teal); }

.cb-layout { display: grid; grid-template-columns: 1fr 330px; gap: 1rem; align-items: start; }
.cb-side .form-group { margin-bottom: .7rem; }

.cb-status {
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .9rem; margin-bottom: 1rem;
}
.cb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.cb-status-ready    .cb-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.cb-status-queued   .cb-dot,
.cb-status-building .cb-dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.cb-status-failed   .cb-dot { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-bg); }

.cb-pf { padding: .8rem 1rem; margin-bottom: .8rem; font-size: .85rem; }
.cb-pf strong { display: block; margin-bottom: .3rem; }
.cb-pf ul { margin: 0; padding-left: 1.1rem; color: var(--text-muted); }
.cb-pf li { margin: .15rem 0; }
.cb-pf-block { border-left: 3px solid var(--danger); }
.cb-pf-warn  { border-left: 3px solid var(--warning); }

.cb-tot { font-size: .78rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.cb-table td { vertical-align: top; }
.cb-tab { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.cb-title { font-weight: 600; font-size: .87rem; line-height: 1.35; }
.cb-sub { font-size: .74rem; color: var(--text-faint); margin-top: .12rem; }
.cb-pages { font-variant-numeric: tabular-nums; color: var(--teal); }
.cb-date { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cb-child td:first-child { padding-left: 1.6rem; }
.cb-child .cb-title { font-weight: 500; }

.cb-mini {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); border-radius: 6px; cursor: pointer;
  width: 24px; height: 24px; line-height: 1; font-size: .82rem;
}
.cb-mini:hover:not(:disabled) { color: var(--text); border-color: var(--text-faint); }
.cb-mini:disabled { opacity: .35; cursor: default; }
.cb-mini-danger:hover { color: var(--danger); border-color: var(--danger); }

.cb-actions {
  display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
  padding: .75rem 1.15rem; border-top: 1px solid var(--border);
}
.cb-note, .cb-hint { font-size: .74rem; color: var(--text-faint); }
.cb-hint { display: block; margin-top: .2rem; line-height: 1.4; }
.cb-empty { padding: 1rem 1.15rem; color: var(--text-muted); font-size: .85rem; margin: 0; }

.cb-picklist { max-height: 300px; overflow-y: auto; padding: .35rem 0; }
.cb-pick {
  display: flex; gap: .55rem; align-items: flex-start;
  padding: .4rem .9rem; cursor: pointer; font-size: .82rem;
}
.cb-pick:hover { background: var(--surface-2); }
.cb-pick input { margin-top: .2rem; flex: none; }
.cb-pick-name { display: block; color: var(--text); line-height: 1.3; word-break: break-word; }
.cb-pick-meta { display: block; font-size: .72rem; color: var(--text-faint); margin-top: .1rem; }
.cb-nonpdf { color: var(--danger); font-weight: 600; }

.cb-badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .12rem .45rem; border-radius: 5px;
  background: var(--surface-3); color: var(--text-muted);
}
.cb-badge-ready, .cb-badge-ok { background: var(--success-bg); color: var(--success); }
.cb-badge-queued, .cb-badge-building, .cb-badge-running { background: var(--warning-bg); color: var(--warning); }
.cb-badge-failed { background: var(--danger-bg); color: var(--danger); }

.cb-err { font-size: .74rem; color: var(--danger); margin-top: .2rem; }
.cb-danger { padding: .75rem .9rem; }

@media (max-width: 900px) {
  .cb-layout { grid-template-columns: 1fr; }
}

/* ── Dashboard (redesign) ────────────────────────────────────────────────── */
.dash-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.dash-greet { font-size: 1.5rem; margin: 0 0 .15rem; }
.dash-today { font-size: .87rem; color: var(--text-muted); margin: 0; }
.dash-today strong { color: var(--text); font-weight: 650; }
.dash-att-n { color: var(--warning) !important; }
.dash-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* metrics */
.dash-metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: .75rem; margin-bottom: 1.1rem;
}
.dash-metric {
  /* position + overflow are load-bearing: .dm-blob and .dm-go are absolutely
     positioned and expect THIS card as their containing block. Without them,
     both escape to the viewport's own coordinates instead of the card's --
     which is what put a stray grey circle over unrelated cards lower on the
     page (the blob, un-clipped, landing wherever the viewport happened to
     end for that scroll position). */
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem;
  box-shadow: var(--shadow-sm); text-decoration: none; display: block;
  transition: border-color var(--transition), transform var(--transition);
}
a.dash-metric:hover { border-color: var(--teal-border); transform: translateY(-1px); }
.dm-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: .35rem;
}
.dm-value {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 1.45rem; font-weight: 700; color: var(--text); line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.dm-unit { font-size: .85rem; font-weight: 600; color: var(--text-faint); margin-left: 1px; }
.dm-teal { color: var(--teal); }
.dm-danger { color: var(--danger); }
.dm-sub { font-size: .72rem; color: var(--text-faint); margin-top: .3rem; }
.dm-bar {
  height: 4px; border-radius: 2px; background: var(--surface-3);
  overflow: hidden; margin-top: .45rem;
}
.dm-bar span { display: block; height: 100%; background: var(--teal); border-radius: 2px; }
.dm-bar span.full { background: var(--success); }

/* ── KPI capsule visuals ────────────────────────────────────────────────────
   Restored after being accidentally deleted along with an old hero CSS block —
   the deletion's end-marker matched a later, unrelated occurrence of the same
   text and swept everything in between, including this section. Content is
   unchanged from before that mistake: six fixed tints (no state-dependent
   colour switching), solid icon chips with a white glyph, and the corner
   arrow/blob accents. */
.dm-blob {
  position: absolute; right: -34px; bottom: -46px;
  width: 132px; height: 132px; border-radius: 50%;
  background: currentColor; opacity: .09; pointer-events: none;
  transition: transform .35s cubic-bezier(.22,.61,.36,1);
}
a.dash-metric:hover .dm-blob { transform: scale(1.16) translate(-6px,-6px); }

.dm-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; margin-bottom: .75rem;
  background: currentColor;
  box-shadow: 0 2px 6px -2px rgba(16,42,67,.30);
}
.dm-icon svg { width: 19px; height: 19px; stroke: #fff; stroke-width: 2.2; }

.dm-go {
  position: absolute; top: .95rem; right: 1rem;
  font-size: .9rem; opacity: .5;
  transition: transform .2s ease, opacity .2s ease;
}
a.dash-metric:hover .dm-go { opacity: 1; transform: translate(2px,-2px); }

.dm-tint-blue   { color: #3B82F6; background: linear-gradient(160deg, rgba(59,130,246,.09), rgba(59,130,246,.02)); border-color: rgba(59,130,246,.20); }
.dm-tint-violet { color: #8B5CF6; background: linear-gradient(160deg, rgba(139,92,246,.09), rgba(139,92,246,.02)); border-color: rgba(139,92,246,.20); }
.dm-tint-teal   { color: #14B8A6; background: linear-gradient(160deg, rgba(20,184,166,.10), rgba(20,184,166,.02)); border-color: rgba(20,184,166,.22); }
.dm-tint-green  { color: #22C55E; background: linear-gradient(160deg, rgba(34,197,94,.09), rgba(34,197,94,.02)); border-color: rgba(34,197,94,.20); }
.dm-tint-amber  { color: #F59E0B; background: linear-gradient(160deg, rgba(245,158,11,.11), rgba(245,158,11,.02)); border-color: rgba(245,158,11,.24); }
.dm-tint-rose   { color: #E11D48; background: linear-gradient(160deg, rgba(225,29,72,.10), rgba(225,29,72,.02)); border-color: rgba(225,29,72,.22); }

.dash-metric .dm-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: none;
  color: var(--text-muted); margin-bottom: .3rem;
}
.dash-metric .dm-value { font-size: 1.85rem; letter-spacing: -.025em; }
.dash-metric .dm-sub { font-size: .73rem; margin-top: .4rem; color: var(--text-muted); }
.dash-metric .dm-bar { margin-top: .6rem; background: rgba(0,0,0,.07); }
.dash-metric .dm-bar span { width: 0; animation: dashFill .9s cubic-bezier(.22,.61,.36,1) .25s forwards; }
@keyframes dashFill { to { width: var(--w, 0%); } }

[data-theme="dark"] .dash-metric { background: var(--surface); }
[data-theme="dark"] .dm-icon { box-shadow: none; }
[data-theme="dark"] .dash-metric .dm-bar { background: rgba(255,255,255,.09); }
[data-theme="dark"] .dm-tint-blue   { background: linear-gradient(160deg, rgba(59,130,246,.14), rgba(59,130,246,.03)); }
[data-theme="dark"] .dm-tint-violet { background: linear-gradient(160deg, rgba(139,92,246,.14), rgba(139,92,246,.03)); }
[data-theme="dark"] .dm-tint-teal   { background: linear-gradient(160deg, rgba(20,184,166,.14), rgba(20,184,166,.03)); }
[data-theme="dark"] .dm-tint-green  { background: linear-gradient(160deg, rgba(34,197,94,.14), rgba(34,197,94,.03)); }
[data-theme="dark"] .dm-tint-amber  { background: linear-gradient(160deg, rgba(245,158,11,.15), rgba(245,158,11,.03)); }
[data-theme="dark"] .dm-tint-rose   { background: linear-gradient(160deg, rgba(225,29,72,.15), rgba(225,29,72,.03)); }

@media (prefers-reduced-motion: reduce) {
  .dash-metric, .dm-blob, .dm-go { transition: none; }
  .dash-metric .dm-bar span { animation: none; width: var(--w, 0%); }
}

/* layout: main + fixed rail so the rail can never run empty */
.dash-grid { display: grid; grid-template-columns: minmax(0,1fr) 336px; gap: 1rem; align-items: start; }
.dash-main, .dash-rail { display: flex; flex-direction: column; gap: 1rem; }
.dash-count {
  font-size: .7rem; font-weight: 700; color: var(--warning);
  background: var(--warning-bg); padding: .1rem .45rem; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.dash-empty { padding: 1.1rem 1.15rem; color: var(--text-muted); font-size: .85rem; margin: 0; }

/* action queue */
.dash-att {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .7rem 1.05rem; border-bottom: 1px solid var(--border);
  text-decoration: none; border-left: 3px solid transparent;
  transition: background var(--transition);
}
.dash-att:last-child { border-bottom: 0; }
.dash-att:hover { background: var(--surface-2); }
.dash-att-crit { border-left-color: var(--danger); }
.dash-att-warn { border-left-color: var(--warning); }
.dash-att-info { border-left-color: var(--teal-mid); }
.dash-att-ico { flex: none; padding-top: 1px; }
.dash-att-crit .dash-att-ico { color: var(--danger); }
.dash-att-warn .dash-att-ico { color: var(--warning); }
.dash-att-info .dash-att-ico { color: var(--teal); }
.dash-att-body { flex: 1; min-width: 0; }
.dash-att-label {
  display: block; font-size: .865rem; font-weight: 600; color: var(--text);
  line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-att-detail { display: block; font-size: .74rem; color: var(--text-faint); margin-top: .1rem; }
.dash-att-go { color: var(--text-faint); font-size: .9rem; flex: none; }
.dash-att:hover .dash-att-go { color: var(--teal); }

.dash-clear { display: flex; gap: .8rem; align-items: center; padding: 1.5rem 1.15rem; }
.dash-clear strong { display: block; font-size: .9rem; color: var(--text); }
.dash-clear p { margin: .15rem 0 0; font-size: .8rem; color: var(--text-muted); }

/* pipeline bars */
.dash-pipe { padding: .8rem 1.05rem 1rem; display: flex; flex-direction: column; gap: .55rem; }
.dash-pipe-row { display: grid; grid-template-columns: 82px 1fr 32px; gap: .6rem; align-items: center; text-decoration: none; }
.dash-pipe-label { font-size: .78rem; color: var(--text-muted); }
.dash-pipe-track { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.dash-pipe-fill { display: block; height: 100%; border-radius: 4px; transition: width var(--transition); }
.dash-pipe-open        { background: var(--teal); }
.dash-pipe-in_progress { background: var(--gold); }
.dash-pipe-on_hold     { background: var(--text-faint); }
.dash-pipe-closed      { background: var(--success); }
.dash-pipe-n { font-size: .78rem; font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.dash-pipe-row:hover .dash-pipe-label { color: var(--text); }

/* activity feed */
.dash-feed { padding: .6rem 1.05rem .9rem; display: flex; flex-direction: column; gap: .55rem; }
.dash-feed-row { display: flex; gap: .6rem; align-items: flex-start; }
.dash-feed-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--teal-border);
  flex: none; margin-top: .42rem;
}
.dash-feed-text { display: block; font-size: .82rem; color: var(--text); line-height: 1.35; }
.dash-feed-meta { display: block; font-size: .71rem; color: var(--text-faint); margin-top: .05rem; }

/* agenda */
.dash-ag {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .6rem 1.05rem; border-bottom: 1px solid var(--border); text-decoration: none;
}
.dash-ag:last-child { border-bottom: 0; }
.dash-ag:hover { background: var(--surface-2); }
.dash-ag-time {
  font-size: .72rem; font-weight: 700; color: var(--teal); flex: none;
  width: 46px; padding-top: .1rem; font-variant-numeric: tabular-nums;
}
.dash-ag-task .dash-ag-time { color: var(--text-faint); }
.dash-ag-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.dash-ag-detail { display: block; font-size: .72rem; color: var(--text-faint); margin-top: .08rem; }

/* radar in the rail */
.dash-radar { display: block; padding: .65rem 1.05rem; border-bottom: 1px solid var(--border); text-decoration: none; }
.dash-radar:last-child { border-bottom: 0; }
.dash-radar:hover { background: var(--surface-2); }
.dash-radar-meta { display: flex; gap: .4rem; align-items: center; font-size: .7rem; color: var(--text-faint); margin-bottom: .25rem; }
.dash-radar-title { display: block; font-size: .8rem; font-weight: 600; color: var(--text); line-height: 1.35; }
.dash-radar-why { display: block; font-size: .72rem; color: var(--text-muted); margin-top: .2rem; line-height: 1.4; }

/* quick actions */

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .dash-metrics { grid-template-columns: 1fr; }
  .dash-head { align-items: flex-start; }
}

/* ── Dashboard: charts & analytics ───────────────────────────────────────── */
.dash-metrics { grid-template-columns: repeat(6, 1fr); }
.dash-metric-alert { border-color: var(--gold-border); }
.dm-ok   { color: var(--success); }
.dm-warn { color: var(--gold); }

.dash-legend { display: flex; gap: .7rem; font-size: .72rem; color: var(--text-faint); }
.dash-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.lg { width: 9px; height: 3px; border-radius: 2px; display: inline-block; }
.lg-worked { background: var(--gold); }
.lg-bill   { background: var(--teal); }
.dash-chart { padding: .9rem 1.05rem 1rem; }

/* practice areas */
.dash-areas { padding: .85rem 1.05rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.dash-area { display: grid; grid-template-columns: 118px 1fr 30px; gap: .6rem; align-items: center; }
.dash-area-label { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-area-track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.dash-area-fill { display: block; height: 100%; border-radius: 4px; background: var(--grad-teal); }
.dash-area-n { font-size: .78rem; font-weight: 600; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

/* donut */
.dash-donut-wrap { padding: 1rem 1.05rem 1.1rem; display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.dash-donut { position: relative; width: 150px; height: 150px; }
.dash-donut-mid {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.dash-donut-mid strong {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dash-donut-mid span { font-size: .68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .07em; margin-top: .15rem; }
.dash-donut-key { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .7rem; width: 100%; }
.dash-key { display: flex; align-items: center; gap: .35rem; font-size: .74rem; color: var(--text-muted); }
.dash-key i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.dash-key b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }

/* ongoing matters table */
.dash-matters td { vertical-align: middle; }
.dash-m-row { display: flex; gap: .55rem; align-items: center; }
.dash-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--teal-dim); color: var(--teal);
  font-size: .74rem; font-weight: 700;
}
.dash-m-title { display: block; font-size: .84rem; font-weight: 600; color: var(--text); text-decoration: none; }
.dash-m-title:hover { color: var(--teal); }
.dash-m-sub { display: block; font-size: .72rem; color: var(--text-faint); margin-top: .05rem; }
.dash-td-muted { font-size: .78rem; color: var(--text-muted); }
.dash-type {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .12rem .45rem; border-radius: 5px;
  color: var(--h); background: color-mix(in srgb, var(--h) 13%, transparent);
}
.dash-hear {
  font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted); white-space: nowrap;
}
.dash-hear.soon { background: var(--warning-bg); color: var(--warning); }

@media (max-width: 1400px) { .dash-metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .dash-metrics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .dash-metrics { grid-template-columns: 1fr; } .dash-donut-key { grid-template-columns: 1fr; } }

/* ── Developer (API + webhooks) ──────────────────────────────────────────── */
.dev-reveal{padding:1rem 1.15rem;margin-bottom:1rem;border-left:3px solid var(--success)}
.dev-reveal strong{display:block;font-size:.95rem}
.dev-reveal p{margin:.25rem 0 .6rem;font-size:.83rem;color:var(--text-muted)}
.dev-token{display:block;background:var(--surface-3);border:1px solid var(--border-strong);border-radius:9px;
  padding:.6rem .75rem;font-size:.82rem;word-break:break-all;color:var(--teal);font-family:ui-monospace,Menlo,Consolas,monospace}
.dev-prefix{font-size:.72rem;color:var(--text-faint);font-family:ui-monospace,Menlo,Consolas,monospace}

.dev-scopes{display:grid;grid-template-columns:1fr 1fr;gap:1px;background:var(--border);
  border:1px solid var(--border);border-radius:10px;overflow:hidden;margin-top:.25rem}
.dev-scope{display:flex;gap:.5rem;align-items:flex-start;padding:.5rem .65rem;background:var(--surface);cursor:pointer}
.dev-scope:hover{background:var(--surface-2)}
.dev-scope input{margin-top:.2rem;flex:none}
.dev-scope code{display:block;font-size:.74rem;color:var(--teal);font-family:ui-monospace,Menlo,Consolas,monospace}
.dev-scope em{display:block;font-style:normal;font-size:.72rem;color:var(--text-faint);margin-top:.05rem}

.dev-ep{display:flex;gap:.75rem;align-items:flex-start;padding:.85rem 1.15rem;border-bottom:1px solid var(--border)}
.dev-ep:last-of-type{border-bottom:0}
.dev-ep-url{font-size:.83rem;font-weight:600;word-break:break-all}
.dev-ep-meta{font-size:.73rem;color:var(--text-faint);margin-top:.12rem}
.dev-secret{margin-top:.4rem}
.dev-secret summary{font-size:.74rem;color:var(--teal);cursor:pointer}
.dev-secret code{display:block;margin-top:.35rem;font-size:.72rem;word-break:break-all;color:var(--text-muted);
  background:var(--surface-2);padding:.4rem .55rem;border-radius:7px;font-family:ui-monospace,Menlo,Consolas,monospace}
.dev-secret p{font-size:.72rem;color:var(--text-faint);margin:.35rem 0 0;line-height:1.5}

.dev-docs{padding:.85rem 1.05rem 1rem}
.dev-docs p{font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text-faint);margin:.75rem 0 .3rem}
.dev-docs p:first-child{margin-top:0}
.dev-docs pre{background:var(--surface-2);border:1px solid var(--border);border-radius:9px;padding:.55rem .65rem;
  font-size:.73rem;overflow-x:auto;margin:0;color:var(--text);font-family:ui-monospace,Menlo,Consolas,monospace;line-height:1.5}
.dev-eps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.2rem}
.dev-eps code{font-size:.74rem;color:var(--teal);font-family:ui-monospace,Menlo,Consolas,monospace}
.dev-note{text-transform:none!important;letter-spacing:0!important;font-weight:400!important;
  font-size:.73rem!important;color:var(--text-muted)!important;line-height:1.5;margin-top:.7rem!important}

.dev-call{display:flex;gap:.6rem;align-items:flex-start;padding:.5rem 1.05rem;border-bottom:1px solid var(--border)}
.dev-call:last-child{border-bottom:0}
.dev-status{font-size:.7rem;font-weight:800;padding:.1rem .4rem;border-radius:5px;flex:none;font-variant-numeric:tabular-nums}
.dev-ok{background:var(--success-bg);color:var(--success)}
.dev-warn{background:var(--warning-bg);color:var(--warning)}
.dev-err{background:var(--danger-bg);color:var(--danger)}
.dev-call-path{display:block;font-size:.75rem;color:var(--text);font-family:ui-monospace,Menlo,Consolas,monospace;word-break:break-all}
.dev-call-meta{display:block;font-size:.68rem;color:var(--text-faint);margin-top:.05rem}
@media (max-width:700px){.dev-scopes{grid-template-columns:1fr}.dev-ep{flex-direction:column}}

/* ── Sidebar "More" group ────────────────────────────────────────────────────
   Everything the user is entitled to but that is not their role's daily work.
   A <details> element so it works with zero JavaScript — the sidebar must never
   depend on a script to reach a page. */
.nav-more details > summary { list-style: none; cursor: pointer; display: flex;
  align-items: center; gap: .4rem; user-select: none; }
.nav-more details > summary::-webkit-details-marker { display: none; }
.nav-more-toggle::after { content: '▸'; font-size: .7em; opacity: .6;
  transition: transform .15s; margin-left: auto; }
.nav-more details[open] > .nav-more-toggle::after { transform: rotate(90deg); }
.nav-more-count { font-size: .7rem; opacity: .55; font-weight: 400;
  font-variant-numeric: tabular-nums; }
.nav-more details > summary:hover { color: var(--text); }

/* ── Launcher (/home) ──────────────────────────────────────────────────────
   The "where can I go" page. Cards are anchors, not buttons: middle-click and
   open-in-new-tab have to keep working, which a JS-driven card would break. */

.launch-filter { position: relative; max-width: 520px; margin: 0 0 1.75rem; }
.launch-filter svg { position: absolute; left: .85rem; top: 50%; width: 16px;
  height: 16px; transform: translateY(-50%); color: var(--text-faint);
  pointer-events: none; }
.launch-filter .form-input { padding-left: 2.4rem; }

.launch-empty { color: var(--text-muted); font-size: .88rem;
  padding: 1.5rem 0 2rem; }

.launch-section { margin-bottom: 2.25rem; }
.launch-section[hidden] { display: none; }
.launch-section-head { margin-bottom: .85rem; }
.launch-section-head h2 { font-size: .82rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted);
  margin: 0 0 .2rem; }
.launch-section-head p { font-size: .84rem; color: var(--text-faint);
  margin: 0; }

/* auto-fill (not auto-fit) so a section holding two cards keeps them at their
   natural width instead of stretching each to half the page. */
.launch-grid { display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }

.launch-card { display: flex; gap: .8rem; align-items: flex-start;
  padding: .95rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-decoration: none; color: inherit;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.launch-card[hidden] { display: none; }
.launch-card:hover { border-color: var(--teal-border);
  transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15,23,42,.07); }
.launch-card:focus-visible { outline: 2px solid var(--teal);
  outline-offset: 2px; }

.launch-icon { flex: 0 0 auto; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--teal-dim); color: var(--teal); }
.launch-icon svg { width: 17px; height: 17px; }

/* Same rotating 8-hue palette as the sidebar (--ic-1..--ic-8, defined near
   .nav-link above), applied the same way: nth-of-type position within each
   section, resetting per section since each .launch-grid is its own sibling
   group. A destination that shares a colour family with its sidebar entry is
   easier to relate back to "where is this in the sidebar" than a single flat
   teal repeated 62 times. */
.launch-card:nth-of-type(8n+1) .launch-icon { background: rgba(58,142,246,.12); color: var(--ic-1); }
.launch-card:nth-of-type(8n+2) .launch-icon { background: rgba(46,184,122,.12); color: var(--ic-2); }
.launch-card:nth-of-type(8n+3) .launch-icon { background: rgba(201,146,42,.14); color: var(--ic-3); }
.launch-card:nth-of-type(8n+4) .launch-icon { background: rgba(168,85,247,.12); color: var(--ic-4); }
.launch-card:nth-of-type(8n+5) .launch-icon { background: rgba(236,72,153,.12); color: var(--ic-5); }
.launch-card:nth-of-type(8n+6) .launch-icon { background: rgba(6,182,212,.12);  color: var(--ic-6); }
.launch-card:nth-of-type(8n+7) .launch-icon { background: rgba(242,84,45,.12);  color: var(--ic-7); }
.launch-card:nth-of-type(8n+0) .launch-icon { background: rgba(99,102,241,.12); color: var(--ic-8); }

.launch-body { display: flex; flex-direction: column; gap: .18rem; min-width: 0; }
.launch-label { font-weight: 600; font-size: .9rem; color: var(--text); }
.launch-desc { font-size: .79rem; line-height: 1.45; color: var(--text-muted); }

.launch-pref { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.15rem; margin-top: .5rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .84rem; color: var(--text-muted); }

@media (max-width: 600px) {
  .launch-grid { grid-template-columns: 1fr; }
}

/* ── Guides: builder + viewer ──────────────────────────────────────────────
   Previously inline <style> blocks in three views, which meant the builder and
   the viewer drifted apart. One place now, tokens only, light + dark. */

.gb-back, .gv-back { font-size: .85rem; margin-bottom: .2rem; }
.gb-head-actions, .gv-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.gb-eyebrow { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; margin: 0 0 .7rem; }
.gb-eyebrow-note { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .8; }
.gb-empty { color: var(--text-muted); font-size: .88rem; margin: 0; }
.gb-sub { font-size: .8rem; color: var(--text-muted); display: block; }
.form-help { color: var(--text-muted); font-size: .78rem; }

.gb-details, .gb-capture { padding: 1.2rem; }
.gb-details { margin-bottom: 1.2rem; }
.gb-steps { padding: 1.1rem; }
.gb-wrap { display: grid; grid-template-columns: 1fr 360px; gap: 1.2rem; align-items: start; }
@media (max-width: 1000px) { .gb-wrap { grid-template-columns: 1fr; } }

/* Alerts — shared by the builder and the viewer stale-review banner. */
.gb-alert { border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0;
  font-size: .84rem; line-height: 1.55; }
.gb-alert ul { margin: .5rem 0 .3rem; padding-left: 1.1rem; }
.gb-alert code { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; }
.gb-alert-warn { background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.35); }
.gb-alert-danger { background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.30); }

/* Capture drop zone */
.gb-drop { border: 2px dashed var(--border); border-radius: 14px; padding: 2rem 1rem;
  text-align: center; color: var(--text-muted); cursor: pointer; transition: .15s; }
.gb-drop:hover, .gb-drop.hot, .gb-drop:focus-visible { border-color: var(--teal-border);
  background: var(--teal-dim); color: var(--text); outline: none; }
.gb-drop svg { width: 26px; height: 26px; margin-bottom: .5rem; opacity: .7; }
.gb-drop kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
  padding: .1rem .4rem; font-size: .8rem; font-family: ui-monospace, Menlo, monospace; }

/* Toolbar */
.gb-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0 .4rem; align-items: center; }
.gb-toolgroup { display: flex; gap: .25rem; padding: .2rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; }
.gb-tool { border: 1px solid transparent; background: transparent; border-radius: 6px;
  min-width: 30px; padding: .3rem .5rem; font-size: .88rem; line-height: 1.1;
  cursor: pointer; color: var(--text-muted); }
.gb-tool:hover { color: var(--text); background: var(--surface); }
.gb-tool.on { background: var(--teal-dim); border-color: var(--teal-border);
  color: var(--teal); font-weight: 700; }
/* Destructive tools read as destructive before they are clicked, not after. */
.gb-destructive .gb-tool.on { background: rgba(220,38,38,.12);
  border-color: rgba(220,38,38,.4); color: #E11D48; }
.gb-swatch { width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; padding: 0; }
.gb-swatch.on { border-color: var(--text); }
.gb-hintline { font-size: .8rem; color: var(--text-faint); margin: 0 0 .5rem; min-height: 1.1em; }

.gb-canvas-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto;
  background: var(--surface-2); max-height: 60vh; }
#gbCanvas { display: block; max-width: 100%; cursor: crosshair; }
.gb-stepform { margin-top: 1rem; }
.gb-textonly { margin-top: 1rem; }
.gb-textonly > summary { cursor: pointer; font-size: .85rem; font-weight: 600; }

/* Step list (drag to reorder) */
.gb-step { border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem;
  margin-bottom: .55rem; display: grid; grid-template-columns: 14px 28px 1fr; gap: .6rem;
  align-items: start; background: var(--surface); }
.gb-step.dragging { opacity: .45; border-style: dashed; }
.gb-grip { cursor: grab; color: var(--text-faint); font-size: .7rem; letter-spacing: -3px;
  line-height: 1.4; user-select: none; }
.gb-n { width: 26px; height: 26px; border-radius: 50%; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-size: .76rem; font-weight: 700; }
.gb-k-note    .gb-n { background: #4F46E5; }
.gb-k-tip     .gb-n { background: #059669; }
.gb-k-warning .gb-n { background: #B45309; }
.gb-stepbody { min-width: 0; }
.gb-stepbody > summary { cursor: pointer; font-size: .9rem; list-style: none; }
.gb-stepbody > summary::-webkit-details-marker { display: none; }
.gb-thumb { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; margin-top: .5rem; }
.gb-editform { margin-top: .7rem; }
.gb-remove { color: #E11D48; }

/* ── Viewer ─────────────────────────────────────────────────────────────── */
.gv-summary { font-size: 1rem; color: var(--text-muted); line-height: 1.6; max-width: 70ch; }
.gv-body { padding: 1.6rem; margin-top: 1rem; }

.gv-progress { display: flex; flex-direction: column; gap: .4rem; margin: 1rem 0 .25rem; }
.gv-progress-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.gv-progress-bar span { display: block; height: 100%; width: 0; background: var(--teal);
  transition: width .25s ease; }
.gv-progress-meta { display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; color: var(--text-muted); }

.gv-step { display: grid; grid-template-columns: 40px 1fr; gap: 1rem; margin-bottom: 1.6rem;
  align-items: start; }
.gv-step.is-done .gv-content { opacity: .55; }
.gv-step.is-done .gv-n { background: var(--text-faint); }
.gv-marker { cursor: pointer; display: block; position: relative; }
.gv-check { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.gv-n { width: 32px; height: 32px; border-radius: 50%; background: var(--teal); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  transition: background .15s ease; }
.gv-marker:hover .gv-n { background: var(--teal-mid); }
.gv-content { min-width: 0; }
.gv-t { font-size: 1.02rem; font-weight: 600; margin: .2rem 0 .35rem; }
.gv-b { font-size: .93rem; line-height: 1.65; color: var(--text-muted);
  white-space: pre-wrap; margin: 0; }
.gv-img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px;
  margin-top: .7rem; display: block; cursor: zoom-in; }

/* Notes / tips / warnings — not numbered, deliberately not step-shaped. */
.gv-callout { border-radius: 10px; padding: .9rem 1.1rem; margin-bottom: 1.6rem;
  border-left: 3px solid; }
.gv-callout-label { font-size: .7rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; display: block; margin-bottom: .3rem; }
.gv-c-note    { background: rgba(79,70,229,.08);  border-color: #4F46E5; }
.gv-c-note    .gv-callout-label { color: #4F46E5; }
.gv-c-tip     { background: rgba(5,150,105,.08);  border-color: #059669; }
.gv-c-tip     .gv-callout-label { color: #059669; }
.gv-c-warning { background: rgba(245,158,11,.10); border-color: #B45309; }
.gv-c-warning .gv-callout-label { color: #B45309; }

.gv-lightbox { position: fixed; inset: 0; z-index: 1200; background: rgba(2,6,23,.85);
  display: grid; place-items: center; padding: 2rem; cursor: zoom-out; }
.gv-lightbox[hidden] { display: none; }
.gv-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; cursor: default; }
.gv-lightbox-close { position: absolute; top: 1rem; right: 1.25rem; background: none;
  border: none; color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1; }

/* Guide index cards */
.gl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: .85rem; }
.gl-card { display: block; border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem; background: var(--surface); text-decoration: none; color: inherit;
  transition: .15s; }
.gl-card:hover { border-color: var(--teal-border); transform: translateY(-2px); }
.gl-t { font-weight: 600; font-size: .98rem; line-height: 1.35; margin: .35rem 0 .3rem; }
.gl-s { font-size: .84rem; color: var(--text-muted); line-height: 1.5; }
.gl-m { font-size: .75rem; color: var(--text-faint); display: flex; gap: .8rem;
  flex-wrap: wrap; margin-top: .6rem; }

@media print {
  .gv-noprint, .gv-progress, .gv-lightbox, .page-header .btn { display: none !important; }
  .gv-step { break-inside: avoid; }
  .gv-img { max-width: 100%; }
}

/* Callout labels in dark mode.
   The light-mode label colours are mid-tone (#4F46E5 / #059669 / #B45309) on a
   near-black surface, which measured 2.58 / 4.16 / 2.90 against the composited
   background — all below the 4.5 AA threshold for 11px bold text. The 300-level
   variants clear it comfortably. The left borders keep the darker hues: they are
   decoration, not text, so they carry no contrast requirement. */
[data-theme="dark"] .gv-c-note    .gv-callout-label { color: #A5B4FC; }
[data-theme="dark"] .gv-c-tip     .gv-callout-label { color: #6EE7B7; }
[data-theme="dark"] .gv-c-warning .gv-callout-label { color: #FCD34D; }
[data-theme="dark"] .gv-c-note    { border-color: #6366F1; }
[data-theme="dark"] .gv-c-tip     { border-color: #10B981; }
[data-theme="dark"] .gv-c-warning { border-color: #F59E0B; }

/* ── Data import ───────────────────────────────────────────────────────────
   Three steps: upload, review, commit. The review screen carries the weight,
   so its tallies and row states are the loudest things on it. */

/* .table-wrap was already used in two views with no rule behind it, so wide
   tables simply overflowed there. Defining it fixes those as well. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table td.num, .data-table th.num { text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap; }

.imp-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: 1.25rem; }
.imp-card { padding: 1.25rem; display: flex; flex-direction: column; gap: .2rem; }
.imp-card-title { font-size: 1.02rem; font-weight: 650; margin: 0; }
.imp-card-blurb { font-size: .85rem; color: var(--text-muted); line-height: 1.5;
  margin: .15rem 0 .9rem; }
.imp-card-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  margin-top: auto; }
.imp-order { margin: 0 0 1.25rem; }
.imp-history { padding: 1.15rem; margin-top: 1.25rem; }
.imp-file { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-undo form { margin: 0; }

/* Review screen */
.imp-tally { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.1rem; }
.imp-tally-item { display: flex; flex-direction: column; gap: .1rem; padding: .95rem 1.1rem;
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm);
  background: var(--surface); }
.imp-tally-n { font-size: 1.6rem; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.imp-tally-l { font-size: .8rem; color: var(--text-muted); }
.imp-ok   { border-left-color: var(--teal); }
.imp-ok   .imp-tally-n { color: var(--teal); }
.imp-skip { border-left-color: var(--text-faint); }
.imp-skip .imp-tally-n { color: var(--text-faint); }
.imp-bad  { border-left-color: #E11D48; }
.imp-bad  .imp-tally-n { color: #E11D48; }

.imp-map { padding: 1.15rem; margin-bottom: 1.1rem; }
.imp-map-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  margin-bottom: .9rem; }
.imp-map-row { display: grid; grid-template-columns: 1fr 16px 1fr; gap: .5rem; align-items: center; }
.imp-map-src { font-size: .84rem; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.imp-map-arrow { color: var(--text-faint); font-size: .8rem; text-align: center; }

.imp-preview { padding: 1.15rem; }
.imp-detail { font-size: .8rem; color: var(--text-muted); }
.imp-row-fail td { background: rgba(220,38,38,.06); }
.imp-row-skip td { color: var(--text-muted); }
.imp-more { font-size: .8rem; color: var(--text-faint); margin: .7rem 0 0; }

.imp-commit { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  margin-top: 1.1rem; }
.imp-commit form { margin: 0; }
.imp-commit-note { font-size: .8rem; color: var(--text-muted); }

@media (max-width: 600px) {
  .imp-map-row { grid-template-columns: 1fr; }
  .imp-map-arrow { display: none; }
}

/* ── Matter types & custom fields ─────────────────────────────────────────── */

.mt-card { padding: 1.2rem; margin-bottom: 1.25rem; }
.mt-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.mt-actions { white-space: nowrap; }
.mt-actions details > summary { list-style: none; cursor: pointer; display: inline-flex; }
.mt-actions details > summary::-webkit-details-marker { display: none; }
.mt-editform { margin: .8rem 0; }
.mt-add { margin-top: 1rem; }
.mt-add > summary { list-style: none; cursor: pointer; display: inline-flex; }
.mt-add > summary::-webkit-details-marker { display: none; }
.mt-add > form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.mt-flags { display: flex; gap: .3rem; flex-wrap: wrap; }
.mt-checks { display: flex; gap: 1rem; flex-wrap: wrap; margin: .6rem 0 .9rem; }
.mt-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem;
  color: var(--text-muted); cursor: pointer; }
.mt-check input { margin: 0; }

/* An edit panel inside a table cell must escape the cell's width, or every
   field is squeezed into one column. */
.data-table .mt-actions details[open] { position: relative; }
.data-table .mt-actions details[open] > .mt-editform,
.data-table .mt-actions details[open] > form { min-width: 420px; text-align: left; white-space: normal; }

/* Custom-field blocks on the matter form */
.mf-block { display: contents; }
.mf-block[hidden] { display: none; }
.mf-section { grid-column: 1 / -1; font-size: .78rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint); font-weight: 700;
  margin: .6rem 0 0; }
.mf-req { color: #E11D48; }

/* Read-only custom fields on the matter detail page */
.mf-list { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.mf-item { min-width: 0; }
.mf-label { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600; display: block; }
.mf-value { font-size: .9rem; color: var(--text); word-break: break-word; }
.mf-value.is-empty { color: var(--text-faint); }

@media (max-width: 700px) {
  .data-table .mt-actions details[open] > .mt-editform,
  .data-table .mt-actions details[open] > form { min-width: 0; }
}

/* ── Matter Command Centre ────────────────────────────────────────────────
   Health strip, tab bar, and the parties panel. */

.mc-health { display: grid; grid-template-columns: 1fr auto; gap: 1.25rem;
  align-items: start; padding: 1rem 1.15rem; margin-bottom: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint); border-radius: var(--radius-sm); }
.mc-health-main { display: flex; gap: .75rem; align-items: flex-start; min-width: 0; }
.mc-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-faint); margin-top: .35rem; }
.mc-health-label { display: block; font-size: .95rem; margin-bottom: .2rem; }

.mc-h-ok   { border-left-color: var(--teal); }
.mc-h-ok   .mc-dot { background: var(--teal); }
.mc-h-ok   .mc-health-label { color: var(--teal); }
.mc-h-warn { border-left-color: #B45309; }
.mc-h-warn .mc-dot { background: #F59E0B; }
.mc-h-warn .mc-health-label { color: #B45309; }
.mc-h-risk { border-left-color: #E11D48; }
.mc-h-risk .mc-dot { background: #E11D48; }
.mc-h-risk .mc-health-label { color: #E11D48; }
[data-theme="dark"] .mc-h-warn .mc-health-label { color: #FCD34D; }
[data-theme="dark"] .mc-h-risk .mc-health-label { color: #FDA4AF; }

.mc-reasons { list-style: none; margin: 0; padding: 0; display: flex;
  flex-direction: column; gap: .2rem; }
.mc-reasons li { font-size: .84rem; color: var(--text-muted); line-height: 1.5; }
.mc-reasons a { color: inherit; text-decoration: underline;
  text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.mc-reasons a:hover { color: var(--text); }
.mc-reasons-none { font-size: .84rem; color: var(--text-muted); }

.mc-next { min-width: 190px; padding-left: 1.25rem; border-left: 1px solid var(--border); }
.mc-next-title { display: block; font-size: .7rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-faint); font-weight: 700; margin-bottom: .35rem; }
.mc-next ol { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.mc-next li { font-size: .83rem; color: var(--text-muted); line-height: 1.45; }
.mc-next a { color: var(--teal); text-decoration: none; }
.mc-next a:hover { text-decoration: underline; }

/* Tab bar. Scrolls sideways rather than wrapping — a wrapped two-row tab bar
   pushes the content down and reads as navigation chrome. */
.mc-tabs { display: flex; gap: .15rem; margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border); overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.mc-tabs::-webkit-scrollbar { display: none; }
.mc-tab { position: relative; flex: 0 0 auto; background: none; border: none;
  padding: .6rem .85rem; font-size: .87rem; font-weight: 500; cursor: pointer;
  color: var(--text-muted); white-space: nowrap; border-bottom: 2px solid transparent;
  margin-bottom: -1px; }
.mc-tab:hover { color: var(--text); }
.mc-tab.is-active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 650; }
.mc-count { display: inline-block; margin-left: .35rem; padding: .05rem .35rem;
  font-size: .7rem; font-weight: 700; border-radius: 8px;
  background: var(--surface-3); color: var(--text-muted);
  font-variant-numeric: tabular-nums; }
.mc-tab.is-active .mc-count { background: var(--teal-dim); color: var(--teal); }

/* ── Parties ─────────────────────────────────────────────────────────────── */
.mp-group { padding: 0 1rem; }
.mp-group + .mp-group { margin-top: .5rem; }
.mp-role { font-size: .7rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; margin: .6rem 0 .3rem; }
.mp-row { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between;
  padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: .45rem; background: var(--surface); }
/* The other side is marked visually as well as with a badge — mailing the
   opposing solicitor a client update is the mistake this is here to prevent. */
.mp-row.is-opposing { border-left: 3px solid #B45309; }
.mp-main { min-width: 0; }
.mp-name { font-weight: 600; font-size: .9rem; display: flex; gap: .4rem;
  align-items: center; flex-wrap: wrap; }
.mp-org { font-size: .82rem; color: var(--text-muted); }
.mp-contact { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem;
  color: var(--text-muted); margin-top: .15rem; }
.mp-contact a { color: var(--teal); text-decoration: none; }
.mp-addr, .mp-notes { font-size: .8rem; color: var(--text-faint); margin-top: .2rem; }
.mp-edit > summary, .mp-add > summary { list-style: none; cursor: pointer; display: inline-flex; }
.mp-edit > summary::-webkit-details-marker, .mp-add > summary::-webkit-details-marker { display: none; }
.mp-edit { flex: 0 0 auto; }
.mp-edit[open] { flex: 1 1 100%; }
.mp-add { padding: .5rem 1rem 1rem; }
.mp-add > form { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.mp-form { margin-bottom: .3rem; }

@media (max-width: 900px) {
  .mc-health { grid-template-columns: 1fr; }
  .mc-next { padding-left: 0; border-left: none; padding-top: .75rem;
    border-top: 1px solid var(--border); }
  .mp-row { flex-direction: column; }
}

/* ── Task dependencies ────────────────────────────────────────────────────
   A blocked task reads as unavailable rather than merely unticked, so nobody
   wonders why the checkbox will not respond. */

.task-item.blocked { opacity: .82; }
.task-item.blocked .task-check { cursor: not-allowed; }
.task-blocked-badge { display: inline-flex; align-items: center; gap: .25rem;
  font-size: .68rem; font-weight: 600; padding: .1rem .45rem; border-radius: 6px;
  background: rgba(245,158,11,.12); color: #B45309; white-space: nowrap;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .task-blocked-badge { color: #FCD34D; }

.task-dep-form { padding: .5rem .75rem; }
.task-dep-form .form-label { font-size: .7rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint); }
.task-dep-form .form-select { font-size: .8rem; margin-bottom: .4rem; }

/* ── Document versions ───────────────────────────────────────────────────── */
.doc-ver { display: inline-block; margin-left: .35rem; padding: .05rem .35rem;
  font-size: .66rem; font-weight: 700; border-radius: 6px;
  background: var(--teal-dim); color: var(--teal); vertical-align: 1px; }
.doc-vnote { font-size: .7rem; color: var(--text-faint); margin-top: .1rem; }

.doc-hist { margin-top: .25rem; }
.doc-hist > summary { cursor: pointer; font-size: .7rem; color: var(--text-muted);
  list-style: none; }
.doc-hist > summary::-webkit-details-marker { display: none; }
.doc-hist > summary:hover { color: var(--text); }
.doc-hist ul { list-style: none; margin: .3rem 0 0; padding: 0 0 0 .5rem;
  border-left: 2px solid var(--border); }
.doc-hist li { font-size: .72rem; color: var(--text-faint); padding: .12rem 0;
  display: flex; gap: .45rem; flex-wrap: wrap; }
.doc-hist li a { color: var(--teal); text-decoration: none; font-weight: 600; }

.doc-newver { display: inline-block; text-align: left; }
.doc-newver > summary { list-style: none; cursor: pointer; display: inline-flex; }
.doc-newver > summary::-webkit-details-marker { display: none; }
.doc-newver[open] { display: block; margin-bottom: .6rem; }
.doc-newver form { margin-top: .5rem; padding: .6rem .75rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; min-width: 260px; }
.doc-keep { font-size: .7rem; color: var(--text-faint); margin: .4rem 0 0; }

/* ── Compliance ───────────────────────────────────────────────────────────── */
.cmp-bar { height: 5px; border-radius: 3px; background: var(--surface-3);
  margin: 0 1rem .75rem; overflow: hidden; }
.cmp-bar span { display: block; height: 100%; background: var(--teal); transition: width .25s ease; }
.cmp-row { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
.cmp-row:last-of-type { border-bottom: none; }
.cmp-row.is-done .cmp-label { color: var(--text-muted); }
.cmp-row.is-na   { opacity: .6; }
.cmp-row.is-overdue { background: rgba(220,38,38,.05); }
.cmp-main { min-width: 0; }
.cmp-label { font-size: .88rem; font-weight: 550; display: flex; gap: .4rem;
  align-items: center; flex-wrap: wrap; }
.cmp-req { color: #E11D48; font-weight: 700; }
.cmp-meta { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .76rem;
  color: var(--text-faint); margin-top: .15rem; }
.cmp-meta a { color: var(--teal); text-decoration: none; }
.cmp-reviewed { color: var(--teal); }
.cmp-awaiting { color: #B45309; }
[data-theme="dark"] .cmp-awaiting { color: #FCD34D; }
.cmp-act { flex: 0 0 auto; }
.cmp-act[open] { flex: 1 1 100%; }
.cmp-act > summary { list-style: none; cursor: pointer; display: inline-flex; }
.cmp-act > summary::-webkit-details-marker { display: none; }
.cmp-act form { margin-top: .5rem; padding: .6rem .75rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; max-width: 420px; }
.cmp-add { padding: .75rem 1rem 1rem; }
.cmp-add > summary { list-style: none; cursor: pointer; display: inline-flex; }
.cmp-add > summary::-webkit-details-marker { display: none; }
.cmp-add > form { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--border); }

/* ── Practice registers: courts, precedents, risk ─────────────────────────── */

.reg-notes { padding: .6rem .75rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: .7rem; font-size: .8rem; line-height: 1.55; text-align: left;
  white-space: normal; }
.reg-notes strong { display: block; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); margin-top: .5rem; }
.reg-notes strong:first-child { margin-top: 0; }
.reg-notes p { margin: .15rem 0 0; color: var(--text-muted); }

.reg-body { font-size: .87rem; line-height: 1.6; color: var(--text-muted); margin: 0; }
.reg-kv { display: flex; flex-direction: column; gap: .4rem; font-size: .84rem; }
.reg-kv > div { display: flex; gap: .6rem; justify-content: space-between; align-items: baseline; }
.reg-kv span:first-child { color: var(--text-faint); font-size: .78rem; flex: 0 0 auto; }

/* Precedent rows */
.prec-row { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between;
  padding: .8rem 0; border-bottom: 1px solid var(--border); }
.prec-row:last-of-type { border-bottom: none; }
/* Superseded authority is kept — knowing something no longer stands is useful —
   but it must never read as current. */
.prec-overruled { opacity: .6; }
.prec-overruled .prec-title { text-decoration: line-through; text-decoration-thickness: 1px; }
.prec-main { min-width: 0; }
.prec-title { font-size: .93rem; font-weight: 600; line-height: 1.4; }
.prec-cite { display: inline-block; margin-left: .4rem; font-family: ui-monospace, Menlo, monospace;
  font-size: .78rem; color: var(--teal); font-weight: 500; }
.prec-meta { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center;
  font-size: .76rem; color: var(--text-faint); margin-top: .25rem; }
.prec-auth { font-weight: 600; }
.prec-binding    .prec-auth { color: var(--teal); }
.prec-persuasive .prec-auth { color: #2563EB; }
.prec-distinguishable .prec-auth { color: #B45309; }
.prec-overruled  .prec-auth { color: #E11D48; }
.prec-rel { letter-spacing: 1px; color: var(--teal); font-size: .6rem; }
.prec-rel-off { color: var(--border-strong); }
.prec-held, .prec-note { font-size: .82rem; line-height: 1.55; color: var(--text-muted); margin: .3rem 0 0; }
.prec-link { display: inline-block; margin-top: .3rem; font-size: .78rem; color: var(--teal); text-decoration: none; }
.prec-act { flex: 0 0 auto; }
.prec-act[open] { flex: 1 1 100%; }
.prec-act > summary { list-style: none; cursor: pointer; display: inline-flex; }
.prec-act > summary::-webkit-details-marker { display: none; }
.prec-act form { margin-top: .6rem; }

/* Risk severity bands */
.risk-band { display: inline-block; padding: .1rem .45rem; border-radius: 6px;
  font-size: .74rem; font-weight: 700; white-space: nowrap; }
.risk-low     { background: rgba(14,148,136,.12);  color: var(--teal); }
.risk-medium  { background: rgba(245,158,11,.14);  color: #B45309; }
.risk-high    { background: rgba(234,88,12,.16);   color: #C2410C; }
.risk-extreme { background: rgba(220,38,38,.16);   color: #E11D48; }
[data-theme="dark"] .risk-medium  { color: #FCD34D; }
[data-theme="dark"] .risk-high    { color: #FDBA74; }
[data-theme="dark"] .risk-extreme { color: #FDA4AF; }

/* ── Client portal dashboard ──────────────────────────────────────────────
   Ordered by what the client must act on, not by what is countable. */

.pd-actions { padding: 0 0 .35rem; margin-bottom: 1.1rem; }
.pd-actions.is-clear { padding-bottom: 0; }

.pd-clear { display: flex; gap: .8rem; align-items: center; padding: .35rem 1.1rem 1.1rem; }
.pd-clear svg { width: 22px; height: 22px; flex: 0 0 auto; color: var(--teal); }
.pd-clear strong { display: block; font-size: .92rem; }
.pd-clear span { font-size: .84rem; color: var(--text-muted); }

.pd-action { display: flex; gap: .75rem; align-items: center; padding: .8rem 1.1rem;
  border-top: 1px solid var(--border); text-decoration: none; color: inherit;
  transition: background .15s ease; }
.pd-action:first-of-type { border-top: none; }
.pd-action:hover { background: var(--surface-2); }
.pd-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.pd-urgent .pd-dot { background: #E11D48; }
.pd-warn   .pd-dot { background: #F59E0B; }
.pd-info   .pd-dot { background: var(--teal); }
.pd-action-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1 1 auto; }
.pd-action-title { font-size: .9rem; font-weight: 600; }
.pd-action-detail { font-size: .8rem; color: var(--text-muted); }
.pd-due { flex: 0 0 auto; font-size: .74rem; font-weight: 600; color: var(--text-muted);
  padding: .12rem .45rem; border-radius: 6px; background: var(--surface-3); white-space: nowrap; }
.pd-due.is-overdue { background: rgba(220,38,38,.12); color: #E11D48; }
.pd-go { flex: 0 0 auto; color: var(--text-faint); font-size: 1rem; }
.pd-action:hover .pd-go { color: var(--teal); }

/* Matter progress */
.pd-progress { padding: 0 0 .5rem; margin-bottom: 1.1rem; }
.pd-matter { display: block; padding: .85rem 1.1rem; border-top: 1px solid var(--border);
  text-decoration: none; color: inherit; transition: background .15s ease; }
.pd-matter:hover { background: var(--surface-2); }
.pd-matter-head { display: flex; justify-content: space-between; gap: .75rem;
  align-items: baseline; margin-bottom: .45rem; }
.pd-matter-title { font-size: .9rem; font-weight: 600; min-width: 0; }
.pd-matter-ref { font-size: .74rem; color: var(--text-faint);
  font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
.pd-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.pd-track span { display: block; height: 100%; background: var(--teal); transition: width .3s ease; }
.pd-matter-meta { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .78rem;
  color: var(--text-muted); margin-top: .35rem; }
.pd-next { color: var(--teal); }

/* Side columns */
.pd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; margin-bottom: 1.1rem; }
.pd-side { padding: 0 0 1rem; }
.pd-empty { font-size: .84rem; color: var(--text-muted); padding: 0 1.1rem; margin: 0; }

.pd-date { display: flex; gap: .75rem; align-items: center; padding: .55rem 1.1rem; }
.pd-date-day { flex: 0 0 auto; width: 40px; text-align: center; line-height: 1.1; }
.pd-date-day strong { display: block; font-size: 1.05rem; font-weight: 700; }
.pd-date-day span { font-size: .68rem; text-transform: uppercase; color: var(--text-faint);
  letter-spacing: .04em; }
.pd-date-body { display: flex; flex-direction: column; min-width: 0; }
.pd-date-label { font-size: .85rem; font-weight: 550; }
.pd-date-matter { font-size: .76rem; color: var(--text-muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

.pd-kv { display: flex; flex-direction: column; gap: .45rem; padding: 0 1.1rem; }
.pd-kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  font-size: .85rem; }
.pd-kv span { color: var(--text-muted); }
.pd-owing { color: #B45309; }
[data-theme="dark"] .pd-owing { color: #FCD34D; }
.pd-side-actions { display: flex; gap: .4rem; flex-wrap: wrap; padding: .9rem 1.1rem 0; }

.pd-activity { padding: 0 0 1rem; }
.pd-act { display: flex; gap: .8rem; padding: .45rem 1.1rem; font-size: .83rem; }
.pd-act-when { flex: 0 0 auto; width: 90px; color: var(--text-faint); font-size: .76rem; }
.pd-act-text { color: var(--text-muted); min-width: 0; }

@media (max-width: 720px) {
  .pd-cols { grid-template-columns: 1fr; }
  .pd-act-when { width: 72px; }
  .pd-matter-head { flex-direction: column; gap: .1rem; }
}

/* ── Dashboard exposure card (health · compliance · risk register) ────────── */
.dash-exp { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .25rem 1.1rem .75rem; }
.dash-exp-cell { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .7rem;
  border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit;
  transition: border-color .15s ease, background .15s ease; }
.dash-exp-cell:hover { background: var(--surface-2); border-color: var(--text-faint); }
.dash-exp-cell strong { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.dash-exp-cell span { font-size: .74rem; color: var(--text-muted); }
.dash-exp-cell.is-crit strong { color: #E11D48; }
.dash-exp-cell.is-crit { border-color: rgba(225,29,72,.35); }
.dash-exp-cell.is-warn strong { color: #B45309; }
.dash-exp-cell.is-warn { border-color: rgba(245,158,11,.35); }
[data-theme="dark"] .dash-exp-cell.is-warn strong { color: #FCD34D; }

.dash-exp-line { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  padding: .5rem 1.1rem; border-top: 1px solid var(--border); font-size: .82rem;
  text-decoration: none; color: inherit; }
.dash-exp-link:hover { background: var(--surface-2); }
.dash-exp-k { color: var(--text-muted); }
.dash-exp-v { text-align: right; }
.dash-exp-crit { color: #E11D48; }

/* Active health filter chip on the matters list */
.mhealth-chip { display: inline-flex; align-items: center; padding: .3rem .6rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap; }
.mhealth-risk { background: rgba(225,29,72,.12); color: #E11D48; }
.mhealth-warn { background: rgba(245,158,11,.15); color: #B45309; }
[data-theme="dark"] .mhealth-warn { color: #FCD34D; }

/* ── Dashboard hero band ────────────────────────────────────────────────────
   Matches the reference: navy → indigo → teal ground, animated flow lines,
   a glowing avatar badge, pill-shaped stat chips, and square action tiles with
   a coloured underline. One consolidated block — this replaces two earlier,
   overlapping passes at the same component. */
.dash-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
  padding: 1.7rem 2rem;
  margin-bottom: 1.1rem;
  border-radius: 18px;
  background: linear-gradient(115deg, #0B1120 0%, #10152B 32%, #131A3A 52%, #0E3B44 78%, #0E5A50 100%);
  background-size: 160% 160%;
  animation: dashShift 24s ease-in-out infinite alternate;
  color: #E8F1F5;
  box-shadow: 0 10px 30px -16px rgba(14,148,136,.4), 0 2px 10px rgba(11,17,32,.35);
}
@keyframes dashShift { from { background-position: 0% 40%; } to { background-position: 100% 60%; } }

.dash-hero-fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

/* Ambient motion: three soft light sources drifting at different speeds and
   radii, plus the background-position shift on .dash-hero itself. No hard
   edges anywhere — that reads as "polished"; the earlier line-drawing pass
   read as "busy" against the KPI capsules directly beneath it, so it's gone. */
.dash-orb { position: absolute; border-radius: 50%; filter: blur(4px); }
.dash-orb-teal {
  top: -55%; right: 8%; width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(45,212,191,.24) 0%, rgba(45,212,191,0) 66%);
  animation: dashDrift 20s ease-in-out infinite alternate;
}
.dash-orb-amber {
  bottom: -75%; left: 28%; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(167,139,250,.15) 0%, rgba(167,139,250,0) 64%);
  animation: dashDrift2 26s ease-in-out infinite alternate;
}
.dash-orb-indigo {
  top: 10%; left: -10%; width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(99,102,241,.13) 0%, rgba(99,102,241,0) 62%);
  animation: dashDrift3 32s ease-in-out infinite alternate;
}
@keyframes dashDrift  { from { transform: translate3d(0,0,0) scale(1); }    to { transform: translate3d(-56px,30px,0) scale(1.16); } }
@keyframes dashDrift2 { from { transform: translate3d(0,0,0) scale(1.06); } to { transform: translate3d(64px,-26px,0) scale(.9); } }
@keyframes dashDrift3 { from { transform: translate3d(0,0,0) scale(.95); }  to { transform: translate3d(42px,20px,0) scale(1.1); } }

.dash-hero-sheen {
  position: absolute; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(153,246,228,.08) 46%, transparent);
  transform: skewX(-14deg);
  animation: dashSheen 12s ease-in-out infinite;
}
@keyframes dashSheen {
  0%, 68%   { left: -50%; opacity: 0; }
  72%       { opacity: 1; }
  92%, 100% { left: 118%; opacity: 0; }
}

/* Main: glowing avatar badge + greeting + stat pills. */
.dash-hero-main { position: relative; z-index: 1; display: flex; align-items: center; gap: 1.1rem; min-width: 0; }

.dash-hero-badge {
  flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: radial-gradient(circle, rgba(45,212,191,.16) 0%, rgba(45,212,191,.04) 70%);
  border: 1px solid rgba(45,212,191,.35);
  box-shadow: 0 0 0 5px rgba(45,212,191,.07), 0 0 22px -4px rgba(45,212,191,.55);
  animation: badgePulse 3.2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 5px rgba(45,212,191,.07), 0 0 22px -4px rgba(45,212,191,.5); }
  50%      { box-shadow: 0 0 0 8px rgba(45,212,191,.10), 0 0 30px -2px rgba(45,212,191,.7); }
}
.dash-wave { display: inline-block; transform-origin: 70% 70%; animation: dashWave 2.6s ease-in-out infinite; }
@keyframes dashWave {
  0%, 60%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(16deg); } 30% { transform: rotate(-8deg); } 45% { transform: rotate(12deg); }
}

.dash-hero-greet { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .09em; color: rgba(232,241,245,.6); }
.dash-hero-name  { margin: .05rem 0 .3rem; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; color: #fff; line-height: 1.1;
  text-shadow: 0 1px 14px rgba(14,148,136,.35); }
.dash-hero-sub   { margin: 0 0 .65rem; font-size: .85rem; color: rgba(232,241,245,.68); }

.dash-hero-live { margin: 0; display: flex; gap: .5rem; flex-wrap: wrap; }
.dash-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .4rem .8rem; border-radius: 10px; font-size: .82rem;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.09);
}
.dash-pill strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-pill svg { width: 15px; height: 15px; flex: none; }
.dash-pill-teal strong  { color: #5EEAD4; }
.dash-pill-amber        { color: #FCD34D; }
.dash-pill-amber strong { color: #FCD34D; }

.dash-live-dots { display: inline-flex; gap: 3px; }
.dash-live-dots i { width: 5px; height: 5px; border-radius: 50%; background: #2DD4BF; animation: dashPulse 1.4s ease-in-out infinite; }
.dash-live-dots i:nth-child(2) { animation-delay: .18s; }
.dash-live-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes dashPulse { 0%,100% { opacity: .28; } 50% { opacity: 1; } }

/* Side: quick-action tiles. Square card, icon chip, label, coloured underline
   bar — the shape in the reference, versus the earlier icon-only row. */
.dash-hero-side { position: relative; z-index: 1; }
.dash-hero-links { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }

.qa-tile {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: .5rem; width: 96px; padding: .9rem .6rem 1rem;
  border-radius: 13px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.035);
  text-decoration: none; color: rgba(232,241,245,.85); text-align: center;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.qa-tile:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.16); transform: translateY(-2px); color: #fff; }
.qa-tile span { font-size: .72rem; font-weight: 600; line-height: 1.25; }

.qa {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(255,255,255,.06); border: 1px solid currentColor;
}
.qa svg { width: 18px; height: 18px; stroke: currentColor; }

/* Coloured underline bar, the identifying touch from the reference — short,
   centred, and only lit for the tile it belongs to. */
.qa-bar { display: block; width: 22px; height: 3px; border-radius: 2px; background: currentColor; opacity: .85; }

.qa-matter  { color: #22D3EE; }
.qa-client  { color: #A78BFA; }
.qa-invoice { color: #34D399; }
.qa-time    { color: #FBBF24; }
.qa-diary   { color: #F472B6; }

@media (max-width: 720px) {
  .dash-hero { padding: 1.25rem 1.15rem; }
  .dash-hero-main { align-items: flex-start; }
  .dash-hero-badge { width: 46px; height: 46px; font-size: 1.2rem; }
  .dash-hero-name { font-size: 1.35rem; }
  .dash-hero-side { width: 100%; }
  .dash-hero-links { justify-content: flex-start; }
  .qa-tile { width: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .dash-hero { animation: none; background-size: 100% 100%; }
  .dash-orb, .dash-hero-sheen, .dash-wave, .dash-live-dots i, .dash-hero-badge { animation: none; }
  .dash-hero-sheen { display: none; }
  .qa-tile { transition: none; }
}

/* ── Person avatars (App\Helpers\Avatar) ───────────────────────────────────
   One shape for every person the app names: lists, detail headers, tables,
   assignee chips. Sizes come from the helper as inline width/height so a single
   class serves every context. */
.lbm-avatar {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  object-fit: cover;            /* photos crop to the circle, never squash */
  background: var(--surface-3);
  border: 1px solid rgba(0,0,0,.06);
  overflow: hidden;
  vertical-align: middle;
}
[data-theme="dark"] .lbm-avatar { border-color: rgba(255,255,255,.10); }

.lbm-avatar-i {
  color: #fff; font-weight: 600; letter-spacing: .01em;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  line-height: 1; text-transform: uppercase;
  border-color: transparent;
  user-select: none;
}

/* Avatar + name + optional second line. */
.lbm-person { display: inline-flex; align-items: center; gap: .6rem; min-width: 0; }
.lbm-person-body { display: flex; flex-direction: column; min-width: 0; gap: .05rem; }
.lbm-person-name {
  font-size: .85rem; font-weight: 600; color: var(--text);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.lbm-person-name:hover { color: var(--teal); text-decoration: underline; }
.lbm-person-sub {
  font-size: .74rem; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Overlapping stack, for "who is on this matter" style groups. */
.lbm-avatar-stack { display: inline-flex; align-items: center; }
.lbm-avatar-stack .lbm-avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.lbm-avatar-stack .lbm-avatar:first-child { margin-left: 0; }

/* ── Upload control on the edit forms ─────────────────────────────────────── */
.avatar-field { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.avatar-field .lbm-avatar { box-shadow: 0 2px 8px rgba(16,42,67,.12); }
.avatar-field-controls { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.avatar-field-hint { font-size: .72rem; color: var(--text-faint); margin: 0; }
.avatar-field-remove {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .76rem; color: var(--text-muted); cursor: pointer;
}
.avatar-field input[type="file"] { font-size: .78rem; max-width: 260px; }

/* ── Settings tab panels ───────────────────────────────────────────────────
   These panels were each capped at a hardcoded 480–760px, so on any normal
   monitor two thirds of the page sat empty while the form stayed in a narrow
   column. The cap is gone; what replaces it is a grid that adds columns as the
   viewport allows, so the space gets used without a text input ever stretching
   to 1600px — which is the actual reason the caps were there. */
.settings-panel { max-width: none; width: 100%; }
.settings-stack { display: flex; flex-direction: column; gap: 1rem; }

/* Any settings form grid becomes responsive: one column on a laptop split
   view, up to four on a wide monitor. Fields that deliberately span (textareas,
   addresses) keep their own grid-column rule. */
.settings-panel .form-grid,
.settings-panel .form-grid-2,
.settings-panel .form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(240px, 22vw, 340px), 1fr));
  gap: 1rem;
}

.settings-card-hint { margin: .15rem 0 0; font-size: .74rem; color: var(--text-muted); font-weight: 400; }

/* ── Dashboard chart capsules ──────────────────────────────────────────────
   Six equal cards sharing the KPI strip's grid rhythm: each capsule spans two
   KPI columns, so the two blocks line up down the page instead of each
   inventing its own column widths. */
.dash-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 30%, 480px), 1fr));
  gap: .85rem; margin-bottom: 1.1rem;
}
.dash-cap { display: flex; flex-direction: column; }
/* Fixed plot height is what actually keeps the six aligned — a canvas sizes to
   its data otherwise, and a sparse month would leave one capsule short. */
.dash-cap-body { flex: 1 1 auto; padding: .85rem 1rem 1rem; min-height: 168px; position: relative; }
.dash-cap-body > canvas { position: absolute; inset: .85rem 1rem 1rem; width: 100% !important; height: auto !important; }
/* Pipeline capsule.
   The centre label ("N active") is absolutely centred inside .dash-donut, so
   that box must match the canvas exactly. It was 150px against a 132px canvas,
   which pushed the label 9px off the ring's centre — the misalignment. The
   earlier override targeted `.dash-donut-wrap > canvas`, but the canvas is a
   grandchild of that element, so it never applied at all. */
.dash-cap .dash-donut-wrap {
  padding: .9rem 1rem 1rem; display: flex; align-items: center;
  gap: 1.1rem; flex-direction: row;
}
.dash-cap .dash-donut { flex: 0 0 132px; width: 132px; height: 132px; }
.dash-cap .dash-donut canvas { width: 132px !important; height: 132px !important; }

/* One column, not two: beside a 132px ring the old 2-up grid left ~70px per
   cell, so "In progress" wrapped and its count no longer lined up with the
   others. A single column keeps every count on the same right edge. */
.dash-cap .dash-donut-key { grid-template-columns: 1fr; gap: .45rem; width: auto; flex: 1 1 auto; min-width: 0; }
.dash-cap .dash-key { gap: .45rem; }
.dash-cap .dash-key b { margin-left: auto; padding-left: .5rem; }

/* "Numbers" chart: practice areas as figures with a proportion bar, rather
   than a bar chart whose axis added nothing over the number itself. */
.dash-nums { display: flex; flex-direction: column; padding: .35rem 0 .6rem; }
.dash-num {
  display: grid; grid-template-columns: 2.6rem 1fr 4.5rem 2.2rem;
  align-items: center; gap: .6rem; padding: .42rem 1rem;
  text-decoration: none; color: inherit; transition: background .15s ease;
}
.dash-num:hover { background: var(--surface-2); }
.dash-num strong {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.dash-num-label { font-size: .8rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-num-bar { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.dash-num-bar i { display: block; height: 100%; width: 0; background: var(--teal);
  animation: dashFill .8s cubic-bezier(.22,.61,.36,1) .2s forwards; }
.dash-num-pct { font-size: .74rem; color: var(--text-faint); text-align: right;
  font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .dash-num { grid-template-columns: 2.2rem 1fr 2.6rem; }
  .dash-num-bar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dash-num-bar i { animation: none; width: var(--w, 0%); }
}

/* ── Tasks kanban, full-height board ───────────────────────────────────────
   The old board was a CSS grid that grew down the page: with 79 cards in one
   column you scrolled the whole document and lost the other columns' headers
   entirely. This is a flex row of fixed-width lanes that each scroll on their
   own, with the board sized to the viewport — the shape every kanban has, and
   the only one where a busy column stays usable. */
.kanban-board.kanban-full {
  display: flex;
  grid-template-columns: none;         /* defeat the base .kanban-board grid */
  align-items: stretch;
  gap: .85rem;
  overflow-x: auto;
  overflow-y: hidden;
  /* Viewport minus topbar and the page header/filters above the board. */
  height: calc(100vh - var(--topbar-h) - 190px);
  min-height: 420px;
  padding-bottom: .5rem;
  scroll-snap-type: x proximity;
}

.kanban-full .kanban-column {
  flex: 0 0 302px;
  display: flex;
  flex-direction: column;
  min-height: 0;                        /* lets the body actually scroll */
  padding: 0;
  overflow: hidden;
  scroll-snap-align: start;
  /* The accent bar reads as the column's identity, as in the reference. */
  border-top: 3px solid var(--col, var(--border));
}

.kanban-full .kanban-col-header {
  display: flex; align-items: center; gap: .5rem;
  margin: 0; padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.kanban-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--col, var(--text-faint)); flex: none; }
.kanban-full .kanban-col-title {
  font-size: .74rem; letter-spacing: .05em; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kanban-count {
  margin-left: auto; flex: none;
  min-width: 22px; padding: .1rem .4rem; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted);
  font-size: .68rem; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Only this scrolls, so headers stay put however long the lane gets. */
.kanban-col-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: .7rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.kanban-empty { margin: .4rem 0 0; font-size: .76rem; color: var(--text-faint); text-align: center; }

.kanban-full .kanban-card {
  margin: 0; padding: .7rem .8rem;
  border-left: 3px solid var(--col, var(--border));
  border-radius: 9px;
}
.kb-title {
  font-size: .81rem; font-weight: 600; color: var(--text);
  line-height: 1.35; margin-bottom: .4rem;
}
.kb-matter {
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: ui-monospace, Menlo, monospace; font-size: .68rem;
  color: var(--teal); margin-bottom: .5rem;
}
.kb-matter svg { width: 11px; height: 11px; flex: none; }

.kb-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .55rem; }
.kb-tags .badge { font-size: .6rem; }
.kb-overdue { background: rgba(225,29,72,.12) !important; color: #E11D48 !important; }

.kb-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding-top: .5rem; border-top: 1px solid var(--border);
}
.kb-due {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .69rem; color: var(--text-faint);
}
.kb-due svg { width: 11px; height: 11px; flex: none; }
.kb-due-none { font-style: italic; opacity: .75; }
.kb-who { display: inline-flex; flex: none; }

@media (max-width: 900px) {
  .kanban-board.kanban-full { height: auto; max-height: none; overflow-y: visible; }
  .kanban-full .kanban-column { flex: 0 0 82vw; }
  .kanban-col-body { overflow-y: visible; }
}

/* ── Referral program ──────────────────────────────────────────────────────
   Left sub-nav + tinted KPI cards, following the reference dashboard. Each
   KPI owns one hue via --c/--c-soft so the corner blob, icon and any accent
   text all read from the same source and cannot drift apart. */
.rp-wrap { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1.15rem; align-items: start; }
.rp-main { display: flex; flex-direction: column; gap: 1.15rem; min-width: 0; }
.rp-h { font-size: 1.05rem; font-weight: 700; color: var(--text); margin: 0 0 .2rem; }

.rp-nav { padding: .45rem; display: flex; flex-direction: column; gap: .15rem; position: sticky; top: calc(var(--topbar-h) + .75rem); }
.rp-nav-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .58rem .7rem; border: none; background: none; cursor: pointer;
  border-radius: 9px; font-size: .84rem; font-weight: 500; color: var(--text-muted);
  text-align: left; transition: background .15s ease, color .15s ease;
}
.rp-nav-item svg { width: 16px; height: 16px; flex: none; }
.rp-nav-item:hover { background: var(--surface-2); color: var(--text); }
.rp-nav-item.is-on { background: var(--surface-3); color: var(--text); font-weight: 600; }
.rp-nav-n { margin-left: auto; font-size: .7rem; font-weight: 700; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.rp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.rp-kpis-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.rp-kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1rem 1.1rem 1.1rem;
}
/* The tinted corner wedge from the reference: an oversized circle clipped by
   the card's own overflow, with the glyph sitting in the visible part. */
.rp-kpi-blob {
  position: absolute; top: -34px; right: -34px;
  width: 104px; height: 104px; border-radius: 50%;
  background: var(--c-soft); pointer-events: none;
}
.rp-kpi-ic { position: absolute; top: .85rem; right: 1rem; color: var(--c); }
.rp-kpi-ic svg { width: 18px; height: 18px; }
.rp-kpi-label { font-size: .76rem; color: var(--text-muted); margin-bottom: .35rem; }
.rp-kpi-val {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 1.6rem; font-weight: 700; color: var(--text);
  line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.rp-kpi-sub { font-size: .72rem; color: var(--text-faint); margin-top: .3rem; }

.rp-c-teal   { --c: #0D9488; --c-soft: rgba(13,148,136,.10); }
.rp-c-blue   { --c: #2563EB; --c-soft: rgba(37,99,235,.10); }
.rp-c-violet { --c: #7C3AED; --c-soft: rgba(124,58,237,.10); }
.rp-c-amber  { --c: #D97706; --c-soft: rgba(217,119,6,.12); }
.rp-c-green  { --c: #059669; --c-soft: rgba(5,150,105,.10); }
.rp-c-rose   { --c: #E11D48; --c-soft: rgba(225,29,72,.11); }
.rp-c-slate  { --c: #64748B; --c-soft: rgba(100,116,139,.09); }

.rp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: .9rem; }

.rp-tile-head {
  display: flex; align-items: center; gap: .7rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--c-soft);
}
.rp-tile-ic {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 10px; background: var(--c); color: #fff; flex: none;
}
.rp-tile-ic svg { width: 17px; height: 17px; stroke: #fff; }
.rp-tile-head strong { display: block; font-size: .87rem; color: var(--text); }
.rp-tile-head span { font-size: .74rem; color: var(--text-muted); }

.rp-policy-body { padding: .3rem 0 .5rem; }
.rp-policy-row {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .5rem 1rem; font-size: .8rem; color: var(--text-muted);
}
.rp-policy-row .badge { margin-left: .2rem; }
.rp-policy-ex { align-items: flex-start; }
.rp-fineprint {
  margin: .3rem 1rem .2rem; padding-top: .6rem; border-top: 1px solid var(--border);
  font-size: .72rem; line-height: 1.55; color: var(--text-faint);
}

.rp-person { display: flex; align-items: center; gap: .7rem; padding: .6rem 1rem; }
.rp-person-row { border-top: 1px solid var(--border); }
.rp-person-row:first-of-type { border-top: none; }
.rp-person-body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; gap: .1rem; }
.rp-person-name { font-size: .85rem; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-person-sub { font-size: .75rem; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-src-n { flex: none; text-align: right; }
.rp-src-n strong { display: block; font-size: .95rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.rp-src-n span { font-size: .68rem; color: var(--text-faint); }

.rp-form-inline .rp-inline-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .55rem; padding: .9rem 1rem 1rem; align-items: center;
}
.rp-count { font-size: .72rem; font-weight: 700; color: var(--text-faint); }
.rp-empty { padding: 1.1rem 1rem; margin: 0; font-size: .84rem; color: var(--text-muted); }
.rp-muted { color: var(--text-faint); }
.rp-ok { font-size: .76rem; color: var(--success); font-weight: 600; }
.rp-reason { font-size: .7rem; color: var(--text-faint); margin-top: .15rem; }

.rp-actions { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; }
.rp-actions form { display: inline; }
.rp-pop { position: relative; display: inline-block; }
.rp-pop > summary { list-style: none; cursor: pointer; }
.rp-pop > summary::-webkit-details-marker { display: none; }
.rp-pop-body {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20;
  display: flex; flex-direction: column; gap: .45rem;
  min-width: 210px; padding: .7rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.rp-pop-wide { min-width: 280px; }
.rp-check { display: flex; gap: .4rem; align-items: flex-start; font-size: .74rem; color: var(--text-muted); }

@media (max-width: 900px) {
  .rp-wrap { grid-template-columns: 1fr; }
  .rp-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .rp-nav-item { width: auto; }
}

/* ── Offline surface (views/offline/index.php) ─────────────────────────────
   Deliberately plain: this renders on a phone with no network, so it leans on
   tokens already loaded rather than anything new that would need fetching. */
.of-net{
  display:flex;align-items:center;gap:.6rem;padding:.7rem 1rem;margin-bottom:1rem;
  background:var(--warning-bg);color:#B45309;border-radius:var(--radius-sm);
  font-size:.85rem;font-weight:500;
}
[data-theme="dark"] .of-net{color:#FCD34D}
.of-dot{width:8px;height:8px;border-radius:50%;background:currentColor;flex:none;animation:ofPulse 1.6s ease-in-out infinite}
@keyframes ofPulse{0%,100%{opacity:.35}50%{opacity:1}}

.of-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:1rem;align-items:start}
.of-form{padding:1rem}
.of-hint{font-size:.74rem;color:var(--text-faint);margin-top:.6rem;line-height:1.5}
.of-search{padding:.75rem 1rem 0}
.of-count{font-size:.72rem;font-weight:700;color:var(--text-faint)}
.of-queued{font-size:.72rem;font-weight:700;color:var(--warning);background:var(--warning-bg);padding:.15rem .5rem;border-radius:999px}

.of-list{max-height:420px;overflow-y:auto;padding:.5rem 0}
.of-row{display:block;padding:.6rem 1rem;border-bottom:1px solid var(--border);text-decoration:none;color:inherit}
.of-row:last-child{border-bottom:0}
a.of-row:hover{background:var(--surface-2)}
.of-row b{display:block;font-size:.88rem;font-weight:600;color:var(--text)}
.of-num{font-family:ui-monospace,Menlo,monospace;font-size:.7rem;color:var(--teal);font-weight:600}
.of-sub{display:block;font-size:.76rem;color:var(--text-muted)}
a.of-link{color:var(--teal);text-decoration:none}
a.of-link:hover{text-decoration:underline}
.of-empty{padding:1.2rem 1rem;margin:0;font-size:.85rem;color:var(--text-muted);text-align:center}

@media(max-width:560px){
  .of-grid{grid-template-columns:1fr}
  .of-list{max-height:340px}
}
