/* ============================================================
   ÚČTO — vizuální styl
   Černo-žluto-bílá, inspirováno účtenkou/lístkem.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --black: #171512;
    --ink: #211d17;
    --white: #ffffff;
    --paper: #fffefb;
    --yellow: #ffc629;
    --yellow-soft: #fff2cc;
    --yellow-deep: #e3a600;
    --line: #ece2c7;
    --muted: #8a8272;
    --error-bg: #fde2e2;
    --error-text: #8a1f1f;
    --success-bg: #e6f4d7;
    --success-text: #3a5311;
    accent-color: var(--yellow-deep);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(circle at 20% 15%, rgba(255,198,41,0.06), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(255,198,41,0.05), transparent 45%),
        var(--black);
    color: var(--ink);
    margin: 0;
    padding: 28px 14px 60px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---- Branding (logo) ---- */

.brand, .brand-standalone {
    text-decoration: none;
    display: inline-block;
}

.brand-logo {
    display: block;
    height: 38px;
    width: auto;
    border-radius: 4px;
}

.brand-standalone {
    display: block;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.brand-logo-standalone {
    display: block;
    height: 68px;
    width: auto;
    margin: 0 auto;
    border-radius: 8px;
}

.brand-standalone::after {
    content: "";
    display: block;
    width: 46px;
    height: 6px;
    background: var(--yellow);
    margin: 10px auto 0;
    border-radius: 3px;
}

.topbar {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--black);
    padding: 14px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    max-width: min(1080px, 94vw);
    margin: 0 auto;
}

/* Appka má na stránkách s topbarem menu vždy pevně nahoře (position: fixed),
   proto musíme obsahu pod ním udělat místo, ať se pod menu nezasekne. */
body.with-topbar {
    padding-top: 86px;
}

nav {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

nav a {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--white);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s, opacity 0.15s;
}
nav a:hover { border-bottom-color: var(--yellow); }
nav a svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Hamburger tlačítko - vidět jen na mobilu */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    margin: 0;
    width: auto;
    cursor: pointer;
}
.nav-toggle svg {
    width: 26px;
    height: 26px;
    stroke: var(--white);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

/* Administrace je jen pro desktop - na mobilu se v menu neukazuje */
@media (max-width: 768px) {
    .admin-only-desktop { display: none; }
}

/* ---- The "receipt" shell ---- */

.shell {
    background: var(--paper);
    width: 100%;
    max-width: 420px;
    min-width: 0; /* zabraňuje "vyfouknutí" karty přes šířku obrazovky, pokud
                     má vnitřní obsah (např. dlouhý text v tabulce) větší
                     min-content šířku - body je flex a flex položky mají
                     defaultně min-width:auto, který by jinak vyhrál nad
                     max-width */
    border-radius: 14px;
    padding: 30px 24px 34px;
    box-shadow: 0 24px 50px rgba(0,0,0,0.4), 0 2px 0 rgba(255,255,255,0.02) inset;
    position: relative;
}

.shell-wide {
    /* Roste s obrazovkou (na velkém monitoru využije víc místa), ale nikdy
       nepřeteče přes okraj a nikdy nebude zbytečně široké na malém displeji. */
    max-width: min(1080px, 94vw);
}

.shell::before {
    content: "";
    position: absolute;
    top: 0; left: 26px; right: 26px;
    border-top: 2px dashed var(--line);
}

h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 25px;
    font-weight: 700;
    text-align: center;
    margin: 6px 0 22px;
    color: var(--ink);
}

h2, h3 {
    font-family: 'Space Grotesk', sans-serif;
    text-align: center;
    color: var(--ink);
}
h3 { font-size: 16px; margin-top: 30px; }

p { text-align: center; line-height: 1.55; }
a { color: var(--yellow-deep); }

/* ---- Forms (obecné, ne search-bar) ---- */

