/* A6 Review Web — self-contained stylesheet (no CDN, works offline).
   Light inspection-console theme. Decision colours follow the business
   semantics of the POC: GREEN = pass, RED = fail, YELLOW = needs review. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ec;
  --border-strong: #c3cddc;
  --text: #1c2430;
  --text-muted: #6b7686;
  --accent: #1f5fd0;
  --accent-weak: #e8f0fe;
  --green: #12885f;
  --green-bg: #e6f6ef;
  --red: #c62828;
  --red-bg: #fdeaea;
  --yellow: #a36300;
  --yellow-bg: #fdf3e0;
  --failed: #5a5f6b;
  --failed-bg: #eceef2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 32, 52, 0.06), 0 4px 12px rgba(20, 32, 52, 0.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

code {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

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

.small {
  font-size: 12px;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.topbar-title {
  font-size: 16px;
  margin: 0;
}

.topbar-sub {
  color: var(--text-muted);
}

.page {
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 12px;
  white-space: nowrap;
}

.badge-muted {
  color: var(--text-muted);
}

.badge-ok {
  color: var(--green);
  background: var(--green-bg);
  border-color: #b9e2d1;
}

.badge-warn {
  color: var(--yellow);
  background: var(--yellow-bg);
  border-color: #f0d9ac;
}

.badge-error {
  color: var(--red);
  background: var(--red-bg);
  border-color: #f2c6c6;
}

.decision-badge.is-green,
.review-auto-level.is-green,
.status-badge.status-decided {
  color: var(--green);
  background: var(--green-bg);
  border-color: #b9e2d1;
}

.decision-badge.is-red,
.review-auto-level.is-red,
.status-badge.status-technical_failed {
  color: var(--red);
  background: var(--red-bg);
  border-color: #f2c6c6;
}

.decision-badge.is-yellow,
.review-auto-level.is-yellow {
  color: var(--yellow);
  background: var(--yellow-bg);
  border-color: #f0d9ac;
}

.decision-badge.is-failed,
.review-auto-level.is-technical_failed,
.status-badge.status-partial_upload {
  color: var(--failed);
  background: var(--failed-bg);
  border-color: var(--border-strong);
}

/* ---------------------------------------------------------------- banners */

.banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  white-space: pre-line;
}

.banner-info {
  border-color: #bcd4f7;
  background: var(--accent-weak);
}

.banner-warn {
  border-color: #f0d9ac;
  background: var(--yellow-bg);
}

.banner-error {
  border-color: #f2c6c6;
  background: var(--red-bg);
}

.banner-title {
  display: block;
}

.banner-message {
  margin: 4px 0 0;
  color: var(--text);
}

.banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.panel-muted {
  background: var(--surface-2);
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 15px;
  margin: 0;
}

.panel-hint,
.panel-note {
  color: var(--text-muted);
  font-size: 12px;
  margin: 6px 0;
}

.panel-timeline.is-disabled {
  opacity: 0.6;
}

