/* =========================================================================
 *  CTM — Caldera Transport Monitoring
 *  Design system: Mission Control / Caldera
 *  Deep navy schematic backgrounds with warm caldera accent.
 *  Typography: Unbounded (display), Manrope (UI), JetBrains Mono (data).
 *  Atmosphere: faint grid overlay, ambient corner glow, radar pulse motifs.
 * ========================================================================= */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@500;600;700;800&family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------- Tokens (light) ---------- */
:root {
    --bg-deep:        #f4f3ee;          /* warm parchment */
    --bg-surface:     #ffffff;
    --bg-elevated:    #ffffff;
    --bg-sunken:      #ebe9e1;
    --line:           #d8d4c5;          /* hairline */
    --line-strong:    #b9b3a1;
    --hairline:       rgba(20, 26, 41, 0.08);

    --ink:            #14141d;
    --ink-soft:       #4a4f5e;
    --ink-mute:       #8a8e9c;
    --ink-faint:      #b3b6c2;

    --accent:         #d44a14;          /* caldera orange */
    --accent-strong:  #b73a08;
    --accent-soft:    #f7d4c0;
    --accent-glow:    rgba(212, 74, 20, 0.18);

    --warm:           #c98a16;          /* amber */
    --emerald:        #157f5a;
    --emerald-soft:   #b8e0cf;
    --crimson:        #b3261e;
    --crimson-soft:   #f4cbc8;
    --azure:          #1f6feb;

    --grid-line:      rgba(20, 26, 41, 0.04);
    --scan-color:     rgba(212, 74, 20, 0.12);

    --shadow-sm:      0 1px 2px rgba(20, 26, 41, 0.04), 0 1px 0 rgba(255,255,255,0.4) inset;
    --shadow-md:      0 4px 16px -8px rgba(20, 26, 41, 0.18), 0 1px 0 rgba(255,255,255,0.4) inset;
    --shadow-lg:      0 18px 48px -24px rgba(20, 26, 41, 0.32);

    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 22px;
    --r-pill: 999px;

    --t-fast:  120ms;
    --t-base:  220ms;
    --t-slow:  420ms;
    --ease:    cubic-bezier(0.32, 0.72, 0.32, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.36, 0.64, 1);

    --rail-w:  72px;
    --topbar-h: 60px;
}

/* ---------- Tokens (dark) — primary mission-control mode ---------- */
[data-theme="dark"] {
    --bg-deep:        #0a0e1a;          /* near-black navy */
    --bg-surface:     #11172a;          /* card background */
    --bg-elevated:    #161e36;          /* hover / elevated */
    --bg-sunken:      #070a14;
    --line:           #1f2842;
    --line-strong:    #2e3a5d;
    --hairline:       rgba(255, 255, 255, 0.06);

    --ink:            #e7ebf4;
    --ink-soft:       #b4bcd1;
    --ink-mute:       #7a8299;
    --ink-faint:      #515a73;

    --accent:         #ff7a2e;          /* caldera orange — brighter on dark */
    --accent-strong:  #ff9656;
    --accent-soft:    rgba(255, 122, 46, 0.18);
    --accent-glow:    rgba(255, 122, 46, 0.30);

    --warm:           #f7b94f;
    --emerald:        #2ee4a8;
    --emerald-soft:   rgba(46, 228, 168, 0.16);
    --crimson:        #ff5a5f;
    --crimson-soft:   rgba(255, 90, 95, 0.16);
    --azure:          #6aa5ff;

    --grid-line:      rgba(255, 255, 255, 0.025);
    --scan-color:     rgba(255, 122, 46, 0.18);

    --shadow-sm:      0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:      0 1px 0 rgba(255,255,255,0.05) inset, 0 8px 28px -8px rgba(0,0,0,0.5);
    --shadow-lg:      0 1px 0 rgba(255,255,255,0.05) inset, 0 32px 64px -28px rgba(0,0,0,0.7);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-deep: #0a0e1a; --bg-surface: #11172a; --bg-elevated: #161e36; --bg-sunken: #070a14;
        --line: #1f2842; --line-strong: #2e3a5d; --hairline: rgba(255,255,255,0.06);
        --ink: #e7ebf4; --ink-soft: #b4bcd1; --ink-mute: #7a8299; --ink-faint: #515a73;
        --accent: #ff7a2e; --accent-strong: #ff9656; --accent-soft: rgba(255,122,46,0.18); --accent-glow: rgba(255,122,46,0.30);
        --warm: #f7b94f; --emerald: #2ee4a8; --emerald-soft: rgba(46,228,168,0.16);
        --crimson: #ff5a5f; --crimson-soft: rgba(255,90,95,0.16); --azure: #6aa5ff;
        --grid-line: rgba(255,255,255,0.025); --scan-color: rgba(255,122,46,0.18);
        --shadow-sm: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 8px rgba(0,0,0,0.3);
        --shadow-md: 0 1px 0 rgba(255,255,255,0.05) inset, 0 8px 28px -8px rgba(0,0,0,0.5);
        --shadow-lg: 0 1px 0 rgba(255,255,255,0.05) inset, 0 32px 64px -28px rgba(0,0,0,0.7);
    }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: 'Manrope', -apple-system, system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg-deep);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

