/* ---------- SELF-HOSTED TYPEFACES ----------
   Variable fonts, latin subset only. `font-src 'self'` in the CSP
   already permits these — no CSP change needed. Woff2 files live at
   /public/fonts and are served by express.static. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/inter-latin-var.woff2') format('woff2-variations'),
       url('/fonts/inter-latin-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/fraunces-latin-var.woff2') format('woff2-variations'),
       url('/fonts/fraunces-latin-var.woff2') format('woff2');
}

/* ---------- DESIGN TOKENS (light, default) ---------- */
:root {
  /* NAVY — sidebar gradient runs 700 (top) → 900 (bottom) */
  --navy-900: #0a1a2e;
  --navy-800: #0d2039;
  --navy-700: #163049;
  --navy-600: #1e3a5a;
  --navy-500: #2d4a6d;
  --navy-100: #e8ecf3;

  /* GOLD — one refined tone + hover + soft tint */
  --gold-500: #c9a04c;
  --gold-600: #a88536;
  --gold-100: #f7ebca;

  /* SEMANTIC — money/state */
  --pos:      #1a7c4a;
  --pos-100:  #dff4e6;
  --neg:      #b83a3a;
  --neg-100:  #fbe5e5;
  --warn:     #b8802a;
  --warn-100: #fbf0d6;
  --info:     #2b6bb5;
  --info-100: #dfeafa;

  /* SURFACES */
  --bg:        #f7f6f2;
  --card:      #ffffff;
  --surface-2: #f0eeea;
  --border:    #e5e2dc;
  --border-2:  #eeece7;

  /* TEXT */
  --text:       #14202f;
  --text-muted: #62707f;
  --text-faint: #97a2b0;

  /* SHADOWS — soft, layered */
  --shadow-sm: 0 1px 2px rgba(20,32,47,0.04), 0 1px 4px rgba(20,32,47,0.03);
  --shadow-md: 0 2px 6px rgba(20,32,47,0.06), 0 8px 24px rgba(20,32,47,0.06);
  --shadow-lg: 0 12px 34px rgba(20,32,47,0.16);

  /* FOREGROUND ON NAVY — warm ivory used across sidebar, chat bubbles,
     toast, calendar header row, and AI panel */
  --ivory: var(--ivory);

  /* GEOMETRY */
  --radius:      10px;
  --radius-pill: 999px;

  /* TYPE SCALE */
  --fs-xs:  12px;
  --fs-sm:  13px;   /* table/body-small */
  --fs-md:  14px;   /* body */
  --fs-lg:  16px;   /* section titles */
  --fs-xl:  20px;   /* card titles */
  --fs-2xl: 28px;   /* page titles */
  --fs-3xl: 32px;   /* dashboard stat numbers */
  --fs-4xl: 36px;

  /* FOCUS RING — 2px gold outline offset */
  --focus-ring: 0 0 0 2px var(--gold-500);

  /* LEGACY ALIASES — keep older references (calendar, misc widgets)
     working while we finish the sweep. New code should use the
     canonical names above. */
  --navy:       var(--navy-800);
  --navy-mid:   var(--navy-700);
  --navy-light: var(--navy-600);
  --gold:       var(--gold-500);
  --gold-light: var(--gold-600);
  --gold-soft:  color-mix(in srgb, var(--gold-500) 14%, transparent);
  --surface:    var(--card);
  --cream:      var(--bg);
  --cream-dark: var(--surface-2);
  --white:      var(--card);
  --accent-tint: color-mix(in srgb, var(--navy-800) 6%, transparent);
  --success:    var(--pos);
  --danger:     var(--neg);
  --shadow:     var(--shadow-sm);
}

/* ---------- DARK ---------- */
[data-theme="dark"] {
  --navy-900: #05101d;
  --navy-800: #0a1a2e;
  --navy-700: #142338;
  --navy-600: #1e3050;
  --navy-500: #2c4666;
  --navy-100: #1b2a3f;

  --gold-500: #d8b86a;
  --gold-600: #b89845;
  --gold-100: color-mix(in srgb, #d8b86a 22%, transparent);

  --pos:      #5bbd8a;
  --pos-100:  color-mix(in srgb, #5bbd8a 16%, transparent);
  --neg:      #e08585;
  --neg-100:  color-mix(in srgb, #e08585 16%, transparent);
  --warn:     #d9a441;
  --warn-100: color-mix(in srgb, #d9a441 18%, transparent);
  --info:     #6ea3d8;
  --info-100: color-mix(in srgb, #6ea3d8 18%, transparent);

  --bg:        #0c1119;
  --card:      #141b26;
  --surface-2: #1b2431;
  --border:    #26303f;
  --border-2:  #202836;

  --text:       #e7ebf1;
  --text-muted: #93a0b2;
  --text-faint: #6b7789;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.25);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.45), 0 10px 28px rgba(0,0,0,0.35);
  --shadow-lg: 0 14px 38px rgba(0,0,0,0.55);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
/* Body font — native system stack (SF Pro on macOS/iOS, Segoe UI on
   Windows, Roboto on Android). Modern system UI fonts support
   font-variant-numeric: tabular-nums, so table digits still align.
   Fraunces (display serif) is used sparingly, on page titles only. */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.page-title, .display {
  font-family: 'Fraunces', Georgia, serif;
  line-height: 1.2;
  letter-spacing: -0.005em;
}
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius); }

/* LOGIN */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, var(--navy-700), var(--navy-900)); }
.login-box { background: var(--card); border-radius: var(--radius); padding: 32px; width: 380px; box-shadow: var(--shadow-lg); }
.login-logo { font-size: 32px; font-weight: 700; color: var(--gold-500); text-align: center; margin-bottom: 4px; letter-spacing: -0.01em; }
.login-firm { font-size: 16px; color: var(--navy-800); text-align: center; font-weight: 600; }
.login-sub { font-size: 11px; color: var(--text-muted); text-align: center; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 24px; font-weight: 500; }
.login-error { background: var(--neg-100); border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent); color: var(--neg); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: none; }

/* HEADER */
header { background: var(--card); color: var(--text); padding: 0 24px; display: flex; align-items: center; justify-content: space-between; height: 60px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; gap: 16px; }
.firm-name { display: none; }
.firm-sub { display: none; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* LAYOUT */
.app-layout { display: flex; min-height: calc(100vh - 60px); }
/* Sidebar — solid lighter navy (was gradient — reverted per Bill's review).
   Extra top padding takes the place of the removed wordmark block. */
nav { width: 224px; background: var(--navy-700); padding: 28px 0; flex-shrink: 0; display: flex; flex-direction: column; }
main { flex: 1; padding: 32px; overflow-y: auto; background: var(--bg); }
.panel { display: none; } .panel.active { display: block; }

/* NAV — brighter ivory text, as it was pre-refresh */
.nav-section { margin-bottom: 24px; }
.nav-label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(245,240,232,0.35); padding: 0 20px; margin-bottom: 6px; font-weight: 500; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(245,240,232,0.7); cursor: pointer; font-size: 14px; transition: background 0.15s, color 0.15s, border-color 0.15s; border-left: 3px solid transparent; }
.nav-item:hover { background: color-mix(in srgb, var(--gold-500) 8%, transparent); color: var(--ivory); }
.nav-item.active { background: color-mix(in srgb, var(--gold-500) 12%, transparent); color: var(--gold-500); border-left-color: var(--gold-500); font-weight: 500; }
.nav-icon { font-size: 16px; width: 18px; text-align: center; }
.msg-badge { color: var(--gold-500); font-size: 18px; line-height: 1; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-family: 'Fraunces', serif; font-size: var(--fs-2xl); font-weight: 600; color: var(--text); letter-spacing: -0.01em; line-height: 1.15; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* CARDS */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }

/* STATS */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow-sm); transition: box-shadow 0.2s ease, transform 0.15s ease; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.stat-value { font-size: var(--fs-3xl); font-weight: 700; color: var(--text); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 12px; color: var(--text-muted); margin-top: 8px; font-variant-numeric: tabular-nums; min-height: 15px; }
.stat-delta.pos { color: var(--pos); }
.stat-delta.neg { color: var(--neg); }
.stat-scope { font-weight: 400; opacity: 0.7; letter-spacing: 0.02em; text-transform: none; font-size: 10px; margin-left: 4px; }

