/*
 * Design tokeny podľa mockupu (docs/plan/README.md → artifact „Bookkeeping – mobilný návrh").
 * Tmavá téma ide podľa systému; ručný prepínač nastaví data-theme na <html>.
 */
:root {
    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

    --bg: #F3F5F7;
    --surface: #FFFFFF;
    --surface-nav: #FFFFFF;
    --line: #DDE2E7;
    --line-soft: #EEF1F4;
    --input-line: #C5CDD5;
    --ink: #14202B;
    --muted: #52606D;
    --accent: #0E6B5C;
    --accent-hover: #0A4F44;
    --accent-ink: #FFFFFF;
    --accent-soft: #E3F2EE;
    --accent-soft-ink: #0A4F44;
    --hero: #14202B;
    --hero-ink: #FFFFFF;
    --hero-muted: #B8C4CF;
    --draft: #8A4B08;
    --draft-soft: #FDF1E2;
    --info: #1F4E8C;
    --info-soft: #E4EDF8;
    --danger: #A1281B;
    --danger-soft: #FBE7E4;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --tap: 48px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0E141A;
        --surface: #17202A;
        --surface-nav: #121A22;
        --line: #26323E;
        --line-soft: #1F2A35;
        --input-line: #3A4754;
        --ink: #E6ECF1;
        --muted: #95A3B0;
        --accent: #3FB8A0;
        --accent-hover: #6FD0BC;
        --accent-ink: #06231D;
        --accent-soft: #143A33;
        --accent-soft-ink: #7DDCC6;
        --hero: #12352F;
        --hero-ink: #E6ECF1;
        --hero-muted: #A9C9C1;
        --draft: #F3BE78;
        --draft-soft: #3A2C16;
        --info: #9CC3F2;
        --info-soft: #1D2F47;
        --danger: #F5A397;
        --danger-soft: #40201C;

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0E141A;
    --surface: #17202A;
    --surface-nav: #121A22;
    --line: #26323E;
    --line-soft: #1F2A35;
    --input-line: #3A4754;
    --ink: #E6ECF1;
    --muted: #95A3B0;
    --accent: #3FB8A0;
    --accent-hover: #6FD0BC;
    --accent-ink: #06231D;
    --accent-soft: #143A33;
    --accent-soft-ink: #7DDCC6;
    --hero: #12352F;
    --hero-ink: #E6ECF1;
    --hero-muted: #A9C9C1;
    --draft: #F3BE78;
    --draft-soft: #3A2C16;
    --info: #9CC3F2;
    --info-soft: #1D2F47;
    --danger: #F5A397;
    --danger-soft: #40201C;

    color-scheme: dark;
}

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

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

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.45;
}

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

h1, h2, p { margin: 0; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ── Rozloženie ──────────────────────────────────────────────── */

.app {
    min-height: 100dvh;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.app-header {
    padding: calc(env(safe-area-inset-top) + 24px) 20px 12px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.app-header__title { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.app-header__eyebrow { font-size: 13px; font-weight: 500; color: var(--muted); }

.app-main {
    flex: 1;
    padding: 4px 16px calc(96px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-title {
    margin: 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}

.empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
}

/* ── Spodná navigácia ────────────────────────────────────────── */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 560px;
    margin: 0 auto;
    background: var(--surface-nav);
    border-top: 1px solid var(--line);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
}

.tabbar__item {
    min-height: var(--tap);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.tabbar__item[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar__item svg { width: 22px; height: 22px; }

/* ── Tlačidlá ────────────────────────────────────────────────── */

.button {
    min-height: 54px;
    padding: 0 20px;
    border: 0;
    border-radius: 16px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 600 17px var(--font-sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
}

.button:hover { background: var(--accent-hover); color: var(--accent-ink); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button svg { width: 20px; height: 20px; }

.button--ghost {
    min-height: var(--tap);
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    font-weight: 500;
    font-size: 15px;
}

.button--ghost:hover { background: var(--surface); color: var(--ink); border-color: var(--input-line); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Hlásenia ────────────────────────────────────────────────── */

.notice {
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 14px;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
}

.notice--error { background: var(--danger-soft); color: var(--danger); }
.notice[hidden] { display: none; }

/* ── Prihlásenie a registrácia passkey ───────────────────────── */

.auth {
    min-height: 100dvh;
    max-width: 440px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 72px) 24px calc(env(safe-area-inset-bottom) + 40px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
}

.auth__brand { display: flex; flex-direction: column; gap: 20px; }

.auth__logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--hero);
    color: var(--hero-ink);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth__logo svg { width: 28px; height: 28px; }
.auth__title { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.auth__lead { margin-top: 8px; font-size: 16px; color: var(--muted); }

.auth__badge {
    align-self: center;
    width: 112px;
    height: 112px;
    border-radius: 56px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth__badge svg { width: 56px; height: 56px; }

.auth__actions { display: flex; flex-direction: column; gap: 12px; }
.auth__hint { text-align: center; font-size: 13px; color: var(--muted); }
.auth__hint code { font-family: var(--font-mono); color: var(--ink); }

/* ── Pomocné rozloženie ──────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 32px;
    color: var(--muted);
    text-decoration: none;
}
.back-link svg { width: 16px; height: 16px; }

/* ── Formuláre ───────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field__help { margin: 0; font-size: 12px; color: var(--muted); }
.field__error { margin: 0; font-size: 13px; color: var(--danger); }

.input {
    width: 100%;
    min-height: var(--tap);
    padding: 0 12px;
    border: 1px solid var(--input-line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font: 400 16px var(--font-sans);
}
.input--area { padding: 10px 12px; min-height: 72px; resize: vertical; line-height: 1.4; }
.field--invalid .input { border-color: var(--danger); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* Adresa: ulica cez celú šírku, PSČ + obec vedľa seba, krajina dole. */
.field-group { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; }
.field-group > .field:first-child, .field-group > .field:last-child { grid-column: 1 / -1; }

.lookup { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.lookup__button { min-height: var(--tap); }

/* ── Zoznamy ─────────────────────────────────────────────────── */

.list {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.list__row {
    min-height: 56px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--line-soft);
}
.list__row:last-child { border-bottom: 0; }
.list__row:hover { color: var(--ink); }
.list__row > svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list__title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.list__meta { font-size: 13px; color: var(--muted); }
.list__value { font-size: 15px; font-weight: 600; color: var(--muted); }

.badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge--ok { color: var(--accent-soft-ink); background: var(--accent-soft); }
.badge--draft { color: var(--draft); background: var(--draft-soft); }
.badge--muted { color: var(--muted); background: var(--line-soft); }
.badge--error { color: var(--danger); background: var(--danger-soft); }

/* ── Tlačidlá – doplnky ──────────────────────────────────────── */

.button--block { width: 100%; }
.button--dark { background: var(--hero); color: var(--hero-ink); font-size: 15px; padding: 0 16px; }
.button--dark:hover { background: var(--hero); color: var(--hero-ink); opacity: 0.9; }

.icon-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.icon-button svg { width: 20px; height: 20px; }
.icon-button--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-button--accent:hover { color: var(--accent-ink); background: var(--accent-hover); }

.notice { display: flex; gap: 8px; align-items: flex-start; }
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice--warn { background: var(--draft-soft); color: var(--draft); }
