* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0b1121;
    --bg2: #141d2f;
    --bg3: #1a2540;
    --bg4: #0f1829;
    --card: linear-gradient(135deg, #1a2540 0%, #0f1829 100%);
    --glass: rgba(255,255,255,0.03);
    --glass-border: rgba(255,255,255,0.08);
    --border: #243049;
    --text: #e8edf5;
    --dim: #6b7fa0;
    --cyan: #22d3ee;
    --green: #34d399;
    --yellow: #fbbf24;
    --red: #f87171;
    --purple: #a78bfa;
    --pink: #f472b6;
    --blue: #60a5fa;
    --orange: #fb923c;
    --lime: #a3e635;
    --glow-cyan: 0 0 20px #22d3ee44;
    --glow-green: 0 0 20px #34d39944;
    --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    --sidebar-width: 220px;
    --sidebar-collapsed: 60px;
    --topbar-height: 48px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #141d2f 0%, #0b1121 100%);
    border-right: 1px solid var(--border);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}
.sidebar-brand-logo {
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(34,211,238,0.3));
    transition: filter 0.3s;
}
.sidebar-brand:hover .sidebar-brand-logo { filter: drop-shadow(0 0 14px rgba(34,211,238,0.5)); }
.sidebar-brand-text {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}
.sidebar.collapsed .sidebar-brand-text { opacity: 0; width: 0; }

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 10px;
    color: var(--dim);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
    background: rgba(34,211,238,0.1);
    color: var(--cyan);
    box-shadow: inset 3px 0 0 var(--cyan);
}
.nav-item.active::after {
    content: '';
    position: absolute;
    right: 8px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 8px var(--cyan);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-label {
    overflow: hidden;
    transition: opacity 0.2s, width 0.3s;
}
.sidebar.collapsed .nav-label { opacity: 0; width: 0; }
.sidebar.collapsed .nav-item.active::after { display: none; }

.nav-badge {
    position: absolute;
    top: 4px;
    left: 26px;
    background: var(--red);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    color: var(--dim);
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-collapse-btn:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
}
.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed); }

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: var(--topbar-height);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    z-index: 100;
    position: sticky;
    top: 0;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-page-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2px 10px;
    min-width: 60px;
}
.topbar-stat-label {
    font-size: 0.5rem;
    color: var(--dim);
    letter-spacing: 1px;
    font-weight: 600;
}
.topbar-stat-value {
    font-size: 0.85rem;
    font-weight: 800;
    font-family: var(--mono);
    color: var(--cyan);
}

.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    opacity: 0.5;
    flex-shrink: 0;
}

.connection-indicator {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #475569;
    transition: all 0.3s;
    flex-shrink: 0;
}
.connection-indicator.connected { background: var(--green); box-shadow: 0 0 12px var(--green); }
.connection-indicator.error { background: var(--red); box-shadow: 0 0 12px var(--red); }

/* Notification Button */
.notification-btn {
    position: relative;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    color: var(--dim);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.notification-btn:hover { border-color: var(--cyan); color: var(--text); }
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 14px;
    text-align: center;
}

/* Notification Center */
.notification-center {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    width: 360px;
    max-height: calc(100vh - var(--topbar-height));
    background: var(--bg2);
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    box-shadow: -4px 4px 20px rgba(0,0,0,0.4);
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notification-center.open { transform: translateX(0); }
.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.notification-header h4 { font-size: 0.85rem; font-weight: 700; }
.notification-clear {
    background: none;
    border: none;
    color: var(--dim);
    font-size: 0.75rem;
    cursor: pointer;
    font-family: var(--font);
}
.notification-clear:hover { color: var(--red); }
.notification-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.notification-entry {
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid var(--cyan);
    background: rgba(255,255,255,0.02);
    margin-bottom: 6px;
    font-size: 0.8rem;
    animation: slideInRight 0.3s ease;
}
.notification-entry.unread { border-left-color: var(--green); background: rgba(52,211,153,0.05); }
.notification-entry.alert { border-left-color: var(--red); }
.notification-entry .notif-time { font-size: 0.65rem; color: var(--dim); margin-top: 4px; display: block; }
.notification-empty { text-align: center; color: var(--dim); padding: 30px; font-size: 0.85rem; }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* User Menu */
.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    transition: all 0.2s;
}
.user-btn:hover { border-color: var(--cyan); }
.user-icon { color: var(--dim); flex-shrink: 0; stroke-linecap: round; stroke-linejoin: round; }
.user-arrow { color: var(--dim); flex-shrink: 0; stroke-linecap: round; stroke-linejoin: round; }
.user-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    min-width: 180px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-info { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.user-role { font-size: 0.7rem; color: var(--cyan); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.dropdown-item {
    display: block; width: 100%;
    padding: 10px 14px;
    background: none; border: none;
    color: var(--text);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.15s;
}
.dropdown-item:hover { background: rgba(255,255,255,0.05); }
.dropdown-item.logout { color: var(--red); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 0; }
.admin-only { display: none; }
.admin-only.show { display: block; }

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34,211,238,0.1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--dim);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.theme-toggle:hover { background: rgba(34,211,238,0.2); border-color: var(--cyan); color: var(--cyan); }
.theme-toggle svg { stroke-linecap: round; stroke-linejoin: round; }
body.light-theme .theme-icon-dark { display: none !important; }
body.light-theme .theme-icon-light { display: inline-block !important; }

/* ===== PAGE CONTENT ===== */
.page-content {
    display: none;
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}
.page-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== HERO STATS STRIP ===== */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.hero-card {
    position: relative;
    padding: 14px 16px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}
.hero-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.15); }
.hero-card.green { border-color: rgba(52,211,153,0.3); }
.hero-card.green:hover { box-shadow: 0 4px 20px rgba(52,211,153,0.15); border-color: rgba(52,211,153,0.5); }
.hero-card.cyan { border-color: rgba(34,211,238,0.3); }
.hero-card.cyan:hover { box-shadow: 0 4px 20px rgba(34,211,238,0.15); border-color: rgba(34,211,238,0.5); }
.hero-card.orange { border-color: rgba(251,146,60,0.3); }
.hero-card.orange:hover { box-shadow: 0 4px 20px rgba(251,146,60,0.15); border-color: rgba(251,146,60,0.5); }
.hero-card.purple { border-color: rgba(167,139,250,0.3); }
.hero-card.purple:hover { box-shadow: 0 4px 20px rgba(167,139,250,0.15); border-color: rgba(167,139,250,0.5); }
.hero-card.pink { border-color: rgba(244,114,182,0.3); }
.hero-card.pink:hover { box-shadow: 0 4px 20px rgba(244,114,182,0.15); border-color: rgba(244,114,182,0.5); }
.hero-card.yellow { border-color: rgba(251,191,36,0.3); }
.hero-card.yellow:hover { box-shadow: 0 4px 20px rgba(251,191,36,0.15); border-color: rgba(251,191,36,0.5); }

.hero-info { position: relative; z-index: 1; }
.hero-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1.2;
}
.hero-card.green .hero-value { color: var(--green); }
.hero-card.cyan .hero-value { color: var(--cyan); }
.hero-card.orange .hero-value { color: var(--orange); }
.hero-card.purple .hero-value { color: var(--purple); }
.hero-card.pink .hero-value { color: var(--pink); }
.hero-card.yellow .hero-value { color: var(--yellow); }

.hero-label {
    display: block;
    font-size: 0.65rem;
    color: var(--dim);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
}

