:root {
  --bg: #edf2f4;
  --panel: #fff;
  --ink: #17262d;
  --muted: #6e7f87;
  --line: #d5e0e5;
  --navy: #122a33;
  --accent: #237d89;
  --accent-strong: #185f68;
  --green: #1e7f4e;
  --amber: #b87511;
  --red: #a94343;
  --shadow: 0 14px 34px rgba(15, 34, 43, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
.hidden { display: none !important; }
.eyebrow { color: #58a4ae; font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg,#dce8ec,#eef3f5); }
.login-card { width: min(520px, 100%); padding: 28px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.login-card h1 { margin: 6px 0 10px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
.login-card label { display: grid; gap: 6px; font-size: 12px; font-weight: 800; }
.login-card input { padding: 11px 12px; border: 1px solid #bfd0d7; border-radius: 9px; outline: none; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,125,137,.12); }
.error-text { margin-top: 12px; color: var(--red); font-size: 13px; font-weight: 700; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 22px 28px; background: var(--navy); color: white; }
.topbar h1 { margin: 4px 0 4px; font-size: 24px; }
.topbar p { margin: 0; color: #bfd2d8; font-size: 13px; }
.top-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { padding: 7px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); font-size: 11px; font-weight: 800; }

.button { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 850; transition: transform .12s ease, background .12s ease; }
.button:not(:disabled):hover { transform: translateY(-1px); }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { background: white; color: #31464e; border: 1px solid #c5d3d9; }
.button.ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,.35); }

.statusbar { display: grid; grid-template-columns: repeat(4,1fr); background: white; border-bottom: 1px solid var(--line); }
.statusbar > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 20px; border-right: 1px solid #edf1f3; }
.statusbar > div:last-child { border-right: 0; }
.statusbar span { color: var(--muted); font-size: 11px; font-weight: 700; }
.statusbar strong { font-size: 14px; }

.page-shell { width: min(1680px, calc(100% - 36px)); margin: 20px auto 60px; }
.source-panel, .output-card, .results-panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.source-panel { margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 4px 0 0; font-size: 18px; }
.source-badge { padding: 6px 9px; border-radius: 999px; background: #e8f1f3; color: #47666f; font-size: 10px; font-weight: 850; }
.source-text { margin: 0; padding: 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.65; background: #fbfcfd; }
.review-intro { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 0 2px 12px; }
.review-intro h2 { margin: 4px 0 0; font-size: 18px; }
.review-intro p { margin: 0; color: var(--muted); font-size: 12px; }

.outputs-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.output-card { overflow: hidden; min-width: 0; }
.output-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.output-head h3 { margin: 4px 0 0; font-size: 17px; }
.raw-badge { padding: 5px 8px; border-radius: 999px; background: #edf3f5; color: #59717a; font-size: 10px; font-weight: 850; }
.output-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 16px; background: #f4f8f9; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 800; }
.raw-toggle { border: 1px solid #b8cbd2; border-radius: 8px; padding: 6px 9px; background: white; color: var(--accent-strong); font-size: 11px; font-weight: 850; }
.readable-output { padding: 14px 16px; background: #fbfcfd; }
.readable-note { margin-bottom: 10px; padding: 8px 10px; border-left: 3px solid var(--accent); background: #eef6f7; color: #536a72; font-size: 11px; line-height: 1.45; }
.readable-section { padding: 9px 0; border-bottom: 1px solid #e4eaed; }
.readable-section:last-child { border-bottom: 0; }
.readable-section h4 { margin: 0 0 6px; font-size: 12px; color: #29454e; }
.readable-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.55; }
.empty-extraction { margin: 0; color: #89979d; font-size: 12px; font-style: italic; }
.raw-output { margin: 0; padding: 16px; max-height: 520px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.55; background: #fbfcfd; border-top: 1px solid var(--line); }

.rating-panel { padding: 14px 16px 16px; border-top: 1px solid var(--line); background: #f8fafb; }
.rating-intro { margin: 0 0 12px; font-size: 12px; color: #465d65; font-weight: 800; }
.rating-dimension { margin: 0 0 12px; }
.rating-dimension legend { margin-bottom: 6px; padding: 0; font-size: 11px; font-weight: 850; color: #344b53; }
.segmented { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.segmented.four { grid-template-columns: repeat(4,minmax(0,1fr)); }
.choice { min-height: 38px; padding: 7px 8px; border: 1px solid #c8d5da; border-radius: 8px; background: white; color: #334951; font-size: 11px; font-weight: 800; }
.choice.selected { border-color: var(--accent); background: var(--accent); color: white; box-shadow: 0 5px 12px rgba(35,125,137,.18); }
.rating-panel label.notes { display: grid; gap: 6px; color: #536870; font-size: 11px; font-weight: 800; }
.rating-panel textarea { min-height: 68px; resize: vertical; padding: 9px 10px; border: 1px solid #c5d3d9; border-radius: 8px; outline: none; font-size: 12px; }
.rating-panel textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,125,137,.1); }

.review-navigation { position: sticky; bottom: 12px; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 18px; padding: 11px; background: rgba(255,255,255,.95); border: 1px solid #c9d6db; border-radius: 13px; box-shadow: 0 14px 34px rgba(15,34,43,.13); backdrop-filter: blur(10px); }
.review-navigation > :last-child { justify-self: end; }
.loading-card { grid-column: 1/-1; min-height: 240px; display: grid; place-items: center; color: var(--muted); font-weight: 800; background: white; border: 1px solid var(--line); border-radius: var(--radius); }

.results-panel { width: min(1400px, calc(100% - 36px)); margin: 20px auto 50px; padding: 20px; }
.results-panel h2 { margin: 4px 0 16px; }
.results-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.result-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; }
.result-card h3 { margin: 4px 0 8px; }
.result-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; font-size: 12px; }
.result-metrics div { padding: 8px; border-radius: 8px; background: #f0f5f6; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: 520px; padding: 12px 14px; border-radius: 10px; background: #243a43; color: white; box-shadow: var(--shadow); font-size: 13px; font-weight: 750; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

@media (max-width: 1100px) {
  .outputs-grid, .results-grid { grid-template-columns: 1fr; }
  .statusbar { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .page-shell { width: calc(100% - 20px); }
  .review-intro { align-items: flex-start; flex-direction: column; }
  .segmented, .segmented.four { grid-template-columns: 1fr; }
  .review-navigation { grid-template-columns: 1fr 1fr; }
  #saveNextBtn { grid-column: 1/-1; grid-row: 1; }
}

.case-triage {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 14px 20px;
  align-items: center;
  margin: 0 0 20px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.case-triage-copy h2 { margin: 4px 0 6px; font-size: 18px; }
.case-triage-copy p { margin: 0; max-width: 820px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.case-triage-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.skip-button { background: #f5f8f9; color: #31464e; border: 1px solid #bfd0d7; }
.skip-button:hover { background: #edf4f5; }
.skip-button.selected { color: white; border-color: var(--amber); background: var(--amber); box-shadow: 0 5px 12px rgba(184,117,17,.18); }
.case-decision-notice { grid-column: 1/-1; padding: 9px 11px; border-left: 3px solid var(--amber); background: #fff7e8; color: #6f531f; font-size: 12px; font-weight: 800; line-height: 1.45; }
.outputs-grid.case-skipped { opacity: .58; }
.outputs-grid.case-skipped .output-card { box-shadow: none; }

.result-coverage { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 800; }
.skip-results { margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd; }
.skip-results h3 { margin: 4px 0 8px; }
.skip-results p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.skip-reviewer-list { margin: 10px 0 0; padding-left: 18px; color: #425b64; font-size: 12px; line-height: 1.6; }

@media (max-width: 900px) {
  .case-triage { grid-template-columns: 1fr; }
  .case-triage-actions { justify-content: flex-start; }
}
