/* Uberlogger web UI
 * Colours are tokens on :root; dark mode follows the system setting unless the
 * user picked one with the header toggle (html[data-theme]). */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #1d2330;
  --muted: #5d6676;
  --border: #e1e4ea;
  --border-strong: #cdd2db;
  --accent: #f26b3a;
  --accent-hover: #e05a29;
  --accent-soft: #fff1ea;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --ok-soft: #edfaf1;
  --bad-soft: #fdf0f0;
  --start: #16a34a;
  --start-ring: rgba(22, 163, 74, 0.18);
  --stop: #dc2626;
  --stop-ring: rgba(220, 38, 38, 0.2);
  --focus: rgba(242, 107, 58, 0.35);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  /* chart (ulchart.js reads these) */
  --ul-muted: #5d6676;
  --ul-grid: #e7eaf0;
  --ul-gap: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1a1e26; --surface-2: #20252f; --text: #e6e9ef; --muted: #9aa3b2;
    --border: #2c323e; --border-strong: #3a4250; --accent: #ff7a45; --accent-hover: #ff8f63;
    --accent-soft: #3a2419; --accent-text: #15100d; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --ok-soft: #12291b; --bad-soft: #2f1717; --focus: rgba(255, 122, 69, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --ul-muted: #9aa3b2; --ul-grid: #2a303b; --ul-gap: #f87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --surface: #1a1e26; --surface-2: #20252f; --text: #e6e9ef; --muted: #9aa3b2;
  --border: #2c323e; --border-strong: #3a4250; --accent: #ff7a45; --accent-hover: #ff8f63;
  --accent-soft: #3a2419; --accent-text: #15100d; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --ok-soft: #12291b; --bad-soft: #2f1717; --focus: rgba(255, 122, 69, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); --ul-muted: #9aa3b2; --ul-grid: #2a303b; --ul-gap: #f87171;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { overflow-y: scroll; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 16px; font-weight: 700; color: var(--text); }
h2 { font-size: 1.2rem; margin: 28px 0 10px; font-weight: 650; color: var(--text); }
h3 { font-size: 1.05rem; margin: 26px 0 8px; font-weight: 650; color: var(--text); }
h2.first, h3.first { margin-top: 0; }
p { margin: 0 0 10px; }
ul { margin: 0 0 12px; padding-left: 22px; }
li { margin: 3px 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.muted { color: var(--muted); }
.error-text { color: var(--bad); }
.invisible { display: none; }
.visible { display: block; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- page frame */
#content { min-height: 100vh; }
#window { margin: 0 auto; padding: 0 24px; }   /* full width on every page */

#top { position: sticky; top: 0; z-index: 50; background: var(--bg); padding-top: 10px; }
/* one bar: logo · tabs · status · theme · start/stop */
#toptitle {
  display: flex; align-items: center; gap: 8px 20px; min-height: 56px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 10px 0 16px; box-shadow: var(--shadow);
}
#toptitle .left { flex-shrink: 0; }
#toptitle .left img { height: 30px; width: auto; display: block; }
:root[data-theme="dark"] #toptitle .left img { filter: invert(1) hue-rotate(180deg) saturate(1.4); mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #toptitle .left img { filter: invert(1) hue-rotate(180deg) saturate(1.4); mix-blend-mode: screen; }
}