.hero-spark {
    position: absolute;
    bottom: 6px;
    right: 6px;
    opacity: 0.3;
}

.hero-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    opacity: 0.12;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.hero-card:hover .hero-icon { opacity: 0.25; }
.hero-card.green .hero-icon { color: var(--green); }
.hero-card.cyan .hero-icon { color: var(--cyan); }
.hero-card.orange .hero-icon { color: var(--orange); }
.hero-card.purple .hero-icon { color: var(--purple); }
.hero-card.pink .hero-icon { color: var(--pink); }
.hero-card.yellow .hero-icon { color: var(--yellow); }

/* ===== CHART GRID (2x3) ===== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

/* ===== DASHBOARD BOTTOM ROW ===== */
.dashboard-bottom-row {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

/* ===== CARDS / CHART BOXES ===== */
.chart-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    animation: slideInUp 0.4s ease both;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chart-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.chart-title.cyan { color: var(--cyan); }
.chart-title.green { color: var(--green); }
.chart-title.yellow { color: var(--yellow); }
.chart-title.red { color: var(--red); }
.chart-title.purple { color: var(--purple); }
.chart-title.orange { color: var(--orange); }
.chart-title.blue { color: var(--blue); }

.chart-val {
    font-family: var(--mono);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
}

.chart-area { position: relative; height: 160px; }
.vehicle-chart-area { height: 140px; }

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stagger chart animations */
.chart-grid .chart-box:nth-child(1) { animation-delay: 0s; }
.chart-grid .chart-box:nth-child(2) { animation-delay: 0.05s; }
.chart-grid .chart-box:nth-child(3) { animation-delay: 0.1s; }
.chart-grid .chart-box:nth-child(4) { animation-delay: 0.15s; }
.chart-grid .chart-box:nth-child(5) { animation-delay: 0.2s; }
.chart-grid .chart-box:nth-child(6) { animation-delay: 0.25s; }

/* Vehicle Status Legend */
.vehicle-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 10px;
}
.vl-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--dim);
}
.vl-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.vl-item strong { color: var(--text); font-family: var(--mono); font-weight: 700; }

