/* Same design language as docs/handover: one typeface (Atkinson Hyperlegible Next), white surfaces,
   hairlines, one accent. Colour marks status only. */
:root {
  color-scheme: light;
  --bg: #eef0f2;
  --bg2: #f6f7f8;
  --surface: #fff;
  --surface2: #eaf2f8;
  --line: #d5d9dd;
  --line2: #c3c9cf;
  --hair: #e8eaed;
  --text: #161a1e;
  --muted: #4f575f;
  --dim: #6b737b;
  --chrome: #262d34;
  --chrome-2: #36404a;
  --chrome-ink: #aab2ba;
  /* status: Structured / Converted / Unverified / Not received */
  --DATA: #1d6fa5;
  --CONFLICT: #2a9d8f;
  --PICTURE: #c98a12;
  --LOST: #c2372e;
  --accent: #1d6fa5;
  --radius: 4px;
  --font: "Inter", "Atkinson Hyperlegible Next", "Segoe UI", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
b, strong { font-weight: 600; }
button { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-variant-ligatures: none; }

/* ------------------------------------------------ top bar (shared with docs/handover) */
#top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px; height: 40px; padding: 0 16px; background: var(--chrome); color: var(--chrome-ink); font-size: 13px; }
#top .brand { font-weight: 600; color: #fff; letter-spacing: .02em; font-size: 16px; text-decoration: none; }
#top nav { display: flex; height: 100%; }
#top nav a { padding: 0 12px; display: flex; align-items: center; border-bottom: 2px solid transparent; border-top: 2px solid transparent; color: var(--chrome-ink); text-decoration: none; }
#top nav a:hover { color: #fff; }
#top nav a.on { border-bottom-color: #fff; color: #fff; }

/* ------------------------------------------------ hero */
.hero { padding: 40px 0 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
h1 { font-size: clamp(32px, 4.4vw, 48px); line-height: 1.1; margin: 12px 0 12px; letter-spacing: -0.01em; }
.grad { color: var(--accent); }
.lede { max-width: 760px; font-size: 17px; color: var(--muted); margin: 0 0 28px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface); }
.stat { padding: 18px 20px; position: relative; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c, var(--accent)); }
.stat .big { font-size: 40px; font-weight: 600; line-height: 1; color: var(--c, var(--text)); }
.stat .big small { font-size: 20px; }
.stat .cap { font-size: 15px; font-weight: 600; margin-top: 8px; }
.stat .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.hero-note { margin: -14px 0 28px; font-size: 13px; }

.waffle-card { background: var(--surface); border: 1px solid var(--line); padding: 16px 18px; }
.waffle-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.waffle-head h3 { font-size: 15px; }
.waffle-head p { margin: 2px 0 0; font-size: 13px; max-width: 640px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; }
.lg.on { font-weight: 600; text-decoration: underline; }
.lg b { color: var(--text); }
.sw { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.waffle { display: grid; grid-template-columns: repeat(auto-fill, minmax(11px, 1fr)); gap: 2px; }
.cell { aspect-ratio: 1; border-radius: 1px; background: var(--c); cursor: pointer; opacity: 0; transition: opacity .4s; }
.cell.in { opacity: .9; }
.cell:hover { opacity: 1; outline: 2px solid var(--text); outline-offset: 1px; z-index: 2; }
.cell.dim { opacity: .12 !important; }

/* ------------------------------------------------ sections */
main section { padding: 40px 24px 8px; }
.section-head { margin-bottom: 16px; }
.section-head h2 { font-size: 22px; }
.section-head p { margin: 4px 0 0; font-size: 14px; max-width: 820px; }

/* systems */
.sys-sum { margin: 0 0 12px; padding: 10px 14px; max-width: 820px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--PICTURE); font-size: 14px; color: var(--muted); }
.sys-sum b { color: var(--text); }
.systems { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.sys { padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 0; }
.sys.offline { background: var(--bg2); }
.sys .ico { width: 32px; height: 32px; border-radius: var(--radius); display: grid; place-items: center; background: var(--bg2); border: 1px solid var(--hair); color: var(--muted); }
.sys .ico svg { width: 18px; height: 18px; }
.sys h4 { font-size: 14px; }
.sys .fmt { font: 12px var(--mono); color: var(--dim); }
.sys .who { min-height: 3.2em; }
.sys .sysname { font-size: 12px; color: var(--dim); min-height: 34px; }
.sys .count { font-size: 12px; color: var(--muted); }
.sys .count b { color: var(--text); font-size: 16px; margin-right: 4px; }
.bar { display: flex; height: 6px; overflow: hidden; background: var(--hair); gap: 1px; }
.bar span { background: var(--c); height: 100%; transition: width .8s ease; }
.sys .verdict { font-size: 12px; font-weight: 600; color: var(--muted); }

/* explorer */
.explorer { display: grid; grid-template-columns: 240px 1fr; gap: 0; align-items: start; border: 1px solid var(--line); background: var(--surface); }
.plist { border-right: 1px solid var(--line); max-height: 860px; overflow: auto; position: sticky; top: 40px; }
.pgroup { font-size: 13px; font-weight: 600; padding: 0 12px; height: 34px; line-height: 34px; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.pitem { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--hair); padding: 6px 12px; cursor: pointer; display: grid; gap: 4px; }
.pitem:hover { background: var(--bg2); }
.pitem.on { background: var(--surface2); }
.pitem .nm { font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.pitem.on .nm { font-weight: 600; }
.pitem .nm span { font: 12px var(--mono); color: var(--dim); font-weight: 400; }
.pitem .bar { height: 4px; }

.pmain { padding: 18px; min-width: 0; }
.phead { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.phead h3 { font-size: 20px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: var(--radius); border: 1px solid var(--line); color: var(--muted); background: var(--bg2); }
.chip.mono { font-family: var(--mono); }
.chip.path { color: var(--accent); border-color: var(--line2); }
.ring-box { display: flex; align-items: center; gap: 12px; }
.ring-box .lbl { font-size: 13px; color: var(--muted); max-width: 150px; }
.ring-box .lbl b { display: block; color: var(--text); font-size: 15px; }

.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); margin: 18px 0 6px; position: relative; background: var(--surface); }
.toggle button { position: relative; z-index: 1; background: none; border: 0; padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--muted); }
.toggle button.on { color: #fff; font-weight: 600; }
.toggle .knob { position: absolute; top: 0; bottom: 0; left: 0; background: var(--chrome); transition: all .3s ease; }
.toggle.comp .knob { background: var(--chrome); }
.view-note { font-size: 14px; color: var(--muted); margin: 8px 0 12px; min-height: 22px; }
.view-note b { color: var(--text); }

.timeline { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); }
.timeline svg { display: block; }
.lane-label { font-size: 12px; fill: var(--text); font-weight: 600; }
.lane-sub { font-size: 10px; fill: var(--dim); font-family: var(--mono); }
.axis-tick { font-size: 11px; fill: var(--dim); font-family: var(--mono); }
.layer { transition: opacity .4s ease; }
.layer.off { opacity: 0; pointer-events: none; }
.mk { cursor: pointer; transition: transform .15s; transform-box: fill-box; transform-origin: center; }
.mk:hover { transform: scale(1.3); }