form { display: flex; flex-direction: column; align-items: center; }
form p, form > div:not(.file-drop) { width: 100%; max-width: 320px; text-align: left; margin: 0 0 14px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 5px;
}

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=number], select, textarea {
    display: block;
    width: 100%;
    padding: 13px 14px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    font-size: 16px; /* zabraňuje auto-zoomu na iOS */
    font-family: inherit;
    background: var(--white);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

/* Mobilní prohlížeče (hlavně iOS Safari) umí pole pro datum vykreslit
   samy o sobě širší/vyšší než ostatní pole, protože k němu přidávají
   vlastní nativní "chrom" navíc k tomu, co appka nastaví přes CSS.
   Tohle to sjednotí s ostatními poli. */
input[type=date] {
    -webkit-appearance: none;
    appearance: none;
    max-width: 100%;
    min-height: 0;
}

textarea { resize: vertical; min-height: 70px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--yellow-deep);
    box-shadow: 0 0 0 3px rgba(227, 166, 0, 0.18);
}

button, input[type=submit] {
    background: var(--yellow);
    color: var(--black);
    border: 2px solid var(--black);
    padding: 14px 22px;
    border-radius: 9px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    margin-top: 6px;
    width: 100%;
    max-width: 320px;
    transition: background 0.15s, color 0.15s, transform 0.08s;
}

button:hover, input[type=submit]:hover { background: var(--black); color: var(--yellow); }
button:active, input[type=submit]:active { transform: scale(0.98); }

button[name=delete] {
    background: var(--white);
    color: var(--error-text);
    border-color: var(--error-text);
}
button[name=delete]:hover { background: var(--error-text); color: var(--white); }

/* Malé sekundární tlačítko (odkazy stylizované jako tlačítko) */
.btn-secondary {
    display: inline-block;
    background: var(--white);
    color: var(--ink);
    border: 1.5px solid var(--line);
    padding: 9px 16px;
    border-radius: 8px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.btn-secondary:hover { border-color: var(--yellow-deep); background: var(--yellow-soft); }

/* ---- Odkazy pod přihlašovacím formulářem (zapomenuté heslo, registrace) ---- */

.auth-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    margin: 22px auto 0;
}

.auth-link-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    text-align: left;
    transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.auth-link-btn:hover { border-color: var(--yellow-deep); background: var(--yellow-soft); }
.auth-link-btn:active { transform: scale(0.98); }
button.auth-link-btn { width: 100%; font: inherit; cursor: pointer; }
button.auth-link-btn:disabled { opacity: 0.6; cursor: default; }

.auth-link-icon {
    font-size: 20px;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--yellow-soft);
    border-radius: 8px;
}