/* Data Quality Panel */
.data-quality-panel {
    padding: 8px 0;
}
.dq-metric {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.dq-label {
    font-size: 0.7rem;
    color: var(--dim);
    min-width: 90px;
    font-weight: 600;
}
.dq-bar-wrap {
    flex: 1;
    height: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}
.dq-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}
.dq-bar.green { background: linear-gradient(90deg, #064e3b, var(--green)); }
.dq-bar.cyan { background: linear-gradient(90deg, #164e63, var(--cyan)); }
.dq-pct {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    min-width: 40px;
    text-align: right;
}

/* System Mini Cards */
.system-mini-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 10px;
}
.smc {
    text-align: center;
    padding: 6px 4px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}
.smc-label { display: block; font-size: 0.55rem; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.smc-value { display: block; font-family: var(--mono); font-size: 0.75rem; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ===== KAFKA PIPELINE ===== */
.kafka-pipeline { display: flex; gap: 14px; align-items: stretch; }
.kafka-gauge-container { flex: 0 0 130px; display: flex; align-items: center; justify-content: center; }
.kafka-gauge-wrapper { position: relative; width: 120px; height: 120px; }
.kafka-gauge-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.kafka-gauge-value { display: block; font-size: 1.4rem; font-weight: 800; color: var(--green); font-family: var(--mono); text-shadow: 0 0 20px rgba(52,211,153,0.4); }
.kafka-gauge-label { display: block; font-size: 0.5rem; color: var(--dim); letter-spacing: 1.5px; font-weight: 600; }
.kafka-details { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kafka-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 6px; }
.kafka-stat { text-align: center; padding: 8px; background: rgba(255,255,255,0.02); border-radius: 8px; border: 1px solid rgba(255,255,255,0.06); }
.kafka-val { display: block; font-family: var(--mono); font-size: 1.1rem; font-weight: 800; }
.kafka-val.green { color: var(--green); }
.kafka-val.red { color: var(--red); }
.kafka-val.yellow { color: var(--yellow); }
.kafka-val.cyan { color: var(--cyan); }
.kafka-label { display: block; font-size: 0.6rem; color: var(--dim); letter-spacing: 0.5px; margin-top: 2px; font-weight: 500; }

/* ===== PROGRESS BARS ===== */
.progress-item { display: flex; align-items: center; gap: 8px; }
.progress-label { font-size: 0.6rem; color: var(--dim); letter-spacing: 1.5px; min-width: 55px; font-weight: 600; }
.progress-bar { flex: 1; height: 18px; background: rgba(255,255,255,0.05); border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,0.06); }
.progress-fill { height: 100%; transition: width 0.3s ease; border-radius: 6px; min-width: 0; }
.progress-fill.green { background: linear-gradient(90deg, #064e3b, var(--green)); box-shadow: inset 0 0 15px rgba(52,211,153,0.3); }
.progress-fill.red { background: linear-gradient(90deg, #7f1d1d, var(--red)); box-shadow: inset 0 0 15px rgba(248,113,113,0.3); }
.progress-fill.cyan { background: linear-gradient(90deg, #164e63, var(--cyan)); box-shadow: inset 0 0 15px rgba(34,211,238,0.3); }
.progress-pct { font-size: 0.7rem; color: var(--text); min-width: 38px; font-weight: 600; font-family: var(--mono); }
.progress-val { font-size: 0.75rem; color: var(--text); font-weight: 700; min-width: 50px; text-align: right; font-family: var(--mono); }

/* ===== DASHBOARD ANALYTICS ROW ===== */
.dashboard-units-section { margin-top: 16px; }
.dash-units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    padding: 4px 0;
}
.unit-card.compact { padding: 10px 12px; }
.unit-card.compact .unit-metrics { font-size: 0.7rem; }
.unit-card.compact .unit-actions { gap: 4px; }

.dashboard-analytics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

/* ===== FLEET PAGE ===== */
.fleet-layout {
    display: flex;
    gap: 16px;
}
.fleet-main { flex: 1; min-width: 0; }
.fleet-sidebar-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.sidebar-panel-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--cyan);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.speed-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.speed-stat { text-align: center; padding: 8px 4px; background: rgba(255,255,255,0.02); border-radius: 8px; border: 1px solid rgba(255,255,255,0.06); }
.speed-stat-value { display: block; font-family: var(--mono); font-size: 1.2rem; font-weight: 800; color: var(--text); }
.speed-stat-value.red { color: var(--red); }
.speed-stat-label { display: block; font-size: 0.55rem; color: var(--dim); margin-top: 2px; font-weight: 500; }
.speed-chart-wrap { height: 120px; }

.distance-stats { margin-bottom: 12px; }
.distance-big { text-align: center; margin-bottom: 8px; }
.distance-value { font-family: var(--mono); font-size: 2rem; font-weight: 800; color: var(--cyan); }
.distance-unit { font-size: 0.75rem; color: var(--dim); margin-left: 4px; }
.distance-row { display: flex; justify-content: center; gap: 16px; font-size: 0.8rem; color: var(--dim); }
.distance-row strong { color: var(--text); font-family: var(--mono); }

.top-travelers-title { font-size: 0.65rem; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.top-travelers-list { max-height: 200px; overflow-y: auto; }
.traveler-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    transition: background 0.15s;
}
.traveler-item:hover { background: rgba(255,255,255,0.03); }
.traveler-id { font-family: var(--mono); color: var(--text); font-weight: 600; font-size: 0.75rem; }
.traveler-km { font-family: var(--mono); color: var(--cyan); font-weight: 700; font-size: 0.75rem; }
.traveler-rank { color: var(--dim); font-size: 0.65rem; margin-right: 6px; }

.fleet-export-btns { display: flex; gap: 4px; }
.btn-export {
    padding: 6px 12px;
    font-size: 0.7rem;
    background: rgba(167,139,250,0.1);
    border: 1px solid rgba(167,139,250,0.3);
    color: var(--purple);
}
.btn-export:hover { background: rgba(167,139,250,0.2); }

/* ===== TERMINAL TABLE (shared) ===== */
.terminal-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    align-items: center;
    flex-wrap: wrap;
}

.terminal-search-wrap {
    position: relative;
    flex: 1 1 320px;
    max-width: 380px;
}

.terminal-toolbar .terminal-search-wrap input {
    width: 100%;
    max-width: none;
    padding-right: 34px;
}

.terminal-search-spinner {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(34, 211, 238, 0.25);
    border-top-color: rgba(34, 211, 238, 0.95);
    transform: translateY(-50%) scale(0.82);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.terminal-search-wrap.is-loading .terminal-search-spinner {
    opacity: 1;
    transform: translateY(-50%) scale(1);
    animation: terminal-search-spin 0.7s linear infinite;
}

.terminal-search-wrap.is-loading input {
    border-color: rgba(34, 211, 238, 0.45);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}
.terminal-toolbar input {
    flex: 1;
    max-width: 360px;
    padding: 7px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.82rem;
    font-family: var(--mono);
    transition: border-color 0.2s;
}
.terminal-toolbar input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }
.terminal-toolbar input::placeholder { color: #475569; }

@keyframes terminal-search-spin {
    to {
        transform: translateY(-50%) scale(1) rotate(360deg);
    }
}
.terminal-toolbar select {
    padding: 7px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.78rem;
    font-family: var(--font);
}
.btn-toolbar {
    padding: 7px 14px;
    background: rgba(34,211,238,0.08);
    border: 1px solid rgba(34,211,238,0.2);
    border-radius: 6px;
    color: var(--cyan);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}
.btn-toolbar:hover { background: rgba(34,211,238,0.15); }
.btn-danger-sm {
    padding: 8px 16px;
    background: rgba(248,113,113,0.1);
    border: 1px solid rgba(248,113,113,0.3);
    border-radius: 8px;
    color: var(--red);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}
.btn-danger-sm:hover { background: rgba(248,113,113,0.2); }

.terminal-count {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--dim);
    font-weight: 600;
    margin-left: auto;
    padding: 4px 10px;
}
.terminal-table-wrap {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg2);
}

/* Terminal Activity Table — dense data table like legacy PHP */
.terminal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-family: var(--font);
}
.terminal-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #0a1628;
}
.terminal-table thead th {
    padding: 8px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dim);
    border-bottom: 2px solid var(--orange);
    white-space: nowrap;
}
.terminal-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.12s;
}
.terminal-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.terminal-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.terminal-table tbody tr:nth-child(even):hover { background: rgba(255,255,255,0.05); }
.terminal-table tbody td {
    padding: 7px 10px;
    vertical-align: top;
    border-right: 1px solid rgba(255,255,255,0.03);
    line-height: 1.5;
}
.terminal-table tbody td:last-child { border-right: none; }

/* Column-specific styles */
.td-serial {
    text-align: right;
    color: var(--cyan);
    font-family: var(--mono);
    font-weight: 600;
    font-size: 0.75rem;
    min-width: 30px;
    opacity: 0.7;
}
.td-code {
    white-space: nowrap;
    min-width: 140px;
}
.td-code .code-line { color: var(--cyan); font-weight: 700; font-family: var(--mono); }
.td-code .customer-line { color: var(--text); font-size: 0.78rem; opacity: 0.85; }
.td-code .provider-line { color: var(--dim); font-size: 0.72rem; }
.td-time {
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 0.78rem;
    min-width: 100px;
}
.td-time .time-line { font-weight: 600; }
.td-time .date-line { color: var(--dim); font-size: 0.72rem; }
.td-time .time-ago { font-size: 0.68rem; font-weight: 700; }
.td-time .time-ago.recent { color: var(--green); }
.td-time .time-ago.moderate { color: var(--yellow); }
.td-time .time-ago.old { color: var(--red); }
.td-time .mark-server { color: var(--yellow); cursor: help; }
.td-gps { text-align: center; min-width: 80px; }
.td-gps .gps-label { font-weight: 600; }
.td-gps .gps-yes { color: var(--green); }
.td-gps .gps-no { color: var(--red); }
.td-gps .coord { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); display: block; }
.td-sep { text-align: center; white-space: nowrap; min-width: 80px; }
.td-sep .speed-val { font-family: var(--mono); font-weight: 700; }
.td-sep .speed-moving { color: var(--green); }
.td-sep .speed-idle { color: var(--dim); opacity: 0.6; }
.td-sep .mark-on { color: var(--green); font-weight: 600; }
.td-sep .mark-off { color: var(--red); opacity: 0.7; }
.td-sep .mark-up { color: var(--green); font-weight: 600; }
.td-sep .mark-down { color: var(--red); opacity: 0.7; }
.td-sep .mark-null { color: var(--dim); opacity: 0.4; }
.td-sdf { text-align: center; white-space: nowrap; min-width: 80px; }
.td-sdf .mark-panic-yes { color: var(--red); font-weight: 800; }
.td-sdf .mark-door-open { color: var(--red); font-weight: 600; }
.td-sdf .mark-door-shut { color: var(--dim); }
.td-sdf .fuel-val { font-family: var(--mono); }
.td-type { white-space: nowrap; min-width: 80px; }
.td-type .type-name { color: var(--text); }
.td-type .mode-tag { color: var(--orange); font-weight: 600; }
.td-type .port-tag { color: var(--dim); font-size: 0.72rem; }

.td-type .phone-tag {
    color: var(--cyan);
    font-size: 0.72rem;
    font-family: var(--mono);
}
.td-identifier { white-space: nowrap; min-width: 130px; }
.td-identifier .id-link { color: var(--cyan); font-family: var(--mono); font-weight: 600; font-size: 0.78rem; text-decoration: none; }
.td-identifier .id-link:hover { text-decoration: underline; }
.td-identifier .device-line { color: var(--dim); font-size: 0.72rem; }
.td-action { text-align: center; padding: 5px !important; }
.td-action .btn-track {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(34,211,238,0.08);
    color: var(--cyan);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}
.td-action .btn-track:hover { background: rgba(34,211,238,0.2); }

/* Row status stripe */
.tr-moving { border-left: 3px solid var(--green); }
.tr-idle { border-left: 3px solid rgba(96,165,250,0.4); }
.tr-panic { border-left: 3px solid var(--red); background: rgba(248,113,113,0.03) !important; }
.tr-no-gps { border-left: 3px solid rgba(251,191,36,0.4); }
.tr-offline { border-left: 3px solid rgba(100,116,139,0.3); opacity: 0.65; }

.tr-stale {
    border-left: 3px solid rgba(251, 191, 36, 0.5);
    opacity: 0.7;
    background: rgba(251, 191, 36, 0.03) !important;
}

/* Stale badge */
.stale-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

/* Source badge: stale */
.source-stale {
    background: rgba(251, 191, 36, 0.15) !important;
    color: #fbbf24 !important;
}

/* Command Panel */
.command-section {
    margin-top: 16px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.command-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.command-panel-header h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.cmd-online-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    color: var(--dim);
    background: rgba(100, 116, 139, 0.15);
    border: 1px solid rgba(100, 116, 139, 0.2);
}

.cmd-online-badge.online {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
}

.cmd-online-badge.offline {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.25);
}

