:root {
  color-scheme: dark;
  --bg: #0b1016;
  --panel: #111923;
  --panel-2: #16212d;
  --line: #2b3a49;
  --text: #e9f0f6;
  --muted: #8ea0b1;
  --cyan: #24c7d9;
  --green: #43d17a;
  --yellow: #f3ca52;
  --red: #ff626b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-header { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); background: #0d141c; }
.app-header h1 { margin: 2px 0 0; font-size: 21px; font-weight: 600; }
.eyebrow { color: var(--cyan); font-size: 10px; letter-spacing: 0.18em; }
.health { color: var(--muted); font-size: 13px; }
.health.ok { color: var(--green); }
.header-actions { display: flex; align-items: center; gap: 16px; }
.auth-panel { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.auth-panel input { width: 170px; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: #070c12; color: var(--text); padding: 0 9px; }
.auth-panel .button { min-height: 34px; }
.hidden { display: none !important; }

.steps { display: flex; gap: 8px; padding: 14px 24px 0; }
.step { border: 1px solid var(--line); border-radius: 8px 8px 0 0; background: #0e151d; color: var(--muted); padding: 10px 20px; cursor: pointer; }
.step span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; border: 1px solid currentColor; border-radius: 50%; font-size: 12px; }
.step.active { color: var(--text); background: var(--panel); border-bottom-color: var(--panel); }
.step.active span { color: #061116; background: var(--cyan); border-color: var(--cyan); }

main { padding: 0 24px 24px; }
.step-page { display: none; }
.step-page.active { display: block; }
.toolbar { min-height: 62px; display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.toolbar-status { margin-left: auto; color: var(--muted); font-size: 13px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; border: 1px solid #3a4a5a; border-radius: 6px; background: #1b2632; color: var(--text); text-decoration: none; cursor: pointer; }
.button:hover:not(:disabled) { border-color: #63788c; }
.button:disabled, .button.disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }
.button.primary { color: #061216; border-color: var(--cyan); background: var(--cyan); }
.button.success { color: #07150e; border-color: var(--green); background: var(--green); }
.button.danger { color: white; border-color: #a83f49; background: #7e2f38; }
.button.quiet { background: transparent; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 410px; height: 650px; min-height: 0; border: 1px solid var(--line); background: var(--panel); }
.viewer-panel { position: relative; min-width: 0; overflow: hidden; background: #05080b; }
.viewer-panel canvas { width: 100%; height: 100%; min-height: 650px; display: block; cursor: grab; }
.viewer-panel canvas:active { cursor: grabbing; }
.viewer-hint { position: absolute; left: 12px; bottom: 10px; padding: 5px 9px; border-radius: 4px; background: rgba(0,0,0,.65); color: #a9b7c4; font-size: 11px; pointer-events: none; }
.side-panel { min-width: 0; min-height: 0; overflow: hidden; border-left: 1px solid var(--line); background: #0f1720; display: flex; flex-direction: column; }
.panel-section { padding: 16px; border-bottom: 1px solid var(--line); }
.panel-section h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.panel-section h2 span { color: var(--cyan); }
.table-section { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title-row h2 { margin: 0; }
.search { min-width: 110px; height: 32px; border: 1px solid var(--line); border-radius: 5px; background: #0a1118; color: var(--text); padding: 0 9px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.form-grid label:first-child { grid-column: 1 / -1; }
.form-grid input { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: #0a1118; color: var(--text); padding: 0 9px; }
.button-row { display: flex; gap: 8px; margin-top: 12px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }

.table-scroll { margin-top: 12px; overflow: auto; min-height: 0; flex: 1; border: 1px solid #22303d; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; background: #182430; color: #9fb0bf; text-align: left; font-weight: 500; }
th, td { padding: 8px 7px; border-bottom: 1px solid #1f2b36; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #192531; }
tbody tr.selected { background: #1c3b43; outline: 1px solid var(--cyan); }

.upload-card { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)) 2fr; gap: 1px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--line); }
.upload-card > div { min-height: 64px; padding: 11px 13px; background: var(--panel); display: grid; align-content: center; gap: 5px; }
.upload-card span { color: var(--muted); font-size: 11px; }
.upload-card strong { font-size: 13px; font-weight: 600; }
.progress-label { display: flex; justify-content: space-between; }
progress { width: 100%; height: 9px; accent-color: var(--cyan); }
.result-workspace { height: 580px; min-height: 0; }
.result-workspace .viewer-panel canvas { min-height: 580px; }
.result-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.summary-chip { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 11px; }
.summary-chip strong { color: var(--text); }
.status-safe { color: var(--green); }
.status-out { color: var(--red); }
.status-review { color: var(--yellow); }
.result-table-scroll { margin-top: 10px; }

.detail-panel { margin-top: 14px; border: 1px solid var(--line); background: var(--panel); padding: 16px; }
.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.detail-header h2 { margin: 0; font-size: 16px; }
.detail-header h2 span { color: var(--cyan); }
.metrics { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.metrics strong { color: var(--text); }
.quad-view { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.quad-view figure { margin: 0; border: 1px solid var(--line); background: #05080b; }
.quad-view figcaption { padding: 7px 9px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.quad-view img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; image-rendering: pixelated; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 420px; padding: 11px 15px; border: 1px solid #3a4b59; border-radius: 6px; background: #18232e; box-shadow: 0 10px 30px rgba(0,0,0,.35); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--red); }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .workspace .viewer-panel canvas { height: 650px; }
  .result-workspace .viewer-panel canvas { height: 580px; }
  .side-panel { border-left: 0; border-top: 1px solid var(--line); max-height: 620px; }
  .upload-card { grid-template-columns: repeat(3, 1fr); }
  .quad-view { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .app-header { height: auto; min-height: 78px; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .auth-panel { flex-wrap: wrap; }
  .app-header, main { padding-left: 12px; padding-right: 12px; }
  .steps { padding-left: 12px; padding-right: 12px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar-status { width: 100%; margin-left: 0; }
  .upload-card { grid-template-columns: 1fr 1fr; }
  .quad-view { grid-template-columns: 1fr; }
}
