/* flow — jednotný vzhled aplikace. Světlé i tmavé téma podle nastavení systému. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #d8dce3;
    --text: #1b1f26;
    --text-dim: #5d6673;
    --accent: #1c5fd6;
    --accent-soft: #e8effd;
    --ok: #1a7f4b;
    --ok-soft: #e4f5eb;
    --warn: #8a5a00;
    --warn-soft: #fdf1dc;
    --err: #b3261e;
    --err-soft: #fdeceb;
    --radius: 8px;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --surface: #1c2027;
        --surface-2: #23282f;
        --border: #333a44;
        --text: #e6e9ee;
        --text-dim: #9aa4b2;
        --accent: #6ea0ff;
        --accent-soft: #1e2b45;
        --ok: #5cc98c;
        --ok-soft: #17301f;
        --warn: #e0ad4a;
        --warn-soft: #332713;
        --err: #ff8b82;
        --err-soft: #3a1c1a;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

/* --- Rozvržení --------------------------------------------------------- */
header.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--text);
}
.brand span { color: var(--text-dim); font-weight: 400; font-size: 13px; }

/* Verze v hlavicce. Drzi se u nazvu, at je na prvni pohled videt, co na
   danem stroji bezi - uplny otisk (commit, cas sestaveni) je ve Stavu. */
.version {
    font-size: 12px;
    color: var(--text-dim);
    background: var(--surface-2);
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

nav.topnav { display: flex; gap: 4px; flex: 1; }
nav.topnav a {
    padding: 6px 11px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 14px;
}
nav.topnav a:hover { background: var(--surface-2); text-decoration: none; }
nav.topnav a.active { background: var(--accent-soft); color: var(--accent); }

.whoami { font-size: 13px; color: var(--text-dim); display: flex; gap: 12px; align-items: center; }

main { max-width: 1400px; margin: 0 auto; padding: 24px 20px 64px; }

h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.subtitle { color: var(--text-dim); font-size: 14px; margin: 0 0 22px; }

/* --- Karty ------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
.card h2 { margin-top: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.stat { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- Formuláře --------------------------------------------------------- */
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }

input[type=text], input[type=password], input[type=number],
input[type=email], input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-soft);
    border-color: var(--accent);
}
textarea { min-height: 70px; resize: vertical; }

.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.checkbox label { margin: 0; color: var(--text); }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary, .btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
button.danger, .btn.danger { background: var(--err); }
button.small, .btn.small { padding: 5px 9px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Tabulky ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
    background: var(--surface-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-dim);
    position: sticky;
    top: 0;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
.empty { padding: 32px; text-align: center; color: var(--text-dim); }

/* --- Odznaky a hlášky -------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-dim);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.alert {
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert.err { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.alert.info { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* --- Přihlášení -------------------------------------------------------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-box {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
}
.auth-box h1 { margin-bottom: 20px; }
.auth-box button { width: 100%; justify-content: center; margin-top: 6px; }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--text-dim); text-align: center; }

.otp-input {
    font-family: var(--mono);
    font-size: 26px !important;
    letter-spacing: 0.35em;
    text-align: center;
}
.qr { display: block; margin: 14px auto; width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }
.secret-box {
    font-family: var(--mono);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px;
    text-align: center;
    word-break: break-all;
    font-size: 13px;
}

/* --- Průběh dohánění historie ------------------------------------------ */
.progress {
    position: relative;
    height: 16px;
    min-width: 110px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.progress > span {
    display: block;
    height: 100%;
    background: var(--accent);
    opacity: 0.75;
}
.progress.done > span { background: var(--ok); }
.progress-label {
    font-size: 11.5px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- Stránkování ------------------------------------------------------- */
.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 13px; color: var(--text-dim); }
.pager .pages { display: flex; gap: 6px; }

.htmx-request .loading { display: inline; }
.loading { display: none; color: var(--text-dim); font-size: 13px; }