.cmd-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.cmd-template-btn {
    padding: 6px 12px;
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 6px;
    color: var(--cyan);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.cmd-template-btn:hover {
    background: rgba(34, 211, 238, 0.18);
}

.cmd-danger-btn {
    background: rgba(248, 113, 113, 0.08) !important;
    border-color: rgba(248, 113, 113, 0.25) !important;
    color: var(--red) !important;
}

.cmd-danger-btn:hover {
    background: rgba(248, 113, 113, 0.2) !important;
}

.cmd-raw-section {
    margin-bottom: 12px;
}

.cmd-raw-toggle {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dim);
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.cmd-raw-toggle:hover {
    color: var(--text);
}

.cmd-raw-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.cmd-raw-form input {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: var(--mono);
}

.cmd-raw-form input:focus {
    outline: none;
    border-color: var(--cyan);
}

.cmd-status-section {
}

.cmd-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cmd-status-header h5 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--dim);
    margin: 0;
}

.cmd-status-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.cmd-status-table th {
    padding: 5px 8px;
    text-align: left;
    color: var(--dim);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.cmd-status-table td {
    padding: 5px 8px;
    color: var(--text);
    border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}

.cmd-id {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--dim);
}

.cmd-action {
    display: inline-block;
    font-size: 0.68rem;
    color: var(--dim);
    margin-left: 4px;
}

.cmd-status {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cmd-st-pending {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
}

.cmd-st-sent {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
}

.cmd-st-complete {
    color: var(--cyan);
    background: rgba(34, 211, 238, 0.1);
}

.cmd-st-failed {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.cmd-st-expired {
    color: var(--dim);
    background: rgba(100, 116, 139, 0.1);
}

/* Inline SVG icon base */
.ic { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* Icon + text row within a cell */
.sep-row { display: flex; align-items: center; gap: 5px; line-height: 1.6; white-space: nowrap; }
.sep-icon { display: inline-flex; align-items: center; width: 16px; flex-shrink: 0; }
.sep-icon.on, .sep-icon.speed { color: var(--green); }
.sep-icon.off { color: var(--red); opacity: 0.8; }
.sep-icon.null, .sep-icon.dim { color: var(--dim); opacity: 0.4; }
.sep-icon.fuel { color: var(--orange); }
.sep-icon.panic { color: var(--red); }
.bat-row { margin-top: -2px; }
.bat-val { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }
.panic-row { animation: pulse-panic 1.2s infinite; }

/* GPS icon */
.gps-icon { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.gps-icon.gps-yes { color: var(--green); }
.gps-icon.gps-no { color: var(--red); }

/* GSM signal bars */
.gsm-indicator { display: inline-flex; align-items: center; gap: 4px; }
.gsm-bars { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 14px; }
.gsm-bar { width: 3px; background: rgba(255,255,255,0.1); border-radius: 1px; transition: background 0.3s; }
.gsm-bar:nth-child(1) { height: 4px; }
.gsm-bar:nth-child(2) { height: 7px; }
.gsm-bar:nth-child(3) { height: 10px; }
.gsm-bar:nth-child(4) { height: 14px; }
.gsm-bar.on { background: var(--dim); }
.gsm-good .gsm-bar.on { background: var(--green); }
.gsm-fair .gsm-bar.on { background: var(--yellow); }
.gsm-weak .gsm-bar.on { background: var(--red); }
.gsm-pct { font-family: var(--mono); font-size: 0.68rem; color: var(--dim); margin-left: 3px; }
.gsm-good .gsm-pct { color: var(--green); }
.gsm-fair .gsm-pct { color: var(--yellow); }
.gsm-weak .gsm-pct { color: var(--red); }

/* Speed unit & direction */
.speed-unit { font-size: 0.68rem; font-weight: 400; color: var(--dim); }
.dir-val { font-family: var(--mono); font-size: 0.68rem; color: var(--dim); margin-left: 4px; }

/* Source indicator */
.terminal-source { font-family: var(--mono); font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.terminal-source.source-live { background: rgba(52,211,153,0.1); color: var(--green); }
.terminal-source.source-db { background: rgba(251,191,36,0.08); color: var(--yellow); }
.terminal-empty { text-align: center; color: var(--dim); padding: 48px 20px; font-size: 0.88rem; }
@keyframes pulse-panic { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Action buttons */
.btn-sm {
    padding: 4px 10px;
    font-size: 0.65rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.btn-sm.map-btn { background: rgba(96,165,250,0.12); color: var(--blue); }
.btn-sm.map-btn:hover { background: rgba(96,165,250,0.25); }
.btn-sm.history-btn { background: rgba(167,139,250,0.12); color: var(--purple); }
.btn-sm.history-btn:hover { background: rgba(167,139,250,0.25); }

/* Metric separator dot */
.fleet-dot { color: var(--dim); opacity: 0.3; font-size: 0.5rem; line-height: 1; }

/* ===== DEVICE DETAIL PANEL ===== */
.device-detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 500px;
    background: var(--bg2);
    border-left: 2px solid var(--cyan);
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0s linear 0.3s;
    z-index: 400;
    overflow-y: auto;
    box-shadow: -8px 0 40px rgba(0,0,0,0.4);
    visibility: hidden;
}
.device-detail-panel.active { transform: translateX(0); visibility: visible; transition: transform 0.3s ease, visibility 0s linear 0s; }
.detail-panel-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: rgba(34,211,238,0.05); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.detail-panel-header h3 { font-size: 1rem; font-weight: 700; color: var(--cyan); font-family: var(--mono); }
.detail-close-btn { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 1.5rem; padding: 4px 8px; border-radius: 4px; transition: all 0.15s; }
.detail-close-btn:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.detail-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 16px 20px; }
.detail-stat-item { text-align: center; padding: 10px 6px; background: rgba(255,255,255,0.02); border-radius: 10px; border: 1px solid rgba(255,255,255,0.06); }
.detail-stat-item.wide { grid-column: span 3; text-align: left; padding: 10px 16px; }
.detail-stat-val { display: block; font-family: var(--mono); font-size: 1rem; font-weight: 700; color: var(--text); }
.detail-stat-lbl { display: block; font-size: 0.6rem; color: var(--dim); margin-top: 3px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.history-section { padding: 16px 20px; border-top: 1px solid var(--border); }
.history-controls { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.history-controls input[type="date"] { padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: var(--mono); font-size: 0.8rem; }
.history-controls input[type="date"]:focus { outline: none; border-color: var(--cyan); }
#history-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }

#history-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

#history-table th {
    background: var(--card);
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 0.65rem;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--cyan);
}

#history-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}

/* Mini-map */
#detail-mini-map-wrapper { margin: 12px 20px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
#detail-mini-map-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: rgba(34,211,238,0.05); border-bottom: 1px solid var(--border); }
#detail-mini-map-info { font-family: var(--mono); font-size: 0.72rem; color: var(--cyan); font-weight: 600; }
#detail-mini-map-toolbar .track-clear-btn { padding: 3px 10px; font-size: 0.68rem; }
#detail-mini-map { height: 280px; width: 100%; background: #0f1829; }
#detail-mini-map .leaflet-tile-pane { filter: brightness(0.85) contrast(1.1); }

/* ===== MAP PAGE ===== */
.map-toolbar {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    align-items: center;
    flex-wrap: wrap;
}
.map-search-wrap { position: relative; flex: 0 0 220px; }
.map-search-wrap input {
    width: 100%;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--mono);
}
.map-search-wrap input:focus { outline: none; border-color: var(--cyan); }
.map-search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    z-index: 50;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}
.map-search-dropdown.show { display: block; }
.map-search-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}
.map-search-item:hover { background: rgba(34,211,238,0.08); }
.map-search-item .search-id { font-family: var(--mono); color: var(--cyan); font-weight: 600; }
.map-search-item .search-meta { font-size: 0.7rem; color: var(--dim); margin-left: 8px; }

.map-device-count { font-family: var(--mono); font-size: 0.8rem; color: var(--cyan); font-weight: 600; }
.map-filter-group { display: flex; gap: 4px; }
.map-filter-btn {
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--mono);
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--dim);
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.map-filter-btn:hover { background: rgba(6,182,212,0.1); color: var(--text); border-color: var(--cyan); }
.map-filter-btn.active { background: rgba(6,182,212,0.15); color: var(--cyan); border-color: var(--cyan); }
.map-filter-btn[data-filter="moving"].active { color: var(--green); border-color: var(--green); background: rgba(52,211,153,0.1); }
.map-filter-btn[data-filter="idle"].active { color: var(--blue); border-color: var(--blue); background: rgba(96,165,250,0.1); }
.map-filter-btn[data-filter="panic"].active { color: var(--red); border-color: var(--red); background: rgba(248,113,113,0.1); }
.map-filter-btn[data-filter="no-gps"].active { color: var(--yellow); border-color: var(--yellow); background: rgba(251,191,36,0.1); }

.track-btn { background: rgba(34,211,238,0.15) !important; color: var(--cyan) !important; border: 1px solid var(--cyan) !important; }
.track-btn:hover { background: rgba(34,211,238,0.25) !important; }
.track-clear-btn { background: rgba(248,113,113,0.15) !important; color: var(--red) !important; border: 1px solid var(--red) !important; }
.track-clear-btn:hover { background: rgba(248,113,113,0.25) !important; }

.map-auto-label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--dim); margin-left: auto; cursor: pointer; }