.auth-link-btn > span:last-child {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.auth-link-btn strong {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13.5px;
    font-weight: 600;
}
.auth-link-btn > span:last-child > span:last-child {
    font-size: 12px;
    color: var(--muted);
}

/* ---- Vlastní stylizovaný výběr souboru ---- */

.file-drop {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin-bottom: 8px;
}
.file-drop input[type=file] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 34px 16px;
    border: 2px dashed var(--line);
    border-radius: 12px;
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover .file-drop-label,
.file-drop input:focus + .file-drop-label { border-color: var(--yellow-deep); background: var(--yellow-soft); }
.file-drop-icon { font-size: 30px; }
.file-drop-name { font-size: 12px; color: var(--yellow-deep); font-weight: 700; }

/* ---- Loading stav při zpracování účtenky přes AI ---- */

.upload-loading {
    display: none; /* zobrazí se přes JS při odeslání formuláře */
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 40px 20px;
    text-align: center;
}
.upload-loading p { margin: 0; }
.upload-loading-note { font-size: 13px; color: var(--muted); max-width: 320px; }

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid var(--line);
    border-top-color: var(--yellow-deep);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Flash messages ---- */

.flash {
    width: 100%;
    max-width: 320px;
    margin: 0 auto 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.shell-wide .flash { max-width: 100%; }

/* ---- Tabulky ---- */

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* Buňky s delším textem (např. popis pluginu) se mají zalamovat, jinak by
   samy o sobě natáhly celou tabulku do zbytečné šířky a schovaly by
   akční tlačítka za posuvník. */
td.wrap-cell { white-space: normal; max-width: 360px; }
th {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
tbody tr:hover { background: var(--yellow-soft); }

/* ---- Vyhledávací lišta (dashboard) — samostatný, nezávislý layout ---- */

.search-bar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 26px;
    width: 100%;
}
.search-bar > div {
    width: auto;
    max-width: none;
    text-align: left;
    margin: 0;
    flex: 1 1 160px;
}
.search-bar input {
    width: 100%;
    margin: 0;
}
.search-bar button {
    width: auto;
    margin: 0;
    padding: 13px 22px;
    flex: 0 0 auto;
}

@media (max-width: 560px) {
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar > div { flex: 1 1 auto; }
    .search-bar button { width: 100%; }
}

/* ---- Jednoduché hledání na přehledu (jen jedno pole) ---- */

.quick-search {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
    margin-bottom: 24px;
}
.quick-search input {
    flex: 1 1 auto;
    margin: 0;
}
.quick-search button {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 13px 22px;
}
@media (max-width: 480px) {
    .quick-search { flex-direction: column; }
    .quick-search button { width: 100%; }
}

/* ---- Logo obchodu / fallback avatar ---- */

.store-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0; /* dovolí zkrácení dlouhého názvu uvnitř grid/flex buňky */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.store-logo {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
    background: var(--white);
    border: 1px solid var(--line);
    flex: 0 0 auto;
}
.store-avatar {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--yellow);
    color: var(--black);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* ---- Widget "Končící záruky" na přehledu ---- */

.warranty-widget {
    display: flex;
    flex-direction: column;
}
.calendar-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    transition: background 0.15s;
}
.warranty-widget a:last-child { border-bottom: none; }
.calendar-tile:hover { background: var(--yellow-soft); }
.calendar-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 56px;
    border-radius: 8px;
    background: var(--yellow);
    flex: 0 0 auto;
    line-height: 1.05;
}
.calendar-date .month {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--black);
    letter-spacing: 0.03em;
}
.calendar-date .day {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--black);
}
.calendar-date .year {
    font-size: 10px;
    font-weight: 600;
    color: rgba(23, 21, 18, 0.65);
}
.calendar-info { display: flex; flex-direction: column; min-width: 0; }
.calendar-info strong { font-size: 14px; }
.calendar-info span { font-size: 12px; color: var(--muted); }

/* ---- Odznaky u záruk (items.php) ---- */

.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 6px;
    white-space: nowrap;
}
.badge-soon { background: var(--yellow); color: var(--black); }
.badge-expired { background: #eee; color: var(--muted); }
tr.warranty-soon { background: var(--yellow-soft); }
tr.warranty-expired td { color: var(--muted); }

/* ---- Upload: položky účtenky ---- */

.item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
    max-width: none;
    justify-content: center;
    background: var(--yellow-soft);
    padding: 10px;
    border-radius: 8px;
}
.item-row input[type=text] { flex: 2 1 140px; margin: 0; }
.item-row input[type=number] { flex: 1 1 70px; margin: 0; }
.item-row input[type=checkbox] { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---- QR kód ---- */

#qrcode { display: flex; justify-content: center; margin: 18px 0; }

/* ---- Soubor účtenky: karta se zobrazit/stáhnout ---- */

.file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--yellow-soft);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    margin: 14px auto 0;
    max-width: 480px;
    text-align: left;
}
.file-card-icon { font-size: 30px; line-height: 1; }
.file-card-info { flex: 1 1 auto; min-width: 0; }
.file-card-info strong { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 14px; }
.file-card-info span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.file-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

code {
    background: #f4efe0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* ---- Poznámka u účtenky ---- */

.note-box {
    background: var(--yellow-soft);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    max-width: 480px;
    margin: 0 auto 20px;
    text-align: left;
}
.note-box strong {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 4px;
}
.note-box p { text-align: left; margin: 0; font-size: 14px; }

/* ---- Logo obchodu v nadpisu detailu účtenky ---- */

.store-heading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 34px; /* rezerva nad nadpisem, aby ho nepřekrývala absolutně
        umístěná rohová tlačítka "Zpět"/"Upravit" - ta jsou vyjmutá z toku
        dokumentu, takže bez týhle rezervy by dlouhý název obchodu (na
        jednom řádku přes celou šířku karty) mohl s tlačítky kolidovat */
}
.store-logo-large {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    background: var(--white);
    border: 1px solid var(--line);
    flex: 0 0 auto;
}
.store-avatar-large {
    width: 32px;
    height: 32px;
    font-size: 15px;
    border-radius: 6px;
}

