/* ============================================================================
   Fakturace Jipos — KH design system (handoff v2)
   Z reporting-saas vizuálního jazyka + Jipos red akcent (#C8171A).
   Klíčové komponenty: pill-switcher, kpi karty (default/alert/success),
   pill buttons, outlined inputy s accent focusem, sticky detail rail.
   ========================================================================== */

/* ─── Inter (variabilní font) ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300..800;1,14..32,700..800&display=swap');

/* ─── KH tokeny ──────────────────────────────────────────────────────────── */
:root {
  --kh-bg:           #FFFFFF;
  --kh-bg-panel:     #FAFAFB;
  --kh-bg-hover:     #F4F4F6;
  --kh-border:       #E5E7EB;
  --kh-border-soft:  #EFF0F3;
  --kh-ink:          #1F2328;
  --kh-ink-2:        #55606B;
  --kh-ink-3:        #8A93A0;
  --kh-ink-4:        #B8BFC8;
  --accent:          #C8171A;
  --accent-ink:      #FFFFFF;
  --accent-soft:     #FBE9E9;
  --accent-border:   #f0c5c5;
  --kh-pos:          #1F7A3A;
  --kh-pos-bg:       #E6F3EA;
  --kh-pos-border:   #a8d4b5;
  --kh-neg:          #B03030;
  --kh-neg-bg:       #F9E4E4;
  --kh-neg-border:   #e8b4b4;
  --kh-warn:         #856000;
  --kh-warn-bg:      #FFF7E0;
  --kh-warn-border:  #f0e0a0;

  --shadow-card:        2px 3px 6px 0px #f4f1f1b8;
  --shadow-card-hover:  3px 5px 10px 0px #e8e3e3cc, 0 4px 14px rgba(14,14,15,.06);
  --shadow-btn:         0 1px 2px rgba(200,23,26,.2);

  --r-sm:    8px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-full: 9999px;

  --ease:   cubic-bezier(0.2, 0, 0, 1);
  --dur-2:  150ms;
  --dur-3:  200ms;

  /* M3 bridge — zachová zpětnou kompatibilitu inline stylů ve Twigu */
  --md-primary:                  var(--accent);
  --md-on-primary:               var(--accent-ink);
  --md-primary-container:        var(--accent-soft);
  --md-on-primary-container:     #7A0000;
  --md-secondary-container:      var(--accent-soft);
  --md-on-secondary-container:   #7A0000;
  --md-surface:                  var(--kh-bg);
  --md-surface-container-lowest: var(--kh-bg);
  --md-surface-container-low:    var(--kh-bg-panel);
  --md-surface-container:        var(--kh-bg-hover);
  --md-surface-container-high:   var(--kh-bg-hover);
  --md-on-surface:               var(--kh-ink);
  --md-on-surface-variant:       var(--kh-ink-3);
  --md-outline:                  var(--kh-border);
  --md-outline-variant:          var(--kh-border-soft);
  --md-error:                    var(--kh-neg);
  --md-error-container:          var(--kh-neg-bg);
  --md-elev-1:                   var(--shadow-card);
  --md-elev-2:                   var(--shadow-card-hover);
  --md-elev-3:                   var(--shadow-card-hover);
  /* status legacy */
  --jp-success:                  var(--kh-pos);
  --jp-success-bg:               var(--kh-pos-bg);
  --jp-success-border:           var(--kh-pos-border);
  --jp-warn:                     var(--kh-warn);
  --jp-warn-bg:                  var(--kh-warn-bg);
  --jp-warn-border:              var(--kh-warn-border);
  --jp-yellow:                   #FECA1F;
  /* old short aliases */
  --bd: var(--kh-border);
  --mut: var(--kh-ink-3);
  --bg: var(--kh-bg);
  --ac: var(--accent);
  --ok: var(--kh-pos);
  --err: var(--kh-neg);
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--kh-bg);
  color: var(--kh-ink);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--kh-border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--kh-ink-4); border: 2px solid transparent; background-clip: padding-box; }

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 72px; }

h1 { margin: 0; font-size: 24px; font-weight: 800; font-style: italic; letter-spacing: -0.04em; line-height: 1.15; color: var(--kh-ink); }
h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--kh-ink); }
code {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--kh-bg-panel); border: 1px solid var(--kh-border);
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
}