/* ---------- Atmospheric backdrop ---------- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 32px 32px;
    background-position: -1px -1px;
    z-index: 0;
}
body::after {
    content: '';
    position: fixed;
    bottom: -25vh;
    right: -10vw;
    width: 70vw;
    height: 70vw;
    pointer-events: none;
    background: radial-gradient(closest-side, var(--accent-glow), transparent 70%);
    opacity: 0.55;
    z-index: 0;
    animation: caldera-breath 14s ease-in-out infinite;
}
@keyframes caldera-breath {
    0%, 100% { opacity: 0.45; transform: scale(1); }
    50%      { opacity: 0.7;  transform: scale(1.08); }
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--accent-strong); }

::selection { background: var(--accent); color: #fff; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 10px;
    border: 2px solid var(--bg-deep);
}
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ---------- Focus ---------- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* =========================================================================
 *  APP SHELL — vertical icon-rail + topbar + main
 * ========================================================================= */

.app-shell {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "rail topbar"
        "rail main";
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.rail {
    grid-area: rail;
    background: var(--bg-surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0 16px;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}

.rail-brand {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 18px;
    border-radius: var(--r-md);
    transition: transform var(--t-base) var(--ease-spring);
}
.rail-brand:hover { transform: rotate(-6deg) scale(1.06); }

.rail-divider {
    width: 24px;
    height: 1px;
    background: var(--line);
    margin: 8px 0;
    flex-shrink: 0;
}

.rail-link {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-mute);
    border-radius: var(--r-md);
    position: relative;
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.rail-link:hover { color: var(--ink); background: var(--bg-elevated); }
.rail-link.is-active {
    color: var(--accent);
    background: var(--accent-soft);
}
.rail-link.is-active::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.rail-tooltip {
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: var(--ink);
    color: var(--bg-surface);
    padding: 5px 10px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
    z-index: 60;
}
.rail-link:hover .rail-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.rail-spacer { flex: 1; }

/* ---------- Top bar ---------- */
.topbar {
    grid-area: topbar;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
}

.topbar-left {
    display: flex;
    align-items: baseline;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.page-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.topbar-clock {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-soft);
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-variant-numeric: tabular-nums;
    background: var(--bg-deep);
}
.topbar-clock::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 0 4px var(--emerald-soft);
    animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: 0.7; }
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    background: var(--bg-deep);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
}
.user-pill-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: 'Unbounded', sans-serif;
    font-size: 11px;
    font-weight: 700;
}

