:root {
  color-scheme: light;
  --paper: oklch(0.985 0.004 245);
  --surface: oklch(0.965 0.007 245);
  --surface-strong: oklch(0.935 0.01 245);
  --ink: oklch(0.25 0.025 245);
  --muted: oklch(0.51 0.025 245);
  --line: oklch(0.87 0.012 245);
  --accent: oklch(0.48 0.11 242);
  --accent-soft: oklch(0.93 0.025 242);
  --danger: oklch(0.47 0.12 30);
  --warning: oklch(0.53 0.1 75);
  --success: oklch(0.45 0.09 155);
  --radius: 10px;
  --shadow: 0 12px 30px oklch(0.25 0.025 245 / 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

button, input, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid oklch(0.72 0.1 242 / 0.55);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; line-height: 1.2; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.top-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }

.button {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.button.secondary { background: var(--paper); }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--paper); }
.button:hover { border-color: var(--muted); }
.button:disabled { cursor: not-allowed; opacity: 0.5; }

.case-panel h2, .case-heading h1, .review-heading h2, .section-heading h2, .judgment h2 {
  margin: 2px 0 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 58px);
}

.case-panel {
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.case-panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 22px 18px 14px;
}

.case-panel-heading h2 { font-size: 20px; }
.case-panel-heading > span { color: var(--muted); font-size: 12px; }

.search-field { position: relative; display: block; margin: 0 14px 12px; }
.search-field svg { position: absolute; top: 50%; left: 10px; width: 15px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-field input {
  width: 100%;
  height: 44px;
  padding: 7px 10px 7px 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  font-size: 13px;
}

.case-list { display: grid; padding-bottom: 24px; }

.case-row {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.case-row:last-child { border-bottom: 1px solid var(--line); }
.case-row:hover { background: var(--paper); }
.case-row[aria-current="true"] { background: var(--paper); color: var(--accent); }
.case-row span, .case-row strong, .case-row small { display: block; }
.case-row strong { font-size: 13px; }
.case-row small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.case-row .review-status { display: flex; align-items: center; gap: 6px; }
.case-row .review-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--danger);
}
.case-result { min-width: 104px; text-align: right; }
.case-result strong { font-variant-numeric: tabular-nums; }
.empty-state { padding: 20px; color: var(--muted); text-align: center; }

.case-content { min-width: 0; overflow: auto; }
.case-content > section, .case-content > .loading { width: min(960px, calc(100% - 48px)); margin: 0 auto; }
.loading, .error-state { padding: 48px 0; color: var(--muted); }

.case-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 34px 0 20px;
}

.case-heading h1 { font-size: 25px; }
.case-controls { display: flex; gap: 6px; }
.case-controls button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  cursor: pointer;
}
.case-controls button:disabled { cursor: not-allowed; opacity: 0.35; }

.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.evidence-block { min-width: 0; padding: 22px 26px 22px 0; }
.evidence-block + .evidence-block { padding-right: 0; padding-left: 26px; border-left: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title h3 { margin: 0; font-size: 14px; }
.section-title span { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
blockquote { margin: 14px 0 0; color: oklch(0.32 0.02 245); font-family: ui-serif, Georgia, serif; font-size: 15px; line-height: 1.7; }
blockquote p { max-width: 70ch; margin: 0; }
blockquote p + p { margin-top: 12px; }

.source-row { min-height: 38px; padding: 9px 0; color: var(--muted); font-size: 11px; text-align: right; }
.source-row a { color: var(--accent); font-weight: 650; text-decoration: none; }

.judgment { margin-top: 24px; padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.judgment h2, .section-heading h2, .review-heading h2 { font-size: 18px; }
.judgment-values { display: grid; grid-template-columns: 0.7fr 1.3fr; gap: 28px; margin-top: 20px; }
.judgment-values > div { display: grid; gap: 4px; }
.judgment-values span { color: var(--muted); font-size: 11px; }
.judgment-values strong { font-size: 22px; line-height: 1.25; }
.route { font-size: 17px !important; }
.route.emergency { color: var(--danger); }
.route.urgent { color: var(--warning); }
.route.non_urgent { color: var(--success); }
.route.needs_data { color: var(--muted); }
.judgment-summary { max-width: 72ch; margin: 18px 0 0; font-size: 13px; line-height: 1.65; }
.findings { padding: 32px 0; border-bottom: 1px solid var(--line); }
.section-heading, .review-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.section-heading > span, .save-state { color: var(--muted); font-size: 11px; }
.table-wrap { margin-top: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: 0.06em; text-align: left; text-transform: uppercase; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td:first-child { width: 34%; }
td:last-child { width: 64px; }
td strong, td small { display: block; }
td q { color: oklch(0.38 0.02 245); }
td small { margin-top: 4px; color: var(--muted); text-transform: capitalize; }
.points { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.flag { display: inline-block; margin-top: 6px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 999px; font-size: 9px; font-weight: 750; text-transform: uppercase; }
.flag.emergency { color: var(--danger); }
.flag.urgent { color: var(--warning); }

.quiet { color: var(--muted); }

.review-section { padding: 30px 0 48px; }
.review-section form { margin-top: 18px; }
fieldset { margin: 0; padding: 0; border: 0; }
.decision-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.decision-options input { position: absolute; opacity: 0; pointer-events: none; }
.decision-options span { display: grid; min-height: 44px; place-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); cursor: pointer; font-size: 12px; font-weight: 650; }
.decision-options input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.decision-options input:focus-visible + span { outline: 3px solid oklch(0.72 0.1 242 / 0.55); outline-offset: 2px; }
.comment-field { display: grid; gap: 7px; margin-top: 16px; font-size: 12px; font-weight: 650; }
.comment-field small { color: var(--muted); font-weight: 400; }
textarea { width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); font-size: 13px; }
.review-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.text-button { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; text-decoration: underline; }
.text-button:disabled { cursor: not-allowed; opacity: 0.4; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 15; margin: 0; padding: 10px 14px; border-radius: 7px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 760px) {
  .topbar { padding-inline: 14px; }
  .shell { grid-template-columns: 1fr; }
  .case-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .case-panel-heading { padding-top: 16px; }
  .case-list { max-height: 250px; overflow-y: auto; }
  .case-content > section, .case-content > .loading { width: min(100% - 28px, 960px); }
  .evidence-grid { grid-template-columns: 1fr; }
  .evidence-block, .evidence-block + .evidence-block { padding: 18px 0; border-left: 0; }
  .evidence-block + .evidence-block { border-top: 1px solid var(--line); }
  .judgment-values { grid-template-columns: 1fr; gap: 14px; }
}

@media (max-width: 460px) {
  .top-actions > span { display: none; }
  .case-heading { padding-top: 24px; }
  .decision-options { grid-template-columns: 1fr; }
  .judgment { padding: 18px; }
  th:nth-child(2), td:nth-child(2) { min-width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