.status { display: flex; align-items: center; gap: 4px 20px; font-size: 13px; margin-left: auto; }
.status-value .muted { font-weight: 400; }
#status-error[data-error="0"] { display: none; }   /* only shown when there is an error */
/* SD card: capacity bar + free space when mounted, otherwise the state text */
.sd-bar { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.sd-bar-fill { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 3px; transition: width .3s; }
#status-sd[data-level="high"] .sd-bar-fill { background: var(--warn); }
#status-sd[data-level="full"] .sd-bar-fill { background: var(--bad); }
#status-sd[data-bar="0"] .sd-bar { display: none; }
#status-sd[data-mounted="0"] .sd-free { display: none; }
#status-sd[data-mounted="0"] .sd-state { color: var(--bad); }
#status-sd[data-mounted="1"] .sd-state { display: none; }
.sd-free { font-weight: 600; }
#btn_unmount_sdcard_top { padding: 3px; display: inline-flex; color: var(--text); }
#btn_unmount_sdcard_top svg { width: 15px; height: 15px; fill: currentColor; }
.status-item { display: flex; flex-direction: column; line-height: 1.25; }
.status-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.status-value { font-weight: 600; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
#status-logger .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
#status-logger[data-state="idle"] .dot { background: var(--ok); }
#status-logger[data-state="logging"] .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
#status-logger[data-state="error"] .dot { background: var(--bad); }
#status-logger[data-state="logging"] .status-value { color: var(--accent); }
/* an error is shown as a red badge in the header (the only place errors appear) */
#status-error[data-error="1"] { background: var(--bad-soft); border: 1px solid var(--bad); border-radius: var(--radius-sm); padding: 2px 8px; }
#status-error[data-error="1"] .status-label { color: var(--bad); }
#status-error[data-error="1"] .status-value { color: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }

.icon-button {
  font: inherit; font-size: 13px; line-height: 1; padding: 4px 7px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--border-strong); }
.icon-button:disabled { opacity: .4; cursor: default; }
#theme_toggle { padding: 7px; align-self: center; display: inline-flex; color: var(--text); }
#theme_toggle svg { width: 20px; height: 20px; }
#theme_toggle .icon-moon { fill: currentColor; }
#theme_toggle .icon-sun { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; display: none; }
#theme_toggle .icon-sun circle { fill: currentColor; stroke: none; }
/* light mode shows the moon (switch to dark), dark mode the sun (switch to light) */
:root[data-theme="dark"] #theme_toggle .icon-moon { display: none; }
:root[data-theme="dark"] #theme_toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme_toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) #theme_toggle .icon-sun { display: block; }
}

#topmenubar { display: flex; align-self: stretch; min-width: 0; }
#left_buttons { display: flex; overflow-x: auto; scrollbar-width: none; }
#left_buttons::-webkit-scrollbar { display: none; }
#left_buttons button {
  font: inherit; font-weight: 550; color: var(--muted); background: none; border: 0; cursor: pointer;
  padding: 0 12px; height: 100%; min-height: 54px; border-bottom: 2px solid transparent; border-top: 2px solid transparent; white-space: nowrap;
}
#left_buttons button:hover { color: var(--text); }
#left_buttons button.selected { color: var(--accent); border-bottom-color: var(--accent); }
#right_buttons { flex-shrink: 0; }
/* Start/stop logging: the one green/red control in the UI, so it never looks like
   an ordinary button. data-mode is set by generic.js (start | stop | nosd). */
#start_logging_button {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--start); color: #fff; border: 0; border-radius: 999px; padding: 8px 18px 8px 14px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 0 0 3px var(--start-ring); letter-spacing: .01em;
}
#start_logging_button:hover:not(:disabled) { filter: brightness(1.08); }
#start_logging_button .button-icon { font-size: 15px; line-height: 1; }
#start_logging_button[data-mode="stop"] { background: var(--stop); box-shadow: 0 0 0 3px var(--stop-ring); }
#start_logging_button[data-mode="stop"] .button-icon { animation: pulse 1.2s ease-in-out infinite; }
#start_logging_button[data-mode="nosd"], #start_logging_button:disabled {
  background: var(--surface-2); color: var(--muted); box-shadow: none; border: 1px solid var(--border); cursor: default;
}
.button-icon { font-size: 12px; }

#render { padding: 14px 0 8px; }

