/* Simple Fleet Manager */
:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --border: #dde3ea;
    --text: #1f2933;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #e0eaff;
    --header: #1e293b;
    --header-text: #f1f5f9;
    --ok: #15803d;
    --ok-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141a;
        --surface: #182029;
        --surface-2: #1d2731;
        --border: #2c3846;
        --text: #e6edf3;
        --muted: #94a3b8;
        --primary: #60a5fa;
        --primary-hover: #93c5fd;
        --primary-soft: #1e3a5f;
        --header: #0b1016;
        --header-text: #e6edf3;
        --ok: #4ade80;
        --ok-soft: #12351f;
        --warning: #fbbf24;
        --warning-soft: #3d2e0a;
        --danger: #f87171;
        --danger-soft: #3f1515;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

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

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- hlavička a navigace ---------- */
.topbar {
    background: var(--header);
    color: var(--header-text);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
}
.brand {
    color: var(--header-text);
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 6px; }
.nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
    color: var(--header-text);
    opacity: .8;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
}
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav a.active { opacity: 1; background: rgba(255, 255, 255, .14); }
.user-menu { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user-menu a { color: var(--header-text); opacity: .85; }
.user-menu button {
    background: transparent;
    color: var(--header-text);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 8px;
    padding: 4px 10px;
    cursor: pointer;
    font: inherit;
    font-size: .85rem;
}

@media (max-width: 760px) {
    .topbar-inner { flex-wrap: wrap; gap: 4px 12px; padding-top: 8px; }
    .nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
    .user-menu { margin-left: auto; }
    .user-menu .user-name { display: none; }
}

/* ---------- rozvržení ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- KPI dlaždice ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.kpi .label { color: var(--muted); font-size: .8rem; }
.kpi .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: .8rem; }

/* ---------- karta vozidla ---------- */
.vehicle-card { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.vehicle-card .title { display: flex; align-items: center; gap: 10px; }
.vehicle-card .title h3 { margin: 0; }
.vehicle-card .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .9rem; }
.vehicle-card .facts .label { color: var(--muted); font-size: .78rem; display: block; }
.vehicle-card .actions { margin-top: auto; }
.color-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border);
    flex: none;
    vertical-align: middle;
}
.color-dot.lg { width: 22px; height: 22px; }

/* ---------- tlačítka ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
    cursor: pointer;
    white-space: nowrap;
    min-height: 38px;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-primary:hover { color: #0b1016; } }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { display: inline; margin: 0; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font: inherit; }

/* ---------- tabulky ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; border-bottom: none; }
td.actions-cell { white-space: nowrap; text-align: right; }

/* ---------- formuláře ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .88rem; }
.field .req { color: var(--danger); }
.help { color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    min-height: 40px;
}
input[type="color"] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px 16px; margin: 16px 0 0; }
legend { font-weight: 600; padding: 0 6px; }
.inline-color { display: flex; gap: 8px; align-items: center; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 240px; }

.auth-box { max-width: 420px; margin: 40px auto; }

/* ---------- štítky a hlášky ---------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.alert {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    background: var(--primary-soft);
}
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger, .alert-error { background: var(--danger-soft); color: var(--danger); }

.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.alert-list li:last-child { border-bottom: none; }
.alert-list .what { flex: 1; min-width: 180px; }

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

.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 20px; }
.details .label { color: var(--muted); font-size: .78rem; }
.details .value { font-weight: 500; overflow-wrap: anywhere; }

.chart-box { position: relative; height: 280px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); font-size: .88rem; }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .tabs a.active { color: #0b1016; } }
.tabs a:hover { text-decoration: none; }

footer.site { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px; }
