/* Screen 5: Hardware kit. Light theme, scoped under .hw-root; tokens from css/app.css */
.hw-root {
  height: 100%; width: 100%; box-sizing: border-box;
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: minmax(0, 1fr);
  font-family: var(--font); color: var(--text);
  position: relative;
}
.hw-root * { box-sizing: border-box; }
.hw-root [hidden] { display: none !important; }
.hw-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.hw-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; flex: 0 0 auto; }
.hw-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hw-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.3px; white-space: nowrap; }
.hw-pill { font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.hw-pill.plan { background: var(--today-soft); color: #b85d1c; }
.hw-pill.sim { background: var(--accent-soft); color: var(--accent); }

.hw-tabs { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.hw-tabs button { font: inherit; font-size: 12.5px; font-weight: 500; color: #3b3e43; background: none; border: 0; border-radius: 999px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.hw-tabs button.on { background: var(--text); color: #fff; }

.hw-body { flex: 1 1 auto; min-height: 0; position: relative; }
.hw-pane { position: absolute; inset: 0; padding: 0 18px 18px; display: flex; flex-direction: column; min-height: 0; }

/* ---------- on the vehicle ---------- */
.veh-wrap { position: relative; flex: 1 1 auto; min-height: 0; border-radius: 18px; background: linear-gradient(180deg, #faf8f5 0%, #f4f1ec 100%); overflow: hidden; }
.veh-svg { width: 100%; height: 100%; display: block; }
.veh-svg text { font-family: var(--font); }
.veh-before { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; font-size: 11.5px; font-weight: 500; padding: 6px 12px; border-radius: 999px; display: none; }
.hw-root.is-before .veh-before { display: block; }
.hw-root.is-before .vc-v, .hw-root.is-before .vb-c { opacity: .35; }
.hw-root.is-before .vlink { animation: none; opacity: .4; }

.vlink { fill: none; stroke: #c9c4f5; stroke-width: 1.6; stroke-dasharray: 3 5; animation: vDash 1.2s linear infinite; }
.vlink.up { stroke: #a9a2f7; }
@keyframes vDash { to { stroke-dashoffset: -16; } }
.vb rect { fill: #fff; stroke: var(--line); stroke-width: 1; filter: drop-shadow(0 2px 6px rgba(20, 22, 26, .05)); transition: fill .3s; }
.vb.flash rect { animation: vbFlash 1s ease-out; }
@keyframes vbFlash { 0% { fill: var(--accent-soft); stroke: var(--accent); } 100% { fill: #fff; stroke: var(--line); } }
.vb-n { font-size: 13px; font-weight: 600; fill: var(--text); }
.vb-s { font-size: 11px; fill: var(--muted); }
.vb-c { font-size: 20px; font-weight: 600; fill: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.vplat rect { fill: var(--text); }
.vp-t { font-size: 13px; font-weight: 600; fill: #fff; }
.vp-pkt { font-size: 10.5px; font-weight: 600; fill: var(--text); paint-order: stroke; stroke: #faf8f5; stroke-width: 4px; }

.vc rect { fill: #fff; filter: drop-shadow(0 4px 10px rgba(20, 22, 26, .10)); }
.vc-l { fill: none; stroke: #16181b; stroke-opacity: .35; stroke-width: 1.1; }
.vc-d { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.vc-n { font-size: 11px; fill: var(--muted); font-weight: 500; }
.vc-v { font-size: 13px; fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.vc.hot .vc-v { fill: var(--accent); }
.rig-led { animation: rigLed 1.4s ease-in-out infinite; }
@keyframes rigLed { 50% { opacity: .25; } }
.dust-in { animation: vDash .6s linear infinite; }
.hw-root.is-before .dust-in, .hw-root.is-before .rig-led { animation: none; }
.cam .cone { animation: cone 2.4s ease-in-out infinite; }
@keyframes cone { 50% { opacity: .55; } }
.heap .heap-box { opacity: 0; transition: opacity .3s; }
.heap.spot .heap-box { opacity: 1; }

/* before / after pair */
.ba { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.ba-card { border-radius: 18px; padding: 14px 16px; }
.ba-card.today { background: var(--today-soft); }
.ba-card.after { background: var(--accent-soft); }
.ba-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ba-h b { font-size: 14px; font-weight: 600; }
.ba-card.today .ba-h b { color: #b85d1c; }
.ba-card.after .ba-h b { color: var(--accent); }
.ba-h span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ba-n { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.ba-n > div { position: relative; }
.ba-n b { font-size: 28px; font-weight: 500; letter-spacing: -1.2px; font-variant-numeric: tabular-nums; }
.ba-n span { display: block; font-size: 11px; color: #5b5e63; margin-top: 1px; }
.ba-n em { font-style: normal; font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 999px; margin-left: 6px; vertical-align: 6px; }
.ba-n em.good { background: var(--good-soft); color: var(--good); }
.ba-n em.bad { background: var(--bad-soft); color: var(--bad); }
.ba-n em:empty { display: none; }

/* ---------- wiring ---------- */
.hw-board .hw-svg { flex: 1 1 auto; min-height: 0; width: 100%; border-radius: 16px; background: #fbfbfa; display: block; border: 1px solid var(--line); }
.hw-legend { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }
.hw-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: #3b3e43; background: var(--surface-2); border-radius: 999px; padding: 4px 10px; }
.hw-legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.hw-svg text { font-family: var(--font); }
.hw-svg .mtitle { font-size: 10.5px; font-weight: 700; fill: #2b2e33; }
.hw-svg .mtitle.big { font-size: 13px; font-weight: 600; fill: var(--text); }
.hw-svg .msub { font-size: 8.5px; fill: #6b6f75; }
.hw-svg .msub.dark { fill: #2b2e33; font-weight: 600; }
.hw-svg .light { fill: #eef2f5 !important; }
.hw-svg .plabel { font-size: 6.8px; fill: #263238; font-weight: 600; letter-spacing: .1px; }
.hw-svg .espl { font-size: 6.6px; }
.hw-svg .railt { font-size: 7px; fill: #7a8288; font-weight: 700; }
.hw-svg .pad { fill: #d4af37; stroke: #6b5413; stroke-width: .8; }
.hw-svg .hw-pin, .hw-svg .hw-wire, .hw-svg .hw-note { cursor: pointer; }
.hw-svg .hw-pin.dim .pad { fill: #a8a8a8; stroke: #6b6b6b; }
.hw-svg .hw-pin.dim text { opacity: .55; }
.hw-svg .hw-wire .casing { fill: none; stroke: #ffffff; stroke-width: 5.2; stroke-linejoin: round; stroke-linecap: round; }
.hw-svg .hw-wire .core { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.hw-svg .hw-wire .hit { fill: none; stroke: transparent; stroke-width: 10; }
.hw-svg .hw-rail { pointer-events: stroke; cursor: pointer; }
.hw-svg.hw-dim .hw-wire:not(.hl), .hw-svg.hw-dim .hw-rail:not(.hl) { opacity: .14; }
.hw-svg.hw-dim .hw-pin:not(.hl) .pad { opacity: .35; }
.hw-svg .hw-wire.hl .core { stroke-width: 3.6; }
.hw-svg .hw-pin.hl .pad { fill: #fff59d; stroke: #f57f17; stroke-width: 1.4; }
.hw-svg .hw-rail.hl { stroke-width: 3.4; }
.hw-svg .hw-led.blink { animation: hwLed .35s ease-out; }
@keyframes hwLed { 0% { fill: #fff; } 100% { fill: #ef4444; } }
.hw-svg .hw-wifi .arc { opacity: .35; animation: hwWifi 2.4s infinite; }
.hw-svg .hw-wifi .a2 { animation-delay: .3s; } .hw-svg .hw-wifi .a3 { animation-delay: .6s; }
@keyframes hwWifi { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.hw-svg .cam-pulse circle.go { animation: hwCam 1s ease-out; }
@keyframes hwCam { 0% { opacity: 1; r: 18; } 100% { opacity: 0; r: 40; } }

.hw-tip { position: absolute; z-index: 20; max-width: 250px; padding: 10px 12px; border-radius: 14px; background: #fff; box-shadow: var(--shadow-lg); font-size: 12px; line-height: 1.4; pointer-events: none; }
.hw-tip .tp-pin { font-weight: 600; margin-bottom: 3px; }
.hw-tip .tp-net { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.hw-tip .tp-net i { width: 12px; height: 4px; border-radius: 2px; display: inline-block; }
.hw-tip .tp-net em { font-style: normal; font-size: 10px; font-weight: 600; color: var(--muted); margin-left: auto; padding-left: 8px; }
.hw-tip .tp-info { color: var(--muted); margin-top: 3px; }

/* ---------- parts ---------- */
.hw-parts { overflow: auto; }
.parts-total { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.parts-total div { background: var(--sun); border-radius: 18px; padding: 14px 16px; }
.parts-total div + div { background: var(--surface-2); }
.parts-total span { display: block; font-size: 12px; color: #4a4434; }
.parts-total b { font-size: 30px; font-weight: 500; letter-spacing: -1.2px; font-variant-numeric: tabular-nums; }
.hw-parts table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hw-parts th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.hw-parts td { padding: 10px; border-bottom: 1px solid var(--line); }
.hw-parts td:first-child { font-weight: 500; }
.hw-parts td:nth-child(3) { color: var(--muted); }
.hw-parts .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hw-note-line { margin-top: 12px; font-size: 11.5px; color: var(--muted); cursor: help; }
.hw-note-line::before { content: "ⓘ "; }

/* ---------- live panel ---------- */
.hw-select { font: inherit; font-size: 12.5px; color: var(--text); background: var(--surface-2); border: 0; border-radius: 999px; padding: 8px 12px; max-width: 160px; cursor: pointer; }
.hw-before { margin: 0 18px 8px; padding: 7px 12px; border-radius: 999px; font-size: 12px; text-align: center; color: #b85d1c; background: var(--today-soft); }
.hw-vals { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 6px; padding: 2px 18px 0; align-items: end; }
.hw-vals b { display: block; font-size: 30px; font-weight: 500; letter-spacing: -1.3px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.hw-vals .main b { font-size: 46px; letter-spacing: -2.4px; color: var(--accent); }
.hw-vals span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.hw-vals .delta.hot b { color: var(--bad); }
.hw-unit { padding: 4px 18px 0; font-size: 11px; color: var(--faint); }
.hw-root.is-before .hw-vals, .hw-root.is-before .hw-meta, .hw-root.is-before .hw-gps { opacity: .4; }
.hw-spark { margin: 10px 18px 0; height: 64px; flex: 0 0 auto; }
.hw-spark canvas { width: 100%; height: 100%; display: block; }
.hw-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 18px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hw-meta span { display: block; font-size: 11px; color: var(--muted); }
.hw-meta b { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hw-gps { margin: 10px 18px 0; display: flex; flex-direction: column; gap: 1px; }
.hw-gps b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hw-gps span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-serial-wrap { flex: 1 1 auto; min-height: 90px; margin: 12px 12px 12px; background: var(--surface-2); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.hw-serial-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px 4px; font-size: 11px; font-weight: 500; color: var(--muted); }
.hw-led-dot { width: 7px; height: 7px; border-radius: 50%; background: #c9cdd1; display: inline-block; }
.hw-led-dot.blink { animation: hwDot .4s ease-out; }
@keyframes hwDot { 0% { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); } 100% { background: #c9cdd1; box-shadow: none; } }
.hw-serial { flex: 1 1 auto; min-height: 0; padding: 2px 12px 10px; overflow-y: auto; font-family: var(--mono); font-size: 10.5px; line-height: 1.55; color: #3b3e43; }
.hw-serial div { white-space: pre-wrap; word-break: break-word; }
.hw-serial .warn { color: #b85d1c; }
.hw-serial .cam { color: var(--accent); }
.hw-serial .cam.warn { color: var(--bad); }
.hw-serial .srv { color: var(--faint); }

/* ---------- Work Tracker ---------- */
.hw-seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 3px; box-shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 4px 12px rgba(20, 22, 26, .06); }
.hw-seg button { font: inherit; font-size: 12px; font-weight: 500; color: #3b3e43; background: none; border: 0; border-radius: 999px; padding: 6px 13px; cursor: pointer; white-space: nowrap; }
.hw-seg button.on { background: var(--accent); color: #fff; }
.veh-wrap { display: flex; flex-direction: column; }
.veh-seg { align-self: center; margin-top: 10px; flex: 0 0 auto; z-index: 2; }
.veh-view { flex: 1 1 auto; min-height: 0; }
.veh-before { top: 54px; }
.vb.mute rect { opacity: .55; }
.vb.mute text { opacity: .5; }
.vb.focus rect { stroke: var(--accent); stroke-width: 1.5; }
.tk-t { font-size: 12.5px; font-weight: 600; fill: #fff; letter-spacing: .1px; }
.wnode-wire { animation: vDash 1.2s linear infinite; }
.spray path { animation: vDash .5s linear infinite; }
.tanker .spray { transition: opacity .3s; }
.tanker.off .spray { opacity: 0; }
.sweeper .brush { transition: opacity .3s; }
.sweeper.off .brush { opacity: .4; }
.hw-root.is-before .wnode-wire, .hw-root.is-before .spray path { animation: none; opacity: .35; }
.vc.hot .vc-v { fill: var(--accent); }
#c-sw-node.hot .vc-v { fill: var(--bad); }

.ba-f { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed rgba(20, 22, 26, .12); font-size: 12px; color: #5b5e63; }
.ba-f b { font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; margin-left: auto; }
.ba-f i { font-style: normal; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: rgba(184, 93, 28, .12); color: #b85d1c; }
.ba-f i.ok { background: var(--accent); color: #fff; }

.wire-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wire-bar .hw-seg { box-shadow: none; background: var(--surface-2); }
.wv { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.parts-total.three { grid-template-columns: repeat(3, 1fr); }
.parts-total div.wp { background: var(--accent-soft); }
.parts-total div.wp span { color: var(--accent); }
.parts-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; }
.parts-h { margin: 2px 0 4px; font-size: 13px; font-weight: 600; }
.hw-parts .fit { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }

@media (max-width: 1360px) {
  .parts-grid { gap: 14px; }
  .hw-parts td { padding: 8px 6px; }
  .parts-total b { font-size: 24px; }
  .hw-root { grid-template-columns: minmax(0, 1fr) 300px; }
  .hw-vals .main b { font-size: 38px; }
  .hw-vals b { font-size: 25px; }
  .ba-n b { font-size: 23px; }
  .hw-tabs button { padding: 7px 11px; font-size: 12px; }
  .hw-live .hw-pill { display: none; }
  .hw-select { max-width: 140px; }
}
