/* 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; }

/* 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; 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;
}

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

/* ─── 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; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  :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; }

  /* 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; }