.main {
    grid-area: main;
    background: var(--bg-deep);
    overflow: hidden;
    position: relative;
}
.main--bleed {
    padding: 0;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
}
.main--padded {
    padding: 28px 32px 56px;
    overflow-y: auto;
    min-height: calc(100vh - var(--topbar-h));
}

/* =========================================================================
 *  LOGO
 * ========================================================================= */

.logo-mark {
    width: 32px;
    height: 32px;
    display: block;
    flex-shrink: 0;
    color: var(--accent);
}
.logo-mark .logo-orbit {
    transform-origin: 16px 16px;
    animation: logo-orbit 12s linear infinite;
}
@keyframes logo-orbit { to { transform: rotate(360deg); } }
.logo-mark .logo-pulse {
    transform-origin: 16px 16px;
    animation: logo-pulse 4s ease-in-out infinite;
}
@keyframes logo-pulse {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 0.35; }
}

.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-text-mark {
    font-family: 'Unbounded', sans-serif;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.04em;
    color: var(--ink);
}
.logo-text-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-top: 4px;
}

/* =========================================================================
 *  TYPOGRAPHY HELPERS
 * ========================================================================= */
.label-eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.text-mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.text-display { font-family: 'Unbounded', sans-serif; letter-spacing: -0.01em; }

.section-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.section-title::before {
    content: '';
    width: 4px;
    height: 14px;
    background: var(--accent);
    border-radius: 1px;
}

/* =========================================================================
 *  BUTTONS
 * ========================================================================= */
.btn {
    --b-bg: var(--bg-elevated);
    --b-fg: var(--ink);
    --b-border: var(--line);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--b-fg);
    background: var(--b-bg);
    border: 1px solid var(--b-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease);
    white-space: nowrap;
    line-height: 1;
    position: relative;
}
.btn:hover {
    background: var(--bg-surface);
    border-color: var(--line-strong);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn[disabled], .btn[data-busy="1"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    --b-bg: var(--accent);
    --b-fg: #ffffff;
    --b-border: var(--accent);
    box-shadow: 0 6px 18px -10px var(--accent), 0 1px 0 rgba(255,255,255,0.2) inset;
}
.btn-primary:hover {
    --b-bg: var(--accent-strong);
    --b-border: var(--accent-strong);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px -10px var(--accent);
}
.btn-primary:active { transform: translateY(0) scale(0.99); }

.btn-ghost { --b-bg: transparent; --b-border: var(--line); }
.btn-ghost:hover { --b-bg: var(--bg-elevated); --b-border: var(--accent); --b-fg: var(--accent); }

.btn-danger { --b-bg: var(--crimson); --b-fg: #ffffff; --b-border: var(--crimson); }
.btn-danger:hover { filter: brightness(1.1); }

.btn-outline { --b-bg: transparent; --b-border: var(--accent); --b-fg: var(--accent); }
.btn-outline:hover { --b-bg: var(--accent-soft); }
.btn-outline.is-active {
    --b-bg: var(--accent);
    --b-fg: #fff;
    --b-border: var(--accent);
}

.btn-secondary { --b-bg: var(--bg-deep); --b-border: var(--line); }
.btn-secondary:hover { --b-bg: var(--bg-elevated); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
    padding: 7px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease);
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn-icon-sm { padding: 5px 7px; }
.btn-icon-sm.btn-icon-danger { color: var(--ink-mute); }
.btn-icon-sm.btn-icon-danger:hover { color: var(--crimson); border-color: var(--crimson); background: var(--crimson-soft); }

.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-with-icon { display: inline-flex; align-items: center; gap: 6px; }

/* =========================================================================
 *  FORMS
 * ========================================================================= */

.input,
.modal-input,
.date-input,
.assign-select,
.company-filter,
.sidebar-search,
.vehicle-selector,
.table-toolbar select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-deep);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease);
}
.input:focus,
.modal-input:focus,
.date-input:focus,
.assign-select:focus,
.company-filter:focus,
.sidebar-search:focus,
.vehicle-selector:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

