/* Design systém aplikace. Popis komponent: DESIGN.md. Bez externích závislostí.
 * Sdílené komponenty jsou jen tady; modulové CSS (static/css/<modul>.css) je nesmí přepisovat ani kopírovat
 * (každý jeho selektor obsahuje vlastní třídu modulu – hlídá tests/test_frontend_css.py). */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #1c2229;
  --ink-2: #3b4450;
  --muted: #636b78;
  --line: #dde3ec;
  --line-2: #ecf0f5;
  --brand: #1d5aa6;
  --brand-2: #164985;
  --brand-ink: #ffffff;
  --brand-soft: #e5eef9;
  --accent: #f08c00;
  --accent-ink: #1b1300;
  --side: #12284b;
  --side-ink: #c3cfe2;
  --side-active: #1d3a68;
  --ok: #2c7a4b;
  --ok-soft: #e2f1e7;
  --warn: #946100;
  --warn-soft: #fbf0d6;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --info: #2c4a73;
  --info-soft: #e6ecf4;
  --ai: #5b3fa0;
  --ai-soft: #f1edfa;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(28, 34, 41, .05), 0 2px 8px rgba(28, 34, 41, .04);
  --side-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); text-decoration: underline; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; }
h3 { font-size: .92rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ico.lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .75rem; top: -3rem; z-index: 70; background: var(--surface); color: var(--ink); padding: .5rem .8rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 600; }
.skip-link:focus { top: .75rem; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
code { font-size: .85em; background: var(--line-2); padding: .05rem .3rem; border-radius: 4px; }
mark { background: #fbe7a4; color: inherit; border-radius: 3px; padding: 0 .1rem; }
/* Indikátor HTMX požadavku (vložené styly htmx jsou vypnuté kvůli Content-Security-Policy). */
.htmx-indicator { opacity: 0; transition: opacity .2s ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.main:focus { outline: none; }

/* ---------- Rozvržení ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; color: #fff; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-weight: 800; color: #fff; }
.brand strong { display: block; font-size: 1rem; letter-spacing: .04em; }
.brand small { display: block; color: var(--side-ink); font-size: .75rem; }
.bell { position: absolute; top: 1.15rem; right: .9rem; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--side-ink); }
.bell:hover, .bell.active { background: var(--side-active); color: #fff; text-decoration: none; }
.bell .count { position: absolute; top: -3px; right: -3px; background: var(--accent); color: var(--accent-ink); font-size: .66rem; font-weight: 700; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; display: grid; place-items: center; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: .25rem .6rem; flex: 1; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: var(--radius-sm); color: var(--side-ink); font-weight: 500; }
.side-nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.side-nav .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; padding: 0 .45rem; border-radius: 999px; }
.side-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #8a929d; padding: .9rem .65rem .3rem; display: block; }
.side-foot { padding: .9rem; border-top: 1px solid #2f363f; display: grid; gap: .6rem; }
.side-foot select { width: 100%; background: var(--side-active); color: #fff; border: 1px solid #2c4a7a; }
.side-foot .side-label { padding: 0 0 .25rem; }
.side-foot .btn.ghost { color: var(--side-ink); width: 100%; justify-content: flex-start; }
.side-foot .btn.ghost:hover { background: var(--side-active); color: #fff; }
.who strong { display: block; color: #fff; } .who small { color: var(--side-ink); }
.demo-tag { background: rgba(232, 175, 60, .15); color: #e8b04a; font-size: .72rem; padding: .2rem .55rem; border-radius: 999px; justify-self: start; }

.main { min-height: 100vh; min-width: 0; }
body.with-sidebar .main { margin-left: var(--side-w); }
.page { max-width: 1320px; margin: 0 auto; padding: 1.6rem 2rem 3rem; }
/* Konec stránky nesmí zůstat pod plovoucím tlačítkem Připomínka (feedback.css). */
.with-sidebar .page { padding-bottom: 5rem; }
.menu-toggle, .menu-backdrop { display: none; }

@media (max-width: 960px) {
  body.with-sidebar .main { margin-left: 0; }
  /* Zavřené menu je mimo obrazovku i mimo pořadí tabulátoru a čtečky (visibility se přepne až po animaci). */
  .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s .2s; box-shadow: 0 0 30px rgba(0, 0, 0, .3); z-index: 50; }
  body.menu-open .sidebar { transform: none; visibility: visible; transition: transform .2s; }
  .menu-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(28, 34, 41, .45); }
  body.menu-open .menu-backdrop { display: block; }
  body.menu-open .menu-toggle { z-index: 55; left: calc(min(var(--side-w), 100vw - 3.5rem) + .7rem); }
  .menu-toggle { display: grid; place-items: center; position: fixed; top: .7rem; left: .7rem; z-index: 40; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
  .page { padding: 4rem 1rem 2rem; }
}

/* ---------- Hlavička stránky ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: .3rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: .35rem; display: flex; gap: .35rem; align-items: center; }
.crumbs a { color: var(--muted); }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Karty a mřížky ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.3rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 1rem 1.3rem .2rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.sticky { position: sticky; top: 1.2rem; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

/* Položky mřížky se nesmí roztáhnout podle nejširšího obsahu (tabulka, dlouhé slovo); tabulky mají vlastní posuv v .table-wrap. */
.grid > *, .split > * { min-width: 0; }
.split.lead { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .split, .split.lead { grid-template-columns: minmax(0, 1fr); } }
.split > .sticky > .pdf-frame { margin-bottom: 1rem; }
/* Detail dokladu: obsah vlevo, boční panel 340 px (rozhodnutí, upozornění); boční panel se .sticky drží na obrazovce. */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.detail-layout > * { min-width: 0; }
.detail-side > .card { margin-bottom: 1.25rem; }
.decision .actions { margin-top: .6rem; }
@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-side.sticky { position: static; }
}
.card.flush > .empty { padding: 1.2rem 1.3rem 1.6rem; }
.card.flush > .card-head .actions { margin: 0; }
.card.flush .table-note { padding: .6rem 1.3rem 1rem; margin: 0; }
.card-foot { padding: .2rem 1.3rem 1.1rem; align-items: center; }
.form-card { max-width: 880px; }
.form-card h3 { margin-top: .4rem; }

/* ---------- Ukazatele (KPI) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: .35rem; }
.kpi .label .ico { width: 15px; height: 15px; }
.kpi .value { font-size: 1.3rem; font-weight: 680; font-variant-numeric: tabular-nums; margin-top: .15rem; letter-spacing: -.01em; }
.kpi .hint { color: var(--muted); font-size: .78rem; }
.kpi.good .value { color: var(--ok); }
.kpi.bad .value { color: var(--danger); }
.kpi.accent { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Tabulky ---------- */
/* position: relative – i absolutně umístěné prvky v buňkách (např. .sr-only popisky) zůstanou uvnitř posuvné oblasti. */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .7rem; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 1.3rem; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 1.3rem; }
tbody tr:hover { background: #fbf9f6; }
tbody tr.clickable { cursor: pointer; }
tr.total td { font-weight: 680; border-top: 2px solid var(--ink-2); background: var(--surface-2); }
td .sub, .cell-sub { display: block; color: var(--muted); font-size: .8rem; }
.over { color: var(--danger); font-weight: 600; }
.under { color: var(--ok); font-weight: 600; }
th.col-wide, td.col-wide { min-width: 15rem; }
tr.row-overdue td { background: var(--danger-soft); }
td .sub.over { color: var(--danger); }
/* Řaditelné záhlaví: <a class="sort [active]">Popisek<span class="sort-arrow [asc|desc]" aria-hidden="true"></span></a> */
th a.sort { color: inherit; display: inline-flex; align-items: center; gap: .25rem; }
th a.sort:hover { color: var(--ink); text-decoration: none; }
th.num a.sort { justify-content: flex-end; }
th a.sort.active { color: var(--ink); }
.sort-arrow { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; opacity: 0; }
.sort-arrow.asc { border-bottom: 5px solid currentColor; opacity: .8; }
.sort-arrow.desc { border-top: 5px solid currentColor; opacity: .8; }
th a.sort:hover .sort-arrow:not(.asc):not(.desc) { border-top: 5px solid currentColor; opacity: .3; }

/* ---------- Štítky ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 650; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
/* Obecné tóny štítku: neutral, warn, ok, danger, ai, plain. Nabídka a příležitost dávají do třídy přímo hodnotu stavu,
   ostatní doklady ji mapují v modelu (`Order.badge`, `Complaint.badge`…) na tón nebo na stav níže. */
.badge.neutral, .badge.draft, .badge.received { background: var(--info-soft); color: var(--info); }
.badge.warn, .badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.ok, .badge.approved, .badge.closed, .badge.confirmed { background: var(--ok-soft); color: var(--ok); }
.badge.danger, .badge.rejected, .badge.cancelled { background: var(--danger-soft); color: var(--danger); }
.badge.ai { background: var(--ai-soft); color: var(--ai); }
/* Obchod: příležitosti (new → negotiating → quoted → won/lost) a nabídky (sent, accepted, expired). */
.badge.new, .badge.negotiating { background: var(--info-soft); color: var(--info); }
.badge.quoted, .badge.sent { background: var(--warn-soft); color: var(--warn); }
.badge.won, .badge.accepted { background: var(--ok-soft); color: var(--ok); }
.badge.lost, .badge.expired { background: var(--line-2); color: var(--muted); }

/* ---------- Upozornění ---------- */
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .95rem; border-radius: var(--radius-sm); margin-bottom: .6rem; border: 1px solid transparent; }
.alert.danger, .alert.error { background: var(--danger-soft); color: var(--danger); border-color: #f0c3bf; }
.alert.warning { background: var(--warn-soft); color: var(--warn); border-color: #f0dcab; }
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: #c2e1cd; }
.alert.info { background: var(--info-soft); color: var(--info); border-color: #ccd8e8; }
.alert > div { flex: 1; min-width: 0; }
.toasts { margin-bottom: 1rem; }
.ai-box { background: var(--ai-soft); border: 1px solid #ddd3f3; color: #3f2b78; border-radius: var(--radius-sm); padding: .75rem .95rem; margin-bottom: 1rem; display: flex; gap: .6rem; }
.ai-box .ico { color: var(--ai); }
.ai-box p { margin: 0; }
/* Odkaz na zdroj v odpovědi AI [n] (filtr `answer_html`, `{% load ui %}`). */
.cite { display: inline-grid; place-items: center; min-width: 1.15rem; height: 1.15rem; padding: 0 .25rem; margin: 0 .1rem; border-radius: 5px; background: var(--ai-soft); color: var(--ai); font-size: .7rem; font-weight: 700; vertical-align: .15em; line-height: 1; }
.cite:hover { background: var(--ai); color: #fff; text-decoration: none; }

/* ---------- Tlačítka ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600; font-size: .9rem; padding: .5rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #cfc9c0; background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(.95); color: #fff; }
.btn.danger { color: var(--danger); border-color: #efc3bf; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost.danger { border-color: transparent; }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.actions.end { justify-content: flex-end; }
.actions.center { justify-content: center; }
/* Akce v řádku tabulky (upravit, smazat) zarovnané vpravo; malé formuláře uvnitř bez okrajů. */
.row-actions { display: flex; gap: .25rem; justify-content: flex-end; white-space: nowrap; }
.row-actions form { margin: 0; }
.inline-form { display: inline; margin: 0; }

/* ---------- Filtry a záložky ---------- */
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.toolbar .search input { padding-left: 2rem; width: 100%; }
.toolbar .search.wide { min-width: 290px; max-width: 440px; }
.toolbar .search .ico { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar select, .toolbar input { width: auto; max-width: 100%; }
.toolbar select { max-width: 240px; }
/* Lišta nad výsledky seznamu (templates/_list_reset.html): stavové filtry vlevo, Zrušit filtry vpravo. */
.list-bar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.list-bar:not(:has(*)) { display: none; }
.list-reset { margin-left: auto; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: .82rem; font-weight: 550; }
.chip:hover { text-decoration: none; border-color: #cfc9c0; color: var(--ink); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .65; margin-left: .25rem; }
.chip.accent:not(.active) { border-color: #f0dcab; background: var(--warn-soft); color: var(--warn); }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .tab-n { display: inline-block; margin-left: .35rem; font-size: .72rem; font-weight: 700; padding: 0 .4rem; border-radius: 999px; background: var(--line-2); color: var(--muted); }
.tabs a.active .tab-n { background: var(--brand-soft); color: var(--brand); }
/* Stránkování (templates/_pager.html): pod kartou s odstupem, uvnitř karty s vnitřním okrajem. */
.pager { display: flex; justify-content: center; align-items: center; gap: .8rem; margin: -.4rem 0 1.2rem; color: var(--muted); font-size: .85rem; }
.card .pager { margin: 0; padding: .8rem 1.3rem; }

/* ---------- Formuláře ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .wide, .form-grid .full { grid-column: 1 / -1; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid.single { grid-template-columns: minmax(0, 1fr); max-width: 420px; }
.form-grid > * { min-width: 0; }
@media (max-width: 700px) { .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); } .form-grid .span-2 { grid-column: auto; } }
.field label, label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
.field .help { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
.req { color: var(--danger); font-weight: 700; }
/* Hodnota, kterou systém dopočítá (např. součet z položek). */
.field.is-derived input { background: var(--surface-2); color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29, 90, 166, .25); border-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { width: auto; }
label.check { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 600; color: var(--ink); cursor: pointer; }
label.check input { margin: 0; width: 16px; height: 16px; }
.form-section { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; margin: 1rem 0 .55rem; }
.form-section:first-of-type { margin-top: .2rem; }
textarea { resize: vertical; min-height: 4.5rem; }
.errorlist { color: var(--danger); font-size: .78rem; margin: .25rem 0 0; padding-left: 1rem; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; background: var(--surface-2); color: var(--muted); }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
/* Položkový formulář (templates/_items_formset.html, static/js/formset.js). */
.formset-table td { padding: .35rem .4rem; vertical-align: top; }
.formset-table input { padding: .35rem .45rem; }
.formset-table .errorlist { padding-left: .9rem; }
.formset-table .col-qty { width: 110px; }
.formset-table .col-unit { width: 80px; }
.formset-table .col-price { width: 160px; }
.formset-table .col-total { width: 140px; padding-top: .8rem; }
.formset-table .col-del { width: 44px; text-align: center; }
.formset-table tr.is-removed td:not(.col-del) { opacity: .4; text-decoration: line-through; }
.formset-foot { padding: .7rem 1.3rem 1rem; }
.formset-error { margin: .6rem 1.3rem; }
.row-delete { position: relative; display: inline-grid; place-items: center; width: 30px; height: 30px; margin: .15rem 0 0; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; }
.row-delete:hover, .row-delete:has(input:checked) { background: var(--danger-soft); color: var(--danger); }
.row-delete input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.row-delete:focus-within { outline: 2px solid rgba(29, 90, 166, .25); }

/* ---------- Údaje ---------- */
dl.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1.4rem; margin: 0; }
dl.facts.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
dl.facts dt { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
dl.facts dd { margin: .05rem 0 .3rem; font-weight: 550; overflow-wrap: anywhere; }
dl.facts.roomy { gap: .9rem 1.4rem; }
dl.facts.roomy dd { margin-bottom: 0; }
dl.facts.single { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
@media (max-width: 700px) { dl.facts.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pdf-frame { width: 100%; height: calc(100vh - 2.4rem); border: 1px solid var(--line); border-radius: var(--radius); background: #525659; }
.empty { color: var(--muted); padding: 1.6rem 0; text-align: center; }
.empty .ico { width: 28px; height: 28px; display: block; margin: 0 auto .4rem; opacity: .6; }
.divider { border: 0; border-top: 1px solid var(--line-2); margin: 1rem 0; }

/* ---------- Historie ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .15rem 0 .85rem 1.2rem; border-left: 2px solid var(--line); position: relative; margin-left: .3rem; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.timeline .when { color: var(--muted); font-size: .78rem; }
.timeline .note { background: var(--surface-2); border-radius: 6px; padding: .35rem .55rem; margin-top: .3rem; font-size: .86rem; }

/* ---------- Seznam úkolů ---------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line-2); }
.task-list li:last-child { border-bottom: 0; }
.task-list .main-col { flex: 1; min-width: 0; }
.task-list .title { display: block; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.task-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.task-icon.warn { background: var(--warn-soft); color: var(--warn); }
.task-icon.danger { background: var(--danger-soft); color: var(--danger); }
.task-icon.ai { background: var(--ai-soft); color: var(--ai); }
.task-icon.info { background: var(--info-soft); color: var(--info); }

/* ---------- Přihlášení ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 460px; }
.login .brand { color: var(--ink); padding: 0 0 1rem; }
.login .brand small { color: var(--muted); }
.user-pick { display: grid; gap: .5rem; }
.user-pick-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .9rem 0 .35rem; }
.user-pick button { width: 100%; justify-content: space-between; padding: .75rem 1rem; }

/* ---------- Graf ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
/* Tabulka hodnot pod grafem (rozbalovací). */
.chart-table { margin-top: .6rem; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
.chart-table table { margin-top: .4rem; font-size: .85rem; }

/* ---------- Hlášení chyb (static/js/app.js) ---------- */
.toasts-float { position: fixed; top: 1rem; right: 1rem; z-index: 60; display: grid; gap: .5rem; width: min(420px, calc(100vw - 2rem)); }
.toasts-float .toast { margin: 0; box-shadow: 0 8px 24px rgba(28, 34, 41, .16); align-items: flex-start; }
.toasts-float .toast span { flex: 1; min-width: 0; }
.toast-close { background: none; border: 0; color: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 .15rem; }

/* ---------- Úzké obrazovky (telefon) ---------- */
@media (max-width: 600px) {
  .card { padding: 1rem; }
  .card.flush > .card-head { padding: .9rem 1rem .2rem; }
  .card.flush table th:first-child, .card.flush table td:first-child { padding-left: 1rem; }
  .card.flush table th:last-child, .card.flush table td:last-child { padding-right: 1rem; }
  .card-head { flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .7rem .8rem; }
  .kpi .value { font-size: 1.08rem; overflow-wrap: anywhere; }
  .task-list li { flex-wrap: wrap; row-gap: .3rem; }
  .task-list .main-col { flex-basis: calc(100% - 34px - .8rem); }
  .task-list .task-side { flex-direction: row; align-items: center; flex-wrap: wrap; margin-left: calc(34px + .8rem); }
  .toolbar .search { min-width: 0; flex-basis: 100%; max-width: none; }
  .btn { white-space: normal; }
  .pdf-frame { height: 70vh; }
}

/* Řádek neaktivního záznamu v seznamu (zákazník, uživatel) */
tr.is-inactive td { color: var(--muted); }
tr.is-inactive a.strong { color: var(--muted); }

/* Ukazatel jako odkaz (Můj přehled) a textová hodnota místo čísla */
a.kpi { color: inherit; display: block; }
a.kpi:hover { text-decoration: none; border-color: var(--brand); }
.kpi .value.small { font-size: 1rem; }