/* DASHBOARD LAYOUT */
.dash-greeting { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dash-summary { font-size: 14px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }
.dash-summary .sep { color: var(--text-faint); margin: 0 8px; }
.dash-summary a { color: var(--navy-800); font-weight: 600; text-decoration: none; border-bottom: 1px dotted color-mix(in srgb, var(--navy-800) 30%, transparent); cursor: pointer; }
.dash-summary a:hover { color: var(--gold-600); border-bottom-color: var(--gold-500); }

.dash-chart-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 24px; }
.dash-list-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .dash-chart-row, .dash-list-row { grid-template-columns: 1fr; } }

.dash-chart-card, .dash-list-card { padding: 20px 24px; }
.dash-card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.dash-card-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.dash-card-subtitle { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.dash-chart-body { min-height: 200px; display: flex; align-items: stretch; justify-content: stretch; }
.dash-chart-body svg { display: block; width: 100%; height: 200px; }

/* SPARKLINE */
.spark-wrap { position: relative; width: 100%; height: 200px; }
.spark-svg  { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.spark-area { fill: color-mix(in srgb, var(--navy-700) 12%, transparent); }
.spark-line { fill: none; stroke: var(--navy-700); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-current { position: absolute; right: 0; display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 4px; background: var(--card); border-radius: 6px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.spark-current-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--navy-700); flex-shrink: 0; }
.spark-current-val { font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
.spark-axis-row { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; }
.spark-axis-label { position: absolute; bottom: 0; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* AGING DONUT */
.dash-aging-wrap { display: flex; align-items: center; gap: 20px; width: 100%; }
.dash-aging-wrap svg { width: 180px; height: 180px; flex-shrink: 0; }
.aging-center-total { fill: var(--text); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; text-anchor: middle; }
.aging-center-label { fill: var(--text-muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; text-anchor: middle; }
.aging-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 13px; min-width: 0; }
.aging-legend-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.aging-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.aging-legend-label { flex: 1; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aging-legend-amt { color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; }

/* UPCOMING + ACTIVITY LISTS */
.dash-list-empty { padding: 24px 8px; text-align: center; color: var(--text-muted); font-size: 13px; }
.dash-item { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border-2); align-items: start; }
.dash-item:last-child { border-bottom: none; }
.dash-item-chip { background: var(--surface-2); color: var(--text-muted); border-radius: 8px; text-align: center; padding: 4px 6px; font-size: 11px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.dash-item-chip.today    { background: color-mix(in srgb, var(--gold-500) 18%, transparent); color: var(--gold-600); }
.dash-item-chip .chip-day { display: block; font-size: 16px; font-weight: 700; color: var(--text); }
.dash-item-chip.today .chip-day { color: var(--gold-600); }
.dash-item-body { min-width: 0; }
.dash-item-title { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.dash-item-meta a { color: var(--navy-800); text-decoration: none; font-weight: 600; }
.dash-item-meta a:hover { color: var(--gold-600); }
.dash-kind-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dash-kind-dot.deadline    { background: var(--warn); }
.dash-kind-dot.appointment { background: var(--info); }
.dash-kind-dot.payment       { background: var(--pos); }
.dash-kind-dot.matter_created{ background: var(--gold-500); }
.dash-kind-dot.invoice_created{ background: var(--info); }
.dash-kind-dot.trust_deposit  { background: var(--pos); }
.dash-kind-dot.trust_disbursement{ background: var(--neg); }
.dash-kind-dot.deadline_added   { background: var(--warn); }

.dash-activity-item { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border-2); align-items: start; }
.dash-activity-item:last-child { border-bottom: none; }
.dash-activity-body { min-width: 0; }
.dash-activity-primary { font-size: 13px; color: var(--text); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; }
.dash-activity-primary a { color: var(--navy-800); text-decoration: none; font-weight: 600; }
.dash-activity-primary a:hover { color: var(--gold-600); }
.dash-activity-primary .amt { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.dash-activity-primary .amt.pos { color: var(--pos); }
.dash-activity-primary .amt.neg { color: var(--neg); }
.dash-activity-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.dash-activity-time { font-size: 11px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dash-activity-item.new { animation: activity-slide-in 0.35s ease-out; }
@keyframes activity-slide-in {
  from { opacity: 0; transform: translateY(-6px); background: color-mix(in srgb, var(--gold-500) 12%, transparent); }
  to   { opacity: 1; transform: translateY(0); background: transparent; }
}

/* TASKS */
.task-group { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.task-group-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); font-weight: 700; }
.task-group-count { background: var(--card); color: var(--text-muted); padding: 1px 8px; border-radius: var(--radius-pill); font-size: 11px; font-variant-numeric: tabular-nums; }

.task-row { display: grid; grid-template-columns: 32px 1fr 32px; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-2); align-items: start; transition: background 0.15s, opacity 0.25s; }
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--surface-2); }
.task-row.task-overdue { background: color-mix(in srgb, var(--warn) 8%, transparent); border-left: 3px solid var(--warn); padding-left: 13px; }
.task-row.task-done { opacity: 0.5; }
.task-row.task-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-check { display: flex; align-items: center; justify-content: center; padding-top: 2px; }
.task-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--pos); }
.task-body { min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-pri { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 1px 7px; border-radius: 4px; }
.task-pri-high { background: var(--neg-100); color: var(--neg); }
.task-pri-low  { background: var(--surface-2); color: var(--text-muted); }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.task-meta-item { white-space: nowrap; }
.task-meta-item.is-overdue { color: var(--neg); font-weight: 600; }
.task-meta-item a { color: var(--navy-800); text-decoration: none; font-weight: 600; }
.task-meta-item a:hover { color: var(--gold-600); }
.task-age { opacity: 0.7; margin-left: auto; }
.task-del-btn { background: none; border: none; color: var(--text-faint); font-size: 20px; cursor: pointer; line-height: 1; padding: 0 4px; opacity: 0; transition: opacity 0.15s, color 0.15s; }
.task-row:hover .task-del-btn { opacity: 1; }
.task-del-btn:hover { color: var(--neg); }

/* Inline "+ Add Task" row on the matter workspace */
.matter-task-add-row { display: grid; grid-template-columns: 1fr 130px 110px 90px 100px; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); align-items: center; }
.matter-task-add-row input, .matter-task-add-row select { font-size: 13px; padding: 6px 10px; height: 34px; }
.matter-task-add-row .btn { height: 34px; padding: 4px 12px; white-space: nowrap; }

/* Dashboard Needs-Attention (stale matter radar) */
.dash-stale-card { grid-column: 1 / -1; }
.dash-stale-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
@media (max-width: 780px) { .dash-stale-list { grid-template-columns: 1fr; } }
.dash-stale-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-2); }
.dash-stale-item:last-child { border-bottom: none; }
.dash-stale-days { font-size: 12px; font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums; padding: 2px 8px; background: var(--warn-100); border-radius: 6px; min-width: 56px; text-align: center; }
.dash-stale-days.very { color: var(--neg); background: var(--neg-100); }
.dash-stale-body { min-width: 0; }
.dash-stale-title a { color: var(--navy-800); text-decoration: none; font-weight: 600; font-size: 13px; }
.dash-stale-title a:hover { color: var(--gold-600); }
.dash-stale-sub { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.dash-stale-btn { padding: 4px 10px; font-size: 11px; font-weight: 600; border-radius: 6px; border: 1px solid var(--gold-500); background: transparent; color: var(--gold-600); cursor: pointer; white-space: nowrap; }
.dash-stale-btn:hover { background: var(--gold-500); color: var(--navy-900); }

/* Task icon on the dashboard Upcoming rows */
.dash-kind-dot.task { background: var(--gold-500); }

/* CONTACT TAGS ROW (in view-client modal) */
.contact-tags-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; flex-wrap: wrap; }
.contact-tags-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.contact-tags-pills { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; align-items: center; }
.contact-tag-pill { display: inline-flex; align-items: center; padding: 3px 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; border-radius: var(--radius-pill); background: var(--gold-100); color: var(--gold-600); border: 1px solid color-mix(in srgb, var(--gold-500) 30%, transparent); }
.contact-ca-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); font-weight: 500; cursor: pointer; padding: 4px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
.contact-ca-toggle input[type="checkbox"] { accent-color: var(--gold-500); }