/* ─── Top app bar ─────────────────────────────────────────────────────────── */
.app-bar {
  background: var(--kh-bg);
  border-bottom: 1px solid var(--kh-border);
  position: sticky; top: 0; z-index: 100;
}
.app-bar__inner {
  display: flex; align-items: stretch;
  max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 60px;
}
.brand {
  display: inline-flex; align-items: center;
  margin-right: 36px; flex-shrink: 0;
  font-weight: 800; font-style: italic; font-size: 17px; letter-spacing: -0.03em;
  color: var(--kh-ink); user-select: none;
}
.brand:hover { text-decoration: none; }
.brand b { font-weight: 800; color: var(--kh-ink); }
.brand i { font-style: italic; font-weight: 800; color: var(--accent); }

.nav-tabs { display: flex; flex: 1; height: 100%; gap: 2px; }
.nav-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px;
  font-size: 13px; font-weight: 500; color: var(--kh-ink-3);
  cursor: pointer; user-select: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 140ms var(--ease), border-color 140ms var(--ease);
}
.nav-tab:hover { text-decoration: none; color: var(--kh-ink-2); }
.nav-tab.is-active { color: var(--kh-ink); font-weight: 600; border-bottom-color: var(--accent); }
.nav-tab.is-active::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

.app-bar__tail { display: flex; align-items: center; }
.logout {
  padding: 5px 13px; font-size: 12px; font-weight: 500;
  color: var(--kh-ink-3); cursor: pointer;
  border: 1px solid var(--kh-border); border-radius: var(--r-full);
  background: var(--kh-bg);
  transition: color 120ms var(--ease), border-color 120ms var(--ease);
}
.logout:hover { text-decoration: none; color: var(--kh-ink); border-color: var(--kh-ink-3); }

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 24px; }
.page-head > div:first-child { flex: 1; min-width: 0; }
.page-head h1 { margin: 0; }
.page-head__back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  cursor: pointer; margin-bottom: 6px; user-select: none;
}
.page-head__back:hover { text-decoration: none; opacity: .85; }
.page-head__eyebrow {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--kh-ink-3); margin-bottom: 5px;
}
.page-head__eyebrow::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.page-head__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; padding-top: 2px; }
.subhead { font-size: 12px; color: var(--kh-ink-3); margin: -16px 0 18px; }

/* ─── Buttons (pill) ─────────────────────────────────────────────────────── */
.btn, button, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 17px;
  border: none; border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.4;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-btn);
  transition: opacity 130ms var(--ease), box-shadow 130ms var(--ease), background-color 130ms var(--ease);
}
.btn:hover, button:hover, input[type=submit]:hover { text-decoration: none; opacity: .92; }
.btn:active, button:active { opacity: .85; }
.btn:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* secondary = outlined */
.btn.sec, button.sec, .btn--secondary {
  background: var(--kh-bg); color: var(--kh-ink);
  border: 1px solid var(--kh-border); box-shadow: var(--shadow-card);
}
.btn.sec:hover, button.sec:hover { background: var(--kh-bg-panel); opacity: 1; }

