button:focus-visible {
  outline: none;
}

:root {
  /* Brand = deep legal green (replaces the old navy). Used for active nav,
     avatars, hero panels, dark gradients. Green is the accent voice. */
  --primary: #14583a;
  --primary-container: #0c3825;
  /* Gold = prestige / CTA only (use sparingly). */
  --secondary: #b58e3a;
  --secondary-container: #f5e9cc;
  --on-secondary-container: #7a5c0d;
  /* Paper → container → white. Sections separate by tonal shift, not borders. */
  --surface: #f9f9f7;
  --surface-low: #ecebe4;
  --surface-lowest: #ffffff;
  --surface-high: #e9e8e2;
  --surface-highest: #e2e1d9;
  --tertiary: #171716;
  --on-primary: #ffffff;
  --danger: #a13434;
  --ghost: rgba(26, 28, 27, 0.15);
  --ghost-soft: rgba(26, 28, 27, 0.08);
  --ink-60: rgba(23, 23, 22, 0.60);
  --ink-50: rgba(23, 23, 22, 0.50);
  --ink-40: rgba(23, 23, 22, 0.40);
  --ink-30: rgba(23, 23, 22, 0.30);
  /* Deep green gradient for brand surfaces (sidebar mark, avatars, hero). */
  --gradient-primary: linear-gradient(135deg, #14583a, #06291b);
  /* Gold gradient reserved for primary CTA buttons. */
  --gradient-gold: linear-gradient(135deg, #d8b65f, #b58e3a);
  --on-gold: #1a1205;
  --green-selection: rgba(46, 125, 84, 0.18);
  --shadow-float: 0 8px 64px rgba(26, 28, 27, 0.05);
  --shadow-deep: 0 24px 64px rgba(6, 41, 27, 0.12);
  --serif: 'Newsreader', 'Times New Roman', serif;
  --sans: 'Manrope', -apple-system, sans-serif;
  --mono: 'Inter', sans-serif;
  --code: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }
@keyframes spin { to { transform: rotate(360deg); } }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface);
  color: var(--tertiary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* Typography helpers */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.label { font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-50); }
.overline { font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-40); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(23,23,22,0.12); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(23,23,22,0.22); }

/* App shell */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  background: var(--surface);
}
.app-shell.collapsed { grid-template-columns: 72px 1fr; }

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(249, 249, 247, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  z-index: 20;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
}
.brand-mark {
  width: 30px; height: 30px;
  background: var(--gradient-primary);
  border-radius: 7px;
  display: grid; place-items: center;
  color: white;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}
.brand-text {
  display: flex; flex-direction: column;
  line-height: 1.1;
}
.brand-name { font-family: var(--serif); font-size: 17px; font-weight: 500; color: var(--tertiary); letter-spacing: 0.01em; }
.brand-sub { font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-40); margin-top: 2px; }

.nav-group { display: flex; flex-direction: column; margin-bottom: 18px; }
.nav-group-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-40);
  padding: 0 12px 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--tertiary);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  position: relative;
}
.nav-item:hover { background: var(--surface-high); }
.nav-item.active {
  background: var(--primary);
  color: var(--on-primary);
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-badge {
  margin-left: auto;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  padding: 2px 7px;
  border-radius: 999px;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.16); color: white; }

.collapsed .nav-item { justify-content: center; padding: 10px; }
.collapsed .nav-text, .collapsed .nav-badge, .collapsed .nav-group-label, .collapsed .brand-text { display: none; }
.collapsed .sidebar-brand { justify-content: center; padding: 6px 0 22px; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-lowest);
  border-radius: 10px;
  flex: 1;
}
.avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--gradient-primary);
  color: white;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-meta { font-family: 'Inter', sans-serif; font-size: 10px; color: var(--ink-50); text-transform: uppercase; letter-spacing: 0.06em; }

.collapse-btn {
  background: transparent;
  border: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--ink-50);
  display: grid; place-items: center;
}
.collapse-btn:hover { background: var(--surface-high); color: var(--tertiary); }

/* Main content */
.main {
  min-width: 0;
  background: var(--surface);
  padding: 0;
  overflow-x: hidden;
}
.topbar {
  position: sticky; top: 0; z-index: 15;
  background: rgba(249, 249, 247, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 36px;
}
.topbar-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-high);
  padding: 9px 14px;
  border-radius: 8px;
  color: var(--ink-50);
}
.topbar-search input { background: transparent; border: none; outline: none; flex: 1; font-size: 13px; color: var(--tertiary); }
.topbar-search kbd {
  font-family: var(--code);
  font-size: 10px;
  background: var(--surface-lowest);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-50);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  background: transparent; border: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--tertiary);
  position: relative;
}
.icon-btn:hover { background: var(--surface-high); }
.icon-btn .dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  background: var(--secondary);
  border-radius: 999px;
  border: 2px solid var(--surface);
}

.page {
  padding: 32px 48px 80px;
  max-width: 1440px;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
}
.page-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--tertiary);
  margin: 0;
}
.page-sub {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-60);
  margin-top: 6px;
}
.page-actions { display: flex; gap: 10px; align-items: center; }