.map-main-area { display: flex; gap: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
#map-container { flex: 1; height: calc(100vh - 180px); min-height: 400px; }
.map-alerts-sidebar {
    width: 260px;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
}
.map-alerts-sidebar h5 { font-size: 0.7rem; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; font-weight: 600; }
.map-alert-list { display: flex; flex-direction: column; gap: 6px; }
.map-alert-item {
    padding: 8px 10px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    border-left: 3px solid var(--red);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.78rem;
}
.map-alert-item:hover { background: rgba(255,255,255,0.05); }
.map-alert-item .alert-type-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    font-family: var(--mono);
    margin-right: 4px;
}
.map-alert-item .alert-time { font-size: 0.65rem; color: var(--dim); display: block; margin-top: 3px; }

.leaflet-container { background: #0f1829; }
.leaflet-tile-pane { filter: brightness(0.85) contrast(1.1); }
#page-map.fullscreen { position: fixed; inset: 0; z-index: 600; padding: 0; margin: 0; }
#page-map.fullscreen .map-toolbar { position: absolute; top: 0; left: 0; right: 0; z-index: 601; background: rgba(11,17,33,0.9); padding: 8px 16px; }
#page-map.fullscreen .map-main-area { border-radius: 0; border: none; }
#page-map.fullscreen #map-container { height: 100vh; }

/* Alert pulse dot for map markers */
.alert-pulse-dot {
    width: 14px; height: 14px;
    background: var(--red);
    border-radius: 50%;
    animation: alertPulse 1.5s infinite;
    box-shadow: 0 0 8px var(--red);
}
@keyframes alertPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== ALERTS PAGE ===== */
.alerts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.alerts-toolbar h3 { font-size: 1rem; font-weight: 700; }
.alert-sound-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--dim);
    cursor: pointer;
}
.alerts-chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.alert-timeline-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}
.alert-timeline-section h4 { font-size: 0.8rem; font-weight: 700; color: var(--cyan); margin-bottom: 12px; letter-spacing: 1px; text-transform: uppercase; }
.alert-timeline {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.alert-timeline-entry {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    border-left: 3px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.8rem;
}
.alert-timeline-entry:hover { background: rgba(255,255,255,0.04); }
.alert-timeline-entry .ate-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--mono);
    flex-shrink: 0;
}
.ate-type.EA { background: rgba(239,68,68,0.15); color: #ef4444; }
.ate-type.OS { background: rgba(245,158,11,0.15); color: #f59e0b; }
.ate-type.FI { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.ate-type.BL { background: rgba(6,182,212,0.15); color: #06b6d4; }
.ate-type.HA { background: rgba(236,72,153,0.15); color: #ec4899; }
.ate-type.HB { background: rgba(100,116,139,0.15); color: #64748b; }
.alert-timeline-entry .ate-info { flex: 1; min-width: 0; }
.alert-timeline-entry .ate-id { font-family: var(--mono); font-weight: 600; color: var(--text); }
.alert-timeline-entry .ate-msg { color: var(--dim); font-size: 0.75rem; }
.alert-timeline-entry .ate-time { font-size: 0.65rem; color: var(--dim); margin-top: 2px; }

/* ===== SYSTEM PAGE ===== */
.system-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0;
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
}
.system-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
}
.system-section-header h4 { font-size: 0.75rem; font-weight: 700; color: var(--cyan); letter-spacing: 1.5px; text-transform: uppercase; }
.system-section-actions { display: flex; align-items: center; gap: 8px; }

.system-two-col {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
}

/* Units in system page */
.system-section .units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 14px;
}

.unit-count, .log-count {
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--green);
    background: rgba(52,211,153,0.15);
    padding: 2px 10px;
    border-radius: 20px;
}

.unit-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--dim);
    padding: 30px;
    font-size: 0.85rem;
}

/* Unit Card */
.unit-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px;
    transition: all 0.2s;
    cursor: default;
}
.unit-card:hover { border-color: rgba(34,211,238,0.4); transform: translateY(-2px); }
.unit-card.active { border-color: rgba(52,211,153,0.4); }
.unit-card.stopped { border-color: rgba(248,113,113,0.3); opacity: 0.7; }
.unit-card.conflict { border-color: var(--orange); }
.unit-card.conflict .unit-port { background: rgba(251,146,60,0.15); color: var(--orange); }

