/* SimovaTrack OTA mainpage styling — same theme as simova-track-idf6's
   on-device web UI (main/web/frontend/*.html), per Italo's 2026-08-15 request.
   Static file, not generated — tools/generate_index.py's TEMPLATE just links
   to it (kept separate from HTML/JS on purpose: easier to maintain than one
   big inline blob). Served straight off html/ by the nginx container, same as
   index.html itself. */

/* --------------------------------------------------------------------
   Color tokens (2026-08-17, Phase 8) — refactored from hardcoded hex to
   CSS custom properties so a light theme can override them in one place.
   The dark block below is byte-for-byte the same values this file had
   hardcoded before the refactor — this is a structural change only, not
   a repaint. Every rule past this point uses var(--token) instead of a
   literal hex; see /shared/theme-toggle.js for how [data-theme] gets
   stamped on <html>. Simova's palette, not ESP32-Bit-Pirate's — see
   CLAUDE.md's design-system note. */
:root {
  --bg: #101418;
  --card-bg: #171c22;
  --border: #232a31;
  --border-alt: #2a333c;
  --input-bg: #1c232b;
  --deep-bg: #0d1013;
  --text: #e8ecef;
  --muted: #8a97a3;
  --notes-text: #b8c0c8;
  --deep-text: #d0d6db;
  --accent: #4d8fef;
  --accent-hover: #357dd8;
  --accent-bg-hover: #1c2a3a;
  --accent-border: #24344a;
  --card-hover-bg: #1a2028;
  --button-primary-hover-bg: #223349;
  --hover-bg-alt: #232c35;
  --on-accent: #fff;
  --danger: #ff6b6b;
  --danger-border: #4a2a2a;
  --danger-hover-bg: #2a1c1c;
  --danger-bg-deep: #3a1414;
  --danger-border-deep: #6b2a2a;
  --danger-text-soft: #f0d0d0;
  --danger-text-soft-2: #ffd2d2;
  --danger-heading: #ff8080;
  --danger-text-alt: #ff8a8a;
  --warn-bg: #3a2c0a;
  --warn-border: #6b4e0a;
  --warn-text: #ffdca0;
  --warn-accent: #ffb020;
  --success-bg: #103a1e;
  --success-border: #1c5f34;
  --success-text: #4ade80;
}

/* Light theme — proposed 2026-08-17, no existing light palette anywhere in
   the Simova family to copy (simova-firmware-server is dark-only), so this
   is a new palette rather than a port. Same structure/contrast roles as
   the dark tokens above, just inverted: white/near-white surfaces, darker
   text, slightly deeper tints on the semantic (danger/warn/success)
   backgrounds so text on them still passes contrast. */
:root[data-theme="light"] {
  --bg: #f3f5f7;
  --card-bg: #ffffff;
  --border: #dde3e9;
  --border-alt: #cfd7de;
  --input-bg: #eef1f4;
  --deep-bg: #eceff2;
  --text: #1a2028;
  --muted: #5b6570;
  --notes-text: #4c5560;
  --deep-text: #2a323a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg-hover: #dce8fd;
  --accent-border: #bdd4f8;
  --card-hover-bg: #f2f6fc;
  --button-primary-hover-bg: #cfe0fb;
  --hover-bg-alt: #e5eaef;
  --on-accent: #fff;
  --danger: #d64545;
  --danger-border: #f0b8b8;
  --danger-hover-bg: #fbe9e9;
  --danger-bg-deep: #fdeeee;
  --danger-border-deep: #f2bcbc;
  --danger-text-soft: #7a2323;
  --danger-text-soft-2: #8a2222;
  --danger-heading: #c22b2b;
  --danger-text-alt: #c22b2b;
  --warn-bg: #fdf1d6;
  --warn-border: #edcd7c;
  --warn-text: #7a5300;
  --warn-accent: #a5680a;
  --success-bg: #e2f6ea;
  --success-border: #8bd6a6;
  --success-text: #17803c;
}