/* narrower screens: the logger time goes first, then the status moves to its own row */
@media (max-width: 1400px) { #status-time { display: none; } }
@media (max-width: 1180px) {
  #toptitle { flex-wrap: wrap; }
  #toptitle .left { order: 1; }
  #topmenubar { order: 2; }
  #theme_toggle { order: 3; margin-left: auto; }
  #right_buttons { order: 4; }
  #topstatus { order: 5; width: 100%; margin: 0 0 8px; justify-content: flex-start; }
  #status-time { display: flex; }
}
#footer { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0 32px; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

/* ---------------------------------------------------------------- surfaces */
.card, .greybox, .group, .container {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.group { margin-bottom: 16px; }
.group.last { margin-bottom: 0; }
/* panels nested in a card don't need a second frame */
.card .group, .tab-pane .group, .container .greybox, .tab-pane .greybox { box-shadow: none; }
.tab-pane .group { border: 0; padding: 0; background: none; }

.flexcontainer { display: flex; flex-wrap: wrap; gap: 16px; }
.flexdiv-sm { flex: 1 1 200px; }
.flexdiv-md { flex: 1 1 300px; }
.flexdiv-lg { flex: 1 1 420px; }

.note { color: var(--muted); font-size: 13.5px; }
.explanation-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 8px; }

details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0 12px; background: var(--surface-2); max-width: 820px; }
details summary { cursor: pointer; color: var(--muted); font-weight: 550; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-left: 2px; }
details[open] summary::before { transform: rotate(45deg); }
details summary:hover { color: var(--text); }
details[open] summary { margin-bottom: 6px; }
details p, details ul { margin-top: 8px; }
details .explanation-box { background: none; padding: 0; margin: 0; }

/* ---------------------------------------------------------------- buttons */
.button, input[type="button"], input[type="submit"], button.button {
  font: inherit; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none; line-height: 1.3;
  margin: 4px 8px 4px 0; transition: background-color .12s, border-color .12s;
}
.button:hover:not(:disabled), input[type="button"]:hover:not(:disabled), input[type="submit"]:hover:not(:disabled) {
  background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none;
}
.button-secondary, input.button-secondary, button.button-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.button-secondary:hover:not(:disabled), input.button-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.button:disabled, input[type="button"]:disabled, button:disabled { opacity: .45; cursor: default; }
.button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.button.button-small { padding: 6px 12px; font-size: 13.5px; margin: 0; }
/* square icon button with the same height as a small text button (1.3em line + padding) */
.button.button-icon-only { padding: 6px 8px; }
.button-icon-only svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.button-ghost {
  font: inherit; font-size: 13.5px; padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer;
  background: none; border: 1px solid var(--border); color: var(--text);
}
.button-ghost:hover { background: var(--surface-2); }
.button-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.button-group .button { margin: 0; }
.btn-icon { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }

/* ---------------------------------------------------------------- forms */
label { font-size: 14px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; min-height: 36px; max-width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  border-color: var(--accent); outline: 3px solid var(--focus); outline-offset: 0;
}
select:disabled, input:disabled { opacity: .5; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: middle; }
.form-grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 20px; margin: 8px 0 12px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-weight: 550; }
.form-group-narrow { max-width: 220px; }
.field-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.field-inline label { font-weight: 550; }
.select-inline { width: auto; }
.split-size-container { display: flex; gap: 8px; }
.split-size-container input { flex: 1; min-width: 0; }
.split-size-container select { width: 90px; }