.panel-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 22px 0 10px; }
.panel-title.sq { color: var(--text); display: flex; align-items: center; gap: 6px; }
.panel-title.sq::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.tl-hint { display: none; font-size: 12px; margin: 6px 0 0; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; }
.doc:hover { border-color: var(--accent); }
.doc .thumb { height: 112px; background: #000; display: grid; place-items: center; overflow: hidden; position: relative; border-bottom: 1px solid var(--line); }
.doc .thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc .thumb.pdf img { object-position: top; background: #fff; }
.doc .thumb pre { margin: 0; padding: 8px; font-size: 8.5px; line-height: 1.35; color: var(--muted); white-space: pre; width: 100%; height: 100%; background: var(--bg2); overflow: hidden; }
.doc .thumb .wsi { font: 12px var(--mono); color: var(--dim); text-align: center; }
.doc .meta { padding: 8px 10px 10px; }
.doc .t { font-size: 13px; font-weight: 600; line-height: 1.3; }
.doc .d { font-size: 12px; color: var(--dim); margin-top: 2px; }
.ok { position: absolute; top: 6px; right: 6px; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: var(--radius); background: var(--surface); color: var(--DATA); border: 1px solid var(--line); }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; text-align: left; }
.fact:hover { background: var(--bg2); }
.fact .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.fact .lab { font-size: 13px; font-weight: 600; }
.fact .val { font-size: 18px; font-weight: 600; margin: 4px 0 2px; }
.fact .val small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.fact .val.none { color: var(--dim); }
.fact .why { font-size: 12px; color: var(--muted); line-height: 1.4; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; color: var(--text); white-space: nowrap; }
.st::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--c); flex: none; }

/* heatmap */
.map-legend { font-size: 13px; color: var(--muted); margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.heat-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); padding: 16px; }
.heat { display: grid; gap: 3px; min-width: 900px; }
.heat .hc { font-size: 12px; color: var(--text); writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; padding: 4px 0; height: 118px; }
.heat .hr { font-size: 13px; white-space: nowrap; padding-right: 10px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.heat .hr:hover { color: var(--accent); }
.heat .hr i { font-style: normal; font-size: 11px; color: var(--dim); }
.hx { height: 22px; background: var(--bg2); display: flex; gap: 1px; padding: 2px; cursor: pointer; }
.hx.empty { background: transparent; border: 1px dashed var(--hair); cursor: default; }
.hx span { flex: 1; background: var(--c); }
.hx:not(.empty):hover { outline: 2px solid var(--text); }

/* halves */
.halves { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); background: var(--surface); }
.half { padding: 20px; position: relative; border-right: 1px solid var(--line); }
.half:nth-child(2) { border-right: 0; }
.half::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c); }
.half h3 { font-size: 17px; }
.half .q { color: var(--muted); margin: 4px 0 16px; font-size: 14px; }
.half .rows { display: grid; gap: 10px; }
.half .row { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; }
.half .row b { font-size: 24px; color: var(--c); text-align: right; }
.half .row span { font-size: 14px; color: var(--muted); }
.half .owner { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--muted); }
.half .owner b { color: var(--text); }
.halves .open-q { grid-column: 1 / -1; margin: 0; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }

