/* MET-AL — Map-native Spatial Verification
   Dark "heavy-metal" aesthetic: chrome/steel on near-black, readable science. */

:root {
  --bg: #06070a;
  --bg2: #0b0e13;
  --panel: #10141b;
  --panel2: #151b24;
  --ink: #e7edf3;
  --ink-dim: #aab4c0;
  --muted: #6f7b88;
  --steel: #8b97a4;
  --chrome-hi: #f2f6fa;
  --chrome-lo: #4a525c;
  --line: #232c37;
  --accent: #6fd3ff;
  --good: #67e8a0;
  --bad: #ff8a8a;
  --warn: #ffcf6b;
  --hit: #78ffaa;
  --fa: #ffaa46;
  --miss: #ff5ac8;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background:
    radial-gradient(1200px 600px at 70% -10%, #141a23 0%, transparent 60%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- Header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(180deg, #161c25, #0c1017);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 0 #000, inset 0 1px 0 rgba(255,255,255,0.05);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  height: 50px; width: auto; display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}
.brand-text .title {
  font-weight: 700; font-size: 18px; letter-spacing: 0.5px;
  background: linear-gradient(180deg, var(--chrome-hi) 0%, var(--steel) 55%, var(--chrome-lo) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.brand-text .subtitle {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: 1.5px; text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 12px; }

.selfcheck {
  font-family: var(--mono); font-size: 12px;
  padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: #0c1017;
}
.selfcheck.ok { color: var(--good); border-color: #1f5a3a; box-shadow: 0 0 12px rgba(103,232,160,0.18) inset; }
.selfcheck.fail { color: var(--bad); border-color: #6a2a2a; }

/* ---------- Disclaimer ---------- */
.disclaimer {
  margin: 0; padding: 8px 20px;
  background: repeating-linear-gradient(45deg, #1a1206, #1a1206 12px, #16100a 12px, #16100a 24px);
  border-bottom: 1px solid #3a2c12;
  color: #ffe2a8; font-size: 12.5px; line-height: 1.5;
}
.disclaimer strong { color: var(--warn); }
.disclaimer code { font-family: var(--mono); color: #ffd98a; }

/* ---------- Layout ---------- */
.layout {
  flex: 1; display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px; padding: 14px; min-height: 0;
}

/* ---------- Map pane ---------- */
.map-pane {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: linear-gradient(180deg, #0d1118, #090c11);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}
.layer-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: linear-gradient(180deg, #141a23, #0e131b);
  border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }

.layer-btn, .ghost-btn {
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
  background: linear-gradient(180deg, #1b222c, #11161e);
  border: 1px solid #2a333f;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 2px rgba(0,0,0,0.4);
  transition: all 0.12s ease;
}
.layer-btn:hover, .ghost-btn:hover { color: var(--ink); border-color: #3a4655; }
.layer-btn.active {
  color: #061018; font-weight: 700;
  background: linear-gradient(180deg, #cfe9fb, #79b8e0);
  border-color: #9fd0ef;
  box-shadow: 0 0 14px rgba(111,211,255,0.35), inset 0 1px 0 rgba(255,255,255,0.6);
}

.canvas-wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#map:focus { outline: 1px solid var(--accent); outline-offset: -1px; }

.map-foot {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 12px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, #0e131b, #0a0e14);
}
.colorbar { width: 240px; height: 46px; }
.map-hints { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- Panel ---------- */
.panel {
  overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
  padding-right: 2px;
}
.panel-block {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 4px 16px rgba(0,0,0,0.35);
}
.panel-block h2 {
  margin: 0 0 10px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--steel); font-family: var(--mono);
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}

.row { display: flex; align-items: center; gap: 8px; }
.row select {
  flex: 1; font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: #0c1017; border: 1px solid #2a333f; border-radius: 6px; padding: 6px 8px;
}
.check { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 12.5px; color: var(--ink-dim); cursor: pointer; }

.thr-row { margin-bottom: 4px; }
#thr-slider { flex: 1; accent-color: var(--accent); }
.thr-readout { font-family: var(--mono); font-size: 13px; color: var(--accent); min-width: 56px; text-align: right; }

/* Hover readout */
.hover-box {
  margin-top: 11px; padding: 9px 11px; border-radius: 8px;
  background: #0a0e14; border: 1px solid var(--line);
}
.hover-label { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-bottom: 5px; }
.hover-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-family: var(--mono); font-size: 13px; }
.hover-grid .hk { color: var(--muted); }
.hover-grid .hv { color: var(--ink); text-align: right; }
.hover-grid .hv.err { color: var(--warn); }

/* Stat tables */
.stat-title { margin: 0 0 8px; font-size: 13px; color: var(--ink); font-weight: 600; }
.stat-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; }
.stat-table tr { border-bottom: 1px solid rgba(35,44,55,0.6); }
.stat-table td { padding: 4px 2px; vertical-align: baseline; }
.stat-table td.k { color: var(--ink-dim); white-space: nowrap; }
.stat-table td.v { color: var(--chrome-hi); text-align: right; font-variant-numeric: tabular-nums; padding-right: 10px; }
.stat-table td.note { color: var(--muted); font-size: 11px; font-family: var(--sans); }
.stat-table tr.good td.v { color: var(--good); }
.stat-table tr.bad td.v { color: var(--bad); }
.stat-table tr.good td.note { color: var(--good); }
.stat-table tr.bad td.note { color: var(--bad); }

/* 2x2 contingency */
.ctc-table { border-collapse: collapse; margin: 0 0 10px; font-family: var(--mono); font-size: 12px; width: 100%; }
.ctc-table th { color: var(--muted); font-weight: 500; padding: 4px 6px; text-align: center; font-size: 11px; }
.ctc-table td { padding: 7px 6px; text-align: center; border: 1px solid var(--line); border-radius: 4px; font-weight: 700; }
.ctc-table td.hit { background: rgba(120,255,170,0.10); color: var(--hit); }
.ctc-table td.fa { background: rgba(255,170,70,0.10); color: var(--fa); }
.ctc-table td.miss { background: rgba(255,90,200,0.10); color: var(--miss); }
.ctc-table td.cn { background: rgba(120,140,160,0.07); color: var(--steel); }

.agg-block { border-color: #2a3a30; }
.agg-block h2 { color: var(--good); }

/* Legend */
.legend { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--ink-dim); }
.legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.sw { width: 14px; height: 14px; border-radius: 3px; border: 2px solid; }
.sw.hit { border-color: var(--hit); }
.sw.fa { border-color: var(--fa); }
.sw.miss { border-color: var(--miss); }

.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.muted code, .small code { font-family: var(--mono); color: var(--ink-dim); }

/* ---------- Footer ---------- */
.app-footer {
  padding: 9px 20px; font-family: var(--mono); font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--line); background: #07090d;
  text-align: center; letter-spacing: 0.5px;
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .map-pane { min-height: 56vh; }
}

/* Scrollbar (webkit) */
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: #232c37; border-radius: 5px; }
.panel::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