html { font-family: Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
/* Without this, elements that are both `hidden` and carry a `display:flex`
   utility class (.field-row, .toolbar, ...) stay visible — the UA's
   `[hidden]{display:none}` rule loses to any author-stylesheet class rule
   regardless of specificity ordering in the source. Bit us on
   usb-updater/ble-serial's #deviceInfo, which rendered as stray " · "
   separators with empty spans before Connect. 2026-08-17. */
[hidden] { display: none !important; }
/* 96vw not 100%: leaves a hair of breathing room on ultra-wide screens
   instead of the table running edge-to-edge (Italo, 2026-08-15 — "use more
   of horizontal screen"). Was a fixed 1100px, which wasted most of a wide
   monitor. */
body { margin: 0; padding: 2rem 1rem; max-width: 96vw; width: 1600px; margin-left: auto; margin-right: auto; }
h1 { font-size: 1.4rem; margin-bottom: 0.2rem; }
.sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.2rem 1.5rem; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; table-layout: fixed; }
th, td { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; white-space: nowrap; }
th { color: var(--muted); font-weight: normal; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
a { color: var(--accent); }
code { font-size: 0.85rem; }
/* SHA-256 and the AT+GETOTA command are the two values long enough to run off
   the right edge forever if left nowrap — everything else in the table is
   short enough to stay single-line. break-all (not break-word) because these
   are unbroken hex/URL strings with no natural wrap points. */
.sha, .cmd { font-family: monospace; font-size: 0.75rem; color: var(--muted); white-space: normal; word-break: break-all; max-width: 16rem; }
.empty { color: var(--muted); font-style: italic; }
.del-btn, .cmd-btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; cursor: pointer; border-radius: 4px; white-space: nowrap; }
.del-btn { color: var(--danger); border: 1px solid var(--danger-border); background: var(--input-bg); }
/* Action buttons (download/decode/delete etc.) laid out side by side within one
   table cell, instead of each button getting its own <td> — 2026-08-16, crashes
   tab request. Reusable for any actions column that grows past one button. */
.action-row { display: flex; gap: 0.4rem; flex-wrap: nowrap; align-items: center; }
/* .cmd-btn's margin-top (below, for its standalone use elsewhere on the page)
   made it sit lower than .del-btn when the two share an .action-row, which
   read as "the delete button is bigger" (2026-08-16 report) — it wasn't a
   size difference, just misalignment. Reset it inside the row. */
.action-row .cmd-btn, .action-row .del-btn { margin-top: 0; }
/* Below-table pagination controls (page size selector + Prev/Next + "x-y of n")
   — 2026-08-16, crashes tab. Plain flex row, same button styling as the rest of
   the dashboard (inline styles elsewhere in dashboard.js/html) rather than a new
   button class, so a Prev/Next pair doesn't look out of place next to Refresh. */
