/* SYD Fleet 1.0.0 -- стилі. Без зовнішніх шрифтів і бібліотек (працює в закритій мережі). */
:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-soft: #ccfbf1;
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --success: #15803d;
    --success-soft: #dcfce7;
    --info-soft: #e0f2fe;
    --info: #0369a1;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --radius: 12px;
    --chart-fuel: #0f766e;
    --chart-exp: #f59e0b;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --primary: #2dd4bf;
    --primary-dark: #5eead4;
    --primary-soft: #134e4a;
    --bg: #0b1220;
    --surface: #111a2c;
    --surface-2: #0f172a;
    --border: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --danger-soft: #450a0a;
    --warning-soft: #422006;
    --success-soft: #052e16;
    --info-soft: #082f49;
    --danger: #f87171;
    --warning: #fbbf24;
    --success: #4ade80;
    --info: #38bdf8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --chart-fuel: #2dd4bf;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        --primary: #2dd4bf;
        --primary-dark: #5eead4;
        --primary-soft: #134e4a;
        --bg: #0b1220;
        --surface: #111a2c;
        --surface-2: #0f172a;
        --border: #1e293b;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --danger-soft: #450a0a;
        --warning-soft: #422006;
        --success-soft: #052e16;
        --info-soft: #082f49;
        --danger: #f87171;
        --warning: #fbbf24;
        --success: #4ade80;
        --info: #38bdf8;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --chart-fuel: #2dd4bf;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }

/* ---------- Каркас ---------- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 30;
    display: flex; align-items: center; gap: 10px; padding: 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-user { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 6px 10px; border-radius: 10px; }
.top-user:hover { background: var(--surface-2); text-decoration: none; }
.top-user span { display: flex; flex-direction: column; line-height: 1.2; }
.top-user small { color: var(--muted); font-size: 11px; }
.icon-btn { background: none; border: 0; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); }
.nav-toggle { display: none; }

.sidebar {
    position: fixed; top: 56px; bottom: 0; left: 0; width: 240px; z-index: 25;
    background: var(--surface); border-right: 1px solid var(--border);
    overflow-y: auto; padding: 12px 10px 16px; display: flex; flex-direction: column;
}
.nav-section { margin-bottom: 14px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 6px; font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: 8px; color: var(--text); font: inherit;
    background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-link .badge { margin-left: auto; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.badge { background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; line-height: 18px; font-weight: 600; }
.main { margin-left: 240px; padding: 76px 28px 40px; min-height: 100vh; max-width: 1480px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions, .page-head > .btn-row { margin-left: auto; }
.app-footer { color: var(--muted); font-size: 12px; text-align: center; padding: 28px 0 0; }
.bottom-nav { display: none; }
.nav-backdrop { display: none; }

.auth-main { max-width: 420px; margin: 0 auto; padding: 8vh 16px 40px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; font-size: 20px; font-weight: 700; }
.auth-sub { text-align: center; color: var(--muted); margin: -10px 0 20px; }

/* ---------- Картки, сітки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .btn-row, .card-head .right { margin-left: auto; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.delta-up { color: var(--danger); }
.delta-down { color: var(--success); }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 9px; border: 1px solid transparent;
    font: inherit; font-weight: 600; cursor: pointer; line-height: 1.3; white-space: nowrap;
    background: var(--primary); color: #fff;
}
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost) { color: #042f2e; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost) { color: #042f2e; } }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: none; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Форми ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 14px; min-width: 0; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=tel], input[type=search], input[type=url], input[type=month], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text); font: inherit; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
.input-lg { font-size: 18px !important; min-height: 50px !important; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2, .form-grid-3 .span-3 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin-bottom: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.has-error input, .has-error select { border-color: var(--danger); }
.inline-form { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.filters .btn-row { padding-bottom: 1px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.preset { padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12px; }
.preset:hover { text-decoration: none; background: var(--surface-2); }
.preset.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: flex; align-items: center; justify-content: center; text-align: center; gap: 6px;
    padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-weight: 500; cursor: pointer; min-height: 44px; background: var(--surface);
}
.segmented input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); }

.upload-box {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; color: var(--muted); background: var(--surface-2);
}
.upload-box:hover { border-color: var(--primary); color: var(--primary); }
.upload-box input { display: none; }
.upload-preview { max-width: 100%; max-height: 220px; border-radius: 8px; display: none; }
.upload-preview.show { display: block; }
.calc-line { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- Таблиці ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .row-link { color: inherit; }
.table td.actions { white-space: nowrap; text-align: right; }
.table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px !important; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-icon { font-size: 40px; }
.pagination { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 14px; }
.pagination a { padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* ---------- Статуси й ознаки ---------- */
.status { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-submitted { background: var(--warning-soft); color: var(--warning); }
.status-approved { background: var(--success-soft); color: var(--success); }
.status-rejected { background: var(--danger-soft); color: var(--danger); }
.status-active { background: var(--success-soft); color: var(--success); }
.status-repair, .status-blocked { background: var(--warning-soft); color: var(--warning); }
.status-retired, .status-lost, .status-expired, .status-inactive { background: var(--danger-soft); color: var(--danger); }
.flag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; margin: 1px 3px 1px 0; white-space: nowrap; font-weight: 600; }
.flag-high { background: var(--danger-soft); color: var(--danger); }
.flag-medium { background: var(--warning-soft); color: var(--warning); }
.flag-low { background: var(--info-soft); color: var(--info); }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.role-admin { background: #ede9fe; color: #6d28d9; border-color: transparent; }
.role-owner { background: #fae8ff; color: #a21caf; border-color: transparent; }
.role-accountant { background: var(--info-soft); color: var(--info); border-color: transparent; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.receipt-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.receipt-big { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); }
.receipt-pdf { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 6px; background: var(--danger-soft); color: var(--danger); font-weight: 700; font-size: 11px; }

.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-high { background: var(--danger); }
.dot-medium { background: var(--warning); }
.dot-low { background: var(--info); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; }
.ok-mark { color: var(--success); font-weight: 600; }

/* ---------- Кабінет менеджера ---------- */
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.quick a {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    background: var(--primary); color: #fff; border-radius: 16px; padding: 18px; font-weight: 700; font-size: 16px; box-shadow: var(--shadow);
}
.quick a:hover { text-decoration: none; filter: brightness(1.05); }
.quick a.alt { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.quick .ic { width: 28px; height: 28px; }
.vehicle-card { display: flex; gap: 14px; align-items: center; }
.vehicle-plate { font-weight: 800; font-size: 15px; letter-spacing: .04em; border: 2px solid var(--text); border-radius: 6px; padding: 2px 8px; background: var(--surface); white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-dark); flex: none; font-size: 18px; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; }
.tl-sub { color: var(--muted); font-size: 12px; }
.tl-amount { text-align: right; font-weight: 700; white-space: nowrap; }

/* ---------- Діаграма ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-fuel { fill: var(--chart-fuel); }
.chart-exp { fill: var(--chart-exp); }
.chart-label { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.chart-legend { display: flex; gap: 6px 14px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: -8px; }
.lg-fuel { background: var(--chart-fuel); }
.lg-exp { background: var(--chart-exp); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.bar.over > i { background: var(--danger); }

.bulk-bar { display: none; position: sticky; bottom: 12px; z-index: 5; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(15, 23, 42, .15); border-radius: 12px; padding: 10px 14px; margin-top: 12px; gap: 10px; align-items: center; flex-wrap: wrap; }
.bulk-bar.show { display: flex; }
.bulk-bar input[type=text] { width: auto; flex: 1 1 200px; }

.mfa-qr { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; border: 1px solid var(--border); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; max-width: 320px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
    .sidebar { transform: translateX(-100%); transition: transform .2s; width: 270px; bottom: 0; visibility: hidden; }
    body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 56px 0 0; background: rgba(15, 23, 42, .4); z-index: 20; }
    .main { margin-left: 0; padding: 72px 16px calc(84px + env(safe-area-inset-bottom)); }
    .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .top-user span { display: none; }
    .bottom-nav {
        display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
        background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }
    .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; padding: 4px 0; }
    .bottom-nav a:hover { text-decoration: none; }
    .bottom-nav .bn-main { color: var(--primary); font-weight: 700; }
    .dl { grid-template-columns: 1fr; gap: 2px; }
    .dl dd { margin-bottom: 8px; }
    .filters .field { max-width: none; }
    h1 { font-size: 19px; }
    .card { padding: 14px; }
    .table-wrap { margin: 0 -14px; padding: 0 14px; }
    .hide-sm { display: none; }
}
@media print {
    .sidebar, .topbar, .bottom-nav, .btn, .filters, .presets, .app-footer { display: none !important; }
    .main { margin: 0; padding: 0; }
    .card { box-shadow: none; border: 0; }
}