/* tonal */
.btn--tonal, .btn.tonal, button.tonal {
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-border); box-shadow: none;
}
.btn--tonal:hover, .btn.tonal:hover, button.tonal:hover { background: #f7d8d8; opacity: 1; }

/* ghost */
.btn.ghost, button.ghost, .btn--ghost {
  background: transparent; color: var(--kh-ink-3); border: none; box-shadow: none;
}
.btn.ghost:hover, button.ghost:hover { color: var(--kh-ink); }

/* danger */
.btn.danger, button.danger {
  background: var(--kh-neg); color: #fff; border: none;
  box-shadow: 0 1px 2px rgba(176,48,48,.2);
}

/* sizes */
.btn--sm, button.sm, .btn.sm { padding: 5px 13px; font-size: 12px; }
.btn--lg, .btn.lg { padding: 9px 22px; font-size: 14px; }
.btn[disabled], button[disabled] { opacity: .4; cursor: not-allowed; }

/* No-op legacy hook used to live for M3 state layer; keep class so templates work */
.m3-state { position: relative; }

/* ─── Pill switcher ──────────────────────────────────────────────────────── */
.pill-switcher-group {
  display: flex; flex-direction: column; gap: 5px;
}
.pill-switcher-group__label,
.eyebrow {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--kh-ink-3);
}
.pill-switcher {
  display: inline-flex; align-items: center; flex-wrap: wrap;
  background: var(--kh-bg-panel);
  border: 1px solid var(--kh-border);
  border-radius: var(--r-full);
  padding: 3px; gap: 2px;
  box-shadow: inset 0 1px 2px rgba(14,14,15,.04);
}
.pill-switcher__opt {
  display: inline-flex; align-items: center;
  padding: 5px 14px;
  border: none; background: transparent;
  border-radius: var(--r-full);
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--kh-ink-2); cursor: pointer;
  white-space: nowrap; line-height: 1.4;
  box-shadow: none;
  transition: background 130ms var(--ease), color 130ms var(--ease);
}
.pill-switcher__opt:hover { color: var(--kh-ink); text-decoration: none; opacity: 1; }
.pill-switcher__opt.is-active {
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.pill-switcher__opt.is-active:hover { color: var(--accent-ink); opacity: .92; }
.pill-switcher__opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.filter-bar {
  display: flex; gap: 16px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: flex-end;
}
.filter-bar > .filter-bar__tail { margin-left: auto; }

.input--pill {
  padding: 7px 12px; border: 1px solid var(--kh-border);
  border-radius: var(--r-full);
  font-family: inherit; font-size: 12px;
  width: 200px; outline: none;
  color: var(--kh-ink); background: var(--kh-bg);
}
.input--pill:focus { border-color: var(--accent); }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--kh-bg);
  border: 1px solid var(--kh-border);
  border-radius: var(--r-md);
  padding: 20px; margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.card.flush, .card--flush { padding: 0; overflow: hidden; }
.card.elevated, .card--elevated { box-shadow: var(--shadow-card-hover); }

/* tables inside flush card own the radius via card overflow:hidden */

/* ─── KPI / stat karty ───────────────────────────────────────────────────── */
.stats {
  display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
.stat {
  flex: 1; min-width: 150px;
  text-align: left;
  background: var(--kh-bg);
  border: 1px solid var(--kh-border);
  border-radius: var(--r-md); padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.stat__label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--kh-ink-3); margin-bottom: 8px;
}
.stat__value {
  font-size: 21px; font-weight: 800; font-style: italic; letter-spacing: -0.03em;
  line-height: 1.2; color: var(--kh-ink);
}
.stat__sub {
  font-size: 11px; color: var(--kh-ink-3); margin-top: 5px; font-weight: 500;
}
.stat--alert   { background: var(--kh-neg-bg); border-color: var(--kh-neg-border); box-shadow: none; }
.stat--alert   .stat__label { color: #9a4040; }
.stat--alert   .stat__value { color: var(--kh-neg); }
.stat--alert   .stat__sub   { color: #9a4040; }
.stat--success { background: var(--kh-pos-bg); border-color: var(--kh-pos-border); box-shadow: none; }
.stat--success .stat__label { color: #2d6b45; }
.stat--success .stat__value { color: var(--kh-pos); }
.stat--success .stat__sub   { color: #2d6b45; }

/* ─── Badges (pill) ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
  background: var(--kh-bg-panel); color: var(--kh-ink-3);
}
.badge--overdue { background: var(--kh-neg-bg);  color: var(--kh-neg); }
.badge--unpaid  { background: var(--kh-bg-panel); color: var(--kh-ink-3); }
.badge--paid    { background: var(--kh-pos-bg);  color: var(--kh-pos); }
.badge--review  { background: var(--kh-warn-bg); color: var(--kh-warn); }
.badge--warn    { background: var(--kh-warn-bg); color: var(--kh-warn); }
.badge--ok      { background: var(--kh-pos-bg);  color: var(--kh-pos); }
.badge--failed  { background: var(--kh-neg-bg);  color: var(--kh-neg); }

/* ─── Forms (outlined) ───────────────────────────────────────────────────── */
label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--kh-ink-3); margin: 0 0 4px;
}
input, select, textarea {
  width: 100%; padding: 7px 11px;
  border: 1px solid var(--kh-border); border-radius: var(--r-sm);
  font-family: inherit; font-size: 13px; color: var(--kh-ink);
  background: var(--kh-bg); outline: none;
  transition: border-color 130ms var(--ease);
}
textarea { resize: vertical; line-height: 1.5; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--kh-ink-3); opacity: .8; }
input:focus, textarea:focus { border-color: var(--accent); }
select { cursor: pointer; appearance: auto; }
select:focus { border-color: var(--kh-ink-3); }
input[readonly] { background: var(--kh-bg-panel); }
input[type=checkbox], input[type=radio] {
  width: auto; height: 15px; min-width: 15px; padding: 0; margin: 0;
  accent-color: var(--accent); cursor: pointer; vertical-align: middle;
}
input[type=file] { border: none; padding: 0; background: none; }

/* form rows */
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }
.field { flex: 1; min-width: 140px; }
.field--half { flex: 0 1 auto; min-width: 110px; }