.pagination-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.pagination-bar label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.pagination-bar select { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 0.3rem 0.5rem; }
.pagination-bar button { padding: 0.4rem 0.9rem; font-size: 0.85rem; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.pagination-bar button:hover:not(:disabled) { background: var(--hover-bg-alt); }
.pagination-bar button:disabled { opacity: 0.4; cursor: default; }
.pagination-info { font-size: 0.85rem; color: var(--muted); }
.del-btn:hover:not(:disabled) { background: var(--danger-hover-bg); }
.del-btn:disabled { opacity: 0.5; cursor: default; }
.cmd-btn { color: var(--accent); border: 1px solid var(--accent-border); background: var(--input-bg); margin-top: 0.4rem; }
.cmd-btn:hover { background: var(--accent-bg-hover); }
.badge { font-size: 0.75rem; padding: 0.15rem 0.55rem; border-radius: 3px; white-space: nowrap; font-weight: bold; }
.badge-stable { background: var(--success-bg); color: var(--success-text); }
.badge-beta { background: var(--warn-bg); color: var(--warn-accent); }
.badge-dev { background: var(--border); color: var(--muted); }
.notes { color: var(--notes-text); max-width: 22rem; white-space: normal; }

/* Flashing-risk warning banner — Italo, 2026-08-15: "big warning note...
   wrong firmware may permanently brick devices". Deliberately loud (red, top
   of page, above the h1) rather than folded into .sub's quiet gray line. */
.warning { background: var(--danger-bg-deep); border: 1px solid var(--danger-border-deep); border-radius: 8px; padding: 1rem 1.2rem; margin-bottom: 1.5rem; }
.warning-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.6rem; }
.warning-head strong { color: var(--danger-heading); font-size: 1rem; letter-spacing: 0.02em; }
.warning p { margin: 0.4rem 0; font-size: 0.85rem; color: var(--danger-text-soft); line-height: 1.4; }
.warning ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.warning li { font-size: 0.85rem; color: var(--danger-text-soft); line-height: 1.4; margin: 0.3rem 0; }
.lang-btn { font-size: 0.75rem; padding: 0.25rem 0.6rem; border-radius: 4px; background: var(--input-bg); color: var(--text); border: 1px solid var(--border-alt); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.lang-btn:hover { background: var(--hover-bg-alt); }

/* Diagnostics page (2026-08-15b): crash dumps + release ELF (debug symbol)
   management, both locked behind admin login — see diagnostics.html/.js.
   "Intelligence data, not exactly sensitive" per Italo, so same visual
   language as the rest of the site, just gated. */
.diag-link { font-size: 0.85rem; margin: 0.8rem 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 0.6rem; }
.section-head h2 { font-size: 1.05rem; margin: 0; }
h2 { font-size: 1.05rem; }
.hint { color: var(--muted); font-size: 0.8rem; }
.card + .card { margin-top: 1.5rem; }
.dl-btn { color: var(--accent); border: 1px solid var(--accent-border); background: var(--input-bg); }
.dl-btn:hover:not(:disabled) { background: var(--accent-bg-hover); }
.dl-btn, .del-btn { font-size: 0.8rem; padding: 0.3rem 0.6rem; cursor: pointer; border-radius: 4px; white-space: nowrap; }
.upload-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.upload-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--muted); }
.upload-form input[type="text"], .upload-form input[type="file"] { background: var(--input-bg); border: 1px solid var(--border-alt); color: var(--text); border-radius: 4px; padding: 0.35rem 0.5rem; font-size: 0.85rem; }
.upload-form input[type="text"] { width: 9rem; }
.upload-form button { align-self: end; }
.locked { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.locked button { margin-top: 1rem; }
.decode-report { background: var(--deep-bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem 1rem; font-size: 0.75rem; line-height: 1.4; color: var(--deep-text); white-space: pre; overflow-x: auto; max-height: 28rem; overflow-y: auto; margin: 0; }
.decode-row td { white-space: normal; padding-top: 0.6rem; padding-bottom: 0.9rem; }

/* Site nav (2026-08-15d) — same small bar atop every page (firmware.html,
   upload.html, diagnostics.html; the landing page at / has its own tiles
   instead, see .tool-grid below). Plain links, not generated/JS-templated —
   four static pages, not worth a shared-include mechanism. */
.top-nav { display: flex; gap: 1.2rem; align-items: center; margin-bottom: 1.2rem; font-size: 0.85rem; }
.top-nav a { color: var(--muted); text-decoration: none; }
.top-nav a:hover { color: var(--accent); }
.top-nav-current { color: var(--text); font-weight: bold; }

/* Version history (2026-08-16, see tools/generate_index.py's render_history)
   — one <details> per product under the "Version history" card. Plain
   browser <details> disclosure triangle, just themed to match the rest of
   the page instead of the default black-on-white. */
details { border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.9rem; }
details + details { margin-top: 0.6rem; }
details summary { cursor: pointer; font-size: 0.9rem; color: var(--text); }
details table { margin-top: 0.8rem; }
.del-version-btn { font-size: 0.75rem; padding: 0.25rem 0.5rem; cursor: pointer; border-radius: 4px; white-space: nowrap; color: var(--danger); border: 1px solid var(--danger-border); background: var(--input-bg); }
.del-version-btn:hover:not(:disabled) { background: var(--danger-hover-bg); }
.del-version-btn:disabled { opacity: 0.5; cursor: default; }

/* Landing page (html/index.html) tool-selector tiles. */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.tool-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.4rem 1.5rem; text-decoration: none; color: inherit; display: block; transition: border-color 0.15s, background 0.15s; }
.tool-card:hover { border-color: var(--accent); background: var(--card-hover-bg); }
.tool-card .tool-icon { font-size: 1.6rem; margin-bottom: 0.6rem; display: block; }
.tool-card h2 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--text); }
.tool-card p { margin: 0; font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
.tool-card .tool-badge { display: inline-block; margin-top: 0.6rem; font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 3px; background: var(--border); color: var(--muted); }

/* Per-tile "unsupported in this browser" state (2026-08-18) — dims the tile
   and swaps its badge to a warning color instead of silently letting a click
   land on a tool page that can only say "not supported" after navigating. */
.tool-card.tool-card-unsupported { opacity: 0.55; }
.tool-card.tool-card-unsupported:hover { border-color: var(--danger-border); background: var(--card-bg); }
.tool-card .tool-badge.tool-badge-unsupported { background: var(--danger-bg-deep); color: var(--danger-text-soft-2); }

/* Admin Dashboard (2026-08-16) — login screen, JWT auth, log viewing */
.login-screen { display: flex; align-items: center; justify-content: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); z-index: 1000; }
.login-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 2rem; width: 100%; max-width: 320px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5); }
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.3rem; }
.login-form { margin: 1.5rem 0; display: flex; flex-direction: column; gap: 1rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.4rem; }
.login-form label span { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.login-form input { background: var(--deep-bg); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 0.5rem 0.7rem; font-size: 0.9rem; }
.login-form input:focus { outline: none; border-color: var(--accent); }
.login-submit { background: var(--accent); color: var(--on-accent); border: none; border-radius: 4px; padding: 0.6rem 1rem; font-size: 0.9rem; cursor: pointer; font-weight: bold; margin-top: 0.5rem; }
.login-submit:hover { background: var(--accent-hover); }
.login-error { color: var(--danger); font-size: 0.8rem; margin: 0; padding: 0.5rem; background: var(--input-bg); border: 1px solid var(--danger-border-deep); border-radius: 4px; }
.lang-selector { display: flex; justify-content: center; margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }

.user-display { color: var(--muted); font-size: 0.85rem; }
.logout-btn { color: var(--danger-text-alt); border: 1px solid var(--danger-border); background: var(--input-bg); font-size: 0.8rem; padding: 0.3rem 0.6rem; cursor: pointer; border-radius: 4px; white-space: nowrap; }
.logout-btn:hover { background: var(--danger-hover-bg); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: end; padding: 1rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.filter-bar label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; }
.filter-bar label span { color: var(--muted); font-weight: 500; }
.filter-bar input, .filter-bar select { background: var(--deep-bg); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 0.35rem 0.5rem; font-size: 0.8rem; }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--accent); }