select.modal-input,
.assign-select,
.company-filter,
.vehicle-selector,
.table-toolbar select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='%237a8299' d='M5 7.5L0.5 3h9z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

label { font-size: 12px; font-weight: 600; color: var(--ink-soft); display: inline-block; margin-bottom: 6px; }

[data-theme="dark"] .date-input::-webkit-calendar-picker-indicator { filter: invert(0.85) hue-rotate(180deg); }

/* =========================================================================
 *  CARD / SURFACE
 * ========================================================================= */

.card,
.info-panel-section,
.chart-section,
.filter-bar,
.sms-form-section,
.sms-info,
.sms-command {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.card::before,
.info-panel-section::before,
.chart-section::before,
.filter-bar::before,
.sms-form-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
    opacity: 0.6;
}

/* =========================================================================
 *  TABLE
 * ========================================================================= */

.table-wrapper {
    overflow: auto;
    max-height: 520px;
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead {
    background: var(--bg-elevated);
    position: sticky;
    top: 0;
    z-index: 2;
}
.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
.data-table td {
    padding: 11px 16px;
    border-top: 1px solid var(--hairline);
    color: var(--ink);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr { transition: background var(--t-fast) var(--ease); }
.data-table tbody tr:hover { background: var(--bg-elevated); }
.data-table tbody tr:nth-child(even) td { background: var(--bg-deep); }
.data-table tbody tr:nth-child(even):hover td { background: var(--bg-elevated); }

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 0 0 14px;
    color: var(--ink-mute);
    font-size: 12.5px;
}
.table-toolbar .tt-left,
.table-toolbar .tt-right {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.table-toolbar select {
    padding: 5px 22px 5px 8px;
    font-size: 12px;
    width: auto;
    background-position: right 6px center;
}
.table-toolbar .tt-count strong { color: var(--ink); font-family: 'JetBrains Mono', monospace; }

.skeleton-row td { padding: 11px 16px; }
.skeleton-bar {
    display: inline-block;
    height: 12px;
    width: 80%;
    background: linear-gradient(90deg, var(--bg-elevated), var(--line), var(--bg-elevated));
    background-size: 200% 100%;
    border-radius: 3px;
    animation: skeleton 1.4s ease-in-out infinite;
}
@keyframes skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.no-data {
    text-align: center;
    color: var(--ink-mute);
    padding: 40px 20px;
    font-size: 13px;
}

.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
}

/* =========================================================================
 *  STATUS DOTS / BADGES
 * ========================================================================= */

.status-dot,
.vehicle-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    background: var(--ink-faint);
}
.status-dot.dot-online,
.vehicle-status-dot.dot-online {
    background: var(--emerald);
    box-shadow: 0 0 0 0 var(--emerald-soft);
    animation: radar-pulse 2.4s ease-out infinite;
}
@keyframes radar-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 228, 168, 0.45); }
    70%  { box-shadow: 0 0 0 8px rgba(46, 228, 168, 0); }
    100% { box-shadow: 0 0 0 8px rgba(46, 228, 168, 0); }
}
.dot-offline { background: var(--ink-faint); }

.status-badge {
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-online { color: var(--emerald); background: var(--emerald-soft); }
.status-offline { color: var(--ink-mute); background: var(--bg-elevated); border: 1px solid var(--line); }

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* =========================================================================
 *  DASHBOARD
 * ========================================================================= */

.dashboard-split {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
}

.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.sidebar-header {
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-surface);
}
.sidebar-company-name {
    font-family: 'Unbounded', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}
.company-filter { margin-bottom: 12px; }

.sidebar-search-wrap { position: relative; margin-bottom: 14px; }
.sidebar-search { padding-right: 32px; }
.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--ink-mute);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: none;
    line-height: 0;
}
.search-clear.is-visible { display: flex; }
.search-clear:hover { background: var(--bg-elevated); color: var(--ink); }