/* table-cell inputs */
td input, td select, td textarea { padding: 5px 8px; font-size: 12px; border-radius: var(--r-sm); }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 9px 14px;
  font-size: 10px; font-weight: 700;
  color: var(--kh-ink-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  border-bottom: 1px solid var(--kh-border);
  background: var(--kh-bg-panel);
  white-space: nowrap;
}
th.right, th .right { text-align: right; }
td {
  padding: 10px 14px; font-size: 13px; color: var(--kh-ink);
  border-bottom: 1px solid var(--kh-border-soft); vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 100ms var(--ease); }
tbody tr:hover { background: var(--kh-bg-hover); }
td.right { text-align: right; }
.t-bold, td.bold { font-weight: 700; }
.t-mono, td.mono { font-family: 'Roboto Mono','Courier New', monospace; }
.t-red   { color: var(--kh-neg); font-weight: 700; }
.t-green { color: var(--kh-pos); font-weight: 700; }
.row-overdue { background: var(--kh-neg-bg); }
.row-overdue:hover { background: var(--kh-bg-hover); }
table a { color: inherit; }
table a:hover { color: var(--accent); text-decoration: none; }

/* ─── Flash / banner ─────────────────────────────────────────────────────── */
.flash {
  padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 14px;
  font-size: 13px; font-weight: 500; border: 1px solid transparent;
}
.flash.success { background: var(--kh-pos-bg); color: var(--kh-pos); border-color: var(--kh-pos-border); }
.flash.error   { background: var(--kh-neg-bg); color: var(--kh-neg); border-color: var(--kh-neg-border); }
.flash.warn    { background: var(--kh-warn-bg); color: var(--kh-warn); border-color: var(--kh-warn-border); }