/* Buttons */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 80ms ease, background 120ms ease, opacity 120ms ease;
  letter-spacing: 0.01em;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--gradient-gold);
  color: var(--on-gold);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-secondary {
  background: transparent;
  color: var(--tertiary);
}
.btn-secondary:hover { background: var(--surface-high); }
.btn-ghost-light {
  background: var(--surface-lowest);
  color: var(--tertiary);
}
.btn-ghost-light:hover { background: var(--surface-high); }
.btn-tertiary {
  background: transparent;
  border: none;
  color: var(--secondary);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 6px 0;
  font-family: var(--sans);
  font-weight: 600;
}
.btn-tertiary:hover { color: var(--on-secondary-container); }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.chip-gold { background: var(--secondary-container); color: var(--on-secondary-container); }
.chip-green { background: #e3eedd; color: #3d5b29; }
.chip-amber { background: #f5e6c4; color: #8a5a14; }
.chip-red { background: #f3dada; color: #823232; }
.chip-neutral { background: var(--surface-high); color: var(--ink-60); }
.chip-navy { background: rgba(4, 21, 52, 0.08); color: var(--primary); }

/* Cards */
.card {
  background: var(--surface-lowest);
  border-radius: 12px;
  padding: 20px;
}
.card-elevated {
  background: var(--surface-lowest);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-float);
}
.card-low { background: var(--surface-low); border-radius: 12px; padding: 20px; }

/* Metric cards */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .metric-grid { grid-template-columns: 1fr; } }
/* Dashboard has 6 metric cards: keep the rows even (3+3, or one row of 6 when
   wide) instead of a ragged 4+2, and let the cards shrink-to-fit. */
@media (min-width: 1101px) and (max-width: 1439px) {
  .dashboard-page .metric-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1440px) {
  .dashboard-page .metric-grid { grid-template-columns: repeat(6, 1fr); gap: 12px; }
  .dashboard-page .metric-label { font-size: 10px; letter-spacing: 0.05em; white-space: nowrap; }
}
.metric {
  background: var(--surface-lowest);
  border-radius: 12px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.metric-label { font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-50); }
.metric-value {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--tertiary);
}
.metric-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-top: auto;
  background: transparent; border: none; padding: 0; text-align: left;
}
.metric-trend { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-50); }

/* Hero next hearing */
.hero-hearing {
  background: var(--gradient-primary);
  color: var(--on-primary);
  border-radius: 16px;
  padding: 32px 36px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 36px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.hero-hearing::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px circle at 90% 0%, rgba(184,149,42,0.18), transparent 60%);
  pointer-events: none;
}
.hero-date {
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--serif);
  border-right: 1px solid rgba(255,255,255,0.12);
  padding-right: 36px;
}
.hero-date .month { font-family: 'Inter', sans-serif; font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em; opacity: 0.7; }
.hero-date .day { font-size: 56px; font-weight: 400; line-height: 1; margin-top: 4px; }
.hero-date .year { font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: 0.1em; opacity: 0.6; margin-top: 4px; }
.hero-info .label-line { font-family: 'Inter', sans-serif; font-size: 10px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--secondary); margin-bottom: 8px; }
.hero-info h3 { font-family: var(--serif); font-size: 26px; font-weight: 400; margin: 0 0 6px; line-height: 1.2; }
.hero-info .meta { font-size: 13px; opacity: 0.75; }
.countdown-badge {
  background: rgba(184,149,42,0.18);
  color: #f0d28a;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-flex; gap: 6px; align-items: center;
  margin-top: 10px;
  letter-spacing: 0.04em;
}
.hero-actions { display: flex; flex-direction: column; gap: 8px; }
.hero-actions .btn { background: rgba(255,255,255,0.1); color: white; }
.hero-actions .btn:hover { background: rgba(255,255,255,0.18); }
.hero-actions .btn.gold { background: var(--gradient-gold); color: var(--on-gold); font-weight: 600; }
.hero-actions .btn.gold:hover { filter: brightness(1.04); }

/* Section */
.section { margin-bottom: 36px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 18px;
}
.section-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--tertiary);
  letter-spacing: -0.005em;
  margin: 0;
}

/* Two column dashboard area */
.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* Activity feed */
.activity {
  display: flex; flex-direction: column;
  gap: 0;
}
.activity-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  padding: 14px 4px;
  align-items: flex-start;
}
.activity-icon {
  width: 32px; height: 32px;
  background: var(--surface-low);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ink-60);
}
.activity-text { font-size: 13px; color: var(--tertiary); line-height: 1.5; }
.activity-text .actor { font-weight: 600; }
.activity-text .case-ref { color: var(--secondary); font-weight: 500; cursor: pointer; }
.activity-time { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-40); white-space: nowrap; padding-top: 3px; }
/* Recent-activity card scrolls inside its own box (height set by the
   viewport-locked dashboard layout below) so the whole page stays put. */
/* Clickable document row (Documents page) — underline the name on hover. */
.doc-row:hover .doc-link-name { text-decoration: underline; text-underline-offset: 2px; }