.unit-port { font-family: var(--mono); font-size: 1.3rem; font-weight: 800; color: var(--text); }
.unit-status { display: inline-flex; align-items: center; gap: 5px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-left: 8px; }
.status-dot-sm { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot-sm.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot-sm.off { background: var(--red); }
.unit-metrics { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.unit-metric { font-size: 0.7rem; color: var(--dim); }
.unit-metric span { font-family: var(--mono); font-weight: 600; color: var(--text); }
.unit-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.btn-unit { padding: 5px 10px; font-size: 0.65rem; font-weight: 600; font-family: var(--font); border: 1px solid; border-radius: 6px; cursor: pointer; transition: all 0.15s; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-unit.details { background: rgba(34,211,238,0.1); border-color: rgba(34,211,238,0.3); color: var(--cyan); }
.btn-unit.details:hover { background: rgba(34,211,238,0.2); }
.btn-unit.stream { background: rgba(167,139,250,0.1); border-color: rgba(167,139,250,0.3); color: var(--purple); }
.btn-unit.stream:hover { background: rgba(167,139,250,0.2); }
.btn-unit.stop { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); color: var(--red); }
.btn-unit.stop:hover { background: rgba(248,113,113,0.2); }
.btn-unit.start { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.3); color: var(--green); }
.btn-unit.start:hover { background: rgba(52,211,153,0.2); }
.btn-unit.delete { background: rgba(248,113,113,0.15); color: var(--red); border-color: rgba(248,113,113,0.3); }
.btn-unit.delete:hover { background: rgba(248,113,113,0.25); }
.btn-unit.force { background: rgba(251,146,60,0.15); color: var(--orange); border-color: rgba(251,146,60,0.3); }
.btn-unit.force:hover { background: rgba(251,146,60,0.25); }

/* Detail/Stream panels */
.detail-panel, .logs-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    margin-bottom: 16px;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border); }
.panel-title { font-size: 0.7rem; font-weight: 700; color: var(--cyan); letter-spacing: 1.5px; }
.panel-close { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 1.2rem; padding: 2px 6px; border-radius: 4px; transition: all 0.15s; }
.panel-close:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.detail-body { padding: 0; max-height: 300px; overflow-y: auto; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th, .detail-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.detail-table th { color: var(--dim); font-weight: 600; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; background: rgba(255,255,255,0.02); position: sticky; top: 0; }
.detail-table tr:hover { background: rgba(255,255,255,0.02); }
.empty-row { text-align: center; color: var(--dim); padding: 20px; }

.stream-body { padding: 10px; max-height: 250px; overflow-y: auto; font-family: var(--mono); font-size: 0.7rem; line-height: 1.6; color: var(--dim); }
.stream-packet { padding: 4px 8px; border-radius: 4px; margin-bottom: 2px; border-left: 3px solid var(--border); }
.stream-packet:hover { background: rgba(255,255,255,0.03); }
.stream-packet .pkt-time { color: var(--yellow); }
.stream-packet .pkt-mode { color: var(--cyan); }
.stream-packet .pkt-id { color: var(--green); }

/* Process table */
.process-table-wrap { max-height: 300px; overflow-y: auto; }

/* Disk Storage */
.disk-storage-panel { padding: 16px; }
.disk-bar-wrap { height: 24px; background: rgba(255,255,255,0.05); border-radius: 8px; overflow: hidden; border: 1px solid rgba(255,255,255,0.06); margin-bottom: 10px; }
.disk-bar-fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); transition: width 0.5s ease; }
.disk-stats { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--dim); font-family: var(--mono); }

/* Scheduler */
.scheduler-info { padding: 12px 16px; font-size: 0.8rem; }
.scheduler-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.scheduler-item:last-child { border-bottom: none; }
.scheduler-key { color: var(--dim); font-weight: 500; }
.scheduler-val { color: var(--text); font-family: var(--mono); font-weight: 600; }

