/*
 * erp-core design system: hand-written CSS on custom properties, light and dark by prefers-color-scheme.
 * Served as /_content/ErpCore.Cloud/css/erp-core.css. A connector overrides only the accent through /_ui/theme.css.
 * Vendored scripts: js/htmx.min.js is htmx 2.0.4 (https://unpkg.com/htmx.org@2.0.4/dist/htmx.min.js). Bump it deliberately.
 * Design 2026-11 (docs/design/navrh-2026-11.md, variant A): brand of base-erp.eu, headings Be Vietnam Pro, text Mulish (fonts/, SIL OFL 1.1),
 * bottom tab bar on phones, icon sidebar on desktop, 44 px touch targets.
 * Contrast: text colors are chosen for WCAG AA (4.5:1) on --bg and --surface in both modes. Skywave (--brand) is too light for white text, so buttons
 * and links use --accent (#1F5FD6); --brand is only for surfaces (progress bars, the logo dot).
 */

/* ---------- Fonts (self-hosted: CSP font-src 'self') ---------- */
@font-face { font-family: "Mulish"; font-style: normal; font-weight: 200 1000; font-display: swap; src: url("../fonts/mulish-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Mulish"; font-style: normal; font-weight: 200 1000; font-display: swap; src: url("../fonts/mulish-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/be-vietnam-pro-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/be-vietnam-pro-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/be-vietnam-pro-800-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/be-vietnam-pro-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light dark;

  /* Palette (light): docs/design/finalni-design.md, brand colours 1:1 from base-erp.eu */
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #eeeef2;
  --fg: #0c0212;
  --muted: #5a5462;
  --line: #e2e1e6;
  --line-strong: #8a8494;
  --brand: #2f7dff;
  --accent: #1f5fd6;
  --accent-soft: #e8f0ff;
  --on-accent: #ffffff;
  --accent-text: var(--accent);
  --ok: #1e9e62;
  --ok-text: #157347;
  --ok-soft: #e2f4e9;
  --warn: #9a4a00;
  --warn-soft: #fff0dc;
  --bad: #c0262d;
  --bad-soft: #fde7e7;
  --on-bad: #ffffff;
  --operator: #5b3df5;
  --operator-soft: #eeeaff;
  --on-operator: #ffffff;
  --shadow-color: 12 2 18;

  /* Type scale */
  --font: "Mulish", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-heading: "Be Vietnam Pro", var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.625rem;

  /* Spacing, radius, elevation, sizes */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(var(--shadow-color) / 0.05);
  --shadow: 0 1px 3px rgb(var(--shadow-color) / 0.08), 0 4px 12px rgb(var(--shadow-color) / 0.06);
  --shadow-lg: 0 12px 40px rgb(var(--shadow-color) / 0.22);
  --sidebar-width: 256px;
  --tap: 44px;
  --control: 40px;
  --field: 48px;
  --tabbar-height: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0212;
    --surface: #1b1322;
    --surface-2: #251c2d;
    --fg: #f4f4f6;
    --muted: #b9b4c0;
    --line: #2c2433;
    --line-strong: #746b80;
    --brand: #2f7dff;
    /* A connector override (/_ui/theme.css) of --accent still wins. */
    --accent: #8db6ff;
    --accent-soft: #1a2440;
    --on-accent: #0c0212;
    --ok: #4cc98a;
    --ok-text: #5bd68e;
    --ok-soft: #13301f;
    --warn: #f5b544;
    --warn-soft: #36270f;
    --bad: #ff8a8a;
    --bad-soft: #3a1519;
    --on-bad: #0c0212;
    --operator: #a99bff;
    --operator-soft: #251e47;
    --on-operator: #0c0212;
    --shadow-color: 0 0 0;
  }
}

/* Derived from --accent, so an override only needs to set --accent (and --on-accent). */
:root { --accent-hover: color-mix(in srgb, var(--accent) 86%, black); }
@media (prefers-color-scheme: dark) {
  :root { --accent-hover: color-mix(in srgb, var(--accent) 86%, white); }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 0.9375rem / 1.45 var(--font);
  color: var(--fg);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-family: var(--font-heading); }
h1 { font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); font-weight: 700; }
h3 { font-size: var(--text-md); font-weight: 700; }
p { margin: 0 0 var(--space-3); }
strong, b { font-weight: 700; }

a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code, pre { font-family: var(--mono); }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Icons (sprite wwwroot/icons/sprite.svg, Ui/Icons.cs) ---------- */
.icon {
  flex: none; width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Text utilities (state colors) ---------- */
.ok { color: var(--ok-text); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- App shell ---------- */
.skip-link {
  position: absolute; left: var(--space-3); top: -100px; z-index: 100;
  background: var(--surface); color: var(--fg); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.skip-link:focus { top: var(--space-3); }

.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5) var(--space-3) var(--space-4);
  background: var(--surface); border-right: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  color: var(--fg); font: 800 var(--text-xl) / 1.2 var(--font-heading); letter-spacing: -0.02em; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 28px; width: auto; max-width: 160px; object-fit: contain; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); color: var(--fg); text-decoration: none; font-weight: 600;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--fg); }
.nav a[aria-current="page"], .nav a.is-active { background: var(--accent-soft); color: var(--accent-text); }
.nav a[aria-current="page"] .icon, .nav a.is-active .icon { color: currentColor; }

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 56px; padding: var(--space-2) var(--space-5);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin-right: auto; overflow-wrap: anywhere; }
.topbar form { margin: 0; }

.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }

.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.page-actions form { margin: 0; }

/* ---------- Authentication layout ---------- */
/* The sign-in layout (.split) is at the end of the file: "Sign-in and public pages (stage 2)". */

/* ---------- Cards (design: komponenty "Karta") ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: var(--space-4) 20px;
}
.card > :last-child { margin-bottom: 0; }
.card h2 { font-size: 1.125rem; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-header h2, .card-header h3 { margin-right: auto; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-header { min-height: 56px; margin: 0; padding: var(--space-3) var(--space-4); }
.card-flush > p { padding: 0 var(--space-4); }
.card-flush > .table-wrap:last-child table tr:last-child td { border-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ---------- Empty state: a circle with an icon, a title, a hint, an optional button ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-6) var(--space-4); text-align: center;
}
.empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); color: var(--muted); margin-bottom: var(--space-1); }
.empty-icon .icon { width: 24px; height: 24px; }
.empty-title { font: 800 var(--text-lg) / 1.35 var(--font); }
.empty-hint { color: var(--muted); font-size: var(--text-md); max-width: 46ch; margin: 0; }
.empty .btn { margin-top: var(--space-2); }

/* ---------- Tables: header 40 px on --surface-2 (12/800 muted), rows 52 px ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px var(--space-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
th { height: 40px; padding-top: 10px; padding-bottom: 10px; color: var(--muted); font-size: var(--text-xs); font-weight: 800; white-space: nowrap; background: var(--surface-2); }
tbody tr:hover td { background: color-mix(in srgb, var(--fg) 3%, transparent); }
table.kv th { width: 1%; background: transparent; }
.table-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.table-filter form { display: contents; }
.sub { display: block; color: var(--muted); font-size: var(--text-sm); }

pre {
  margin: 0; padding: var(--space-3) var(--space-4); overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: var(--text-xs); line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
pre.bad { color: var(--bad); }

/* ---------- Status badges: dot 7 px + text 13/700 on the soft tone ---------- */
.badge {
  --tone: var(--muted); --tone-soft: var(--surface-2);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--text-sm); font-weight: 700; line-height: 1.45; white-space: nowrap;
  color: var(--tone); background: var(--tone-soft);
}
.badge::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, currentColor); }
.badge-ok { --tone: var(--ok-text); --tone-soft: var(--ok-soft); --dot: var(--ok); }
.badge-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.badge-bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.badge-muted { --tone: var(--muted); --tone-soft: var(--surface-2); }
.badge-info { --tone: var(--accent-text); --tone-soft: var(--accent-soft); }
.badge-op { --tone: var(--operator); --tone-soft: var(--operator-soft); }

/* ---------- Forms: label 14/700, field 48 px, radius 10, border --line-strong ---------- */
label { display: block; margin: 0 0 6px; color: var(--fg); font-weight: 700; font-size: var(--text-md); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field label { margin: 0; }
.field-hint { color: var(--muted); font-size: var(--text-sm); margin: 0; }
/* A form row: label and hint on the left, the control on the right; stacked on a phone. */
.form-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-2) var(--space-5); align-items: start; padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.form-row:first-child { border-top: 0; }
.form-row > .form-row-label { display: flex; flex-direction: column; gap: 2px; }
.form-row > .form-row-label label { margin: 0; }

input, select, textarea, button { font: inherit; }
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: var(--field); padding: 10px 14px; color: var(--fg); font-size: 0.9375rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 96px; }
select { width: auto; max-width: 100%; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 0; border-color: var(--accent-text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.input-wide { max-width: 520px; }
textarea.code { font: var(--text-xs) / 1.6 var(--mono); }
/* Check boxes and radios: 22 px; a .switch check box is the 48 x 28 toggle. */
input[type="checkbox"], input[type="radio"] { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
input[type="checkbox"].switch {
  appearance: none; -webkit-appearance: none; position: relative; width: 48px; height: 28px; border-radius: var(--radius-pill);
  background: var(--line-strong); cursor: pointer; transition: background-color 0.15s;
}
input[type="checkbox"].switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); transition: transform 0.15s;
}
input[type="checkbox"].switch:checked { background: var(--accent); }
input[type="checkbox"].switch:checked::after { transform: translateX(20px); }

.field-validation-error, .validation-summary-errors, .form-error { color: var(--bad); font-size: var(--text-sm); }
.validation-summary-errors ul { margin: 0; padding-left: 1.2em; }
.input-validation-error { border: 2px solid var(--bad) !important; }
.form-error ul { margin: 0; padding-left: 1.2em; }

/* ---------- Buttons: 44 px (36 px small on a desktop), radius 10, 15/700 ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 8px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent);
  font-size: 0.9375rem; font-weight: 700; line-height: 1.25; cursor: pointer; text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover, button:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn-secondary, button.secondary, .btn.secondary { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.btn-secondary:hover, button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-danger, button.danger, .btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn-danger:hover, button.danger:hover, .btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.danger-solid, .btn.danger-solid { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
button.text, .btn.text { background: transparent; border-color: transparent; color: var(--accent-text); padding-inline: var(--space-2); }
button.text:hover, .btn.text:hover { background: var(--accent-soft); border-color: transparent; }
.btn-sm, button.small, .btn.small { min-height: 36px; padding: 6px 14px; font-size: var(--text-md); }
.icon-button { width: var(--tap); padding: 0; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

/* ---------- Notices: icon 20 + title 800 in the tone + text 14 on the soft tone, radius 14 ---------- */
.notice {
  --tone: var(--accent-text); --tone-soft: var(--accent-soft);
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: 14px var(--space-4); border-radius: var(--radius);
  background: var(--tone-soft); color: var(--fg); font-size: var(--text-md);
}
.notice > .icon { color: var(--tone); margin-top: 1px; }
.notice-ok { --tone: var(--ok-text); --tone-soft: var(--ok-soft); }
.notice-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.notice-bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.notice-muted { --tone: var(--muted); --tone-soft: var(--surface-2); }
.notice-op { --tone: var(--operator); --tone-soft: var(--operator-soft); }
.notice-info { --tone: var(--accent-text); --tone-soft: var(--accent-soft); }
.notice-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notice-title { display: block; margin: 0 0 2px; color: var(--tone); font-weight: 800; font-size: 0.9375rem; }
.notice-text > p { margin: 0 0 var(--space-1); }
.notice-text > p:last-child { margin-bottom: 0; }
.notice-close { min-height: 32px; width: 32px; padding: 0; background: transparent; color: inherit; border-color: transparent; font-size: var(--text-lg); line-height: 1; }
.notice-close:hover { background: color-mix(in srgb, currentColor 12%, transparent); color: inherit; border-color: transparent; }
.notice-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

/* ---------- Toasts: --fg background, --bg text ---------- */
.toasts {
  position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 60;
  display: flex; flex-direction: column; gap: var(--space-2);
  width: min(440px, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}
.toasts > * { pointer-events: auto; box-shadow: var(--shadow-lg); animation: toast-in 0.18s ease-out; }
.toasts > .notice { --tone: var(--bg); background: var(--fg); color: var(--bg); align-items: center; }
.toasts > .notice .notice-title { color: var(--bg); }
.toasts > .is-leaving { opacity: 0; transition: opacity 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Confirm dialog ---------- */
dialog.confirm {
  width: min(92vw, 420px); padding: var(--space-5);
  color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
dialog.confirm::backdrop { background: rgb(0 0 0 / 0.45); }
dialog.confirm p { font-size: var(--text-lg); margin-bottom: var(--space-4); }
dialog.confirm .dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* ---------- Charts (inline SVG) ---------- */
.chart { display: block; overflow: visible; max-width: 100%; height: auto; }
.chart-line { fill: none; stroke: var(--accent-text); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--accent-text); }
.chart-bar { fill: var(--accent-text); opacity: 0.85; }

/* ---------- htmx ---------- */
.htmx-request { opacity: 0.6; transition: opacity 0.15s; }
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Tablet and narrow screens: sidebar becomes a top bar ---------- */
@media (max-width: 900px) {
  .app { display: block; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-4);
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .topbar { position: static; padding: var(--space-2) var(--space-4); backdrop-filter: none; }
  .page { padding: var(--space-4); gap: var(--space-4); }
  .card { padding: var(--space-4); }
  .card-flush { padding: 0; }
  .card-flush > .card-header { padding: var(--space-4) var(--space-4) 0; }
  .card-flush > p { padding: 0 var(--space-4); }
  th, td { padding: var(--space-2) var(--space-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Usage metering (tenant detail card, /admin/usage) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.stat { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); background: var(--surface-2); }
.stat-value { font-size: var(--text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: var(--text-sm); }
.usage-trend, .usage-limit { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.usage-progress { width: 100%; max-width: 320px; height: 8px; accent-color: var(--accent, currentColor); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Step indicator ---------- */
.steps { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-4); padding: 0; list-style: none; counter-reset: none; }
.step { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--muted); font-size: var(--text-sm); }
.step-number {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-variant-numeric: tabular-nums;
}
.step.is-done { color: var(--fg); }
.step.is-done .step-number { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }
.step.is-current { color: var(--fg); font-weight: 600; }
.step.is-current .step-number { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Public registration (two columns: claim on the accent, form on the page) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.chips li { background: var(--surface); color: var(--fg); border-radius: 999px; padding: 4px 12px; font-size: var(--text-sm); font-weight: 600; }
.company-id, .company-city { flex-wrap: nowrap; align-items: flex-start; }
.company-id > .field:first-child, .company-city > .field:last-child { flex: 1; }
.company-fields { gap: 0; }
.choice { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--fg); font-weight: 400; font-size: var(--text-md); }
.choice input { width: auto; margin-top: 3px; }
.field select.input-wide { width: 100%; }
.page-footer { margin-top: var(--space-5); padding-top: var(--space-3); border-top: 1px solid var(--line); font-size: var(--text-sm); }
/* A form with a provider radio (billing settings) shows the section of the chosen provider only; without :has support both stay visible. */
.provider-form:has(input[name="provider"][value="fakturoid"]:checked) [data-provider]:not([data-provider="fakturoid"]),
.provider-form:has(input[name="provider"][value="myucto"]:checked) [data-provider]:not([data-provider="myucto"]) { display: none; }
.provider-form fieldset:not(.field) { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.provider-form fieldset:not(.field) > legend { font-weight: 600; margin-bottom: var(--space-2); padding: 0; }
fieldset.field { border: 0; padding: 0; margin: 0 0 var(--space-3); }
fieldset.field legend { color: var(--muted); font-weight: 500; font-size: var(--text-sm); margin-bottom: var(--space-1); }

/* ---------- Two-factor sign-in ---------- */
.two-factor-steps { margin: 0; padding-left: 1.2em; }
.qr-wrap { margin: var(--space-3) 0; }
.qr { display: block; width: 200px; height: 200px; border-radius: var(--radius-sm); }
.secret { overflow-wrap: anywhere; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, max-content); gap: var(--space-2) var(--space-5); margin: 0; padding: 0; list-style: none; font-size: var(--text-lg); }

/* ---------- Approval queue and facts ---------- */
.nav-count { margin-left: var(--space-2); background: var(--accent-soft); color: var(--accent-text); border-radius: 999px; padding: 0 8px; font-size: var(--text-xs); font-weight: 600; }
.approvals { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 3fr); gap: var(--space-4); align-items: start; }
.approval-queue { display: flex; flex-direction: column; gap: var(--space-2); }
.approval-item { display: flex; flex-direction: column; gap: 2px; color: var(--fg); }
.approval-item:hover { text-decoration: none; border-color: var(--line-strong); }
.approval-item[aria-current="true"] { border-color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent-text); }
.approval-actions { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-sm); background: var(--accent-soft); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: 0; }
.facts dt { color: var(--muted); font-size: var(--text-sm); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 860px) {
  .approvals { grid-template-columns: 1fr; }
}

/* ---------- Operator console (docs/design: $operator, screens 08-13) ---------- */
/* The console has its own accent so it can never be mistaken for the portal; the derived colors are redeclared because they resolve where defined. */
/* The console uses the operator colour where the portal uses the accent, so it can never be mistaken for the portal. */
.area-operator {
  --accent: var(--operator);
  --on-accent: var(--on-operator);
  --accent-text: var(--operator);
  --accent-soft: var(--operator-soft);
  --accent-hover: color-mix(in srgb, var(--operator) 86%, black);
}
@media (prefers-color-scheme: dark) {
  .area-operator { --accent-hover: color-mix(in srgb, var(--operator) 86%, white); }
}
.icon { flex: none; }
.brand { flex-wrap: wrap; row-gap: 0; }
.nav a { display: flex; align-items: center; gap: 10px; }
.nav .nav-count { margin-left: auto; }
.nav-bottom { margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--line); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text); font-size: var(--text-xs); font-weight: 650;
}
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3) var(--space-5); }
.page-title { min-width: 0; }
.page-subtitle { color: var(--muted); margin: var(--space-1) 0 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); }
.tile { display: flex; flex-direction: column; gap: var(--space-1); }
.tile-label { color: var(--muted); font-size: var(--text-sm); }
.tile-value { font-size: 1.75rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-note { font-size: var(--text-sm); color: var(--muted); }
.dash { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-4); align-items: start; }
.dash > .stack { gap: var(--space-4); }

