/* Harsha LBM — 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 {
  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); }

/* 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 */
.dash-quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); }
.dash-quick-grid a {
  background: var(--surface); padding: .6rem .7rem; font-size: .765rem;
  color: var(--text-muted); text-decoration: none; text-align: center;
  transition: background var(--transition), color var(--transition);
}
.dash-quick-grid a:hover { background: var(--teal-dim); color: var(--teal); }
.dash-quick { overflow: hidden; }

@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); }
