:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --sunken: #eef0f3;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e4e4e0;
  --line-strong: #d3d2cc;
  --accent: #2a78d6;
  --accent-soft: #e6f0fb;
  --orange: #eb6834;
  --match: #0a7d3c;   --match-soft: #e3f4ea;
  --partial: #9a6400; --partial-soft: #fdf1d6;
  --mismatch: #c93434; --mismatch-soft: #fbe5e4;
  --atco: #2a78d6;
  --pilot: #1baf7a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --sans: "Inter", "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px;
  -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; color: inherit; }
h2 { font-size: 13px; margin: 0; font-weight: 600; }
svg { display: block; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 230px; max-width: 300px; flex-shrink: 0; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand-logo svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-mark { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 3px 8px; align-items: center; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); }
.kpis { display: flex; flex: 1; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.kpi { display: flex; flex-direction: column; padding: 0 14px; white-space: nowrap; border-left: 1px solid var(--line); line-height: 1.2; }
.kpi:first-child { border-left: none; }
.kpi b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi span { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.kpi.match span::before, .kpi.partial span::before, .kpi.mismatch span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.kpi.match span::before { background: var(--match); } .kpi.partial span::before { background: #e0a100; } .kpi.mismatch span::before { background: var(--mismatch); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 15px; height: 15px; }
.search input { border: none; outline: none; background: none; font-family: var(--mono); font-size: 13px; width: 170px; color: var(--ink); }

/* ---------- scrubber ---------- */
.scrubber { display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.play { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px 0 11px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 12px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.play svg { width: 14px; height: 14px; color: var(--accent); }
.play .i-pause { display: none; }
.play.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.play.on svg { color: #fff; } .play.on .i-play { display: none; } .play.on .i-pause { display: block; }
.scrub-track { position: relative; flex: 1; height: 56px; }
.scrub-track canvas { position: absolute; inset: 0; width: 100%; height: 56px; }
.scrub-track input { position: absolute; inset: 0; width: 100%; height: 56px; margin: 0; opacity: 0; cursor: ew-resize; }
.clock { display: flex; align-items: baseline; justify-content: flex-end; min-width: 150px; cursor: text; }
.clock input { font-family: var(--mono); font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink); width: 9ch;
  text-align: right; border: 1px solid transparent; border-radius: 6px; background: none; padding: 2px 4px; outline: none; transition: border-color .12s, background .12s; }
.clock:hover input { border-color: var(--line-strong); }
.clock input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.clock input.bad { border-color: var(--mismatch); box-shadow: 0 0 0 3px var(--mismatch-soft); }
.clock small { font-size: 11px; color: var(--muted); margin-left: 4px; }

/* ---------- board layout ---------- */
.board { display: grid; grid-template-columns: 300px minmax(0, 1fr) 380px; gap: 12px; padding: 12px; height: calc(100vh - 139px); }
.bay, .work, .side { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-height: 0; overflow: hidden; }
.bay { display: flex; flex-direction: column; }
.bay-head, .alerts-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.bay-head small { color: var(--muted); font-size: 12px; }
.strips { overflow-y: auto; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 6px; }

/* flight cards */
.strip { flex-shrink: 0; display: grid; grid-template-columns: 4px 1fr auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer; min-height: 60px; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.strip:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.strip.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.strip .band { background: var(--line-strong); }
.strip .band.MATCH { background: var(--match); } .strip .band.PARTIAL { background: #e0a100; } .strip .band.MISMATCH { background: var(--mismatch); }
.strip .main { padding: 8px 10px; min-width: 0; }
.strip .cs { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.strip .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .last { font-family: var(--mono); font-size: 11px; color: var(--ink-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .stats { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; font-size: 11px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px;
  background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill.MATCH { color: var(--match); background: var(--match-soft); }
.pill.PARTIAL { color: var(--partial); background: var(--partial-soft); }
.pill.MISMATCH { color: var(--mismatch); background: var(--mismatch-soft); }
.pill.flag { background: var(--sunken); color: var(--ink-2); }

/* ---------- work area ---------- */
.work { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: none; padding: 9px 12px 11px; font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-body { flex: 1; min-height: 0; position: relative; }
.tab { display: none; position: absolute; inset: 0; overflow: auto; padding: 18px 20px; }
.tab.active { display: block; }
.hint { color: var(--muted); }

/* airfield snapshot */
.lanes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.lane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lane h3 { margin: 0; padding: 10px 12px; font-size: 12px; font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; }
.lane h3 span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.lane ul { list-style: none; margin: 0; padding: 4px 0; }
.lane li { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; padding: 6px 12px; font-family: var(--mono); font-size: 12px; cursor: pointer; align-items: center; }
.lane li:hover { background: var(--accent-soft); }
.lane li .what { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.snap-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; }
.snap-title b { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.snap-title small { color: var(--muted); }

/* flight timeline */
.flight-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.flight-head .cs { font-family: var(--mono); font-size: 24px; font-weight: 600; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 12px; font-weight: 500; }
.btn svg { width: 13px; height: 13px; color: var(--accent); }
.btn:hover { border-color: var(--accent); }
.radio { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 74%; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.msg:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.msg.ATCO { align-self: flex-start; border-top-left-radius: 4px; }
.msg.PILOT { align-self: flex-end; background: #f3faf6; border-color: #d4ece0; border-top-right-radius: 4px; }
.msg.UNKNOWN { align-self: center; border-style: dashed; }
.msg .meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); margin-bottom: 5px; flex-wrap: wrap; }
.msg .meta .who { font-weight: 600; }
.msg.ATCO .meta .who { color: var(--atco); } .msg.PILOT .meta .who { color: #0f8a5f; }
.msg .text { font-size: 14px; line-height: 1.5; }
.text.redacted { font-family: var(--mono); font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.redacted-note { font-family: var(--sans); font-size: 11px; color: var(--muted); }
.btn.dl { text-decoration: none; color: var(--ink); height: 36px; }
.btn[hidden] { display: none; }
.msg .chips, .ev-tx .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.chip { font-family: var(--mono); font-size: 11px; background: var(--sunken); color: var(--ink-2); border-radius: 5px; padding: 2px 7px; }
.chip.req { background: var(--accent-soft); color: #1d5ea8; }
.play-btn { flex-shrink: 0; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 50%; width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center; color: var(--accent); transition: background .12s; }
.play-btn svg { width: 11px; height: 11px; margin-left: 1px; }
.play-btn:hover, .play-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.play-btn.on { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
.play-btn.off, .play-btn.off:hover { color: var(--muted); background: var(--surface); border-color: var(--line); cursor: not-allowed; opacity: .6; }

/* graph */
.legend { position: absolute; left: 16px; right: 16px; bottom: 10px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend i.ln { width: 16px; height: 2px; border-radius: 0; vertical-align: 3px; }
.legend i.ln.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; }

/* KG explorer */
.tab.kg-tab.active { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.kg-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--sunken); border-radius: var(--radius); padding: 3px; }
.seg button { border: none; background: none; padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.kg-window { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.kg-find { display: flex; align-items: center; gap: 6px; margin-left: auto; height: 30px; padding: 0 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); color: var(--muted); }
.kg-find:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kg-find svg { width: 13px; height: 13px; }
.kg-find input { border: none; outline: none; background: none; font-family: var(--mono); font-size: 12px; width: 190px; color: var(--ink); }
.kg-stage { position: relative; flex: 1; min-height: 0; }
#kgcy { position: absolute; inset: 0; }
.kg-detail { position: absolute; top: 12px; left: 12px; width: 290px; max-height: calc(100% - 24px); overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 24, 40, .12); padding: 12px 14px; font-size: 12px; }
.kg-detail.hidden { display: none; }
.kd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kd-head b { font-family: var(--mono); font-size: 14px; }
.kd-head small { color: var(--muted); }
.kd-head .close { margin-left: auto; border: none; background: none; color: var(--muted); }
.kd-kind { width: 10px; height: 10px; border-radius: 50%; }
.kg-detail table { width: 100%; border-collapse: collapse; }
.kg-detail td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-word; }
.kg-detail td:first-child { color: var(--muted); width: 40%; }
.kg-detail h4 { margin: 10px 0 4px; font-size: 12px; font-weight: 600; }
.kg-detail ul { list-style: none; margin: 0 0 10px; padding: 0; max-height: 180px; overflow-y: auto; }
.kg-detail li { padding: 3px 0; font-size: 11px; }
.kg-detail li .et { font-family: var(--mono); color: var(--accent); margin-right: 4px; }
.kg-detail li small { color: var(--muted); }
.kg-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-2); }
.kg-legend button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 9px; font-size: 11px; }
.kg-legend button small { color: var(--muted); }
.kg-legend button.off { opacity: .4; text-decoration: line-through; }
.kg-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.kg-legend i.ln { width: 16px; height: 2px; border-radius: 0; vertical-align: 3px; margin-right: 5px; }
.kg-legend .sep { width: 1px; height: 16px; background: var(--line); }
.kg-legend .hint { margin-left: auto; }

.kg-edgekey { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 11px; color: var(--ink-2); box-shadow: var(--shadow); backdrop-filter: blur(4px); }
.kg-edgekey h4 { margin: 0 0 6px; font-size: 11px; font-weight: 600; color: var(--ink); cursor: pointer; display: flex; justify-content: space-between; gap: 12px; user-select: none; }
.kg-edgekey .chev { color: var(--muted); transition: transform .15s; }
.kg-edgekey.collapsed h4 { margin: 0; }
.kg-edgekey.collapsed .chev { transform: rotate(-90deg); }
.kg-edgekey.collapsed .keys { display: none; }
.kg-edgekey .keys > div { display: flex; align-items: center; gap: 8px; line-height: 1.9; }
.kg-edgekey svg { width: 30px; height: 8px; flex-shrink: 0; }
.kg-edgekey:empty { display: none; }
.kg-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; border-radius: 6px; padding: 6px 9px; font-size: 12px;
  display: flex; flex-direction: column; gap: 1px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; max-width: 280px; z-index: 5; }
.kg-tip.show { opacity: 1; transform: none; }
.kg-tip span { color: #c3c2b7; font-size: 11px; }
.kg-detail li[data-id] { cursor: pointer; border-radius: 4px; padding: 3px 4px; }
.kg-detail li[data-id]:hover { background: var(--accent-soft); }
.kg-detail .sw { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }
.kg-detail h4 small { font-weight: 400; color: var(--muted); }

/* evaluation */
.eval-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.card table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.card td, .card th { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
.card th { font-weight: 500; color: var(--muted); font-size: 11px; }
.card td { font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--sunken); border-radius: 3px; position: relative; overflow: hidden; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.big { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ---------- side: alerts + evidence ---------- */
.side { display: flex; flex-direction: column; }
.near { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.near input { accent-color: var(--accent); }
.alert-filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px 10px; border-bottom: 1px solid var(--line); }
.alert-filters button { font-size: 11px; font-weight: 500; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 3px 9px; color: var(--ink-2); }
.alert-filters button:hover { border-color: var(--accent); }
.alert-filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.alerts { overflow-y: auto; flex: 1; padding: 6px 8px 12px; display: flex; flex-direction: column; }
.alert { display: grid; grid-template-columns: 64px 1fr; gap: 10px; border-radius: 6px; padding: 8px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--line); }
.alert:hover { background: var(--surface-2); }
.alert.selected { background: var(--accent-soft); }
.alert .t { font-family: var(--mono); color: var(--muted); font-size: 11px; line-height: 1.5; }
.alert .lbl { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.alert .lbl::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.alert .lbl .hint { font-weight: 400; }
.alert .lbl.MISMATCH::before, .alert .lbl.KB_VIOLATION::before { background: var(--mismatch); }
.alert .lbl.PARTIAL::before, .alert .lbl.NO_READBACK::before, .alert .lbl.NO_CALLSIGN::before { background: #e0a100; }
.alert .lbl.SIMILAR_CALLSIGN::before, .alert .lbl.POST_HANDOFF::before, .alert .lbl.RWY_OVERLAP::before { background: var(--accent); }
.alert .m { color: var(--ink-2); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.evidence { margin: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; max-height: 55%; overflow-y: auto; flex-shrink: 0; }
.evidence.hidden { display: none; }
.evidence h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.evidence .close { border: none; background: none; color: var(--muted); font-size: 14px; }
.ev-tx { border-left: 3px solid var(--line-strong); padding: 6px 10px; margin: 8px 0; background: var(--surface); border-radius: 0 6px 6px 0; line-height: 1.5; }
.ev-tx.ATCO { border-left-color: var(--atco); } .ev-tx.PILOT { border-left-color: var(--pilot); }
.ev-tx .meta { font-size: 11px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 3px; }
.diff { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; background: var(--surface); border-radius: 6px; overflow: hidden; }
.diff td, .diff th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.diff th { font-weight: 500; color: var(--muted); font-size: 11px; }
.diff .ok { color: var(--match); } .diff .bad { color: var(--mismatch); } .diff .miss { color: var(--partial); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: var(--radius); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d3d2cc; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

@media (max-width: 1200px) {
  .board { grid-template-columns: 260px minmax(0, 1fr); height: auto; }
  .work { min-height: 70vh; }
  .side { grid-column: 1 / -1; max-height: 70vh; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .kpi { padding: 0 10px; }
  .scrubber { padding: 10px 16px; flex-wrap: wrap; }
  .play span { display: none; }
  .board { grid-template-columns: 1fr; padding: 8px; }
  .bay { max-height: 45vh; }
  .msg { max-width: 92%; }
}