.panel-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.layout-cell {
  min-width: 0;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .review-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------- case head */

.case-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.case-title {
  margin: 0 0 6px;
  font-size: 18px;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.case-meta span {
  font-family: var(--mono);
}

.status-line {
  margin: 4px 0 0;
  font-weight: 600;
}

.progress-line {
  margin: 2px 0 0;
  font-size: 12px;
}

/* --------------------------------------------------------------- tables */

.case-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 2px;
}

.chip {
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.table-wrap {
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.grid th,
.grid td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* bank back-office: header stays visible while scrolling long case lists */
.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}

/* zebra rows improve row tracking across wide case tables */
.grid tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

.grid tbody tr:hover {
  background: var(--surface-2);
}

/* timestamps and numeric columns read better aligned and quiet */
.grid td:last-child {
  white-space: nowrap;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.case-link {
  font-family: var(--mono);
  color: var(--accent);
  text-decoration: none;
}

.case-link:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-small {
  padding: 4px 9px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
}

.link-btn {
  font: inherit;
  font-size: 12px;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}

.link-btn:hover {
  text-decoration: underline;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.input {
  font: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.input-inline {
  width: auto;
  max-width: 340px;
}

.select-label {
  font-size: 12px;
  color: var(--text-muted);
}

.checkbox-label,
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.steps {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.steps li {
  margin: 4px 0;
}

/* --------------------------------------------------------------- player */

.player-frame {
  background: #0d1117;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video {
  width: 100%;
  height: 100%;
  background: #0d1117;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.clock {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}

.player-state {
  margin: 8px 0 0;
  font-size: 12px;
}

.kbd-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.kbd-hint-label {
  font-weight: 600;
}

.kbd-hint-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kbd {
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
}

.inline-error,
.inline-warning {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.inline-error {
  background: var(--red-bg);
  border: 1px solid #f2c6c6;
  color: var(--red);
}

.inline-warning {
  background: var(--yellow-bg);
  border: 1px solid #f0d9ac;
  color: var(--yellow);
}

/* ----------------------------------------------------------- decision */

.decision-level {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  margin-bottom: 10px;
}

.decision-level.is-green {
  background: var(--green-bg);
  border-color: #b9e2d1;
  color: var(--green);
}

.decision-level.is-red {
  background: var(--red-bg);
  border-color: #f2c6c6;
  color: var(--red);
}

.decision-level.is-yellow {
  background: var(--yellow-bg);
  border-color: #f0d9ac;
  color: var(--yellow);
}

.decision-level.is-failed {
  background: var(--failed-bg);
  border-color: var(--border-strong);
  color: var(--failed);
}

.decision-level-text {
  font-size: 16px;
  font-weight: 700;
}

.decision-risk {
  font-family: var(--mono);
  font-size: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.field-grid-compact {
  margin-bottom: 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.field-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-value {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-word;
}

.field-is-green .field-value {
  color: var(--green);
}

.field-is-red .field-value {
  color: var(--red);
}

.field-is-yellow .field-value {
  color: var(--yellow);
}

.findings {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finding {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 8px 10px;
}

.finding summary {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.finding-rule {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
}

.finding-risk {
  color: var(--red);
  font-family: var(--mono);
  font-size: 12px;
}

.finding-ok {
  color: var(--green);
  font-family: var(--mono);
  font-size: 12px;
}

.finding-summary {
  color: var(--text-muted);
  font-size: 12px;
}

.finding-body {
  margin-top: 8px;
}

.evidence-refs {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.evidence-refs li {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.evidence-observation {
  color: var(--text-muted);
}

.tech-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #f2c6c6;
  background: var(--red-bg);
}

.tech-error-title {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--red);
}

.tech-error-message {
  margin: 0;
  font-size: 12px;
}

/* ----------------------------------------------------------- timeline */

.rail {
  position: relative;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
}

.rail-segments,
.rail-ticks {
  position: absolute;
  inset: 0;
}

.rail-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px dashed var(--border-strong);
}

.rail-segment.is-even {
  background: rgba(31, 95, 208, 0.04);
}

.rail-segment.is-odd {
  background: rgba(31, 95, 208, 0.09);
}

.rail-tick {
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 16px;
  background: var(--accent);
  transform: translateX(-1px);
}

.rail-tick.tick-door_crossing,
.rail-tick.tick-room_visible {
  height: 24px;
  background: var(--red);
}

.rail-tick.tick-low_quality {
  background: var(--yellow);
}

.rail-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #111;
  transform: translateX(-1px);
}

.rail-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend-event {
  background: var(--red);
}

.legend-boundary {
  background: var(--border-strong);
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.event-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1.4fr) minmax(0, 0.9fr) 48px 64px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}

.event-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.panel-timeline.is-disabled .event-row {
  cursor: default;
}

.event-row:hover {
  background: var(--surface-2);
}

.event-row.is-current {
  background: var(--accent-weak);
  box-shadow: inset 3px 0 0 var(--accent);
}

.event-time {
  font-family: var(--mono);
  font-weight: 600;
}

.event-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-value {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-confidence {
  font-family: var(--mono);
  color: var(--text-muted);
}

.thumb-button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

/* --------------------------------------------------------- thumbnails */

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.thumb-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}

.thumb-card.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #d9dee6;
}

.thumb-small {
  width: 64px;
  height: 36px;
  aspect-ratio: auto;
  border-radius: 3px;
}

.thumb-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  background: var(--failed-bg);
}

.thumb-card figcaption {
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thumb-meta {
  font-family: var(--mono);
  font-size: 11px;
}

/* -------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 36, 0.55);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: min(1000px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-title {
  margin: 0;
  font-size: 15px;
}

.modal-media {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.modal-image {
  max-width: 100%;
  border-radius: 6px;
  background: #d9dee6;
}

.bbox-layer {
  position: absolute;
  inset: 0;
}

.bbox-box {
  position: absolute;
  border: 2px solid #ff3b30;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  border-radius: 2px;
}

.modal-caption {
  margin-top: 10px;
  font-size: 12px;
}

.modal-meta {
  margin: 2px 0;
  font-family: var(--mono);
}

.ocr-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

/* ---------------------------------------------------------- reasoning */

.reasoning-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reasoning-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.reasoning-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.reasoning-question {
  font-family: var(--mono);
  font-weight: 600;
}

.reasoning-status {
  font-size: 12px;
  color: var(--text-muted);
}

.reasoning-confidence {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.reasoning-question-text,
.reasoning-reason,
.reasoning-allowed {
  margin: 6px 0 0;
  font-size: 12px;
}

.reasoning-conclusion {
  margin: 6px 0 0;
  font-weight: 600;
}

.reasoning-subtitle {
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reasoning-evidence {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reasoning-evidence li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.reasoning-evidence.is-contradictory .evidence-frame {
  color: var(--red);
}

.evidence-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.evidence-frame {
  font-family: var(--mono);
  font-size: 11px;
}

/* ------------------------------------------------------------- review */

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.review-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.review-subtitle {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.review-auto-level {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.review-auto-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--mono);
  font-size: 12px;
}

.review-human-line {
  margin: 0 0 4px;
  font-weight: 600;
}

.review-human-changed {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
}

.review-comment {
  margin: 6px 0 0;
  white-space: pre-wrap;
  background: var(--surface);
  border-left: 3px solid var(--border-strong);
  padding: 6px 8px;
  font-size: 12px;
}

.review-version {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.comment-counter {
  margin: 4px 0 0;
  font-size: 12px;
  text-align: right;
}

.comment-counter.is-near-limit {
  color: var(--yellow);
}

.comment-counter.is-at-limit {
  color: var(--red);
  font-weight: 600;
}

.review-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.form-label {
  min-width: 88px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 6px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.error-list {
  margin: 0;
  padding-left: 18px;
  color: var(--red);
  font-size: 12px;
}

.review-submit-status {
  font-size: 12px;
}