/* FEE APPLICATIONS */
.fa-controls-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.fa-controls-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fa-control-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); font-weight: 700; }
.fa-controls-left select { width: auto; min-width: 140px; padding: 6px 10px; font-size: 13px; height: 34px; }
.fa-sort-toggle { display: inline-flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 2px; }
.fa-sort-toggle button { padding: 5px 12px; border-radius: 7px; font-size: 12px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-family: inherit; transition: background 0.15s, color 0.15s; }
.fa-sort-toggle button.active { background: var(--card); color: var(--navy-800); font-weight: 600; box-shadow: var(--shadow-sm); }
.fa-controls-right { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.feeapp-row.is-selected { background: color-mix(in srgb, var(--gold-500) 8%, transparent); }
.feeapp-row input[type="checkbox"] { accent-color: var(--gold-500); }
.fa-bulk-bar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--navy-800); color: var(--ivory); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 500; font-size: 14px; min-width: 380px; }
.fa-bulk-bar strong { color: var(--gold-500); font-weight: 700; }
.fa-bulk-bar .btn-outline { background: transparent; color: var(--ivory); border-color: color-mix(in srgb, var(--ivory) 30%, transparent); }
.fa-bulk-bar .btn-outline:hover { border-color: var(--ivory); }

.feeapp-row .fa-date { font-variant-numeric: tabular-nums; color: var(--text); }
.feeapp-row .age-warn { color: var(--warn); font-weight: 600; }
.feeapp-row .age-neg  { color: var(--neg);  font-weight: 700; }
.feeapp-row.is-virtual { background: color-mix(in srgb, var(--warn) 6%, transparent); }
.fa-virtual-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--warn-100); color: var(--warn); margin-left: 6px; }

/* Matter overview compact fee-app strip */
.matter-feeapp-strip { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--gold-500); border-radius: var(--radius); box-shadow: var(--shadow-sm); font-size: 13px; flex-wrap: wrap; }
.matter-feeapp-strip.is-empty { border-left-color: var(--text-faint); background: var(--surface-2); }
.fa-strip-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 700; }
.fa-strip-value { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.fa-stage-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.fa-stage-needs_app { background: var(--warn); }
.fa-stage-submitted { background: var(--info); }
.fa-stage-paid      { background: var(--pos); }
.fa-stage-closed    { background: var(--text-muted); }
.fa-strip-dates { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fa-strip-amt { margin-left: auto; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Dashboard fee-apps summary card */
.dash-feeapps-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 780px) { .dash-feeapps-row { grid-template-columns: repeat(2, 1fr); } }
.dash-fa-cell { padding: 10px 14px; background: var(--surface-2); border-radius: 8px; }
.dash-fa-cell.dash-fa-money { background: color-mix(in srgb, var(--gold-500) 10%, transparent); }
.dash-fa-num { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dash-fa-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* MANAGE CALENDARS MODAL */
.cal-manage-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; line-height: 1; opacity: 0.75; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.cal-manage-btn:hover { opacity: 1; color: var(--gold-600); background: var(--surface-2); }
.mc-row { display: grid; grid-template-columns: 32px 14px 1fr; gap: 10px; padding: 12px 10px; border-bottom: 1px solid var(--border-2); align-items: start; }
.mc-row:last-child { border-bottom: none; }
.mc-row-legacy { grid-template-columns: 32px 14px 1fr; opacity: 0.72; }
.mc-toggle { display: flex; align-items: center; justify-content: center; padding-top: 2px; }
.mc-toggle input { width: 18px; height: 18px; accent-color: var(--gold-500); cursor: pointer; }
.mc-toggle input:disabled { cursor: not-allowed; opacity: 0.6; }
.mc-swatch { width: 14px; height: 14px; border-radius: 3px; margin-top: 5px; }
.mc-row-body { min-width: 0; }
.mc-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.mc-summary { font-size: 14px; font-weight: 600; color: var(--text); }
.mc-tag { display: inline-block; padding: 1px 7px; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; border-radius: 4px; background: var(--surface-2); color: var(--text-muted); }
.mc-tag-lock { background: var(--gold-100); color: var(--gold-600); }
.mc-tag-reader { background: var(--warn-100); color: var(--warn); }
.mc-row-details { display: grid; grid-template-columns: 1fr 40px auto; gap: 8px; align-items: center; }
.mc-row-details-off { grid-template-columns: 1fr auto; opacity: 0.7; }
.mc-name { font-size: 13px; padding: 6px 10px; height: 32px; }
.mc-color { width: 40px; height: 32px; padding: 2px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; background: var(--card); }
.mc-color:disabled { cursor: not-allowed; opacity: 0.6; }
.mc-gcal-id { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; word-break: break-all; }

/* SKELETON LOADING */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--border-2) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite ease-in-out; border-radius: 6px; }
.skeleton-chart { height: 200px; width: 100%; }
.skeleton-row   { height: 42px; margin-bottom: 8px; }
.skeleton-row:last-child { margin-bottom: 0; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; opacity: 0.6; }
  .stat-card:hover { transform: none; }
  .dash-activity-item.new { animation: none; }
}

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; height: 36px; border-radius: var(--radius); font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; border: 1px solid transparent; transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s; white-space: nowrap; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--gold-500); }
.btn-primary { background: var(--navy-800); color: var(--gold-500); border-color: var(--navy-800); }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
.btn-gold { background: var(--gold-500); color: var(--navy-900); font-weight: 600; }
.btn-gold:hover { background: var(--gold-600); color: #fff; }
.btn-outline { background: var(--card); color: var(--navy-800); border-color: var(--border); }
.btn-outline:hover { border-color: var(--navy-700); color: var(--navy-900); }
.btn-danger { background: transparent; color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.btn-danger:hover { background: var(--neg-100); border-color: var(--neg); }
.btn-sm { height: 28px; padding: 4px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:disabled:hover { background: inherit; border-color: inherit; color: inherit; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.badge-open::before, .badge-closed::before, .badge-archived::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-open { background: var(--pos-100); color: var(--pos); }
.badge-closed { background: var(--surface-2); color: var(--text-muted); }
.badge-archived { background: var(--warn-100); color: var(--warn); }
.unlinked-badge { font-size: 11px; color: var(--text-muted); opacity: 0.55; vertical-align: middle; cursor: default; user-select: none; }
.btn-matters-expand { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--navy-800); padding: 2px 6px; border-radius: 4px; display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-matters-expand:hover { background: var(--surface-2); }
.matter-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 180px; z-index: 100; padding: 6px 0; }
.matter-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 8px 16px; font-size: 13px; color: var(--text); cursor: pointer; font-family: inherit; }
.matter-menu button:hover { background: var(--surface-2); }
.matter-menu button.menu-danger { color: var(--neg); }
.matter-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }
.cb-col { width: 32px; text-align: center; padding: 0 4px; }
#bulk-action-bar { align-items: center; gap: 12px; padding: 10px 16px; background: var(--gold-100); border: 1px solid color-mix(in srgb, var(--gold-500) 40%, transparent); border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
#bulk-count-label { font-weight: 700; color: var(--text); min-width: 96px; }
#bulk-status-select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--card); }
.internal-note-label { color: var(--text-muted); display: flex; align-items: baseline; gap: 6px; }
.internal-note-sublabel { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.85; }
.te-note-btn { background: none; border: none; cursor: pointer; font-size: 12px; padding: 0 3px; vertical-align: middle; opacity: 0.65; line-height: 1; }
.te-note-btn:hover { opacity: 1; }
.te-note-reveal { background: var(--warn-100); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: 6px; padding: 6px 10px; margin-top: 4px; font-size: 12px; color: var(--text); white-space: pre-wrap; }
.te-note-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.te-note-item:last-child { border-bottom: none; }
.te-note-item-header { display: flex; gap: 12px; align-items: baseline; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; flex-wrap: wrap; }
.te-note-item-date { font-variant-numeric: tabular-nums; }
.te-note-item-who { font-weight: 600; color: var(--navy-800); }
.te-note-item-ref { font-style: italic; }
.te-note-item-body { font-size: 13px; color: var(--text); white-space: pre-wrap; background: var(--warn-100); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: 6px; padding: 6px 10px; }
.badge-fl { background: var(--info-100); color: var(--info); }
.badge-cl { background: var(--pos-100); color: var(--pos); }
.badge-we { background: color-mix(in srgb, #8e24aa 12%, transparent); color: #8e24aa; }
.badge-cd { background: var(--neg-100); color: var(--neg); }

/* INPUTS */
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="password"], select, textarea { font-family: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); background: var(--card); width: 100%; transition: border-color 0.15s, box-shadow 0.15s; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-700) 12%, transparent); }