/* radio choices rendered as selectable cards */
input.radio { position: absolute; opacity: 0; pointer-events: none; }
label.choice {
  display: block; position: relative; margin: 8px 0; padding: 10px 14px 10px 40px; cursor: pointer; line-height: 1.45;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); max-width: 760px;
}
label.choice::first-line { color: var(--text); font-weight: 600; }
label.choice::before {
  content: ""; position: absolute; left: 14px; top: 13px; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface);
}
input.radio:checked + label.choice { border-color: var(--accent); background: var(--accent-soft); }
input.radio:checked + label.choice::before { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
input.radio:focus-visible + label.choice { outline: 3px solid var(--focus); }

/* ---------------------------------------------------------------- tables */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
table.compact-table { background: var(--surface); }
table.compact-table td input[type="text"] { width: 100%; min-width: 120px; }
table.compact-table td select { width: 100%; min-width: 110px; }
#channel_configuration .compact-table { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
#channel_configuration .compact-table th { background: var(--surface-2); }
#channel_configuration .compact-table td:nth-child(2) { font-weight: 600; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ---------------------------------------------------------------- config tabs */
.config-tab-nav { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.config-tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  font: inherit; font-weight: 550; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; cursor: pointer; white-space: nowrap; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; padding: 8px 2px 4px; }
.tab-pane.active { display: block; }
#configuration > #config { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 20px 20px; max-width: 1100px; }
#calibStatus { color: var(--ok); font-weight: 600; margin-top: 6px; }

/* ---------------------------------------------------------------- files page */
.sd-summary { font-size: 14px; }
.sd-summary b { color: var(--text); }
#filebrowser { padding: 0; overflow: hidden; max-width: 1100px; }
#log .page-head { max-width: 1100px; }
.files-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.breadcrumb { font-size: 14px; }
.breadcrumb a { color: var(--accent); }
.button.button-danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.button.button-danger:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); color: #fff; }
.file-table { width: 100%; border-collapse: collapse; }
.file-table th { background: var(--surface-2); padding: 8px 16px; }
.file-table td { padding: 9px 16px; border-bottom: 1px solid var(--border); }
.file-table tbody tr:last-child td { border-bottom: 0; }
.file-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
.file-table .actions { text-align: right; white-space: nowrap; width: 1%; padding-left: 8px; }
.file-table .num { color: var(--muted); }
.file-row:hover { background: var(--surface-2); }
.file-name { overflow-wrap: anywhere; }
.fname { display: flex; align-items: center; gap: 10px; color: var(--text); }
.fname svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-row.folder .fname { font-weight: 600; color: var(--accent); }
.icon-action {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin-left: 6px; vertical-align: middle;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 18px; line-height: 1; text-decoration: none !important;
}
.icon-action svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-action:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-action.danger:hover { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.files-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
#filelist.muted { padding: 16px; }
.files-note { font-size: 13px; padding: 10px 16px 12px; margin: 0; border-top: 1px solid var(--border); }
.pagination { display: flex; gap: 4px; padding: 10px 16px; }
.pagination a, .pagination .current-page { min-width: 30px; text-align: center; padding: 3px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.pagination .current-page { font-weight: 700; color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- manual page */
.manual { display: grid; grid-template-columns: 240px minmax(0, 820px); gap: 32px; align-items: start; }
.manual > * { min-width: 0; }   /* let the columns shrink (the phone TOC row scrolls instead) */
.manual-toc { position: sticky; top: 150px; }
.manual-toc { max-height: calc(100vh - 170px); overflow-y: auto; }
.toc-group + .toc-group { margin-top: 14px; }
.toc-cat { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 4px 15px; }
.manual-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.manual-toc li { margin: 0; }
.manual-toc a {
  display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--muted); font-size: 14px; text-decoration: none;
}
.manual-toc a:hover { color: var(--text); }
.manual-toc a.active { color: var(--text); font-weight: 600; border-left-color: var(--accent); }
.manual-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 32px 24px; }
.manual { padding-bottom: 45vh; }   /* room so the last sections can also scroll to the top */
.manual-cat {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--accent);
  margin: 30px 0 0; padding: 6px 0 0; border-top: 2px solid var(--border);
}
.manual-cat:first-child { margin-top: 18px; border-top: 0; padding-top: 0; }
.manual-section { padding: 18px 0 18px; border-bottom: 1px solid var(--border); }
.manual-section:last-child, .manual-section:has(+ .manual-cat) { border-bottom: 0; }
.manual-section h2 { margin: 0 0 10px; font-size: 1.25rem; }
.manual-section h3 { font-size: 1rem; margin: 18px 0 6px; }
.manual-section ol, .manual-section ul { padding-left: 22px; }
.manual-section table { margin-top: 8px; }
.manual-section td[colspan] { background: var(--surface-2); color: var(--text); }

