:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --text: #102238;
    --muted: #65758a;
    --border: #d9e2ec;
    --primary: #0d5bd7;
    --primary-dark: #0846a5;
    --success: #16865b;
    --warning: #b26a00;
    --danger: #bc2f3b;
    --shadow: 0 12px 34px rgba(15, 40, 75, .12);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
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); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.topbar {
    min-height: 64px;
    background: #0d2138;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 22px;
}
.brand { display: flex; gap: 11px; align-items: center; font-weight: 750; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 12px;
    display: grid; place-items: center; background: #1569e8; color: white;
}
.nav-links { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.nav-links a { color: #dce9fb; padding: 8px 10px; border-radius: 9px; }
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,.1); text-decoration: none; }
.page { width: min(1180px, calc(100% - 28px)); margin: 24px auto 36px; }
.page-narrow { width: min(760px, calc(100% - 28px)); margin: 28px auto; }
.card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow); padding: 22px;
}
.card + .card { margin-top: 18px; }
h1, h2, h3 { margin-top: 0; line-height: 1.18; }
h1 { font-size: clamp(1.55rem, 3vw, 2.15rem); }
h2 { font-size: 1.25rem; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field label { font-weight: 650; font-size: .94rem; }
.field input, .field select, .field textarea {
    width: 100%; border: 1px solid #bdcad8; border-radius: 11px;
    padding: 11px 12px; background: #fff; color: var(--text);
}
.field textarea { min-height: 104px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 3px solid rgba(13,91,215,.16); border-color: var(--primary);
}
.help { color: var(--muted); font-size: .84rem; line-height: 1.35; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.btn {
    border: 0; border-radius: 11px; padding: 11px 16px; cursor: pointer;
    font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #e8eef6; color: #20364f; }
.btn-danger { background: #ffe8eb; color: var(--danger); }
.alert { border-radius: 12px; padding: 12px 14px; border: 1px solid; margin-bottom: 16px; line-height: 1.45; }
.alert-success { background: #ebfaf4; border-color: #a9dfca; color: #116b49; }
.alert-warning { background: #fff7e7; border-color: #ecd097; color: #855000; }
.alert-danger { background: #fff0f1; border-color: #efb5bb; color: #922530; }
.alert-info { background: #edf5ff; border-color: #b9d3f5; color: #184d8e; }
.check-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.check-list li { display: flex; gap: 9px; align-items: flex-start; }
.check-ok { color: var(--success); font-weight: 800; }
.check-bad { color: var(--danger); font-weight: 800; }
.status-pill {
    display: inline-flex; align-items: center; gap: 7px; border-radius: 999px;
    padding: 7px 11px; font-size: .86rem; font-weight: 700; background: #e6edf5; color: #354a62;
}
.status-pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status-pill.online { background: #e8f8f2; color: var(--success); }
.status-pill.connecting { background: #fff4db; color: var(--warning); }
.status-pill.offline { background: #ffe9eb; color: var(--danger); }
.dashboard { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; }
.sidebar { display: grid; gap: 12px; align-content: start; }
.metric-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric { background: #f5f8fc; border: 1px solid var(--border); border-radius: 13px; padding: 12px; }
.metric strong { display: block; font-size: 1.35rem; margin-top: 3px; }
.vehicle-list { display: grid; gap: 10px; max-height: 530px; overflow: auto; padding-right: 3px; }
.vehicle-card {
    border: 1px solid var(--border); border-radius: 14px; padding: 13px; background: #fff; cursor: pointer;
}
.vehicle-card:hover, .vehicle-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,91,215,.10); }
.vehicle-card h3 { font-size: 1rem; margin-bottom: 7px; }
.vehicle-card .vehicle-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; font-size: .86rem; color: var(--muted); }
.map-panel { min-width: 0; }
#map { height: 650px; width: 100%; border-radius: 15px; border: 1px solid var(--border); background: #dfe8f1; }
.map-placeholder { display: grid; place-items: center; height: 650px; text-align: center; padding: 25px; color: var(--muted); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.code-box { background: #102238; color: #eaf3ff; border-radius: 12px; padding: 13px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88rem; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); }
.logo-large { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 1.55rem; margin-bottom: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .86rem; color: var(--muted); }
.hidden { display: none !important; }
.footer { text-align: center; color: var(--muted); font-size: .84rem; padding: 15px; }
@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
    #map, .map-placeholder { height: 520px; }
    .vehicle-list { max-height: none; }
}
@media (max-width: 650px) {
    .grid-2, .grid-3, .metric-row { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .page { width: min(100% - 18px, 1180px); margin-top: 12px; }
    .card { padding: 16px; border-radius: 13px; }
    #map, .map-placeholder { height: 440px; }
}