.note-indicator { font-size: 12px; opacity: 0.8; }

/* ---- Nastavení: seznam pluginů se zapínáním ---- */

.plugin-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto 20px;
}

.plugin-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.plugin-toggle:hover { border-color: var(--yellow-deep); }
.plugin-toggle input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; flex: 0 0 auto; }
.plugin-toggle-info { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.plugin-toggle-info strong { font-family: 'Space Grotesk', sans-serif; font-size: 14px; }
.plugin-toggle-info span { font-size: 12.5px; color: var(--muted); }

/* ---- Nastavení: seznam zařízení pro rychlé přihlášení (WebAuthn) ---- */

.webauthn-device-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
}
.webauthn-device-row .plugin-toggle-info { flex: 1 1 auto; min-width: 0; }
.webauthn-device-row form { margin: 0; }

/* ---- Widgety od pluginů na přehledu ---- */

.plugin-widgets { margin-bottom: 22px; }
.plugin-widget {
    background: var(--yellow-soft);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 14px;
    margin-bottom: 10px;
}

/* ---- Výrazné tlačítko "Nahrát účtenku" nahoře na přehledu ---- */

.upload-cta {
    display: none; /* na počítači se nezobrazuje - tam je "Nahrát" v menu */
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--yellow);
    color: var(--black);
    border: 2px solid var(--black);
    border-radius: 10px;
    padding: 16px 20px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    margin-bottom: 24px;
    transition: background 0.15s, color 0.15s;
}
.upload-cta:hover { background: var(--black); color: var(--yellow); }
.upload-cta svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
}

/* ---- Odkaz "Přidat appku na plochu" a jeho rozbalovací panel ---- */

.install-toggle-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    margin: -12px 0 20px;
}
.install-toggle-link:hover { color: var(--yellow-deep); }
.install-toggle-link svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.install-panel {
    display: none;
    flex-direction: column;
    gap: 12px;
    background: var(--yellow-soft);
    border: 1.5px dashed var(--yellow-deep);
    border-radius: 12px;
    padding: 16px;
    margin: -10px 0 20px;
}
.install-panel.install-panel-open { display: flex; }

.install-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.install-step strong { font-family: 'Space Grotesk', sans-serif; font-size: 13px; }
.install-step p { margin: 2px 0 0; text-align: left; font-size: 12px; color: var(--muted); }
.install-step .btn-secondary { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 480px) {
    .install-step { flex-direction: column; align-items: stretch; }
    .install-step .btn-secondary { width: 100%; }
}

/* ---- Dvousloupcové rozvržení detailu účtenky na širších obrazovkách ---- */

.receipt-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* ne jen "1fr" - bez minmax(0, ...)
        se grid sloupec nesmí zmenšit pod min-content šířku svého obsahu
        (např. tabulka s dlouhým názvem položky), což na mobilu tlačilo
        celou kartu přes okraj obrazovky */
    gap: 28px;
    align-items: start;
}

@media (min-width: 780px) {
    .receipt-detail-layout {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    }
}

.receipt-detail-sidebar .file-card {
    margin: 0 0 14px;
    max-width: none;
}
.receipt-detail-sidebar h3 { text-align: left; }
.receipt-detail-main .detail-toolbar { justify-content: flex-start; }

/* ---- Tlačítka pro ruční otočení fotky (oprava starších fotek) ---- */

.rotate-actions {
    display: flex;
    gap: 8px;
    margin: -6px 0 14px;
}
.rotate-actions form { flex: 1; }
.rotate-actions .btn-secondary {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: stretch;
}

.dashboard-main, .dashboard-sidebar {
    display: flex;
    flex-direction: column;
}

/* Poslední panel v každém sloupci se natáhne, ať jsou spodní okraje obou
   sloupců zarovnané na stejné výšce (i když má jeden sloupec méně obsahu
   než druhý). */
