:root {
    --navy-950: #071426;
    --navy-900: #0b1d35;
    --navy-800: #12345b;
    --blue: #1769aa;
    --blue-soft: #e9f3fb;
    --green: #147d62;
    --green-soft: #e6f7f1;
    --amber: #d88a13;
    --amber-soft: #fff4dc;
    --red: #c64036;
    --red-soft: #fff0ee;
    --ink: #142236;
    --muted: #586c83;
    --line: #cfdbe6;
    --surface: #fff;
    --canvas: #eef3f7;
    --shadow: 0 18px 48px -35px rgba(6, 26, 50, .62);
}

* { box-sizing: border-box; }
html { min-width: 0; background: var(--canvas); }
body {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(125deg, rgba(23, 105, 170, .09), transparent 28rem),
        linear-gradient(180deg, rgba(255, 255, 255, .82), transparent 24rem),
        var(--canvas);
    font-family: Manrope, system-ui, sans-serif;
}
html.dark {
    --ink: #eef5fb;
    --muted: #a8b8ca;
    --line: #334a61;
    --surface: #112132;
    --canvas: #08131f;
    --blue-soft: rgba(41, 131, 199, .17);
    --green-soft: rgba(20, 125, 98, .17);
    --amber-soft: rgba(216, 138, 19, .16);
    --red-soft: rgba(198, 64, 54, .17);
}
html.dark body { background: radial-gradient(circle at 87% 0, rgba(35, 114, 179, .17), transparent 30rem), var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 3px solid rgba(23, 105, 170, .32);
    outline-offset: 2px;
}
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.app-shell { min-height: 100vh; min-width: 0; }
.dashboard { min-height: 100vh; min-width: 0; padding: 28px 30px 60px; overflow: clip; transition: margin-left .28s ease; }
.dashboard-shell { width: min(1560px, 100%); margin: 0 auto; }

.dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow::before { content: ''; width: 28px; height: 3px; border-radius: 9px; background: var(--amber); }
.dashboard h1 { margin: 9px 0 8px; color: var(--navy-900); font-size: clamp(32px, 3.5vw, 51px); line-height: .98; letter-spacing: -.06em; font-weight: 800; }
html.dark .dashboard h1 { color: #f4f8fd; }
.subtitle, .source-note { max-width: 760px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.header-actions { display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.field { display: grid; min-width: 0; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.field select, .field input, .field textarea { min-height: 42px; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--ink); background: var(--canvas); font-size: 11px; letter-spacing: 0; text-transform: none; }
.compact select { min-width: 175px; background: var(--surface); }
.refresh-button, .secondary-button, .primary-button, .period-tabs button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 11px; font-size: 10px; font-weight: 800; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.refresh-button { border: 1px solid var(--navy-900); padding: 9px 14px; color: #fff; background: var(--navy-900); }
.refresh-button:hover { transform: translateY(-1px); background: var(--navy-800); }
.refresh-button:disabled { cursor: wait; opacity: .6; transform: none; }
.updated-at { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 9px; text-align: right; }
.global-error, .drawer-message { padding: 12px 14px; border: 1px solid #efc1bc; border-radius: 12px; color: #922f28; background: var(--red-soft); font-size: 10px; }
.global-error { margin-bottom: 14px; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.metric-card { position: relative; min-width: 0; min-height: 138px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; padding: 18px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); text-align: left; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.metric-card::before { content: ''; position: absolute; top: 0; right: 0; width: 6px; height: 100%; background: #7e93a9; }
.metric-card::after { content: ''; position: absolute; right: -57px; bottom: -74px; width: 145px; height: 145px; border: 26px solid color-mix(in srgb, var(--blue) 7%, transparent); border-radius: 50%; pointer-events: none; }
.metric-card:hover, .metric-card:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--blue) 48%, var(--line)); box-shadow: 0 20px 42px -30px rgba(6, 26, 50, .75); }
.metric-card.operation::before { background: var(--green); }
.metric-card.maintenance::before { background: var(--amber); }
.metric-card.activity::before, .metric-card.mileage::before { background: var(--blue); }
.metric-icon { position: relative; z-index: 1; float: right; color: #637d96; font-size: 23px; }
.operation .metric-icon { color: var(--green); }
.maintenance .metric-icon { color: var(--amber); }
.activity .metric-icon, .mileage .metric-icon { color: var(--blue); }
.metric-label { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.metric-card strong { position: relative; z-index: 1; display: block; margin-top: 21px; overflow: hidden; font-family: 'IBM Plex Mono', monospace; font-size: clamp(23px, 2.1vw, 32px); line-height: 1; letter-spacing: -.055em; white-space: nowrap; text-overflow: ellipsis; }
.metric-card small { position: relative; z-index: 1; display: block; margin-top: 10px; color: var(--muted); font-size: 9px; line-height: 1.4; }

.dashboard-grid { display: grid; gap: 14px; }
.upper-grid { grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); margin-bottom: 14px; }
.lower-grid { grid-template-columns: 1fr 1fr; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; padding: 18px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.panel h2, .drawer h2 { margin: 7px 0 0; font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
.legend { color: var(--muted); font-size: 9px; }
.legend i { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--green); }

.regions-list { display: grid; gap: 7px; }
.region-row { display: grid; grid-template-columns: minmax(125px, 1.45fr) repeat(4, minmax(60px, .65fr)) minmax(115px, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; color: var(--ink); background: var(--canvas); text-align: left; transition: border-color .15s ease, background .15s ease; }
.region-row:hover, .region-row:focus-visible { border-color: color-mix(in srgb, var(--blue) 55%, var(--line)); background: var(--blue-soft); }
.region-name { min-width: 0; overflow: hidden; font-size: 11px; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; }
.region-value { color: var(--muted); font-size: 9px; }
.region-value b { color: var(--ink); font-family: 'IBM Plex Mono', monospace; font-size: 10px; }
.availability { display: flex; align-items: center; gap: 8px; color: var(--green); font-family: 'IBM Plex Mono', monospace; font-size: 9px; }
.availability-bar { height: 6px; flex: 1; overflow: hidden; border-radius: 99px; background: color-mix(in srgb, var(--line) 84%, var(--surface)); }
.availability-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.region-chevron { color: var(--blue); font-size: 18px; }

.alerts-list { display: grid; gap: 8px; }
.alert-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 43px; border: 1px solid color-mix(in srgb, var(--amber) 36%, var(--line)); border-radius: 11px; padding: 9px 10px; color: var(--ink); background: var(--amber-soft); text-align: left; }
.alert-row:hover { border-color: var(--amber); }
.alert-row.critical { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); background: var(--red-soft); }
.alert-row .material-symbols-outlined { color: var(--amber); font-size: 19px; }
.alert-row.critical .material-symbols-outlined, .danger-text, .attention-icon { color: var(--red); }
.alert-row span:not(.material-symbols-outlined) { font-size: 10px; font-weight: 700; }
.alert-row strong { margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 15px; }

.mileage-panel { margin-bottom: 14px; }
.mileage-heading { align-items: center; }
.period-tabs { display: flex; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
.period-tabs button { min-height: 34px; border: 1px solid transparent; padding: 7px 10px; color: var(--muted); background: transparent; }
.period-tabs button:hover, .period-tabs button.active { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, var(--line)); background: var(--surface); }
.km-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.km-summary div { min-width: 0; padding: 13px 14px; background: var(--canvas); }
.km-summary span { display: block; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.km-summary strong { display: block; margin-top: 6px; overflow: hidden; font-family: 'IBM Plex Mono', monospace; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.trend { display: flex; align-items: flex-end; gap: 4px; height: 125px; padding-top: 20px; overflow: hidden; }
.trend-column { display: flex; flex: 1; min-width: 4px; height: 100%; align-items: flex-end; }
.trend-column i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #4d9cdb, var(--blue)); }
.vehicle-ranking { display: grid; gap: 1px; background: var(--line); }
.rank-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 10px 5px; background: var(--surface); }
.rank-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; color: var(--navy-800); background: var(--blue-soft); font-family: 'IBM Plex Mono', monospace; font-size: 9px; font-weight: 600; }
html.dark .rank-number { color: #a9d1f1; }
.rank-info { min-width: 0; }
.rank-info strong, .rank-info small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rank-info strong { font-size: 10px; }
.rank-info small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.rank-km { font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 600; }
.source-badge, .source-pill { display: inline-flex; align-items: center; margin-left: 6px; border-radius: 99px; padding: 4px 7px; color: var(--blue); background: var(--blue-soft); font-family: Manrope, sans-serif; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.empty-state { margin: 0; padding: 26px; color: var(--muted); font-size: 10px; line-height: 1.55; text-align: center; }

.drawer-layer { position: fixed; inset: 0; z-index: 1200; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(3, 12, 24, .67); backdrop-filter: blur(4px); }
.drawer { position: absolute; inset: 0 0 0 auto; width: min(720px, 100%); display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--surface); box-shadow: -30px 0 80px -35px rgba(0, 0, 0, .72); animation: drawer-in .24s ease both; }
.drawer-header { position: relative; overflow: hidden; flex: 0 0 auto; display: flex; justify-content: space-between; gap: 16px; padding: 22px 24px; color: #fff; background: linear-gradient(135deg, var(--navy-950), var(--navy-800)); }
.drawer-header::after { content: ''; position: absolute; top: 0; right: 0; width: 8px; height: 100%; background: var(--amber); }
.drawer-header .eyebrow { color: #b9d5ec; font-size: 10px; }
.drawer-header .eyebrow::before { display: none; }
.drawer-header h2 { margin-top: 7px; font-family: 'IBM Plex Mono', monospace; font-size: 23px; letter-spacing: -.04em; }
.drawer-header p:last-child { margin: 8px 0 0; color: #d2dfec; font-size: 12px; line-height: 1.45; }
.icon-button { position: relative; z-index: 1; width: 39px; height: 39px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(255, 255, 255, .22); border-radius: 11px; color: #fff; background: rgba(255, 255, 255, .08); }
.icon-button:hover { background: rgba(255, 255, 255, .16); }
.drawer-toolbar { flex: 0 0 auto; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.search-field { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 11px; background: var(--canvas); }
.search-field .material-symbols-outlined { color: #75899e; font-size: 18px; }
.search-field input { width: 100%; height: 44px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.drawer-message { margin: 12px 24px 0; }
.drawer-body { min-height: 0; overflow-y: auto; padding: 0 24px 32px; font-size: 13px; line-height: 1.5; }
.drawer-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 -24px 18px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.drawer-fact { min-width: 0; padding: 14px 17px; border-right: 1px solid var(--line); }
.drawer-fact:last-child { border-right: 0; }
.drawer-fact span, .drawer-fact strong { display: block; }
.drawer-fact span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.drawer-fact strong { margin-top: 6px; overflow: hidden; font-family: 'IBM Plex Mono', monospace; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.calculation-note { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 14px; padding: 13px 14px; border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line)); border-radius: 12px; color: var(--ink); background: var(--blue-soft); font-size: 12px; line-height: 1.6; }
.calculation-note .material-symbols-outlined { flex: 0 0 auto; color: var(--blue); font-size: 18px; }
.drawer-list { display: grid; gap: 9px; }
.vehicle-card, .mileage-row { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface); }
.vehicle-card-head, .mileage-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.vehicle-card h3, .mileage-main h3 { margin: 0; color: var(--ink); font-family: 'IBM Plex Mono', monospace; font-size: 14px; }
.vehicle-card p, .mileage-main p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.mileage-total { flex: 0 0 auto; color: var(--navy-800); font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 600; }
html.dark .mileage-total { color: #9dc9ee; }
.mileage-breakdown { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.mileage-breakdown div { min-width: 0; padding: 9px 10px; background: var(--canvas); }
.mileage-breakdown span, .mileage-breakdown strong { display: block; }
.mileage-breakdown span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.mileage-breakdown strong { margin-top: 5px; overflow: hidden; font-family: 'IBM Plex Mono', monospace; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.mileage-warning { margin: 10px 0 0; color: #8b5a0d; font-size: 11px; line-height: 1.55; }
html.dark .mileage-warning { color: #f1bd67; }
.vehicle-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }
.tag { padding: 6px 9px; border-radius: 99px; color: var(--muted); background: var(--canvas); font-size: 10px; font-weight: 700; }
.tag.green { color: var(--green); background: var(--green-soft); }
.tag.amber { color: #96600f; background: var(--amber-soft); }
.tag.red { color: var(--red); background: var(--red-soft); }
.vehicle-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 11px; }
.vehicle-metrics div { padding: 9px 10px; border-radius: 10px; background: var(--canvas); }
.vehicle-metrics span, .vehicle-metrics strong { display: block; }
.vehicle-metrics span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.vehicle-metrics strong { margin-top: 5px; font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.vehicle-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.secondary-button, .primary-button { border: 1px solid var(--line); padding: 9px 12px; font-size: 11px; text-decoration: none; }
.secondary-button { color: var(--ink); background: var(--surface); }
.secondary-button:hover { border-color: var(--blue); }
.primary-button { border-color: var(--navy-900); color: #fff; background: var(--navy-900); }
.primary-button:hover { background: var(--navy-800); }
.edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; padding-top: 18px; }
.edit-form .full { grid-column: 1 / -1; }
.edit-form textarea { min-height: 88px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.history-entry { padding: 13px 0; border-bottom: 1px solid var(--line); }
.history-entry strong, .history-entry span { display: block; }
.history-entry strong { font-size: 13px; }
.history-entry span { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.drawer .field { font-size: 11px; }
.drawer .field select, .drawer .field input, .drawer .field textarea { font-size: 13px; }
.drawer .empty-state { font-size: 12px; }
.drawer .drawer-message { font-size: 12px; }
.skeleton { animation: pulse 1.2s ease-in-out infinite; }
.loading-block { min-height: 120px; border-radius: 11px; background: linear-gradient(90deg, var(--canvas), color-mix(in srgb, var(--line) 70%, var(--surface)), var(--canvas)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

@keyframes drawer-in { from { transform: translateX(25px); opacity: .4; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media (max-width: 1280px) {
    .dashboard { padding-right: 20px; padding-left: 20px; }
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .upper-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
    .dashboard, body:not(.sidebar-collapsed) main.dashboard, body.sidebar-collapsed main.dashboard { margin-left: 0 !important; padding: 21px 16px 45px; }
    .dashboard-header { flex-direction: column; }
    .header-actions { width: 100%; justify-content: flex-start; }
    .updated-at { text-align: left; }
}
@media (max-width: 720px) {
    .dashboard { padding: 17px 10px 35px; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .metric-card { min-height: 116px; padding: 14px; }
    .metric-card strong { margin-top: 16px; font-size: 23px; }
    .region-row { grid-template-columns: minmax(0, 1fr) auto auto; }
    .region-row .region-value:nth-of-type(n+3), .region-row .availability { display: none; }
    .mileage-heading { align-items: flex-start; flex-direction: column; }
    .period-tabs { width: 100%; overflow-x: auto; }
    .period-tabs button { flex: 1; white-space: nowrap; }
    .km-summary { grid-template-columns: repeat(2, 1fr); }
    .km-summary div:last-child { grid-column: 1 / -1; }
    .lower-grid { grid-template-columns: 1fr; }
    .drawer-header, .drawer-toolbar { padding-left: 17px; padding-right: 17px; }
    .drawer-body { padding-left: 17px; padding-right: 17px; }
    .drawer-summary { margin-left: -17px; margin-right: -17px; }
    .mileage-breakdown, .vehicle-metrics { grid-template-columns: 1fr 1fr; }
    .edit-form { grid-template-columns: 1fr; }
    .edit-form .full { grid-column: auto; }
}
@media (max-width: 430px) {
    .dashboard h1 { font-size: 35px; }
    .metric-label { font-size: 8px; }
    .metric-card small { display: none; }
    .metric-card { min-height: 102px; }
    .panel { padding: 15px; }
    .compact { width: 100%; }
    .compact select { min-width: 0; }
    .drawer-summary { grid-template-columns: 1fr 1fr; }
    .drawer-fact:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); }
}
