@font-face {
  font-family: Oswald;
  src: url("assets/oswald.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #121c27;
  --night: #10161e;
  --blue: #65b6e6;
  --link: #075e94;
  --line: #d5dce3;
  --muted: #4d6071;
  --display: Oswald, "Arial Narrow", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden], .symbols { display: none !important; }
body { margin: 0; color: var(--ink); background: #f2f5f8; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3, p, dl, dd { margin: 0; }
button, select, textarea, input { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button:disabled, select:disabled { cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible, textarea:focus-visible { outline: 3px solid #1986cd; outline-offset: 3px; }
.shell { width: min(1180px, calc(100% - 72px)); margin-inline: auto; }
.ic { width: 21px; height: 21px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.topbar { background: var(--night); color: white; border-bottom: 1px solid #36404a; }
.masthead, .brand, .guide, .primary, .section-label, .card-head, .card-title, .device-name, .metric-top, .dialog-head, .log-toolbar, footer { display: flex; align-items: center; }
.masthead { min-height: 72px; justify-content: space-between; gap: 16px; }
.brand { gap: 18px; white-space: nowrap; }
.brand img { width: 153px; height: auto; display: block; }
.brand span { border-left: 1px solid #43505d; padding-left: 17px; color: #d6e6f2; font: 400 16px/1.45 var(--display); letter-spacing: .09em; text-transform: uppercase; }
.guide { color: #ecf3f9; background: transparent; border: 0; gap: 8px; font-weight: 600; font-size: 14px; padding: 9px 0 9px 8px; }
.guide { white-space: nowrap; }
.guide:hover { color: var(--blue); }
.guide .ic { width: 18px; height: 18px; }
.hero { background: #10161e; isolation: isolate; position: relative; overflow: hidden; color: white; }
.hero-photo { position: absolute; z-index: -1; inset: 0 0 0 30%; background: #172735 url("assets/cadet-grid.webp") 52% 54% / cover no-repeat; }
.hero-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, #10161e 1%, rgba(16,22,30,.87) 14%, rgba(16,22,30,.24) 43%, rgba(16,22,30,.02) 76%), linear-gradient(0deg,rgba(4,15,27,.26),transparent 55%); }
.hero-inner { padding-block: 34px 37px; }
h1 { font: italic 700 clamp(48px,5.2vw,80px)/1.07 var(--display); letter-spacing: -.028em; text-transform: uppercase; }
h1 em { font-style: inherit; color: var(--blue); }
.hero p { color: #e1e7ed; max-width: 390px; margin-top: 10px; text-wrap: pretty; }
.primary { width: fit-content; justify-content: center; gap: 9px; background: var(--blue); border: 1px solid var(--blue); color: #071d2d; border-radius: 5px; padding: 10px 19px; font-weight: 740; min-height: 44px; margin-top: 19px; }
.primary:hover { background: #8dcef4; }
.primary:disabled { opacity: .7; }
.demo-banner { position: sticky; top: 0; z-index: 3; background: #ffcf69; color: #2e220d; border-bottom: 1px solid #bc892b; }
.demo-inner, .demo-message, .demo-message strong { display: flex; align-items: center; gap: .75rem; }
.demo-inner { justify-content: space-between; padding-block: .4rem; }
.demo-message strong { gap: .35rem; font: 700 1.3rem/1.2 var(--display); text-transform: uppercase; letter-spacing: .045em; }
.demo-message span { font-size: .95rem; line-height: 1.3; }
.demo-banner button { flex-shrink: 0; color: inherit; background: transparent; border: 1px solid #76551d; border-radius: 5px; padding: .35rem .7rem; min-height: 40px; font-weight: 650; }
.demo-banner button:hover { background: #ffe5ac; }
.demo-banner:not([hidden]) ~ main section[id] { scroll-margin-top: 5rem; }
@media(max-width:640px) {
  .demo-message { align-items: flex-start; flex-direction: column; gap: .12rem; }
  .demo-message span { font-size: .875rem; }
}
.charge-panel {
  --accent: #a4cce4;
  background: #142633; color: #fff;
  border-top: 3px solid var(--accent);
}
.charge-panel[data-flow="demo"] { --accent: #ffcf69; background: #24282b; }
.charge-panel[data-flow="charging"] { --accent: #8af0ad; background: #10332b; }
.charge-inner { padding-block: 20px; display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,2fr); align-items: center; gap: 24px; }
.charge-heading h2 { display: flex; align-items: center; gap: .25em; font-size: clamp(2rem,3.6vw,3.25rem); margin-top: 5px; color: var(--accent); }
.charge-heading h2 .ic { width: .74em; height: .86em; stroke-width: 2; }
.charge-panel[data-flow="charging"] h2 .ic { fill: currentColor; }
.charge-readings { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
.charge-readings > div { padding-left: clamp(12px,2.5vw,34px); border-left: 1px solid #ffffff40; }
.charge-readings dt { color: #dae6e8; font-size: 1rem; font-weight: 600; }
.charge-readings dd { font: 400 clamp(2.5rem,4.5vw,4.25rem)/1.2 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.charge-readings small { font-size: .48em; margin-left: .12em; color: #d5e5e6; }
.charge-panel[data-flow="charging"] .charge-readings > :first-child dd { color: var(--accent); }
@media(max-width:760px) {
  .charge-inner { display: block; padding-block: 12px 16px; }
  .charge-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
  .charge-heading h2 { order: -1; margin: 0; line-height: 1.16; }
  .charge-heading .badge { flex-shrink: 0; }
  .charge-readings > div { padding-inline: 10px 2px; }
  .charge-readings > :first-child { padding-left: 0; border: 0; }
  .charge-readings dt { font-size: .875rem; line-height: 1.15; }
  .charge-readings dd { font-size: clamp(1.9rem,8.7vw,2.95rem); margin-top: 4px; }
}
.section-nav { background: white; border-bottom: 1px solid var(--line); }
.section-links { display: flex; align-items: stretch; gap: clamp(18px,3.3vw,48px); }
.section-links a { display: inline-flex; align-items: center; color: #334657; font-weight: 650; font-size: 14px; text-decoration: none; min-height: 45px; border-bottom: 2px solid transparent; }
.section-links a:hover, .section-links a:focus-visible { color: var(--link); border-bottom-color: var(--blue); }
.dashboard { padding-top: 24px; }
section[id] { scroll-margin-top: 15px; }
.section-label { justify-content: space-between; gap: 12px; margin-bottom: 12px; }
h2 { font: 400 26px/1.2 var(--display); letter-spacing: -.015em; }
.badge, .mos-state, #balanceStatus, .event-kind { display: inline-flex; width: fit-content; align-items: center; border-radius: 4px; font-size: 13px; font-weight: 670; line-height: 1.4; padding: 3px 8px; }
.badge { gap: 6px; border: 1px solid #c3d2dd; color: #365367; background: #e5eef5; }
.badge[data-kind="live"], .mos-state[data-state="enabled"], #balanceStatus[data-state="Balanced"], .event-kind[data-kind="Recovery"] { color: #105d42; background: #ddf4e8; border-color: #9cc9b6; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.card { border: 1px solid var(--line); background: white; border-radius: 9px; min-width: 0; overflow: hidden; }
.metrics .card { position: relative; padding: 19px 21px 17px; display: flex; flex-direction: column; align-items: flex-start; min-height: 157px; }
.metric-top { gap: 7px; color: #314a5c; }
.metric-top .ic { width: 19px; height: 19px; color: #0875ac; }
.metric-top h3 { font: 400 16px/1.3 var(--display); text-transform: uppercase; letter-spacing: .055em; }
.reading, .balance-reading strong { font-family: var(--display); font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.05; }
.reading { font-size: clamp(44px,4.1vw,62px); margin-block: 10px 9px; position: relative; z-index: 1; }
.unit { font-size: .46em; margin-left: .16em; color: var(--muted); }
.metric-foot { margin-top: auto; font-size: 14px; line-height: 1.4; color: var(--muted); }
.thermal .metric-top .ic { color: #a55321; }
.thermo-track { position: absolute; right: 20px; top: 54px; bottom: 24px; width: 7px; background: #efe8e2; border-radius: 3px; overflow: hidden; }
#thermoFill { position: absolute; inset: auto 0 0; background: #c76a2f; }
.thermal[data-empty="true"] .thermo-track { display: none; }
.balance-reading { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; margin: 13px 0 9px; }
.balance-reading strong { font-weight: 400; font-size: clamp(33px,3.4vw,47px); }
#balanceStatus, .mos-state, .event-kind { color: #455666; background: #ecf0f3; }
#balanceStatus[data-state="Above limit"], .event-kind[data-kind="Protection"], .event-kind[data-kind="Fault"] { background: #fce4da; color: #8e361c; }
.event-kind[data-kind="Warning"], .mos-state[data-state="off"] { background: #f8edd2; color: #72531a; }
.lower { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 14px; margin-top: 16px; align-items: stretch; }
.history, .details, .log-panel { padding: 20px 22px; }
.card-head { justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-title { gap: 9px; }
.card-title .ic { color: #277ca9; }
.range { position: relative; }
.range select { appearance: none; background: white; border: 1px solid #bdcbd6; border-radius: 5px; padding: 7px 28px 7px 10px; min-height: 36px; font-size: 14px; }
.range .ic { position: absolute; width: 14px; height: 14px; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.switches { width: fit-content; display: flex; gap: 2px; background: #edf2f5; border-radius: 6px; padding: 3px; margin-block: 15px 4px; }
.switches button { border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 13px; border-radius: 4px; }
.switches button[aria-pressed="true"] { background: #16384b; color: white; }
.plot { position: relative; height: 186px; margin-block: 6px 8px; }
.plot canvas { width: 100%; height: 100%; display: block; }
#emptyPlot { white-space: nowrap; position: absolute; left: 50%; top: 45%; transform: translate(-50%,-50%); background: white; color: var(--muted); font-size: 14px; padding: 5px; }
.chart-foot, .chart-foot span:first-child, footer span { display: flex; align-items: center; gap: 7px; }
.chart-foot, footer { justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; color: var(--muted); }
.chart-foot i { width: 16px; height: 3px; border-radius: 2px; background: #1277ae; }
.device-name { gap: 12px; margin-block: 16px 12px; }
.device-icon { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 5px; background: #e5f3fa; color: var(--link); flex: 0 0 auto; }
.device-name h3 { font-size: 16px; overflow-wrap: anywhere; }
.device-name p, .details dt { color: var(--muted); }
.device-name p { font-size: 14px; }
.details dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-block: 7px; border-top: 1px solid #e2e8ed; font-size: 14px; }
.details dd { text-align: right; font: 600 14px/1.45 var(--mono); overflow-wrap: anywhere; }
.text-action { background: transparent; border: 0; padding: 8px 0; color: var(--link); font-weight: 630; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.log-panel { margin-top: 16px; }
.log-toolbar { flex-wrap: wrap; gap: 12px; margin-block: 14px 8px; }
.log-button, .pair-actions a, .pair-actions button { display: inline-flex; align-items: center; justify-content: center; min-height: 39px; padding: 7px 13px; border: 1px solid #a9c8db; border-radius: 5px; background: #eaf5fc; color: #164d6d; font-size: 14px; font-weight: 650; text-decoration: none; }
.log-button:disabled { color: #617383; background: #f0f3f5; border-color: #d6dde2; }
#logMessage, .log-panel li p, #logRaw, #logCopyStatus { font-size: 14px; color: var(--muted); line-height: 1.5; }
#logRows { padding: 0; margin: 0; list-style: none; }
.log-panel li { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 5px 10px; border-top: 1px solid var(--line); padding: 12px 0; font-size: 15px; }
.log-panel li:first-child, #logDiagnostics { margin-top: 14px; }
.log-panel li p { grid-column: 2 / -1; }
.event-time { font: 13px/1.4 var(--mono); color: var(--muted); }
#logDiagnostics { padding-top: 12px; border-top: 1px solid var(--line); }
#logRaw { margin-top: 8px; }
#logRaw summary { width: fit-content; padding: 4px 0; }
#logRawText, #manualLink { width: 100%; margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; font-size: 16px; }
#logRawText { resize: vertical; font-family: var(--mono); }
footer { gap: 10px; margin-block: 22px; padding-top: 12px; flex-wrap: wrap; }
footer .ic { width: 16px; height: 16px; }
footer b { color: #627c8e; }
#notice { background: #fff5df; color: #62490f; padding: 12px 16px; border-left: 4px solid #bc8b34; margin-block: 12px; }
#notice button { display: block; }
dialog { width: min(470px,calc(100% - 28px)); max-height: 88vh; max-height: 88dvh; padding: 22px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; box-shadow: 0 16px 60px #09151b36; }
dialog::backdrop { background: rgba(9,20,30,.62); }
.dialog-head { justify-content: space-between; gap: 12px; margin: -22px -22px 18px; padding: 15px 22px; background: var(--night); }
.guide-brand img { width: 112px; display: block; height: auto; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: #25323e; border: 1px solid #435463; border-radius: 5px; }
dialog h2 { font-size: 31px; }
dialog p, dialog li { margin: 10px 0; font-size: 15px; color: var(--muted); }
dialog ol { padding-left: 23px; }
dialog strong, dialog li::marker { color: var(--ink); }
dialog a { color: var(--link); font-weight: 650; }
.pair-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 12px 6px; }
#copyStatus { display: block; color: var(--link); font-size: 14px; }
@media(max-width:880px) {
  .shell { width: calc(100% - 40px); }
  .metrics { gap: 10px; }
  .metrics .card { padding-inline: 16px; }
  .lower { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); }
}
@media(max-width:680px) {
  .shell { width: calc(100% - 28px); }
  .masthead { min-height: 58px; }
  .brand { gap: 9px; }
  .brand img { width: 109px; }
  .brand span { font-size: 13px; padding-left: 10px; }
  .guide { font-size: 13px; gap: 5px; }
  .hero-inner { padding-block: 23px 24px; }
  .hero-photo { left: 19%; background-position: 64% 50%; }
  .hero-photo::after { background: linear-gradient(92deg, #10161e, rgba(16,22,30,.88) 32%,rgba(16,22,30,.45) 68%,rgba(16,22,30,.16)); }
  h1 { font-size: clamp(37px,8.8vw,55px); }
  .hero p { max-width: 65%; margin-top: 7px; font-size: 14px; }
  .primary { margin-top: 12px; padding: 8px 14px; font-size: 15px; }
  .section-links { justify-content: space-between; gap: 6px; }
  .section-links a { min-height: 43px; font-size: 13px; }
  .dashboard { padding-top: 17px; }
  h2 { font-size: 23px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metrics .card { min-height: 136px; padding: 13px; }
  .metric-top { gap: 6px; }
  .metric-top h3 { font-size: 14px; letter-spacing: .01em; }
  .metric-top .ic { width: 16px; height: 16px; }
  .metric-foot { font-size: 13px; }
  .reading { font-size: 45px; }
  .thermo-track { width: 5px; right: 13px; top: 46px; bottom: 33px; }
  .balance-reading { margin: 9px 0; gap: 4px 8px; }
  .balance-reading strong { font-size: 32px; }
  .lower { grid-template-columns: minmax(0,1fr); gap: 12px; margin-top: 12px; }
  .history, .details, .log-panel { padding: 16px; }
  .log-panel { margin-top: 12px; }
  .log-panel li { grid-template-columns: auto 1fr; }
  .log-panel li p, .event-time { grid-column: 1/-1; }
  .plot { height: 164px; }
}
@media(max-width:520px) {
  .wide-label { display: none; }
}
@media(max-width:365px) {
  .narrow-omit { display: none; }
  .brand span { letter-spacing: .025em; }
  .guide { gap: 4px; font-size: 12px; }
  .guide .ic { width: 15px; }
  .metrics .card { padding-inline: 10px; }
  .metric-top { gap: 4px; }
  .metric-top h3 { font-size: 13px; }
  .hero p { max-width: 74%; }
}

.offline-setup { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem .8rem; margin:1rem 0; font-size:.9rem; }
.offline-setup button { width:auto; min-height:40px; padding:.5rem .9rem; border:1px solid currentColor; border-radius:.4rem; background:transparent; color:inherit; font:inherit; cursor:pointer; }
.offline-setup button[hidden] { display:none; }
.offline-setup button:disabled { opacity:.65; cursor:wait; }
.offline-setup [role=status]:empty { display:none; }

.share-trigger { gap: .4rem; min-height: 44px; }
.share-trigger .ic { width: 17px; height: 17px; }
#shareDialog h2 { color: white; font-size: 1.55rem; }
#shareDialog .dialog-head { margin-bottom: 12px; }
#shareSource { color: var(--ink); font-weight: 650; }
#shareSource[data-demo="true"] { background: #ffcf69; color: #2e220d; padding: .4rem .65rem; border-radius: 4px; }
.share-actions, .share-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 13px; }
.share-actions .primary, .share-actions .log-button { margin: 0; min-height: 44px; font-size: 15px; }
.share-tools a { font-size: 14px; text-underline-offset: 3px; padding: 8px 0; }
#sharePreview { display: block; max-width: 100%; height: auto; margin: 12px auto 0; border: 1px solid var(--line); border-radius: 6px; }
#shareStatus:empty { display: none; }
#shareManual { width: 100%; padding: 8px; font-size: 16px; }
@media(max-width:570px) {
  .section-label:has(.share-trigger:not([hidden])) { flex-direction: column-reverse; align-items: stretch; }
}