.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.attention-text { flex: 1; min-width: 0; }
.attention-title { font-weight: 600; }
.attention-icon { --tone: var(--muted); color: var(--tone); }
.attention-icon.ok { --tone: var(--ok); }
.attention-icon.warn { --tone: var(--warn); }
.attention-icon.bad { --tone: var(--bad); }
.attention-icon.approval { color: var(--accent-text); }
.attention a.go { white-space: nowrap; font-weight: 600; text-decoration: none; }

.chart-months { width: 100%; height: auto; }
.chart-months .chart-bar { fill: var(--accent-soft); opacity: 1; }
.chart-months .chart-bar.is-current { fill: var(--accent); }
.chart-months .chart-label { fill: var(--muted); font-size: 10px; font-family: var(--mono); text-anchor: middle; }
.chart-load { width: 100%; height: auto; }
.load { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: var(--space-2) var(--space-3); align-items: center; }
.meters { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: var(--space-2) var(--space-4); align-items: center; }
.meters progress, .meter { width: 100%; height: 8px; accent-color: var(--accent); }

.tabs { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); border-bottom: 1px solid var(--line); }
.tabs a { padding: var(--space-2) 0; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--accent-text); border-bottom-color: var(--accent-text); font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.timeline li { position: relative; padding-left: var(--space-4); }
.timeline li::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.muted { background: var(--line-strong); }
.count-badge { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; text-align: center; font-size: var(--text-xs); font-weight: 600; color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.legend { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.placeholder { color: var(--muted); }
@media (max-width: 1100px) {
  .dash, .split { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .nav-bottom { margin-top: 0; padding-top: 0; border-top: 0; }
  .topbar { flex-wrap: wrap; }
}

/* ---------- Setup wizard (portal /portal/setup/{step}) ---------- */
.setup-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(240px, 2fr); gap: var(--space-4); align-items: start; }
.stack-tight { display: flex; flex-direction: column; gap: 2px; }
.setup-prepare { display: flex; gap: var(--space-4); justify-content: space-between; align-items: flex-start; }
.setup-image { max-width: 280px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.setup-agent { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); }
.setup-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.setup-checks li { display: flex; flex-direction: column; gap: 2px; padding-left: var(--space-3); border-left: 3px solid var(--line); }
.setup-checks li.ok { border-left-color: var(--ok); }
.setup-checks li.bad { border-left-color: var(--bad); }
.setup-checks li.warn { border-left-color: var(--warn); }
.check-stale { opacity: 0.6; }
.setup-links { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: var(--space-2); }
@media (max-width: 860px) {
  .setup-columns { grid-template-columns: 1fr; }
  .setup-prepare { flex-direction: column; }
}

/* ---------- Module settings in sections (wizard step 8 and /portal/settings; docs/ai-nastaveni.md) ---------- */
.proposal-banner { display: flex; gap: var(--space-4); align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); background: var(--accent-soft); margin-bottom: var(--space-3); }
.proposal-banner .stack-tight { display: flex; flex-direction: column; gap: 2px; }
.settings-propose { margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.section-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.section-nav a { display: flex; align-items: center; gap: var(--space-2); padding: 4px var(--space-3); border-radius: var(--radius-sm); color: var(--muted); font-size: var(--text-sm); }
.section-nav a:hover { text-decoration: none; background: var(--surface-2); }
.section-nav li.is-current a { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.section-nav li.is-done .section-mark { color: var(--ok); }
.section-nav li.is-error a { color: var(--bad); }
.section-nav li.is-error.is-current a { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.section-nav li.is-check .section-mark, .section-nav li.is-suggested .section-mark { color: var(--accent-text); }
.section-count { margin-left: auto; min-width: 1.5em; text-align: center; font-size: var(--text-xs); font-weight: 600; border-radius: 999px; padding: 0 6px; background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--warn); }
.section-nav li.is-error .section-count { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); color: var(--bad); }
.settings-section { gap: var(--space-3); }
.section-head h3 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xl); }
.section-actions { align-items: center; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
details.advanced { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); background: var(--surface); }
details.advanced > summary { cursor: pointer; }
details.advanced[open] > summary { margin-bottom: var(--space-3); }
button.link { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Origin of a value: where the suggestion came from */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.origin-ok { color: var(--muted); }
.chip.origin-check { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.chip.origin-user { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.chip.origin-error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.origin-reason { color: var(--warn); }
.mapping tr:has(.origin-check) select, .mapping tr:has(.origin-check) input[type="text"] { border-color: var(--warn); }

/* Errors bound to a field */
.field-error { margin: var(--space-1) 0 0; color: var(--bad); font-size: var(--text-sm); }
.field-error::before { content: "⚠ "; }
[aria-invalid="true"] { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.row-invalid > td { background: color-mix(in srgb, var(--bad) 4%, transparent); }

/* Countries and currencies as chips with a search field */
.chips { display: flex; flex-direction: column; gap: var(--space-2); }
.chip-list { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip-list .chip { color: var(--fg); background: var(--surface); }
.chip-remove { background: none; border: 0; padding: 0 2px; line-height: 1; color: var(--muted); cursor: pointer; font-size: var(--text-md); }
.chip-remove:hover { color: var(--bad); }
.chip-input { max-width: 22rem; }
.chip-presets { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0; color: var(--muted); font-size: var(--text-sm); }

/* Actions of a form on one row; a destructive one sits on the right. */
.form-actions { margin-top: var(--space-2); }
.form-actions > .danger { margin-left: auto; }

/* ---------- Narrow screens (portal on a phone, issue: mobile layout) ---------- */
/* A fieldset defaults to min-inline-size: min-content, so the fieldset around the settings form grew to its widest table and pushed the whole page sideways. */
fieldset { min-width: 0; max-width: 100%; }
h1, h2, h3 { overflow-wrap: anywhere; }
.content, .page, .card, .stack, .field { min-width: 0; }
.field > input:not([type="checkbox"]):not([type="radio"]), .field > select, .field > textarea { max-width: 100%; }

/* A table that scrolls sideways shows it: a shadow on the edge that still has content behind it (the scrollbar itself is hidden on phones). */
.table-wrap {
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 24px 100% no-repeat local,
    linear-gradient(to right, rgb(var(--shadow-color) / 0.18), transparent) left center / 10px 100% no-repeat scroll,
    linear-gradient(to left, rgb(var(--shadow-color) / 0.18), transparent) right center / 10px 100% no-repeat scroll;
}
.table-wrap td > input:not([type="checkbox"]):not([type="radio"]), .table-wrap td > select { min-width: 8rem; }

@media (max-width: 600px) {
  .page { padding: var(--space-3); gap: var(--space-3); }
  .topbar { padding: var(--space-2) var(--space-3); }
  .user-menu-list { max-width: calc(100vw - 2 * var(--space-3)); }
  .toasts { right: var(--space-3); left: var(--space-3); bottom: var(--space-3); width: auto; }

  /* Long values (URLs, GUIDs, tokens, ERP codes) wrap instead of widening the page. */
  /* Tables that scroll keep their columns (a word is never broken there); only stacked tables and prose wrap anywhere. */
  .page dd, .page li, .page p, .page .sub, .page .field-hint, .page summary, .page label, .table-stack td, .table-stack th { overflow-wrap: anywhere; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .facts dd { margin-bottom: var(--space-2); }
  .input-wide, .chip-input, .setup-image { max-width: 100%; }
  .company-id, .company-city { flex-wrap: wrap; }
  .company-id > .field, .company-city > .field { flex: 1 1 100%; }
  .recovery-codes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proposal-banner, .setup-prepare { flex-direction: column; align-items: stretch; }
  .form-actions > .danger { margin-left: 0; }
  details.advanced { padding: var(--space-3); }

  /* Small read-only tables become blocks: each row is a card, the flows table gets its column names above the values. */
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack th, .table-stack td { display: block; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack tr { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); }
  .table-stack th, .table-stack td { padding: 2px 0; border: 0; background: transparent; }
  .table-stack tbody tr:hover td { background: transparent; }
  .table-stack tr > :first-child { color: var(--fg); font-weight: 600; font-size: var(--text-md); }
  .table-stack-flows td::before { display: block; color: var(--muted); font-size: var(--text-xs); }
  .table-stack-flows td:nth-child(2)::before { content: "Výsledek"; }
  .table-stack-flows td:nth-child(3)::before { content: "Kdy"; }
  .table-stack td:empty { display: none; }
}

/* ==========================================================================================================================
   Portal, final design (docs/design/finalni-design.md): phone < 768 px, tablet 768-1023 px (phone navigation), desktop >= 1024 px.
   ========================================================================================================================== */

/* ---------- Shell: sidebar (desktop) ---------- */
:is(.area-portal, .area-operator) .sidebar { padding: 20px 14px var(--space-4); gap: var(--space-4); }
:is(.area-portal, .area-operator) .brand { padding: 2px 10px; }
.brand-picture { display: contents; }
/* The SVG has room around the mark: 31 px high makes "base." 22 px as drawn (27 px / 20 px on a phone). */
.brand-logo { display: block; height: 31px; width: auto; max-width: 200px; object-fit: contain; }
.sidebar-tenant { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.sidebar-tenant-name { font-weight: 800; font-size: var(--text-md); overflow-wrap: anywhere; }
.sidebar-tenant .sub { font-size: var(--text-xs); }
:is(.area-portal, .area-operator) .nav a, .nav-group > summary {
  display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm); color: var(--fg); font-size: 0.9375rem; font-weight: 600; text-decoration: none;
}
:is(.area-portal, .area-operator) .nav a .icon, .nav-group > summary .icon { color: var(--muted); }
:is(.area-portal, .area-operator) .nav a:hover, .nav-group > summary:hover { background: var(--surface-2); }
:is(.area-portal, .area-operator) .nav a[aria-current="page"], :is(.area-portal, .area-operator) .nav a.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
:is(.area-portal, .area-operator) .nav a[aria-current="page"] .icon, :is(.area-portal, .area-operator) .nav a.is-active .icon { color: currentColor; }
.nav-group > summary { cursor: pointer; list-style: none; }
.nav-group > summary > span { flex: 1; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after {
  content: ""; flex: none; width: 7px; height: 7px; margin-right: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.nav-group[open] > summary::after { transform: rotate(45deg); }
.nav-group > summary.is-active, .nav-group > summary.is-active .icon { color: var(--accent-text); font-weight: 800; }
.nav-group > summary:focus-visible, .user-menu > summary:focus-visible, .tab-more > summary:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 var(--space-1) 44px; }
:is(.area-portal, .area-operator) .nav .nav-sub a { min-height: 38px; padding: 0 10px; font-size: var(--text-md); font-weight: 500; color: var(--muted); }
:is(.area-portal, .area-operator) .nav .nav-sub a[aria-current="page"], :is(.area-portal, .area-operator) .nav .nav-sub a.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
:is(.area-portal, .area-operator) .nav .count-badge { margin-left: auto; }
.nav-dot { flex: none; width: 8px; height: 8px; margin-left: auto; margin-right: 6px; border-radius: 50%; background: var(--bad); }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 800; line-height: 1; color: var(--on-bad); background: var(--bad);
}
.sidebar-help { margin: auto 0 0; padding: var(--space-4) 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm); display: flex; flex-direction: column; gap: 2px; }
.sidebar-help a { font-weight: 800; text-decoration: none; overflow-wrap: anywhere; }

/* ---------- Shell: top bar (breadcrumb on a desktop; logo or back link on a phone) ---------- */
:is(.area-portal, .area-operator) .topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--space-4);
  min-height: 60px; padding: 0 40px; background: var(--surface); border-bottom: 1px solid var(--line); backdrop-filter: none;
}
.topbar-brand, .topbar-back { display: none; }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); color: var(--accent-text); font-weight: 700; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.back-link .icon { width: 22px; height: 22px; }
/* The back link of the top bar is for phones; a desktop has the breadcrumb (the phone rule in the < 1024 px block shows it). */
.topbar > .topbar-back { display: none; }
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); min-width: 0; margin-right: auto; font-size: var(--text-md); color: var(--muted); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--fg); text-decoration: underline; }
.breadcrumb [aria-current="page"], .breadcrumb > span:last-child { color: var(--fg); font-weight: 700; }
.breadcrumb .icon { width: 16px; height: 16px; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.bell {
  position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font-weight: 700; text-decoration: none;
}
.bell:hover { background: var(--surface-2); text-decoration: none; }
.bell[aria-current="page"] { color: var(--accent-text); border-color: var(--accent-text); }
.bell-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 800; color: var(--on-bad); background: var(--bad);
}
.user-menu { position: relative; }
.user-menu > summary {
  display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); cursor: pointer; list-style: none;
  padding: 0 var(--space-1); border-radius: var(--radius-pill); color: var(--fg); font-weight: 700;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary::after {
  content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 6px 3px 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
}
.user-menu-name { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px;
  display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.user-menu-who { display: flex; flex-direction: column; padding: var(--space-2) var(--space-3) var(--space-3); border-bottom: 1px solid var(--line); margin-bottom: var(--space-1); }
.user-menu-who-name { font-weight: 800; overflow-wrap: anywhere; }
.user-menu-list a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--radius-sm); color: var(--fg); font-weight: 600; text-decoration: none; }
.user-menu-list a .icon { color: var(--muted); }
.user-menu-list a:hover { background: var(--surface-2); }
.user-menu-list form { padding: var(--space-1) var(--space-3) var(--space-2); }
.user-menu-list form button { width: 100%; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text); font: 800 var(--text-sm) / 1 var(--font-heading);
}
.avatar-lg { width: 48px; height: 48px; border-radius: var(--radius-sm); font-size: var(--text-lg); }
.avatar-solid { background: var(--accent); color: var(--on-accent); }
.user-menu-list form:has(.menu-row) { padding: 0; }
button.menu-row { justify-content: flex-start; gap: var(--space-3); width: 100%; min-height: var(--tap); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg); font-weight: 600; }
button.menu-row:hover { background: var(--surface-2); border: 0; }
button.menu-row.menu-row-danger, button.menu-row.menu-row-danger .icon { color: var(--bad); }
button.list-row { color: var(--fg); }

/* ---------- Shell: strips above the content (operator view, wizard) ---------- */
.strip { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); padding: 10px 40px; font-weight: 700; font-size: var(--text-md); }
.strip > .icon { flex: none; }
.strip-text { flex: 1; min-width: 12rem; }
.strip form { margin: 0; }
.strip-op { background: var(--operator-soft); color: var(--operator); }
.strip-op .strip-button { background: var(--operator); border-color: var(--operator); color: var(--on-operator); }
.strip-wizard { background: var(--accent-soft); color: var(--accent-text); }
.setup-strip .nav-count { font-weight: 800; }

/* ---------- Page head: title in the content, actions on the right ---------- */
:is(.area-portal, .area-operator) .page { max-width: none; padding: 28px 40px 40px; gap: var(--space-4); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3) var(--space-5); }
.page-title { min-width: 0; }
.page-title h1 { font-size: 1.875rem; font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.page-subtitle { color: var(--muted); font-size: var(--text-md); margin: var(--space-1) 0 0; overflow-wrap: anywhere; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.page-actions form { margin: 0; }
.page-footer { margin-top: var(--space-2); padding-top: 0; border-top: 0; font-size: var(--text-md); }
.page-footer a { font-weight: 800; text-decoration: none; }
.section-heading, .card h2.section-heading, .card h3.section-heading { margin: 0 0 var(--space-3); color: var(--muted); font: 800 var(--text-xs) / 1.4 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }
/* Shown only on a phone / only on a wider screen; !important so a component's own display (e.g. .action-bar) never wins. */
@media (min-width: 768px) { .mobile-only { display: none !important; } }

/* ---------- Tab bar and the "Více" sheet (< 1024 px) ---------- */
.tabbar { display: none; }
.list-card { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-card > li + li { border-top: 1px solid var(--line); }
.list-card form { margin: 0; }
.list-row {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 52px; padding: var(--space-2) var(--space-4);
  color: var(--fg); background: transparent; border: 0; border-radius: 0; font-size: 0.9375rem; font-weight: 700; text-align: left; text-decoration: none;
}
.list-row:hover { background: var(--surface-2); text-decoration: none; }
button.list-row { justify-content: flex-start; }
button.list-row:hover { background: var(--surface-2); border-color: transparent; }
.list-row > .icon { color: var(--muted); }
.list-row > .icon:last-child { width: 18px; height: 18px; }
.list-row-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list-row-value { color: var(--muted); font-weight: 500; }
.list-row[aria-current="page"] { color: var(--accent-text); }
.list-row[aria-current="page"] > .icon:first-child { color: currentColor; }

/* ---------- Overview: what needs attention, connection tiles, numbers, runs, actions ---------- */
.attention-card { border-left: 4px solid var(--bad); }
.attention-card.is-warn { border-left-color: var(--warn); }
.attention-card.is-ok { border-left-color: var(--ok); }
.attention-card h2 { font-size: 1.3125rem; font-weight: 800; margin-bottom: var(--space-2); }
.attention-list { list-style: none; margin: 0; padding: 0; counter-reset: attention; display: flex; flex-direction: column; }
.attention-list li {
  --tone: var(--muted); --tone-soft: var(--surface-2); counter-increment: attention;
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); color: var(--fg);
}
.attention-list li:first-child { border-top: 0; }
.attention-list li.warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.attention-list li.bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.attention-number {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  color: var(--tone); background: var(--tone-soft); font: 800 var(--text-sm) / 1 var(--font);
}
.attention-number::before { content: counter(attention); }
.attention-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.attention-list .btn { flex: none; }
.attention-calm { display: flex; align-items: center; gap: var(--space-3); }
.attention-calm p, .attention-calm h2 { margin: 0; }
.attention-calm-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 50%; color: var(--ok-text); background: var(--ok-soft); }

.status-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.status-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); min-width: 0; padding: var(--space-4) 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.status-tile-head { display: flex; align-items: center; gap: var(--space-2); width: 100%; }
.status-tile-head .icon { color: var(--muted); }
.status-tile-name { flex: 1; min-width: 0; font: 700 1.0625rem / 1.3 var(--font-heading); overflow-wrap: anywhere; }
.status-tile-text { margin: 0; color: var(--muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.muted { background: var(--line-strong); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 9fr) minmax(0, 13fr); gap: var(--space-4); align-items: start; }
.big-number { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); margin: 0 0 var(--space-3); }
.big-number-value { font: 800 2.75rem / 1 var(--font-heading); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.mini-stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini-stats:last-child { margin-bottom: 0; }
.mini-stat-value { display: block; font: 800 1.25rem / 1.2 var(--font); font-variant-numeric: tabular-nums; }
.card h3.section-heading { margin-top: var(--space-1); }
.actions-card .card-header { margin-bottom: var(--space-2); }
.actions-card .card-header h2 { margin-right: auto; }
.actions-explain { color: var(--muted); margin: 0 0 var(--space-3); }
.actions-buttons { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.actions-buttons form { margin: 0; }

/* ---------- Lists: toolbar, search, filter chips, pager ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.toolbar-end { margin-left: auto; }
.search { position: relative; display: block; flex: 0 1 360px; min-width: 220px; margin: 0; }
.search > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
/* :not([type="hidden"]) outranks the generic input rule. */
.search input[type="search"]:not([type="hidden"]) { padding-left: 42px; min-height: 40px; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.filter-chip, .filter-more > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface);
  color: var(--fg); font-size: var(--text-md); font-weight: 700; text-decoration: none; list-style: none;
}
.filter-more > summary::-webkit-details-marker { display: none; }
.filter-chip:hover, .filter-more > summary:hover { border-color: var(--muted); text-decoration: none; }
.filter-chip[aria-current="page"], .filter-more.is-active > summary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.filter-chip-count { color: var(--muted); font-weight: 700; }
.filter-chip[aria-current="page"] .filter-chip-count { color: inherit; opacity: 0.8; }
.filter-more { position: relative; }
.filter-more > summary .icon { width: 16px; height: 16px; }
.filter-more-list {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 220px; display: flex; flex-direction: column; padding: var(--space-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.filter-more-list a { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-sm); color: var(--fg); font-weight: 600; text-decoration: none; }
.filter-more-list a:hover { background: var(--surface-2); }
.filter-more-list a[aria-current="page"] { color: var(--accent-text); font-weight: 800; }
.pager { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-md); }
.pager-info { margin-right: auto; }
.pager .icon-button { width: 44px; padding: 0; }
.pager .btn[aria-disabled="true"] { pointer-events: none; }

/* A table on a wide screen; its rows are cards on a phone (below). The first cell links the whole row. */
.table-cards .cell-title { font-weight: 700; }
.table-cards .cell-title .sub { font-weight: 400; }
.table-cards .cell-link { font-weight: 800; text-decoration: none; }
.table-cards .cell-link:hover { text-decoration: underline; }
/* In a table cell the actions flow inline (a flex td would stop being a table cell); a div or a phone card lays them out with flex. */
.table-cards td.cell-actions { white-space: normal; }
.table-cards td.cell-actions > form { display: inline-flex; margin: 2px 6px 2px 0; vertical-align: middle; }
div.cell-actions, .pin-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pin-form { margin: 0; }
.pin-form input:not([type="hidden"]) { width: 11rem; min-width: 8rem; min-height: 36px !important; padding-block: 6px !important; }
.list-section > .card-header h2 { font-size: 1.125rem; }
.table-cards td.cell-note:empty::before { content: "–"; }
.small-text { font-size: var(--text-sm); margin: 0; }
.title-with-badge { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.alert-actions .btn, .alert-actions button { width: 100%; }
.alert-actions form { margin: 0; }
.alerts-section > .card-header { flex-wrap: wrap; }
.table-alerts .cell-title .sub { display: none; }
.vat-facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); margin: 0; padding: 0 var(--space-4) var(--space-3); }
.vat-facts > div { display: flex; flex-direction: column; }
.vat-facts dt { color: var(--muted); font-size: var(--text-sm); }
.vat-facts dd { margin: 0; font-weight: 700; }
.vat-facts:not(:has(> div:not(.mobile-only))) { display: none; }
.desktop-only-inline { display: inline; }
.table-vat td.vat-line { display: none; }
.page-actions:empty { display: none; }

