:root {
  --accent: #0d9488;
  --accent-dark: #0f766e;
  --ink: #1d2330;
  --muted: #6b7385;
  --border: #e3e6ec;
  --bg: #f5f6f8;
  --surface: #fff;
  --danger: #b3261e;
  --warn-bg: #fff3c4;
  --warn-fg: #7a5b00;
  --ok-bg: #dcf5ea;
  --ok-fg: #0f6b3f;
  --err-bg: #fbdcdc;
  --err-fg: #8a1f18;
  --info-bg: #cffafe;
  --info-fg: #155e75;
  --prep-bg: #ede9fe;
  --prep-fg: #5b21b6;
  --selected-bg: #d5efeb;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent-dark); }
a:hover { color: var(--accent); }

h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 24px 0 8px; }

main { padding: 20px 24px 48px; max-width: 1600px; margin: 0 auto; }

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav .brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 14px 16px 14px 0;
  margin-right: 8px;
}
.nav-links { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-links a {
  color: #c9d0e0;
  text-decoration: none;
  padding: 14px 12px;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: #fff; }
.nav-links a.active { color: #fff; border-bottom-color: var(--accent); }
.nav-links .logout { margin-left: auto; }
.nav-links .logout button {
  background: none;
  border: 1px solid #3a4257;
  color: #c9d0e0;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-links .logout button:hover { color: #fff; border-color: #565f78; }
.nav-burger {
  display: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 10px;
}
.nav-toggle:checked ~ .nav-burger { color: var(--accent); }

@media (max-width: 720px) {
  .nav-burger { display: block; margin-left: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--ink);
    padding: 4px 0 8px;
  }
  .nav-toggle:checked ~ .nav-links { display: flex; }
  .nav-links a { padding: 12px 20px; border-bottom: none; border-left: 3px solid transparent; }
  .nav-links a.active { border-left-color: var(--accent); }
  .nav-links .logout { margin: 6px 20px 0; }
}

/* Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); }
.error { color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.grid thead th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border); }
.grid tbody tr:nth-child(even) { background: var(--bg); }
.grid tbody tr:hover { background: #e9ebef; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Weight and dimensions are short: tight padding, and the header wraps so it does not set the column width. */
.grid .weight-col, .grid .dim-col { width: 8%; padding-left: 6px; padding-right: 6px; text-align: right; font-variant-numeric: tabular-nums; }
.grid thead th.weight-col, .grid thead th.dim-col { white-space: normal; }
.grid tr.new { animation: flash 2s ease-out; }
@keyframes flash { from { background: #fff6c2; } to { background: transparent; } }
.grid tbody tr.selected, .grid tbody tr.selected:hover { background: var(--selected-bg); }
.grid .select-col { width: 1%; }
.grid .codes-col { max-width: 260px; white-space: normal; overflow-wrap: anywhere; }
.grid .select-col input { width: 18px; height: 18px; margin: 0; vertical-align: middle; }
.thumb { max-width: 115px; max-height: 77px; display: block; border-radius: 4px; background: var(--border); }
.full { max-width: 100%; max-height: 70vh; border-radius: var(--radius); border: 1px solid var(--border); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-err { background: var(--err-bg); color: var(--err-fg); }
.badge-neutral { background: var(--border); color: var(--muted); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-prep { background: var(--prep-bg); color: var(--prep-fg); }

/* Stat card (dashboard) */
.stat-card {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  text-decoration: none;
  color: var(--ink);
}
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat-card--alert { border-color: var(--err-fg); }
.stat-card--alert strong { color: var(--err-fg); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters input, .filters select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.filters input:focus, .filters select:focus, button:focus, .login input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.filters button {
  font: inherit;
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.filters button:hover { background: var(--accent-dark); }
.filters a { align-self: center; font-size: 13px; }
.filters label.grow { flex: 1 1 280px; max-width: 350px; }
.filters label.grow input { width: 100%; box-sizing: border-box; }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.pager a, .pager strong {
  display: inline-flex;
  min-width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 6px;
  text-decoration: none;
}
.pager a { border: 1px solid var(--border); background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager strong { background: var(--accent); color: #fff; }
.pager .summary { color: var(--muted); margin-right: auto; }

.new-bar {
  background: var(--warn-bg);
  color: var(--warn-fg);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.new-bar a { color: var(--warn-fg); font-weight: 600; }

.flash {
  background: var(--ok-bg);
  color: var(--ok-fg);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-weight: 600;
}

.bulk-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
/* Sticky bottom action bar: floats 20px above the window edge; the margin is 0 so the last table row can scroll above it. */
.bulk-bar { position: sticky; bottom: 20px; z-index: 10; margin-bottom: 0; background: var(--surface); box-shadow: 0 -6px 20px rgba(20, 24, 36, .22), 0 -1px 3px rgba(20, 24, 36, .14); }
/* The copy above the table scrolls away with the page. */
.bulk-bar.bulk-bar-top { position: static; margin-bottom: 12px; box-shadow: none; }
.bulk-bar .per-page { gap: 6px; }
.bar-summary { margin-left: auto; color: var(--muted); }
.bulk-bar[hidden], .bulk-bar [hidden] { display: none; }
.bulk-bar label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.bulk-bar button {
  font: inherit;
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.bulk-bar button:hover { background: var(--accent-dark); }
.bulk-bar button.danger { background: var(--err-fg); }
.bulk-bar button.danger:hover { filter: brightness(0.85); }
.bulk-bar select { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; }
.bulk-bar select:disabled { color: var(--muted); cursor: not-allowed; }
.bulk-bar button:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

/* Confirmation modal (app/static/modal.js) */
.modal {
  border: none;
  border-radius: 12px;
  padding: 24px;
  width: min(440px, calc(100vw - 32px));
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(20, 24, 36, 0.35);
}
.modal::backdrop { background: rgba(20, 24, 36, 0.55); }
.modal[open] { animation: modal-in 0.15s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-title { margin: 0 0 8px; font-size: 18px; }
.modal-text { margin: 0 0 16px; color: var(--muted); white-space: pre-line; }
.modal-word { display: block; margin-bottom: 16px; }
.modal-word[hidden] { display: none; }
.modal-word strong { font-family: ui-monospace, Consolas, monospace; color: var(--err-fg); }
.modal-word-input {
  display: block; width: 100%; margin-top: 6px; padding: 8px 10px;
  font: inherit; border: 1px solid var(--border); border-radius: 6px;
}
.modal-word-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button {
  font: inherit; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: #fff;
}
.modal-actions button:hover { background: var(--accent-dark); }
.modal-actions .modal-cancel { background: var(--bg); color: var(--ink); border: 1px solid var(--border); }
.modal-actions .modal-cancel:hover { background: var(--border); }
.modal-actions .modal-ok.danger { background: var(--err-fg); }
.modal-actions .modal-ok.danger:hover { filter: brightness(0.85); }
.modal-actions .modal-ok:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; filter: none; }

/* Warning notice ("Export beží, nevypínajte"): Modal.notice({alert: true}) puts .modal-alert on the shared dialog. */
.modal.modal-alert {
  width: min(620px, calc(100vw - 32px));
  padding: 32px 36px 28px;
  background: #fdeeee;
  border: 4px solid var(--danger);
  box-shadow: 0 0 0 6px rgba(179, 38, 30, 0.18), 0 24px 60px rgba(20, 24, 36, 0.45);
  text-align: center;
}
.modal.modal-alert::backdrop { background: rgba(60, 10, 10, 0.6); }
.modal-alert .modal-title {
  margin: 0 0 14px; font-size: 46px; line-height: 1.2; font-weight: 800;
  color: var(--danger); text-transform: uppercase; letter-spacing: .01em; white-space: pre-line;
}
.modal-alert .modal-title::before { content: "\26A0\FE0F"; display: block; margin-bottom: 8px; font-size: 54px; line-height: 1; }
.modal-alert .modal-text { color: var(--ink); font-size: 18px; margin-bottom: 24px; white-space: normal; }
.modal-alert .modal-actions { justify-content: center; }
.modal-alert .modal-actions button { font-size: 18px; padding: 12px 36px; font-weight: 700; }
.modal-alert .modal-actions .modal-ok { background: var(--danger); }
.modal-alert .modal-actions .modal-ok:hover { background: #8f1d17; }

.row-actions { display: flex; gap: 8px; }
.row-actions form { margin: 0; }
.row-actions button.danger { background: var(--err-fg); color: #fff; border: none; border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit; }
.row-actions button.danger:hover { filter: brightness(0.85); }

.issue-banners { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.issue-banner {
  display: block;
  background: var(--err-bg);
  color: var(--err-fg);
  border: 1px solid #f0b4b0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
}
.issue-banner:hover { color: var(--err-fg); text-decoration: underline; }
.issue-banner.active { outline: 2px solid var(--danger); }
.issue-banner[hidden] { display: none; }

.state-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.state-chip {
  display: inline-block;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.state-chip:hover { color: var(--accent-dark); border-color: var(--accent); }
.state-chip.badge-neutral, .state-chip.badge-prep, .state-chip.badge-info,
.state-chip.badge-warn, .state-chip.badge-ok, .state-chip.badge-err { border-color: transparent; }
.state-chip.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.state-chip.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.state-chip.badge-err { background: var(--err-bg); color: var(--err-fg); }
.state-chip.badge-neutral { background: var(--border); color: var(--muted); }
.state-chip.badge-info { background: var(--info-bg); color: var(--info-fg); }
.state-chip.badge-prep { background: var(--prep-bg); color: var(--prep-fg); }
.state-chip[class*="badge-"]:hover { filter: brightness(0.95); color: inherit; }
.state-chip[class*="badge-"].active { filter: brightness(0.82); font-weight: 600; box-shadow: inset 0 0 0 2px currentColor; }
.state-chip.active:not([class*="badge-"]) { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.thumbs a { display: flex; gap: 6px; align-items: center; }
.thumb-missing {
  position: relative;
  display: inline-block;
  width: 96px;
  height: 64px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.thumb-missing::before, .thumb-missing::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 141%;
  height: 2px;
  background: var(--muted);
  opacity: 0.6;
}
.thumb-missing::before { transform: translate(-50%, -50%) rotate(45deg); }
.thumb-missing::after { transform: translate(-50%, -50%) rotate(-45deg); }
/* Three images side by side; they wrap below each other on a narrow screen. */
.detail-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.detail-images figure { margin: 0; min-width: 0; }
.detail-images a { display: block; }
.detail-images .full { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--border); }
.detail-images figcaption { color: var(--muted); font-size: 12px; margin-top: 4px; }
.full-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  padding: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.banner-key { background: var(--warn-bg); color: var(--warn-fg); }
.banner-key code { font-size: 15px; user-select: all; }

/* Detail pages */
.back-link { display: inline-block; margin-bottom: 8px; font-size: 13px; }
dl.card { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.card dt { font-weight: 600; color: var(--muted); }
dl.card dd { margin: 0; }
.read-codes { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.read-codes th, .read-codes td { padding: 2px 12px 2px 0; text-align: left; }
.read-codes th { color: var(--muted); font-weight: 600; }
.read-json pre { max-height: 320px; overflow: auto; }
/* Every non-destructive button on the scan detail looks like "Orezať znova"; "Zmazať" is the red one. */
.detail-actions button {
  font: inherit;
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.detail-actions button:hover { background: var(--accent-dark); }
.detail-actions button.danger { background: var(--err-fg); }
.detail-actions button.danger:hover { filter: brightness(0.85); }

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow: auto;
  max-height: 50vh;
  font-size: 12px;
}
code { background: #eef0f4; padding: 1px 4px; border-radius: 3px; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  padding: 32px;
  min-width: 300px;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(29, 35, 48, 0.08);
}
.login h1 { text-align: center; color: var(--accent-dark); }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.login button {
  font: inherit;
  padding: 9px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-top: 4px;
}
.login button:hover { background: var(--accent-dark); }
.state-note { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; }

.send-dialog { width: min(440px, calc(100vw - 32px)); }
.send-pile { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 12px; margin: 0 0 12px; }
.send-pile legend { font-weight: 600; padding: 0 4px; }
.send-choice { display: block; margin: 8px 0 4px; }
.send-dialog input[type="text"], .send-dialog select { width: 100%; box-sizing: border-box; padding: 6px 8px; font: inherit; }
.send-branch { display: block; margin-bottom: 16px; font-weight: 600; }
.send-branch select { margin-top: 4px; font-weight: normal; }
.pile-col { white-space: nowrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.detail-actions form { margin: 0; }
.release-bar { display: flex; justify-content: flex-end; margin: 0 0 12px; }
button.btn-export {
  font: inherit; cursor: pointer; border: 1px solid #a21caf; border-radius: 6px;
  background: #c026d3; color: #fff;
  font-size: 16px; font-weight: 700; padding: 11px 22px;
  box-shadow: 0 2px 6px rgba(162, 28, 175, .35);
}
button.btn-export:hover:not(:disabled) { background: #a21caf; border-color: #86198f; color: #fff; }
button.btn-export:focus-visible { outline: 3px solid #f0abfc; outline-offset: 2px; }
.export-banners { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.export-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }
.export-banner-outage { background: var(--err-bg); color: var(--err-fg); border: 1px solid #f0b4b0; }
.export-banner-off { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.inline-form { margin: 0; display: inline; }
.attempts { display: flex; flex-direction: column; gap: 8px; }
.attempt summary { cursor: pointer; font-weight: 600; }
.attempt pre { max-height: 320px; overflow: auto; }

/* Image viewer (app/static/lightbox.js) */
.lightbox {
  border: 0; border-radius: var(--radius); padding: 16px; background: var(--surface); color: var(--ink);
  width: min(96vw, 1400px); max-height: 94vh; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.lightbox::backdrop { background: rgba(20, 24, 36, 0.7); }
.lightbox-close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; line-height: 1;
  font-size: 22px; padding: 0; background: var(--bg); color: var(--ink); border: 1px solid var(--border); cursor: pointer;
}
.lightbox-body { display: flex; gap: 12px; justify-content: center; align-items: flex-start; margin-top: 24px; }
.lightbox-body figure { margin: 0; flex: 1 1 0; min-width: 0; text-align: center; }
.lightbox-body img { max-width: 100%; max-height: 78vh; border-radius: 4px; background: var(--border); }
.lightbox-body figcaption { color: var(--muted); font-size: 13px; margin-top: 6px; }
.lightbox-missing {
  display: flex; align-items: center; justify-content: center; min-height: 160px; border-radius: 4px;
  background: var(--border); color: var(--muted);
}
.lightbox-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 12px; }
.lightbox-nav[hidden] { display: none; }
.lightbox-nav button {
  width: 40px; height: 40px; border-radius: 50%; font-size: 26px; line-height: 1; padding: 0;
  background: var(--accent); color: #fff; border: 0; cursor: pointer;
}
.lightbox-nav button:hover { background: var(--accent-dark); }
.lightbox-caption { min-width: 200px; text-align: center; color: var(--muted); }
@media (max-width: 700px) { .lightbox-compare .lightbox-body { flex-direction: column; align-items: stretch; } }

/* Controller widget on /scans (docs/reference/controller-widget.md).
   The panel's data-tone (the station badge tone) sets --tone / --tone-bg for the accent bar, the light and the header. */
.controller { display: flex; flex-direction: column; padding: 0; overflow: hidden; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .06); }
.controller-picker { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 14px 16px;
  background: linear-gradient(90deg, #ecfeff, var(--surface) 70%); border-left: 5px solid var(--accent); }
.controller-picker-title { font-weight: 700; color: var(--accent-dark); }
.controller-picker label { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.controller-picker select { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 180px; }
.controller-picker select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.controller-panel { --tone: #94a3b8; --tone-bg: #f1f5f9; display: flex; flex-direction: column; border-left: 5px solid var(--tone); transition: border-color .3s; }
.controller-panel[data-tone="badge-ok"] { --tone: #16a34a; --tone-bg: #ecfdf3; }
.controller-panel[data-tone="badge-warn"] { --tone: #f59e0b; --tone-bg: #fffbeb; }
.controller-panel[data-tone="badge-err"] { --tone: #dc2626; --tone-bg: #fef2f2; }

.controller-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 16px;
  background: linear-gradient(90deg, var(--tone-bg), var(--surface) 75%); border-bottom: 1px solid var(--border); }
.controller-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.controller-title-label { font-weight: 500; color: var(--muted); }
.controller-change { font: inherit; font-size: 12px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--accent-dark); cursor: pointer; }
.controller-change:hover { border-color: var(--accent); background: #f0fdfa; }
.controller-broker { margin-left: auto; display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.controller-broker .badge::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%;
  background: currentColor; vertical-align: 1px; }

.controller-state { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 16px; }
.controller-light { width: 16px; height: 16px; border-radius: 50%; background: var(--tone); flex: none;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--tone) 18%, transparent); }
.controller-panel[data-tone="badge-ok"] .controller-light { animation: controller-pulse 2s ease-out infinite; }
@keyframes controller-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 45%, transparent); }
  100% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--tone) 0%, transparent); }
}
.controller-state .badge { font-size: 15px; padding: 5px 14px; }
.controller-note { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }

.controller-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.controller-info { min-width: 0; }
/* Device cards on the right (Dataman, scale); data-tone = the card's badge tone. */
.controller-cards { display: flex; gap: 12px; margin: 12px 16px 14px 0; }
.controller-card { --card: #94a3b8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 210px; padding: 12px 14px; border: 1px solid var(--border); border-top: 3px solid var(--card); border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 8%, var(--surface)), var(--surface)); text-align: center; }
.controller-card[data-tone="badge-ok"] { --card: #16a34a; }
.controller-card[data-tone="badge-warn"] { --card: #f59e0b; }
.controller-card[data-tone="badge-err"] { --card: #dc2626; }
.controller-card-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.controller-card-detail { font-size: 12px; color: var(--muted); line-height: 1.35; }
.controller-weight { font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.1; }
.controller-weight-value { font-size: 30px; font-weight: 700; }
.controller-weight-unit { font-size: 16px; font-weight: 600; color: var(--muted); }
.controller-weight-stale { opacity: .45; }
@media (max-width: 900px) {
  .controller-main { grid-template-columns: 1fr; }
  .controller-cards { margin: 0 16px 14px; }
  .controller-card { flex: 1 1 0; width: auto; }
}
.controller-error { display: flex; gap: 12px; align-items: flex-start; margin: 0 16px 14px; padding: 10px 14px;
  background: var(--err-bg); color: var(--err-fg); border: 1px solid #f5b5b1; border-left: 4px solid #dc2626; border-radius: var(--radius); }
.controller-error-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #dc2626; color: #fff;
  font-weight: 800; font-size: 14px; line-height: 22px; text-align: center; }
.controller-error-meta { font-size: 13px; opacity: .85; margin-top: 2px; }
.controller-hint { margin-top: 6px; padding: 6px 10px; font-weight: 600; background: #fff7d6; color: #7a4b00; border-radius: 6px; }

.controller-foot { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 16px;
  background: var(--bg); border-top: 1px solid var(--border); }
.controller-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.controller-cmd { --btn: #475569; display: inline-flex; gap: 8px; align-items: center; font: inherit; font-weight: 600;
  padding: 8px 18px; border: 1px solid var(--btn); border-radius: 8px; background: var(--surface); color: var(--btn); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s, transform .05s; }
.controller-cmd[data-action="start"] { --btn: #15803d; }
.controller-cmd[data-action="stop"] { --btn: #b45309; }
.controller-cmd[data-action="reset"] { --btn: #1d4ed8; }
.controller-cmd:hover { background: var(--btn); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--btn) 35%, transparent); }
.controller-cmd:active { transform: translateY(1px); }
.controller-cmd:focus-visible { outline: 2px solid var(--btn); outline-offset: 2px; }
.controller-cmd-icon::before { font-size: 11px; }
.controller-cmd[data-action="start"] .controller-cmd-icon::before { content: "\25B6"; }
.controller-cmd[data-action="stop"] .controller-cmd-icon::before { content: "\25A0"; font-size: 13px; }
.controller-cmd[data-action="reset"] .controller-cmd-icon::before { content: "\21BB"; font-size: 15px; }
.controller-cmd.controller-cmd-primary { --btn: #dc2626; background: var(--btn); color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn) 22%, transparent); }
.controller-cmd.controller-cmd-primary:hover { --btn: #b91c1c; }
.controller-result { font-size: 13px; color: var(--muted); padding: 4px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; }

.controller-message { margin: 0; padding: 10px 16px; color: var(--err-fg); background: var(--err-bg); font-weight: 600; border-top: 1px solid #f5b5b1; }
.controller-message[hidden], .controller-picker[hidden] { display: none; }
@media (max-width: 640px) { .controller-broker { margin-left: 0; } }
@media (prefers-reduced-motion: reduce) { .controller-panel[data-tone="badge-ok"] .controller-light { animation: none; } }

/* Help on GUI pages (docs/reference/help.md): "Nápoveda" button, "?" bubbles, side panel. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.detail-images-head { margin: 0 0 4px; }
.help-open { display: inline-flex; gap: 8px; align-items: center; font: inherit; font-weight: 600; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--accent-dark); cursor: pointer; }
.help-open:hover { border-color: var(--accent); background: #f0fdfa; }
.help-open::before { content: "?"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; }
/* "main" outranks the generic button rules of the bars (.bulk-bar button, …). */
main button.help-btn { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; padding: 0; margin: 0; border: 1px solid #b9c0cc; border-radius: 50%; background: var(--surface); color: var(--muted); box-shadow: none; font: 700 11px/1 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; letter-spacing: 0; text-transform: none; cursor: pointer; vertical-align: 1px; }
main button.help-btn:hover, main button.help-btn[aria-expanded="true"] { border-color: var(--accent); background: var(--accent); color: #fff; filter: none; }
main button.help-btn:focus-visible, .help-open:focus-visible, .help-panel button:focus-visible, .help-panel a:focus-visible, .help-pop-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th button.help-btn { margin-left: 4px; }
.controller-card-label button.help-btn { margin-left: 4px; }

.issue-area { display: flex; gap: 8px; align-items: flex-start; }
.issue-area .issue-banners { flex: 1; min-width: 0; }
.issue-help { padding-top: 12px; }
.issue-help[hidden] { display: none; }
.release-bar { gap: 8px; align-items: center; }

.help-pop { position: absolute; z-index: 30; width: min(320px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(20, 24, 36, .18); padding: 12px 14px; font-size: 13px; line-height: 1.5; white-space: normal; text-align: left; font-weight: 400; }
.help-pop-title { font-weight: 700; margin: 0 0 4px; font-size: 14px; }
.help-pop p { margin: 0 0 8px; }
.help-pop-more { background: none; border: 0; padding: 0; color: var(--accent-dark); cursor: pointer; font: inherit; font-weight: 600; text-decoration: underline; }

.help-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(920px, 100vw); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(20, 24, 36, .16); transform: translateX(100%); visibility: hidden; transition: transform .2s ease-out, visibility 0s linear .2s; }
.help-panel.open { transform: none; visibility: visible; transition: transform .2s ease-out; }
.help-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, #ecfeff, var(--surface) 70%); }
.help-panel-head h2 { margin: 0; font-size: 17px; color: var(--accent-dark); }
.help-close { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
.help-toc a { font-size: 12px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); text-decoration: none; color: var(--ink); white-space: nowrap; }
.help-toc a:hover { border-color: var(--accent); color: var(--accent-dark); }
.help-body { flex: 1; overflow-y: auto; padding: 4px 24px 32px; overscroll-behavior: contain; }
.help-body section { padding: 14px 0 6px; border-bottom: 1px solid var(--border); scroll-margin-top: 8px; }
.help-body section section { border: 0; padding: 10px 0 0; }
.help-body h3 { font-size: 15px; margin: 0 0 6px; text-wrap: balance; }
.help-body h4 { font-size: 13px; margin: 0 0 4px; }
.help-body p, .help-body li { max-width: 90ch; }
.help-body p { margin: 0 0 8px; }
.help-body ul, .help-body ol { margin: 0 0 8px; padding-left: 20px; }
.help-body li { margin-bottom: 4px; }
.help-body table { border-collapse: collapse; font-size: 13px; margin: 4px 0 10px; width: 100%; }
.help-body th, .help-body td { text-align: left; vertical-align: top; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--border); }
.help-body th { color: var(--muted); font-weight: 600; }
.help-body details { margin: 4px 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.help-body details > summary { cursor: pointer; padding: 6px 10px; font-weight: 600; font-size: 13px; color: var(--muted); }
.help-body details > div { padding: 0 10px 8px; font-size: 13px; }
.help-body blockquote { margin: 4px 0 10px; background: #fef9c3; color: #713f12; border-radius: 6px; padding: 8px 10px; }
.help-body blockquote p { margin: 0; }
.help-body section.help-flash { animation: help-flash 1.6s ease-out; }
@keyframes help-flash { from { background: #ccfbf1; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .help-panel, .help-panel.open { transition: none; } .help-body section.help-flash { animation: none; } }

/* Expired-session overlay (app/static/session_guard.js) */
.session-expired::backdrop {
  background: rgba(20, 24, 36, 0.6);
  backdrop-filter: grayscale(1);
  -webkit-backdrop-filter: grayscale(1);
}
.session-expired .btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
}
.session-expired .btn:hover { background: var(--accent-dark); }

/* Export progress bar (app/static/export_progress.js, docs/reference/export-progress.md) */
.export-progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius); font-weight: 600; }
.export-progress[hidden] { display: none; }
.export-progress-running { background: var(--info-bg); color: var(--info-fg); border: 1px solid #a5e3ee; }
.export-progress-done { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid #a7dfc4; }
.export-progress progress { flex: 1 1 160px; min-width: 120px; height: 14px; }
.export-progress-outage { font-size: 0.85em; color: var(--err-fg); font-weight: 600; }
/* "Do not switch off" reminder while an export runs: a big red line of its own under the progress. */
.export-progress-reminder { flex: 1 0 100%; font-size: 1.7em; line-height: 1.2; font-weight: 800; color: var(--danger); }
.export-progress-done button { margin-left: auto; }
.modal-actions .modal-cancel[hidden] { display: none; }

/* Link to the barcode stats on the scans page: the shape of .help-open, indigo (docs/reference/barcode-stats.md) */
.page-head-links { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stats-open { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: #4338ca; text-decoration: none; }
.stats-open:hover { border-color: #4f46e5; background: #eef2ff; color: #4338ca; }
.stats-open::before { content: "%"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #4f46e5; color: #fff; font-size: 11px; font-weight: 800; }
.stats-open:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }

/* Barcode stats page (/scans/barcode-stats); the source colours are shared with barcode_stats.js */
.bs-pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.bs-back { font-weight: 600; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); text-decoration: none; }
.bs-back:hover { border-color: var(--accent); background: #f0fdfa; }
.bs-top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.bs-top h1 { margin: 0 0 4px; }
.bs-sub { color: var(--muted); font-size: 12.5px; margin: 0; }
.bs-filters { display: flex; flex-wrap: wrap; gap: 10px; }
.bs-lbl { display: block; margin-bottom: 3px; font: 500 10.5px ui-monospace, Consolas, monospace; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.bs-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.bs-seg a { padding: 6px 12px; font-size: 13px; color: var(--muted); text-decoration: none; border-right: 1px solid var(--border); }
.bs-seg a:last-child { border-right: 0; }
.bs-seg a:hover { background: var(--bg); }
.bs-seg a[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.bs-seg a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bs-card { min-width: 0; }
.bs-card h2 { margin: 0 0 2px; }
.bs-empty { text-align: center; padding: 32px 16px; }
.bs-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.bs-grid3 .bs-card { margin-bottom: 0; }
.bs-grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
@media (max-width: 860px) { .bs-grid3, .bs-grid2 { grid-template-columns: minmax(0, 1fr); } }
.bs-src-reader1, .bs-src-r1 { --bs-c: #0072b2; }
.bs-src-reader2, .bs-src-r2 { --bs-c: #d55e00; }
.bs-src-photo, .bs-src-ph { --bs-c: #0a8f6a; }
.bs-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.bs-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--bs-c); display: inline-block; }
.bs-big { margin-top: 6px; font-size: 38px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.bs-big small { font-size: 18px; color: var(--muted); font-weight: 400; }
.bs-delta { font: 500 12px ui-monospace, Consolas, monospace; margin-top: 2px; }
.bs-delta-up { color: #1a7f4b; }
.bs-delta-down { color: var(--danger); }
.bs-delta-none { color: var(--muted); }
.bs-split { display: flex; gap: 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.bs-split b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 500; }
.bs-trsum { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.bs-trsum b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.bs-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; margin: 8px 0; }
.bs-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bs-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; background: var(--bs-c); }
.bs-legend i.bs-legend-box { height: 10px; width: 12px; background: var(--muted); opacity: .3; }
.bs-legend i.bs-legend-square { height: 10px; width: 10px; }
.bs-rel { position: relative; }
.bs-rel svg { display: block; width: 100%; height: auto; overflow: visible; }
.bs-rel svg text { fill: var(--muted); font: 11px ui-monospace, Consolas, monospace; }
.bs-rel svg text.bs-strong { fill: var(--ink); }
.bs-rel svg text.bs-label { fill: var(--ink); font: 12px -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; }
.bs-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid #cfd6de; border-radius: 6px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); display: none; z-index: 5; min-width: 150px; }
.bs-tip b { display: block; margin-bottom: 4px; font-weight: 600; }
.bs-tip-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.bs-tip-row.bs-tip-first { padding-bottom: 5px; margin-bottom: 5px; border-bottom: 1px solid var(--border); }
.bs-tip-row b { display: inline; margin: 0; }
.bs-tip table { border-collapse: collapse; width: 100%; }
.bs-tip th { text-align: right; font: 500 10px ui-monospace, Consolas, monospace; color: var(--muted); padding: 0 0 4px 12px; white-space: nowrap; }
.bs-tip td { text-align: right; padding: 2px 0 2px 12px; font-variant-numeric: tabular-nums; }
.bs-tip th:first-child, .bs-tip td:first-child { text-align: left; padding-left: 0; white-space: nowrap; }
.bs-tip tr.bs-hot { font-weight: 600; }
.bs-tip-total { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 14px; }
.bs-tip-note { margin-top: 4px; color: var(--muted); font-size: 11px; }
.bs-mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.bs-ok, .bs-no, .bs-na { font: 500 12px ui-monospace, Consolas, monospace; display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 3px; }
.bs-ok { color: #1a7f4b; background: #e3f3ea; }
.bs-no { color: var(--danger); background: #f7e4e2; }
.bs-na { color: var(--muted); }
.bs-bar { display: inline-block; height: 8px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.bs-overlap { width: 100%; border-collapse: collapse; font-size: 13px; }
.bs-overlap td { padding: 7px 8px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bs-overlap td.bs-r { text-align: right; }
.bs-scroll { overflow-x: auto; }