/* SEARCH */
.search-bar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.search-input-wrap { position: relative; flex: 1; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrap input { padding-left: 34px; }

/* FILTER TABS */
.filter-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--radius); padding: 4px; margin-bottom: 16px; width: fit-content; }
.filter-tab { padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-family: inherit; transition: background 0.15s, color 0.15s; }
.filter-tab.active { background: var(--card); color: var(--navy-800); box-shadow: var(--shadow-sm); font-weight: 600; }

/* TABLE */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface-2); }
th { padding: 10px 16px; text-align: left; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; color: var(--text-muted); white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border-2); font-size: var(--fs-sm); vertical-align: middle; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: color-mix(in srgb, var(--navy-100) 40%, transparent); }
.client-name { font-weight: 600; color: var(--navy-800); font-variant-numeric: normal; }
.matter-num { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.action-btns { display: flex; gap: 6px; }

/* CONFLICT */
.conflict-result { padding: 16px; border-radius: var(--radius); font-size: 14px; }
.conflict-clear { background: var(--pos-100); border: 1px solid color-mix(in srgb, var(--pos) 30%, transparent); color: var(--pos); }
.conflict-hit { background: var(--neg-100); border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent); color: var(--neg); }
.conflict-match { background: var(--neg-100); border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent); border-radius: var(--radius); padding: 16px; margin-top: 12px; }
.conflict-match-name { font-weight: 700; color: var(--neg); }
.conflict-match-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* CHAT */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 220px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; flex-direction: column; gap: 2px; }
.chat-msg-header { display: flex; align-items: baseline; gap: 8px; }
.chat-msg-name { font-weight: 600; font-size: 13px; color: var(--navy-800); }
.chat-msg-time { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chat-msg-body { font-size: 14px; color: var(--text); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; width: fit-content; max-width: 80%; }
.chat-msg.mine .chat-msg-body { background: var(--navy-800); color: var(--ivory); align-self: flex-end; }
.chat-msg.mine { align-items: flex-end; }
.chat-input-row { display: flex; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: color-mix(in srgb, var(--navy-900) 55%, transparent); backdrop-filter: blur(3px); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
/* Flex-column so the header sits at top, body scrolls in the middle,
   and .form-actions inside the body can pin sticky to the bottom
   without any dedicated .modal-footer element. Backward-compatible
   with every existing modal (the form-actions markup didn't change). */
.modal { background: var(--card); border-radius: var(--radius); width: 680px; max-width: 95vw; max-height: 88vh; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.modal-header { background: var(--card); color: var(--text); padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: var(--fs-lg); font-weight: 600; color: var(--navy-800); letter-spacing: -0.005em; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; opacity: 0.7; line-height: 1; padding: 0 4px; }
.modal-close:hover { opacity: 1; color: var(--text); }
/* Flex-grow so the body claims all remaining height; overflow-y so
   long content scrolls INSIDE the modal instead of pushing the
   footer out. */
.modal-body { padding: 24px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

/* FORMS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }
/* Sticky footer inside .modal-body — Save/Cancel stay visible even
   when the form is taller than the viewport. Card background + a
   soft top border make the sticky boundary readable when content
   scrolls behind it. Negative horizontal margins undo the body
   padding so the border spans the full modal width. */
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin: 24px -24px -24px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--card); position: sticky; bottom: -24px; z-index: 2; }
.form-section-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin: 0 0 16px; padding-bottom: 6px; border-bottom: 2px solid var(--gold-500); }

/* INTAKE TABS */
.intake-area-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.area-tab { padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--card); color: var(--text-muted); font-family: inherit; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.area-tab.active { background: var(--navy-800); color: var(--gold-500); border-color: var(--navy-800); font-weight: 600; }
.intake-form { display: none; } .intake-form.active { display: block; }

/* DETAIL */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.detail-item label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.detail-item .val { font-size: 14px; color: var(--text); font-weight: 500; }

/* TOAST */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy-800); color: var(--ivory); padding: 12px 20px; border-radius: var(--radius); font-size: 13px; border-left: 3px solid var(--gold-500); box-shadow: var(--shadow-lg); z-index: 999; opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }

/* BILLING */
.billing-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--radius); padding: 4px; margin-bottom: 24px; width: fit-content; }
.billing-tab { padding: 6px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-family: inherit; transition: background 0.15s, color 0.15s; }
.billing-tab.active { background: var(--card); color: var(--navy-800); box-shadow: var(--shadow-sm); font-weight: 600; }
.billing-tab-panel { }
.lawpay-badge-count { display: inline-block; margin-left: 6px; padding: 1px 8px; font-size: 11px; font-weight: 700; border-radius: var(--radius-pill); background: var(--gold-500); color: var(--navy-900); font-variant-numeric: tabular-nums; }
.acct-badge { display: inline-block; padding: 2px 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; border-radius: 6px; text-transform: uppercase; }
.acct-badge-trust { background: color-mix(in srgb, #8e24aa 12%, transparent); color: #7b1fa2; }
.acct-badge-operating { background: var(--pos-100); color: var(--pos); }
.acct-badge-unknown { background: var(--surface-2); color: var(--text-muted); }
input[type="number"] { font-family: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); background: var(--card); width: 100%; transition: border-color 0.15s, box-shadow 0.15s; outline: none; font-variant-numeric: tabular-nums; }
input[type="number"]:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-700) 12%, transparent); }
input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--navy-800); }
@media print { .no-print { display: none !important; } }

/* GENERAL AREA BADGE */
.badge-gn { background: var(--surface-2); color: var(--text-muted); }

/* SORTABLE TABLE HEADERS */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { background: var(--border-2); }
.sort-asc::after  { content: ' ▲'; font-size: 9px; opacity: 0.75; }
.sort-desc::after { content: ' ▼'; font-size: 9px; opacity: 0.75; }
.import-badge { display: inline-block; margin-left: 6px; padding: 2px 6px; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); text-transform: uppercase; vertical-align: middle; }

/* DYNAMIC LISTS (authorized contacts, children) */
.dynamic-list { display: flex; flex-direction: column; gap: 6px; }
.contact-row, .child-row { display: flex; gap: 6px; align-items: center; }
.contact-row input, .child-row input { flex: 1; min-width: 0; }