/* In-app document viewer modal */
.doc-viewer {
  background: var(--surface);
  border-radius: 16px;
  width: 94vw; max-width: 1040px;
  height: 88vh; max-height: 940px;
  padding: 18px;
  box-shadow: var(--shadow-deep);
  animation: slideUp 240ms ease;
  display: flex; flex-direction: column;
}
.doc-viewer-body { flex: 1 1 auto; min-height: 0; background: var(--surface-low); border-radius: 8px; overflow: hidden; }
.doc-viewer-frame { width: 100%; height: 100%; border: 0; }
.doc-viewer-img { width: 100%; height: 100%; display: grid; place-items: center; overflow: auto; padding: 12px; }
.doc-viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.doc-viewer-empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--ink-50); font-size: 13.5px; padding: 24px; line-height: 1.6; }
/* Rendered Word (.docx) content — a paged, scrollable document surface. */
.doc-viewer-doc { height: 100%; overflow-y: auto; background: #fff; padding: 44px 56px; color: #1a1a1a; }
.doc-viewer-doc > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.doc-viewer-doc p { margin: 0 0 11px; line-height: 1.65; font-size: 14px; }
.doc-viewer-doc h1, .doc-viewer-doc h2, .doc-viewer-doc h3 { font-family: var(--serif); font-weight: 500; margin: 20px auto 10px; line-height: 1.25; }
.doc-viewer-doc ul, .doc-viewer-doc ol { margin: 0 auto 11px; padding-left: 26px; }
.doc-viewer-doc li { margin-bottom: 5px; line-height: 1.6; }
.doc-viewer-doc table { border-collapse: collapse; width: 100%; margin: 0 auto 14px; }
.doc-viewer-doc td, .doc-viewer-doc th { border: 1px solid #ddd; padding: 6px 10px; font-size: 13px; }
.doc-viewer-doc img { max-width: 100%; height: auto; }
@media (max-width: 600px) { .doc-viewer-doc { padding: 24px 18px; } }
@media (max-width: 600px) { .doc-viewer { width: 100%; height: 92vh; padding: 14px; } }

.activity-card { overflow-y: auto; }
.activity-card::-webkit-scrollbar { width: 8px; }
.activity-card::-webkit-scrollbar-thumb { background: var(--surface-highest); border-radius: 8px; }

/* Desktop: viewport-locked shell — the sidebar and main content scroll
   independently and the topbar stays pinned, so a page can feel "solid". */
@media (min-width: 1101px) {
  .app-shell { height: 100vh; overflow: hidden; }
  .main { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  .main > .topbar { flex: 0 0 auto; }
  .main > .page { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

  /* Dashboard fits the viewport; only the activity feed scrolls (in its box).
     Tighten the vertical rhythm (scoped to the dashboard) so it fits laptop
     heights without a scroll. */
  .page.dashboard-page { display: flex; flex-direction: column; padding-top: 20px; padding-bottom: 18px; }
  .dashboard-page .metric-grid { margin-bottom: 12px; }
  .dashboard-page .metric { padding: 13px 15px; gap: 6px; }
  .dashboard-page .metric-value { font-size: 30px; }
  .dashboard-page .section { margin-bottom: 16px; }
  .dashboard-page .section-head { margin-bottom: 10px; }
  .dashboard-page .section-title { font-size: 19px; }
  .dashboard-page .casetype, .dashboard-page .quick-action { padding: 11px 14px; }
  .dashboard-page .dash-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .dashboard-page .dash-grid > div:first-child { display: flex; flex-direction: column; min-height: 0; }
  .dashboard-page .dash-grid > div:first-child > .section { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin-bottom: 0; }
  .dashboard-page .dash-grid > div:first-child > .section > .card { flex: 1 1 auto; min-height: 0; }
}

/* Case type chips grid */
.casetype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.casetype {
  background: var(--surface-lowest);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 120ms ease;
  text-align: left;
  border: none;
}
.casetype:hover { background: var(--surface-high); }
.casetype .ct-name { font-size: 13px; font-weight: 600; }
.casetype .ct-count { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-50); }

/* Cases table */
.filter-bar {
  background: var(--surface-low);
  padding: 16px 20px;
  border-radius: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}
.filter-bar .input-search {
  flex: 1; min-width: 220px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-lowest);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink-50);
}
.filter-bar .input-search input { background: transparent; border: none; outline: none; flex: 1; font-size: 13px; color: var(--tertiary); }
.dropdown-btn {
  background: var(--surface-lowest);
  color: var(--tertiary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.dropdown-btn:hover { background: var(--surface-high); }
.dropdown-btn .caret { color: var(--ink-40); }

.cases-table {
  background: var(--surface-lowest);
  border-radius: 14px;
  overflow: hidden;
}
.cases-table-head, .cases-row {
  display: grid;
  grid-template-columns: 2.4fr 1.4fr 1.2fr 1fr 1fr 1fr 1.1fr 80px;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
}
.cases-table-head {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-40);
  padding-top: 18px;
  padding-bottom: 14px;
  background: var(--surface-low);
}
.cases-row {
  padding-top: 18px;
  padding-bottom: 18px;
  cursor: pointer;
  transition: background 120ms ease;
}
.cases-row:hover { background: var(--surface-high); }
.cases-row + .cases-row { /* no border, just spacing via padding */ }
.case-title-cell .title { font-family: var(--serif); font-size: 16px; font-weight: 500; line-height: 1.25; color: var(--tertiary); letter-spacing: 0.005em; }
.case-title-cell .num { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-50); margin-top: 3px; letter-spacing: 0.04em; }
.row-cell { font-size: 13px; color: var(--tertiary); }
.row-cell .sub { font-size: 11px; color: var(--ink-50); margin-top: 2px; font-family: 'Inter', sans-serif; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions button {
  background: transparent;
  border: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--ink-50);
  display: grid; place-items: center;
}
.row-actions button:hover { background: var(--surface-low); color: var(--tertiary); }

/* Wizard */
.wizard-shell {
  background: var(--surface);
  min-height: 100vh;
}
.wizard-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(249, 249, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 18px 48px 0;
}
.wizard-breadcrumb {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink-50);
  display: flex; gap: 8px; align-items: center;
  margin: 0 auto 10px;
  max-width: 1100px;
}
.wizard-breadcrumb a { color: var(--ink-50); cursor: pointer; }
.wizard-breadcrumb a:hover { color: var(--tertiary); }
.wizard-breadcrumb .here { color: var(--tertiary); font-weight: 500; }
.wizard-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1100px;
}
.wizard-title { font-family: var(--serif); font-size: 28px; font-weight: 400; margin: 0; }
.wizard-step-meta { font-family: 'Inter', sans-serif; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-50); }
.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 18px;
  max-width: 1100px;
  margin: 0 auto;
}
.stepper-item {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px;
  background: var(--surface-low);
  border-radius: 10px;
  position: relative;
}
.stepper-item.active { background: var(--surface-lowest); }
.stepper-item.done { background: var(--surface-low); }
.stepper-item .step-num {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-40);
}
.stepper-item.active .step-num { color: var(--secondary); }
.stepper-item.done .step-num { color: var(--ink-50); }
.stepper-item .step-label {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-50);
  display: flex; align-items: center; gap: 8px;
}
.stepper-item.active .step-label { color: var(--tertiary); }
.stepper-item.done .step-label { color: var(--tertiary); }
.stepper-item .step-bar {
  height: 2px;
  background: var(--ghost-soft);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.stepper-item.active .step-bar { background: var(--surface-high); }
.stepper-item.active .step-bar::after {
  content: ''; display: block; height: 100%; width: 50%;
  background: var(--gradient-primary);
}
.stepper-item.done .step-bar::after {
  content: ''; display: block; height: 100%; width: 100%;
  background: var(--secondary);
}

.wizard-body {
  padding: 32px 0 120px;
  max-width: 1100px;
  margin: 0 auto;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 22px;
  margin-bottom: 22px;
}
.field-grid.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tertiary);
  display: flex; gap: 6px; align-items: center;
}
.field-label .req { color: var(--secondary); }
.field-label .opt { color: var(--ink-40); font-weight: 500; }