/* ---------- Detail: main column + right column 380 px; facts as key and value ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--space-5); align-items: start; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: calc(-1 * var(--space-2)); color: var(--muted); font-size: var(--text-md); }
.kv-list { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); margin: 0; }
.kv-list dt, .kv-list dd { min-height: 48px; padding: 13px 0; border-top: 1px solid var(--line); min-width: 0; }
.kv-list dt { color: var(--muted); padding-right: var(--space-4); }
.kv-list dd { margin: 0; text-align: right; font-weight: 700; overflow-wrap: anywhere; }
.kv-list dt:first-of-type, .kv-list dt:first-of-type + dd { border-top: 0; }
.kv-card { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.hint-line { display: flex; gap: var(--space-2); align-items: flex-start; color: var(--muted); font-size: var(--text-md); margin: 0; }
.hint-line .icon { margin-top: 1px; }
.back-row { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 800; text-decoration: none; }
.side-note h3 { font-size: 1rem; margin-bottom: var(--space-1); }
.side-note p { color: var(--muted); font-size: var(--text-sm); margin: 0; }

/* The actions of a detail or a form: in the flow on a wide screen, pinned above the tab bar on a phone. */
.action-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.action-bar form { margin: 0; }

/* ---------- Matching tiles ---------- */
.stat-tiles .stat { background: var(--surface); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.stat-tiles .stat-value { display: flex; align-items: center; gap: var(--space-2); font: 800 1.5rem / 1.2 var(--font-heading); }
.stat-tiles .stat-value::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--stat-tone, var(--line-strong)); }
.stat-tiles .stat-ok { --stat-tone: var(--ok); }
.stat-tiles .stat-warn { --stat-tone: var(--warn); }
.stat-tiles .stat-bad { --stat-tone: var(--bad); }
.stat-tiles .stat-accent { --stat-tone: var(--accent); }

/* ---------- Settings: the overview of sources and sections, then one page per section ---------- */
.settings-sources-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.settings-intro-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); color: var(--muted); }
.settings-intro-row form { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.settings-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.settings-index { position: sticky; top: 76px; padding: var(--space-2); }
.settings-main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.settings-form > fieldset, fieldset.stack { border: 0; padding: 0; margin: 0; min-width: 0; }
.settings-form > .action-bar { justify-content: flex-end; }
.list-row-value.ok { color: var(--ok-text); }
.list-row-value.warn, .list-row-value.bad { font-weight: 700; }
.list-row-value.warn { color: var(--warn); }
.list-row-value.bad { color: var(--bad); }
.section-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.section-nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--fg); font-size: var(--text-md); font-weight: 600; text-decoration: none; }
.section-nav a:hover { background: var(--surface-2); }
.section-nav li.is-current a { background: var(--accent-soft); color: var(--fg); font-weight: 800; }
.section-mark { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); font-size: 0.6875rem; font-weight: 800; }
.section-nav li.is-done .section-mark { border-color: var(--ok); color: var(--ok); }
.section-nav li.is-error .section-mark { border-color: var(--bad); color: var(--bad); }
.section-nav li.is-check .section-mark, .section-nav li.is-suggested .section-mark { border-color: var(--warn); color: var(--warn); }
.section-count { margin-left: auto; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; font-size: var(--text-xs); font-weight: 800; border-radius: var(--radius-pill); background: var(--warn-soft); color: var(--warn); }
.section-nav li.is-error .section-count { background: var(--bad); color: var(--on-bad); }


/* ---------- Tablet and phone navigation (< 1024 px) ---------- */
@media (max-width: 1023px) {
  :is(.area-portal, .area-operator) .app { display: block; }
  :is(.area-portal, .area-operator) .sidebar { display: none; }
  :is(.area-portal, .area-operator) .content { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)); }
  :is(.area-portal, .area-operator) .topbar { position: static; min-height: 56px; padding: var(--space-2) var(--space-4); background: var(--bg); border-bottom: 0; }
  :is(.area-portal, .area-operator) .topbar-brand { display: flex; padding: 0; }
  :is(.area-portal, .area-operator) .topbar-brand .brand-logo { height: 27px; }
  :is(.area-portal, .area-operator) .topbar-back { display: inline-flex; font-size: 1.0625rem; }
  :is(.area-portal, .area-operator) .breadcrumb, :is(.area-portal, .area-operator) .bell, .user-menu-name, .user-menu > summary::after { display: none; }
  .user-menu > summary .avatar { width: 44px; height: 44px; }
  .strip { padding: 10px var(--space-4); }
  :is(.area-portal, .area-operator) .page { padding: var(--space-2) var(--space-4) var(--space-5); }
  .page-title h1 { font-size: 1.625rem; }
  :is(.area-portal, .area-operator) .toasts { bottom: calc(var(--tabbar-height) + var(--space-3)); }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: var(--tabbar-height); padding: 6px var(--space-1) env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; min-width: 0;
    padding: 0; color: var(--muted); font-size: var(--text-xs); font-weight: 700; text-decoration: none; cursor: pointer; list-style: none;
  }
  .tab::-webkit-details-marker { display: none; }
  .tab > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab > .icon, .tab-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 30px; border-radius: var(--radius-pill); }
  .tab .icon { width: 22px; height: 22px; }
  .tab > .icon { padding: 4px 17px; box-sizing: content-box; width: 22px; }
  .tab-icon { position: relative; }
  .tab:hover { color: var(--fg); text-decoration: none; }
  .tab[aria-current="page"], .tab.is-active, .tab-more[open] > .tab { color: var(--accent-text); font-weight: 800; }
  .tab[aria-current="page"] > .icon, .tab[aria-current="page"] .tab-icon, .tab.is-active > .icon, .tab-more[open] > .tab > .icon { background: var(--accent-soft); }
  .tab-count {
    position: absolute; top: -4px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
    display: inline-flex; align-items: center; justify-content: center; font-size: 0.6875rem; font-weight: 800; color: var(--on-bad); background: var(--bad);
  }
  .tab-more { display: block; min-width: 0; }
  .tab-more > .tab { height: 100%; }
  .tab-more[open] > summary::before {
    content: ""; position: fixed; inset: 0 0 var(--tabbar-height); z-index: -1; background: rgb(12 2 18 / 0.45); cursor: default;
  }
  .sheet {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)); z-index: 41;
    max-height: calc(100dvh - var(--tabbar-height) - 56px); overflow-y: auto; overscroll-behavior: contain;
    display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-5);
    background: var(--bg); border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow-lg);
  }
  .sheet > * { flex-shrink: 0; }
  .sheet-who { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .sheet-who-name { display: block; font: 700 var(--text-lg) / 1.3 var(--font-heading); overflow-wrap: anywhere; }
  .sheet-heading { margin: var(--space-3) 0 0; color: var(--muted); font: 800 var(--text-xs) / 1.4 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }

  .status-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .overview-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { display: block; }
  .settings-index { display: none; }
}
@media (max-width: 1023px) and (prefers-color-scheme: dark) {
  .tab-more[open] > summary::before { background: rgb(0 0 0 / 0.6); }
}

/* ---------- Phone (< 768 px) ---------- */
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  .card:not(.card-flush) { padding: var(--space-4); }
  .page-head .page-actions { width: 100%; }
  .page-head .page-actions > * { flex: 1 1 auto; }

  /* Touch targets: 44 px, fields 48 px. */
  .btn.small, .btn-sm, button.small { min-height: var(--tap); }
  button.link { min-height: var(--tap); padding: 0 var(--space-1); }
  .chip-remove { min-width: var(--tap); min-height: var(--tap); margin: -8px -12px -8px -6px; padding: 0; font-size: var(--text-lg); }
  .chip-list .chip { min-height: var(--tap); padding-right: 6px; }
  .search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .search input[type="search"]:not([type="hidden"]) { min-height: var(--field); }
  .form-row { grid-template-columns: minmax(0, 1fr); }

  /* Filter chips scroll sideways inside their row; the page never does. */
  .filter-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; padding-bottom: 2px; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip, .filter-more > summary { min-height: var(--tap); font-size: 0.9375rem; }
  .filter-more-list { position: fixed; left: var(--space-4); right: var(--space-4); top: auto; }
  .pager { border-top: 0; padding: var(--space-3) 0 0; }

  .attention-list li { flex-wrap: wrap; }
  .attention-list li .attention-text { flex: 1 1 calc(100% - 44px); }
  .attention-list li .btn { margin-left: 40px; }
  .status-tile { padding: var(--space-3) 14px; }
  .big-number-value { font-size: 2.5rem; }
  .actions-buttons > form, .actions-buttons > form > button { width: 100%; }
  .mini-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-sources-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-intro-row { align-items: flex-start; flex-direction: column; }

  /* The actions of a detail or a form are pinned above the tab bar, full width. */
  .action-bar {
    position: sticky; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)); z-index: 5;
    margin: 0 calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .action-bar > *, .action-bar > form > button, .action-bar > .btn { flex: 1 1 100%; width: 100%; }

  /* The rows of .table-cards become cards: title and state on top, the rest below; labels come from data-label. */
  .list-section { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .list-section > .card-header { min-height: 0; padding: 0 0 var(--space-2); }
  .list-section > .table-wrap { margin: 0; overflow: visible; background: none; }
  .table-cards, .table-cards tbody { display: block; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards tbody { display: flex; flex-direction: column; gap: var(--space-3); }
  .table-cards tr {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: row dense; align-items: center; gap: 6px var(--space-3);
    padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  }
  .table-cards tr.tone-edge { border-left: 4px solid var(--edge, var(--line)); }
  .table-cards td { display: block; grid-column: 1 / -1; min-width: 0; padding: 0; border: 0; background: transparent; overflow-wrap: anywhere; text-align: left; }
  .table-cards tbody tr:hover td { background: transparent; }
  .table-cards td.cell-title { grid-column: 1; grid-row: 1; font: 800 1rem / 1.35 var(--font); }
  .table-cards td.cell-title .sub { font-weight: 400; margin-top: 2px; }
  .table-cards td.cell-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .table-cards td.cell-meta { grid-column: 1; }
  .table-cards td.cell-end { grid-column: 2; justify-self: end; text-align: right; }
  .table-cards td.cell-time { grid-column: 2; justify-self: end; }
  .table-cards td.num { text-align: left; }
  .table-cards td.cell-end.num { text-align: right; }
  .table-cards td:empty { display: none; }
  .table-cards td[data-label]::before { content: attr(data-label) " "; }
  .table-cards td[data-label].cell-end::before { content: none; }
  .table-cards .cell-link { color: var(--fg); }
  .table-cards .cell-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
  .table-cards td.cell-meta, .table-cards td.cell-time, .table-cards td.cell-note { color: var(--muted); }
  .table-cards td.cell-actions { position: relative; z-index: 1; margin-top: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .table-cards td.cell-actions > form { margin: 0; }
  .table-cards td.cell-actions .pin-form { flex: 1 1 100%; }
  .table-cards td.cell-actions .pin-form input:not([type="hidden"]) { flex: 1; width: auto; min-height: var(--tap) !important; }
  /* Orders: "#id", the reason under the title, then the document and the time on one line. */
  .table-orders .cell-link::before { content: "#"; }
  .table-cards td.cell-note { order: 1; }
  .table-cards td.cell-meta, .table-cards td.cell-time { order: 2; }
  .table-cards td.cell-note:empty::before { content: none; }
  /* Alerts: cards inside the card, the message under the title, the state on the right. */
  .alerts-section { padding: var(--space-4); overflow: visible; }
  .alerts-section > .card-header { min-height: 0; padding: 0 0 var(--space-3); }
  .alerts-section .table-wrap { overflow: visible; background: none; }
  .table-alerts .cell-title .sub { display: block; color: var(--muted); }
  .table-alerts td.cell-status { grid-row: 1; }
  .table-alerts td.cell-meta { order: 3; grid-column: 1 / -1; }
  .table-alerts td.alert-state { order: 2; grid-row: 2; align-self: start; font-weight: 800; color: var(--fg); }
  .table-alerts tr { box-shadow: none; }
  .table-alerts td.cell-title .sub { order: 1; }
  .desktop-only-inline { display: none; }
  .vat-facts:not(:has(> div:not(.mobile-only))) { display: flex; }
  .table-vat td.vat-cell { display: none; }
  .table-vat td.vat-line { display: block; color: var(--muted); font-size: var(--text-sm); }
  .table-vat td.cell-status { font-weight: 800; }
  .table-matching td:nth-child(3)::before { content: "Kód: "; color: var(--muted); }
  .table-matching td:nth-child(4)::before { content: "Párováno podle: "; color: var(--muted); }

  /* The last runs on a phone: one line each, name, result, time (no header). */
  .table-stack-flows tr { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
  .table-stack-flows tr > td:first-child { flex: 1; min-width: 0; font-weight: 600; }
  .table-stack-flows td:nth-child(n)::before { content: none; }
  .table-stack-flows td:last-child { color: var(--muted); font-size: var(--text-sm); white-space: nowrap; }

}

/* ---------- Setup wizard (stage 2) ---------- */
/* The shell: a slim top bar (_WizardLayout), the list of steps on the left from 1024 px, the step in a column of 720 px (wide steps: the rest). */
.area-wizard .wiz-top { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) var(--space-4); background: var(--bg); }
.area-wizard .wiz-brand { order: 2; margin-left: auto; padding: 0; }
.wiz-brand .brand-logo { height: 27px; }
.wiz-leave { order: 1; display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); font: 700 1.0625rem / 1.2 var(--font); text-decoration: none; }
.wiz-leave:hover { text-decoration: underline; }
.wiz-title { display: none; }
.wiz-main { display: flex; flex-direction: column; }
.wiz { display: grid; grid-template-columns: minmax(0, 1fr); padding: var(--space-2) var(--space-4) 0; }
.wiz-step { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.wiz-steps { display: none; }
.area-wizard .toasts { bottom: 88px; }

/* Heading of a step: kicker with the segmented progress on a phone. */
.wiz-head { display: flex; flex-direction: column; gap: var(--space-2); }
.wiz-kicker { display: flex; justify-content: space-between; gap: var(--space-2); margin: 0; font: 800 0.9375rem / 1.3 var(--font); color: var(--accent-text); }
.wiz-kicker-label { color: var(--muted); font-weight: 600; }
.wiz-segments { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.wiz-segments li { height: 6px; border-radius: var(--radius-pill); background: var(--line); }
.wiz-segments li.is-done { background: var(--brand); }
.wiz-segments li.is-current { background: var(--accent); }
.wiz-segments li.is-error { background: var(--bad); }
.wiz-head h1 { font: 800 1.375rem / 1.25 var(--font-heading); letter-spacing: -0.01em; }
.wiz-help { margin: 0; }

/* The foot of a step: back and the main action; pinned to the bottom edge on a phone. */
.wiz-form { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.wiz-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: var(--space-3);
  margin: var(--space-2) calc(-1 * var(--space-4)) 0; padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line);
}
.wiz-bar > button, .wiz-bar > a.btn:not(.wiz-back) { flex: 1 1 auto; }
.wiz-bar .wiz-back { flex: none; }
.wiz-skip { margin: 0; text-align: right; font-size: var(--text-md); }
.wiz-note { margin: 0; font-size: var(--text-sm); }
.wiz-count { font-weight: 800; font-size: var(--text-md); }
.wiz-save-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* Fields */
.wiz-fields { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; margin: 0; border: 0; padding: 0; }
.card.wiz-fields { padding: var(--space-4); }
.wiz .field { margin-bottom: 0; }
.wiz-fields select { width: 100%; }
.wiz-fields .choice { align-items: center; min-height: var(--tap); gap: var(--space-3); }
.wiz-fields .choice input { margin: 0; }
.wiz-fields .section-heading { margin: var(--space-2) 0 var(--space-3); }
.wiz-fields legend, fieldset.field legend { padding: 0; margin: 0 0 6px; font-weight: 700; font-size: var(--text-md); }
fieldset.field { min-width: 0; border: 0; padding: 0; }
.wiz-fact { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 52px; margin: 0; padding: 0 var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.wiz-fact dt { color: var(--muted); font-size: var(--text-md); }
.wiz-fact dd { margin: 0; font-weight: 700; text-align: right; }
.card > .wiz-fact { margin-bottom: 0; }
.wiz details.advanced > summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-height: var(--tap); }
.wiz .card h3, .wiz .card .wiz-card-title { margin: 0; font: 700 1.125rem / 1.3 var(--font-heading); }
.wiz-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); }
.wiz-when { margin: 0; font-size: var(--text-sm); }