/* INTAKE LINK CARDS */
.intake-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.intake-link-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow-sm); }
.intake-link-card img { width: 140px; height: 140px; border-radius: 6px; margin-bottom: 12px; display: block; margin-left: auto; margin-right: auto; }
.intake-link-area { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.intake-link-url { font-size: 11px; color: var(--text-muted); word-break: break-all; margin-bottom: 4px; font-variant-numeric: tabular-nums; }

/* MATTER WORKSPACE */
.matter-ws-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.matter-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--radius); padding: 4px; margin-bottom: 24px; width: fit-content; flex-wrap: wrap; }
.matter-tab { padding: 6px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--text-muted); font-family: inherit; transition: background 0.15s, color 0.15s; }
.matter-tab.active { background: var(--card); color: var(--navy-800); box-shadow: var(--shadow-sm); font-weight: 600; }
.matter-overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .matter-overview-grid { grid-template-columns: 1fr; } }
.ws-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.ws-card-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-2); }

/* Assigned-staff pills on the matter overview */
.staff-pill-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.staff-pill { display: inline-flex; align-items: center; gap: 6px; background: color-mix(in srgb, var(--gold-500) 10%, transparent); border: 1px solid color-mix(in srgb, var(--gold-500) 32%, transparent); color: var(--text); border-radius: var(--radius-pill); padding: 4px 8px 4px 12px; font-size: 12px; }
.staff-pill .staff-pill-role { color: var(--text-muted); font-size: 11px; }
.staff-pill button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.staff-pill button:hover { color: var(--neg); }
.staff-pill-empty { font-size: 13px; color: var(--text-muted); padding: 4px 0 8px; }

/* Contact status row under the New Matter modal's client-name input */
.contact-status-row { min-height: 24px; margin-top: 6px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.contact-status-row .hint { color: var(--text-muted); }
.contact-status-row .linked { color: var(--pos); }
.contact-status-row .warn   { color: var(--warn); }

/* Unlinked-matter badge + Link button on the contact detail's linked-matters table */
.unlinked-pill { display: inline-flex; align-items: center; padding: 2px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; border-radius: var(--radius-pill); background: var(--warn-100); color: var(--warn); margin-left: 8px; text-transform: uppercase; }
.staff-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.staff-add-row select, .staff-add-row input { flex: 1; min-width: 120px; }
.ws-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.ws-stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow-sm); }
.ws-stat-val { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); font-variant-numeric: tabular-nums; }
.ws-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; font-weight: 600; }

/* CLICKABLE TABLE CELLS */
.link-cell { cursor: pointer; }
.link-cell:hover { text-decoration: underline; text-underline-offset: 2px; }

/* USER AVATAR */
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-800); color: var(--gold-500); font-size: 11px; font-weight: 700; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border: none; flex-shrink: 0; transition: opacity 0.15s; letter-spacing: 0.02em; }
.user-avatar:hover { opacity: 0.82; }
/* .theme-forest / .theme-slate / .theme-plum were defined but never
   applied to any element — removed during Phase 1 design refresh. */

/* AI FLOATING BUTTON */
#ai-fab { position: fixed; bottom: 24px; right: 24px; width: 52px; height: 52px; border-radius: 50%; background: var(--gold-500); color: var(--navy-900); border: none; font-size: 20px; cursor: pointer; box-shadow: 0 4px 18px rgba(20,32,47,0.28); z-index: 300; align-items: center; justify-content: center; transition: background 0.15s, transform 0.15s; font-family: inherit; font-weight: 700; }
#ai-fab:hover { background: var(--gold-600); color: #fff; transform: translateY(-2px); }

/* AI GLOBAL CHAT PANEL */
#ai-chat-panel { position: fixed; bottom: 88px; right: 24px; width: 380px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 128px); background: var(--navy-800); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 299; display: flex; flex-direction: column; overflow: hidden; opacity: 0; transform: translateY(12px) scale(0.97); pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
#ai-chat-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.ai-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--navy-700); border-bottom: 1px solid color-mix(in srgb, var(--gold-500) 20%, transparent); flex-shrink: 0; }
.ai-panel-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; color: var(--gold-500); letter-spacing: -0.005em; }
.ai-panel-icon { font-size: 18px; }
.ai-panel-close { background: none; border: none; color: rgba(245,240,232,0.5); font-size: 20px; cursor: pointer; line-height: 1; transition: color 0.15s; padding: 0; }
.ai-panel-close:hover { color: var(--ivory); }
.ai-chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold-500) 30%, transparent); border-radius: 2px; }
.ai-message { max-width: 88%; padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.ai-message-user { align-self: flex-end; background: var(--gold-500); color: var(--navy-900); font-weight: 500; border-radius: 10px 10px 2px 10px; }
.ai-message-assistant { align-self: flex-start; background: var(--navy-600); color: var(--ivory); border-radius: 10px 10px 10px 2px; }
.ai-message-thinking { align-self: flex-start; background: var(--navy-600); color: rgba(245,240,232,0.5); border-radius: 10px; padding: 8px 14px; }
.ai-dots { display: inline-flex; gap: 3px; align-items: center; }
.ai-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-500); animation: ai-dot-bounce 1.2s infinite; }
.ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-5px); opacity: 1; } }
.ai-chat-input-area { display: flex; gap: 8px; padding: 12px; border-top: 1px solid color-mix(in srgb, var(--gold-500) 15%, transparent); flex-shrink: 0; align-items: flex-end; }
.ai-chat-input-area textarea { flex: 1; min-height: 38px; max-height: 100px; resize: none; background: var(--navy-600); border: 1px solid color-mix(in srgb, var(--gold-500) 20%, transparent); color: var(--ivory); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: inherit; outline: none; transition: border-color 0.15s; }
.ai-chat-input-area textarea:focus { border-color: var(--gold-500); }
.ai-chat-input-area textarea::placeholder { color: rgba(245,240,232,0.35); }

/* MATTER AI TAB */
.matter-tab-ai { color: var(--gold-500) !important; }
.matter-tab-ai.active { background: color-mix(in srgb, var(--gold-500) 15%, transparent) !important; color: var(--gold-500) !important; }
.matter-ai-wrap { display: flex; flex-direction: column; gap: 16px; }
.matter-ai-header { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }
.matter-ai-quick-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ai-quick-btn { padding: 6px 14px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--gold-500); background: transparent; color: var(--gold-600); font-family: inherit; transition: background 0.15s, color 0.15s; }
.ai-quick-btn:hover { background: var(--gold-500); color: var(--navy-900); }
.matter-ai-msgs { flex: 1; min-height: 200px; max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--navy-800); border-radius: var(--radius); margin-bottom: 8px; scroll-behavior: smooth; }
.matter-ai-msgs::-webkit-scrollbar { width: 4px; }
.matter-ai-msgs::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold-500) 30%, transparent); border-radius: 2px; }
.matter-ai-msg-user { align-self: flex-end; background: var(--gold-500); color: var(--navy-900); font-weight: 500; max-width: 88%; padding: 8px 12px; border-radius: 10px 10px 2px 10px; font-size: 13px; line-height: 1.45; }
.matter-ai-msg-assistant { align-self: flex-start; background: var(--navy-600); color: var(--ivory); max-width: 92%; padding: 8px 12px; border-radius: 10px 10px 10px 2px; font-size: 13px; line-height: 1.5; }
.matter-ai-msg-thinking { align-self: flex-start; background: var(--navy-600); color: rgba(245,240,232,0.5); padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.matter-ai-input { display: flex; gap: 8px; align-items: flex-end; }
.matter-ai-input textarea { flex: 1; min-height: 36px; max-height: 90px; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: inherit; outline: none; transition: border-color 0.15s; }
.matter-ai-input textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-700) 12%, transparent); }