.sidebar-stats {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--ink-mute);
    font-size: 12px;
}
.vehicle-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 10px;
    border-radius: var(--r-sm);
    font-variant-numeric: tabular-nums;
}
.sidebar-stats-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.sidebar-vehicle-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 12px 24px;
}

.sv-row {
    padding: 12px 12px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
    border-left: 2px solid transparent;
    margin-bottom: 4px;
    position: relative;
    background: transparent;
}
.sv-row:hover { background: var(--bg-elevated); }
.sv-row.sv-row-active {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}
.sv-row-main {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sv-info { flex: 1; min-width: 0; }
.sv-name {
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sv-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--ink-mute);
    margin-top: 2px;
    letter-spacing: 0.04em;
}
.sv-metrics { flex-shrink: 0; text-align: right; }
.sv-speed {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.sv-speed small {
    display: block;
    font-size: 9px;
    font-weight: 500;
    color: var(--ink-mute);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 1px;
}
.sv-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 7px;
    padding-left: 18px;
}
.sv-lastseen {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--ink-mute);
    letter-spacing: 0.04em;
}
.sv-detail-link {
    color: var(--ink-mute);
    transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
    display: flex;
    align-items: center;
}
.sv-detail-link:hover { color: var(--accent); transform: translateX(2px); }

.main-map { position: relative; overflow: hidden; }
.main-map #map { width: 100%; height: 100%; }

/* =========================================================================
 *  DEVICE DETAIL
 * ========================================================================= */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--ink-mute);
    margin-bottom: 18px;
    text-transform: uppercase;
}
.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--ink-faint); }
.breadcrumb-current { color: var(--ink); }

.device-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.device-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.device-header-left .page-title {
    margin: 0;
    font-family: 'Unbounded', sans-serif;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.device-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.device-id-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--ink-mute);
    letter-spacing: 0.06em;
    background: var(--bg-elevated);
    padding: 5px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
}
.vehicle-selector {
    width: auto;
    min-width: 200px;
    max-width: 320px;
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    transition: transform var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}
.stat-value {
    font-family: 'Unbounded', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}
.stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
}
.stat-violations .stat-value { color: var(--crimson); }

.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}
.filter-bar-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ink-mute);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.04em;
}
.filter-bar-hint svg { color: var(--accent); }
.filter-bar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-bar-controls > label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 0;
}
.filter-bar-controls .date-input {
    width: auto;
    min-width: 160px;
}
.filter-bar-buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
}

.map-section { margin-bottom: 22px; }
.map-section #map {
    height: clamp(380px, 60vh, 720px) !important;
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.speed-legend {
    display: flex;
    gap: 14px;
    padding: 12px 4px 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--ink-soft);
    flex-wrap: wrap;
    letter-spacing: 0.04em;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 4px; border-radius: 2px; display: inline-block; }

.info-panel-section { margin-bottom: 22px; }
.info-grid { display: flex; flex-direction: column; gap: 0; }
.info-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 28px;
}
.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--hairline);
    gap: 16px;
}
.info-item:last-child { border-bottom: none; }
.info-item-full { grid-column: 1 / -1; }
.info-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
    flex-shrink: 0;
}
.info-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    text-align: right;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.chart-section { margin-bottom: 22px; }
.chart-container { height: 320px; position: relative; }

.table-section { margin-bottom: 22px; }

/* =========================================================================
 *  ADMIN
 * ========================================================================= */

.admin-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 22px;
    padding-bottom: 0;
}
.admin-tab {
    padding: 10px 18px;
    background: transparent;
    border: none;
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-mute);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.admin-panel { margin-bottom: 32px; }
.admin-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.admin-panel-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.admin-panel-form .modal-input {
    margin-bottom: 0;
    width: auto;
    min-width: 240px;
}

