:root {
  color-scheme: dark;
  --bg: #101417;
  --surface: #181f24;
  --line: #354249;
  --text: #f0f4f3;
  --muted: #a6b6ba;
  --accent: #ff7148;
  --mint: #73dfbf;
  --amber: #ffd184;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select {
  font: inherit; color: inherit; background: #1c252a; border: 1px solid #46545d;
  border-radius: 5px; min-height: 38px; padding: 5px 10px;
}
button { cursor: pointer; }
button:hover, button[aria-pressed=true] { border-color: #517a70; color: var(--mint); }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
a { color: var(--mint); }
.topbar {
  min-height: 56px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 7px max(25px, calc((100vw - 1600px) / 2)); border-bottom: 1px solid #2b373d;
  background: #141a1e;
}
.brand { display: flex; align-items: center; gap: 13px; white-space: nowrap; }
.brand strong { font-size: 1.63rem; font-weight: 900; letter-spacing: -.075em; line-height: 1; }
.brand strong span { color: var(--accent); }
.product {
  color: #c2ced0; border-left: 1px solid #4a575d; padding-left: 12px;
  font-size: .69rem; font-weight: 750; letter-spacing: .17em;
}
body[data-profile=marine] .product { color: #9ad9ee; }
.health { display: flex; flex-wrap: wrap; gap: 7px 20px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #718087; }
.status.good::before { background: var(--mint); }
.status.warn::before { background: var(--amber); }
.status.red::before { background: var(--accent); }
body[data-profile] #recording { display: none; }
.release { text-align: right; display: grid; gap: 2px; padding-left: 14px; border-left: 2px solid var(--accent); }
.release strong { font-size: .67rem; letter-spacing: .11em; }
.release span { color: var(--muted); font-size: .68rem; }
main { max-width: 1650px; margin: auto; padding: 13px 25px 12px; }
.fixture { background: #4b2b11; color: #ffe0ac; border: 1px solid #986639; border-radius: 5px; padding: 5px 10px; font-size: .75rem; }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dashboard-heading h1 { margin: 0; font-size: 1.73rem; line-height: 1.12; font-weight: 740; letter-spacing: -.043em; }
.dashboard-heading p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.vehicle { display: flex; align-items: baseline; gap: 9px; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.vehicle strong { color: var(--text); font-size: .83rem; border: 1px solid #465963; border-radius: 4px; padding: 4px 7px; letter-spacing: .04em; }
.overview, .plots { display: grid; gap: 12px; margin-bottom: 12px; }
.overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.map-panel, .plot-panel, .instrument-panel { overflow: hidden; display: flex; flex-direction: column; }
.overview > .panel { min-height: clamp(286px, 42.5vh, 460px); }
.plots > .panel { height: clamp(197px, 29.6vh, 340px); }
.panel-header {
  display: flex; justify-content: space-between; align-items: center; gap: 7px;
  min-height: 40px; padding: 5px 13px; border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: .87rem; font-weight: 730; }
.panel-header button { min-height: 26px; padding: 3px 8px; font-size: .68rem; }
.panel-caption { color: var(--muted); font-size: .68rem; white-space: nowrap; }
.map-view { flex: 1; min-height: 183px; position: relative; background: #22312f; }
#map { position: absolute; width: 100%; height: 100%; }
.map-footer { display: flex; justify-content: space-between; gap: 8px; }
.panel-footer { color: var(--muted); min-height: 32px; padding: 7px 13px; border-top: 1px solid var(--line); font-size: .70rem; }
#map-info { color: #d3dfdf; white-space: pre; }
#map-note { text-align: right; }
.map-north {
  position: absolute; left: 10px; top: 9px; padding: 4px 6px; border-radius: 4px;
  background: #17242be8; border: 1px solid #53676c; color: #e0eeee; font: 700 10px/1.15 system-ui;
  display: grid; justify-items: center; pointer-events: none;
}
.map-north span { color: var(--mint); }
.map-vehicle { width: 22px; height: 24px; filter: drop-shadow(0 1px 2px #071116); }
.map-vehicle::before, .map-vehicle::after { content: ""; position: absolute; }
.map-vehicle::before { inset: 0; background: #ffede1; clip-path: polygon(50% 0, 98% 96%, 50% 77%, 2% 96%); }
.map-vehicle::after { inset: 3px 3px 4px; background: #ff7148; clip-path: polygon(50% 0, 98% 96%, 50% 75%, 2% 96%); }
.map-vehicle[data-live=false]::after { background: #809398; }
.maplibregl-ctrl-attrib { background: #142229eb !important; color: var(--text) !important; font-size: 10px; }
.maplibregl-ctrl-attrib a { color: #d1e2e3 !important; }
.maplibregl-ctrl-scale { background: #142229eb !important; color: #d0e1e4; border-color: #aec8cb; font-size: 9px; }
.maplibregl-ctrl-group { background: #16252ce8; border: 1px solid #53676c; }
.maplibregl-ctrl-group button { min-height: 24px; width: 24px; height: 24px; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-group button + button { border-top-color: #4b5a60; }
.instrument-row { display: flex; flex: 1; flex-direction: column; gap: 8px; padding: 9px; min-width: 0; }
.primary-readings, .gauge-grid { display: grid; gap: 6px; grid-auto-rows: minmax(min-content, 1fr); }
.primary-readings { grid-template-columns: 1.28fr 1.05fr .77fr; }
.primary-readings:has(.gauge:only-child) { grid-template-columns: 1fr; }
.gauge-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#gauges { flex: 1; }
.gauge {
  border: 1px solid #2e3d45; background: #1d272e; border-radius: 5px; padding: 6px 9px;
  min-height: 51px; display: flex; flex-direction: column; justify-content: center; min-width: 0;
}
.primary-readings .gauge { min-height: 77px; padding: 8px 11px; }
.primary-readings [data-channel=gps_speed] { border-top: 2px solid var(--mint); background: #1b2b2d; }
.gauge-name { color: #afbec3; font-size: .62rem; font-weight: 650; line-height: 1.15; }
.gauge-reading { display: flex; gap: 5px; align-items: baseline; white-space: nowrap; }
.gauge-value { letter-spacing: -.045em; font-size: 1.2rem; font-weight: 740; line-height: 1.18; }
.primary-readings .gauge-name { font-size: .68rem; }
.primary-readings .gauge-value { font-size: clamp(1.7rem, 2.7vw, 2.65rem); }
.primary-readings [data-channel=gps_speed] .gauge-value { color: var(--mint); }
.gauge-unit { color: #a4b4b8; font-size: .67rem; }
.gauge-state { color: var(--amber); font-size: .62rem; }
.gauge-state:empty { display: none; }
.gauge[data-validity]:not([data-validity=valid]) .gauge-value { color: #839399; }
#extra-readings summary { color: var(--muted); padding: 3px 3px 2px; min-height: 20px; font-size: .68rem; }
#extra-gauges { margin-top: 6px; }
.plot-legend { display: flex; flex-wrap: wrap; min-height: 35px; align-content: center; align-items: center; padding: 3px 13px; gap: 2px 14px; }
.telemetry-graph { overflow: visible; }
.graph-header { position: relative; flex-shrink: 0; }
.graph-header h2 { min-width: 0; }
.graph-header .graph-toggle {
  display: flex; align-items: center; gap: 7px; text-align: left; color: var(--text);
  min-height: 28px; margin-left: -5px; padding: 2px 5px; background: transparent;
  border: 1px solid transparent; font: inherit; line-height: 1.18; overflow-wrap: anywhere;
}
.graph-header .graph-toggle:hover, .graph-header .graph-toggle[aria-expanded=true] {
  color: var(--mint); background: #21302f; border-color: #3d5654;
}
.graph-arrow {
  width: 0; height: 0; flex-shrink: 0; border-top: 4px solid transparent;
  border-bottom: 4px solid transparent; border-left: 6px solid var(--mint);
}
.graph-toggle[aria-expanded=true] .graph-arrow { transform: rotate(90deg); }
.graph-menu {
  position: absolute; z-index: 5; top: calc(100% + 3px); left: 8px; width: min(250px, calc(100% - 16px));
  padding: 6px; background: #1c282e; border: 1px solid #52636b; border-radius: 7px;
  box-shadow: 0 7px 20px #0008;
}
.graph-menu-top {
  display: flex; align-items: center; justify-content: space-between; gap: 7px;
  padding: 5px 7px; font-size: .73rem;
}
.graph-count { color: var(--muted); }
.graph-options { max-height: min(42vh, 280px); overflow-y: auto; }
.graph-options label {
  display: flex; gap: 8px; align-items: center; padding: 4px 7px;
  min-height: 28px; font-size: .76rem; cursor: pointer;
}
.graph-options label:hover { background: #27373e; }
.graph-options label:has(input:disabled) { opacity: .55; cursor: default; }
.graph-options input { min-height: 0; inline-size: 14px; block-size: 14px; margin: 0; flex: none; }
.graph-header .remove-graph { width: 100%; margin-top: 5px; color: #ffb59e; }
.graph-workspace, #wide-graphs { display: grid; gap: 10px; }
.graph-workspace { margin-bottom: 12px; }
.wide-graph { height: clamp(235px, 33vh, 390px); }
.add-graph {
  min-height: 30px; height: 30px; padding: 0; border: 1px dashed #465a61;
  border-radius: 6px; background: var(--surface); color: var(--mint); font-size: 1.25rem; line-height: 1;
}
.instrument-reading { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.instrument-label { color: var(--muted); font-size: .65rem; }
.plot-legend .instrument-label::before {
  content: ""; display: inline-block; vertical-align: .16em; margin-right: 5px; width: 8px; height: 2px; background: var(--trace);
}
.instrument-reading strong { color: var(--text); font-size: 1rem; letter-spacing: -.035em; }
.instrument-unit { color: var(--muted); font-size: .65rem; }
.plot-panel canvas { flex: 1; min-width: 0; min-height: 0; width: 100%; height: 0; display: block; }
.dynamics-content { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 35%; align-items: stretch; }
.dynamics-content canvas { width: 100%; height: 100%; }
.g-values { display: grid; align-content: center; gap: 9px; padding: 0 9px 0 0; }
.g-values .instrument-reading { border-left: 1px solid #4a6067; padding: 3px 0 3px 9px; display: block; }
.g-values .instrument-label { display: block; margin-bottom: 3px; }
.g-values strong { font-size: 1.24rem; }
.g-values .instrument-unit { margin-left: 4px; }
.operations { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
summary { cursor: pointer; padding: 8px 13px; min-height: 34px; font-size: .73rem; color: #ccd7d9; font-weight: 660; }
.drawer{padding:0 14px 12px;color:var(--muted);font-size:.81rem}
.controls{display:flex;align-items:end;flex-wrap:wrap;gap:6px}
.key{display:grid;gap:4px}.key input{max-width:160px}
.log-storage{margin-top:12px;padding-top:2px;border-top:1px solid var(--line)}
.log-storage p{margin:8px 0}
#storage-limit{width:120px}
.download-button{display:inline-flex;align-items:center;min-height:42px;padding:6px 12px;border:1px solid #46545d;border-radius:6px;text-decoration:none}
.download-button[hidden]{display:none}
.download-button:hover{border-color:var(--mint)}
.danger:not(:disabled){color:#ffab96;border-color:#9f5344}
button:disabled,input:disabled{opacity:.55;cursor:default}
.session-row{padding:7px 0;border-top:1px solid var(--line);display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.session-row span{margin-right:auto}
.session-row a{display:inline-flex;min-height:42px;align-items:center}
pre{white-space:pre-wrap;overflow-wrap:anywhere;background:#10171a;padding:9px;border-radius:6px;max-height:320px;overflow:auto}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}

@media (min-width: 1450px) and (min-height: 900px) {
  .topbar { min-height: 68px; }
  main { padding-top: 20px; }
  .dashboard-heading { margin-bottom: 17px; }
  .overview, .plots, .operations { gap: 16px; }
  .overview, .plots { margin-bottom: 16px; }
  .gauge { padding-inline: 14px; }
  .gauge-name { font-size: .73rem; }
  .gauge-value { font-size: 1.4rem; }
}
@media (max-width: 980px) {
  main, .topbar { padding-left: 13px; padding-right: 13px; }
  .primary-readings, .gauge-grid { gap: 5px; }
  .gauge, .primary-readings .gauge { padding-left: 6px; padding-right: 6px; }
  .gauge-value { font-size: 1.08rem; }
  .panel-header { padding-left: 9px; padding-right: 9px; }
  .panel-header h2 { font-size: .79rem; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; }
  .health { order: 3; width: 100%; }
  .overview, .plots, .operations { grid-template-columns: 1fr; margin-bottom: 10px; gap: 10px; }
  .overview > .panel { min-height: 295px; }
  .plots > .panel { height: 230px; }
  .gauge-value { font-size: 1.16rem; }
  .map-footer { flex-wrap: wrap; }
}
@media (max-width: 395px) {
  .gauge-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vehicle span { display: none; }
}