.stats-bar { background: var(--deep-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.8rem; margin-bottom: 1rem; font-size: 0.85rem; color: var(--muted); }
.stats-bar p { margin: 0; }

.close-btn { color: var(--muted); border: 1px solid var(--border); background: transparent; font-size: 0.8rem; padding: 0.3rem 0.6rem; cursor: pointer; border-radius: 4px; }
.close-btn:hover { color: var(--text); border-color: var(--accent); }

.nav-back { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.nav-back:hover { color: var(--accent); }

/* Decoded ST0 event name, shown as a short tag ahead of the raw protocol
   line in the Device Logs Message column (2026-08-16) — raw text stays
   fully visible right after it, this is additive, not a replacement. */
.event-name-tag { display: inline-block; font-weight: bold; color: var(--success-text); background: var(--success-bg); border-radius: 3px; padding: 0.1rem 0.4rem; margin-right: 0.4rem; font-size: 0.8rem; }

.level-ERROR { color: var(--danger); font-weight: bold; }
.level-WARN { color: var(--warn-accent); }
.level-INFO { color: var(--success-text); }
.level-DEBUG { color: var(--muted); }

/* Devices tab "Last Seen" recency coloring (2026-08-16) — < 1 day green,
   1-7 days yellow, 7+ days (or unknown) red. Same traffic-light convention
   as .level-* above, just keyed off age instead of log level. */
.last-seen-fresh { color: var(--success-text); }
.last-seen-stale { color: var(--warn-accent); }
.last-seen-old { color: var(--danger); }

/* Device Logs table (2026-08-16): fixed-width predictable columns (event
   time/received time/device/level/tag) so Message — the one column with
   genuinely variable-length content — gets the rest of the row instead of
   everything being squeezed/stretched evenly by table-layout:fixed's
   default equal split. nth-child order matches #logsTable's <thead>:
   event time, received time, device, level, tag, message, actions. */
#logsTable th:nth-child(1), #logsTable td:nth-child(1) { width: 11rem; }
#logsTable th:nth-child(2), #logsTable td:nth-child(2) { width: 11rem; }
#logsTable th:nth-child(3), #logsTable td:nth-child(3) { width: 9rem; }
#logsTable th:nth-child(4), #logsTable td:nth-child(4) { width: 5rem; }
#logsTable th:nth-child(5), #logsTable td:nth-child(5) { width: 8rem; }
#logsTable th:nth-child(6), #logsTable td:nth-child(6) { white-space: normal; word-break: break-word; }
#logsTable th:nth-child(7), #logsTable td:nth-child(7) { width: 4rem; }

/* Tab navigation styling */
.tab-btn { background: transparent; border: none; color: var(--muted); font-size: 0.9rem; padding: 0.5rem 0.8rem; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab-btn:hover { color: var(--text); border-bottom-color: var(--accent); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }

/* --------------------------------------------------------------------
   Device-tool pages (usb-updater, usb-serial, ble-serial) — 2026-08-17.
   Same palette as the rest of the site; monospace is only used inside the
   log console / hex-ish output, never for page chrome, per CLAUDE.md's
   design-system note (a straight port of ESP32-Bit-Pirate's terminal theme
   was explicitly rejected — this stays Simova's house style). */

.notice { font-size: 0.85rem; padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.notice.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.notice.error { background: var(--danger-bg-deep); border: 1px solid var(--danger-border-deep); color: var(--danger-text-soft-2); }
.notice.info { background: var(--card-bg); border: 1px solid var(--border); color: var(--muted); }
.notice.hidden { display: none; }

.toolbar { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.toolbar .spacer { flex: 1; }

.status-pill { font-size: 0.75rem; padding: 0.25rem 0.7rem; border-radius: 999px; background: var(--input-bg); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.status-pill.connected { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.status-pill.connecting { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-accent); }
.status-pill.error { background: var(--danger-bg-deep); border-color: var(--danger-border-deep); color: var(--danger-heading); }

button.primary { background: var(--accent-bg-hover); color: var(--accent); border: 1px solid var(--accent-border); border-radius: 4px; padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; }
button.primary:hover:not(:disabled) { background: var(--button-primary-hover-bg); }
button.primary:disabled { opacity: 0.4; cursor: default; }
button.secondary { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; }
button.secondary:hover:not(:disabled) { background: var(--hover-bg-alt); }
button.secondary:disabled { opacity: 0.4; cursor: default; }
button.danger { background: var(--input-bg); color: var(--danger); border: 1px solid var(--danger-border); border-radius: 4px; padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; }
button.danger:hover:not(:disabled) { background: var(--danger-hover-bg); }
button.danger:disabled { opacity: 0.4; cursor: default; }

select, input[type="text"], input[type="number"], input[type="file"] { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 0.4rem 0.6rem; font-size: 0.85rem; font-family: inherit; }

/* Generic notification modal (2026-08-18), ported from simova-track-idf6's
   shared_body.js/shared.css — see shared/modal.js for showModal()/
   closeModal()/showSpinnerModal(). One overlay, built lazily on first use,
   reused across every popup that wants one. */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); align-items: center; justify-content: center; z-index: 2000; padding: 1rem; }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.6rem 1.8rem; min-width: 18rem; max-width: 26rem; text-align: center; }
.modal-icon { font-size: 2.6rem; margin-bottom: 0.75rem; line-height: 1; }
.modal-icon:empty { display: none; }
.modal-title { font-size: 1.15rem; margin: 0 0 0.75rem; color: var(--text); }
.modal-message { font-size: 0.9rem; color: var(--muted); line-height: 1.5; margin: 0; }
.modal-actions { display: flex; gap: 0.6rem; margin-top: 1.5rem; }
.modal-actions:empty { display: none; margin-top: 0; }
.modal-actions button { flex: 1 1 auto; }
.modal-progress { height: 3px; background: var(--border); border-radius: 999px; margin-top: 1.5rem; overflow: hidden; }
.modal-progress-bar { height: 100%; background: var(--accent); width: 100%; transform-origin: left; }
@keyframes modal-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.modal-spinner { display: inline-block; width: 1.6rem; height: 1.6rem; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: modal-spin 0.8s linear infinite; }
@keyframes modal-spin { to { transform: rotate(360deg); } }

/* Font ported from ESP32-Bit-Pirate's web-serial-terminal (2026-08-17,
   Phase 7 — "font style and size, could be nice to port this to our app
   terminals"): Menlo-first stack, 14px default, 1.2 line-height. Size is
   adjustable 11-22px via .term-font-btn +/- buttons, see
   /shared/terminal-font.js — the inline font-size set there overrides this
   default once the page's stored preference (if any) loads. */
.log-console { background: var(--deep-bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem 1rem; font-family: Menlo, "Courier New", Courier, "Liberation Mono", monospace; font-size: 14px; line-height: 1.2; color: var(--deep-text); white-space: pre-wrap; word-break: break-all; height: 22rem; overflow-y: auto; }
.log-console .log-err { color: var(--danger-heading); }
.log-console .log-ok { color: var(--success-text); }

.term-font-btn { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; width: 1.8rem; height: 1.8rem; font-size: 0.8rem; cursor: pointer; line-height: 1; padding: 0; }
.term-font-btn:hover { background: var(--hover-bg-alt); }

.progress-bar { background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px; height: 0.6rem; overflow: hidden; margin: 0.5rem 0; }
.progress-bar-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.15s; }

.muted { color: var(--muted); }
.field-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.field-row label { font-size: 0.8rem; color: var(--muted); }

.serial-input-row { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.serial-input-row input[type="text"] { flex: 1; font-family: monospace; }

.file-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; font-size: 0.85rem; }
.file-row .file-name { flex: 1; color: var(--text); }
.file-row .file-size { color: var(--muted); font-size: 0.75rem; }

/* --------------------------------------------------------------------
   Theme toggle button (2026-08-17, Phase 8) — injected into each page's
   .toolbar/.top-nav by /shared/theme-toggle.js. Kept here rather than
   inline in the JS so it inherits the same button.secondary-ish sizing
   without duplicating it. */
.theme-toggle-btn {
  position: fixed; top: 1rem; right: 1rem; z-index: 500;
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; width: 2.2rem; height: 2.2rem; font-size: 1rem;
  cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.theme-toggle-btn:hover { background: var(--hover-bg-alt); border-color: var(--accent); }

/* Language toggle (2026-08-17) — same fixed-corner pattern as
   .theme-toggle-btn above, injected by /shared/i18n.js, sits just to its
   left so the two don't overlap. EN/PT text label instead of an icon since
   a flag emoji reads ambiguous for "Portuguese" specifically. */
.lang-toggle-btn {
  position: fixed; top: 1rem; right: 3.6rem; z-index: 500;
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; min-width: 2.2rem; height: 2.2rem; padding: 0 0.6rem;
  font-size: 0.75rem; font-weight: bold; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lang-toggle-btn:hover { background: var(--hover-bg-alt); border-color: var(--accent); }

/* --------------------------------------------------------------------
   AT-command mode + ANSI-color + IDF-log-level-color + Follow toggles
   (2026-08-17/18) — inline toolbar buttons (not fixed-position like
   theme/lang above), injected by /shared/at-commands.js,
   /shared/ansi-color.js, /shared/idf-log-level.js and
   /shared/follow-scroll.js into usb-serial's and ble-serial's existing
   .toolbar. Same .secondary sizing, with a `.active` state (accent border
   + tinted background) so it's obvious at a glance whether the mode is on. */
.at-toggle-btn.active, .ansi-toggle-btn.active, .idf-toggle-btn.active, .follow-toggle-btn.active {
  background: var(--accent-bg-hover); color: var(--accent); border-color: var(--accent);
}

/* Row of common AT-command buttons, shown under the toolbar once AT mode
   is toggled on ("adapts current terminal for it and show common
   commands" — not a separate terminal). Small chip buttons, wraps freely. */
.at-preset-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.at-preset-btn {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.75rem; font-family: monospace;
  cursor: pointer;
}
.at-preset-btn:hover { background: var(--hover-bg-alt); border-color: var(--accent); }

/* AT-mode reply-line classification (classifyAtLine() in at-commands.js) —
   a `+KEY:` line gets the accent color; OK/ERROR reuse the existing
   .log-ok/.log-err classes already defined above. */
.log-console .log-at-key { color: var(--accent); }

/* ANSI foreground-only colors (ansi-color.js) — "letters colours only, no
   background or fancy shit". Standard 8 + bright 8, picked to stay legible
   on both the dark log-console background and a light-theme page (the
   console itself always uses --deep-bg/--deep-text regardless of theme, so
   these are fixed values, not theme variables — same reasoning .log-err/
   .log-ok above already use var(--danger-heading)/var(--success-text),
   which are themselves dark-console-tuned). */
.log-console .ansi-fg-black { color: #6b7580; }
.log-console .ansi-fg-red { color: #ff6b6b; }
.log-console .ansi-fg-green { color: #4ade80; }
.log-console .ansi-fg-yellow { color: #e8c547; }
.log-console .ansi-fg-blue { color: #5b9dff; }
.log-console .ansi-fg-magenta { color: #d68fff; }
.log-console .ansi-fg-cyan { color: #4dd4d4; }
.log-console .ansi-fg-white { color: #e8ecef; }
.log-console .ansi-fg-bright-black { color: #8a97a3; }
.log-console .ansi-fg-bright-red { color: #ff9494; }
.log-console .ansi-fg-bright-green { color: #7ef0a8; }
.log-console .ansi-fg-bright-yellow { color: #f5da7a; }
.log-console .ansi-fg-bright-blue { color: #8ab8ff; }
.log-console .ansi-fg-bright-magenta { color: #e4b3ff; }
.log-console .ansi-fg-bright-cyan { color: #7ee8e8; }
.log-console .ansi-fg-bright-white { color: #ffffff; }

/* ESP-IDF log-level whole-line coloring (idf-log-level.js) — E/W/I/D/V,
   applied on the line's own <div> the same way .log-ok/.log-err already
   are, not as an inner span. Same color values as the matching ansi-fg-*
   classes above for visual consistency (error=red, warn=yellow, info=green,
   debug=cyan, verbose=dim gray — ESP-IDF's own conventional level colors). */
.log-console .idf-lvl-error { color: #ff6b6b; }
.log-console .idf-lvl-warn { color: #e8c547; }
.log-console .idf-lvl-info { color: #4ade80; }
.log-console .idf-lvl-debug { color: #4dd4d4; }
.log-console .idf-lvl-verbose { color: #8a97a3; }

/* --------------------------------------------------------------------
   Remote Control panel (shared/remote-panel.js) — Phase 13, 2026-08-18.
   Reuses .card/.tab-btn/.status-pill/button.primary|secondary|danger
   rather than inventing new chrome; only the bits those don't cover
   (code display, tab container spacing) get their own rules here. */
.remote-panel .remote-subtitle { font-size: 0.8rem; }
.remote-tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.remote-code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 1.1rem; letter-spacing: 0.15em; background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.3rem 0.6rem; }