/* Step 3: the modules as cards; the price below the text. */
.setup-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.card.setup-module { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 6px var(--space-3); align-items: start; cursor: pointer; }
.setup-module > input { margin-top: 1px; }
.setup-module-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setup-module-main strong { font-size: var(--text-lg); }
.setup-module-main .muted { font-size: var(--text-md); }
.setup-module-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); font-weight: 700; }
.setup-module-badges { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); margin-left: auto; }
.wiz-estimate { padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); }
.wiz-estimate dt, .wiz-estimate dd { font-size: var(--text-md); }
.wiz-estimate dd { font-weight: 700; }
#setup-estimate { display: flex; flex-direction: column; gap: var(--space-3); }

/* Step 4 */
.card.setup-prepare { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-3); }
.setup-prepare .choice { gap: var(--space-3); align-items: flex-start; }
.setup-prepare .choice input { margin-top: 0; }
.setup-prepare .stack-tight { gap: 4px; min-width: 0; }
.setup-prepare .stack-tight .muted { font-size: var(--text-md); }
.setup-prepare .row { gap: var(--space-4); margin-top: var(--space-2); font-weight: 700; }
.stack-tight { display: flex; flex-direction: column; gap: 2px; }

/* Step 5 (the code is also shown on the agent page) */
.setup-agent { display: flex; flex-direction: column; gap: var(--space-4); }
.setup-code { margin: 0; font-size: var(--text-2xl); letter-spacing: 0.12em; font-weight: 600; }
.setup-code-box { padding: var(--space-5) var(--space-4); border-radius: var(--radius); background: var(--surface-2); text-align: center; }
.setup-code-box p { margin: 0; }
.setup-code-box .setup-code { font: 800 2rem / 1.2 var(--font-heading); letter-spacing: 3px; }
.setup-code-box code, .setup-agent small code { padding: 0; background: transparent; font: inherit; }
.wiz-bullets { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: var(--space-2); }
.wiz-strong-link { font-weight: 800; text-decoration: none; }

/* The checks (connection, Base token, dry run): an icon per line in the wizard, the text marks elsewhere. */
.setup-checks > li > .icon { display: none; }
.setup-checks .check-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.flow-overview li { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-3); }
.flow-state { display: inline-flex; align-items: center; gap: var(--space-3); }
.wiz .setup-checks { gap: var(--space-3); }
.wiz .setup-checks > li { flex-direction: row; align-items: flex-start; gap: var(--space-3); padding-left: 0; border-left: 0; color: var(--fg); }
.wiz .setup-checks > li > .icon { display: block; width: 22px; height: 22px; margin-top: 1px; }
.wiz .setup-checks li.ok > .icon { color: var(--ok-text); }
.wiz .setup-checks li.warn > .icon { color: var(--warn); }
.wiz .setup-checks li.bad > .icon { color: var(--bad); }
.wiz .check-glyph { display: none; }
.wiz .check-body > .muted:not(.check-note) { color: var(--fg); }
.wiz .check-hint { color: var(--fg); font-size: var(--text-md); }
.wiz .check-note { font-size: var(--text-sm); }
.wiz .setup-validation .setup-checks { display: block; list-style: disc; padding-left: 1.1em; }
.wiz .setup-validation .setup-checks > li { display: list-item; }
.wiz .setup-validation .setup-checks > li > .icon { display: none; }
.wiz .flow-overview > li { align-items: center; }

/* Step 6 and 7 */
.wiz-fields.wiz-fields-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.wiz-pair { display: flex; flex-direction: column; gap: var(--space-4); }
.setup-columns-even { grid-template-columns: minmax(0, 1fr); }
.wiz .card form { margin: 0; }