.input, .select, .textarea {
  background: var(--surface-high);
  border: none;
  outline: none;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--sans);
  color: var(--tertiary);
  transition: background 120ms ease, box-shadow 120ms ease;
  width: 100%;
  border-left: 2px solid transparent;
}
.input:focus, .select:focus, .textarea:focus {
  background: var(--surface-lowest);
  border-left: 2px solid var(--secondary);
  box-shadow: 0 0 0 1px var(--ghost-soft);
}
.input.disabled, .select.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.input.error, .select.error { box-shadow: 0 0 0 2px rgba(160, 50, 50, 0.4); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field-help { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-50); }
.field-error { font-family: 'Inter', sans-serif; font-size: 11px; color: #a13434; font-weight: 500; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23171716' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.chip-input {
  background: var(--surface-high);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 44px;
  border-left: 2px solid transparent;
}
.chip-input:focus-within { background: var(--surface-lowest); border-left: 2px solid var(--secondary); box-shadow: 0 0 0 1px var(--ghost-soft); }
.chip-input input { background: transparent; border: none; outline: none; flex: 1; min-width: 100px; font-size: 13px; padding: 4px; }
.chip-input .chip-removable {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
}
.chip-input .chip-removable button { background: rgba(255,255,255,0.18); border: none; color: white; width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; cursor: pointer; }

/* Wizard footer */
.wizard-footer {
  position: sticky; bottom: 0; z-index: 30;
  background: rgba(249, 249, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 16px 48px;
}
.wizard-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.wizard-section-card {
  background: var(--surface-lowest);
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 18px;
}
.wizard-section-card h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.005em;
}
.wizard-section-card .h-sub { font-size: 13px; color: var(--ink-60); margin-bottom: 22px; }

.banner {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 18px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-low);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 9px 16px;
  border-radius: 7px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-60);
}
.tab-btn:hover { color: var(--tertiary); }
.tab-btn.active { background: var(--surface-lowest); color: var(--tertiary); font-weight: 600; }

.tabs-primary {
  display: flex;
  gap: 4px;
}
.tabs-primary .tab-btn { background: transparent; padding: 11px 18px; border-radius: 8px; }
.tabs-primary .tab-btn:hover { background: var(--surface-low); }
.tabs-primary .tab-btn.active { background: var(--primary); color: white; }

/* Toggle */
.toggle {
  width: 38px; height: 22px;
  background: var(--surface-highest);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 160ms ease;
  border: none;
  flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 999px;
  transition: transform 160ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--primary); }
.toggle.on::after { transform: translateX(16px); }

/* Vakalatnama specific */
.vak-status-track {
  background: var(--surface-low);
  border-radius: 14px;
  padding: 22px 26px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  position: relative;
  margin-bottom: 22px;
}
.vak-status-step {
  display: flex; flex-direction: column;
  gap: 10px;
}
.vak-status-step .dot {
  width: 12px; height: 12px;
  border-radius: 999px;
  background: var(--surface-highest);
  margin-top: 4px;
}
.vak-status-step.done .dot { background: var(--secondary); }
.vak-status-step.active .dot { background: var(--primary); box-shadow: 0 0 0 4px rgba(4,21,52,0.12); }
.vak-status-step .stage-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-50);
}
.vak-status-step .stage-name {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-50);
}
.vak-status-step.done .stage-label, .vak-status-step.done .stage-name { color: var(--tertiary); }
.vak-status-step.active .stage-name { color: var(--primary); }

.vak-document {
  background: var(--surface-lowest);
  border-radius: 16px;
  padding: 56px 64px;
  font-family: var(--serif);
  color: var(--tertiary);
  position: relative;
}
.vak-document::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0px, transparent 31px, rgba(23,23,22,0.04) 31px, rgba(23,23,22,0.04) 32px);
  pointer-events: none;
  border-radius: 16px;
}
.vak-document h2 {
  font-family: var(--serif);
  font-size: 26px;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.vak-document .subhead { text-align: center; font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-50); margin-bottom: 36px; }
.vak-document p { font-size: 15px; line-height: 1.85; margin: 14px 0; }
.vak-document .underline { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--ink-30); }
.vak-document .signoff {
  display: grid; grid-template-columns: 1fr 1fr; gap: 60px;
  margin-top: 70px;
}
.vak-document .signoff .slot {
  border-top: 1px solid var(--ghost);
  padding-top: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-50);
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 21, 52, 0.32);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid; place-items: center;
  padding: 40px;
  animation: fadeIn 200ms ease;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-deep);
  animation: slideUp 240ms ease;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Fixed header — holds the close (x); never scrolls with the body */
.modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 32px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-low);
}
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 32px;
}
/* Fixed footer — actions stay put while the body scrolls */
.modal-foot {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 32px 24px;
  background: var(--surface);
  border-top: 1px solid var(--surface-low);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Calendar */
.calendar-grid {
  background: var(--surface-lowest);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dayhead {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-40);
  text-align: center;
  padding: 12px 0 8px;
}
.cal-cell {
  background: var(--surface);
  border-radius: 8px;
  min-height: 96px;
  padding: 8px;
  display: flex; flex-direction: column;
  gap: 4px;
  position: relative;
}
.cal-cell.muted { background: transparent; }
.cal-cell.muted .cal-num { color: var(--ink-30); }
.cal-cell.today { background: var(--primary); color: white; }
.cal-cell.today .cal-num { color: white; }
.cal-num { font-family: var(--serif); font-size: 16px; font-weight: 500; }
.cal-event {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 500;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-event.gold { background: var(--secondary-container); color: var(--on-secondary-container); }
.cal-event.navy { background: rgba(4,21,52,0.85); color: white; }
.cal-event.green { background: #e3eedd; color: #3d5b29; }
.cal-event.amber { background: #f5e6c4; color: #8a5a14; }
.cal-event.red { background: #f3dada; color: #823232; }
.cal-event.neutral { background: var(--surface-high); color: var(--ink-60); }
.cal-cell.today .cal-event.gold { background: var(--secondary); color: var(--primary); }

/* Notifications */
.notif-group { margin-bottom: 24px; }
.notif-group-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-40);
  padding: 0 0 12px;
}
.notif {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  align-items: flex-start;
}
.notif.unread { background: var(--surface-low); }
.notif.read { background: transparent; }
.notif-icon {
  width: 32px; height: 32px;
  background: var(--surface-lowest);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--primary);
}
.notif-text { font-size: 13px; line-height: 1.5; }
.notif-text .actor { font-weight: 600; }
.notif-text .case-ref { color: var(--secondary); font-weight: 500; }
.notif-time { font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-40); white-space: nowrap; }

/* Empty */
.empty {
  display: flex; flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 32px;
  gap: 14px;
}
.empty-art {
  width: 80px; height: 80px;
  border-radius: 16px;
  background: var(--surface-low);
  display: grid; place-items: center;
  color: var(--ink-40);
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 400;
}
.empty h3 { font-family: var(--serif); font-size: 22px; font-weight: 500; margin: 0; }
.empty p { font-size: 13px; color: var(--ink-60); margin: 0; max-width: 360px; }

/* Onboarding */
.onboard-shell {
  position: fixed; inset: 0;
  background: var(--surface);
  z-index: 200;
  display: grid;
  grid-template-columns: 360px 1fr;
}
.onboard-side {
  background: var(--gradient-primary);
  color: white;
  padding: 48px 36px;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
.onboard-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(500px circle at 100% 100%, rgba(184,149,42,0.16), transparent 60%);
  pointer-events: none;
}
.onboard-side .brand-stack { font-family: var(--serif); font-size: 22px; font-weight: 500; }
.onboard-side .brand-stack-sub { font-family: 'Inter', sans-serif; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.6; }
.onboard-steps-list { margin-top: 60px; display: flex; flex-direction: column; gap: 22px; }
.onboard-step-item { display: grid; grid-template-columns: 28px 1fr; gap: 14px; align-items: flex-start; }
.onboard-step-item .num {
  font-family: var(--serif);
  font-size: 18px;
  width: 28px; height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  display: grid; place-items: center;
  color: rgba(255,255,255,0.6);
}
.onboard-step-item.active .num { background: var(--secondary); color: var(--primary); }
.onboard-step-item.done .num { background: rgba(184,149,42,0.25); color: var(--secondary); }
.onboard-step-item .step-name { font-family: var(--sans); font-size: 14px; font-weight: 600; opacity: 0.9; }
.onboard-step-item .step-desc { font-family: var(--sans); font-size: 12px; opacity: 0.55; }
.onboard-side .footer-note { margin-top: auto; font-family: 'Inter', sans-serif; font-size: 11px; opacity: 0.5; line-height: 1.6; }

.onboard-main {
  padding: 48px 64px;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.onboard-card {
  max-width: 720px;
}
.onboard-h {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
}
.onboard-sub { font-size: 14px; color: var(--ink-60); margin-bottom: 36px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.feature-card {
  background: var(--surface-lowest);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.feature-card .ic {
  width: 36px; height: 36px;
  background: var(--surface-low);
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--primary);
  flex-shrink: 0;
}
.feature-card h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.feature-card p { margin: 0; font-size: 12px; color: var(--ink-60); line-height: 1.5; }

.onboard-footer {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: auto;
  padding-top: 32px;
}

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(4,21,52,0.28);
  backdrop-filter: blur(4px);
  z-index: 90;
  animation: fadeIn 200ms ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 92vw);
  background: var(--surface);
  z-index: 100;
  overflow-y: auto;
  box-shadow: var(--shadow-deep);
  animation: slideIn 280ms ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Asymmetric editorial moment */
.editorial-mark {
  font-family: var(--serif);
  font-style: italic;
  color: var(--secondary);
}

/* Bottom nav (mobile) — built but layout is desktop-first for prototype */

/* Helpers */
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--ink-50); }
.gold-text { color: var(--secondary); }
.serif-num { font-family: var(--serif); font-weight: 500; }

/* Quick action tile — same grid/tile treatment as the case-type blocks,
   icon and label side by side on a single compact line. */
.quick-action {
  background: var(--surface-lowest);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 120ms ease;
}
.quick-action:hover { background: var(--surface-high); }
.quick-action .ic {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border-radius: 7px;
  background: var(--surface-low);
  display: grid; place-items: center;
  color: var(--primary);
}
/* Match the case-type tile text exactly (override the global uppercase .label). */
.quick-action .label { font-size: 13px; font-weight: 600; line-height: 1.25; text-transform: none; letter-spacing: normal; color: var(--tertiary); }
.quick-action .arrow { display: none; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 16px 1fr; gap: 16px; padding: 8px 0 18px; position: relative; }
.tl-item .tl-mark {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--surface-highest);
  margin-top: 6px;
  position: relative;
  z-index: 1;
}
.tl-item.gold .tl-mark { background: var(--secondary); }
.tl-item.navy .tl-mark { background: var(--primary); }
.tl-item::before {
  content: ''; position: absolute;
  left: 4px; top: 16px; bottom: 0;
  width: 2px;
  background: var(--surface-low);
}
.tl-item:last-child::before { display: none; }
.tl-content { font-size: 13px; line-height: 1.5; }
.tl-content .when { font-family: 'Inter', sans-serif; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-50); margin-bottom: 4px; }

