:root {
  /* — Chancery palette: ivory paper · navy bench · oxblood accent · gold — */
  --bg: #f7f4ee;
  --surface: #fffdf8;
  --surface-soft: #f6f0e6;
  --ink: #20242e;
  --muted: #6d6656;
  --line: #e2d9c9;
  --primary: #7b2d34;
  --primary-dark: #5f2228;
  --blue: #1f2d51;
  --orange: #9a6a1e;
  --green: #3f6b4a;
  --danger: #8f2f2c;
  --warning: #8a6212;
  --gold: #d4af78;
  --shadow: 0 18px 45px rgba(60, 44, 20, 0.12);
  --radius: 18px;
  --radius-sm: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: Georgia, "Times New Roman", "Iowan Old Style", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 82% -8%, rgba(123, 45, 52, 0.06), transparent 60%),
    radial-gradient(900px 480px at -6% 4%, rgba(31, 45, 81, 0.05), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

.hidden { display: none !important; }

.lock-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
}

.lock-card {
  width: min(520px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand-row, .sidebar-brand {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--orange));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(212,175,120,0.25), 0 12px 30px rgba(123, 45, 52, 0.3);
  flex: 0 0 auto;
}

h1, h2, h3, p { margin-top: 0; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; }
h1 { margin-bottom: 4px; font-size: 27px; letter-spacing: -0.01em; }
h2 { margin-bottom: 6px; font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.015em; line-height: 1.08; }
h3 { margin-bottom: 10px; font-size: 19px; letter-spacing: -0.005em; }

.subtle, .lock-card p, .mini { color: var(--muted); }

.security-note {
  margin: 24px 0;
  padding: var(--space-4);
  border: 1px solid rgba(123, 45, 52, 0.25);
  border-radius: var(--radius-sm);
  background: #fff2ee;
  color: #6c2b22;
}

.tab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: 6px;
  border-radius: 999px;
  background: #f1ebe4;
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(24, 32, 51, 0.08);
}

.stack { display: grid; gap: var(--space-4); }

label { display: grid; gap: 7px; font-weight: 700; }

label span { color: var(--ink); font-size: 14px; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea { resize: vertical; }

input:focus, textarea:focus, select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(154, 106, 30, 0.16);
}

.form-message { min-height: 22px; margin: 0; color: var(--danger); font-weight: 700; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: linear-gradient(180deg, #1c2233, #232a3d);
  color: #eae4d6;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0,0,0,0.25);
}

.sidebar-brand span { display: block; color: rgba(255,255,255,0.64); font-size: 13px; }

.nav-list { display: grid; gap: var(--space-2); margin: 32px 0; }

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255,255,255,0.76);
  text-align: left;
  padding: 13px 14px;
  border-radius: 14px;
  font-weight: 750;
}

.nav-item:hover, .nav-item:focus-visible { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(212,175,120,0.16); color: #f2e7d2; box-shadow: inset 3px 0 0 var(--gold); }

.sidebar-footer { margin-top: auto; display: grid; gap: var(--space-3); }
#signedInAs { color: rgba(255,255,255,0.7); font-size: 13px; }

.main { padding: 30px; min-width: 0; }
.view { display: none; }
.active-view { display: block; }

.page-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-5);
}

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 16px 0;
  background: linear-gradient(180deg, var(--bg) 86%, rgba(247,243,238,0));
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 900;
}

.card {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: 0 12px 35px rgba(24,32,51,0.045);
}