.dashboard-main > .panel:last-child,
.dashboard-sidebar > .panel:last-child {
    flex: 1;
}

@media (min-width: 860px) {
    .dashboard-layout {
        grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
    }
}

.dashboard-sidebar .warranty-widget,
.dashboard-sidebar .plugin-widgets {
    margin-bottom: 22px;
}

/* Levý i pravý sloupec přehledu musí začínat na stejné výšce - první
   prvek v každém sloupci proto nikdy nemá horní mezeru (i kdyby to byl
   nadpis h3, který má jinak horní odsazení kvůli oddělení od obsahu nad
   sebou). */
.dashboard-main > *:first-child,
.dashboard-sidebar > *:first-child {
    margin-top: 0;
}

/* ---- Panel (velká bublina) - "Poslední účtenky", "Končící záruky" ---- */

.panel {
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 22px;
}
.panel-title {
    margin: 0 0 6px !important;
    text-align: left !important;
}
.panel-footer-link {
    text-align: left;
    margin: 14px 0 0;
    font-size: 13px;
}

/* ---- Statistiky na přehledu ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}
.stat-card {
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
}
.stat-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 0 0 10px;
    text-align: left;
}
.stat-card-simple { text-align: center; }
.stat-big {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 24px;
    font-weight: 700;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 5px 0;
}
.stat-row-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-family: 'Space Grotesk', sans-serif; }
.stat-income { color: #166534; }
.stat-expense { color: #8a1f1f; }

/* ---- Poslední účtenky (přehled) ---- */

.recent-receipts {
    display: flex;
    flex-direction: column;
}
.recent-receipt-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 100px 110px;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    transition: background 0.15s;
}
.recent-receipts a:last-child { border-bottom: none; }
.recent-receipt-row:hover { background: var(--yellow-soft); }
.recent-receipt-date { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.recent-receipt-amount { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 13px; white-space: nowrap; text-align: right; }

/* ---- Rozšířené vyhledávání (Moje účtenky) ---- */

.advanced-search {
    margin: 6px 0 10px;
}
.advanced-search summary {
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--yellow-deep);
    padding: 8px 0;
}
.advanced-search summary:hover { text-decoration: underline; }
.advanced-search-form {
    background: var(--yellow-soft);
    border: 1.5px dashed var(--yellow-deep);
    border-radius: 10px;
    padding: 16px;
    margin-top: 8px;
    display: block;
}
.advanced-search-form button,
.advanced-search-form .btn-secondary { width: auto; display: inline-block; }

.filter-group { margin-bottom: 16px; text-align: left; }
.filter-group-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin: 0 0 8px;
}
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.checkbox-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12.5px;
    cursor: pointer;
}
.checkbox-chip input { width: 14px; height: 14px; margin: 0; }

/* ---- Stránkování ---- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.pagination-info { font-size: 13px; color: var(--muted); }
.pagination .btn-secondary { width: auto; }

/* ---- Sekce pluginu vložená do formuláře (např. Podnikatel) ---- */

.plugin-section {
    width: 100%;
    max-width: 320px;
    margin: 6px auto 18px;
    padding: 14px 16px 4px;
    background: var(--yellow-soft);
    border: 1.5px dashed var(--yellow-deep);
    border-radius: 10px;
}
.plugin-section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--yellow-deep);
    margin: 0 0 10px;
    text-align: left;
}

/* ---- Odznak příjem/výdaj ---- */