/* ─── Section heading (uppercase eyebrow uvnitř karty) ───────────────────── */
.section-h {
  margin: 0 0 12px;
  font-size: 12px; font-weight: 700;
  color: var(--kh-ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* Settings: H2 s červenou 3×14px čárou (accent bar) */
.section-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 24px 0 10px;
  font-size: 14px; font-weight: 700;
  color: var(--kh-ink); letter-spacing: -0.01em;
}
.section-bar::before {
  content: ''; width: 3px; height: 14px;
  background: var(--accent); border-radius: 2px;
  flex-shrink: 0;
}

/* ─── Helpers ────────────────────────────────────────────────────────────── */
.mut, .muted { color: var(--kh-ink-3); font-size: 13px; }
.right { text-align: right; }
.sp { margin-left: auto; }
details > summary {
  cursor: pointer; font-weight: 600; color: var(--accent);
  margin: 8px 0; padding: 4px 0; list-style: none; user-select: none;
  font-size: 13px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▶ '; font-size: 10px; }
details[open] > summary::before { content: '▲ '; }

/* ─── Two-column detail layouts ──────────────────────────────────────────── */
.cols { display: flex; gap: 14px; align-items: flex-start; }
.col-main { flex: 1; min-width: 340px; }
.col-side { width: 440px; flex-shrink: 0; position: sticky; top: 72px; }
.col-rail { width: 220px; flex-shrink: 0; }
@media (max-width: 860px) {
  .cols { flex-direction: column; }
  .col-side, .col-rail { width: 100%; position: static; }
}

/* Months rail (zachováno pro fallback, ale supplier detail teď používá pill-switcher) */
.rail-head {
  padding: 14px 16px 8px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--kh-ink-3);
}
.rail-table { width: 100%; }
.rail-table td, .rail-table th {
  padding: 8px 16px; border-bottom: none; border-top: 1px solid var(--kh-border-soft);
  white-space: nowrap; font-size: 12px;
}
.rail-table th { background: transparent; }
.rail-table tr { cursor: pointer; }
.rail-table tr.is-active { background: var(--accent-soft); }
.rail-table tr.is-active td:first-child { color: var(--accent); font-weight: 600; }

/* ─── Incoming detail: confidence card (full colored bg) ─────────────────── */
.confidence { border: none; color: #fff; box-shadow: none; }
.confidence--ok    { background: var(--kh-pos-bg); color: var(--kh-pos); }
.confidence--ok strong, .confidence--ok b, .confidence--ok .conf-val { color: var(--kh-pos); }
.confidence--warn  { background: var(--kh-warn); color: #fff; }
.confidence--err   { background: var(--accent); color: #fff; }
.confidence strong, .confidence b { color: inherit; }
.confidence .conf-val { font-weight: 900; font-size: 15px; }
.confidence ul { margin: 10px 0 0; padding-left: 20px; }
.confidence li, .confidence p { color: inherit; opacity: .92; }
.confidence--ok li, .confidence--ok p { opacity: .85; }

/* QR card */
.qr-card { text-align: center; }
.qr-card svg, .qr-card img { display: block; margin: 0 auto; }

/* PDF preview frame */
.pdf-frame { width: 100%; height: 72vh; border: 0; border-radius: var(--r-sm); display: block; }

/* ─── Dropzone (upload) ──────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--kh-border); border-radius: var(--r-md);
  padding: 40px; text-align: center; cursor: pointer;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
  background: var(--kh-bg);
}
.dropzone:hover { border-color: var(--accent); background: var(--kh-bg-panel); }
.dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); }

/* ─── Icon button (např. odebrání řádku) ─────────────────────────────────── */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; min-width: 28px; padding: 0 8px;
  background: var(--kh-bg); color: var(--kh-ink-3);
  border: 1px solid var(--kh-border); border-radius: var(--r-sm);
  font-size: 14px; line-height: 1; cursor: pointer; box-shadow: none;
}
.icon-btn:hover { background: var(--kh-bg-hover); color: var(--kh-ink); opacity: 1; }

/* ─── Product search dropdown (invoice form) ─────────────────────────────── */
.psearch-box {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: var(--kh-bg);
  border: 1px solid var(--kh-border); border-top: 0;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  max-height: 300px; overflow: auto;
  box-shadow: var(--shadow-card-hover);
  display: none;
}
.psearch-box > div {
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--kh-border-soft); font-size: 12px;
}
.psearch-box > div:last-child { border-bottom: none; }
.psearch-box > div:hover { background: var(--kh-bg-hover); }

/* ─── Login ──────────────────────────────────────────────────────────────── */
.auth-card { max-width: 380px; margin: 64px auto; }
.auth-card h1 { text-align: center; margin-bottom: 20px; font-style: italic; font-size: 22px; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(31, 35, 40, .45);
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 460px;
  background: var(--kh-bg);
  border: 1px solid var(--kh-border);
  border-radius: var(--r-md);
  padding: 24px;
  box-shadow: var(--shadow-card-hover);
}

/* Vystavené faktury — pomocné */
.count-foot { font-size: 11px; color: var(--kh-ink-3); margin-top: 8px; text-align: right; }

/* ============================================================================
   Help Jipos — extensions
   Sdílíme tokeny a app-bar z Fakturace, přidáváme komponenty pro dokumentaci:
   login shell, hub grid (rozcestník), tree sidebar, prose render, editor shell.
   ========================================================================== */

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-shell {
  display: flex; align-items: center; justify-content: center;
  min-height: 70vh;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--kh-bg);
  border: 1px solid var(--kh-border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
}
.login-brand {
  font-weight: 800; font-style: italic; font-size: 22px;
  letter-spacing: -0.03em; text-align: center;
}
.login-brand b { color: var(--kh-ink); }
.login-brand i { color: var(--accent); }
.login-tagline {
  text-align: center; color: var(--kh-ink-3);
  font-size: 12px; margin: 4px 0 24px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field__label {
  font-size: 11px; font-weight: 600; color: var(--kh-ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.field input[type=text],
.field input[type=password] {
  padding: 9px 12px;
  border: 1px solid var(--kh-border); border-radius: var(--r-sm);
  font-family: inherit; font-size: 14px;
  transition: border-color 130ms var(--ease), box-shadow 130ms var(--ease);
}
.field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ─── Hub (rozcestník) ────────────────────────────────────────────────────── */
.hub-header { margin-bottom: 24px; }
.hub-header h1 { font-size: 28px; }
.hub-header .muted { color: var(--kh-ink-3); margin-top: 4px; }
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.hub-card {
  --accent: var(--accent);
  display: block;
  padding: 22px;
  background: var(--kh-bg);
  border: 1px solid var(--kh-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  color: inherit;
  transition: box-shadow 160ms var(--ease), transform 160ms var(--ease);
}
.hub-card:hover {
  text-decoration: none;
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}
.hub-card h2 {
  font-size: 16px; font-weight: 700;
  margin: 0 0 6px;
}
.hub-card p {
  margin: 0; font-size: 13px; color: var(--kh-ink-3); line-height: 1.5;
}
.hub-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state {
  text-align: center; padding: 64px 24px;
  border: 2px dashed var(--kh-border-soft);
  border-radius: var(--r-lg);
  color: var(--kh-ink-3);
}
.empty-state p { margin: 0 0 6px; }
.empty-state .btn { margin-top: 16px; }

/* ─── Tree sidebar (editor + section view) ────────────────────────────────── */
.tree-shell { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.tree-sidebar {
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px); overflow-y: auto;
  padding-right: 8px;
  font-size: 13px;
}
.tree-section { margin-bottom: 8px; }
.tree-section__head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--kh-ink-3); cursor: pointer; user-select: none;
}
.tree-section__head::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.tree-list { list-style: none; padding: 0; margin: 0 0 0 14px; }
.tree-item {
  display: flex; align-items: center;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--kh-ink-2);
  cursor: pointer;
}
.tree-item:hover { background: var(--kh-bg-hover); text-decoration: none; color: var(--kh-ink); }
.tree-item.is-active {
  background: var(--accent-soft); color: var(--md-on-primary-container);
  font-weight: 600;
}
.tree-add {
  display: block; margin-top: 12px;
  padding: 6px 10px;
  font-size: 12px; color: var(--kh-ink-3);
  border: 1px dashed var(--kh-border); border-radius: var(--r-sm);
  text-align: center;
}
.tree-add:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ─── Prose (rendered markdown) ───────────────────────────────────────────── */
.prose {
  max-width: 760px;
  font-size: 15px; line-height: 1.65; color: var(--kh-ink);
}
.prose h1 { font-size: 28px; font-style: normal; margin: 0 0 16px; letter-spacing: -0.02em; }
.prose h2 { font-size: 20px; font-weight: 700; margin: 32px 0 12px; letter-spacing: -0.01em; }
.prose h3 { font-size: 16px; font-weight: 700; margin: 24px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose a { color: var(--accent); border-bottom: 1px solid transparent; }
.prose a:hover { border-bottom-color: var(--accent); text-decoration: none; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 24px; }
.prose li { margin-bottom: 4px; }
.prose img { max-width: 100%; border-radius: var(--r-sm); margin: 8px 0; }
.prose code {
  background: var(--kh-bg-panel); border: 1px solid var(--kh-border-soft);
  padding: 1px 6px; border-radius: 4px; font-size: 13px;
}
.prose pre {
  background: var(--kh-bg-panel); border: 1px solid var(--kh-border);
  border-radius: var(--r-sm);
  padding: 12px 14px; overflow-x: auto; font-size: 13px;
}
.prose pre code { background: transparent; border: none; padding: 0; }
.prose blockquote {
  margin: 0 0 14px; padding: 8px 14px;
  background: var(--kh-bg-panel);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--kh-ink-2);
}
.prose table {
  border-collapse: collapse; width: 100%; margin: 0 0 14px;
  font-size: 13px;
}
.prose th, .prose td {
  border: 1px solid var(--kh-border);
  padding: 6px 10px; text-align: left;
}
.prose th { background: var(--kh-bg-panel); font-weight: 700; }

/* ─── Page (view) header ──────────────────────────────────────────────────── */
.doc-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 20px;
  padding-bottom: 16px; border-bottom: 1px solid var(--kh-border-soft);
}
.doc-head h1 { font-style: normal; font-size: 26px; }
.doc-head__sub { font-size: 13px; color: var(--kh-ink-3); margin-top: 4px; }
.doc-head__actions { display: flex; gap: 8px; }

/* ─── Editor shell ────────────────────────────────────────────────────────── */
.editor-shell { display: flex; flex-direction: column; gap: 14px; }
.editor-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .editor-meta { grid-template-columns: 1fr; } }
.editor-body { min-height: 60vh; }
.editor-actions {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--kh-border-soft);
}
.save-status {
  margin-left: auto; font-size: 12px; color: var(--kh-ink-3);
}
.save-status.is-dirty { color: var(--kh-warn); }
.save-status.is-saved { color: var(--kh-pos); }
.save-status.is-error { color: var(--kh-neg); }