/* AI ACTION CHIPS */
.ai-action-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: color-mix(in srgb, var(--gold-500) 8%, transparent); border: 1px solid color-mix(in srgb, var(--gold-500) 25%, transparent); border-radius: 8px; padding: 8px 12px; margin-top: 6px; }
.ai-action-item-text { font-size: 13px; font-weight: 600; color: var(--ivory); flex: 1; }
.ai-action-item-meta { font-size: 11px; color: rgba(245,240,232,0.55); font-variant-numeric: tabular-nums; }
.ai-action-add-btn { padding: 4px 12px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid var(--gold-500); background: transparent; color: var(--gold-500); font-family: inherit; white-space: nowrap; transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.ai-action-add-btn:hover { background: var(--gold-500); color: var(--navy-900); }
.ai-action-add-btn:disabled { opacity: 0.5; cursor: default; }
.matter-ai-msg-assistant .ai-action-item .ai-action-item-text,
.matter-ai-msg-assistant .ai-action-item .ai-action-item-meta { color: var(--text); }
.matter-ai-msg-assistant .ai-action-item .ai-action-item-meta { color: var(--text-muted); }
.matter-ai-msg-assistant .ai-action-item { background: color-mix(in srgb, var(--gold-500) 6%, transparent); border-color: color-mix(in srgb, var(--gold-500) 30%, transparent); }
.matter-ai-msg-assistant .ai-action-add-btn { color: var(--gold-600); }
.matter-ai-msg-assistant .ai-action-add-btn:hover { background: var(--gold-500); color: var(--navy-900); }

/* MYCASE IMPORT */
.import-file-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.import-file-slot { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; transition: border-color 0.2s; }
.import-file-slot.has-file { border-color: var(--gold-500); }
.import-slot-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.import-slot-icon { font-size: 20px; line-height: 1; }
.import-slot-title { font-weight: 600; font-size: 13px; }
.import-slot-hint { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.import-slot-status { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-top: 6px; min-height: 1.1em; }
.import-file-slot.has-file .import-slot-status { color: var(--gold-600); }
.import-results-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 20px; }
.import-results-head { padding: 10px 16px; background: var(--surface-2); font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); }
.import-results-row { display: flex; align-items: baseline; gap: 20px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.import-results-row:last-child { border-bottom: none; }
.import-results-label { font-weight: 600; min-width: 110px; }
.import-results-ok   { color: var(--pos); }
.import-results-upd  { color: var(--info); }
.import-results-skip { color: var(--text-muted); }
.import-results-err  { color: var(--neg); }
.import-error-list { padding: 6px 16px 8px; background: color-mix(in srgb, var(--neg) 6%, transparent); }
.import-error-line { font-size: 11px; color: var(--neg); font-variant-numeric: tabular-nums; line-height: 1.5; }

/* CALENDAR */
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-bottom: 16px; }
.cal-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; }
.cal-legend-item.muted { opacity: 0.35; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cal-grid-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.cal-header-row { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--navy-800); color: var(--ivory); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; text-align: center; font-weight: 600; }
.cal-header-row div { padding: 10px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 110px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 8px; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other-month { background: rgba(0,0,0,0.02); }
.cal-cell.today .cal-day-num { background: var(--gold-500); color: var(--navy-900); border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.cal-day-num { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; line-height: 1; font-variant-numeric: tabular-nums; font-weight: 500; }
.cal-event { border-radius: 4px; padding: 2px 6px; font-size: 11px; line-height: 1.35; cursor: pointer; color: #fff; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 0.15s; }
.cal-event:hover { opacity: 0.85; }
.cal-event.area-Family-Law       { background: #039BE5; }
.cal-event.area-Civil-Litigation  { background: #0B8043; }
.cal-event.area-Wills-Estates     { background: #8E24AA; }
.cal-event.area-Criminal-Defense  { background: #D50000; }
.cal-event.area-General           { background: #F6BF26; color: #333; }
.cal-event.completed              { opacity: 0.45; text-decoration: line-through; }
.gcal-status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gcal-connected-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--pos-100); color: var(--pos); border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.gcal-disconnected-badge { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); color: var(--text-muted); border-radius: 6px; padding: 4px 10px; font-size: 12px; }

/* CALENDAR PAGE LAYOUT */
.cal-page-layout { display: flex; gap: 24px; align-items: flex-start; }
.cal-sidebar { width: 200px; flex-shrink: 0; }
.cal-sidebar-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.cal-sidebar-heading { font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; font-weight: 600; }
.cal-main { flex: 1; min-width: 0; }
.cal-cal-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 13px; color: var(--text); user-select: none; }
.cal-cal-row:hover { color: var(--navy-800); }
.cal-cal-row input[type="checkbox"] { width: 13px; height: 13px; flex-shrink: 0; }
.cal-cal-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cal-event-conflict::before { content: '⚠ '; font-size: 10px; }
.cal-event-needs-link { outline: 2px dashed rgba(255,255,255,0.7); outline-offset: -2px; }
.cal-link-btn { background: rgba(255,255,255,0.25); border: none; border-radius: 3px; cursor: pointer; font-size: 10px; padding: 0 3px; margin-left: 3px; vertical-align: middle; line-height: 1; }
.cal-link-btn:hover { background: rgba(255,255,255,0.5); }
.link-picker-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.link-picker-row:last-child { border-bottom: none; }
input[type="datetime-local"] { font-family: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); background: var(--card); width: 100%; transition: border-color 0.15s, box-shadow 0.15s; outline: none; font-variant-numeric: tabular-nums; }
input[type="datetime-local"]:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-700) 12%, transparent); }

/* THEME TOGGLE */
.theme-toggle { background: none; border: none; cursor: pointer; font-size: 17px; color: var(--text-muted); padding: 6px 8px; border-radius: 6px; line-height: 1; transition: color 0.15s, background 0.15s; }
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }

/* HEADER SEARCH */
.header-search { flex: 1; max-width: 380px; position: relative; }
.header-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-faint); pointer-events: none; }
input.header-search-input { background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius); padding: 8px 12px 8px 36px; font-size: 13px; font-family: inherit; color: var(--text); width: 100%; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; outline: none; }
.header-search-input:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-700) 12%, transparent); background: var(--card); }
.header-search-input::placeholder { color: var(--text-faint); }