/* Responsive */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 72px 1fr; }
  .nav-text, .brand-text, .nav-group-label, .nav-badge { display: none; }
  .sidebar-brand { justify-content: center; padding: 6px 0 22px; }
  .nav-item { justify-content: center; padding: 10px; }
  .page { padding: 24px 24px 80px; }
  .topbar { padding: 12px 24px; }
  .stepper { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .onboard-shell { grid-template-columns: 1fr; }
  .onboard-side { display: none; }
  /* Single-pane onboarding: smaller symmetric padding, centred content column */
  .onboard-main { padding: 36px 24px; align-items: center; }
  .onboard-card { max-width: 620px; width: 100%; margin: 0 auto; }
}

/* ───────────────────────────────────────────────────────────
   Mobile / app-like experience
   ─────────────────────────────────────────────────────────── */

/* Bottom tab bar + mobile menu button are desktop-hidden by default */
.mobile-tabbar { display: none; }
.mobile-menu-btn { display: none; }
.mobile-overlay { display: none; }

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }

  /* Single-column shell; sidebar becomes a slide-in drawer */
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: 84vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 60; box-shadow: var(--shadow-deep);
    padding: 20px 14px; background: var(--surface);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .mobile-overlay { display: block; position: fixed; inset: 0; background: rgba(4,21,52,0.45); z-index: 55; }

  /* Re-show full labels inside the drawer (override the tablet icon-rail rules) */
  .nav-text { display: inline; }
  .brand-text { display: flex; }
  .nav-group-label { display: block; }
  .nav-badge { display: inline-block; }
  .nav-item { justify-content: flex-start; padding: 11px 12px; }
  .sidebar-brand { justify-content: flex-start; padding: 6px 8px 20px; }

  .main { min-width: 0; }

  /* Topbar: hamburger + hide the big search */
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar-search { display: none; }
  .mobile-menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border: none; background: transparent;
    color: var(--tertiary); border-radius: 8px; cursor: pointer;
  }

  /* Page padding leaves room for the bottom tab bar */
  .page { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .page-title { font-size: 25px; }

  /* Stack class-based grids */
  .dash-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-wrap: wrap; }
  .filter-bar .input-search { width: 100%; }

  /* Any 2-column page layout tagged .page-split collapses to one column */
  .page-split { grid-template-columns: 1fr !important; }

  /* Tables scroll horizontally instead of crushing */
  .cases-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cases-table-head, .cases-row { min-width: 640px; }

  /* Wizard fits the screen */
  .wizard-body { padding-left: 14px; padding-right: 14px; }
  .stepper { grid-template-columns: 1fr; }

  /* Onboarding: phone-sized padding/type, cards never overflow the viewport */
  .onboard-main { padding: 24px 16px calc(28px + env(safe-area-inset-bottom)); }
  .onboard-h { font-size: 30px; }
  .onboard-sub { margin-bottom: 24px; }
  .feature-grid { grid-template-columns: 1fr; gap: 10px; }

  /* Modals use the full width */
  .modal { width: 94vw; max-width: 94vw !important; }

  /* Bottom tab bar */
  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(249,249,247,0.96); backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -1px 16px rgba(4,21,52,0.06);
  }
  .mobile-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    border: none; background: transparent; cursor: pointer;
    color: var(--ink-50); padding: 6px 0; font-family: 'Inter', sans-serif;
    font-size: 10px; font-weight: 500;
  }
  .mobile-tab.active { color: var(--primary); }
  .mobile-tab.active .mobile-tab-ico { color: var(--secondary); }
}

/* Phones: keep metrics as a compact 2x2 grid (not full-width stacked) */
@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .grid-3 { grid-template-columns: 1fr 1fr !important; }
}

/* ───────────────────────────────────────────────────────────
   Mobile refinement — compact, app-like sizing
   ─────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* Cards & sections tighter */
  .card { padding: 15px; border-radius: 12px; }
  .card-elevated { padding: 15px; border-radius: 14px; }
  .card-low { padding: 13px; }
  .section { margin-bottom: 22px; }
  .section-head { margin-bottom: 12px; }
  .section-title { font-size: 17px; }
  .page-title { font-size: 22px; }
  .page-sub { font-size: 12px; }

  /* Metrics: compact 2-up */
  .metric-grid { gap: 10px; margin-bottom: 16px; }
  .metric { padding: 13px; gap: 5px; border-radius: 12px; }
  .metric-value { font-size: 26px; }
  .metric-label { font-size: 9.5px; letter-spacing: 0.06em; }
  .metric-trend { font-size: 10px; }
  .metric-link { font-size: 11px; }

  /* Hero next-hearing stacks */
  .hero-hearing { grid-template-columns: 1fr; gap: 14px; padding: 18px; border-radius: 14px; }
  .hero-date { flex-direction: row; gap: 10px; align-items: baseline; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.12); padding: 0 0 12px; }
  .hero-date .day { font-size: 30px; margin-top: 0; }
  .hero-info h3 { font-size: 19px; }
  .hero-actions { flex-direction: row; flex-wrap: wrap; }
  .hero-actions .btn, .hero-actions .btn-primary { flex: 1; }

  /* Primary tabs scroll horizontally */
  .tabs-primary { overflow-x: auto; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; }
  .tabs-primary .tab-btn { padding: 8px 12px; font-size: 12.5px; white-space: nowrap; }

  /* Bottom tab bar slimmer */
  .mobile-tabbar { padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
  .mobile-tab { font-size: 9px; padding: 5px 0; gap: 2px; }

  /* Month calendar: compact grid, events as colour bars (no text) */
  .calendar-grid { gap: 3px; padding: 5px; border-radius: 12px; }
  .cal-dayhead { padding: 6px 0 4px; font-size: 9px; letter-spacing: 0.05em; }
  .month-view .cal-cell { min-height: 46px; padding: 4px 3px; border-radius: 6px; gap: 3px; }
  .month-view .cal-num { font-size: 12px; }
  .month-view .cal-event { font-size: 0 !important; height: 5px; min-height: 5px; padding: 0 !important; border-radius: 3px; line-height: 0; }

  /* Week calendar: keep text but cap height */
  .week-view .cal-cell { min-height: 120px !important; }
  .week-view .cal-event { font-size: 9px; }
}