.advanced-panel {
  margin-top: 14px;
  border: 1px solid var(--kh-border-soft); border-radius: var(--r-md);
  background: var(--kh-bg-panel);
}
.advanced-panel > summary {
  cursor: pointer; padding: 10px 14px;
  font-size: 12px; font-weight: 600; color: var(--kh-ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  user-select: none;
}
.advanced-panel[open] > summary { border-bottom: 1px solid var(--kh-border-soft); }
.advanced-body { padding: 14px; display: grid; gap: 12px; }
.advanced-body textarea {
  width: 100%; min-height: 240px; padding: 10px;
  font-family: 'Roboto Mono', ui-monospace, monospace; font-size: 12px;
  border: 1px solid var(--kh-border); border-radius: var(--r-sm);
}

/* ─── Embedded HTML page ──────────────────────────────────────────────────── */
.embedded-frame {
  width: 100%; height: calc(100vh - 180px); border: 1px solid var(--kh-border);
  border-radius: var(--r-md); background: var(--kh-bg);
}

/* ─── Search modal (Cmd+K) ───────────────────────────────────────────────── */
.search-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh; }
.search-modal[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 22, 0.55); backdrop-filter: blur(4px); }
.search-shell {
  position: relative; width: min(720px, 92vw);
  background: var(--kh-bg); border: 1px solid var(--kh-border);
  border-radius: var(--r-lg, 12px); box-shadow: 0 24px 64px rgba(0,0,0,0.32);
  overflow: hidden; display: flex; flex-direction: column;
}
#search-input {
  width: 100%; padding: 16px 20px; font-size: 16px;
  border: none; border-bottom: 1px solid var(--kh-border-soft);
  background: transparent; color: var(--kh-ink); outline: none;
}
.search-results { list-style: none; margin: 0; padding: 6px 0; max-height: 60vh; overflow-y: auto; }
.search-results:empty { display: none; }
.search-result { display: block; padding: 10px 20px; color: inherit; cursor: pointer; border-left: 3px solid transparent; }
.search-result:hover, .search-result.is-active { background: var(--kh-bg-panel); border-left-color: var(--accent, #D81E1F); text-decoration: none; }
.search-result__title { font-weight: 600; color: var(--kh-ink); }
.search-result__section { font-size: 12px; color: var(--kh-ink-3); margin-right: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.search-result__snippet { font-size: 13px; color: var(--kh-ink-2); margin-top: 2px; }
.search-result__snippet mark { background: rgba(216, 30, 31, 0.18); color: inherit; padding: 0 2px; border-radius: 2px; }
.search-results__empty { padding: 24px 20px; color: var(--kh-ink-3); font-style: italic; text-align: center; }
.search-footer {
  display: flex; gap: 16px; padding: 10px 20px; font-size: 11px; color: var(--kh-ink-3);
  border-top: 1px solid var(--kh-border-soft); background: var(--kh-bg-panel);
}