/* ---------------------------------------------------------------- live view */
.value-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.value-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 10px; }
.value-card h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.value-card h2 .unit { text-transform: none; letter-spacing: 0; font-weight: 500; }
.value-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 16px; }
.value { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); min-width: 0; }
.value-label { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.value-num { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dio { display: inline-block; min-width: 22px; text-align: center; border-radius: 4px; font-size: 12px; padding: 1px 6px; }
.dio.on { background: var(--ok-soft); color: var(--ok); }
.dio.off { background: var(--surface-2); color: var(--muted); }

.chart-card { padding: 10px 12px 6px; }
.chart-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.toolbar-spacer { flex: 1; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  font: inherit; font-size: 13px; font-weight: 550; padding: 5px 11px; border: 0; border-right: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); }
.live-state { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.follow-btn {
  font: inherit; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; color: var(--muted);
}
.follow-btn:disabled { cursor: default; opacity: 1; }
.follow-btn[data-state="paused"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); cursor: pointer; }
.follow-btn[data-state="paused"]:hover { background: var(--accent); color: var(--accent-text); }
.follow-btn[data-state="lost"] { color: var(--bad); }
.follow-btn .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.live-state .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.paused { background: var(--warn); }
.dot.pin { background: var(--accent); }
#lv-csv-info { font-size: 13px; }
.progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin: 4px 0 8px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.chart-help { font-size: 12.5px; margin: 6px 4px 2px; }

#drop-overlay {
  position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 75%, transparent); backdrop-filter: blur(2px); pointer-events: none;
}
#drop-overlay.show { display: flex; }
#drop-overlay > div {
  width: min(640px, 100%); padding: 56px 24px; border: 3px dashed var(--accent); border-radius: 16px; background: var(--accent-soft);
  color: var(--text); text-align: center; font-size: 20px; font-weight: 650; box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}
#drop-overlay small { display: block; margin-top: 8px; font-size: 14px; font-weight: 400; color: var(--muted); }

