:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #687773;
  --line: #d7dfdc;
  --paper: #f5f7f5;
  --panel: #ffffff;
  --green: #1f6b55;
  --green-dark: #164d3e;
  --amber: #9b5c08;
  --amber-bg: #fff6df;
  --red: #a13b32;
  --red-bg: #fff0ed;
  --blue: #2e5c85;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef3ef; }
.login-panel { width: min(420px, 100%); padding: 42px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 28px rgba(24, 52, 42, .08); }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: 1.5px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 32px; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 24px; }
h3 { margin-bottom: 0; font-size: 16px; }
.login-note, .quiet-label { color: var(--muted); }
.login-note { margin-bottom: 30px; }
label { display: grid; gap: 7px; color: #41504b; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #c9d4d0; background: #fff; color: var(--ink); padding: 10px 11px; border-radius: 3px; outline: none; }
textarea { resize: vertical; min-height: 38px; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(31, 107, 85, .12); }
#login-form { display: grid; gap: 18px; }
.primary-button, .secondary-button, .link-button, .back-button, .icon-button, .action-button { border: 0; border-radius: 3px; }
.primary-button { color: white; background: var(--green); padding: 10px 15px; font-weight: 700; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { color: var(--green-dark); background: #e7efeb; padding: 9px 13px; font-weight: 700; }
.secondary-button:hover { background: #dbe9e3; }
.link-button, .back-button { color: var(--green); background: transparent; padding: 4px 0; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); }
.topbar { height: 62px; display: flex; align-items: center; gap: 38px; padding: 0 32px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 27px; height: 27px; color: #fff; background: var(--green); border-radius: 4px; font-weight: 800; }
.topnav { display: flex; align-self: stretch; gap: 22px; }
.nav-button { position: relative; border: 0; background: transparent; color: var(--muted); padding: 0; font-weight: 700; }
.nav-button.active { color: var(--ink); }
.nav-button.active::after { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: var(--green); content: ""; }
.session-label { display: flex; align-items: center; gap: 14px; margin-left: auto; color: var(--muted); }
main { max-width: 1500px; margin: 0 auto; padding: 32px; }
.page-heading, .workbench-heading, .list-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 22px; }
.upload-strip { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--panel); border: 1px solid var(--line); }
.upload-estimate { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.admin-tools { margin-top: 14px; padding: 12px 14px; background: #eef1f0; border: 1px solid var(--line); color: var(--muted); }
.admin-tools summary { cursor: pointer; font-weight: 700; }
.admin-form { display: flex; align-items: end; gap: 10px; margin-top: 12px; }
.admin-form label { flex: 1; }
.file-picker { display: inline-flex; align-items: center; width: auto; color: var(--green-dark); background: #e7efeb; padding: 10px 13px; border-radius: 3px; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker:focus-within { outline: 2px solid rgba(31, 107, 85, .35); outline-offset: 2px; }
.file-name { min-width: 220px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-list { display: grid; gap: 10px; margin-top: 22px; }
.task-row { display: grid; grid-template-columns: minmax(200px, 1.8fr) 170px 180px 160px auto; align-items: center; gap: 18px; padding: 18px; background: var(--panel); border: 1px solid var(--line); }
.task-title { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { color: var(--muted); font-size: 12px; }
.task-actions { display: flex; justify-self: end; gap: 7px; }
.delete-task-button { border: 1px solid #e5c7c3; border-radius: 3px; padding: 9px 11px; color: var(--red); background: var(--red-bg); font-weight: 700; }
.delete-task-button:hover { background: #f9ddd8; }
.delete-task-button:disabled { cursor: not-allowed; opacity: .4; }
.status { display: inline-flex; width: fit-content; align-items: center; padding: 4px 7px; border-radius: 3px; color: var(--green-dark); background: #e6f1eb; font-size: 12px; font-weight: 750; }
.status.warning { color: var(--amber); background: var(--amber-bg); }
.status.error { color: var(--red); background: var(--red-bg); }
.workbench-heading { margin-bottom: 18px; }
.workbench-heading h2 { min-width: 0; margin-top: 10px; overflow-wrap: anywhere; }
.workbench-actions { display: flex; gap: 9px; }
.review-action-status { min-height: 18px; margin: -10px 0 16px; color: var(--amber); font-size: 12px; font-weight: 650; text-align: right; }
.review-action-status.ready { color: var(--green-dark); }
.export-status { margin: -7px 0 16px; padding: 10px 12px; color: var(--green-dark); background: #e7efeb; border-left: 3px solid var(--green); overflow-wrap: anywhere; }
.export-status a { color: var(--green-dark); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.export-history { margin: -7px 0 16px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.lineage-panel { margin: -3px 0 18px; padding: 12px 14px; background: #f0f5f2; border: 1px solid var(--line); }
.lineage-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.lineage-origin { color: var(--amber); font-size: 12px; font-weight: 750; }
.lineage-grid { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 5px 12px; color: var(--muted); font-size: 12px; }
.lineage-grid code { color: var(--ink); overflow-wrap: anywhere; }
.back-button { font-size: 12px; }
.coverage-banner { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; padding: 14px 16px; color: var(--amber); background: var(--amber-bg); border: 1px solid #e9ca87; }
.coverage-banner span { color: #76521d; }
.analysis-progress { margin-bottom: 16px; padding: 14px 16px; background: #f0f5f2; border: 1px solid var(--line); }
.analysis-progress-heading, .analysis-progress-meta { display: flex; justify-content: space-between; gap: 16px; }
.analysis-progress-heading { margin-bottom: 9px; }
.analysis-progress-heading span, .analysis-progress-meta { color: var(--muted); font-size: 12px; }
.analysis-progress progress { display: block; width: 100%; height: 8px; margin-bottom: 8px; accent-color: var(--green); }
#analysis-error { color: var(--red); text-align: right; }
.analysis-recovery { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 13px; padding-top: 13px; border-top: 1px solid #d3ddd8; color: #76521d; font-size: 12px; }
.analysis-recovery .primary-button { flex: 0 0 auto; }
.state-strip { display: flex; align-items: center; gap: 4px; overflow-x: auto; margin-bottom: 18px; padding: 0 1px 2px; }
.state-step { display: flex; align-items: center; gap: 7px; color: #83918c; font-size: 12px; white-space: nowrap; }
.state-step::after { display: block; width: 22px; height: 1px; margin-left: 3px; background: var(--line); content: ""; }
.state-step:last-child::after { display: none; }
.state-step.active { color: var(--green); font-weight: 800; }
.state-dot { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.state-step.active .state-dot { background: currentColor; }
.workbench-grid { display: grid; grid-template-columns: minmax(420px, .95fr) minmax(600px, 1.35fr); gap: 20px; align-items: start; }
.video-pane, .findings-pane { min-width: 0; background: var(--panel); border: 1px solid var(--line); }
.video-pane { padding: 16px; }
.findings-pane { padding: 16px; }
.video-frame { background: #101513; aspect-ratio: 16 / 9; display: grid; place-items: center; }
video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-controls { display: grid; grid-template-columns: 1fr auto auto; align-items: end; gap: 10px; padding: 14px 0 12px; border-bottom: 1px solid var(--line); }
.time-readout { align-self: end; padding-bottom: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.watch-confirm { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 0; }
.watch-confirm label { display: flex; grid-template-columns: none; align-items: center; gap: 8px; color: var(--ink); }
.watch-confirm input { width: 16px; height: 16px; accent-color: var(--green); }
.add-finding-panel { padding-top: 16px; border-top: 1px solid var(--line); }
.panel-heading { margin-bottom: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.add-finding-panel > .secondary-button { margin-top: 13px; }
.list-heading { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.list-heading .quiet-label { font-size: 12px; }
.finding-list { display: grid; gap: 9px; padding-top: 10px; }
.finding-row { display: grid; grid-template-columns: 66px minmax(108px, 120px) minmax(0, 1fr) minmax(0, 1fr) 82px; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-left: 3px solid #c8d3cf; }
.finding-row.high { border-left-color: #bb5146; }
.finding-row.medium { border-left-color: #c08a2e; }
.finding-row.low { border-left-color: #6a9b80; }
.finding-row.coverage { background: var(--amber-bg); border-color: #e9ca87; }
.finding-time { color: var(--green); font-weight: 800; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.finding-tag { min-width: 0; color: var(--muted); font-size: 12px; }
.finding-tag strong { display: block; color: var(--ink); font-size: 12px; overflow-wrap: anywhere; }
.finding-copy { min-width: 0; line-height: 1.45; }
.finding-copy .label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.finding-copy p { margin-bottom: 10px; overflow-wrap: anywhere; }
.finding-thumb { width: 82px; height: 54px; border: 1px solid var(--line); background: #eef2f0; object-fit: cover; cursor: zoom-in; }
.thumb-empty { display: grid; place-items: center; width: 82px; height: 54px; color: var(--muted); background: #eef2f0; font-size: 11px; text-align: center; }
.finding-actions { grid-column: 1 / -1; display: flex; gap: 6px; padding-top: 9px; border-top: 1px solid #e4eae7; }
.action-button { padding: 6px 9px; color: var(--green-dark); background: #edf3f0; font-size: 12px; }
.action-button:hover { background: #dceae4; }
.action-button.reject { color: var(--red); background: #fff0ed; }
.action-button.follow { color: var(--amber); background: #fff6df; }
.edit-dialog { width: min(600px, calc(100% - 32px)); border: 1px solid var(--line); padding: 22px; box-shadow: 0 20px 60px rgba(17, 37, 29, .22); }
.edit-dialog::backdrop { background: rgba(12, 26, 20, .35); }
.edit-dialog form { display: grid; gap: 16px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.icon-button, .image-close { color: var(--muted); background: transparent; font-size: 25px; line-height: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.image-dialog { max-width: min(92vw, 1200px); max-height: 92vh; padding: 14px; border: 0; background: #101513; }
.image-dialog::backdrop { background: rgba(8, 17, 13, .78); }
.image-dialog img { display: block; max-width: 88vw; max-height: 82vh; object-fit: contain; }
.image-close { position: absolute; top: 10px; right: 12px; color: #fff; }

@media (max-width: 1050px) {
  .workbench-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 17px; padding: 15px 18px 0; }
  .topnav { order: 3; width: 100%; height: 40px; }
  .session-label { margin-left: auto; }
  main { padding: 22px 14px; }
  .upload-strip { align-items: stretch; flex-direction: column; }
  .admin-form { align-items: stretch; flex-direction: column; }
  .file-name { min-width: 0; }
  .task-row { grid-template-columns: 1fr; gap: 8px; }
  .task-row .primary-button { justify-self: start; }
  .task-actions { justify-self: start; }
  .workbench-heading { align-items: flex-start; flex-direction: column; }
  .workbench-actions { width: 100%; }
  .workbench-actions button { flex: 1; }
  .review-action-status { text-align: left; }
  .lineage-grid { grid-template-columns: 100px minmax(0, 1fr); }
  .coverage-banner { align-items: flex-start; flex-direction: column; gap: 6px; }
  .analysis-progress-meta, .analysis-recovery { align-items: flex-start; flex-direction: column; }
  #analysis-error { text-align: left; }
  .video-controls { grid-template-columns: 1fr auto; }
  .time-readout { grid-column: 1 / -1; padding-bottom: 0; }
  .finding-row { grid-template-columns: 1fr 82px; }
  .finding-time, .finding-tag, .finding-copy, .finding-copy.suggestion { grid-column: 1; }
  .finding-thumb, .thumb-empty { grid-column: 2; grid-row: 1 / span 3; }
  .finding-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}