/* export */
.export { background: var(--surface); border: 1px solid var(--line); padding: 20px; }
.xrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn { text-decoration: none; display: inline-block; background: var(--chrome); color: #fff; border: 1px solid var(--chrome); font-weight: 600; padding: 7px 14px; border-radius: 3px; cursor: pointer; font-size: 14px; }
.btn:hover { background: var(--chrome-2); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); font-weight: 400; }
.btn.ghost:hover { background: var(--bg2); }
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.pstep { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: 13px; opacity: .45; transition: opacity .35s; }
.pstep.done { opacity: 1; background: var(--surface); border-left: 3px solid var(--DATA); }
.pstep b { display: block; font-size: 13px; margin-bottom: 2px; }
.pstep span { color: var(--muted); font-size: 12px; }
.xtable { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.xtable th { text-align: left; font-size: 12px; font-weight: 600; color: var(--dim); border-bottom: 1px solid var(--line); padding: 6px 8px; }
.xtable td { border-bottom: 1px solid var(--hair); padding: 5px 8px; font-size: 13px; }
.leak { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; color: var(--DATA); font-size: 14px; }

/* unlinked */
.unl { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--LOST); padding: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.unl h4 { font-size: 15px; }
.unl pre { margin: 0; background: var(--bg2); border: 1px solid var(--hair); padding: 10px; font-size: 12px; color: var(--muted); overflow: auto; max-width: 100%; }
.unl > * { min-width: 0; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(22, 26, 30, .35); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--line); z-index: 50; transform: translateX(100%); transition: transform .3s ease; overflow-y: auto; padding: 22px; }
.drawer.on { transform: none; box-shadow: -12px 0 32px rgba(0, 0, 0, .12); }
.drawer .x { position: absolute; top: 14px; right: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; width: 30px; height: 30px; cursor: pointer; font-size: 16px; }
.drawer h3 { font-size: 18px; margin: 10px 40px 2px 0; }
.drawer .sub { color: var(--muted); font-size: 13px; }
.cmp { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin: 16px 0; }
.cmp > div { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.cmp .k { font-size: 12px; color: var(--dim); font-weight: 600; }
.cmp .v { font-size: 20px; font-weight: 600; margin-top: 2px; word-break: break-word; }
.cmp .v small { font-size: 13px; color: var(--muted); font-weight: 400; }
.cmp .arrow { color: var(--dim); font-size: 18px; }
.reason { background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--c); padding: 10px 12px; font-size: 14px; }
.steps { list-style: none; padding: 0; margin: 14px 0; display: grid; }
.steps li { position: relative; padding: 0 0 12px 24px; font-size: 14px; }
.steps li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.steps li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.steps li:last-child::after { display: none; }
.media { position: relative; overflow: hidden; border: 1px solid var(--line); background: #000; margin: 8px 0 14px; }
.media img { display: block; width: 100%; }
.media.pdf { background: #fff; }
.media .box { position: absolute; border: 2px solid var(--c); border-radius: 2px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); animation: boxin .5s ease; }
@keyframes boxin { from { opacity: 0; } }
.drawer pre.raw { background: var(--bg2); border: 1px solid var(--line); padding: 10px; font-size: 12px; color: var(--text); overflow: auto; white-space: pre; }
.drawer .file { font: 12px var(--mono); color: var(--dim); margin-top: 8px; word-break: break-all; }
.drawer .dt { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 0 6px; }

.tip { position: fixed; pointer-events: none; z-index: 60; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 3px; padding: 6px 10px; font-size: 13px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); opacity: 0; transition: opacity .12s; max-width: 280px; }
.tip.on { opacity: 1; }
.tip b { display: block; }

.foot { display: grid; grid-template-columns: 1fr 1fr 220px; gap: 32px; padding: 40px 24px 56px; margin-top: 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot h4 { color: var(--text); font-size: 14px; margin-bottom: 6px; }
.foot p { margin: 0; }
.foot-meta { font-size: 13px; color: var(--dim); }
.foot-meta a { color: var(--accent); text-decoration: none; }

#export-out { overflow-x: auto; }

@media (max-width: 1100px) {
  .systems { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .stats, .halves, .unl, .foot { grid-template-columns: 1fr; }
  .stat, .half { border-right: 0; border-bottom: 1px solid var(--line); }
  .explorer { grid-template-columns: 1fr; }
  .plist { position: static; max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .systems { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: 1fr 1fr; }
  #top { gap: 12px; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  main section { padding: 32px 16px 8px; }
  .stat .big { font-size: 34px; }
  #top nav a { padding: 0 8px; }
}
