:root {
    color-scheme: dark;
    --bg: #101418;
    --surface: #171d23;
    --surface-2: #202832;
    --text: #eef3f7;
    --muted: #98a6b3;
    --line: rgba(255,255,255,.09);
    --primary: #35c28f;
    --primary-2: #2aa7e8;
    --danger: #f06464;
    --warning: #f4b860;
    --shadow: 0 18px 60px rgba(0,0,0,.28);
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f7f9;
    --surface: #ffffff;
    --surface-2: #eaf0f4;
    --text: #17202a;
    --muted: #667684;
    --line: rgba(25,35,45,.1);
    --shadow: 0 18px 40px rgba(45,63,80,.12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary-2); text-decoration: none; }
button, input, select { font: inherit; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; padding: 24px;
    background: var(--surface); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 800; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 8px; display: inline-grid; place-items: center;
    color: #07120e; background: linear-gradient(135deg, var(--primary), #ffe082); font-weight: 900;
}
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
    color: var(--muted); padding: 12px 14px; border-radius: 8px; transition: .18s ease;
}
.sidebar nav a:hover { color: var(--text); background: var(--surface-2); transform: translateX(2px); }
.logout-form { margin-top: auto; }
.main { padding: 28px; max-width: 1480px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
h1, h2, h3 { margin: 0; line-height: 1.12; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); text-transform: uppercase; font-size: 12px; font-weight: 800; }
.muted { color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.profile-chip, .panel, .vehicle-card, .mini-card, .auth-card {
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.profile-chip { padding: 10px 14px; border-radius: 8px; display: grid; gap: 2px; }
.profile-chip span { color: var(--muted); font-size: 13px; }
.icon-btn, .btn {
    border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
    min-height: 40px; padding: 0 14px; border-radius: 8px; cursor: pointer; transition: .18s ease;
}
.icon-btn { width: 42px; padding: 0; }
.btn:hover, .icon-btn:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary), transparent 40%); }
.btn.primary { background: var(--primary); color: #06130f; border-color: transparent; font-weight: 800; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(240,100,100,.12); color: var(--danger); }
.flash { padding: 13px 16px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; margin-bottom: 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { padding: 20px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.stat-card span { display: block; color: var(--muted); margin-bottom: 8px; }
.stat-card strong { font-size: 28px; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .vehicle-card, .mini-card { border-radius: 8px; padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.list-row, .admin-row, .order-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 13px 0; border-top: 1px solid var(--line);
}
.list-row:first-of-type, .admin-row:first-of-type, .order-row:first-of-type { border-top: 0; }
.list-row div, .admin-row div { display: grid; gap: 4px; }
.list-row span, .admin-row span { color: var(--muted); font-size: 13px; }
.good { color: var(--primary); }
.bad { color: var(--danger); }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card-grid.small { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.vehicle-card { display: grid; gap: 16px; }
.vehicle-icon { width: 54px; height: 54px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-weight: 900; font-size: 24px; }
.specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.specs.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.specs div { padding: 10px; border-radius: 8px; background: var(--surface-2); }
.specs dt { color: var(--muted); font-size: 12px; }
.specs dd { margin: 3px 0 0; font-weight: 800; }
.progress { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.badge { padding: 6px 10px; border-radius: 999px; background: var(--surface-2); color: var(--primary); font-weight: 800; }
.actions, .inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input, .inline-form select, .stack input, .stack select, .stack label input {
    min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 0 12px;
}
.stack { display: grid; gap: 14px; }
.stack label { display: grid; gap: 7px; color: var(--muted); }
.notice { padding: 12px; border-radius: 8px; background: var(--surface-2); display: grid; gap: 3px; margin-bottom: 8px; }
.notice.success { border-left: 3px solid var(--primary); }
.notice.warning { border-left: 3px solid var(--warning); }
.notice.danger { border-left: 3px solid var(--danger); }
.chart-bars { height: 160px; display: flex; align-items: end; gap: 12px; padding: 12px; background: var(--surface-2); border-radius: 8px; margin-bottom: 12px; }
.chart-bars span { flex: 1; min-height: 8px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, var(--primary), var(--primary-2)); }
.admin-tabs, .admin-pages {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface), transparent 4%);
    backdrop-filter: blur(12px);
}
.admin-tabs a, .admin-pages a, .admin-tile {
    color: var(--text);
    background: var(--surface-2);
    padding: 9px 12px;
    border-radius: 8px;
}
.admin-pages { position: static; }
.admin-tile {
    display: grid;
    gap: 6px;
    min-height: 110px;
    align-content: center;
    border: 1px solid var(--line);
}
.admin-tile strong { font-size: 20px; }
.admin-tile span { color: var(--muted); }
.admin-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.admin-form input,
.admin-form select,
.admin-form textarea {
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    padding: 0 12px;
}
.admin-form textarea {
    grid-column: 1 / -1;
    min-height: 82px;
    padding: 10px 12px;
    resize: vertical;
}
.admin-form .full,
.checkline {
    grid-column: 1 / -1;
}
.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}
.admin-detail {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}
.admin-detail summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}
.admin-detail summary span {
    color: var(--muted);
}
.admin-detail[data-muted="1"] {
    opacity: .58;
}
.admin-detail form {
    margin-top: 12px;
}
.danger-zone {
    border-color: color-mix(in srgb, var(--danger), transparent 55%);
}
.fuel-admin {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
.vehicle-card {
    position: relative;
    overflow: hidden;
}
.vehicle-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
}
.garage-section {
    margin-bottom: 24px;
}
.garage-card {
    gap: 14px;
}
.garage-card-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}
.plate {
    min-width: 112px;
    padding: 7px 10px;
    border-radius: 6px;
    border: 2px solid var(--text);
    background: color-mix(in srgb, var(--surface-2), white 8%);
    color: var(--text);
    font-weight: 900;
    text-align: center;
    letter-spacing: 1px;
    white-space: nowrap;
}
.condition-line {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}
.condition-line strong {
    color: var(--text);
}
.map-board {
    position: relative;
    min-height: 360px;
    overflow: hidden;
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255,255,255,.05) 1px, transparent 1px),
        var(--surface-2);
    background-size: 56px 56px;
}
.map-board::before {
    content: "";
    position: absolute;
    inset: 18% 6% 20% 10%;
    border: 1px dashed color-mix(in srgb, var(--primary-2), transparent 40%);
    border-radius: 50%;
    transform: rotate(-8deg);
}
.city-pin {
    position: absolute;
    min-width: 132px;
    padding: 9px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface), transparent 8%);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translate(-50%, -50%);
}
.city-pin::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    position: absolute;
    left: 10px;
    top: -5px;
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary), transparent 78%);
}
.city-pin strong, .city-pin span { display: block; }
.city-pin span { color: var(--muted); font-size: 12px; margin-top: 3px; }

.guest-body {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(circle at 20% 10%, rgba(53,194,143,.22), transparent 32%),
        radial-gradient(circle at 80% 0%, rgba(42,167,232,.18), transparent 30%),
        var(--bg);
}
.auth-panel { width: min(980px, 100%); display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: stretch; }
.auth-hero { padding: 34px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.auth-hero h1 { margin-top: 22px; font-size: 46px; }
.auth-hero p { color: var(--muted); font-size: 18px; max-width: 520px; }
.auth-card { padding: 28px; border-radius: 8px; }
.empty-state { padding: 40px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
    .sidebar nav { display: flex; }
    .logout-form { margin-top: 0; margin-left: auto; }
    .stats-grid, .card-grid, .card-grid.small, .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .main { padding: 18px; }
    .topbar, .list-row, .admin-row, .order-row, .auth-panel { grid-template-columns: 1fr; display: grid; align-items: start; }
    .stats-grid, .card-grid, .card-grid.small, .grid.two, .grid.three { grid-template-columns: 1fr; }
    .sidebar { padding: 14px; }
    .brand span:last-child { display: none; }
    .sidebar nav a { white-space: nowrap; }
    .auth-hero h1 { font-size: 34px; }
}
