/* ==========================================================================
   HUF & PARTNERS – vzhled aplikace
   Komponenty jsou napsané v čistém CSS, aby aplikace vypadala správně i kdyby
   se nepodařilo načíst Tailwind z CDN. Tailwind se používá na rozvržení.
   ========================================================================== */

:root {
    --bg:           #f5f5f7;
    --bg-elevated:  #ffffff;
    --bg-sunken:    #fafafa;
    --surface:      #ffffff;
    --surface-hover:#f5f5f7;
    --text:         #1d1d1f;
    --text-muted:   #6e6e73;
    --text-subtle:  #86868b;
    --border:       #e3e3e6;
    --border-strong:#d2d2d7;
    --accent:       #0071e3;
    --accent-hover: #0077ed;
    --accent-soft:  #eaf3ff;
    --green:        #1a8a4e;
    --green-soft:   #e7f6ed;
    --amber:        #a1660a;
    --amber-soft:   #fdf3e0;
    --red:          #c9342c;
    --red-soft:     #fdeceb;
    --purple:       #6b3fd4;

    --radius-lg: 18px;
    --radius:    12px;
    --radius-sm: 9px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow:    0 1px 3px rgba(0, 0, 0, .05), 0 8px 24px -14px rgba(0, 0, 0, .12);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, .06), 0 24px 48px -24px rgba(0, 0, 0, .22);

    --ease: cubic-bezier(.32, .72, 0, 1);
}

.dark {
    --bg:           #000000;
    --bg-elevated:  #1c1c1e;
    --bg-sunken:    #0a0a0a;
    --surface:      #1c1c1e;
    --surface-hover:#2c2c2e;
    --text:         #f5f5f7;
    --text-muted:   #a1a1a6;
    --text-subtle:  #86868b;
    --border:       #2c2c2e;
    --border-strong:#3a3a3c;
    --accent:       #0a84ff;
    --accent-hover: #409cff;
    --accent-soft:  #16283d;
    --green:        #32d74b;
    --green-soft:   #122a19;
    --amber:        #ffd60a;
    --amber-soft:   #2e2510;
    --red:          #ff453a;
    --red-soft:     #2e1614;
    --purple:       #bf5af2;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow:    0 1px 3px rgba(0, 0, 0, .5), 0 8px 24px -14px rgba(0, 0, 0, .8);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, .5), 0 24px 48px -24px rgba(0, 0, 0, .9);
}

/* ------------------------------------------------------------------ základ */

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

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

/* Atribut hidden musí přebít i komponenty, které nastavují display (např. .alert) */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -.021em;
    line-height: 1.2;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }

::selection { background: var(--accent); color: #fff; }

/* Čísla vždy tabulkově, ať se sloupce nerozjíždějí */
.tnum, table td, table th, .metric-value { font-variant-numeric: tabular-nums; }

/* Jemný scrollbar v Apple stylu */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border: 3px solid transparent;
    border-radius: 99px;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: content-box; }

/* ------------------------------------------------------------------- typografie */

.page-title {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -.024em;
}
.page-subtitle { color: var(--text-subtle); font-size: 14px; margin-top: 2px; }

.section-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.018em;
}

.label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.hint { font-size: 12.5px; color: var(--text-subtle); margin-top: 5px; line-height: 1.45; }
.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

/* ---------------------------------------------------------------------- karty */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}
.card-body { padding: 20px 22px; }
.card-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--bg-sunken);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.dark .card-footer { background: rgba(255, 255, 255, .02); }

/* Metrická karta na dashboardu */
.metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.metric-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-subtle);
    display: flex;
    align-items: center;
    gap: 7px;
}
.metric-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.026em;
    margin-top: 8px;
    line-height: 1.15;
}
.metric-value.sm { font-size: 21px; }
.metric-sub { font-size: 12.5px; color: var(--text-subtle); margin-top: 4px; }

/* -------------------------------------------------------------------- tlačítka */

.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-bd: var(--border-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: -.01em;
    color: var(--btn-fg);
    background: var(--btn-bg);
    border: 1px solid var(--btn-bd);
    border-radius: 980px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s var(--ease), border-color .18s var(--ease),
                transform .12s var(--ease), opacity .18s var(--ease);
    -webkit-user-select: none;
    user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* Tlačítko udělané z <label> (výběr souboru) nelze zneaktivnit atributem disabled. */
.btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }

.btn-primary { --btn-bg: var(--accent); --btn-fg: #fff; --btn-bd: var(--accent); }
.btn-primary:hover:not(:disabled) { --btn-bg: var(--accent-hover); --btn-bd: var(--accent-hover); }

.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost { --btn-bd: transparent; --btn-bg: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }

.btn-danger { --btn-bg: transparent; --btn-fg: var(--red); --btn-bd: color-mix(in srgb, var(--red) 35%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); }

.btn-danger-solid { --btn-bg: var(--red); --btn-fg: #fff; --btn-bd: var(--red); }
.btn-danger-solid:hover:not(:disabled) { opacity: .88; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 7px; border-radius: 50%; }
.btn-block { width: 100%; }

/* Textový odkaz-akce v tabulce */
.action-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 7px;
    transition: background .15s var(--ease), color .15s var(--ease);
    white-space: nowrap;
    display: inline-block;
}
.action-link:hover { background: var(--surface-hover); color: var(--text); }
.action-link.is-primary { color: var(--accent); }
.action-link.is-danger:hover { background: var(--red-soft); color: var(--red); }

/* --------------------------------------------------------------- formuláře */

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
    appearance: none;
}
.dark .input, .dark .select, .dark .textarea { background: #000; }

.input:hover, .select:hover, .textarea:hover { border-color: var(--text-subtle); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--bg-sunken);
    color: var(--text-subtle);
    cursor: not-allowed;
}
.input.is-invalid, .select.is-invalid {
    border-color: var(--red);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 15%, transparent);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.55; }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2386868b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

/* Pole s příponou (Kč, %) */
.input-affix { position: relative; display: block; }
.input-affix .input { padding-right: 44px; }
.input-affix::after {
    content: attr(data-affix);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-subtle);
    pointer-events: none;
}

/* Pole dopočítané aplikací – vizuálně odlišené, ale editovatelné */
.input.is-computed { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.dark .input.is-computed { background: var(--accent-soft); }
.input.is-overridden { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }

.field-error { font-size: 12.5px; color: var(--red); margin-top: 5px; font-weight: 500; }

.required::after { content: " *"; color: var(--red); font-weight: 600; }

.checkbox, .radio {
    appearance: none;
    width: 19px; height: 19px;
    flex: 0 0 19px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: var(--bg-elevated);
    cursor: pointer;
    position: relative;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.radio { border-radius: 50%; }
.checkbox:checked, .radio:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 19 19'%3E%3Cpath fill='none' stroke='white' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round' d='M5 9.7l2.9 2.9L14.2 6.3'/%3E%3C/svg%3E") center/contain no-repeat;
}
.radio:checked::after {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: #fff;
}
.checkbox:focus-visible, .radio:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s var(--ease);
    font-size: 14px;
}
.check-row:hover { background: var(--surface-hover); }

/* Přepínač (segmented control) v Apple stylu */
.segmented {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.dark .segmented { background: rgba(255, 255, 255, .05); }
.segmented a, .segmented button {
    padding: 5px 13px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.segmented a:hover, .segmented button:hover { color: var(--text); }
.segmented .is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.dark .segmented .is-active { background: var(--surface-hover); }

/* --------------------------------------------------------------- tabulky */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}
table.data th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .045em;
    text-transform: uppercase;
    color: var(--text-subtle);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data th.sortable { cursor: pointer; -webkit-user-select: none; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .sort-arrow {
    display: inline-block;
    width: 0; height: 0;
    margin-left: 5px;
    vertical-align: middle;
    opacity: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    transition: opacity .15s var(--ease);
}
table.data th[aria-sort="ascending"]  .sort-arrow { opacity: 1; border-bottom: 5px solid currentColor; }
table.data th[aria-sort="descending"] .sort-arrow { opacity: 1; border-top: 5px solid currentColor; }
table.data th.sortable:hover .sort-arrow { opacity: .4; border-bottom: 5px solid currentColor; }
table.data th[aria-sort]:hover .sort-arrow { opacity: 1; }

table.data td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    /* Datové tabulky se raději posouvají do strany, než aby se lámaly do řádků */
    white-space: nowrap;
}

/* Dlouhé texty (klient, odběratel, poznámka) se smí zalomit nebo zkrátit */
table.data td.wrap {
    white-space: normal;
    min-width: 11rem;
}
table.data td.clip {
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hlášení pod polem se musí zalomit, jinak by ho nezalamovaná buňka odřízla */
table.data td .field-error,
table.data td .hint {
    white-space: normal;
    max-width: 18rem;
}
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .strong { font-weight: 600; }

/* Souhrnný řádek */
table.data tfoot td {
    padding: 13px 14px;
    font-weight: 600;
    background: var(--bg-sunken);
    border-top: 2px solid var(--border-strong);
    border-bottom: 0;
}
.dark table.data tfoot td { background: rgba(255, 255, 255, .03); }
table.data tfoot tr:first-child td:first-child { border-radius: 0 0 0 var(--radius-lg); }
table.data tfoot tr:last-child td:last-child  { border-radius: 0 0 var(--radius-lg) 0; }

/* Zvýraznění řádků v náhledu importu */
tr.row-error   { background: var(--red-soft)   !important; }
tr.row-warning { background: var(--amber-soft) !important; }
tr.row-skip    { opacity: .45; }
tr.row-ok      { background: transparent; }

/* ---------------------------------------------------------------- odznaky */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 980px;
    white-space: nowrap;
    line-height: 1.45;
}
.badge-neutral { background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border); }
.dark .badge-neutral { background: rgba(255, 255, 255, .06); }
.badge-blue   { background: var(--accent-soft); color: var(--accent); }
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber); }
.badge-red    { background: var(--red-soft);    color: var(--red); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; display: inline-block; }