.grid { display: grid; gap: var(--space-4); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.metric-card {
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 35px rgba(24,32,51,0.045);
}

.metric-card span { display: block; color: var(--muted); font-weight: 700; }
.metric-card strong { display: block; margin-top: 8px; font-size: 36px; line-height: 1; }
.danger-soft { background: #fff2ee; border-color: rgba(123, 45, 52, 0.18); }

.check-list, .number-list { margin: 0; padding-left: 20px; color: var(--ink); }
.check-list li, .number-list li { margin: 8px 0; }

.workspace-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.case-panel { position: sticky; top: 126px; max-height: calc(100vh - 150px); overflow: auto; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.panel-title-row h3 { margin-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff0e6;
  color: #7c4a12;
  font-weight: 850;
  font-size: 12px;
}
.badge.muted { background: #f1ebe4; color: var(--muted); }
.badge.green { background: #e9f7ef; color: var(--green); }
.badge.red { background: #fff2ee; color: var(--danger); }

.case-list { display: grid; gap: var(--space-2); }
.case-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 13px;
  text-align: left;
}
.case-item strong { display: block; margin-bottom: 4px; }
.case-item span { display: block; color: var(--muted); font-size: 13px; }
.case-item.active { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(154, 106, 30, 0.13); }

.empty-state { text-align: center; padding: 56px 24px; }
.case-summary-card { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-4); }
.case-actions, .action-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.action-row.compact { justify-content: flex-end; }

.document-list { display: grid; gap: var(--space-2); }
.document-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  background: #fff;
}
.document-row strong { display: block; }
.document-row span { color: var(--muted); font-size: 13px; }
.document-actions { display: flex; gap: var(--space-2); }

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 42px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 850;
  text-decoration: none;
}
.btn.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.btn.full { width: 100%; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.primary-alt { background: var(--blue); color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(104,112,132,0.25); }
.btn.danger { background: #fff2ee; color: var(--danger); border-color: rgba(123, 45, 52,0.2); }
.file-btn input { display: none; }

.output-card { min-height: 360px; }
.ai-output, .context-preview {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 260px;
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf8 0%, #f9f3e7 100%);
  color: var(--ink);
  padding: var(--space-4);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  box-shadow: inset 0 1px 2px rgba(60,44,20,0.05);
}

.dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 620px;
  width: calc(100% - 32px);
}
.dialog::backdrop { background: rgba(11,31,58,0.52); backdrop-filter: blur(3px); }
.dialog-card {
  display: grid;
  gap: var(--space-4);
  background: #fff;
  border-radius: 22px;
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
.dialog-card header, .dialog-card footer { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.dialog-card header h3 { margin: 0; }
.wide-dialog { max-width: 900px; }
.context-preview { background: #fff; color: var(--ink); max-height: 65vh; }

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.toast-region {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 99;
  display: grid;
  gap: var(--space-2);
}
.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 13px 14px;
  border-radius: 14px;
  background: #1c2233;
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 750;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--green); }

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #f1ebe4;
  color: #6c2b22;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-list { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .workspace-grid, .grid.two, .metric-grid { grid-template-columns: 1fr; }
  .case-panel { position: static; max-height: none; }
}

@media (max-width: 680px) {
  .main { padding: 18px; }
  .page-header, .case-summary-card, .panel-title-row { flex-direction: column; align-items: stretch; }
  .nav-list { grid-template-columns: 1fr 1fr; }
  .lock-card { padding: 22px; }
}

/* v2.1 specialised legal benches */
.compact-left { justify-content: flex-start; }
.compact-title { margin-bottom: var(--space-2); }
.mini { font-size: 13px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.tiny-check {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  width: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.tiny-check input { width: auto; margin: 0; }

.rera-slot-list { display: grid; gap: var(--space-3); }
.rera-slot {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}
.slot-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(34,59,115,0.04), rgba(154, 106, 30,0.05));
}
.slot-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}
.slot-title span {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(34,59,115,0.1);
  color: var(--blue);
  font-size: 13px;
}
.slot-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.slot-files { display: grid; gap: var(--space-2); padding: var(--space-3); }
.slot-empty { color: var(--muted); font-weight: 750; padding: 6px; }
.slot-pill {
  display: grid;
  grid-template-columns: auto auto minmax(160px, 1fr) auto auto;
  align-items: center;
  gap: var(--space-2);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.slot-pill.is-off { opacity: 0.72; background: #f8f4ef; }
.slot-file-name strong { display: block; word-break: break-word; }
.slot-file-name span { display: block; color: var(--muted); font-size: 12px; }

.tax-bench {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}
.tax-bench-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.tax-head {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-4);
}
.tax-department { border-right: 1px solid var(--line); background: rgba(34,59,115,0.035); }
.tax-client { background: rgba(154, 106, 30,0.04); }
.tax-badge {
  justify-self: start;
  font-size: 12px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-weight: 950;
  border-radius: 999px;
  padding: 6px 12px;
}
.tax-badge.blue { color: var(--blue); background: rgba(34,59,115,0.1); border: 1px solid rgba(34,59,115,0.25); }
.tax-badge.orange { color: #7c4a12; background: #fff0e6; border: 1px solid rgba(154, 106, 30,0.25); }
.tax-rows { display: grid; }
.tax-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.tax-row:last-child { border-bottom: 0; }
.tax-cell { padding: var(--space-4); min-width: 0; }
.tax-cell.tax-department { border-right: 1px solid var(--line); }
.tax-notice-title {
  color: var(--ink);
  font-weight: 950;
  margin-bottom: var(--space-3);
  word-break: break-word;
}
.tax-notice-title span { color: var(--primary); }
.field-inline { display: grid; gap: 6px; margin-bottom: var(--space-3); }
.field-inline span { color: var(--muted); font-size: 12px; font-weight: 900; }
.tax-annex-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: var(--space-3);
  background: #fffaf3;
}
.annexure-list { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); }
.annexure-item {
  display: grid;
  grid-template-columns: auto auto minmax(140px,1fr) auto auto;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
}
.annexure-item span { font-weight: 800; word-break: break-word; }
.tax-preview {
  min-height: 92px;
  max-height: 150px;
  background: #fff;
  font-size: 13px;
  font-weight: 650;
}
.tax-empty { padding: var(--space-5); color: var(--muted); text-align: center; font-weight: 850; }

@media (max-width: 900px) {
  .slot-head, .tax-bench-head, .tax-row { grid-template-columns: 1fr; }
  .tax-department, .tax-cell.tax-department { border-right: 0; border-bottom: 1px solid var(--line); }
  .slot-actions { justify-content: flex-start; }
  .slot-pill, .annexure-item { grid-template-columns: 1fr; align-items: stretch; }
}

/* v2.3 production-workflow additions */
.metric-grid.enhanced-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card.warning-soft { background: linear-gradient(135deg, #fff8e9, #fff); }
.metric-card.green-soft { background: linear-gradient(135deg, #eefaf3, #fff); }
.badge.orange { background: #fff4e7; color: #7c4a12; }
.badge.red { background: #fff2ee; color: var(--danger); }
.case-deadline.green { color: var(--green); }
.case-deadline.orange { color: #7c4a12; }
.case-deadline.red { color: var(--danger); font-weight: 900; }
.case-filter-box { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); }
.case-filter-box input, .case-filter-box select { padding: 10px 11px; font-size: 13px; }
.dashboard-table-card { margin: var(--space-5) 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.matter-table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
.matter-table th, .matter-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.matter-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: #fff9f1; }
.matter-table td span { color: var(--muted); font-size: 12px; }
.table-status { display: inline-block; color: var(--blue) !important; background: rgba(34,59,115,.08); border-radius: 999px; padding: 4px 9px; font-weight: 850; }
.empty-table { text-align: center; color: var(--muted); font-weight: 850; }
.case-insight-card { display: grid; gap: var(--space-4); margin-bottom: var(--space-4); }
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.deadline-card { border: 1px solid var(--line); border-radius: 14px; padding: var(--space-3); background: #fff; display: grid; gap: 4px; }
.deadline-card strong { font-size: 13px; }
.deadline-card span { color: var(--muted); font-size: 12px; }
.deadline-card b { font-size: 12px; }
.deadline-card.green { border-color: rgba(23,114,69,.22); background: #f0fbf5; }
.deadline-card.orange { border-color: rgba(154, 106, 30,.28); background: #fff7ec; }
.deadline-card.red { border-color: rgba(123, 45, 52,.24); background: #fff2ee; }
.calculator-box, .timeline-box { border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: var(--space-4); }
.calculator-box h4, .timeline-box h4 { margin: 0 0 12px; font-size: 15px; }
.calc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.calc-grid div { border: 1px dashed var(--line); border-radius: 12px; padding: 10px; background: #fffaf5; }
.calc-grid span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.calc-grid strong { display: block; margin-top: 2px; word-break: break-word; }
.calc-grid strong.green { color: var(--green); }
.calc-grid strong.orange { color: #7c4a12; }
.calc-grid strong.red { color: var(--danger); }
.timeline-list { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 10px; }
.timeline-list li { display: grid; grid-template-columns: 150px 1fr; gap: var(--space-3); align-items: start; }
.timeline-list time { color: var(--blue); font-size: 12px; font-weight: 950; }
.timeline-list span { font-weight: 750; }
.quick-ai-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.final-draft-card textarea { min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55; }
.case-extra-fields { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 14px; padding: var(--space-4); background: #fffaf5; }
.extra-fields-title { font-weight: 950; margin-bottom: var(--space-3); color: var(--blue); }
.extra-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.meta-chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--space-3); }
.meta-chip { border: 1px solid var(--line); background: #fff; color: var(--blue); border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 900; }
.document-row.important-doc, .slot-pill.important-doc, .annexure-item.important-doc { border-color: rgba(154, 106, 30,.5); background: #fff8ef; }
.slot-pill { grid-template-columns: auto auto minmax(160px, 1fr) auto auto auto auto; }
.annexure-item { grid-template-columns: auto auto minmax(140px,1fr) auto auto auto; }
.document-preview-card { max-height: 92vh; overflow: auto; }
.original-preview { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.document-text-preview { max-height: 360px; white-space: pre-wrap; }
.compact-title { gap: var(--space-2); }
@media (max-width: 1100px) {
  .metric-grid.enhanced-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .insight-grid, .calc-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .extra-fields-grid, .insight-grid, .calc-grid, .timeline-list li { grid-template-columns: 1fr; }
}

/* v2.4 navigation fix: workspace list and matter detail are separate screens */
.workspace-grid.list-mode {
  display: block;
}
.workspace-grid.list-mode .case-panel {
  position: static;
  max-height: none;
  width: min(760px, 100%);
}
.workspace-grid.list-mode .case-main {
  display: none;
}
.workspace-grid.detail-mode {
  display: block;
}
.workspace-grid.detail-mode .case-panel {
  display: none;
}
.workspace-grid.detail-mode .case-main {
  width: min(1120px, 100%);
}
.matter-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
#backToMattersBtn {
  background: #fff;
}
.case-main > #activeCaseArea > .card,
.case-main > #activeCaseArea > .grid,
.case-main > #activeCaseArea > article {
  margin-bottom: var(--space-4);
}
.case-panel .panel-title-row h3::after {
  content: " — click any matter to open full page";
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: normal;
}
@media (max-width: 1100px) {
  .workspace-grid.list-mode .case-panel,
  .workspace-grid.detail-mode .case-main { width: 100%; }
}

/* v2.5 compact matter detail: one clean section at a time */
#workspaceView.matter-open > .page-header {
  display: none;
}
.workspace-grid.detail-mode {
  margin-top: 0;
}
.workspace-grid.detail-mode .case-main {
  width: min(1180px, 100%);
  margin: 0 auto;
}
.matter-detail-top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0 12px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, var(--bg) 84%, rgba(247,243,238,0));
}
.compact-detail-card {
  padding: 16px 18px;
  margin-bottom: 12px !important;
}
.case-summary-card.compact-detail-card {
  align-items: center;
}
.case-summary-card.compact-detail-card h3 {
  margin-bottom: 4px;
  font-size: 21px;
}
.case-summary-card.compact-detail-card .eyebrow {
  margin-bottom: 4px;
}
.case-summary-card.compact-detail-card p {
  margin-bottom: 0;
}
.matter-tabs {
  position: sticky;
  top: 60px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 25px rgba(24,32,51,.055);
}
.matter-tab {
  border: 1px solid transparent;
  border-radius: 13px;
  min-height: 40px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}
.matter-tab.active {
  background: #1c2233;
  color: #fff;
  box-shadow: 0 8px 18px rgba(11,31,58,.16);
}
.detail-section { display: none; }
.detail-section.active-section { display: block; }
.compact-title-row { margin-bottom: 10px; }
.compact-title-row h3 { margin-bottom: 0; }
.compact-title-row .subtle { margin-bottom: 0; }
.case-insight-card { gap: 12px; }
.case-insight-card .panel-title-row { margin-bottom: 10px; }
.insight-grid { gap: 10px; }
.deadline-card { padding: 10px; }
.calculator-box, .timeline-box {
  padding: 12px;
  border-radius: 14px;
}
.calculator-box h4, .timeline-box h4 {
  margin-bottom: 8px;
}
.calc-grid { gap: 10px; }
.calc-grid div { padding: 9px; }
.timeline-list { gap: 7px; }
.timeline-list li {
  grid-template-columns: 130px 1fr;
  gap: 10px;
}

/* Compact document benches */
.tax-bench {
  border-radius: 14px;
}
.tax-head, .tax-cell {
  padding: 12px;
}
.tax-head .subtle,
.tax-cell .mini {
  margin-bottom: 0;
}
.tax-badge {
  padding: 5px 11px;
}
.tax-notice-title {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.35;
}
.meta-chip-row {
  margin-bottom: 8px;
}
.field-inline {
  margin-bottom: 8px;
}
.field-inline input {
  min-height: 44px;
  padding: 9px 12px;
}
.tax-annex-card {
  padding: 10px;
}
.annexure-list {
  gap: 7px;
  margin-bottom: 8px;
}
.annexure-item {
  grid-template-columns: auto auto minmax(0, 1fr) auto auto auto;
  gap: 7px;
  padding: 7px;
}
.annexure-item span {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.tax-preview {
  min-height: 74px;
  max-height: 110px;
  font-size: 12px;
  line-height: 1.42;
}
.slot-head {
  padding: 12px;
}
.slot-files {
  padding: 10px;
}
.slot-pill {
  grid-template-columns: auto auto minmax(0, 1fr) auto auto auto auto;
  padding: 8px;
}
.slot-file-name strong,
.tax-annex-card strong {
  overflow-wrap: anywhere;
}
.document-row {
  padding: 10px;
}
.document-actions,
.slot-actions {
  gap: 6px;
}
.btn.small {
  min-height: 32px;
}
.output-card {
  min-height: 0;
}
.ai-output, .context-preview {
  min-height: 190px;
  max-height: 380px;
}
.compact-output-grid {
  gap: 12px;
}
.final-draft-card textarea {
  min-height: 260px;
}
.sticky-head {
  position: static;
  padding: 0;
}
@media (max-width: 900px) {
  .matter-detail-top,
  .matter-tabs { position: static; }
  .matter-tabs { grid-template-columns: 1fr 1fr; }
  .tax-bench-head, .tax-row { grid-template-columns: 1fr; }
  .tax-department, .tax-cell.tax-department { border-right: 0; border-bottom: 1px solid var(--line); }
  .annexure-item, .slot-pill { grid-template-columns: 1fr; align-items: stretch; }
}

/* v2.7 Knowledge Library */
.knowledge-library {
  display: grid;
  gap: 16px;
}
.library-controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(420px, 1.4fr);
  gap: 18px;
  align-items: center;
}
.library-controls h3 { margin-bottom: 4px; }
.library-controls p { margin-bottom: 0; }
.library-control-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(230px, .8fr) auto auto;
  gap: 8px;
  align-items: center;
}
.library-control-grid input,
.library-control-grid select { min-height: 46px; padding: 10px 12px; }
.library-control-grid select {
  font-weight: 850;
  color: var(--ink);
  background-color: #fff;
}
.btn.active-filter {
  background: #1c2233;
  color: #fff;
  border-color: #1c2233;
}
.library-selected-filter {
  display: block;
}
.selected-library-section {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px 14px;
  box-shadow: 0 8px 22px rgba(24,32,51,.035);
}
.selected-library-section span {
  color: var(--primary);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.selected-library-section strong { font-size: 16px; }
.selected-library-section small { color: var(--muted); font-weight: 800; }
.library-item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.library-item-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}
.library-item-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.library-type {
  display: inline-block;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 950;
  margin-bottom: 4px;
}
.library-item-head h3 {
  margin-bottom: 0;
  line-height: 1.25;
}
.library-star {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: #b7a99a;
  font-size: 19px;
  font-weight: 950;
}
.library-star.active {
  color: #7c4a12;
  background: #fff4e7;
  border-color: rgba(154, 106, 30,.4);
}
.library-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.library-tags span {
  border: 1px solid var(--line);
  background: #fffaf5;
  color: var(--blue);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
}
.library-preview {
  margin: 0;
  min-height: 150px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf5;
  color: var(--ink);
  padding: 12px;
  font-size: 12px;
  line-height: 1.48;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.empty-library-card {
  grid-column: 1 / -1;
  text-align: center;
}
#libraryItemContent {
  min-height: 300px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
@media (max-width: 1250px) {
  .library-controls { grid-template-columns: 1fr; }
  .library-control-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .library-item-grid { grid-template-columns: 1fr; }
  .selected-library-section { grid-template-columns: 1fr; align-items: start; }
  .library-control-grid { grid-template-columns: 1fr; }
}

/* v2.8 search + voice UI fixes */
.main {
  overflow-x: hidden;
}

.dashboard-header {
  align-items: stretch;
}

.dashboard-search-panel {
  width: min(420px, 100%);
  padding: 16px;
  align-self: flex-start;
}

.dashboard-search-panel label {
  gap: 8px;
}

.dashboard-search-count {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 800;
}

.search-with-voice {
  position: relative;
  width: 100%;
  min-width: 0;
}

.search-with-voice input[type="search"] {
  padding-right: 48px;
}

.voice-search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 1px solid rgba(104,112,132,.22);
  border-radius: 10px;
  background: #fff8f0;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 950;
  box-shadow: 0 6px 16px rgba(24,32,51,.06);
}

.voice-search-btn:hover,
.voice-search-btn:focus-visible {
  border-color: rgba(123, 45, 52,.35);
  background: #fff0e6;
}

.voice-search-btn.listening {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 45, 52,.28); }
  50% { box-shadow: 0 0 0 8px rgba(123, 45, 52,.08); }
}

.case-filter-box .search-with-voice,
.library-control-grid .search-with-voice {
  min-width: 0;
}

.library-controls {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.library-control-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  justify-content: flex-start;
}

.library-control-grid .search-with-voice {
  flex: 1 1 320px;
}

.library-control-grid select {
  flex: 1 1 240px;
}

.library-control-grid .btn {
  flex: 0 0 auto;
  min-height: 46px;
}

.library-item-grid {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
}

.library-item-card,
.library-controls,
.selected-library-section {
  min-width: 0;
}

.library-item-head h3,
.library-preview {
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .dashboard-header {
    flex-direction: column;
  }
  .dashboard-search-panel {
    width: 100%;
  }
  .library-control-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Universal voice-to-text search control */
.search-with-voice {
  position: relative;
  width: 100%;
  min-width: 0;
}

.search-with-voice input[type="search"],
.search-with-voice input[id*="Search"],
.search-with-voice input[id*="search"] {
  width: 100%;
  padding-right: 52px !important;
}

.voice-search-btn {
  cursor: pointer;
  user-select: none;
}

.voice-search-btn.listening span {
  font-size: 16px;
  line-height: 1;
}

/* ============================================================
   PREMIUM LAYER v3 — depth, iconography, motion, refinement
   (visual only; no structural/feature changes)
   ============================================================ */

:root {
  --elev-1: 0 1px 2px rgba(60,44,20,.05), 0 10px 26px -16px rgba(60,44,20,.16);
  --elev-2: 0 2px 6px rgba(60,44,20,.06), 0 22px 46px -20px rgba(60,44,20,.26);
  --elev-3: 0 3px 10px rgba(60,44,20,.08), 0 34px 60px -26px rgba(60,44,20,.34);
  --spring: cubic-bezier(.16,1,.3,1);
}

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: rgba(123,45,52,.16); color: var(--primary-dark); }

/* ---- refined scrollbars ---- */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #cdc0aa; }

/* ---- entrance motion ---- */
@keyframes premUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes premFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.active-view { animation: premFade .45s var(--spring) both; }

/* ============================================================
   SIDEBAR — glow, icons, tactile nav
   ============================================================ */
.sidebar { box-shadow: inset -1px 0 0 rgba(255,255,255,.03); }
.sidebar .brand-mark {
  box-shadow: inset 0 0 0 1px rgba(212,175,120,.4), 0 0 24px -6px rgba(212,175,120,.55);
}
.sidebar-brand strong { letter-spacing: .01em; }

.nav-list { gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; position: relative;
  border-radius: 12px; font-weight: 650; letter-spacing: .005em;
  transition: background .2s var(--spring), color .2s ease, transform .18s var(--spring);
}
.nav-item::before {
  content: ""; width: 18px; height: 18px; flex: 0 0 auto;
  background-color: currentColor; opacity: .85;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
  transition: opacity .2s ease, transform .2s var(--spring);
}
.nav-item:hover { transform: translateX(3px); }
.nav-item:hover::before { opacity: 1; }
.nav-item.active::before { opacity: 1; }
.nav-item[data-view="dashboard"]        { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E"); }
.nav-item[data-view="rera"]             { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='1'/%3E%3Cpath d='M9 8h.01M12 8h.01M15 8h.01M9 12h.01M12 12h.01M15 12h.01M10 21v-4h4v4'/%3E%3C/svg%3E"); }
.nav-item[data-view="income_tax"]       { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 3v18l2-1 2 1 2-1 2 1 2-1 2 1V3l-2 1-2-1-2 1-2-1-2 1-2-1z'/%3E%3Cpath d='M9 8h6M9 12h6'/%3E%3C/svg%3E"); }
.nav-item[data-view="knowledge_library"]{ --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/%3E%3Cpath d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'/%3E%3C/svg%3E"); }
.nav-item[data-view="settings"]         { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 2v3M12 19v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M2 12h3M19 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1'/%3E%3C/svg%3E"); }

/* ============================================================
   CARDS — paper elevation
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--elev-1);
  transition: box-shadow .28s var(--spring), transform .28s var(--spring), border-color .2s ease;
}
.panel-title-row { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.panel-title-row.compact-title-row { border-bottom: 0; padding-bottom: 0; }

/* ============================================================
   METRIC CARDS — the dashboard hero
   ============================================================ */
.metric-grid { gap: 14px; }
.metric-card {
  position: relative; overflow: hidden;
  padding: 20px 22px; border-radius: 16px;
  background: linear-gradient(160deg, #fffdf9, #fbf5ea);
  border: 1px solid var(--line);
  box-shadow: var(--elev-1);
  transition: transform .28s var(--spring), box-shadow .28s var(--spring);
  animation: premUp .5s var(--spring) both;
}
.metric-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--gold));
}
.metric-card::after {
  content: ""; position: absolute; top: 0; left: -160%; width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.5), transparent);
  transform: skewX(-16deg); transition: left .7s var(--spring); pointer-events: none;
}
.metric-card:hover { transform: translateY(-4px); box-shadow: var(--elev-2); }
.metric-card:hover::after { left: 170%; }
.metric-card span { text-transform: uppercase; letter-spacing: .09em; font-size: 11.5px; font-weight: 800; color: var(--muted); }
.metric-card strong { font-family: var(--font-display); font-size: 42px; margin-top: 10px; color: var(--ink); font-variant-numeric: tabular-nums; }
.metric-card:nth-child(1){animation-delay:.03s}.metric-card:nth-child(2){animation-delay:.07s}
.metric-card:nth-child(3){animation-delay:.11s}.metric-card:nth-child(4){animation-delay:.15s}
.metric-card:nth-child(5){animation-delay:.19s}.metric-card:nth-child(6){animation-delay:.23s}
.metric-card:nth-child(7){animation-delay:.27s}.metric-card:nth-child(8){animation-delay:.31s}
.metric-card.danger-soft { background: linear-gradient(160deg, #fdf2ee, #fff9f6); }
.metric-card.danger-soft::before { background: linear-gradient(90deg, var(--danger), #c8735f); }
.metric-card.warning-soft { background: linear-gradient(160deg, #fdf4e3, #fffdf7); }
.metric-card.warning-soft::before { background: linear-gradient(90deg, var(--warning), var(--gold)); }
.metric-card.green-soft { background: linear-gradient(160deg, #eef6ee, #fbfefb); }
.metric-card.green-soft::before { background: linear-gradient(90deg, var(--green), #82a673); }

/* ============================================================
   BUTTONS — gradient, gloss, depth
   ============================================================ */
.btn {
  border-radius: 12px; font-weight: 750; letter-spacing: .01em;
  position: relative; overflow: hidden;
  transition: transform .16s var(--spring), box-shadow .22s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fdf7f2; border: 0; box-shadow: 0 10px 22px -12px rgba(123,45,52,.85);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(123,45,52,.95); }
.btn.primary::after {
  content: ""; position: absolute; top: 0; left: -140%; width: 48%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.32), transparent);
  transform: skewX(-18deg); transition: left .6s var(--spring); pointer-events: none;
}
.btn.primary:hover::after { left: 165%; }
.btn.primary-alt { background: linear-gradient(135deg, var(--blue), #16203c); color: #eef1f8; border: 0; box-shadow: 0 10px 22px -12px rgba(31,45,81,.8); }
.btn.primary-alt:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(31,45,81,.9); }
.btn.secondary { background: var(--surface); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn.ghost:hover { transform: translateY(-1px); }

/* ============================================================
   TABLE — professional data grid
   ============================================================ */
.matter-table thead th {
  text-transform: uppercase; letter-spacing: .07em; font-size: 11px;
  color: var(--muted); font-weight: 800;
  background: var(--surface-soft); border-bottom: 1px solid var(--line);
}
.matter-table tbody tr { transition: background .16s ease; }
.matter-table tbody tr:hover { background: rgba(212,175,120,.07); }

/* ============================================================
   DASHBOARD HEADER + SEARCH — hero feel
   ============================================================ */
.dashboard-header h2 { font-size: clamp(34px, 5vw, 46px); position: relative; display: inline-block; }
.dashboard-header h2::after {
  content: ""; position: absolute; left: 0; bottom: -8px; height: 3px; width: 54px;
  border-radius: 3px; background: linear-gradient(90deg, var(--primary), var(--gold));
}
.dashboard-search-panel { box-shadow: var(--elev-2); border-radius: 16px; }
.dashboard-search-panel input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(123,45,52,.12); }

/* ============================================================
   BADGES + CHIPS
   ============================================================ */
.badge { border-radius: 999px; font-weight: 800; letter-spacing: .02em; }
.eyebrow { color: var(--primary); }

/* ============================================================
   MATTER TABS — segmented control feel
   ============================================================ */
.matter-tab { transition: color .2s ease, background .2s var(--spring); border-radius: 10px; }
.case-item { transition: transform .18s var(--spring), border-color .2s ease, box-shadow .22s ease; }
.case-item:hover { transform: translateX(2px); box-shadow: var(--elev-1); }

/* ---- inputs ---- */
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(123,45,52,.12); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   SPACING BALANCE v3.1 — declutter + even rhythm
   ============================================================ */
.nav-list { margin: 20px 0; }
.sidebar-brand { padding-bottom: 4px; }
.page-header { margin-bottom: 22px; }
.dashboard-header { gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.metric-grid { margin-bottom: 22px; gap: 14px; }
.metric-card { padding: 18px 20px; }
.metric-card strong { margin-top: 8px; font-size: 38px; }
.dashboard-table-card { margin-bottom: 0; }
.card + .card { margin-top: 0; }
.grid { gap: 16px; }
/* tighten the master tracker header/table gap */
.dashboard-table-card .panel-title-row { margin-bottom: 14px; }
.matter-table td, .matter-table th { padding-top: 13px; padding-bottom: 13px; }
/* workspace vertical rhythm */
.matter-detail-top { margin-bottom: 14px; }
.detail-section > .card { margin-bottom: 0; }
.case-summary-card { margin-bottom: 16px; }
.matter-tabs { margin-bottom: 16px; }

/* ============================================================
   FIX PASS v3.2 — A-to-Z UI refinements
   ============================================================ */
:root { --muted: #61594a; --radius: 16px; }

/* ---- DASHBOARD: KPI row ---- */
.kpi-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.metric-card.kpi { padding-right: 52px; }
.kpi-ico {
  position: absolute; top: 16px; right: 16px; width: 26px; height: 26px;
  background-color: var(--primary); opacity: .3;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
}
.metric-card.kpi[data-kpi="total"]   { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2 2 7l10 5 10-5-10-5z'/%3E%3Cpath d='M2 17l10 5 10-5M2 12l10 5 10-5'/%3E%3C/svg%3E"); }
.metric-card.kpi[data-kpi="open"]    { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.metric-card.kpi[data-kpi="overdue"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.metric-card.kpi[data-kpi="overdue"] .kpi-ico { background-color: var(--danger); opacity: .4; }
.metric-card.kpi[data-kpi="due"]     { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M3 10h18M8 2v4M16 2v4'/%3E%3C/svg%3E"); }
.metric-card.kpi[data-kpi="due"] .kpi-ico { background-color: var(--warning); opacity: .42; }

/* ---- DASHBOARD: secondary stat strip ---- */
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); box-shadow: var(--elev-1);
  transition: border-color .2s ease, box-shadow .25s var(--spring);
}
.stat:hover { border-color: var(--border-strong, #d8c9a9); box-shadow: var(--elev-2); }
.stat span { color: var(--muted); font-weight: 700; font-size: 13px; }
.stat strong { font-family: var(--font-display); font-size: 26px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- DASHBOARD: integrated tracker search ---- */
.tracker-head { align-items: flex-end; }
.tracker-search { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.tracker-search input { width: 280px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-soft); }
.tracker-search input:focus { background: #fff; }
.tracker-search .dashboard-search-count { font-size: 12px; }
.dashboard-table-card .panel-title-row { border-bottom: 0; padding-bottom: 16px; }

/* ---- TABLE: status tones ---- */
.table-status { display:inline-flex; align-items:center; padding: 4px 11px; border-radius:999px; font-size:12px; font-weight:800; background:#f1ebe4; color:var(--muted); }
.table-status.tone-crit { background:#f7e3de; color:#9a2f22; }
.table-status.tone-warn { background:#f6ecd4; color:#8a6212; }
.table-status.tone-ok   { background:#e7f1e5; color:#3f6b4a; }
.table-status.tone-info { background:#e6eaf2; color:#223b73; }
.table-status.tone-neutral { background:#f1ebe4; color:var(--muted); }

/* ---- KNOWLEDGE LIBRARY: clean actions + even previews ---- */
.library-preview { display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; overflow:hidden; min-height:0; max-height:none; }
.library-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.lib-use { display:flex; gap:6px; }
.lib-util { margin-left:auto; display:flex; gap:4px; }
.icon-only { width:34px; min-width:34px; padding:0; justify-content:center; font-size:15px; line-height:1; }
.lib-del:hover { color:var(--danger); border-color:var(--danger); }

/* ---- SIDEBAR: group labels + tighter width ---- */
.app-shell { grid-template-columns: 252px 1fr; }
.nav-group-label { margin: 14px 0 2px; padding: 0 14px; font-size:10.5px; font-weight:800; letter-spacing:.12em; text-transform:uppercase; color: rgba(255,255,255,0.42); }

/* ---- MATTERS hint -> subtitle (no wrap clash) ---- */
.case-panel .panel-title-row h3::after {
  content: "Click any matter to open its full page";
  display:block; margin-top:3px; font-size:11.5px; font-weight:500; letter-spacing:normal; color:var(--muted);
}

/* ---- LOGIN: refined card ---- */
.lock-card { border-radius: 20px; position: relative; overflow: hidden; }
.lock-card::before { content:""; position:absolute; inset:0 0 auto 0; height:3px; background: linear-gradient(90deg, var(--primary), var(--gold)); }

/* ---- leading + icon on create buttons ---- */
#newCaseBtn::before, #addLibraryItemBtn::before, #emptyNewCaseBtn::before { content:"+"; font-weight:800; font-size:16px; margin-right:3px; line-height:1; }

/* ---- radius consistency ---- */
.btn { border-radius: 11px; }
input, textarea, select { border-radius: 11px; }
.badge, .table-status, .dl-chip, .tracker-search input { border-radius: 999px; }
.card, .metric-card, .stat, .library-item-card { border-radius: 16px; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-strip { grid-template-columns: repeat(3, 1fr); }
  .tracker-head { flex-wrap: wrap; }
  .tracker-search input { width: 100%; }
}
@media (max-width: 680px) {
  .kpi-grid, .stat-strip { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVE FIX v3.3 — sidebar -> clean horizontal bar on narrow
   ============================================================ */
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: column;
    padding: 14px 18px; border-right: 0; border-bottom: 1px solid rgba(0,0,0,0.25);
  }
  .nav-group-label { display: none; }
  .nav-list {
    display: flex; flex-direction: row; flex-wrap: nowrap;
    grid-template-columns: none;
    overflow-x: auto; gap: 6px; margin: 12px 0 4px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 0 0 auto; white-space: nowrap; width: auto;
    padding: 9px 14px; border-radius: 999px;
  }
  .nav-item:hover { transform: none; }
  .sidebar-footer {
    margin-top: 8px; display: flex; flex-direction: row; align-items: center;
    justify-content: space-between; gap: 12px;
  }
  #signedInAs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .sidebar-footer .btn.full { width: auto; flex: 0 0 auto; }
}