/* Step 8: the sections of the module settings (their partials are styled elsewhere). */
.wiz-sections { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.wiz-section-index { display: flex; flex-direction: column; gap: var(--space-3); }
.wiz-section-index p { margin: 0; font-size: var(--text-md); }
.wiz-section-body { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.wiz-section-body .section-actions { justify-content: space-between; }
.wiz-errors { display: flex; align-items: flex-start; gap: var(--space-3); padding: 14px var(--space-4); border-radius: var(--radius); background: var(--bad-soft); font-size: var(--text-md); }
.wiz-errors p { margin: 0 0 2px; font-weight: 800; }
.wiz-errors ul { margin: 0; padding: 0; list-style: none; }
.wiz-errors a { color: var(--fg); text-decoration: none; }
.wiz-confirm-all { margin: 0; }
.wiz-confirm-all button { width: 100%; }

/* Step 9 */
.wiz-summary { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.wiz-summary li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 34px; }
.wiz-summary a { font-weight: 700; text-decoration: none; }
.wiz-modules { margin: 0; }
.wiz .card .section-heading { margin: var(--space-1) 0 0; }

/* Phone: buttons inside cards take the full width. */
@media (max-width: 767px) {
  .wiz-step .card button, .wiz-step .card .btn { width: 100%; }
  .wiz-leave .icon { width: 24px; height: 24px; }
  .wiz-bar > button .icon, .wiz-bar > a.btn .icon { display: none; }
  .wiz-bar .wiz-back .icon { display: none; }
}

/* From 768 px: the desktop top bar and two-column field rows. */
@media (min-width: 768px) {
  .area-wizard .wiz-top { min-height: 64px; padding: 0 56px 0 40px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .area-wizard .wiz-brand { order: 1; margin-left: 0; }
  .wiz-brand .brand-logo { height: 31px; }
  .wiz-title { order: 2; display: block; padding-left: var(--space-4); margin-left: var(--space-1); border-left: 1px solid var(--line); font: 700 var(--text-md) / 32px var(--font); }
  .wiz-leave { order: 3; margin-left: auto; font-size: var(--text-md); }
  .wiz-leave .icon { display: none; }
  .wiz { padding: var(--space-6) 40px var(--space-6); }
  .wiz-kicker { justify-content: flex-start; font-size: var(--text-xs); letter-spacing: 0.8px; text-transform: uppercase; }
  .wiz-kicker-label { display: none; }
  .wiz-head { gap: var(--space-3); }
  .wiz-head h1 { font-size: 1.5rem; }
  .wiz-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
  .wiz-pair-postal { grid-template-columns: minmax(0, 5fr) minmax(0, 12fr); }
  .wiz-fields.wiz-fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-3); }
  .wiz-bar { position: static; margin: var(--space-1) 0 0; padding: var(--space-4) 0 0; background: transparent; }
  .wiz-bar > button, .wiz-bar > a.btn:not(.wiz-back) { flex: none; margin-left: auto; }
  .wiz-confirm-all button { width: auto; }
  .area-wizard .toasts { bottom: var(--space-4); }
}

/* A tablet keeps the pinned bar, the segments and the phone navigation. */
@media (min-width: 768px) and (max-width: 1023px) {
  .wiz-bar { position: sticky; bottom: 0; margin: var(--space-2) -24px 0; padding: var(--space-3) 24px; background: var(--surface); border-top: 1px solid var(--line); }
  .wiz { padding: var(--space-4) 24px 0; }
  .area-wizard .wiz-top { padding: 0 24px; }
}

/* From 1024 px: the step list, the step beside it. */
@media (min-width: 1024px) {
  .wiz { grid-template-columns: 280px minmax(0, 1fr); gap: 48px; align-items: start; }
  .wiz-steps { display: block; position: sticky; top: var(--space-5); }
  .wiz-steps ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
  .wiz-steps a { display: flex; align-items: center; gap: var(--space-3); min-height: 46px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted); font-size: var(--text-md); font-weight: 600; text-decoration: none; }
  .wiz-steps a:hover { background: var(--surface-2); }
  .wiz-steps .step-number { flex: none; width: 26px; height: 26px; border: 0; background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: 800; }
  .wiz-steps .step-number .icon { width: 15px; height: 15px; stroke-width: 3; }
  .wiz-steps li.is-done a { color: var(--fg); }
  .wiz-steps li.is-done .step-number { background: var(--brand); color: #ffffff; }
  .wiz-steps li.is-error .step-number { background: var(--bad); color: var(--on-bad); }
  .wiz-steps li.is-current a { background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
  .wiz-steps li.is-current .step-number { background: var(--accent); color: var(--on-accent); }
  .wiz-segments { display: none; }
  .wiz-step { max-width: 720px; }
  .wiz-step.wiz-wide { max-width: none; }
  .wiz { padding-bottom: var(--space-6); }
  .wiz-bar { position: static; margin: var(--space-1) 0 0; padding: var(--space-4) 0 0; background: transparent; border-top: 1px solid var(--line); }
  .setup-columns { grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; }
  .setup-columns-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #setup-estimate { position: sticky; top: var(--space-5); }
  .wiz-sections { grid-template-columns: 240px minmax(0, 1fr); gap: 20px; }
}
.wiz .flow-overview a { font-weight: 700; text-decoration: none; }
@media (max-width: 767px) {
  .wiz-section-body .section-actions > button, .wiz-section-body .section-actions > .btn { flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .setup-code-box .setup-code { font-size: 1.5rem; letter-spacing: 1px; white-space: nowrap; }
}

/* ---------- Settings: overview and section pages (portal-nastaveni-*) ---------- */
.settings-sources-grid > form { display: none; }
.settings-sources-grid > section h2 { font-size: 1.125rem; }
.settings-sources-grid > section .muted { margin: 0; }
.settings-sources-grid > section > div:last-child > button { margin-top: var(--space-1); }
.settings-intro-row .settings-wizard { margin: 0; }
.settings-intro-row .settings-wizard a { color: inherit; text-decoration: none; }
.settings-intro-row .settings-wizard a:hover { text-decoration: underline; }
.settings-propose button.secondary { margin: 0; }
.settings-list .list-row .badge { flex: none; }
/* On a section page the title and description are the page head: the section's own heading goes; its errors stay. */
.settings-section-page .settings-section > h2[id^="h-"], .settings-section-page .settings-section > h2[id^="h-"] + p.muted { display: none; }
.settings-section-page .settings-section { gap: var(--space-4); }
.settings-section .card h3, .settings-section .card-title h3 { font-size: 1.1875rem; font-weight: 700; }
.settings-section .card > p.muted { margin: 0; color: var(--muted); font-size: var(--text-md); }
/* A check box on a row of its own: a 44 px target, the text next to the box. */
.settings-section label:has(> input[type="checkbox"]), .settings-section label:has(> input[type="radio"]), label.choice {
  display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); margin: 0; font-weight: 600; color: var(--fg);
}
.settings-section .field:has(> label > input[type="checkbox"]) { margin-bottom: 0; }
/* Mapping tables: the head on --surface-2, inputs in the cells; cards on a phone. */
.mapping > label { font-size: 0.9375rem; }
.mapping .table-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.mapping table td { padding: 8px var(--space-4); }
.mapping table tr:last-child td { border-bottom: 0; }
.mapping button.link { text-decoration: none; font-weight: 800; }
details.advanced { padding: 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
details.advanced > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-3); min-height: 64px; padding: var(--space-3) 52px var(--space-3) 20px;
  position: relative; cursor: pointer; list-style: none;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary > strong { flex-basis: 100%; font-size: 0.9375rem; }
details.advanced > summary > .muted { font-size: var(--text-sm); }
details.advanced > summary::after {
  content: ""; position: absolute; right: 22px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s;
}
details.advanced[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
details.advanced > :not(summary) { padding: 0 20px 20px; }
details.advanced[open] > summary { margin-bottom: 0; }
.origin-reason { color: var(--warn); }
.chip { min-height: 26px; padding: 2px 10px; font-weight: 700; }
.chip.origin-ok { color: var(--ok-text); background: var(--ok-soft); border-color: transparent; }
.chip.origin-check { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.chip.origin-user { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
.chip.origin-error { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.mapping tr:has(.origin-check) select, .mapping tr:has(.origin-check) input[type="text"] { border: 2px solid var(--warn); }
[aria-invalid="true"] { border: 2px solid var(--bad) !important; background: var(--surface); }
.field-error::before { content: none; }

@media (max-width: 767px) {
  .settings-propose { flex-direction: column; align-items: stretch !important; }
  .settings-propose button.secondary { width: 100%; }
  .settings-sources-grid > section > div:last-child > button { width: 100%; }
  /* A mapping row is a card: the key on top with its origin, the value with its label below. */
  .mapping .table-wrap { border: 0; background: none; overflow: visible; }
  .mapping table, .mapping tbody { display: block; }
  .mapping thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .mapping tbody { display: flex; flex-direction: column; gap: var(--space-2); }
  .mapping tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); }
  .mapping td { display: block; padding: 0 !important; border: 0; background: transparent !important; min-width: 0; }
  .mapping td:first-child { grid-column: 1; grid-row: 1; }
  .mapping td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .mapping td:nth-child(3) { grid-column: 2; grid-row: 1; align-self: center; }
  .mapping td > select, .mapping td > input { width: 100%; }
  .table-wrap td > input:not([type="checkbox"]):not([type="radio"]), .table-wrap td > select { min-width: 0; }
}

/* ---------- Sign-in and public pages (stage 2) ---------- */
/* Phone: logo on top, the form straight on the page. Wide screen (>= 900 px): a coal panel of 560 px on the left (claim), the form centred on the right. */
.auth-split { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.split-hero { display: none; }
.split-main { display: flex; justify-content: center; padding: 28px 20px 40px; min-width: 0; }
.split-body { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.split-brand { display: block; }
.split-brand .brand-picture { display: block; }
.split-brand .brand-logo { display: block; height: 38px; width: auto; max-width: 100%; }

.auth-form, .split-body > .card { display: flex; flex-direction: column; gap: 16px; }
.split-body > .card { background: none; border: 0; box-shadow: none; padding: 0; }
.auth-form > *, .split-body > .card > * { margin: 0; }
.auth-form h1, .split-body > .card h1 { font-size: 1.625rem; line-height: 1.2; margin-bottom: 4px; }
.auth-form .field, .split-body > .card .field { margin: 0; }
.auth-form p, .split-body > .card p { margin: 0; }
.auth-form .form-error, .split-body > .card .form-error { font-size: var(--text-md); }
.auth-form .field > .form-error { margin: 0; }
.auth-form > .btn { align-self: flex-start; }
.auth-sub { margin-top: 6px !important; }
.auth-sub a, .strong-link { font-weight: 700; text-decoration: none; }
.auth-icon { display: inline-flex; margin-bottom: 8px; color: var(--accent-text); }
.auth-icon .icon { width: 32px; height: 32px; }
.auth-icon-warn { color: var(--warn); }

/* Links under the button: one per line, centred, 44 px tall. */
.auth-links { display: flex; flex-direction: column; align-items: center; text-align: center; }
.auth-links a { display: flex; align-items: center; justify-content: center; min-height: var(--tap); font-weight: 700; text-decoration: none; }
.auth-links p { display: flex; flex-direction: column; align-items: center; }
.split-body > .card a:not(.btn) { font-weight: 700; text-decoration: none; }

/* Registration */
.auth-form .company-id, .auth-form .company-city { flex-direction: column; align-items: stretch; gap: 16px; }
.auth-form .company-id > .field, .auth-form .company-city > .field { flex: none; }
.auth-form .company-fields { gap: 16px; }
.auth-form fieldset.field { margin: 0; }
.auth-form fieldset.field legend { padding: 0; margin-bottom: 4px; color: var(--muted); font: 800 var(--text-xs) / 1.3 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }
.choice-list { display: flex; flex-direction: column; }
.choice-row { align-items: center; min-height: 52px; font-size: 0.9375rem; }
.choice-row input { margin-top: 0; }
.auth-form .consent { align-items: flex-start; min-height: var(--tap); font-size: 0.9375rem; }
.auth-form .consent a { font-weight: 700; text-decoration: none; }
.auth-form .cf-turnstile { min-height: 65px; max-width: 100%; }
.chip-ares { margin-left: 6px; padding: 2px 10px; border: 0; background: var(--accent-soft); color: var(--accent-text); font-size: var(--text-xs); font-weight: 700; vertical-align: 1px; }
.chip-ares::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* The coal panel is the same in the light and the dark mode (brand colours). */
@media (min-width: 900px) {
  .auth-split { grid-template-columns: 560px minmax(0, 1fr); }
  .split-hero { display: flex; flex-direction: column; gap: 32px; padding: 52px 56px 40px; background: #0c0212; color: #fff; }
  .split-hero-logo .brand-logo { display: block; height: 43px; width: auto; }
  .split-hero-body { margin-block: auto; }
  .split-claim { margin: 0 0 16px; font: 800 2.5rem / 1.15 var(--font-heading); letter-spacing: -0.01em; color: #fff; }
  .split-lead { margin: 0 0 24px; font-size: 1.0625rem; line-height: 1.5; color: #e9e6ee; }
  .split-features { margin: 0 0 28px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 0.9375rem; color: #f4f4f6; }
  .split-features li::before { content: "\2713"; margin-right: 6px; font-weight: 800; }
  .split-eyebrow { margin: 0 0 10px; color: #b9b4c0; font: 800 var(--text-xs) / 1.3 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }
  .split-erps { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
  .split-erps li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: #eeeef2; color: #0c0212; font-size: var(--text-xs); font-weight: 700; }
  .split-erps li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #5a5462; }
  .split-foot { margin: 0; color: #b9b4c0; font-size: var(--text-sm); }
  .split-brand { display: none; }
  .split-main { align-items: center; padding: 64px 40px; }
  .split-body-wide { max-width: 520px; }
  .auth-form .company-id, .auth-form .company-city { flex-direction: row; gap: 10px; }
  .auth-form .company-id > .field, .auth-form .company-city > .field { flex: 1 1 0; min-width: 0; }
  .auth-form .field-hint { font-size: var(--text-sm); }
}
@media (min-width: 600px) and (max-width: 899px) {
  .split-main { padding-top: 56px; }
  .auth-form .company-id, .auth-form .company-city { flex-direction: row; gap: 10px; }
  .auth-form .company-id > .field, .auth-form .company-city > .field { flex: 1 1 0; min-width: 0; }
}

/* ---------- Operation and administration pages (stage 2) ---------- */
.card-narrow, .card-medium { max-width: 720px; }
.field-medium { max-width: 560px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); align-items: start; }
.form-grid > .field { margin-bottom: var(--space-3); }
.card > .action-bar.action-bar-start { justify-content: flex-start; }
.row-stack-mobile > form { margin: 0; }
.row-fields input:not([type="hidden"]) { flex: 1 1 200px; width: auto; max-width: 320px; }
.empty-note, .call-hint, .history-note { padding: var(--space-3) var(--space-4) var(--space-4); margin: 0; }
.card-flush > .empty-note:first-of-type, .card-flush > .call-hint:first-of-type { padding-top: 0; }

/* Key and value inside a bordered box: values left (agent) or right (default), a header row on a wide screen (Slack status). */
.kv-inset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 var(--space-4); overflow: hidden; }
.kv-list.kv-start { grid-template-columns: minmax(0, min(40%, 210px)) minmax(0, 1fr); }
.kv-list.kv-start dd { text-align: left; }
.kv-list.kv-start dd.kv-end { text-align: right; }
.kv-list dd.nowrap { white-space: nowrap; }
.kv-wrap { display: flex; flex-wrap: nowrap; margin: 0; padding: 0; }
.kv-wrap:has(.kv-full) { flex-wrap: wrap; }
.kv-wrap > div { flex: 1 1 auto; min-width: 0; }
.kv-wrap dt { padding: 10px var(--space-4); background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: 800; white-space: nowrap; }
.kv-wrap dd { margin: 0; padding: 14px var(--space-4); min-height: 52px; overflow-wrap: anywhere; }
.kv-wrap > .kv-full { flex-basis: 100%; }
.kv-wrap > .kv-full dd { border-top: 1px solid var(--line); }

/* A URL or code in a box; numbered steps with a circle. */
p.code-block { margin: 0; padding: 14px var(--space-4); background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--text-md); overflow-wrap: anywhere; }
p.code-block code { font: inherit; }
.steps-list { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: var(--space-3); }
.steps-list li { position: relative; counter-increment: step; min-height: 28px; padding: 3px 0 0 40px; }
.steps-list li::before {
  content: counter(step); position: absolute; left: 0; top: 0; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: var(--text-sm); font-weight: 800;
}

/* Choices: radios and check boxes in 44 px rows. */
fieldset.choice-list { border: 0; padding: 0; min-width: 0; }
fieldset.choice-list legend { padding: 0; margin-bottom: 6px; color: var(--fg); font-size: var(--text-md); font-weight: 700; }
.choice-list .choice { align-items: center; gap: var(--space-3); min-height: 44px; margin: 0; font-size: 0.9375rem; font-weight: 400; }
.choice-list .choice input { margin: 0; }

/* Agent: the pairing code in a soft box (the partial is shared with the wizard, hence the scope). */
.agent-page aside .card { height: auto; }
.agent-page .setup-code { margin: 0; padding: var(--space-4) var(--space-4) var(--space-1); text-align: center; background: var(--accent-soft); border-radius: var(--radius) var(--radius) 0 0; }
.agent-page .setup-code code { font: 800 1.875rem / 1.2 var(--mono); letter-spacing: 0.06em; color: var(--accent-text); background: none; padding: 0; }
.agent-page .setup-code + p { margin-top: calc(-1 * var(--space-3)); padding: 0 var(--space-4) var(--space-4); text-align: center; background: var(--accent-soft); border-radius: 0 0 var(--radius) var(--radius); }
.agent-page aside form button { width: 100%; }

/* Billing: four numbers. */
.billing-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.billing-stats .stat { padding: var(--space-4) 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.billing-stats .stat-value { font: 800 1.875rem / 1.2 var(--font-heading); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.billing-stats .stat-label { margin-top: var(--space-1); }
.pdf-link { font-weight: 800; text-decoration: none; }
.table-invoices td.cell-title code { font: inherit; background: none; padding: 0; }

/* Users: role change and invitation. */
.role-form { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.role-form select { min-width: 150px; }
.invite-fields { display: grid; grid-template-columns: minmax(0, 1fr) 200px auto; gap: var(--space-4); align-items: end; }
.invite-fields .field { margin: 0; }
.table-modules .usage-progress { max-width: 220px; margin-top: 6px; }

@media (min-width: 768px) {
  /* Tables keep a real cell for the actions and normal text color (the card rows of the phone are muted). */
  :is(.table-modules, .table-users, .table-invoices, .table-calls, .table-history) td.cell-actions { display: table-cell; white-space: nowrap; }
  :is(.table-modules, .table-users, .table-invoices, .table-calls, .table-history) :is(td.cell-meta, td.cell-note) { color: var(--fg); }
  .table-history td.cell-title { font-weight: 400; }
  .table-modules td.cell-title, .table-users td.cell-title { white-space: nowrap; }
  .table-modules td.cell-title .sub { white-space: normal; }
}
@media (max-width: 1023px) {
  .billing-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
}

@media (max-width: 767px) {
  .btn-block-mobile, form > .btn-block-mobile { width: 100%; }
  .card > .action-bar.action-bar-start { margin: 0 -32px -16px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .invite-fields { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .invite-fields select { width: 100%; }
  .row-stack-mobile > form { flex: 1 1 100%; }
  .row-stack-mobile > form > button { width: 100%; }
  .row-fields > * { flex: 1 1 100%; max-width: none; }
  .row-fields button { width: 100%; }
  .kv-inset { padding: 0 var(--space-4); }
  .kv-wrap { display: block; }
  .kv-wrap > div { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 48px; padding: 13px 0; border-top: 1px solid var(--line); }
  .kv-wrap > div:first-child { border-top: 0; }
  .kv-wrap dt { padding: 0; background: none; font-size: var(--text-md); font-weight: 400; white-space: normal; }
  .kv-wrap dd { padding: 0; min-height: 0; text-align: right; font-weight: 700; }
  .kv-wrap > .kv-full { display: block; }
  .kv-wrap > .kv-full dd { padding: 4px 0 0; border: 0; text-align: left; }
  .kv-list.kv-start { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }

  /* Card rows inside a white card (webhook calls, invoices, access history). */
  .card.list-section { padding: 0; }
  .card.card-cards { padding: var(--space-4); }
  .card-cards > .card-header { min-height: 0; margin: 0 0 var(--space-3); padding: 0; }
  .card-cards > .table-wrap { overflow: visible; }
  .card-cards .table-cards tr { box-shadow: none; padding: 14px; }
  .card-cards > p { padding-inline: 0; }
  .card-cards > .empty { padding-inline: 0; }
  .list-section > p { padding-inline: 0; }

  .table-cards td.cell-actions:not(:has(*)) { display: none; }
  .table-cards td.cell-actions form { display: block; margin: 0; }
  .table-cards td.cell-actions form > button, .table-cards td.cell-actions .pdf-link { width: 100%; }
  .table-cards td.cell-actions .pdf-link {
    display: flex; align-items: center; justify-content: center; min-height: var(--tap); border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font-size: 0.9375rem;
  }
  .table-modules td.cell-usage, .table-users td.cell-name { color: var(--muted); }
  .table-modules td.cell-usage .mobile-only { display: inline; }
  .table-modules td.usage-empty { display: none; }
  .table-users td.cell-role .role-form { gap: var(--space-2); }
  .table-users td.cell-role .role-form select { flex: 1; min-width: 0; }
  .table-users td.cell-role:not(:has(form)) { color: var(--muted); }
  .table-calls td.cell-meta, .table-history td.cell-meta, .table-invoices td.cell-meta { color: var(--muted); }
  .table-history td.cell-note { font-size: var(--text-sm); }
  .table-calls td.cell-title { word-break: normal; }
  .billing-stats .stat { padding: 14px var(--space-4); }
  .billing-stats .stat-value { font-size: 1.375rem; white-space: nowrap; }
}

/* ---------- Products pages (stage 2) ---------- */
/* Matching, creating products from cards (batches and their detail), product fields. */
.card-pad { padding: 0 var(--space-4) var(--space-4); }
.card-flush > .toolbar { padding: 0 var(--space-4) var(--space-3); }
.inset { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.inset > .table-wrap tbody tr:last-child td { border-bottom: 0; }
.pager .btn[aria-hidden="true"] { opacity: 0.45; pointer-events: none; }
.pager .btn .icon { width: 18px; height: 18px; }
.stat-tiles .stat-value::before { flex: none; }
.stat-tiles .stat:not(.stat-ok):not(.stat-warn):not(.stat-bad) .stat-value::before { display: none; }
.stat-tiles .stat-label a { color: inherit; text-decoration: none; }
.stat-tiles .stat-label a:hover { text-decoration: underline; }
.stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .stat-tiles.tiles-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .stat-tiles.tiles-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* A select (or a field) with its button on one row; stacked on a phone. */
.inline-field { display: flex; align-items: flex-end; gap: var(--space-2); margin: 0; }
.inline-field .field { margin: 0; }
.inline-field select { min-width: 220px; }
.inline-field button.small { min-height: var(--field); }
.catalog-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-5); }
.card-header .inline-field { margin-left: auto; }
.card-header .inline-field select { min-width: 200px; }

/* Matching: the cards without a product. */
.notice-action { flex-wrap: wrap; align-items: center; }
.notice-action .notice-text { flex: 1 1 0; }
.notice-link { margin-left: auto; font-weight: 800; white-space: nowrap; }
.search-form { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.search-form .search { flex: 1 1 auto; max-width: 420px; }
.table-unpaired th:first-child, .table-unpaired td.cell-pick { width: 56px; padding-right: 0; }
.table-unpaired td.cell-pick { line-height: 0; }
.table-unpaired th { padding-left: var(--space-3); }
.table-unpaired td { padding-left: var(--space-3); }
.pin-form input:not([type="hidden"]) { width: 7.5rem; }
.table-matching td.cell-actions, .table-orphans td.cell-actions, .table-fields td.cell-actions { display: table-cell; }
.table-fields td.cell-actions { white-space: nowrap; }
.table-matching .pin-form { display: inline-flex; flex-wrap: nowrap; vertical-align: middle; margin: 0 var(--space-2) var(--space-1) 0; }
.table-matching td.cell-actions form.inline { margin-right: var(--space-2); }
.table-matching td.cell-actions form.inline, .table-matching td.cell-actions button { vertical-align: middle; }

/* Disclosure row ("Jak to funguje"): a bordered row with a title, a hint and a chevron. */
details.disclosure { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
details.disclosure > summary { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) var(--space-4); cursor: pointer; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: var(--radius-sm); }
.disclosure-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.disclosure-title { font-weight: 800; }
.disclosure-sub { color: var(--muted); font-size: var(--text-sm); }
details.disclosure > summary > .icon { flex: none; color: var(--muted); transition: transform 0.15s; }
details.disclosure[open] > summary > .icon { transform: rotate(90deg); }
details.disclosure[open] .disclosure-sub { display: none; }
details.disclosure > ul { margin: 0; padding: 0 var(--space-4) var(--space-4) 36px; display: flex; flex-direction: column; gap: var(--space-2); }

/* Batches. */
.table-batches td.cell-break { display: none; }
.table-batches td.cell-title { font-weight: 800; }
.cell-time { white-space: nowrap; }
.batch-grid { grid-template-areas: "main aside" "items aside"; }
.batch-main { grid-area: main; min-width: 0; }
.batch-aside { grid-area: aside; display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.batch-items { grid-area: items; min-width: 0; }
.batch-main h2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.batch-progress { display: flex; flex-direction: column; gap: var(--space-2); }
.batch-progress p { margin: 0; }
.batch-progress-label { font-weight: 700; }
.batch-progress progress { max-width: none; height: 8px; appearance: none; -webkit-appearance: none; border: 0; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.batch-progress progress::-webkit-progress-bar { background: var(--surface-2); border-radius: var(--radius-pill); }
.batch-progress progress::-webkit-progress-value { background: var(--brand); border-radius: var(--radius-pill); }
.batch-progress progress::-moz-progress-bar { background: var(--brand); border-radius: var(--radius-pill); }
.batch-main .stat-tiles { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-bottom: 0; }
.batch-actions form { margin: 0; }
.batch-actions button { width: 100%; }
.batch-links { display: flex; flex-wrap: wrap; flex-direction: column; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 800; }
.batch-links a { text-decoration: none; }
.batch-links a:hover { text-decoration: underline; }
.table-items td:nth-child(1) { font-weight: 800; }
.table-items td:nth-child(1) { white-space: nowrap; }

/* Product fields. */
.fields-grid { align-items: start; }
.fields-main { min-width: 0; margin: 0; }
.fields-main .field { gap: var(--space-3); }
.fields-main .card, .fields-status { min-width: 0; }
.fields-main .action-bar { justify-content: flex-start; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--tap); }
.switch-row label { margin: 0; }
.fields-map { border-radius: var(--radius); }
.fields-map-title { margin: 0; padding: var(--space-3) var(--space-4); min-height: 56px; display: flex; align-items: center; font-size: 1.125rem; }
.table-fields td { padding-top: 8px; padding-bottom: 8px; }
.table-fields td select { width: 100%; }
.table-fields th:last-child, .table-fields td.cell-actions { width: 1%; white-space: nowrap; }
.add-row .icon { width: 18px; height: 18px; }
.fields-status .stat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields-status .stat-tiles .stat { padding: var(--space-3); }
.fields-status .stat-tiles .stat-value { font-size: 1.375rem; flex-wrap: wrap; }
.rewrite-button { width: 100%; }
.fields-status h3.section-heading { margin: var(--space-2) 0 0; }

@media (max-width: 1023px) {
  .batch-grid { grid-template-areas: "main" "aside" "items"; }
  .batch-main.is-joined { margin-bottom: calc(-1 * var(--space-5)); border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; }
  .batch-actions { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; padding-top: 0; }
  .batch-links { flex-direction: row; background: transparent; border: 0; padding: 0; }
  .batch-links a { display: inline-flex; align-items: center; min-height: var(--tap); }
}

@media (max-width: 767px) {
  .card.matching-list, .card.batches, .card.batch-items, .card.unpaired { padding: 0; }
  .inline-field, .catalog-bar { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .inline-field select { width: 100%; min-width: 0; }
  .inline-field .field { width: 100%; }
  .inline-field button.small, .search-form button { width: 100%; }
  .card-header .inline-field { margin-left: 0; width: 100%; }
  .card-header .inline-field select { min-width: 0; }
  .search-form { flex-direction: column; align-items: stretch; }
  .search-form .search { flex: 0 0 auto; max-width: none; }
  .notice-link { flex: 1 1 100%; margin-left: 0; padding-left: 32px; display: inline-flex; align-items: center; min-height: var(--tap); }
  .stat-tiles .stat-value { font-size: 1.375rem; }

  /* The lists live inside their white card; each row is a bordered card in it. */
  .matching-list > .card-header, .batches > .card-header, .batch-items > .card-header { padding-bottom: var(--space-2); }
  .matching-list > .toolbar { padding-bottom: var(--space-3); }
  .matching-list > .table-wrap, .batches > .table-wrap, .batch-items > .table-wrap { padding: 0 var(--space-4) var(--space-4); overflow: visible; }
  .matching-list .table-cards tr, .batches .table-cards tr, .batch-items .table-cards tr { box-shadow: none; }
  .matching-list > .pager, .batch-items > .pager { padding: 0 var(--space-4) var(--space-4); }
  .matching-list > .empty, .batch-items > .empty { padding-top: var(--space-4); }

  /* Matching: a product. */
  .table-matching td.cell-title { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .table-matching td.cell-status { grid-column: 2; grid-row: 1; }
  .table-matching td:nth-child(3) { grid-column: 2; grid-row: 2; justify-self: end; text-align: right; font-weight: 800; }
  .table-matching td:nth-child(3)::before { content: "Kód: "; font-weight: 700; }
  .table-matching td:nth-child(4) { grid-row: 3; color: var(--muted); font-size: var(--text-md); }
  .table-matching td:nth-child(4)::before { content: "Zdroj: "; }
  .table-matching td.cell-note { grid-row: 4; font-size: var(--text-md); }
  .table-matching td.cell-actions { grid-row: 5; white-space: normal; display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .table-matching td.cell-actions form, .table-orphans td.cell-actions form { width: 100%; margin: 0; }
  .table-matching td.cell-actions .pin-form { flex-direction: column; align-items: stretch; }
  .table-matching td.cell-actions .pin-form input:not([type="hidden"]) { width: 100%; }
  .table-matching td.cell-actions button, .table-orphans td.cell-actions button { width: 100%; }
  .table-orphans td.cell-actions { display: block; }
  .table-orphans td.cell-title { grid-column: 1 / -1; }
  .table-orphans td.cell-meta { grid-column: 1 / -1; font-size: var(--text-md); }

  /* Matching: the cards without a product, a hairline list. */
  .table-unpaired thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-unpaired, .table-unpaired tbody { display: block; }
  .table-unpaired tr { display: grid; grid-template-columns: 44px max-content minmax(0, 1fr); column-gap: 4px; align-items: center; padding: 6px var(--space-3) 6px 4px; border-bottom: 1px solid var(--line); }
  .table-unpaired tbody tr:last-child { border-bottom: 0; }
  .table-unpaired tbody tr:hover td { background: transparent; }
  .table-unpaired td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .table-unpaired td.cell-pick { grid-column: 1; grid-row: 1 / span 2; display: flex; align-items: center; justify-content: center; width: auto; min-height: var(--tap); }
  .table-unpaired td.cell-pick input { width: 24px; height: 24px; }
  .table-unpaired td.cell-name { grid-column: 2 / -1; grid-row: 1; font-weight: 800; }
  .table-unpaired td:not([class]) { grid-column: 2; grid-row: 2; color: var(--muted); font-size: var(--text-md); }
  .table-unpaired td.cell-storage { grid-column: 3; grid-row: 2; color: var(--muted); font-size: var(--text-md); }
  .table-unpaired td.cell-storage::before { content: "· sklad "; }
  .table-unpaired-ro tr { grid-template-columns: max-content minmax(0, 1fr); padding-left: var(--space-3); }
  .table-unpaired-ro td.cell-name { grid-column: 1 / -1; }
  .table-unpaired-ro td:not([class]) { grid-column: 1; }
  .table-unpaired-ro td.cell-storage { grid-column: 2; }
  .unpaired .card-pad .row { flex-direction: column; align-items: stretch; }
  .unpaired .card-pad .row button { width: 100%; }
  .inset > .pager { padding: var(--space-3); border-top: 1px solid var(--line); }
  .inset > .pager .pager-info { font-size: var(--text-sm); }

  /* Batches: a batch is a card of four lines (title and state, who and when, the counts, the link). */
  .table-cards.table-batches tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--space-2); }
  .table-cards.table-batches td { grid-column: auto; min-width: 0; }
  .table-batches td.cell-title { order: 1; flex: 1 1 0; }
  .table-batches td.cell-status { order: 2; flex: none; align-self: center; }
  .table-cards.table-batches td.cell-break { display: block; flex: 0 0 100%; height: 0; padding: 0; }
  .table-batches td.cell-break:nth-last-child(2) { order: 3; }
  .table-batches td.cell-break:last-child { order: 6; }
  .table-batches td.cell-meta { order: 4; flex: 1 1 0; }
  .table-batches td.cell-time { order: 5; flex: none; color: var(--fg); font-weight: 800; }
  .table-batches td:nth-child(n+5):nth-child(-n+9) { order: 7; flex: none; color: var(--muted); font-size: var(--text-md); }
  .table-batches td:nth-child(5)::before { content: "Založeno "; }
  .table-batches td:nth-child(6)::before { content: "Už existovalo "; }
  .table-batches td:nth-child(7)::before { content: "Neúspěšné "; }
  .table-batches td:nth-child(8)::before { content: "Přeskočeno "; }
  .table-batches td:nth-child(9)::before { content: "Čeká "; }
  .table-batches td:nth-child(n+5):nth-child(-n+8)::after { content: "·"; margin-left: var(--space-2); }
  .table-cards.table-batches td.cell-end { order: 8; flex: none; margin-left: auto; align-self: center; }
  .table-batches td.cell-end a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--accent-text); }

  /* Batch detail. */
  .batch-main .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-links { padding: 0; }
  .table-cards.table-items tr { grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: var(--space-3); }
  .table-items td:nth-child(1) { grid-column: 1; grid-row: 1; font: 800 1rem / 1.35 var(--font); }
  .table-items td.cell-name { grid-column: 1 / -1; grid-row: 2; font-weight: 700; min-width: 0; }
  .table-items td.cell-status { grid-column: 2; grid-row: 1; }
  .table-items td:nth-child(4) { grid-column: 1; grid-row: 3; color: var(--muted); font-size: var(--text-md); }
  .table-items td:nth-child(4)::before { content: "Produkt v Base "; }
  .table-items td:nth-child(6) { grid-column: 2; grid-row: 3; justify-self: end; font-weight: 800; }
  .table-items td:nth-child(6)::before { content: "Pokusy "; }
  .table-items td.cell-note { grid-column: 1 / -1; grid-row: 4; font-size: var(--text-md); min-width: 0; }

  /* Fields: a mapping row is a grey card with two labelled selects and "Odebrat". */
  .fields-map { border: 0; background: transparent; border-radius: 0; overflow: visible; }
  .fields-map-title { display: none; }
  .table-cards.table-fields tr { background: var(--surface-2); box-shadow: none; display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .table-cards.table-fields tr.is-empty { background: transparent; border: 0; padding: 0; }
  .table-cards.table-fields td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 6px; font-weight: 700; color: var(--fg); }
  .table-cards.table-fields td.cell-actions { white-space: normal; display: flex; justify-content: center; width: auto; margin: 0; }
  .table-cards.table-fields td.cell-actions:empty { display: none; }
  .table-fields td.cell-actions button { width: 100%; }
  .add-row { width: 100%; }
  .fields-status .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields-main .action-bar { margin-bottom: calc(-1 * var(--space-4)); }
}

/* ---------- Matching: search, state and "Filtrovat" in the products card ---------- */
.matching-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); padding: 0 var(--space-4) var(--space-4); margin: 0; }
.matching-filter .search { flex: 1 1 320px; max-width: 480px; }
.matching-filter .field { margin: 0; flex: 0 1 240px; }
.matching-filter .field select { width: 100%; }
@media (max-width: 767px) {
  .matching-filter { padding: 0 0 var(--space-3); flex-direction: column; align-items: stretch; }
  .matching-filter .search, .matching-filter .field { flex: 1 1 auto; max-width: none; }
  .matching-filter button { width: 100%; }
}

/* ==========================================================================================================================
   Console, final design (konzole-*, stage 3): the portal shell with the operator colour (.area-operator maps the accent to it).
   ========================================================================================================================== */

/* ---------- Shell: sidebar ---------- */
.area-operator .brand { flex-direction: column; align-items: flex-start; gap: 4px; }
.brand-area { color: var(--operator); font: 800 var(--text-xs) / 1.2 var(--font); letter-spacing: 0.2px; }
.area-operator .nav .nav-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; margin-left: auto; padding: 0 7px;
  border-radius: var(--radius-pill); background: var(--operator-soft); color: var(--operator); font-size: var(--text-xs); font-weight: 800;
}
.area-operator .nav-bottom { margin-top: auto; padding-top: 0; border-top: 0; }
.area-operator .nav-bottom a.sidebar-user {
  min-height: 60px; margin-top: var(--space-2); padding: var(--space-3) 10px 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent;
}
.area-operator .nav-bottom a.sidebar-user:hover { background: transparent; }
.area-operator .nav-bottom a.sidebar-user[aria-current="page"] .sidebar-user-name { color: var(--operator); }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { color: var(--fg); font-weight: 800; font-size: var(--text-md); overflow-wrap: anywhere; }
.sidebar-user .sub { font-size: var(--text-xs); font-weight: 500; }

/* ---------- Shell: top bar (breadcrumb, search, host, environment, sign out) ---------- */
.area-operator .topbar .breadcrumb { flex: 1 1 auto; margin-right: 0; }
.topbar-search.search { flex: 0 1 380px; min-width: 220px; }
.topbar-search.search input[type="search"]:not([type="hidden"]) { min-height: 40px; background: var(--surface); }
.area-operator .topbar-actions { gap: var(--space-3); margin-left: 0; }
.topbar-host { font-family: var(--mono); font-size: var(--text-sm); color: var(--muted); white-space: nowrap; }
.env-badge {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 6px;
  font-size: var(--text-xs); font-weight: 800; letter-spacing: 0.8px; white-space: nowrap;
}
.env-bad { background: var(--bad-soft); color: var(--bad); }
.env-warn { background: var(--warn-soft); color: var(--warn); }
.env-muted, .env-ok, .env-info { background: var(--surface-2); color: var(--muted); }
.topbar-logout { margin: 0; }
.topbar-avatar { display: none; }
.topbar-avatar:hover { text-decoration: none; }

/* ---------- Page head: badges under the subtitle ---------- */
.page-badges { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }

/* ---------- Více (phone): the other places, then the account ---------- */
.more-card:not(.card-flush) { padding: var(--space-4); }
.list-row-sub { display: block; margin-top: 2px; color: var(--muted); font-size: var(--text-md); font-weight: 500; }

@media (max-width: 1023px) {
  .area-operator .topbar { gap: var(--space-2); }
  .area-operator .topbar-brand { min-height: var(--tap); align-items: center; }
  .area-operator .topbar-search, .topbar-host, .topbar-logout { display: none; }
  .area-operator .topbar-actions { margin-left: auto; }
  .topbar-avatar { display: inline-flex; width: 44px; height: 44px; }
}
a.avatar, a.avatar:hover { text-decoration: none; }


/* ---------- Console a (stage 3) ---------- */
/* Overview (/admin), tenant list, new tenant, approvals. Designs: konzole-prehled, -tenanti, -novy-tenant, -schvalovani. */

/* Overview: six stat tiles, the dashboard grid, bar rows, meters */
.console-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.console-tile { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.console-tile-value { display: flex; align-items: center; gap: var(--space-2); font: 800 1.5rem / 1.2 var(--font-heading); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.console-tile-value.has-dot::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dot-tone, var(--line-strong)); }
.console-tile-value.dot-warn { --dot-tone: var(--warn); }
.console-tile-value.dot-bad { --dot-tone: var(--bad); }
.console-tile-text { color: var(--muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
@media (min-width: 768px) {
  .console-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
  .console-tile-value { font-size: 1.75rem; }
}
.console-dash { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-4); align-items: start; }
.console-dash > .stack { gap: var(--space-4); min-width: 0; }
@media (max-width: 1023px) { .console-dash { grid-template-columns: minmax(0, 1fr); } }
.console-dash .card > h2, .console-dash .card-header h2 { font: 700 1.125rem / 1.3 var(--font-heading); }
.console-dash .card > h2 { margin-bottom: var(--space-3); }
.console-attention .list-row { min-height: 64px; }
.console-attention .attention-title { display: block; font-weight: 700; }
.console-attention .sub { font-weight: 400; }
.console-attention-action { white-space: nowrap; font-size: var(--text-md); }
.console-load { display: flex; flex-direction: column; gap: var(--space-4); }
.console-load-head { display: flex; justify-content: space-between; gap: var(--space-3); margin-bottom: 4px; font-weight: 700; }
.console-load .chart { display: block; width: 100%; height: auto; }
.console-load .chart-bar, .console-dash .chart-months .chart-bar { fill: color-mix(in srgb, var(--operator) 18%, var(--surface)); opacity: 1; }
.console-load .chart-bar:last-child, .console-dash .chart-months .chart-bar.is-current { fill: var(--operator); }
.console-dash .chart-months { display: block; width: 100%; height: auto; margin-bottom: var(--space-3); }
.console-dash .chart-months .chart-label { font-family: var(--font); font-size: 12px; fill: var(--muted); }
.console-meters { display: flex; flex-direction: column; gap: 14px; margin-bottom: var(--space-3); }
.console-meter-head { display: flex; justify-content: space-between; gap: var(--space-3); margin-bottom: 6px; font-weight: 700; }
.console-meter-head .num strong { font-weight: 700; }
.console-meter progress { display: block; width: 100%; height: 8px; border: 0; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; -webkit-appearance: none; appearance: none; }
.console-meter progress::-webkit-progress-bar { background: var(--surface-2); border-radius: var(--radius-pill); }
.console-meter progress::-webkit-progress-value { background: var(--operator); border-radius: var(--radius-pill); }
.console-meter progress::-moz-progress-bar { background: var(--operator); border-radius: var(--radius-pill); }
.console-health { margin-top: var(--space-3); padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.console-health dt { font-weight: 400; }
.console-alerts-card > .card-header { padding-bottom: 0; }
.console-alerts-card > .card-header h2 { font: 700 1.125rem / 1.3 var(--font-heading); }
.console-alerts-card .table-filter { border-bottom: 0; }
.console-alerts-card .table-filter select { min-width: 240px; min-height: 40px; }
.console-alerts-card .table-wrap { margin: 0 var(--space-4) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.console-alerts-table tbody tr:last-child td { border-bottom: 0; }
.console-alerts-table .cell-link { color: var(--fg); text-decoration: none; font-weight: 800; }
.console-alerts-table td.cell-time, .console-alerts-table td.cell-actions { white-space: nowrap; }
.console-alerts-card #alerts-table > .empty { padding-top: var(--space-5); }

/* Tenant list: a filter card, then the table (cards on a phone) */
.console-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: 16px 18px; }
.console-filter .search { flex: 1 1 200px; min-width: 200px; max-width: none; }
.console-filter select { flex: none; width: 170px; min-height: 40px; }
.console-filter select[name="sort"] { width: 180px; }
.console-filter .choice { flex: none; margin: 0; align-items: center; white-space: nowrap; }
.console-filter button { flex: none; }
.console-tenants > .card-header h2 { font: 700 1.125rem / 1.3 var(--font-heading); }
.console-tenants th a { color: inherit; text-decoration: none; }
.console-tenants th a:hover { text-decoration: underline; }
.console-tenants .cell-link { color: var(--fg); }
@media (min-width: 768px) {
  .console-tenants td { padding-inline: 10px; }
  .console-tenants th:first-child, .console-tenants td:first-child { padding-left: var(--space-4); }
  .console-tenants th:last-child, .console-tenants td:last-child { padding-right: var(--space-4); }
}
.console-tenants td.cell-status .sub { max-width: 12rem; }
.console-tenants td.cell-agent .sub { font-weight: 400; }
.console-tenants th { white-space: normal; }
.console-tenants td.cell-title { min-width: 170px; }
.console-tenants td.cell-agent { white-space: nowrap; }
.console-tenants tbody tr:last-child td { border-bottom: 0; }

/* New tenant: stepper card, forms up to 720 px */
.console-new { display: flex; flex-direction: column; gap: var(--space-4); }
.console-new > * { min-width: 0; }
.console-form { width: 100%; max-width: 720px; }
.console-form.stack { gap: var(--space-4); }
.console-form .field { margin-bottom: 0; }
.console-form:not(.stack) > h2 { margin-bottom: var(--space-3); }
.console-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); align-items: start; }
.console-form pre { overflow-x: auto; }
.console-stepper .steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); margin: 0; }
.console-stepper .step { flex-direction: column; justify-content: flex-start; gap: var(--space-2); text-align: center; font-size: var(--text-sm); color: var(--muted); }
.console-stepper .step-link { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); color: inherit; text-decoration: none; }
.console-stepper .step-number { width: 32px; height: 32px; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--fg); font-weight: 800; }
.console-stepper .step.is-current { color: var(--fg); font-weight: 800; }
.console-stepper .step.is-current .step-number { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.console-stepper .step.is-done { color: var(--fg); }
.console-stepper .step.is-done .step-number { background: var(--ok-soft); border-color: var(--ok); color: var(--ok-text); }
.console-stepper .step-caption { margin: var(--space-3) 0 0; font: 800 1rem / 1.3 var(--font); }
.console-next-steps li { display: flex; flex-direction: column; gap: 2px; padding: 10px var(--space-4); }
.console-next-steps .sub { font-weight: 400; }
.console-form .list-card { margin-top: 0; }
.console-flows li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); }
.console-flows .list-row-label { flex: 1 1 160px; }
.console-flows form { margin: 0; }

/* Approvals: the queue card and the detail card */
.console-approvals { grid-template-columns: 320px minmax(0, 1fr); gap: var(--space-4); }
@media (max-width: 1023px) { .console-approvals { grid-template-columns: minmax(0, 1fr); } }
.console-approvals .approval-queue { gap: var(--space-2); }
.console-approvals .section-label { margin: 0; color: var(--muted); font: 800 var(--text-xs) / 1.4 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }
.console-approvals .approval-queue .section-label { margin-bottom: var(--space-1); }
.console-approvals .approval-item { display: flex; flex-direction: column; gap: 2px; min-height: var(--tap); padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: none; color: var(--fg); }
.console-approvals .approval-item, .console-approvals .approval-item:hover { text-decoration: none; }
.console-approvals .approval-item[aria-current="true"] { background: var(--operator-soft); border-color: var(--operator); box-shadow: 0 0 0 1px var(--operator); }
.console-approvals .approval-detail { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.console-approvals .approval-detail > .card-header { margin: 0; }
.console-approvals .approval-detail > .card-header h2 { font: 700 1.125rem / 1.3 var(--font-heading); }
.console-approvals .approval-detail > p, .console-approvals .approval-detail > h3 { margin: 0; }
.console-approvals .approval-detail > h3.section-label { margin-top: var(--space-2); }
.console-facts { grid-template-columns: 210px minmax(0, 1fr); padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.console-facts dd { text-align: left; }
.console-facts dt { font-weight: 400; }
.setup-summary .setup-steps { gap: 0; }
.setup-summary .setup-steps li { display: flex; flex-direction: row; align-items: center; gap: var(--space-3); padding: 12px var(--space-4); border-left: 0; }
.setup-summary .setup-steps li > .icon { color: var(--muted); }
.setup-summary .setup-steps li.ok > .icon { color: var(--ok); }
.setup-summary .setup-steps li.bad > .icon { color: var(--bad); }
.setup-step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setup-step-text .muted { font-size: var(--text-sm); }
.console-price-form { display: flex; align-items: flex-end; gap: var(--space-2); }
.console-price-form .field { flex: 1; margin: 0; min-width: 0; }
.console-price-form select { width: 100%; }
.console-price-form button { flex: none; }
.console-approvals .approval-actions { gap: var(--space-4); padding: 0; background: none; }
.console-approvals .approval-actions > p { margin: 0; }
.console-approvals .approval-lead { font-weight: 700; }
.console-approvals .approval-actions form { margin: 0; }
.console-approvals .approval-actions .field { margin: 0; }
.console-flow-notice .flow-warning { padding: 0; background: transparent; border-radius: 0; }
.console-flow-notice .notice-text > p { margin-top: var(--space-1); }

/* Phone */
@media (max-width: 767px) {
  .console-alerts-card.card { padding: var(--space-4); }
  .console-alerts-card .table-filter { flex-direction: column; align-items: stretch; padding: var(--space-3) 0; }
  .console-alerts-card .table-filter select, .console-alerts-card .table-filter button { width: 100%; min-height: var(--field); }
  .console-alerts-card .table-wrap { margin: 0; border: 0; border-radius: 0; }
  .console-alerts-table td.cell-title { grid-column: 1; grid-row: 1; }
  .console-alerts-table td.cell-status { grid-column: 2; grid-row: 1; }
  .console-alerts-table td.cell-kindref { grid-column: 1; grid-row: 2; }
  .console-alerts-table td.cell-time { grid-column: 2; grid-row: 2; justify-self: end; color: var(--fg); font-weight: 800; }
  .console-alerts-table td.cell-note { grid-column: 1 / -1; grid-row: 3; order: 0; }
  .console-alerts-table td.cell-actions { grid-column: 1 / -1; grid-row: 4; }
  .console-alerts-table td.cell-actions form, .console-alerts-table td.cell-actions form > button { width: 100%; }

  .console-filter { flex-direction: column; align-items: stretch; gap: var(--space-3); padding: 0; background: none; border: 0; box-shadow: none; }
  .console-filter .search { flex: none; }
  .console-tenants > .card-header h2 { font-size: 1rem; font-weight: 600; }
  .console-tenants td.cell-title { grid-column: 1; grid-row: 1; }
  .console-tenants td.cell-status { grid-column: 2; grid-row: 1; }
  .console-tenants td.cell-meta:not(.cell-figures) { grid-column: 1; grid-row: 2; }
  .console-tenants td.cell-agent { grid-column: 2; grid-row: 2; font-weight: 700; color: var(--fg); }
  .console-tenants td.cell-agent .dot, .console-tenants td.cell-agent .sub { display: none; }
  .console-tenants td.cell-figures { grid-column: 1; grid-row: 3; }
  .console-tenants td.cell-time { grid-column: 2; grid-row: 3; justify-self: end; }
  .console-tenants td.cell-actions { grid-column: 1 / -1; grid-row: 4; }
  .console-tenants td.cell-actions .btn { width: 100%; }

  .console-stepper .step-label { display: none; }
  .console-stepper .step-link { min-width: var(--tap); min-height: var(--tap); justify-content: center; }
  .console-stepper .step-number { width: 36px; height: 36px; }
  .console-form-row { grid-template-columns: minmax(0, 1fr); }
  .console-form .form-actions > button, .console-form .form-actions > .btn { width: 100%; }
  .console-flows li > form, .console-flows li > form > button { width: 100%; }

  .console-facts { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }
  .console-facts dd { text-align: right; }
  .console-price-form { flex-direction: column; align-items: stretch; }
  .console-approvals .approval-actions button { width: 100%; }
  .console-approvals #approve-form { display: none; }
}
/* ---------- Console b (stage 3) ---------- */
/* Tenant detail, Moduly a podmínky, impersonation. Scoped by the classes the pages add (ta-*, tenant-*, table-*). */

/* Head: actions. Desktop: one row on the right (view, export, pause, end). Phone: view-as above the badges, pause and end side by side, export last. */
.page-actions .ta-view { order: 0; }
.page-actions .ta-export { order: 1; }
.page-actions .ta-main { order: 2; }
.page-actions .ta-cancel { order: 3; }
.page-actions .ta-view .icon, .page-actions .ta-export .icon { width: 18px; height: 18px; }
.page-actions .ta-main:is(button, .btn), .page-actions .ta-main button { white-space: nowrap; }
.page-actions .ta-cancel button { white-space: nowrap; }
.tenant-cards .phone-price { display: none; }
.tenant-cards .phone-prefix { display: none; }

@media (max-width: 767px) {
  .page-head:has(.ta-view) { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0 var(--space-3); }
  .page-head:has(.ta-view) .page-title, .page-head:has(.ta-view) .page-actions { display: contents; }
  .page-head:has(.ta-view) h1, .page-head:has(.ta-view) .page-subtitle { flex: 1 1 100%; order: 0; }
  .page-head:has(.ta-view) .page-subtitle { order: 1; }
  .page-head:has(.ta-view) .ta-view { order: 2; flex: 1 1 100%; margin-top: var(--space-3); }
  .page-head:has(.ta-view) .page-badges { order: 3; flex: 1 1 100%; margin-top: var(--space-3); }
  .page-head:has(.ta-view) .ta-main, .page-head:has(.ta-view) .ta-cancel { order: 4; flex: 1 1 calc(50% - 6px); margin-top: var(--space-3); }
  .page-head:has(.ta-view) .ta-export { order: 5; flex: 1 1 100%; margin-top: var(--space-3); }
  .page-head:has(.ta-view) :is(.ta-view, .ta-main, .ta-cancel, .ta-export) > button, .page-head:has(.ta-view) a.ta-main { width: 100%; }
}

/* Tabs: an underline row; on a phone it scrolls sideways inside itself. */
.tenant-tabs { flex-wrap: nowrap; gap: 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line-strong); }
.tenant-tabs::-webkit-scrollbar { display: none; }
.tenant-tabs a {
  flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-3); white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 600; font-size: 0.9375rem;
}
.tenant-tabs a[aria-current="page"] { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 800; }

/* Overview: stat tiles */
.tenant-tiles { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: var(--space-3); }
.tenant-tiles .tile { gap: 2px; padding: var(--space-3) var(--space-4); background: var(--surface); }
.tenant-tiles .tile-label { color: var(--muted); font: 800 var(--text-xs) / 1.4 var(--font); letter-spacing: 0.6px; text-transform: uppercase; }
.tenant-tiles .tile-value { font: 800 1.75rem / 1.25 var(--font-heading); }
.tenant-tiles .tile-value.ok { color: var(--ok-text); }
.tenant-tiles .tile-note { margin-top: 2px; }
.tenant-tiles .tile-note .badge { max-width: 100%; white-space: normal; }
.tenant-tiles .tile-note a { color: var(--muted); }
.tenant-actions { gap: var(--space-2); }
.tenant-actions form { margin: 0; }
.tenant-actions .icon { width: 18px; height: 18px; }
.tenant-section-title { margin: var(--space-3) 0 0; font: 800 1.5rem / 1.3 var(--font-heading); }

/* Boxed key/value list inside a card */
.kv-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 var(--space-4); margin: 0; background: var(--surface); }
.kv-box code { font: var(--text-sm) / 1.5 var(--mono); background: none; padding: 0; }
.card-flush > .kv-box { margin: 0 var(--space-4) var(--space-4); }
.card > .kv-box + form { margin-top: var(--space-3); }
.card > p.muted + .kv-box { margin-top: var(--space-3); }
.card > .kv-box { margin-bottom: var(--space-3); }

/* Forms inside the overview cards */
.secret-form .field { margin: 0; }
.cfg-form .field-label { font-weight: 800; }
.cfg-form textarea { min-height: 200px; }
.export-links > form, .export-links-intro { padding-inline: var(--space-4); }
.export-links > .table-wrap + p, .export-links > p.muted { padding: 0 var(--space-4) var(--space-4); }
.export-links .export-links-intro { padding-bottom: var(--space-3); }

/* Tables that become cards on a phone: tenant detail and modules */
.tenant-cards th.num, .tenant-cards td.num { text-align: left; }
.tenant-cards .cell-title .sub { display: block; }
@media (min-width: 768px) {
  .tenant-cards td.cell-error:empty::before { content: "—"; color: var(--muted); }
  .tenant-cards td.cell-actions { white-space: normal; }
  .tenant-inner { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 var(--space-4) var(--space-4); }
  .tenant-inner table tr:last-child td { border-bottom: 0; }
  .card-flush > .table-wrap:last-child { margin-bottom: 0; }
  .matching-summary { margin: 0 0 var(--space-3); }
}
.matching-summary { padding: 0 var(--space-4); }
.card-flush > h3, .card-flush > .card-header h3 { font-size: 1rem; }
.card-flush > .card-header + .card-header { min-height: 0; padding-top: 0; }

@media (max-width: 767px) {
  .card-flush > .table-wrap { padding: 0 var(--space-4) var(--space-4); overflow: visible; }
  .tenant-cards tr { box-shadow: none; }
  .tenant-cards td[data-label] { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); text-align: right; font-weight: 700; }
  .tenant-cards td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-weight: 400; text-align: left; }
  .tenant-cards td[data-label].cell-amount { font-weight: 400; }
  .tenant-cards td.cell-title { font-size: 1rem; }
  .tenant-cards .cell-hide-phone { display: none !important; }
  .tenant-cards .phone-price { display: inline; font-weight: 400; color: var(--muted); }
  .tenant-cards .cell-amount .phone-price { color: inherit; }
  .tenant-cards .phone-prefix { display: inline; }
  .tenant-cards td.cell-error { color: var(--bad); font-size: var(--text-md); }
  .tenant-cards td.cell-error.muted { color: var(--muted); }
  .tenant-cards td.cell-invoice { flex-wrap: wrap; }
  .tenant-cards td.cell-invoice > form { flex: 1 1 100%; margin-top: var(--space-2); }
  .tenant-cards td.cell-invoice > form button { width: 100%; }
  .tenant-cards td.cell-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .tenant-cards td.cell-actions > form { flex: 1 1 100%; margin: 0; }
  .table-agents td.cell-actions > form { flex: 1 1 0; }
  .tenant-cards td.cell-actions button, .tenant-cards td.cell-actions .btn { width: 100%; }
  .tenant-cards td.cell-actions:not(:has(*)) { display: none; }
  .tenant-cards tr.row-total { display: flex; justify-content: space-between; padding: 0 var(--space-1); background: none; border: 0; }
  .tenant-cards tr.row-total th, .tenant-cards tr.row-total td { display: block; padding: 0; background: none; border: 0; color: var(--fg); font-size: 1rem; }
  .tenant-cards td.cell-meta .phone-price { display: inline; }
  .tenant-cards td.cell-input { display: block; }
  .tenant-cards td.cell-input::before { content: none; }
  .tenant-cards td.cell-input > input { margin-top: var(--space-1); }
  .tenant-cards td.mobile-only.agent-line, .tenant-cards td.mobile-only.user-line { display: flex; }
  .table-users td.user-role { margin-top: var(--space-1); }
  .table-users td.user-role:not(:has(form)) { display: none; }
  .table-users td.cell-actions > form { flex: 1 1 100%; }
  .table-agents .cell-erp { color: var(--muted); }
  .table-agents .cell-erp .sub { display: inline; }
  .request-actions, .request-actions form { flex-direction: column; align-items: stretch; width: 100%; }
}
.user-role form { display: flex; align-items: center; gap: var(--space-2); }
.user-role select { flex: 1 1 auto; min-width: 8rem; }
.table-users .cell-actions { display: table-cell; }
.request-actions form { display: flex; gap: var(--space-2); align-items: center; }
@media (min-width: 768px) { .table-users td.cell-actions { white-space: normal; } .table-users td.cell-actions > form { margin: 2px 6px 2px 0; } }

/* Průvodce tab: the partial _SetupSummary styled from outside */
.tenant-wizard .setup-summary { gap: var(--space-3); }
.tenant-wizard .setup-summary h4 { margin: var(--space-3) 0 0; font: 800 1.25rem / 1.3 var(--font-heading); }
.tenant-wizard .setup-checks { gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.tenant-wizard .setup-checks > li { border-left: 0; border-top: 1px solid var(--line); padding: 10px var(--space-4); }
.tenant-wizard .setup-checks > li:first-child { border-top: 0; }
.tenant-wizard .setup-summary > p { margin: 0; }

/* Agents tab */
.agent-pairing .pairing-code { margin: 0; font-weight: 700; }
.agent-pairing .pairing-code code { font: inherit; background: none; padding: 0; }
.card-flush > .agent-token { padding: 0 var(--space-4) var(--space-3); }

/* Usage tab */
.usage-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }
.usage-stats .stat { background: var(--surface); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.usage-stats .stat-value { font: 800 1.5rem / 1.3 var(--font-heading); }
.usage-stats .stat-bad .stat-value::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: var(--space-2); border-radius: 50%; background: var(--bad); vertical-align: middle; }
.usage-trend-card .usage-trend { display: block; margin: var(--space-3) 0; }
.usage-trend-card .chart { width: 100%; max-height: 96px; }
.usage-trend-card .chart-bar { opacity: 1; fill: var(--accent); }
.usage-trend-card .usage-limit { flex-direction: column; align-items: flex-start; gap: var(--space-2); margin: 0; }
.usage-trend-card .usage-progress { max-width: 700px; accent-color: var(--ok); }
.tariff-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-3); }
.tariff-fields .field { margin: 0; }
@media (max-width: 767px) {
  .usage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tariff-fields { grid-template-columns: minmax(0, 1fr); }
  .tariff-form > div > button, .invite-form > button, .secret-form button, .cfg-form button, .onetime-form > button, .terms-form button { width: 100%; }
}

/* Users tab */
.invite-form { display: grid; grid-template-columns: minmax(0, 1fr) 220px auto; gap: var(--space-3); align-items: end; }
.invite-form .field { margin: 0; }
.users-card .notice { margin: 0; }
@media (max-width: 767px) { .invite-form { grid-template-columns: minmax(0, 1fr); } }

/* Moduly a podmínky */
.month-picker { padding: 0 var(--space-4) var(--space-3); }
.month-picker .field { margin: 0; }
.month-picker input[type="month"] { width: auto; min-width: 11rem; }
.charges-note { margin: 0; padding: var(--space-3) var(--space-4) var(--space-4); }
.terms-grid { display: grid; gap: var(--space-3); }
.terms-grid .field { margin: 0; font-weight: 700; }
.terms-grid .field input, .terms-grid .field select { font-weight: 400; width: 100%; margin-top: 6px; }
.terms-top { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.terms-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.terms-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card > form .field:not(.terms-grid .field) input[name="reason"] { width: 100%; }
.terms-prices { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.terms-prices table tr:last-child td { border-bottom: 0; }
.terms-prices td.cell-input input { min-width: 0; width: 100%; max-width: 180px; }
.terms-note { margin: 0; font-size: var(--text-sm); }
.onetime-form { display: grid; grid-template-columns: 160px minmax(0, 1fr) 200px auto; gap: var(--space-3); align-items: end; padding: var(--space-3) var(--space-4) var(--space-4); }
.onetime-form .field { margin: 0; }
#charge-currency-hint { padding: 0 var(--space-4) var(--space-4); margin: 0; }
@media (max-width: 767px) {
  .terms-top, .terms-3, .terms-2, .onetime-form { grid-template-columns: minmax(0, 1fr); }
  .terms-prices { border: 0; }
  .card-flush > .month-picker { padding-bottom: var(--space-3); }
}
@media (max-width: 767px) {
  .tenant-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tenant-tiles .tile-agent { grid-column: 1 / -1; }
  .tenant-actions { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .tenant-actions form, .tenant-actions button { width: 100%; }
}
.usage-trend-card .usage-progress { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-2); color: var(--ok); }
.usage-trend-card .usage-progress::-webkit-progress-bar { background: var(--surface-2); }
.usage-trend-card .usage-progress::-webkit-progress-value { background: var(--ok); border-radius: var(--radius-pill); }
.usage-trend-card .usage-progress::-moz-progress-bar { background: var(--ok); border-radius: var(--radius-pill); }
main:has(.tenant-tabs) .card-header > a { color: var(--accent-text); font-weight: 800; text-decoration: none; }
main:has(.tenant-tabs) .card-header > a:hover { text-decoration: underline; }
main:has(.tenant-tabs) .card > h2:first-child:not(:last-child) { margin-bottom: var(--space-3); }
main:has(.tenant-tabs) .card-flush > p:last-child { padding-bottom: var(--space-4); }
.month-picker input[type="month"]:not([type="hidden"]) { width: auto; min-width: 11rem; }
.month-picker .row { flex-wrap: nowrap; }
.tenant-cards .cell-title a { color: var(--accent-text); font-weight: 800; text-decoration: none; }
.tenant-cards .cell-title a:hover { text-decoration: underline; }
@media (max-width: 767px) { .table-statements td.cell-end { max-width: 12rem; text-align: right; } }
@media (min-width: 768px) { .table-users td.cell-actions { white-space: nowrap; } }
.exit-card { max-width: 560px; }
@media (max-width: 767px) { .exit-card button { width: 100%; } }
.exit-card button { background: var(--operator); border-color: var(--operator); color: var(--on-operator); }
/* ---------- Console c (stage 3) ---------- */
/* Usage, Vyúčtování (list, detail, settings), Ceník. */

/* Shared bits: a note under a table inside a card, and table-cards that sit INSIDE a card on a phone. */
.card-note { margin: 0; padding: var(--space-3) var(--space-4); }
.console-usage-total { margin-top: var(--space-3); }
.console-usage-total h2 { margin-bottom: var(--space-2); }
.console-usage-total .kv-list { padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); }

/* Usage: 15 metrics are too many for one screen, the table scrolls inside its card; labels may wrap. */
.table-usage th { white-space: normal; vertical-align: bottom; line-height: 1.25; min-width: 86px; }
.table-usage th:first-child { min-width: 200px; }
.table-usage td.cell-title a { font-weight: 700; color: var(--fg); text-decoration: none; }
.table-usage tfoot th { background: transparent; color: var(--fg); font-size: var(--text-md); font-weight: 800; }

/* Billing list: actions, tiles, statements. */
.period-form { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.console-billing-stats { margin-bottom: var(--space-4); }
.status-flow { margin: var(--space-3) 0 var(--space-4); }
.table-statements td.cell-select { width: 1%; padding-right: 0; }
.select-label { display: inline-flex; align-items: center; gap: var(--space-3); margin: 0; min-height: var(--tap); font-weight: 700; }
.table-statements .warning-line { display: block; }
.approve-row { margin: 0; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); }
.table-invoice-list td.cell-title a { font-weight: 800; text-decoration: none; }
.check-payments { margin: 0; padding: 0 var(--space-4) var(--space-4); }
.check-payments button { width: 100%; }

/* Statement detail. */
.console-statement { display: grid; gap: var(--space-4); }
.console-statement > .card { margin: 0; }
.console-statement .inset-pad { padding: 0 var(--space-4); }
.console-statement .kv-list dd { min-width: 0; }
.console-statement .kv-list dd code { overflow-wrap: anywhere; }
.cs-state h2, .cs-profile h2, .cs-history h2, .cs-side h2 { margin-bottom: var(--space-3); }
.table-lines td.line-amount { font-variant-numeric: tabular-nums; }
.table-lines tr.line-total th { background: transparent; color: var(--fg); height: auto; padding: 14px var(--space-4); font-size: var(--text-md); font-weight: 800; }
.adjust-form { display: grid; grid-template-columns: minmax(0, 1fr) 190px auto; gap: var(--space-3); align-items: end; padding: var(--space-3) var(--space-4) var(--space-4); margin: 0; }
.adjust-form .field, .void-form .field { margin: 0; }
.adjust-form input, .void-form input { width: 100%; max-width: none; }
.void-form { display: flex; flex-direction: column; gap: var(--space-3); align-items: flex-start; margin: 0; }
.void-form .field { width: 100%; }
.profile-edit { margin-top: var(--space-3); }
.profile-edit > summary { display: flex; align-items: center; min-height: var(--tap); cursor: pointer; color: var(--accent-text); font-weight: 700; }
.profile-edit > form { margin-top: var(--space-3); }

/* Billing settings. */
.console-settings .provider-form fieldset:not(.x) > legend,
.console-settings fieldset.field:not(.x) > legend { padding: 0; margin: 0 0 var(--space-2); color: var(--muted); font: 800 var(--text-xs) / 1.3 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }
.console-settings .provider-form { gap: var(--space-4); }
.console-settings .provider-form fieldset:not(.field) { gap: var(--space-3); }
.console-settings .choice { align-items: center; min-height: 52px; gap: var(--space-3); margin: 0; }
.console-settings .choice input { margin: 0; }
.console-settings .field { margin: 0; }
.console-settings .field input:not([type="checkbox"]):not([type="radio"]), .console-settings .field select { width: 100%; max-width: none; }
.console-settings .form-grid { gap: var(--space-4); }
.console-settings .form-grid > .field { margin: 0; }
.console-settings .notice { margin: 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 52px; margin: 0; font-weight: 700; color: var(--fg); }
.switch-row input.switch { flex: none; }

/* Ceník. */
.pricing-new { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.pricing-new .field { display: contents; }
.pricing-new select { width: auto; min-width: 120px; }
.price-legend { margin: 0; color: var(--muted); font: 800 var(--text-xs) / 1.3 var(--font); letter-spacing: 0.8px; text-transform: uppercase; }
.pricing-draft { display: grid; gap: var(--space-4); }
.pricing-draft > .card { margin: 0; }
.pricing-draft .field { margin: 0; }
.pricing-draft .field input, .pricing-draft .field select { width: 100%; max-width: none; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
.table-fees td { padding: 6px var(--space-3); }
.table-fees td.fee-name { font-weight: 800; }
.table-fees td.fee-price input { min-width: 8rem; }
.approval-check { display: inline-flex; align-items: center; gap: var(--space-3); margin: 0; font-weight: 400; }
.table-fees td.fee-approval { width: 1%; text-align: center; }
.table-erp-edit td input { width: 100%; min-width: 6rem; }
.table-erp-edit td.erp-name { font-weight: 800; }
.stat-tiles.console-pricing-stats { margin-bottom: var(--space-4); }
.table-price-modules td.cell-note { font-size: var(--text-sm); }
.form-actions .danger { margin-left: auto; }

@media (min-width: 768px) {
  .console-billing-stats.stat-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
  .console-pricing-stats.stat-tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); }
  .console-statement .kv-list { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }
  .console-statement .kv-list dd { text-align: left; }
  .console-statement .kv-list dt { padding-right: var(--space-3); }
  .console-settings { max-width: 720px; }
  .console-settings .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-lines td.line-amount, .table-lines th.num { text-align: left; }
  .table-statements td.cell-select input { margin: 0; }
}

@media (min-width: 1024px) {
  .console-statement { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .cs-left, .cs-right { display: grid; gap: var(--space-4); min-width: 0; }
  .cs-right { grid-column: 2; grid-row: 1; }
  .cs-left { grid-column: 1; grid-row: 1; }
  .pricing-draft { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
  /* The title stays on one line (as drawn); the actions wrap under it, to the right, when they do not fit beside it. */
  .page-head:has(.period-form, .pricing-new) > .page-title { flex: 1 1 26rem; min-width: 0; }
  .page-head:has(.period-form) .page-actions { flex: 0 1 auto; justify-content: flex-end; margin-left: auto; }
}

@media (max-width: 767px) {
  /* Usage: header card, tenant cards, total card. */
  .console-usage .usage-head { margin-bottom: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
  .console-usage .usage-head .card-header { min-height: 0; margin: 0 0 var(--space-3); padding: 0; }
  .console-usage .usage-head .table-filter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--space-3); padding: 0; border: 0; align-items: center; }
  .console-usage .usage-head .table-filter label { grid-column: 1 / -1; font-weight: 700; }
  .console-usage .usage-head .table-filter input, .console-usage .usage-head .table-filter button { min-height: var(--field); }
  .table-usage tfoot { display: none; }
  .table-usage td.usage-summary { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
  .usage-line { display: flex; justify-content: space-between; gap: var(--space-3); color: var(--muted); }
  .usage-line strong { color: var(--fg); }
  .table-usage td.cell-status { white-space: nowrap; }

  /* Billing list. */
  .page-actions:has(.period-form) > * { flex: 1 1 100%; }
  .page-actions:has(.period-form) .period-form { order: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--space-3); }
  .page-actions:has(.period-form) .period-label { grid-column: 1 / -1; font-weight: 700; }
  .page-actions:has(.period-form) .period-form input, .page-actions:has(.period-form) .period-form button { min-height: var(--field); }
  .page-actions:has(.period-form) .act-issue { order: 1; }
  .page-actions:has(.period-form) .act-recompute { order: 2; }
  .page-actions:has(.period-form) .act-settings { order: 3; }
  .page-actions:has(.period-form) .act-recompute button, .page-actions:has(.period-form) .act-issue button { width: 100%; }
  .console-billing > .card-header { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); }
  .table-statements td.cell-select { order: 9; grid-column: 1 / -1; width: auto; padding: 0; }
  .table-statements td.cell-select:empty { display: none; }
  .table-statements td.cell-select .select-label { position: relative; z-index: 1; }
  .table-statements .warning-line { grid-column: 1 / -1; }
  .approve-row { flex-direction: column; align-items: stretch; padding: var(--space-3) 0 0; border: 0; }
  .approve-row button { width: 100%; }
  :is(.console-billing-invoices, .console-pricing-card) .table-wrap { padding: 0 var(--space-4) var(--space-4); }
  :is(.console-billing-invoices, .console-pricing-card) .table-cards tr { box-shadow: none; }
  :is(.console-billing-invoices, .console-pricing-card) .table-cards tbody tr:last-child { margin-bottom: 0; }
  .console-pricing-card .card-note { padding-top: 0; }
  .table-invoice-list td.cell-title { grid-column: 1; }
  .table-invoice-list td.cell-title .sub { margin-top: 2px; }

  /* Statement detail: lines as a plain list. */
  .console-statement .kv-list dt { padding-right: var(--space-3); }
  .cs-lines .table-wrap { padding: 0 var(--space-4); overflow: visible; }
  .table-lines, .table-lines tbody { display: block; }
  .table-lines thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-lines tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--space-3); padding: var(--space-2) 0; }
  .table-lines td, .table-lines th { display: block; padding: 0; border: 0; min-width: 0; text-align: left; overflow-wrap: anywhere; }
  .table-lines tbody tr:hover td { background: transparent; }
  .table-lines td.line-text, .table-lines th.line-text { grid-column: 1; grid-row: 1; }
  .table-lines td.line-amount { grid-column: 2; grid-row: 1; text-align: right; }
  .table-lines td.line-kind { grid-column: 1 / -1; grid-row: 2; font-size: var(--text-sm); }
  .table-lines td.line-kind:empty, .table-lines td.line-action:empty { display: none; }
  .table-lines td.line-action { grid-column: 1 / -1; grid-row: 3; margin-top: var(--space-2); }
  .table-lines td.line-action form { display: block; margin: 0; }
  .table-lines td.line-action button { width: 100%; min-height: var(--field); }
  .table-lines tr.line-total { border-top: 1px solid var(--line); }
  .table-lines tr.line-total th { padding: 0; }
  .table-lines tr.line-total th[colspan] { grid-column: 1; }
  .adjust-form { grid-template-columns: minmax(0, 1fr); }
  .adjust-form .field { gap: 6px; }
  .adjust-form label { font-weight: 700; }
  .adjust-form input::placeholder { color: transparent; }
  .adjust-form button, .void-form button { width: 100%; }
  .void-form { align-items: stretch; }

  /* Billing settings: the sections stack, the note keeps its full width. */
  .console-settings .form-grid { grid-template-columns: minmax(0, 1fr); }

  /* Ceník. */
  .pricing-new { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--space-3); }
  .pricing-new .field > span { grid-column: 1 / -1; font-weight: 700; }
  .pricing-new select, .pricing-new button { min-height: var(--field); }
  .page-head .page-actions:has(.pricing-new) > * { flex: 1 1 100%; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .pricing-draft .inset { border: 0; background: none; overflow: visible; }
  .table-fees, .table-fees tbody { display: block; }
  .table-fees thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-fees tr { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
  .table-fees td { display: block; padding: 0; border: 0; text-align: left; width: auto; }
  .table-fees tbody tr:hover td { background: transparent; }
  .table-fees td.fee-approval { width: auto; }
  .approval-check { min-height: var(--tap); }
  .table-erp-edit, .table-erp-edit tbody { display: block; }
  .table-erp-edit thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-erp-edit tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px var(--space-3); padding: 0 0 var(--space-3); }
  .table-erp-edit td { display: block; padding: 0; border: 0; }
  .table-erp-edit tbody tr:hover td { background: transparent; }
  .table-erp-edit td.erp-name { grid-column: 1 / -1; }
  .table-erp-edit td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: var(--text-sm); }
  .cs-aside .table-wrap { overflow: visible; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions button { width: 100%; }
  .form-actions .danger { margin-left: 0; }
}

@media (max-width: 1023px) {
  .cs-left, .cs-right { display: contents; }
  .cs-state { order: 1; }
  .cs-lines { order: 2; }
  .cs-profile { order: 3; }
  .cs-side { order: 4; }
  .cs-history { order: 5; }
}
.console-billing .cell-link, .console-pricing-card .cell-link, .table-invoice-list .cell-link { color: var(--fg); }
.pricing-new select { min-height: var(--field); }
.console-usage > .usage-head .card-header { min-height: 56px; margin: 0; padding: var(--space-3) var(--space-4); }
.console-usage .card-header a { font-weight: 700; text-decoration: none; }
.console-usage .table-filter input { width: auto; }
.console-usage .table-filter label { font-weight: 700; }
@media (max-width: 767px) {
  .console-usage .usage-head .table-filter input { width: 100%; }
  .console-usage .usage-head .card-header { min-height: 0; padding: 0; }
}
@media (min-width: 768px) {
  .table-usage td, .table-usage th { padding-left: 10px; padding-right: 10px; }
  .table-usage td:first-child, .table-usage th:first-child { padding-left: var(--space-4); }
}
@media (max-width: 767px) {
  .table-versions tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr); }
  .table-versions td.cell-end { min-width: 0; }
  .console-settings > .provider-form .row button { width: 100%; }
  .console-settings .row { margin-top: var(--space-2); }
}