/* ---------------------------------------------------------------- chart (uPlot) */
.ulchart { width: 100%; }
.ulchart-digital { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 4px; }
.uplot, .uplot *, .uplot *::before, .uplot *::after { box-sizing: border-box; }
.uplot { font-family: inherit; line-height: 1.5; width: min-content; color: var(--text); }
.u-title { text-align: center; font-size: 18px; font-weight: bold; }
.u-wrap { position: relative; user-select: none; }
.u-over, .u-under { position: absolute; }
.u-under { overflow: hidden; }
.uplot canvas { display: block; position: relative; width: 100%; height: 100%; }
.u-axis { position: absolute; }
.u-legend { font-size: 13.5px; margin: auto; text-align: left; padding: 6px 6px 2px; }
.u-inline { display: block; }
.u-inline * { display: inline-block; }
.u-inline tr { margin-right: 14px; }
.u-legend th { font-weight: 550; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 13.5px; }
.u-legend th > * { vertical-align: middle; display: inline-block; }
.u-legend th, .u-legend td { border: 0; padding: 1px 2px; }
.u-legend .u-marker { width: 1em; height: 1em; margin-right: 4px; background-clip: padding-box !important; }
.u-inline.u-live th::after { content: ":"; vertical-align: middle; }
.u-inline:not(.u-live) .u-value { display: none; }
.u-legend .u-value { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 650; min-width: 7ch; }
.u-legend .u-series:first-child .u-value { min-width: 23ch; }
.u-series > * { padding: 4px; }
.u-series th { cursor: pointer; }
.u-legend .u-off > * { opacity: 0.3; }
.u-select { background: rgba(242, 107, 58, 0.12); position: absolute; pointer-events: none; }
.u-cursor-x, .u-cursor-y { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
.u-hz .u-cursor-x, .u-vt .u-cursor-y { height: 100%; border-right: 1px dashed var(--muted); }
.u-hz .u-cursor-y, .u-vt .u-cursor-x { width: 100%; border-bottom: 1px dashed var(--muted); }
.u-cursor-pt { position: absolute; top: 0; left: 0; border-radius: 50%; border: 0 solid; pointer-events: none; will-change: transform; background-clip: padding-box !important; }
.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off { display: none; }

/* ---------------------------------------------------------------- custom on/off switch (network page) */
.check { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; cursor: pointer; vertical-align: middle; }
.check::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.check:checked { background: var(--accent); }
.check:checked::before { left: 16px; }

/* ---------------------------------------------------------------- firmware update page */
.update-warning { border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 16px; max-width: 760px; }
.update-warning ul { margin: 6px 0 0; }
.fw-file-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; margin: 12px 0; }
.fw-file-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.fw-file-row.fw-row-ok { border-color: var(--ok); background: var(--ok-soft); }
.fw-file-row.fw-row-bad { border-color: var(--bad); background: var(--bad-soft); }
.fw-file-info { flex: 1 1 180px; min-width: 140px; }
.fw-file-name { font-family: ui-monospace, monospace; font-size: .92rem; font-weight: 700; display: block; }
.fw-file-desc { font-size: .8rem; color: var(--muted); }
.fw-hidden-input { display: none; }
.fw-pick-btn { cursor: pointer; padding: 8px 14px !important; white-space: nowrap; margin: 0 !important; }
.fw-chosen-name { flex: 1 1 120px; font-size: .85rem; color: var(--muted); word-break: break-all; }
.fw-status-icon { font-size: 1.1rem; width: 1.4em; text-align: center; }
.fwupdate-error-box {
  border: 1px solid var(--bad); background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 12px 0; max-width: 760px;
}
.fw-progress-track { background: var(--border); height: 8px; border-radius: 4px; overflow: hidden; max-width: 600px; margin: 6px 0 14px; }
.fw-progress-bar { background: var(--accent); height: 100%; border-radius: 4px; transition: width .3s ease; }
.fw-progress-label { font-weight: 600; margin-bottom: 4px; }
.fw-step-list { display: flex; flex-direction: column; gap: 6px; max-width: 600px; }
.fw-step { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--muted); }
.fw-step.fw-step-active { color: var(--accent); font-weight: 600; }
.fw-step.fw-step-done { color: var(--ok); }
.fw-step.fw-step-error { color: var(--bad); }
.fw-step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.fw-step.fw-step-active .fw-step-dot { background: var(--accent); }
.fw-step.fw-step-done .fw-step-dot { background: var(--ok); }
.fw-step.fw-step-error .fw-step-dot { background: var(--bad); }
.fw-step-pct { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  #window { padding: 0 10px; }
  #top { padding-top: 8px; position: static; }
  #toptitle { padding: 8px 8px 0 12px; gap: 4px 10px; }
  #toptitle .left img { height: 28px; }
  #theme_toggle { order: 2; }
  #right_buttons { order: 3; }
  #topmenubar { order: 4; width: 100%; }
  #topstatus { order: 5; gap: 6px 14px; flex-wrap: wrap; }
  #left_buttons button { padding: 0 10px; min-height: 44px; }
  #start_logging_button .button-text { display: none; }
  #start_logging_button { padding: 7px 11px; }
  #render { padding-top: 16px; }
  h1 { font-size: 1.35rem; }
  .card, .greybox, .group, .container { padding: 14px; }
  .files-toolbar .breadcrumb { width: 100%; }
  #configuration > #config { padding: 4px 12px 14px; }
  #channel_configuration { overflow-x: auto; }
  #channel_configuration .compact-table { min-width: 560px; }
  .manual { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .manual-toc { position: static; }
  .manual { padding-bottom: 30vh; }
  .manual-toc { max-height: none; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .toc-group { display: contents; }
  .toc-cat { display: none; }
  .manual-toc ul { border: 0; display: flex; gap: 6px; }
  .manual-toc a { white-space: nowrap; border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; margin: 0; background: var(--surface); font-size: 13px; }
  .manual-toc a.active { border-color: var(--accent); }
  .manual-body { padding: 4px 16px 16px; }
  .manual-section table { display: block; overflow-x: auto; }
  .value-cards { grid-template-columns: 1fr; gap: 12px; }
  .chart-card { padding: 10px 6px 6px; }
}