.transaction-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.transaction-badge.income { background: #dcfce7; color: #166534; }
.transaction-badge.expense { background: #fee2e2; color: #8a1f1f; }

/* ---- Tlačítko "Upravit" v pravém horním rohu detailu ---- */

.edit-corner-btn {
    position: absolute;
    top: 22px;
    right: 24px;
    margin: 0;
    padding: 8px 14px;
    font-size: 13px;
    z-index: 2;
}

.back-corner-btn {
    position: absolute;
    top: 22px;
    left: 24px;
    margin: 0;
    padding: 8px 14px;
    font-size: 13px;
    z-index: 2;
}

@media (max-width: 480px) {
    .edit-corner-btn {
        top: 16px;
        right: 16px;
        padding: 6px 10px;
        font-size: 12px;
    }
    .back-corner-btn {
        top: 16px;
        left: 16px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ---- Odkaz na fotky produktu (Google Images) ---- */

.item-photo-link {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px dashed var(--line);
}
.item-photo-link:hover { color: var(--yellow-deep); border-bottom-color: var(--yellow-deep); }
.item-photo-link .photo-icon { font-size: 11px; opacity: 0.6; }

/* ---- Nástrojová lišta pod detailem účtenky (Smazat) ---- */

.detail-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}
.detail-toolbar form { display: contents; }
.detail-toolbar button[name=delete] {
    width: auto;
    margin: 0;
    padding: 9px 16px;
    background: var(--white);
    color: var(--error-text);
    border: 1.5px solid var(--error-text);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 13px;
    border-radius: 8px;
}
.detail-toolbar button[name=delete]:hover { background: var(--error-text); color: var(--white); }

/* ---- Tlačítko na odebrání nově přidaného řádku položky (edit mód) ---- */

.remove-item-btn {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--white);
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.remove-item-btn:hover { border-color: var(--error-text); color: var(--error-text); background: var(--white); }

/* ---- Mobilní optimalizace ---- */

@media (max-width: 480px) {
    body { padding: 14px 8px 44px; }
    body.with-topbar { padding-top: 76px; }
    .shell { padding: 24px 16px 28px; border-radius: 12px; }
    h1 { font-size: 20px; }

    .topbar-inner { flex-direction: row; text-align: left; }
    .nav-toggle { display: block; }

    /* Menu na mobilu je schované, dokud se neklikne na hamburger ikonu */
    nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--black);
        padding: 8px 16px 14px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.35);
    }
    nav.nav-open { display: flex; }
    nav a {
        padding: 13px 4px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        border-radius: 0;
    }
    nav a:last-child { border-bottom: none; }
    nav a:hover { border-bottom-color: rgba(255,255,255,0.1); }

    th, td { padding: 9px 6px; font-size: 13px; }
    button, input[type=submit] { padding: 15px 20px; }
    .file-card { flex-direction: column; text-align: center; }
    .file-card-actions { justify-content: center; }

    /* Sloupec "Platba" a tlačítko "Detail" se na mobilu nevejdou vedle
       sebe pěkně - místo toho je klikací celý řádek. */
    .payment-col, .detail-col { display: none; }
    .receipt-row { cursor: pointer; }
    .receipt-row:active { background: var(--yellow-soft); }

    /* Na mobilu naopak tlačítko "Nahrát účtenku" na přehledu chceme vidět */
    .upload-cta { display: flex; }
}

/* ============================================================
   Složky (podklady k pojistné události apod.) a výpis s tiskem
   ============================================================ */

button.btn-secondary { width: auto; max-width: none; margin-top: 0; }
mark { background: var(--yellow); color: var(--black); padding: 0 2px; border-radius: 3px; }

.folder-list { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.folder-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--white); border: 1.5px solid var(--line); border-radius: 12px;
    padding: 14px 16px; text-decoration: none; color: var(--ink);
    transition: border-color 0.15s, background 0.15s;
}
.folder-card:hover { border-color: var(--yellow-deep); background: var(--yellow-soft); }
.folder-card-icon {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px;
    background: var(--yellow); display: flex; align-items: center; justify-content: center;
}
.folder-card-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--black); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.folder-card-info { flex: 1 1 auto; min-width: 0; }
.folder-card-info strong { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 15px; overflow-wrap: anywhere; }
.folder-card-info span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.folder-card-arrow { font-size: 24px; color: var(--muted); }

