:root {
  --bg: #0b1418;
  --panel: #111d22;
  --panel2: #16262c;
  --line: #22363d;
  --text: #e6eff0;
  --muted: #8aa3a8;
  --teal: #159e9a;
  --amber: #f0a202;
  --crimson: #c8102e;
  --ok: #2bb673;
  --warn: #f0a202;
  --accent: #4fd1c5;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
h2 { font-size: 15px; margin: 0; letter-spacing: .2px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #0d181c; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; color: var(--crimson); filter: drop-shadow(0 0 6px rgba(200,16,46,.5)); }
.brand b { display: block; font-size: 17px; }
.brand span { color: var(--muted); font-size: 12px; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); background: var(--panel); }
.badge.warn { border-color: rgba(240,162,2,.6); color: #ffd27a; background: rgba(240,162,2,.08); font-weight: 600; }
.badge.ok { border-color: rgba(43,182,115,.5); color: #8be3b6; }

/* ---------- layout ---------- */
.grid { flex: 1; display: grid; grid-template-columns: 330px 1fr 420px; gap: 10px; padding: 10px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }
.input, .output { overflow: auto; padding: 12px; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.panel-h select { max-width: 200px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; }

/* ---------- input ---------- */
.avail { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--panel2); padding: 8px 10px; border-radius: 10px; }
.avail span { color: var(--muted); font-size: 12px; margin-right: 2px; }
.avail label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 2px 10px; }
.seg { display: flex; background: var(--panel2); border-radius: 10px; padding: 3px; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--line); color: var(--text); }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 8px; padding: 6px 10px 8px; }
fieldset.off { opacity: .4; }
legend { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; padding: 0 4px; }
.row { display: grid; grid-template-columns: 1fr 112px; align-items: center; gap: 6px; padding: 3px 0; }
.row label { font-size: 13px; }
.row small { display: block; color: var(--muted); font-size: 11px; }
.row input[type=number], .row select { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; text-align: right; }
.row input.abn { border-color: var(--amber); }
.row input.oor { border-color: var(--crimson); }
.row.hidden { display: none; }
.switch { justify-self: end; position: relative; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2b3f45; border-radius: 22px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #cfdcde; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- viewer ---------- */
.viewer { position: relative; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #18303a 0%, #0c171b 70%); }
#heart3d { position: absolute; inset: 0; }
#heart3d canvas { display: block; }
.vbar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.vbar > * { pointer-events: auto; }
.views button { background: rgba(17,29,34,.85); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.views button:hover { border-color: var(--accent); }
.toggles { display: flex; gap: 10px; background: rgba(17,29,34,.85); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.toggles label { display: flex; gap: 4px; align-items: center; cursor: pointer; font-size: 13px; }
.legend { position: absolute; left: 12px; bottom: 62px; width: 190px; font-size: 11px; color: var(--muted); }
.ramp { height: 8px; border-radius: 6px; background: linear-gradient(90deg, var(--teal), var(--amber), var(--crimson)); margin: 4px 0 2px; }
.ticks { display: flex; justify-content: space-between; }
.bullseye { position: absolute; right: 10px; bottom: 40px; width: 170px; color: var(--muted); background: rgba(17,29,34,.82); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.vnote { position: absolute; left: 12px; right: 190px; bottom: 8px; line-height: 1.3; margin: 0; font-size: 11px; color: var(--muted); }
.vlabels { position: absolute; inset: 0; pointer-events: none; }
.vlabel { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; background: rgba(10,18,22,.88); border: 2px solid var(--teal); color: var(--text); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.vlabel.on { box-shadow: 0 0 0 3px rgba(79,209,197,.35); }

/* ---------- output ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -2px -2px 10px; padding-bottom: 6px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tab { display: none; }
.tab.on { display: block; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.decision { border-left: 5px solid var(--muted); }
.decision.high { border-left-color: var(--crimson); }
.decision.low { border-left-color: var(--teal); }
.decision.unsure { border-left-color: var(--amber); }
.decision.check { border-left-color: #8a7dff; }
.decision b { font-size: 16px; }
.big { display: flex; align-items: baseline; gap: 10px; }
.big .num { font-size: 40px; font-weight: 700; line-height: 1; }
.big .band { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.chip.pos { border-color: var(--crimson); color: #ff9aa9; }
.chip.neg { border-color: var(--teal); color: #8fe3de; }
.bar { position: relative; height: 12px; background: #24383f; border-radius: 6px; overflow: visible; margin: 6px 0 2px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; }
.bar .bandmark { position: absolute; top: -3px; bottom: -3px; border: 1.5px solid rgba(255,255,255,.75); border-radius: 4px; }
.vrow { cursor: pointer; }
.vrow:hover { border-color: var(--accent); }
.vrow.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,209,197,.25); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warnbox { border: 1px solid rgba(240,162,2,.5); background: rgba(240,162,2,.07); color: #ffd99a; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 10px; }
.drv { display: grid; grid-template-columns: 1fr 140px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.drv .dbar { position: relative; height: 10px; }
.drv .dbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.drv .dbar::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line); }
.stack { display: flex; height: 16px; border-radius: 6px; overflow: hidden; margin: 6px 0; }
.stack span { display: block; height: 100%; }
.mlegend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.mlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.chosen td { color: #b8f3ec; font-weight: 600; }
.pos { color: #ff9aa9; }
.neg { color: #8fe3de; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.slider { display: grid; grid-template-columns: 120px 1fr 60px; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.slider input { width: 100%; accent-color: var(--accent); }
.chart { width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 9px; }
.seltarget { display: flex; gap: 4px; margin-bottom: 8px; }
.seltarget button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 4px 10px; cursor: pointer; }
.seltarget button.on { background: var(--line); }

.foot { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; padding: 6px 16px 10px; font-size: 11px; color: var(--muted); }

@media (max-width: 1150px) {
  html, body { height: auto; overflow-x: hidden; }
  .grid { grid-template-columns: 1fr; flex: none; }
  .viewer { height: 62vh; min-height: 420px; }
  .input, .output { max-height: none; overflow: visible; }
}

/* ---------- tour ---------- */
.tourbtn { cursor: pointer; color: var(--accent); border-color: rgba(79,209,197,.5); }
.tour-on { outline: 3px solid var(--accent); outline-offset: 3px; position: relative; z-index: 5; }
.tourcard { position: fixed; z-index: 50; width: 300px; background: #0f2a2f; border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 13.5px; }
.tourcard p { margin: 0 0 10px; }
.tourcard div { display: flex; justify-content: flex-end; gap: 6px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  .top { padding: 8px 10px; }
  .badges { gap: 5px; }
  .badge { font-size: 11px; padding: 3px 8px; white-space: normal; }
  .top { flex-direction: column; align-items: flex-start; }
  .grid { padding: 6px; gap: 6px; }
  .viewer { height: 56vh; min-height: 360px; }
  .bullseye { width: 120px; bottom: 54px; }
  .legend { width: 140px; bottom: 70px; }
  .vnote { right: 10px; font-size: 10px; }
  .vbar { flex-direction: column; align-items: flex-start; }
  .row { grid-template-columns: 1fr 96px; }
  .drv { grid-template-columns: 1fr 100px; }
  .tourcard { left: 12px !important; right: 12px; width: auto; }
}