/* ---------- Console d (stage 3) ---------- */
.console-agents, .console-system, .console-operators, .console-audit, .console-job { display: flex; flex-direction: column; gap: var(--space-4); }
.console-job.detail-grid { display: grid; }
.console-agents > .card, .console-system > .card, .console-operators > .card { margin: 0; }
.console-agents .section-heading { margin: 0; }
.console-agents .kv-inset .kv-list dd { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--space-2); }
.console-agents .field input.mono, .console-agents .field input.input-wide { width: 100%; max-width: none; }
.console-agents input.mono { font-family: var(--mono); font-size: var(--text-md); }
.console-agents .agents-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-5); align-items: start; }
.console-agents .offer-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.console-agents .table-versions .num { text-align: left; }
.table-nested { margin: 0; }
.console-agents .agents-grid .table-nested { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.console-agents .table-versions tr:last-child td { border-bottom: 0; }
.console-agents .table-agents .cell-actions form { margin: 0; }

.console-system .tile { padding: var(--space-4); gap: var(--space-2); }
.console-system .tile-value { font-family: var(--font-heading); font-weight: 800; font-size: 1.75rem; }
.console-system .tile-status { font-size: 1.25rem; line-height: 1.25; display: flex; align-items: flex-start; gap: var(--space-2); }
.console-system .tile-status::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 0.5em; border-radius: 50%; background: var(--stat-tone, var(--line-strong)); }
.console-system .tone-ok { --stat-tone: var(--ok); }
.console-system .tone-warn { --stat-tone: var(--warn); }
.console-system .tone-bad { --stat-tone: var(--bad); }
.console-system .system-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.console-system .tile-platform, .console-system .tile-schema { grid-column: 1 / -1; }
.console-system .system-grid { display: flex; flex-direction: column; gap: var(--space-4); }
.console-system .system-versions .kv-inset { margin-top: var(--space-1); }
.console-system td.bad { color: var(--bad); font-weight: 700; }
.console-system .tile-note { overflow-wrap: anywhere; }
@media (min-width: 1024px) {
  .console-system .system-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .console-system .tile-platform, .console-system .tile-schema { grid-column: auto; }
  .console-system .system-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--space-4); align-items: start; }
  .console-system .system-jobs { grid-row: 1 / span 2; }
}