/* =========================================================================
 *  MODAL
 * ========================================================================= */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.55);
    backdrop-filter: blur(6px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
    animation: modal-fade var(--t-base) var(--ease) both;
}
@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 26px 28px;
    min-width: 340px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modal-rise var(--t-base) var(--ease-spring) both;
    position: relative;
}
.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}
@keyframes modal-rise {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin-bottom: 4px;
}
.modal-subtitle {
    font-size: 13px;
    color: var(--ink-mute);
    margin-bottom: 18px;
    line-height: 1.55;
}
.modal-form-group { margin-bottom: 14px; }
.modal-form-group label { display: block; }
.modal-form-group .modal-input { margin-bottom: 0; }
.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.form-error {
    color: var(--crimson);
    font-size: 12.5px;
    font-weight: 600;
    display: inline-block;
    min-height: 1em;
}

/* =========================================================================
 *  TOAST
 * ========================================================================= */

#toast-root {
    position: fixed;
    top: calc(var(--topbar-h) + 16px);
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
}
.toast {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-spring);
    font-size: 13px;
    line-height: 1.45;
}
.toast.toast-shown { opacity: 1; transform: translateX(0); }
.toast.toast-leaving { opacity: 0; transform: translateX(20px); }
.toast-success { border-left-color: var(--emerald); }
.toast-success .toast-icon { color: var(--emerald); }
.toast-error { border-left-color: var(--crimson); }
.toast-error .toast-icon { color: var(--crimson); }
.toast-info .toast-icon { color: var(--accent); }
.toast-icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 2px; }
.toast-msg { flex: 1; min-width: 0; word-wrap: break-word; }
.toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--ink-mute);
    cursor: pointer;
    padding: 2px;
    border-radius: var(--r-xs);
}
.toast-close:hover { color: var(--ink); }

/* =========================================================================
 *  LEAFLET OVERRIDES
 * ========================================================================= */

.leaflet-container {
    background: var(--bg-deep);
    font-family: 'Manrope', sans-serif;
}
.leaflet-popup-content-wrapper {
    background: var(--bg-surface);
    color: var(--ink);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    padding: 4px;
}
.leaflet-popup-tip { background: var(--bg-surface); border: 1px solid var(--line); }
.leaflet-popup-content { font-size: 12.5px; line-height: 1.55; margin: 10px 14px; }
.leaflet-popup-content b { font-family: 'Unbounded', sans-serif; font-size: 13px; color: var(--accent); display: block; margin-bottom: 4px; }
.leaflet-popup-content a { color: var(--accent); }
[data-theme="dark"] .leaflet-popup-close-button { color: var(--ink-mute) !important; }
[data-theme="dark"] .leaflet-popup-close-button:hover { color: var(--ink) !important; }

.leaflet-control-layers,
.leaflet-control-attribution,
.leaflet-control-zoom a {
    background: var(--bg-surface) !important;
    color: var(--ink) !important;
    border-color: var(--line) !important;
}
.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 30px !important;
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.leaflet-control-zoom a:hover { background: var(--accent-soft) !important; color: var(--accent) !important; }

.device-marker, .current-position-marker, .track-start-marker,
.track-end-marker, .track-single-marker, .track-arrow, .stop-marker {
    background: transparent !important;
    border: none !important;
}

.veh-marker {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--emerald);
    border: 2px solid #fff;
    box-shadow: 0 0 0 0 rgba(46, 228, 168, 0.5), 0 1px 4px rgba(0,0,0,0.4);
    animation: veh-pulse 2.6s ease-out infinite;
}
.veh-marker.is-offline {
    background: var(--ink-mute);
    animation: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
@keyframes veh-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 228, 168, 0.45), 0 1px 4px rgba(0,0,0,0.4); }
    70%  { box-shadow: 0 0 0 14px rgba(46, 228, 168, 0), 0 1px 4px rgba(0,0,0,0.4); }
    100% { box-shadow: 0 0 0 0 rgba(46, 228, 168, 0), 0 1px 4px rgba(0,0,0,0.4); }
}