/* ------------------------------------------------------------ upozornění */

.alert {
    display: flex;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid transparent;
}
.alert-icon { flex: 0 0 18px; margin-top: 1px; }
.alert-info    { background: var(--accent-soft); color: var(--accent);
                 border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.alert-success { background: var(--green-soft);  color: var(--green);
                 border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.alert-warning { background: var(--amber-soft);  color: var(--amber);
                 border-color: color-mix(in srgb, var(--amber) 28%, transparent); }
.alert-error   { background: var(--red-soft);    color: var(--red);
                 border-color: color-mix(in srgb, var(--red) 22%, transparent); }
.alert strong { font-weight: 600; }
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* Plovoucí oznámení po uložení */
.toast-stack {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(30rem, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 16px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    animation: toast-in .45s var(--ease) both;
}
.toast.is-leaving { animation: toast-out .3s var(--ease) both; }
.toast-success .toast-mark { color: var(--green); }
.toast-error   .toast-mark { color: var(--red); }
.toast-warning .toast-mark { color: var(--amber); }
.toast-info    .toast-mark { color: var(--accent); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* ------------------------------------------------------------------- navigace */

.sidebar {
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-right: 1px solid var(--border);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 450;
    color: var(--text-muted);
    transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-link svg { flex: 0 0 18px; opacity: .85; }
.nav-link.is-active svg { opacity: 1; }
.nav-count {
    margin-left: auto;
    font-size: 11.5px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 980px;
    background: var(--border);
    color: var(--text-muted);
}
.nav-link.is-active .nav-count { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.nav-count.is-alert { background: var(--red); color: #fff; }

.nav-group {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-subtle);
    padding: 0 11px;
    margin: 22px 0 7px;
}

.topbar {
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
}

/* Mobilní zásuvka */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(2px);
    z-index: 60;
    opacity: 0;
    transition: opacity .3s var(--ease);
}
.drawer-backdrop.is-open { opacity: 1; }

@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 274px;
        z-index: 70;
        transform: translateX(-100%);
        transition: transform .38s var(--ease);
        background: var(--surface);
    }
    .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
}

/* --------------------------------------------------------------- dialogy */

dialog.modal {
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    width: min(30rem, calc(100vw - 32px));
    animation: modal-in .32s var(--ease) both;
}
dialog.modal::backdrop {
    background: rgba(0, 0, 0, .38);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
@keyframes modal-in { from { opacity: 0; transform: scale(.94) translateY(10px); } }

.modal-body { padding: 22px 24px 18px; }
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -.018em; }
.modal-text { font-size: 14px; color: var(--text-muted); margin-top: 7px; line-height: 1.55; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    padding: 14px 24px 18px;
}

/* ------------------------------ srovnání nahraného PDF a vytěžených údajů */

/* Okno jde skoro přes celou obrazovku – faktura potřebuje co nejvíc místa. */
dialog.modal.modal-review {
    width: calc(100vw - 28px);
    max-width: none;
    height: calc(100vh - 28px);
    display: flex;
    flex-direction: column;
}
.review-head    { flex: 0 0 auto; padding: 15px 22px 12px; }
.review-actions { flex: 0 0 auto; padding: 12px 22px 15px; }
.review-split {
    flex: 1 1 auto;
    min-height: 0;               /* bez toho by grid přetekl místo scrollování */
    display: grid;
    /* Velikost stránky určuje výška okna, ne šířka – přebytek šířky proto
       dostane pravý sloupec, aby se v údajích méně scrollovalo. */
    grid-template-columns: minmax(0, 1fr) minmax(25rem, 38rem);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.review-pdf {
    min-width: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-sunken);
}
.review-pdf iframe { width: 100%; height: 100%; border: 0; display: block; }
.review-fields { min-width: 0; overflow: auto; padding: 10px 16px 14px; }

/* Na úzkém okně nemá smysl dělit na sloupce – faktura jde nad údaje. */
@media (max-width: 900px) {
    .review-split {
        grid-template-columns: minmax(0, 1fr);
        /* Vedle sebe to nejde, takže víc místa dostanou údaje – u nich se
           rozhoduje. Fakturu si lze otevřít v nové kartě. */
        grid-template-rows: minmax(0, 34vh) minmax(0, 1fr);
    }
    .review-pdf { border-right: 0; border-bottom: 1px solid var(--border); }
    /* Čtyři prvky se do jedné řady nevejdou – počet vybraných jde na svůj řádek */
    .review-actions { flex-wrap: wrap; }
    .review-actions [data-review-count] { width: 100%; margin: 0 0 2px; }
}

/* ------------------------------------------------------------------- grafy */

.chart-bar {
    transition: opacity .18s var(--ease);
    cursor: default;
}
.chart:hover .chart-bar { opacity: .45; }
.chart .chart-bar:hover { opacity: 1; }

.chart-grid line { stroke: var(--border); stroke-width: 1; }
.chart-axis text { fill: var(--text-subtle); font-size: 10.5px; font-weight: 500; }

.donut-seg { transition: opacity .18s var(--ease); }
.donut:hover .donut-seg { opacity: .4; }
.donut .donut-seg:hover { opacity: 1; }

.legend-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 0;
    font-size: 13.5px;
}
.legend-row .legend-value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Vodorovný ukazatel podílu */
.meter { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; transition: width .6s var(--ease); }

/* -------------------------------------------------------------- prázdné stavy */

.empty {
    text-align: center;
    padding: 52px 24px;
}
.empty-icon {
    width: 46px; height: 46px;
    margin: 0 auto 14px;
    color: var(--text-subtle);
    opacity: .55;
}
.empty-title { font-size: 16px; font-weight: 600; }
.empty-text { color: var(--text-subtle); font-size: 14px; margin-top: 5px; }

/* --------------------------------------------------------------- pomocné */

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

.kv { display: grid; grid-template-columns: minmax(9rem, auto) 1fr; gap: 11px 20px; font-size: 14.5px; }
.kv dt { color: var(--text-subtle); }
.kv dd { margin: 0; font-weight: 500; }

.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 13px; }

.muted { color: var(--text-subtle); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.fade-in { animation: fade-in .4s var(--ease) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

/* Odkaz pro přeskočení na obsah – přístupnost */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.skip-link:focus { left: 8px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------------------------------------------------------------------- tisk */

@media print {
    :root {
        --bg: #fff; --surface: #fff; --bg-sunken: #fff;
        --text: #000; --text-muted: #333; --text-subtle: #555;
        --border: #bbb; --border-strong: #888;
    }
    body { background: #fff; font-size: 10.5pt; }

    .no-print, .sidebar, .topbar, .toast-stack, .drawer-backdrop { display: none !important; }

    .print-only { display: block !important; }

    main { padding: 0 !important; margin: 0 !important; max-width: none !important; }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
        break-inside: avoid;
        border-radius: 0;
    }
    .metric { box-shadow: none; border: 1px solid #ccc; border-radius: 0; }

    table.data { font-size: 9pt; }
    table.data th {
        position: static;
        background: #f0f0f0 !important;
        color: #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    table.data td, table.data th { padding: 5px 7px; }
    table.data thead { display: table-header-group; }
    table.data tr { break-inside: avoid; }
    table.data tfoot td { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    .badge { border: 1px solid #999; }
    a { color: #000; text-decoration: none; }

    @page { margin: 12mm; size: A4 landscape; }
}

.print-only { display: none; }