/* Log Console */
.log-console {
    height: 280px;
    overflow-y: auto;
    padding: 12px;
    font-family: var(--mono);
    font-size: 0.7rem;
    line-height: 1.7;
    background: #060a14;
}
.log-line { padding: 1px 0; }
.log-time { color: var(--dim); }
.log-INFO { color: var(--green); font-weight: 600; }
.log-WARN { color: var(--yellow); font-weight: 600; }
.log-ERROR { color: var(--red); font-weight: 600; }
.log-DEBUG { color: var(--purple); font-weight: 600; }
.log-msg { color: #94a3b8; }
.log-src { color: var(--dim); font-size: 0.6rem; }

/* System Status Cards */
.system-status-section {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    flex-wrap: wrap;
}
.status-card { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 10px; min-width: 120px; transition: all 0.2s; }
.status-card:hover { border-color: rgba(255,255,255,0.15); transform: translateY(-1px); }
.status-icon { line-height: 1; flex-shrink: 0; stroke-linecap: round; stroke-linejoin: round; }
.status-icon.green { color: var(--green); }
.status-icon.cyan { color: var(--cyan); }
.status-icon.yellow { color: var(--yellow); }
.status-icon.purple { color: var(--purple); }
.status-icon.orange { color: var(--orange); }
.status-icon.blue { color: var(--blue); }
.status-icon.red { color: var(--red); }
.status-card.wide { flex: 2; min-width: 200px; }
.status-info { display: flex; flex-direction: column; }
.status-title { font-size: 0.55rem; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.status-value { font-size: 0.8rem; font-weight: 700; color: var(--text); font-family: var(--mono); }

/* Add Unit Button */
.btn-add-unit { background: var(--cyan); color: var(--bg); border: none; border-radius: 4px; width: 24px; height: 24px; font-size: 1.1rem; font-weight: 700; cursor: pointer; display: none; align-items: center; justify-content: center; line-height: 1; }
.btn-add-unit:hover { background: #0891b2; }
.btn-add-unit.show { display: flex; }

/* ===== SETTINGS PAGE ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.settings-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.settings-card h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.settings-card p { font-size: 0.8rem; color: var(--dim); margin-bottom: 12px; }
.settings-field { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.settings-label { font-size: 0.8rem; color: var(--dim); }
.settings-value { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; color: var(--text); }
.settings-hint { font-size: 0.75rem; color: var(--dim); margin-bottom: 10px; }
.settings-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-danger-outline { padding: 8px 16px; background: transparent; border: 1px solid var(--red); color: var(--red); border-radius: 8px; font-size: 0.8rem; cursor: pointer; font-weight: 600; }
.btn-danger-outline:hover { background: rgba(248,113,113,0.1); }
.telegram-alerts { margin: 12px 0; }
.telegram-alerts label { display: block; padding: 6px 0; font-size: 0.8rem; color: var(--text); cursor: pointer; }
.telegram-alerts label input { margin-right: 8px; accent-color: var(--cyan); }
.tg-linked-badge { color: var(--green); font-weight: 700; }
.tg-code { font-family: var(--mono); font-size: 1.4rem; font-weight: 800; letter-spacing: 4px; color: var(--cyan); text-align: center; padding: 12px; background: rgba(6,182,212,0.08); border: 1px dashed var(--cyan); border-radius: 8px; margin: 10px 0; }
.telegram-code-box { margin: 12px 0; }
.telegram-code-box p { font-size: 0.8rem; color: var(--dim); margin-bottom: 6px; }
.tg-bot-link { color: var(--cyan); text-decoration: none; font-weight: 600; }

/* ===== MALFUNCTION OVERLAY ===== */
.malfunction-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(220,38,38,0.15);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: malfunctionPulse 2s infinite;
}
.malfunction-content { text-align: center; padding: 40px; background: var(--bg2); border: 2px solid var(--red); border-radius: 20px; max-width: 400px; animation: malfunctionShake 0.5s ease; box-shadow: 0 0 60px rgba(220,38,38,0.3); }
.malfunction-icon { color: var(--red); animation: malfunctionBlink 1s infinite; }
.malfunction-content h2 { color: var(--red); font-size: 1.3rem; letter-spacing: 3px; margin: 12px 0 8px; }
.malfunction-content p { color: var(--dim); font-size: 0.85rem; margin-bottom: 20px; }
@keyframes malfunctionPulse { 0%, 100% { background: rgba(220,38,38,0.1); } 50% { background: rgba(220,38,38,0.2); } }
@keyframes malfunctionShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes malfunctionBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== FOOTER ===== */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg2) 100%);
    border-top: 2px solid var(--border);
    font-size: 0.7rem;
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
}
.footer-section { display: flex; align-items: center; gap: 8px; }
.footer-brand { font-weight: 800; background: linear-gradient(90deg, var(--cyan), var(--green)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: 2px; }
.footer-tag { color: var(--dim); font-size: 0.6rem; letter-spacing: 1px; }
.footer-brand-section { display: flex; flex-direction: column; gap: 2px; }
.footer-powered { font-size: 0.6rem; color: var(--dim); }
.footer-powered span { background: linear-gradient(90deg, var(--cyan), var(--green)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; font-weight: 600; }
.footer-progress-section { flex: 1; display: flex; flex-direction: column; gap: 4px; max-width: 400px; }
.footer-stats-bar { display: flex; gap: 16px; }
.footer-stat { text-align: center; }
.footer-stat-val { font-family: var(--mono); font-weight: 700; color: var(--cyan); margin-right: 4px; }
.footer-stat-lbl { color: var(--dim); }
.footer-status { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; }
.status-dot.connected { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.error { background: var(--red); }
.footer-ver { color: var(--dim); }
.footer-time { color: var(--dim); font-family: var(--mono); }

/* ===== MODALS ===== */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 2000; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal.show { display: flex; }
.modal-content { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 420px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5); overflow: hidden; animation: modalSlide 0.3s ease; }
@keyframes modalSlide { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-content.modal-large { max-width: 700px; max-height: 85vh; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; color: var(--dim); cursor: pointer; font-size: 1.3rem; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; min-height: 0; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select { width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 0.9rem; font-family: var(--font); transition: border-color 0.2s; }
.form-input:focus, .form-select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }
.form-input::placeholder { color: #475569; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-row .form-input, .form-row .form-select { flex: 1; min-width: 100px; }
.form-message { margin-top: 12px; font-size: 0.8rem; padding: 8px 12px; border-radius: 6px; display: none; }
.form-message.show { display: block; }
.form-message.success { background: rgba(52,211,153,0.1); color: var(--green); }
.form-message.error { background: rgba(248,113,113,0.1); color: var(--red); }
.user-form { margin-bottom: 20px; }
.user-form h4 { font-size: 0.85rem; color: var(--text); margin-bottom: 10px; }

.btn-primary { padding: 10px 20px; background: linear-gradient(135deg, var(--cyan), var(--green)); border: none; border-radius: 8px; color: #0f172a; font-weight: 700; font-size: 0.85rem; cursor: pointer; font-family: var(--font); transition: all 0.2s; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(34,211,238,0.3); }
.btn-danger { padding: 4px 10px; background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); border-radius: 6px; color: var(--red); font-size: 0.7rem; cursor: pointer; font-family: var(--font); transition: all 0.15s; }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-secondary { padding: 8px 16px; background: var(--bg2); color: var(--dim); border: 1px solid var(--border); border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: var(--font); }
.btn-secondary:hover { border-color: var(--dim); color: var(--text); }

/* Config Editor */
.config-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.config-tab { padding: 6px 16px; background: transparent; color: var(--dim); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font-family: var(--font); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.config-tab.active { background: var(--cyan); color: var(--bg); border-color: var(--cyan); }
.config-editor { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-family: var(--mono); font-size: 0.8rem; line-height: 1.5; resize: vertical; min-height: 300px; }
.config-editor:focus { outline: none; border-color: var(--cyan); }
.config-section { margin-bottom: 16px; }
.config-section-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--cyan); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.config-field { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.config-field label { font-size: 0.75rem; color: var(--dim); min-width: 140px; font-weight: 500; }
.config-field input, .config-field select { flex: 1; padding: 6px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-family: var(--mono); font-size: 0.8rem; }
.config-field input:focus { outline: none; border-color: var(--cyan); }
.config-field .config-val { color: var(--text); font-family: var(--mono); font-size: 0.8rem; }

/* DB Not Connected */
.db-not-connected { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--dim); text-align: center; }
.db-not-connected .db-icon { margin-bottom: 16px; opacity: 0.5; color: var(--dim); }
.db-not-connected h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.db-not-connected p { font-size: 0.85rem; max-width: 400px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 10px; font-size: 0.8rem; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,0.4); animation: slideIn 0.3s ease-out; max-width: 350px; }
.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
.toast.info { background: var(--bg2); color: var(--cyan); border: 1px solid var(--border); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.flash { animation: flash 0.6s ease-out; }
@keyframes flash { 0% { color: var(--cyan); } 100% { color: inherit; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ===== LIGHT THEME ===== */
body.light-theme {
    --bg: #f0f4f8;
    --bg2: #dfe6ee;
    --bg3: #ffffff;
    --bg4: #f0f4f8;
    --card: linear-gradient(135deg, #ffffff 0%, #f0f4f8 100%);
    --glass: rgba(0,0,0,0.02);
    --glass-border: rgba(0,0,0,0.06);
    --border: #b8c8d8;
    --text: #1a2a3a;
    --dim: #5a6a7a;
    --cyan: #0891b2;
    --green: #059669;
    --yellow: #d97706;
    --red: #dc2626;
    --purple: #7c3aed;
    --pink: #db2777;
    --blue: #2563eb;
    --orange: #ea580c;
    --lime: #65a30d;
}

body.light-theme .sidebar { background: linear-gradient(180deg, #dfe6ee 0%, #f0f4f8 100%); }
body.light-theme .topbar { background: #dfe6ee; }
body.light-theme footer { background: #dfe6ee; }
body.light-theme .chart-box,
body.light-theme .system-section,
body.light-theme .fleet-sidebar-panel,
body.light-theme .settings-card,
body.light-theme .detail-panel,
body.light-theme .logs-panel { background: var(--card); box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
body.light-theme .unit-card { background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.08); }
body.light-theme .unit-card:hover { border-color: rgba(8,145,178,0.4); }
body.light-theme .modal-content { background: #ffffff; }
body.light-theme .form-input,
body.light-theme .form-select,
body.light-theme .config-editor,
body.light-theme .config-field input { background: #f0f4f8; border-color: #b8c8d8; color: #1a2a3a; }
body.light-theme .user-dropdown { background: #ffffff; box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
body.light-theme .dropdown-item:hover { background: rgba(0,0,0,0.04); }
body.light-theme .notification-center { background: #ffffff; }
body.light-theme .log-console { background: #f5f8fa; }
body.light-theme .log-msg { color: #4a5568; }
body.light-theme .kafka-stat { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06); }
body.light-theme .status-card { background: rgba(0,0,0,0.02); border-color: #b8c8d8; }
body.light-theme .progress-bar { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.08); }
body.light-theme .hero-card { background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.08); }
body.light-theme .panel-header,
body.light-theme .system-section-header { background: rgba(0,0,0,0.03); }
body.light-theme .detail-table th { background: rgba(0,0,0,0.03); }
body.light-theme .toast.info { background: #ffffff; }
body.light-theme .user-btn { background: rgba(0,0,0,0.04); }
body.light-theme .theme-toggle { background: rgba(0,0,0,0.04); }
body.light-theme ::-webkit-scrollbar-thumb { background: #94a3b8; }
body.light-theme .stream-body { color: #4a5568; }
body.light-theme .terminal-toolbar input { background: #f0f4f8; border-color: #b8c8d8; }
body.light-theme .terminal-table-wrap { background: #ffffff; border-color: rgba(0,0,0,0.08); }
body.light-theme .terminal-table thead { background: #f0f4f8; }
body.light-theme .terminal-table thead th { color: #475569; border-bottom-color: #d97706; }
body.light-theme .terminal-table tbody tr { border-bottom-color: rgba(0,0,0,0.06); }
body.light-theme .terminal-table tbody tr:hover { background: rgba(0,0,0,0.03); }
body.light-theme .terminal-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
body.light-theme .terminal-table tbody tr:nth-child(even):hover { background: rgba(0,0,0,0.04); }
body.light-theme .terminal-table tbody td { border-right-color: rgba(0,0,0,0.04); }
body.light-theme .td-serial { color: #0891b2; }
body.light-theme .td-code .code-line { color: #0891b2; }
body.light-theme .td-code .customer-line { color: #1e293b; }
body.light-theme .td-code .provider-line { color: #64748b; }
body.light-theme .td-gps .gps-yes { color: #059669; }
body.light-theme .td-gps .gps-no { color: #dc2626; }
body.light-theme .td-gps .coord { color: #64748b; }
body.light-theme .td-sep .speed-moving { color: #059669; }
body.light-theme .td-sep .speed-idle { color: #94a3b8; }
body.light-theme .td-sep .mark-on { color: #059669; }
body.light-theme .td-sep .mark-off { color: #dc2626; }
body.light-theme .td-sep .mark-up { color: #059669; }
body.light-theme .td-sep .mark-down { color: #dc2626; }
body.light-theme .td-type .mode-tag { color: #d97706; }
body.light-theme .td-identifier .id-link { color: #0891b2; }
body.light-theme .td-action .btn-track { background: rgba(8,145,178,0.08); color: #0891b2; }
body.light-theme .td-action .btn-track:hover { background: rgba(8,145,178,0.15); }
body.light-theme .gsm-bar { background: rgba(0,0,0,0.08); }
body.light-theme .gsm-bar.on { background: var(--dim); }
body.light-theme .gsm-good .gsm-bar.on { background: var(--green); }
body.light-theme .gsm-fair .gsm-bar.on { background: var(--yellow); }
body.light-theme .gsm-weak .gsm-bar.on { background: var(--red); }
body.light-theme .gsm-pct { color: #64748b; }
body.light-theme .gsm-good .gsm-pct { color: var(--green); }
body.light-theme .gsm-fair .gsm-pct { color: var(--yellow); }
body.light-theme .gsm-weak .gsm-pct { color: var(--red); }
body.light-theme .speed-unit { color: #94a3b8; }
body.light-theme .dir-val { color: #64748b; }
body.light-theme .sep-icon.on, body.light-theme .sep-icon.speed { color: var(--green); }
body.light-theme .sep-icon.off { color: var(--red); }
body.light-theme .sep-icon.null, body.light-theme .sep-icon.dim { color: #94a3b8; }
body.light-theme .sep-icon.fuel { color: var(--orange); }
body.light-theme .gps-icon.gps-yes { color: var(--green); }
body.light-theme .gps-icon.gps-no { color: var(--red); }
body.light-theme .topbar-divider { background: #b8c8d8; }
body.light-theme .hero-icon { opacity: 0.08; }
body.light-theme .hero-card:hover .hero-icon { opacity: 0.15; }
body.light-theme .device-detail-panel { background: #ffffff; box-shadow: -8px 0 30px rgba(0,0,0,0.1); border-left-color: var(--cyan); }
body.light-theme .map-filter-btn { background: rgba(0,0,0,0.04); border-color: #c8d4e0; }
body.light-theme .leaflet-container { background: #e8e8e8; }
body.light-theme .leaflet-tile-pane { filter: none; }
body.light-theme #detail-mini-map { background: #e8e8e8; }
body.light-theme #detail-mini-map .leaflet-tile-pane { filter: none; }
body.light-theme #detail-mini-map-wrapper { border-color: #c8d4e0; }
body.light-theme #detail-mini-map-toolbar { background: rgba(8,145,178,0.04); }
body.light-theme .detail-stat-item { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06); }
body.light-theme .terminal-count { color: #64748b; }

body.light-theme #history-table th {
    background: var(--card);
    color: var(--cyan);
    border-bottom-color: var(--cyan);
}
body.light-theme .detail-panel-header { background: rgba(8,145,178,0.04); }
body.light-theme .nav-item:hover { background: rgba(0,0,0,0.04); }
body.light-theme .nav-item.active { background: rgba(8,145,178,0.1); color: var(--cyan); }
body.light-theme .malfunction-overlay { background: rgba(220,38,38,0.1); }
body.light-theme .malfunction-content { background: #ffffff; }
body.light-theme .map-alerts-sidebar { background: #f0f4f8; }
body.light-theme .disk-bar-wrap { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.08); }
body.light-theme .smc { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06); }
body.light-theme .speed-stat { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .hero-stats { grid-template-columns: repeat(3, 1fr); }
    .chart-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-bottom-row { grid-template-columns: 1fr; }
    .alerts-chart-grid { grid-template-columns: repeat(2, 1fr); }
    .system-two-col { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
    .dashboard-analytics-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .hero-stats { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
    .alerts-chart-grid { grid-template-columns: 1fr; }
    .map-alerts-sidebar { display: none; }
}

@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar .sidebar-brand-text { opacity: 0; width: 0; }
    .sidebar .nav-label { opacity: 0; width: 0; }
    .sidebar .nav-item.active::after { display: none; }
    .main-wrapper { margin-left: var(--sidebar-collapsed); }
    .hero-stats { grid-template-columns: repeat(2, 1fr); }
    .hide-mobile { display: none; }
    .topbar { padding: 0 12px; }
    .device-detail-panel { width: 100%; }
    #map-container { height: calc(100vh - 200px); }
    .terminal-toolbar { padding: 10px 0; }
    .detail-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .kafka-pipeline { flex-direction: column; }
    .kafka-gauge-container { flex: 0 0 auto; }
    .system-status-section { gap: 6px; padding: 8px; }
    .status-card { min-width: 100px; padding: 6px 10px; }
}

@media (max-width: 480px) {
    .hero-stats { grid-template-columns: 1fr; }
    .system-mini-cards { grid-template-columns: repeat(2, 1fr); }
}

/* GMT Mismatch Panel */
.gmt-info-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.2);
    border-radius: 8px;
    margin-bottom: 16px;
    color: var(--dim);
    font-size: 0.8rem;
    line-height: 1.4;
}

.gmt-info-banner svg {
    flex-shrink: 0;
    color: #eab308;
}

.gmt-count-label {
    font-size: 0.8rem;
    color: var(--dim);
    font-weight: 600;
}

.gmt-table-wrap {
    overflow-x: auto;
}

.gmt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.gmt-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--dim);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.gmt-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.gmt-table tbody tr:hover {
    background: rgba(6, 182, 212, 0.04);
}

.gmt-imei code {
    font-family: var(--mono);
    color: var(--cyan);
    font-size: 0.82rem;
}

.gmt-drift {
    color: #ef4444;
    font-weight: 700;
    font-family: var(--mono);
}

.gmt-detected {
    color: var(--dim);
    font-size: 0.78rem;
}

.gmt-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.gmt-status.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.gmt-status.status-offline {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
}

.gmt-empty-row td {
    text-align: center;
    color: var(--dim);
    padding: 32px;
}

.btn-warning {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-warning:hover {
    background: rgba(234, 179, 8, 0.25);
}

.nav-badge.gmt-badge {
    background: #eab308;
    color: #0f172a;
}