/* =========================================================================
 *  PAGE-LOAD MOTION
 * ========================================================================= */

@media (prefers-reduced-motion: no-preference) {
    .reveal {
        animation: reveal 600ms var(--ease-out) both;
    }
    .reveal-stagger > * {
        animation: reveal 500ms var(--ease-out) both;
    }
    .reveal-stagger > *:nth-child(1) { animation-delay:  0ms; }
    .reveal-stagger > *:nth-child(2) { animation-delay: 60ms; }
    .reveal-stagger > *:nth-child(3) { animation-delay: 120ms; }
    .reveal-stagger > *:nth-child(4) { animation-delay: 180ms; }
    .reveal-stagger > *:nth-child(5) { animation-delay: 240ms; }
    .reveal-stagger > *:nth-child(6) { animation-delay: 300ms; }
    .reveal-stagger > *:nth-child(7) { animation-delay: 360ms; }
    .reveal-stagger > *:nth-child(8) { animation-delay: 420ms; }
}
@keyframes reveal {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
 *  SMS SETUP
 * ========================================================================= */

.sms-setup-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 22px;
    align-items: start;
}
.sms-form { position: sticky; top: calc(var(--topbar-h) + 20px); }
.sms-form-section { padding: 20px; }
.sms-form-section .modal-form-group { margin-bottom: 12px; }
.sms-form-section .modal-form-group:last-child { margin-bottom: 0; }
.sms-form-section .modal-input { margin-bottom: 0; }
.sms-results { min-width: 0; }
.sms-section-header {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin: 18px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.sms-section-header:first-child { margin-top: 0; }
.sms-command { padding: 14px; margin-bottom: 12px; }
.sms-command-title {
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 8px;
}
.sms-command-text {
    background: var(--bg-deep);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    color: var(--accent);
    word-break: break-all;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.sms-command-text code { flex: 1; font-family: inherit; white-space: pre-wrap; word-break: break-all; }
.sms-copy-btn {
    flex-shrink: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 5px 7px;
    cursor: pointer;
    color: var(--ink-soft);
    display: inline-flex;
    align-items: center;
    transition: all var(--t-fast) var(--ease);
    min-width: 30px;
}
.sms-copy-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.sms-copy-btn-success { background: var(--emerald) !important; color: #fff !important; border-color: var(--emerald) !important; }
.sms-note { font-size: 12px; color: var(--ink-mute); margin-top: 6px; }

.sms-info { padding: 0; margin: 28px 0 32px; }
.sms-info-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    cursor: pointer;
    color: var(--ink);
    user-select: none;
    border-radius: var(--r-lg);
    transition: background var(--t-fast) var(--ease);
}
.sms-info-toggle:hover { background: var(--bg-elevated); }
.sms-info-chevron { transition: transform var(--t-base) var(--ease); }
.sms-info-body { padding: 0 18px 18px; }

/* =========================================================================
 *  LOGIN PAGE
 *  Locked to 100vh — must fit entirely without page scroll, even on
 *  laptop-sized viewports (~720px tall). All vertical sizing is compact
 *  and uses clamp() so big screens still breathe a bit.
 * ========================================================================= */
.login-shell {
    height: 100vh;
    max-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    z-index: 1;
    overflow: hidden;
}
body:has(.login-shell) { overflow: hidden; }

.login-aside {
    position: relative;
    overflow: hidden;
    background: var(--bg-surface);
    border-right: 1px solid var(--line);
    padding: clamp(28px, 5vh, 56px) clamp(28px, 4vw, 56px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(20px, 4vh, 56px);
    min-height: 0;
}
/* Background SVG must stay absolutely positioned. The next rule was
 * accidentally overriding `position` for the SVG too — that pushed the
 * brand statement out of view. `:not(.login-aside-bg)` excludes it. */
.login-aside-bg {
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.55;
}
.login-aside > *:not(.login-aside-bg) {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.login-brand .logo-mark { width: 40px; height: 40px; }
.login-brand .logo-text-mark { font-size: 20px; }
.login-brand .logo-text-tag { font-size: 10px; }

.login-statement { max-width: 460px; }
.login-statement h1 {
    font-family: 'Unbounded', sans-serif;
    font-weight: 700;
    font-size: clamp(22px, 3.4vw, 36px);
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: var(--ink);
    margin-bottom: 12px;
}
.login-statement h1 em {
    font-style: normal;
    color: var(--accent);
}
.login-statement p {
    font-size: clamp(12.5px, 1.1vw, 14px);
    color: var(--ink-soft);
    line-height: 1.55;
    max-width: 400px;
}

.login-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 420px;
}
.login-stat-value {
    font-family: 'Unbounded', sans-serif;
    font-weight: 700;
    font-size: clamp(16px, 1.8vw, 22px);
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.login-stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-top: 4px;
}

.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 5vh, 48px) 32px;
    background: var(--bg-deep);
    min-height: 0;
    overflow-y: auto;
}
.login-card {
    width: 100%;
    max-width: 380px;
}
.login-card .label-eyebrow { display: block; margin-bottom: 8px; }
.login-card h2 {
    font-family: 'Unbounded', sans-serif;
    font-size: clamp(20px, 2.4vw, 26px);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 22px;
    color: var(--ink);
}
.login-card .modal-form-group { margin-bottom: 12px; }
.login-card .btn-primary { width: 100%; padding: 12px 16px; font-size: 14px; margin-top: 4px; }

.login-error {
    background: var(--crimson-soft);
    color: var(--crimson);
    border: 1px solid var(--crimson);
    border-left-width: 3px;
    border-radius: var(--r-sm);
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
}

.login-foot {
    margin-top: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

/* Single-column layout on phones — keep scrollable to avoid cramping form */
@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
        max-height: none;
        overflow: visible;
    }
    body:has(.login-shell) { overflow: auto; }
    .login-aside {
        padding: 28px 22px;
        gap: 24px;
    }
    .login-statement h1 { font-size: 24px; }
    .login-stats { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .login-form-side { overflow: visible; }
}

/* =========================================================================
 *  RESPONSIVE
 * ========================================================================= */

@media (max-width: 980px) {
    .dashboard-split {
        grid-template-columns: 1fr;
        height: auto;
    }
    .sidebar {
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .main-map { min-height: 400px; }
    .info-grid-2col { grid-template-columns: 1fr; }
    .device-header { flex-direction: column; align-items: stretch; }
    .device-header-right { flex-wrap: wrap; }
    .vehicle-selector { max-width: none; flex: 1 1 100%; }
    .filter-bar-buttons { margin-left: 0; width: 100%; }
    .filter-bar-buttons .btn { flex: 1; min-width: 80px; }
    .sms-setup-layout { grid-template-columns: 1fr; }
    .sms-form { position: static; }
}

@media (max-width: 700px) {
    :root { --rail-w: 60px; --topbar-h: 56px; }
    .topbar { padding: 0 16px; }
    .topbar-clock { display: none; }
    .main--padded { padding: 20px 16px 40px; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 18px; }
    .table-toolbar { flex-direction: column; align-items: flex-start; }
    .device-header-left .page-title { font-size: 19px; }
    .filter-bar-controls { flex-direction: column; align-items: stretch; }
    .filter-bar-controls .date-input { width: 100%; }
}

@media (max-width: 460px) {
    #toast-root { left: 12px; right: 12px; max-width: none; }
    .modal-content { padding: 20px; }
    .stats-bar { grid-template-columns: 1fr; }
    .device-header-right { flex-direction: column; align-items: stretch; }
}

/* =========================================================================
 *  Reduced motion
 * ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