/* Week view: each day = self-contained column (header + cell). Desktop unchanged. */
.week-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* ───────────────────────────────────────────────────────────
   Mobile: tables → stacked cards, week view → vertical agenda
   (everything scoped to phones; desktop untouched)
   ─────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* Tables become stacked cards */
  .cases-table { overflow-x: visible; }
  .cases-table-head { display: none !important; }
  .cases-row {
    display: flex !important; flex-direction: column; align-items: stretch;
    gap: 7px; min-width: 0 !important;
    background: var(--surface-lowest); border-radius: 12px;
    padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-float);
  }
  .cases-row:hover { background: var(--surface-lowest); }
  .cases-row > div { min-width: 0; }
  .cases-row .case-title-cell .title { font-size: 15px; }
  .cases-row .row-cell { font-size: 13px; color: var(--ink-60); }
  .cases-row .row-actions { justify-content: flex-end; gap: 16px; margin-top: 2px; }

  /* Week view: vertical day-by-day agenda */
  .week-view { grid-template-columns: 1fr !important; gap: 8px !important; padding: 0 !important; background: transparent !important; }
  .week-view .week-col { flex-direction: row; gap: 10px; align-items: flex-start; background: var(--surface-lowest); border-radius: 10px; padding: 8px 10px; box-shadow: var(--shadow-float); }
  .week-view .cal-dayhead { width: 50px; flex-shrink: 0; text-align: center; padding: 6px 0; }
  .week-view .cal-dayhead.today { color: var(--secondary); font-weight: 700; }
  .week-view .cal-cell { min-height: auto !important; flex: 1; background: transparent !important; color: inherit !important; padding: 4px 0; }
  .week-view .cal-cell .cal-num { display: none; }
  .week-view .cal-event {
    font-size: 11px !important; height: auto !important; min-height: 0 !important;
    padding: 6px 9px !important; line-height: 1.35 !important; border-radius: 6px;
    white-space: normal !important;
  }
}

@media (max-width: 760px) {
  .modal-backdrop { padding: 16px; }
  .modal { width: 100%; max-width: 100% !important; border-radius: 14px; max-height: 88vh; }
  .modal-head { padding: 20px 20px 12px; }
  .modal-body { padding: 16px 20px; }
  .modal-foot { padding: 14px 20px 20px; }
}

