:root {
  --ink: #15202b;
  --muted: #5e6c78;
  --line: #d9e1e5;
  --panel: #ffffff;
  --canvas: #f4f7f7;
  --teal: #006b6c;
  --teal-dark: #004f50;
  --blue: #1e5d8c;
  --amber: #976400;
  --red: #a63636;
  --green: #23734d;
  --shadow: 0 1px 2px rgb(20 32 43 / 8%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
body.lightbox-open { overflow: hidden; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px max(24px, calc((100vw - 1440px) / 2));
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand, .event-row-head, .detail-header, .detail-actions, .section-heading, .pane-heading, .form-actions { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark { width: 28px; height: 28px; border: 7px solid var(--teal); border-left-color: var(--blue); display: inline-block; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; font-weight: 700; letter-spacing: 0; }
h2 { font-size: 18px; letter-spacing: 0; }
h3 { font-size: 15px; letter-spacing: 0; }
.eyebrow { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

.token-form { display: flex; align-items: center; gap: 8px; }
.token-form label { color: var(--muted); white-space: nowrap; }
.token-form input { width: 188px; }

.shell { max-width: 1440px; margin: 0 auto; padding: 20px 24px 32px; }
.intake, .event-pane, .detail-pane { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.intake { padding: 20px; margin-bottom: 20px; }
.section-heading, .pane-heading, .detail-header { justify-content: space-between; gap: 16px; }
.section-heading.compact { margin-bottom: 14px; }

.event-form { display: grid; grid-template-columns: minmax(210px, 2fr) minmax(150px, 1fr) minmax(130px, .8fr) minmax(130px, .8fr) minmax(190px, 1fr) auto; gap: 12px; align-items: end; margin-top: 16px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
input, select, textarea { min-width: 0; width: 100%; padding: 8px 9px; color: var(--ink); background: #fff; border: 1px solid #b9c6cc; border-radius: 4px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgb(0 107 108 / 15%); }
textarea { resize: vertical; }
.file-input input { padding: 6px; }
.test-samples { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.test-sample-list { display: grid; gap: 14px; }
.test-sample-group { display: grid; gap: 7px; }.test-sample-group h4 { margin: 0; color: var(--teal-dark); font-size: 13px; overflow-wrap: anywhere; }.test-sample-group-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.test-sample { display: grid; gap: 3px; min-height: 68px; padding: 10px; text-align: left; color: var(--teal-dark); background: #f4f9f9; border-color: #b9cecf; }
.test-sample:hover { background: #e8f3f3; border-color: var(--teal); }
.test-sample strong, .test-sample span { display: block; overflow-wrap: anywhere; }.test-sample span { color: var(--muted); font-size: 12px; font-weight: 400; }

button { min-height: 36px; border: 1px solid transparent; border-radius: 4px; padding: 7px 12px; font-weight: 650; }
.primary { color: #fff; background: var(--teal); }
.primary:hover { background: var(--teal-dark); }
.secondary { color: var(--teal-dark); background: #fff; border-color: #a9c1c2; }
.secondary:hover { background: #eef7f7; }
.icon-button { width: 34px; padding: 0; font-size: 20px; color: var(--teal-dark); background: #fff; border-color: var(--line); }

.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.event-pane { min-height: 560px; padding: 16px; }
.filter-label { margin-top: 16px; }
.bulk-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.bulk-select { display: flex; grid-template-columns: none; align-items: center; gap: 7px; min-width: 0; color: var(--ink); font-size: 12px; cursor: pointer; }
.bulk-select input, .event-check input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--teal); }
.danger-button { min-height: 32px; padding: 5px 8px; color: var(--red); background: #fff; border-color: #d9b2b2; font-size: 12px; white-space: nowrap; }
.danger-button:hover:not(:disabled) { color: #fff; background: var(--red); }
.event-list { display: grid; gap: 7px; margin-top: 12px; }
.event-row { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr) 34px; min-height: 68px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.event-row:hover, .event-row[aria-current="true"] { border-color: var(--teal); background: #f1f8f8; }
.event-row:has(.event-checkbox:checked) { border-color: var(--blue); background: #edf5fa; }
.event-check { display: flex; align-items: center; justify-content: center; min-width: 0; cursor: pointer; }
.event-check:has(input:disabled) { cursor: not-allowed; }
.event-row-select { display: grid; gap: 4px; width: 100%; min-width: 0; min-height: 66px; padding: 9px 8px 9px 10px; text-align: left; color: inherit; background: transparent; border: 0; border-radius: 0; }
.event-delete { align-self: center; width: 28px; min-height: 28px; padding: 0; color: var(--red); background: transparent; border-color: transparent; font-size: 20px; line-height: 1; }
.event-delete:hover:not(:disabled) { background: #fbe9e9; border-color: #e1baba; }
.event-row-head { justify-content: space-between; gap: 8px; }
.event-row-select strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row-time { color: var(--muted); font-size: 12px; }

.detail-pane { min-height: 560px; padding: 20px; }
.empty-state { min-height: 500px; display: grid; align-content: center; justify-items: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state h2 { color: var(--ink); }
.detail-header { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-actions { gap: 10px; }
.status-chip, .risk-chip { display: inline-flex; align-items: center; width: fit-content; min-height: 24px; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-queued, .status-running { color: var(--blue); background: #e8f2f9; }
.status-waiting_review { color: var(--amber); background: #fff4d9; }
.status-normal, .status-closed { color: var(--green); background: #e5f5ed; }
.status-failed { color: var(--red); background: #fbe9e9; }
.risk-none { color: #47606a; background: #e9eff1; }.risk-low { color: #386d23; background: #e9f3e4; }.risk-medium { color: #875600; background: #fff1cc; }.risk-high { color: #962f2f; background: #f9e4e4; }
.notice { margin: 16px 0 0; padding: 10px 12px; color: #7a3600; background: #fff1e6; border-left: 3px solid #c46b17; }
.progress-panel { display: grid; gap: 2px; margin: 16px 0 0; padding: 11px 13px; color: var(--teal-dark); background: #edf8f7; border: 1px solid #b9d8d6; border-left: 3px solid var(--teal); }
.progress-panel strong { font-size: 15px; }
.progress-panel .muted { font-size: 12px; }

.detail-grid { display: grid; grid-template-columns: minmax(280px, .9fr) minmax(280px, 1.1fr); gap: 20px; padding: 20px 0; }
.source-panel { margin: 0; min-height: 270px; background: #12232a; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.source-panel img { display: block; max-width: 100%; width: 100%; max-height: 440px; min-height: 230px; object-fit: contain; cursor: zoom-in; }
.source-panel figcaption { padding: 8px 10px; color: #dce7e9; font-size: 12px; overflow-wrap: anywhere; }
.image-lightbox { position: fixed; inset: 0; z-index: 1000; display: none; place-items: center; padding: 24px; }
.image-lightbox.is-open { display: grid; }
.image-lightbox-backdrop { position: absolute; inset: 0; background: rgb(7 18 23 / 78%); cursor: zoom-out; }
.image-lightbox-content { position: relative; z-index: 1; display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(1200px, 96vw); height: min(900px, 94vh); padding: 10px; background: #101c21; border: 1px solid #60757b; box-shadow: 0 12px 40px rgb(0 0 0 / 35%); }
.image-lightbox-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 2px 10px; color: #e8f1f2; }
.image-lightbox-toolbar .icon-button { color: #e8f1f2; background: transparent; border-color: #60757b; }
.image-lightbox-content img { display: block; width: 100%; height: 100%; object-fit: contain; }
.facts-panel { display: grid; align-content: start; gap: 20px; }
.facts-panel section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.facts-panel section:first-child { padding-top: 0; }
.fact-list { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr); gap: 7px 12px; margin: 12px 0 0; }
.fact-list dt { color: var(--muted); }.fact-list dd { margin: 0; overflow-wrap: anywhere; }

.evidence-section, .assessment-section, .review-form { border-top: 1px solid var(--line); padding: 20px 0; }
.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
details { border: 1px solid var(--line); border-radius: 4px; background: #fbfcfc; }
summary { padding: 10px; color: var(--ink); font-weight: 650; cursor: pointer; }
pre { max-height: 280px; margin: 0; padding: 0 10px 10px; overflow: auto; color: #263942; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.readable-evidence { display: grid; gap: 14px; padding: 0 10px 12px; }
.evidence-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 11px; background: #f1f7f6; border-left: 3px solid var(--teal); }
.evidence-summary p { font-weight: 650; }
.evidence-status { flex: 0 0 auto; padding: 2px 7px; border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.evidence-status-success { color: var(--green); background: #e5f5ed; }
.evidence-status-partial { color: var(--amber); background: #fff4d9; }
.evidence-status-failed { color: var(--red); background: #fbe9e9; }
.evidence-facts { display: grid; grid-template-columns: minmax(90px, 130px) minmax(0, 1fr); gap: 6px 12px; margin: 0; }
.evidence-facts dt { color: var(--muted); }
.evidence-facts dd { margin: 0; overflow-wrap: anywhere; }
.evidence-table-wrap { max-width: 100%; overflow-x: auto; }
.evidence-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.evidence-table th, .evidence-table td { min-width: 90px; padding: 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.evidence-table th { color: var(--muted); background: #f7f9f9; font-weight: 650; }
.evidence-table tbody tr:last-child td { border-bottom: 0; }
.assessment-summary { max-width: 920px; padding: 12px 14px; background: #eff6f6; border-left: 3px solid var(--teal); }
.review-items { display: grid; gap: 8px; margin-top: 14px; }
.review-item { padding: 11px 12px; border: 1px solid var(--line); border-left: 3px solid var(--blue); background: #fff; }
.review-item h4 { margin: 0 0 4px; font-size: 13px; }.review-item p { color: var(--muted); }

.action-segment { display: flex; gap: 0; width: fit-content; max-width: 100%; margin: 0 0 16px; padding: 0; overflow: hidden; border: 1px solid #9ab4b6; border-radius: 4px; }
.action-segment label { display: block; padding: 8px 12px; color: var(--teal-dark); border-right: 1px solid #9ab4b6; cursor: pointer; }.action-segment label:last-child { border-right: 0; }.action-segment input { position: absolute; opacity: 0; pointer-events: none; }.action-segment label:has(input:checked) { color: #fff; background: var(--teal); }
.item-decisions { display: grid; gap: 9px; margin-bottom: 16px; }
.decision-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 130px minmax(180px, 1fr); gap: 10px; align-items: end; padding: 10px; background: #f7faf9; border: 1px solid var(--line); }
.decision-text { align-self: center; }.decision-text strong, .decision-text span { display: block; }.decision-text span { color: var(--muted); font-size: 12px; }
.closing-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }.full-width { grid-column: 1 / -1; }
.form-actions { justify-content: space-between; gap: 16px; margin-top: 16px; }.form-message { color: var(--red); }.form-message.success { color: var(--green); }

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

@media (max-width: 960px) {
  .event-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }.event-form .primary { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; }.event-pane { min-height: auto; }.event-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }.detail-pane { min-height: 0; }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }.token-form { width: 100%; }.token-form input { flex: 1; width: auto; }.shell { padding: 14px 16px 24px; }.intake, .detail-pane, .event-pane { padding: 14px; }.event-form, .test-sample-group-list, .detail-grid, .evidence-grid, .closing-fields { grid-template-columns: 1fr; }.detail-header, .section-heading { align-items: flex-start; flex-direction: column; }.detail-actions { width: 100%; justify-content: space-between; }.action-segment { display: grid; width: 100%; }.action-segment label { border-right: 0; border-bottom: 1px solid #9ab4b6; }.action-segment label:last-child { border-bottom: 0; }.decision-row { grid-template-columns: 1fr; }.form-actions { align-items: stretch; flex-direction: column; }.form-actions button { width: 100%; }
}
