  :root {
    --accent: #1e3a5f;
    --accent-light: #3b5a85;
    --accent-pale: #eef2f8;
    --paper: #fafaf7;
    --ink: #1c1917;
    --ink-muted: #57534e;
    --line: #e7e5e4;
    --line-strong: #d6d3d1;
    --warn: #b45309;
    --warn-bg: #fef3c7;
    --err: #b91c1c;
    --ok: #047857;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--paper); color: var(--ink);
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 14px; line-height: 1.5;
  }
  .font-display { font-family: 'Newsreader', Georgia, serif; letter-spacing: -0.01em; }
  .font-mono { font-family: 'IBM Plex Mono', monospace; }
  button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
  input, select, textarea { font-family: inherit; font-size: 14px; }

  /* HEADER */
  header { background: #fff; border-bottom: 1px solid var(--line-strong); }
  .hdr-inner { max-width: 1280px; margin: 0 auto; padding: 16px 24px; display: flex; justify-content: space-between; align-items: flex-start; }
  .hdr-title { font-family: 'Newsreader', serif; font-size: 26px; line-height: 1.15; margin: 4px 0 0; font-weight: 600; }
  .hdr-title em { font-style: italic; font-weight: 400; color: var(--ink-muted); }
  .hdr-title .accent { color: var(--accent); }
  .hdr-eyebrow { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-muted); font-weight: 500; }
  .hdr-actions { display: flex; gap: 8px; }
  .tabs { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; gap: 2px; }
  .tab {
    padding: 10px 16px; font-size: 14px; font-weight: 500; color: var(--ink-muted);
    border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 8px;
    transition: all 0.15s;
  }
  .tab:hover { color: var(--ink); }
  .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
  .tab-sep {
    width: 1px; background: var(--line-strong); margin: 6px 12px;
    display: inline-block; align-self: stretch;
  }

  /* GLOBAL SEARCH */
  .search-global-wrap {
    position: relative; flex: 0 1 320px; min-width: 200px;
  }
  .search-global-wrap > svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--ink-muted); pointer-events: none; width: 14px; height: 14px;
  }
  .search-global {
    width: 100%; padding: 7px 32px 7px 32px;
    background: #fafaf7; border: 1px solid var(--line);
    border-radius: 6px; font-size: 13px;
    transition: all 0.15s;
  }
  .search-global:focus {
    background: #fff; border-color: var(--accent); outline: none;
    box-shadow: 0 0 0 3px rgba(56, 122, 174, 0.1);
  }
  .search-global-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border-radius: 4px; border: 0; background: transparent;
    color: var(--ink-muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  }
  .search-global-clear:hover { background: rgba(0,0,0,0.06); color: var(--ink); }
  .search-results {
    position: absolute; top: calc(100% + 6px); right: 0; left: 0;
    min-width: 380px; max-width: 480px; max-height: 70vh; overflow-y: auto;
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    z-index: 100; padding: 6px;
  }
  .search-section { margin-bottom: 6px; }
  .search-section:last-child { margin-bottom: 0; }
  .search-section h5 {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--ink-muted);
    margin: 4px 8px 4px; padding: 0;
  }
  .search-row {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; padding: 7px 8px; border: 0; background: transparent;
    border-radius: 4px; cursor: pointer; text-align: left;
    font-size: 13px; color: var(--ink);
  }
  .search-row:hover { background: #f5f5f4; }
  .search-row-meta {
    font-size: 11px; color: var(--ink-muted); flex-shrink: 0; margin-left: 12px;
  }
  .search-empty {
    padding: 16px; text-align: center; color: var(--ink-muted); font-size: 13px;
  }
  .search-more {
    padding: 4px 8px; font-size: 11px; color: var(--ink-muted); font-style: italic;
  }

  /* Status žáka v selectu - barevné rozlišení */
  .zak-status-select { font-size: 12px !important; }

  /* MAIN */
  main { max-width: 1280px; margin: 0 auto; padding: 32px 24px; }
  h2.page-title { font-family: 'Newsreader', serif; font-size: 30px; font-weight: 600; margin: 0 0 4px; }
  .page-subtitle { color: var(--ink-muted); font-size: 13px; margin: 0 0 24px; }

  /* BUTTONS */
  .btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; font-size: 14px; font-weight: 500;
    background: var(--accent); color: #fff; border-radius: 6px;
    transition: background 0.15s;
  }
  .btn-primary:hover { background: var(--accent-light); }
  .btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 13px; font-weight: 500;
    color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px;
    background: #fff; transition: all 0.15s;
  }
  .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
  .btn-link { color: var(--accent); font-size: 13px; }
  .btn-link:hover { text-decoration: underline; }
  .btn-link-muted { color: var(--ink-muted); font-size: 12px; }
  .btn-link-muted:hover { color: var(--accent); }
  .icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 4px; color: var(--ink-muted);
    transition: all 0.15s;
  }
  .icon-btn:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
  .icon-btn.danger:hover { color: var(--err); background: #fee2e2; }
  .icon-btn.ok:hover { color: var(--ok); background: #d1fae5; }
  .icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

  /* INPUTS */
  .input, input[type=text], input[type=number], input[type=date], input[type=time], select, textarea.input {
    width: 100%; padding: 8px 10px; font-size: 14px;
    border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink);
    transition: all 0.15s;
  }
  .input:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
  }
  .input-cell {
    width: 100%; padding: 4px 8px; font-size: 14px;
    border: 1px solid var(--line); border-radius: 4px; background: #fff;
  }
  .input-cell:focus { outline: none; border-color: var(--accent); }
  textarea.input { resize: vertical; min-height: 60px; }
  label.field-label {
    display: block; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--ink-muted); font-weight: 500; margin-bottom: 4px;
  }

  /* TABLES */
  table.data {
    width: 100%; border-collapse: collapse; background: #fff;
    border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  }
  table.data thead { background: #f5f5f4; border-bottom: 1px solid var(--line); }
  table.data th {
    padding: 10px 16px; text-align: left; font-size: 11px; letter-spacing: 0.05em;
    text-transform: uppercase; font-weight: 500; color: var(--ink-muted);
  }
  table.data td { padding: 8px 16px; border-bottom: 1px solid #f5f5f4; vertical-align: middle; }
  table.data tbody tr:hover { background: #fafaf7; }
  table.data tbody tr.editing { background: #fffbeb; }
  table.data tbody tr:last-child td { border-bottom: 0; }
  td.actions { display: flex; gap: 4px; padding: 4px 8px; }

  /* CARDS */
  .card {
    background: #fff; border: 1px solid var(--line); border-radius: 8px;
    padding: 20px; margin-bottom: 20px;
  }
  .card-title {
    font-family: 'Newsreader', serif; font-size: 17px; font-weight: 600;
    margin: 0 0 14px; color: var(--ink);
  }
  .card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
  .card-header .card-title { margin: 0; }

  /* GRIDS */
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
  .full { grid-column: 1 / -1; }

  /* TŘÍDY tab — plná šířka obrazovky */
  body.tab-tridy main { max-width: none; padding-left: 32px; padding-right: 32px; }

  /* Pills s třídami nahoře (místo sidebaru) */
  .tridy-pills {
    display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
    padding: 12px; margin-bottom: 20px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
  }
  .tridy-pills .trida-pill {
    padding: 8px 14px; border-radius: 999px;
    background: var(--paper); border: 1px solid var(--line);
    transition: all 0.15s; cursor: pointer;
    display: flex; gap: 8px; align-items: baseline;
    font-family: inherit;
  }
  .tridy-pills .trida-pill:hover { background: #f5f5f4; border-color: var(--line-strong); }
  .tridy-pills .trida-pill.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
  }
  .tridy-pills .trida-pill.active .trida-pill-sub { color: rgba(255,255,255,0.8); }
  .tridy-pills .trida-pill-name { font-family: 'Newsreader', serif; font-size: 15px; font-weight: 600; }
  .tridy-pills .trida-pill-sub { font-size: 11px; color: var(--ink-muted); }
  .tridy-pills .trida-pill-add {
    padding: 8px 14px; border-radius: 999px;
    background: var(--accent-pale); border: 1px dashed var(--accent);
    color: var(--accent); font-weight: 500; cursor: pointer; font-family: inherit;
  }
  .tridy-pills .trida-pill-add:hover { background: #fff; }

  /* Legacy — kept for global search results which still use trida-item */
  .trida-list { display: flex; flex-direction: column; gap: 4px; }
  .trida-item {
    text-align: left; padding: 10px 12px; border-radius: 6px;
    transition: all 0.15s; cursor: pointer; width: 100%;
  }
  .trida-item:hover { background: #f5f5f4; }
  .trida-item.active { background: var(--accent); color: #fff; }
  .trida-item.active .trida-item-sub { color: rgba(255,255,255,0.8); }
  .trida-item-name { font-family: 'Newsreader', serif; font-size: 16px; font-weight: 600; }
  .trida-item-sub { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }
  .sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

  /* ZKOUŠKY */
  .zkouska {
    border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fff;
    margin-bottom: 10px; border-left-width: 4px;
  }
  .zkouska.prakticka { background: #fffbeb55; }
  .zkouska.swap-pair-second { opacity: 0.92; }
  .zkouska-color-bar {
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  }
  .swap-pair-group {
    border: 1px dashed; border-radius: 8px; padding: 8px;
    margin-bottom: 10px;
  }
  .swap-pair-header {
    display: flex; align-items: center; gap: 6px; padding: 4px 8px 6px;
    font-size: 12px; font-weight: 500;
  }
  .swap-pair-group .zkouska { margin-bottom: 6px; }
  .swap-pair-group .zkouska:last-child { margin-bottom: 0; }

  /* COLOR SWATCHES */
  .color-swatch {
    display: inline-block; width: 14px; height: 14px; border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1); vertical-align: middle; margin-right: 6px;
  }
  .color-swatch-pair {
    display: inline-flex; align-items: center; gap: 2px;
  }
  .color-swatch-pair .color-swatch { margin-right: 0; }
  input[type="color"] {
    width: 32px; height: 28px; padding: 2px; border: 1px solid var(--line-strong);
    border-radius: 4px; cursor: pointer; background: #fff;
  }
  input[type="color"]:focus { outline: none; border-color: var(--accent); }
  .zkouska-row1 { display: grid; grid-template-columns: 1fr 80px 80px 60px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
  .zkouska-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .badge {
    display: inline-block; font-size: 10px; font-weight: 600; padding: 4px 8px;
    border-radius: 4px; text-align: center; letter-spacing: 0.04em;
  }
  .badge.ustni { background: #f5f5f4; color: var(--ink-muted); }
  .badge.prakticka { background: #fde68a; color: #92400e; }
  .badge.nav { background: var(--accent-pale); color: var(--accent); }

  /* SEARCH */
  .search-wrap { position: relative; margin-bottom: 16px; }
  .search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #a8a29e; }
  .search-wrap input { padding-left: 34px; }

  /* TOAST */
  .toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100;
    animation: slideIn 0.2s ease-out;
  }
  .toast.success { background: #1c1917; color: #fafaf7; }
  .toast.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
  @keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

  /* MULTI-SELECT */
  .multi-select { display: flex; flex-direction: column; gap: 4px; }
  .multi-row { display: flex; gap: 4px; }
  .multi-row select { flex: 1; }

  /* DOCUMENT PREVIEW */
  .doc-preview {
    background: #fff; border: 1px solid var(--line-strong); margin: 0 auto;
    max-width: 210mm; padding: 20mm;
    font-family: 'Times New Roman', serif; font-size: 11pt; color: #000; line-height: 1.4;
  }
  .doc-preview h2 { text-align: center; font-size: 13pt; font-weight: 700; margin: 0 0 12px; }
  .doc-preview .doc-meta { display: grid; grid-template-columns: 130px 1fr 130px 80px; gap: 4px 8px; margin-bottom: 6px; }
  .doc-preview .doc-times { display: grid; grid-template-columns: 160px 1fr 160px 1fr; gap: 4px 8px; margin: 12px 0 4px; }
  .doc-preview .doc-leadership { display: grid; grid-template-columns: 160px 1fr; gap: 2px 8px; margin: 8px 0 12px; }
  .doc-preview table { width: 100%; border-collapse: collapse; margin-top: 12px; }
  .doc-preview table th { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid #444; font-weight: 700; }
  .doc-preview table td { padding: 4px 8px 4px 0; vertical-align: top; }
  .doc-preview .obor-header { padding: 12px 0 4px !important; font-weight: 700; font-style: italic; }
  .trida-block + .trida-block { page-break-before: always; margin-top: 40px; }
  .doc-signatures { margin-top: 60px; }
  .doc-signatures .row { display: grid; grid-template-columns: 1fr 200px; gap: 16px; margin-bottom: 12px; align-items: end; }
  .doc-signatures .line { border-bottom: 1px solid #444; height: 24px; }

  /* MUTED text helpers */
  .muted { color: var(--ink-muted); }
  .muted-sm { color: var(--ink-muted); font-size: 12px; }
  .center { text-align: center; }
  .right { text-align: right; }
  .warning-row td { background: #fffbeb; }
  .empty-state { text-align: center; padding: 32px; color: var(--ink-muted); font-style: italic; }

  /* MODAL */
  .modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: flex-start; justify-content: center;
    z-index: 100; padding: 5vh 16px; overflow-y: auto;
  }
  .modal {
    background: #fff; border-radius: 8px; padding: 24px;
    max-width: 640px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  }
  .modal h3 {
    font-family: 'Newsreader', serif; font-size: 22px; font-weight: 600;
    margin: 0 0 4px;
  }
  .modal .modal-sub { color: var(--ink-muted); font-size: 13px; margin-bottom: 20px; }
  .modal-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line);
  }
  .modal .field-group { margin-bottom: 14px; }

  /* ZAK PREDMET ROW */
  .zak-predmet-row {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border-radius: 4px; transition: background 0.15s; cursor: pointer;
  }
  .zak-predmet-row:hover { background: #fafaf7; }
  .zak-predmet-row input[type="checkbox"] { margin: 0; cursor: pointer; }
  .zak-predmet-row.checked { background: #fffbeb; }
  .zak-predmet-row select { flex: 0 0 90px; margin-left: auto; padding: 4px 6px; font-size: 13px; }

  /* PREDMET BADGES */
  .predmet-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 6px; border-radius: 3px; font-size: 11px; font-weight: 600;
    color: #fff; margin-right: 4px; margin-bottom: 2px;
    font-family: 'IBM Plex Mono', monospace;
  }
  .predmet-badge.muted { opacity: 0.6; font-weight: 500; }
  .predmet-badge .grp { font-weight: 400; opacity: 0.85; }

  .priprava-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;
    background: var(--warn-bg); color: var(--warn);
  }
  .priprava-badge small { font-size: 10px; font-weight: 400; opacity: 0.7; }

  /* FILTER BAR */
  .filter-bar {
    display: flex; gap: 8px; margin-bottom: 16px; align-items: center;
  }
  .filter-bar select { width: auto; min-width: 160px; }
  .filter-bar .search-wrap { flex: 1; margin-bottom: 0; }
  .filter-bar .badge-count {
    font-size: 12px; color: var(--ink-muted); margin-left: auto;
  }

  /* PŘEHLED — KROKY */
  .kroky { display: flex; flex-direction: column; gap: 10px; }
  .krok {
    display: grid; grid-template-columns: 44px 36px 1fr auto;
    gap: 16px; align-items: center;
    padding: 16px 20px; background: #fff;
    border: 1px solid var(--line); border-radius: 8px;
    border-left-width: 4px;
  }
  .krok.done { border-left-color: var(--ok); }
  .krok.todo { border-left-color: var(--warn); background: #fffdf5; }
  .krok.disabled { opacity: 0.55; border-left-color: var(--line-strong); }
  .krok-cislo {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; font-family: 'Newsreader', serif;
    background: #f5f5f4; color: var(--ink-muted);
  }
  .krok.done .krok-cislo { background: #d1fae5; color: var(--ok); }
  .krok.todo .krok-cislo { background: var(--warn-bg); color: var(--warn); }
  .krok-status { display: flex; align-items: center; }
  .krok.done .krok-status { color: var(--ok); }
  .krok.todo .krok-status { color: var(--warn); }
  .krok.disabled .krok-status { color: var(--ink-muted); }
  .krok-content h4 { margin: 0; font-family: 'Newsreader', serif; font-size: 17px; font-weight: 600; }
  .krok-content p { margin: 2px 0 0; color: var(--ink-muted); font-size: 13px; }
  .krok-content .krok-detail { margin-top: 6px; font-size: 12px; color: var(--warn); }
  .krok.done .krok-detail { color: var(--ok); }

  /* HELP BOX */
  .help-box {
    background: #f0f7ff; border: 1px solid #c7dbf2;
    border-radius: 8px; padding: 14px 16px 14px 14px;
    margin-bottom: 20px; position: relative;
    display: flex; gap: 12px; align-items: flex-start;
  }
  .help-box .help-icon {
    color: var(--accent); flex-shrink: 0; margin-top: 2px;
    width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  }
  .help-box .help-icon svg { width: 18px; height: 18px; }
  .help-box .help-content { flex: 1; padding-right: 24px; }
  .help-box h5 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
  .help-box p { margin: 0; font-size: 13px; line-height: 1.55; color: #1e3a5f; }
  .help-box ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.55; color: #1e3a5f; }
  .help-box ul li { margin-bottom: 2px; }
  .help-box .help-close {
    position: absolute; top: 8px; right: 8px;
    width: 22px; height: 22px; border-radius: 4px;
    color: var(--ink-muted); display: flex; align-items: center; justify-content: center;
  }
  .help-box .help-close:hover { background: rgba(0,0,0,0.06); color: var(--ink); }

  /* STEP NAVIGATION */
  .step-nav {
    margin-top: 32px; padding-top: 20px;
    border-top: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  .step-nav .btn-primary { padding: 10px 18px; font-size: 14px; }
  .step-nav .step-info { color: var(--ink-muted); font-size: 13px; }

  /* STEP LETTER BADGE */
  .step-letter {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); color: #fff;
    font-family: 'Newsreader', serif; font-weight: 700; font-size: 13px;
    margin-right: 8px; vertical-align: middle;
  }

  /* MATRIX TABLE */
  .matrix-table {
    width: 100%; border-collapse: separate; border-spacing: 0; background: #fff;
    font-size: 13px;
  }
  .matrix-table thead th {
    padding: 10px 8px; text-align: center; vertical-align: bottom;
    background: #fafaf7; font-weight: 500; font-size: 12px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 3;
  }
  .matrix-table th.zak-col {
    text-align: left; min-width: 200px;
    position: sticky; left: 0; top: 0;
    background: #fafaf7;
    z-index: 4; /* roh musí překrýt jak řádky tak sloupec */
    border-right: 1px solid var(--line);
  }
  .matrix-table th.blok-col { min-width: 70px; }
  .matrix-table tbody tr:hover { background: #fafaf7; }
  .matrix-table td {
    padding: 6px 4px; text-align: center; border-bottom: 1px solid #f5f5f4;
    vertical-align: middle;
  }
  .matrix-table td.zak-col {
    text-align: left; padding: 6px 12px; position: sticky; left: 0;
    background: #fff; z-index: 1; font-size: 13px;
    border-right: 1px solid var(--line);
  }
  .matrix-table tbody tr:hover td.zak-col { background: #fafaf7; }
  .matrix-table td.blok-cell { padding: 4px; }
  .matrix-table td.blok-cell.checked { font-weight: 600; }
  .matrix-table td.blok-cell input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; margin: 0;
  }
  .matrix-table td.blok-cell .cell-select {
    width: 100%; padding: 4px 6px; font-size: 12px; text-align: center;
    border: 1px solid var(--line); border-radius: 4px; background: #fff;
  }
  .matrix-table tfoot td {
    padding: 8px 12px; background: #fafaf7;
    border-top: 2px solid var(--line); border-bottom: none;
    position: sticky; bottom: 0; z-index: 2;
  }
  .matrix-table tfoot td.zak-col {
    z-index: 3; /* spodní levý roh musí být nad ostatními sticky elementy */
    border-right: 1px solid var(--line);
  }

  @media print {
    header, main > *:not(.doc-preview) { display: none !important; }
    main { padding: 0 !important; max-width: none !important; }
    .doc-preview { border: none !important; padding: 0 !important; max-width: none !important; }
    body { background: #fff; }
    @page { size: A4; margin: 20mm; }
  }

  /* Save status indicator */
  .save-status {
    font-size: 13px; padding: 4px 10px; border-radius: 4px;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s;
    font-family: 'IBM Plex Sans', system-ui, sans-serif; min-width: 0;
    white-space: nowrap;
  }
  .save-status.save-idle    { opacity: 0; }
  .save-status.save-saving  { background: #fef3c7; color: #92400e; }
  .save-status.save-saved   { background: #d1fae5; color: #065f46; }
  .save-status.save-error   { background: #fee2e2; color: #991b1b; }

  /* Login modal */
  #mk-login-modal { position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center; }
  #mk-login-modal .mk-login-backdrop {
    position: absolute; inset: 0; background: rgba(15,23,42,.55);
    backdrop-filter: blur(2px);
  }
  #mk-login-modal .mk-login-card {
    position: relative; background: #fff; border-radius: 12px;
    padding: 28px 32px; width: 360px; max-width: calc(100vw - 32px);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex; flex-direction: column; gap: 12px;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
  }
  #mk-login-modal h2 { margin: 0; font-size: 22px; font-weight: 600; color: #1c1917; }
  #mk-login-modal p { margin: 0; color: #57534e; font-size: 14px; }
  #mk-login-modal input[type=password] {
    padding: 10px 12px; font-size: 15px; border: 1.5px solid #d6d3d1;
    border-radius: 6px; outline: none; font-family: inherit;
  }
  #mk-login-modal input[type=password]:focus { border-color: #0891b2; }
  #mk-login-modal .mk-login-error {
    color: #b91c1c; font-size: 13px; padding: 6px 10px;
    background: #fef2f2; border-radius: 4px;
  }
  #mk-login-modal button {
    padding: 10px 14px; background: #0891b2; color: #fff;
    border: none; border-radius: 6px; font-size: 15px; font-weight: 500;
    cursor: pointer; font-family: inherit;
  }
  #mk-login-modal button:hover { background: #0e7490; }