.folder-form label:not(.checkbox-chip) { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.folder-form p { text-align: left; margin: 0 0 14px; }

.folder-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.folder-action-primary { background: var(--yellow) !important; border-color: var(--black) !important; color: var(--black) !important; }
.folder-action-primary:hover { background: var(--black) !important; color: var(--yellow) !important; }

.folder-banner, .folder-badge {
    background: var(--yellow-soft); border: 1.5px solid var(--yellow-deep);
    border-radius: 10px; padding: 10px 14px; font-size: 13px; margin: 0 0 16px;
}
.folder-badge { display: inline-block; padding: 6px 12px; margin: 0 0 12px; }

.folder-receipts { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.folder-receipt { background: var(--white); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.folder-receipt-head {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px;
    text-decoration: none; color: var(--ink);
}
.folder-receipt-head:hover strong { text-decoration: underline; }
.folder-receipt-meta { font-size: 13px; color: var(--muted); }
.folder-receipt-items { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; }
.folder-receipt-items li {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 4px 0; border-top: 1px dashed var(--line);
}
.folder-receipt-items li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.folder-item-price { white-space: nowrap; color: var(--muted); }
.folder-receipt-note { text-align: left; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.folder-receipt-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.folder-receipt-foot form { margin: 0; }
.folder-remove-btn { font-size: 12px; padding: 6px 12px; color: var(--error-text); }

.folder-move-box { margin-top: 18px; }
.folder-move-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.folder-move-form label { flex: 1 1 100%; font-size: 12px; font-weight: 600; margin: 0; }
.folder-move-form select { flex: 1 1 180px; width: auto; margin: 0; }

.picker-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 8px; }
.picker-count { font-size: 13px; color: var(--muted); }
.picker-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.picker-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--white); border: 1.5px solid var(--line); border-radius: 10px;
    padding: 10px 14px; cursor: pointer;
}
.picker-row:hover { border-color: var(--yellow-deep); background: var(--yellow-soft); }
.picker-row input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; }
.picker-row-main { flex: 1 1 auto; min-width: 0; }
.picker-row-main strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.picker-row-main span { font-size: 12px; color: var(--muted); }
.picker-row-amount { white-space: nowrap; font-size: 13px; font-weight: 600; }

.report-head p { text-align: left; margin: 0 0 12px; }
.report-head label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.report-receipt { background: var(--white); border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.report-receipt-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px; background: var(--yellow-soft); cursor: pointer; font-size: 14px;
}
.report-receipt-head span { color: var(--muted); font-size: 12px; }
.report-receipt input[type=checkbox] { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.report-item {
    display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap;
    padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13px;
}
.report-item:hover { background: var(--paper); }
.report-item-check { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; min-width: 0; cursor: pointer; }
.report-item-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.item-edit-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.item-edit-inline input[type=number] { width: 78px; margin: 0; padding: 5px 6px; text-align: right; font-size: 13px; }
.item-edit-inline input.in-qty { width: 58px; }
.item-edit.has-error input { border-color: var(--error-text); background: var(--error-bg); }
.report-empty { font-size: 12px; color: var(--muted); margin: 0; padding: 10px 14px; text-align: left; }
.report-sum-bar {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--black); color: var(--white);
    padding: 12px 16px; border-radius: 10px; margin: 14px 0; font-size: 14px;
}
.report-sum-bar strong { color: var(--yellow); }

.redact-sub { margin: -14px 0 14px; color: var(--muted); font-size: 13px; }
.redact-legend { display: flex; gap: 18px; justify-content: center; font-size: 13px; margin-bottom: 4px; }
.redact-legend .lg { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; border-radius: 2px; }
.lg-black { background: #000; }
.lg-visible { border: 2px solid #2e9e4f; }
.redact-help { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }
.redact-wrap { position: relative; max-width: 720px; margin: 0 auto; line-height: 0; background: #ddd; }
.redact-wrap img { width: 100%; height: auto; display: block; user-select: none; -webkit-user-select: none; }
.redact-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; cursor: crosshair; touch-action: none; }
.rbox { position: absolute; cursor: pointer; }
.rbox-black { background: rgba(0, 0, 0, 0.86); }
.rbox-visible { border: 2px solid #2e9e4f; background: rgba(46, 158, 79, 0.08); }
.rbox-manual { outline: 2px dashed #ffc629; outline-offset: -2px; }
.rbox-draft { background: rgba(0, 0, 0, 0.45); border: 2px dashed #ffc629; pointer-events: none; }
.redact-status { min-height: 20px; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.redact-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