/* Global header search dropdown */
.global-search-dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 480px; overflow-y: auto; z-index: 500; }
.gsd-empty { padding: 12px 16px; color: var(--text-muted); font-size: 13px; font-style: italic; }
.gsd-section { padding: 4px 0; }
.gsd-section-title { padding: 6px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border-2); }
.gsd-row { padding: 8px 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--border-2); }
.gsd-row:last-child { border-bottom: none; }
.gsd-row:hover, .gsd-row.gsd-active { background: color-mix(in srgb, var(--gold-500) 10%, transparent); }
.gsd-row-main { font-size: 13px; color: var(--text); font-weight: 500; }
.gsd-row-sub { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* DARK MODE — badge overrides */
[data-theme="dark"] .badge-fl { color: #7ba7e8; background: rgba(123,167,232,0.14); }
[data-theme="dark"] .badge-we { color: #c48ad8; background: rgba(196,138,216,0.14); }
[data-theme="dark"] input[type="checkbox"] { accent-color: var(--gold-500); }

/* LIVE TIMER WIDGET */
.header-timers { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; flex-shrink: 0; }
.btn-timer-start { background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); font-size: 12px; font-family: inherit; padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; transition: border-color 0.15s, color 0.15s, background 0.15s; white-space: nowrap; }
.btn-timer-start:hover { border-color: var(--gold-500); color: var(--gold-600); background: var(--gold-100); }
.timer-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; max-width: 270px; min-width: 0; }
.timer-pill.has-matter { border-color: var(--gold-500); background: var(--gold-100); }
.timer-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.timer-elapsed { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.timer-stop-btn { background: var(--navy-800); border: none; border-radius: 4px; color: var(--gold-500); font-size: 10px; font-weight: 700; padding: 3px 6px; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: opacity 0.15s; }
.timer-stop-btn:hover { opacity: 0.82; }
.timer-discard-btn { background: none; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; padding: 0 2px; line-height: 1; flex-shrink: 0; transition: color 0.15s; }
.timer-discard-btn:hover { color: var(--neg); }

/* Trust / IOLTA */
.trust-bal-pos { color: var(--pos); font-weight: 600; }
.trust-bal-neg { color: var(--neg); font-weight: 600; }
.trust-voided td { opacity: 0.45; text-decoration: line-through; }
.trust-voided td:last-child { text-decoration: none; }

/* Trust Reconciliation */
.recon-tx-list { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; border-top: 1px solid var(--border-2); }
.recon-tx-row { display: grid; grid-template-columns: 18px 78px 1fr auto; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--border-2); cursor: pointer; font-size: 13px; transition: background 0.1s; }
.recon-tx-row:hover { background: var(--surface-2); }
.recon-tx-row input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--navy-800); flex-shrink: 0; }
.recon-tx-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.recon-tx-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recon-tx-amt  { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.recon-locked  { opacity: 0.55; }
.recon-checked { background: color-mix(in srgb, var(--pos) 6%, transparent); }
.recon-summary { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.recon-summary-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border-2); font-size: 14px; }
.recon-summary-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.recon-summary-subtotal { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-size: 14px; font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.recon-summary-subtotal span:last-child { font-variant-numeric: tabular-nums; }
.recon-summary-diff { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-size: 14px; font-weight: 700; border-bottom: 1px solid var(--border-2); }
.recon-summary-diff span:last-child { font-size: 16px; font-variant-numeric: tabular-nums; }
.recon-summary-divider { border-top: 2px solid var(--border); margin: 0; }
.recon-three-way { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; font-size: 13px; }
.recon-three-way span:last-child { font-weight: 700; white-space: nowrap; margin-left: 16px; font-variant-numeric: tabular-nums; }
.diff-ok  { color: var(--pos); }
.diff-bad { color: var(--neg); background: var(--neg-100); }


/* Payments / LawPay
   ⚠ HOSTED FIELD WRAP: dimensions and positioning are load-bearing.
   The iframe is cross-origin (AffiniPay) and needs a plain bordered
   frame — no position/z-index/pseudo-elements/overlays or the
   keystrokes stop reaching the iframe input. Colors + border may
   change, geometry may not. */
.hosted-field-wrap { border: 1px solid var(--border); border-radius: 8px; padding: 0; height: 42px; background: var(--card); overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s; }
.hosted-field-wrap:focus-within { border-color: var(--gold-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-500) 22%, transparent); }
.hosted-field-wrap iframe { border: none !important; width: 100% !important; height: 100% !important; display: block; background: transparent; }
.env-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; padding: 3px 9px; border-radius: 4px; text-transform: uppercase; }
.env-badge-test { background: var(--warn-100); color: var(--warn); }
.env-badge-live { background: var(--neg-100); color: var(--neg); border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent); }
.pay-error { background: var(--neg-100); color: var(--neg); border: 1px solid color-mix(in srgb, var(--neg) 25%, transparent); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.payment-row { display: grid; grid-template-columns: 90px 1fr 90px 80px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.payment-row:last-child { border-bottom: none; }

/* Invoice payment ledger */
.inv-ledger { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.inv-ledger-header { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; font-weight: 600; }
.inv-ledger-body { }
.inv-ledger-row { display: grid; grid-template-columns: 88px minmax(0,1fr) 90px 90px 110px; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.inv-ledger-row:last-child { border-bottom: none; }
.inv-ledger-charge { background: var(--navy-100); font-weight: 600; }
.ll-date { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ll-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ll-label-main { font-weight: 600; color: var(--text); }
.ll-label-detail { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-amount { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.ll-running { font-size: 13px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ll-action { text-align: right; }
.inv-ledger-summary { border-top: 2px solid var(--border); padding: 8px 14px 12px; background: var(--surface-2); }
.inv-ledger-summary-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.inv-ledger-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.inv-balance-due { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; margin-top: 6px; background: var(--gold-100); border: 1px solid color-mix(in srgb, var(--gold-500) 35%, transparent); border-radius: 8px; font-size: 15px; font-weight: 700; }
.inv-balance-due .inv-ledger-num { font-size: 17px; }
.inv-balance-paid { background: var(--pos-100); border-color: color-mix(in srgb, var(--pos) 30%, transparent); color: var(--pos); }
.ledger-status-pill { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 4px; margin-left: 4px; vertical-align: middle; text-transform: uppercase; }
.lsp-auth { background: var(--warn-100); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.lsp-completed { background: var(--pos-100); color: var(--pos); }

/* Print Checks queue */
.pending-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px; margin-left: 6px; background: var(--gold-500); color: var(--navy-900); font-size: 11px; font-weight: 700; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.pc-check-row { display: grid; grid-template-columns: 24px 90px 1fr 1fr 100px 1fr; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.pc-check-row:last-child { border-bottom: none; }
.pc-check-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--navy-800); }
.pc-check-row.pc-stale { background: var(--neg-100); }
.pc-stale-marker { font-size: 11px; color: var(--neg); font-weight: 600; margin-left: 4px; }
.pc-preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.pc-preview-header { padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
.pc-preview-row { display: grid; grid-template-columns: 90px 1fr 110px; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.pc-preview-row:last-child { border-bottom: none; }
.pc-preview-num { font-weight: 700; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.pc-preview-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.pc-cross-month { padding: 10px 14px; background: var(--neg-100); border: 1px solid color-mix(in srgb, var(--neg) 25%, transparent); color: var(--neg); border-radius: var(--radius); margin: 12px 0; font-size: 13px; }
.pending-print-flag { display: inline-block; padding: 1px 6px; margin-left: 4px; font-size: 10px; font-weight: 700; background: var(--gold-100); color: var(--gold-600); border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Firm-owned funds label — distinguishes fee-cushion matters from client money */
.firm-funds-badge { display: inline-block; padding: 2px 8px; margin-left: 6px; font-size: 10px; font-weight: 700; background: var(--gold-100); color: var(--navy-800); border: 1px solid color-mix(in srgb, var(--gold-500) 40%, transparent); border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; vertical-align: middle; }

/* Typeahead / autocomplete — shared component */
.typeahead-wrap { position: relative; }
.typeahead-dropdown { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 250; }
.typeahead-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border-2); }
.typeahead-row:last-child { border-bottom: none; }
.typeahead-row.active { background: var(--gold-100); }
.typeahead-row .ta-val { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typeahead-row .ta-meta { color: var(--text-muted); font-variant-numeric: tabular-nums; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.ta-contact-fill { background: var(--gold-100); border: 1px solid color-mix(in srgb, var(--gold-500) 45%, transparent); border-radius: 8px; padding: 10px 12px; margin-top: 6px; font-size: 13px; color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ta-contact-fill button { padding: 6px 12px; font-size: 12px; border-radius: 6px; border: none; background: var(--navy-800); color: var(--gold-500); cursor: pointer; font-weight: 600; }

/* New Task modal — matter picker chip (shown after a matter is
   selected in the typeahead; hides the search input). min-width:0
   on the picker container so the chip's flex label can truncate
   instead of stretching the form-grid column. */
#nt-matter-picker { min-width: 0; }
#nt-matter-chip { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 10px; background: var(--gold-100); border: 1px solid color-mix(in srgb, var(--gold-500) 40%, transparent); border-radius: 8px; font-size: 13px; color: var(--text); width: 100%; box-sizing: border-box; }
#nt-matter-chip-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.nt-chip-clear { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; padding: 0 6px; line-height: 1; border-radius: 4px; flex-shrink: 0; }
.nt-chip-clear:hover { color: var(--neg); background: var(--card); }

/* ── FullCalendar theming ─────────────────────────────
   Overrides library defaults to match our navy/gold theme. FullCalendar
   inlines its base CSS via the CDN JS bundle so there is no separate
   stylesheet to load. */
#fc-cal { --fc-border-color: var(--border); --fc-page-bg-color: var(--card);
          --fc-neutral-bg-color: var(--surface-2); --fc-list-event-hover-bg-color: var(--surface-2);
          --fc-today-bg-color: color-mix(in srgb, var(--gold-500) 12%, transparent);
          --fc-now-indicator-color: var(--gold-500); font-family: inherit; }
#fc-cal .fc-scrollgrid { border-radius: var(--radius); overflow: hidden; }
#fc-cal .fc-col-header-cell { background: var(--navy-800); color: var(--ivory); }
#fc-cal .fc-col-header-cell-cushion { color: var(--ivory); text-decoration: none; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; padding: 10px 6px; font-weight: 600; }
#fc-cal .fc-daygrid-day-number { color: var(--text); text-decoration: none; font-size: 12px; padding: 4px 6px; font-variant-numeric: tabular-nums; font-weight: 500; }
#fc-cal .fc-day-today .fc-daygrid-day-number { background: var(--gold-500); color: var(--navy-900); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
#fc-cal .fc-event { border-radius: 4px; padding: 1px 4px; font-size: 12px; font-weight: 500; cursor: pointer; border-width: 0; }
#fc-cal .fc-event-time { font-size: 11px; opacity: 0.85; font-variant-numeric: tabular-nums; }
#fc-cal .fc-event-title { font-weight: 500; }
#fc-cal .fc-event.fc-event-conflict::before { content: '⚠ '; }
#fc-cal .fc-event.fc-event-needs-link { outline: 2px dashed var(--gold-500); outline-offset: -1px; }
/* 15-min slots — was 2.4em when slots were 30 min; halving keeps roughly
   the same on-screen density per hour and lets more of the day fit. */
#fc-cal .fc-timegrid-slot { height: 1.2em; }

/* Bounded height for week/day views — set on #fc-cal via a class
   toggle from JS. FullCalendar's height:'parent' then makes the
   internal grid fill this container so the timed slots get their own
   scrollbar instead of pushing the whole page. Month view removes
   the class so it grows naturally with six-row cells. */
#fc-cal.sc-fc-bounded {
  height: calc(100vh - 180px);
  min-height: 420px;
  max-height: 920px;
}
/* And force .fc-view to fill its harness when we're in bounded mode
   — FC 6's runtime mode transition doesn't always re-flip .fc-view
   from position:relative back to absolute-fill, which was collapsing
   the timed grid. */
#fc-cal.sc-fc-bounded .fc-view-harness-active > .fc-view.fc-timegrid {
  position: absolute !important;
  top: 0; left: 0; right: 0; bottom: 0;
  height: auto !important;
}
#fc-cal .fc-timegrid-slot-minor { border-top-style: dotted; opacity: 0.6; }
#fc-cal .fc-timegrid-slot-label-cushion { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
#fc-cal .fc-timegrid-axis-cushion { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
#fc-cal .fc-daygrid-more-link { color: var(--navy-800); font-weight: 600; font-size: 11px; text-decoration: none; }
#fc-cal .fc-daygrid-day.fc-day-other { background: rgba(0,0,0,0.02); }
/* All-day row (top of week/day view) — thicker separator so it feels pinned */
#fc-cal .fc-timegrid-divider { background: var(--border); border-color: var(--border); height: 3px; }
/* All-day area — user-draggable divider. Height is written inline with
   !important from JS to beat FullCalendar's non-important layout writes;
   the handle is absolutely-positioned inside .fc-timegrid and
   repositioned on every FC callback. */
.sc-allday-scroll { overflow-y: auto !important; overflow-x: hidden !important; }
.sc-allday-handle { position: absolute; left: 0; right: 0; height: 10px; margin-top: -5px; cursor: row-resize; z-index: 6; display: flex; align-items: center; justify-content: center; pointer-events: auto; }
.sc-allday-handle:hover .sc-allday-handle-grip,
.sc-allday-handle:active .sc-allday-handle-grip { background: var(--gold-500); width: 56px; }
.sc-allday-handle-grip { width: 44px; height: 4px; border-radius: 3px; background: color-mix(in srgb, var(--text-muted) 45%, transparent); transition: background 0.12s, width 0.12s; pointer-events: none; }
#fc-cal .fc-day-sat, #fc-cal .fc-day-sun { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
/* Neutralize the app's global `tr:hover td` rule inside the calendar —
   it was tinting the whole cell background and painting over the vertical
   day-divider borders. We draw a subtle inset-shadow hover instead,
   which sits inside the border and doesn't obscure the grid lines. */
#fc-cal tr:hover td { background: inherit; }
#fc-cal .fc-daygrid-day:hover { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--gold-500) 5%, transparent); }
#fc-cal .fc-day-today:hover  { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--gold-500) 18%, transparent); }
#fc-cal .fc-timegrid-slot:hover { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--gold-500) 4%, transparent); }

[data-theme="dark"] #fc-cal { --fc-page-bg-color: var(--card); --fc-neutral-bg-color: var(--surface-2); }
[data-theme="dark"] #fc-cal .fc-col-header-cell-cushion,
[data-theme="dark"] #fc-cal .fc-daygrid-day-number { color: var(--text); }

/* Matter Overview → Appointments panel */
.appt-list { display: flex; flex-direction: column; }
.appt-row  { display: grid; grid-template-columns: 90px 70px 1fr auto; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--border-2); cursor: pointer; font-size: 13px; transition: background 0.1s; }
.appt-row:last-child { border-bottom: none; }
.appt-row:hover { background: var(--surface-2); }
.appt-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.appt-time { font-size: 12px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.appt-allday { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.appt-title { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-handled { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 4px; background: var(--pos-100); color: var(--pos); text-transform: uppercase; white-space: nowrap; }

/* Un-actioned past-events prompt */
.unactioned-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; background: var(--card); }
.unactioned-row:last-child { margin-bottom: 0; }
.unactioned-head { margin-bottom: 10px; }
.unactioned-title { font-weight: 600; color: var(--text); font-size: 14px; }
.unactioned-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.unactioned-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.unactioned-note-form { margin-top: 10px; display: flex; gap: 6px; flex-direction: column; }
.unactioned-note-form textarea { width: 100%; resize: vertical; font-family: inherit; }
.unactioned-note-form button { align-self: flex-end; }

/* Conflict Check — role-grouped results */
.conflict-role-group { margin-top: 16px; }
.conflict-role-header { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin: 12px 0 6px; font-weight: 600; }
.conflict-role-count { font-weight: 400; opacity: 0.75; }
.conflict-match-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.conflict-match-name mark { background: var(--gold-100); color: var(--text); padding: 0 3px; border-radius: 3px; font-weight: 700; }
.conflict-match-meta { font-size: 11px; color: var(--text-faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.conflict-match-actions { margin-top: 8px; }
.conflict-role-badge { display: inline-block; padding: 2px 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; border-radius: 4px; white-space: nowrap; }
.conflict-role-client            { background: var(--pos-100); color: var(--pos); border: 1px solid color-mix(in srgb, var(--pos) 30%, transparent); }
.conflict-role-opposing-party    { background: var(--neg-100); color: var(--neg); border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent); }
.conflict-role-contact           { background: var(--navy-100); color: var(--navy-800); border: 1px solid color-mix(in srgb, var(--navy-700) 20%, transparent); }
.conflict-role-authorized-contact{ background: var(--gold-100); color: var(--gold-600); border: 1px solid color-mix(in srgb, var(--gold-500) 40%, transparent); }

/* Contacts list — CLIENT designation pill next to the name. Shows for
   contacts with is_client=1 OR ≥1 CMS matter. */
.contact-client-pill { display: inline-block; margin-left: 8px; padding: 2px 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; border-radius: 4px; background: var(--pos-100); color: var(--pos); border: 1px solid color-mix(in srgb, var(--pos) 30%, transparent); vertical-align: middle; }