@media (max-width: 760px) {
  /* Case Journey: horizontal scroll, fixed-width steps, no text overflow */
  .case-journey {
    display: flex !important; overflow-x: auto; overflow-y: hidden;
    gap: 8px; touch-action: pan-x; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .case-journey::-webkit-scrollbar { display: none; }
  .case-journey-step {
    flex: 0 0 auto !important; width: 108px; white-space: normal;
    line-height: 1.3; min-height: 44px;
  }

  /* Horizontal tab strips: scroll sideways only, never vertically */
  .tabs-primary {
    overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap !important;
    touch-action: pan-x; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .tabs-primary::-webkit-scrollbar { display: none; }
  .tabs-primary .tab-btn { flex: 0 0 auto; white-space: nowrap; }
}

/* ── Shared chat thread (lawyer + client portals) ── */
.chat-thread {
  display: flex; flex-direction: column;
  height: 62vh;
  background: var(--surface-lowest);
  border-radius: 14px;
  overflow: hidden;
}
.chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty { margin: auto; color: var(--ink-50); font-size: 13px; text-align: center; max-width: 320px; }
.chat-msg { align-self: flex-start; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; }
.chat-bubble {
  background: var(--surface-high); color: var(--tertiary);
  border-radius: 12px; padding: 9px 13px;
  font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg.mine .chat-bubble { background: var(--primary); color: var(--on-primary); }
.chat-meta { font-family: 'Inter', sans-serif; font-size: 10.5px; color: var(--ink-50); margin-top: 3px; }
.chat-msg.mine .chat-meta { text-align: right; }
.chat-composer {
  border-top: 1px solid rgba(23,23,22,0.08);
  padding: 12px; display: flex; gap: 8px;
}
.chat-composer .input { flex: 1; }

/* ── Drafting: rich document editor ─────────────────────────── */
.draft-toolbar {
  position: sticky; top: 10px; z-index: 6;
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  background: var(--surface-lowest);
  border: 1px solid var(--ghost-soft); border-radius: 9px;
  padding: 6px 8px; margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.draft-tbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 7px;
  border: none; background: transparent; border-radius: 5px;
  cursor: pointer; color: var(--ink-60);
  font-family: 'Inter', sans-serif; font-size: 13.5px; line-height: 1;
}
.draft-tbtn:hover { background: var(--surface-high); color: var(--tertiary); }
.draft-tbtn.active { background: rgba(20, 88, 58, 0.10); color: var(--primary); }
.draft-tsep { width: 1px; height: 20px; background: var(--ghost-soft); margin: 0 6px; flex: none; }
.draft-tselect {
  height: 30px; border: none; background: transparent; border-radius: 5px;
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--ink-60);
  padding: 0 4px; cursor: pointer; outline: none; max-width: 118px;
}
.draft-tselect:hover { background: var(--surface-high); color: var(--tertiary); }

.draft-canvas {
  background: var(--surface-high);
  border: 1px solid var(--ghost-soft); border-radius: 12px;
  padding: 36px 20px 28px;
}
.draft-page {
  background: #ffffff; max-width: 830px; margin: 0 auto;
  padding: 58px 68px 72px; border-radius: 3px; min-height: 72vh;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 10px 30px rgba(0,0,0,0.07);
}
@media (max-width: 800px) { .draft-page { padding: 28px 22px 40px; } }
.draft-page-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.draft-case-link {
  border: 1px solid var(--ghost-soft); background: var(--surface);
  border-radius: 999px; padding: 4px 10px;
  font-family: 'Inter', sans-serif; font-size: 11.5px; color: var(--ink-60);
  cursor: pointer; outline: none; max-width: 280px;
}
.draft-case-link:hover { border-color: var(--ghost); color: var(--tertiary); }
.draft-case-link.unlinked { color: var(--secondary); border-style: dashed; }

.draft-editor {
  outline: none; min-height: 52vh;
  font-family: var(--serif); font-size: 15.5px; line-height: 1.9;
  color: var(--tertiary); word-wrap: break-word;
}
.draft-editor:empty::before { content: attr(data-placeholder); color: var(--ink-30); pointer-events: none; }
.draft-editor p, .draft-editor div { margin: 0 0 10px; }
.draft-editor h1 { font-size: 24px; font-weight: 600; line-height: 1.35; margin: 22px 0 10px; }
.draft-editor h2 { font-size: 19px; font-weight: 600; line-height: 1.4; margin: 18px 0 8px; }
.draft-editor h3 { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 16px 0 6px; text-transform: none; }
.draft-editor ul, .draft-editor ol { margin: 0 0 10px; padding-left: 30px; }
.draft-editor li { margin-bottom: 4px; }
.draft-editor blockquote {
  border-left: 3px solid var(--secondary); margin: 12px 0;
  padding: 2px 0 2px 16px; color: var(--ink-60);
}
.draft-editor hr { border: none; border-top: 1px solid var(--ghost); margin: 22px 0; }
.draft-editor a { color: var(--primary); }
.draft-statusbar {
  max-width: 830px; margin: 12px auto 0;
  display: flex; justify-content: space-between; gap: 12px;
  font-family: 'Inter', sans-serif; font-size: 11px; color: var(--ink-40);
}

/* ── Drafting: new-draft wizard + download menu ─────────────── */
.draft-wiz-steps { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.draft-wiz-dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 600;
  background: var(--surface-high); color: var(--ink-50);
  border: 1px solid var(--ghost-soft);
}
.draft-wiz-dot.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.draft-wiz-dot.done { background: rgba(20, 88, 58, 0.12); color: var(--primary); border-color: rgba(20, 88, 58, 0.25); }
.draft-wiz-line { width: 26px; height: 1px; background: var(--ghost); flex: none; }

.draft-wiz-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px;
  max-height: 38vh; overflow-y: auto; padding: 2px 4px 6px 2px;
}
@media (max-width: 700px) { .draft-wiz-fields { grid-template-columns: 1fr; } }
.draft-autofill-chip {
  font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(181, 142, 58, 0.14); color: var(--secondary);
  border-radius: 999px; padding: 2px 7px;
}

.draft-dlmenu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--surface-lowest);
  border: 1px solid var(--ghost-soft); border-radius: 9px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  padding: 5px; min-width: 200px;
}
.draft-dlitem {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent; border-radius: 6px;
  padding: 9px 11px; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--tertiary);
}
.draft-dlitem:hover { background: var(--surface-high); }

/* ── Drafting wizard: compact category rail + row list ──────── */
.draft-wiz-pane { display: flex; gap: 14px; height: 44vh; min-height: 300px; }
.draft-wiz-rail {
  flex: 0 0 168px; overflow-y: auto; padding-right: 2px;
  border-right: 1px solid var(--ghost-soft);
  display: flex; flex-direction: column; gap: 2px;
}
.draft-wiz-railitem {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: none; background: transparent; border-radius: 6px;
  padding: 8px 10px; margin-right: 10px; cursor: pointer; text-align: left;
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--ink-60);
}
.draft-wiz-railitem:hover { background: var(--surface-high); color: var(--tertiary); }
.draft-wiz-railitem.on { background: rgba(20, 88, 58, 0.10); color: var(--primary); font-weight: 600; }
.draft-wiz-count {
  font-size: 10px; font-weight: 600; color: var(--ink-40);
  background: var(--surface-high); border-radius: 999px; padding: 1px 7px;
}
.draft-wiz-railitem.on .draft-wiz-count { background: rgba(20, 88, 58, 0.12); color: var(--primary); }

.draft-wiz-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding-right: 4px; }
.draft-wiz-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; cursor: pointer;
  border: 1px solid transparent; background: transparent; border-radius: 7px;
  padding: 9px 12px;
}
.draft-wiz-row:hover { background: var(--surface-lowest); border-color: var(--ghost-soft); }
.draft-wiz-row.blank { border: 1px dashed var(--ghost); margin-bottom: 6px; }
.draft-wiz-rowname { font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500; color: var(--tertiary); }
.draft-wiz-rowmeta { font-family: 'Inter', sans-serif; font-size: 10.5px; color: var(--ink-40); flex: none; text-align: right; }

@media (max-width: 700px) {
  .draft-wiz-pane { flex-direction: column; height: auto; max-height: 52vh; }
  .draft-wiz-rail { flex: none; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--ghost-soft); padding-bottom: 8px; }
  .draft-wiz-railitem { margin-right: 0; }
  .draft-wiz-list { max-height: 38vh; }
}