.console-job.detail-grid { gap: var(--space-4); }
.console-job .job-main { gap: var(--space-4); }
.console-job .kv-id { font-family: var(--mono); font-size: var(--text-md); font-weight: 500; word-break: break-all; }
@media (min-width: 1024px) {
  .console-job .job-main { grid-column: 1; grid-row: 1; }
  .console-job .job-facts { grid-column: 2; grid-row: 1; }
}

.console-operators .table-operators .op-actions { white-space: normal; }
.console-operators .op-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 2px 6px 2px 0; vertical-align: middle; }
.console-operators .op-form select, .console-operators .op-form input[type="password"] { min-height: 36px; width: auto; max-width: 11rem; }
.console-operators .op-label { display: none; }

.audit-more { margin: 0; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); font-weight: 800; }
.table-audit .audit-line { display: block; }
.table-audit .audit-line.sub { font-size: var(--text-sm); color: var(--muted); }

.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.account-grid > .card { margin: 0; }

.two-factor-steps { list-style: none; counter-reset: tfs; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.two-factor-steps > li { counter-increment: tfs; position: relative; padding-left: 52px; min-height: 36px; display: flex; flex-direction: column; gap: var(--space-2); }
.two-factor-steps > li::before {
  content: counter(tfs); position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 800;
}
.two-factor-steps .qr-wrap { margin: 0; }
.two-factor-steps .qr-wrap svg, .two-factor-steps .qr { display: block; width: 168px; height: 168px; padding: var(--space-2); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.two-factor-steps .field { margin: 0; }
.two-factor-steps .field label { font-weight: 800; }
.two-factor-steps .field-hint { margin: 0; }

@media (max-width: 767px) {
  .console-agents .agents-grid { grid-template-columns: minmax(0, 1fr); }
  .console-agents .agents-grid .table-nested { border: 0; overflow: visible; }
  .table-nested { overflow: visible; }
  .console-agents .table-versions .num, .console-system .table-cards td.num { text-align: left; }
  .console-agents .table-agents td.cell-actions { grid-column: 1 / -1; display: block; }
  .console-agents .table-agents td.cell-actions form, .console-agents .table-agents td.cell-actions button { width: 100%; }
  .console-agents .table-agents td.cell-title a { font-weight: 800; }
  .console-agents .table-agents td.cell-meta, .console-system .table-cards td.cell-meta, .console-operators .table-cards td.cell-meta { grid-column: 1; }
  .console-agents .table-agents td.cell-end, .console-system .table-cards td.cell-end, .console-operators .table-cards td.cell-end { grid-column: 2; }
  .console-operators .op-actions { display: flex; flex-direction: column; gap: var(--space-2); }
  .console-operators .op-form { display: flex; flex-direction: column; align-items: stretch; margin: 0; }
  .console-operators .op-form select, .console-operators .op-form input[type="password"], .console-operators .op-form button { width: 100%; max-width: none; min-height: var(--tap); }
  .console-operators .op-label { display: block; font-weight: 800; }
  .console-operators .card-medium .form-grid { grid-template-columns: minmax(0, 1fr); }

  /* The global history is one plain list in a card; the tenant tab keeps a card per record. */
  .audit-plain tbody { gap: 0; }
  .audit-plain tr { display: block; padding: var(--space-3) 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
  .audit-plain td { display: block; }
  .audit-plain td.cell-title { font-size: 1.0625rem; }
  .audit-plain td.audit-when, .audit-plain td.audit-who { display: inline; font-weight: 400; color: var(--muted); }
  .audit-plain td.audit-who::before { content: " · "; }
  .audit-plain td.audit-tenant::before { content: attr(data-label) " "; }
  .audit-plain td.audit-detail { margin-top: 2px; }
  .table-audit:not(.audit-plain) td.audit-who { font-weight: 800; color: var(--fg); }
  .table-audit:not(.audit-plain) td.audit-detail { grid-column: 1 / -1; color: var(--muted); }
  .console-audit > .audit-more { padding: 0 var(--space-1); border: 0; color: var(--accent-text); }
  .console-audit .card-flush .table-nested { padding: 0 var(--space-4) var(--space-3); }
  .account-grid { grid-template-columns: minmax(0, 1fr); }
}
.console-agents .table-agents td.cell-title a { color: var(--fg); text-decoration: none; }
.console-agents .table-agents td.cell-title a:hover { text-decoration: underline; }
.console-system .table-jobs td.cell-title { grid-column: 1; }
.console-system .table-jobs td.cell-note { grid-column: 1 / -1; }
.console-audit .table-audit a { color: var(--fg); text-decoration: none; }
.console-audit .table-audit a:hover { text-decoration: underline; }
.console-operators .op-actions { min-width: 0; }
.console-operators .op-form { flex-wrap: nowrap; }
.console-operators .op-form select { max-width: 9rem; }
.console-operators .op-form input[type="password"] { max-width: 8.5rem; }
@media (max-width: 767px) {
  .console-system .table-processes .row-2 { grid-row: 2; }
  .console-system .table-processes .row-3 { grid-row: 3; }
  .console-operators .op-form { flex-wrap: wrap; }
}

/* ---------- Console, orchestrator fixes after the merge (stage 3) ---------- */
.run-line { display: block; white-space: nowrap; }
.run-main { font-weight: 700; }
/* The console's sign-in panel: the operator purple of the light theme in both themes (white text on it is AA), like the coal portal panel. */
@media (min-width: 900px) {
  .auth-operator .split-hero { background: #5b3df5; }
}
/* The help contact once per screen (#194): in the sidebar on a desktop, in the page footer below 1024 px (portal-objednavky-d, portal-prehled-m). */
@media (min-width: 1024px) {
  .area-portal .page-footer { display: none; }
}
