:root {
    --bg-dark: #FFF7ED;
    --bg-panel: #FFFFFF;
    --bg-input: #FFF3E6;
    --border-color: rgba(var(--primary-rgb), 0.18);
    --primary: #ED8B00;
    --primary-rgb: 237, 139, 0;
    --primary-hover: #C97500;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --danger: #F85149;
    --success: #3FB950;
    --gradient: linear-gradient(135deg, rgba(var(--primary-rgb), 0.12) 0%, rgba(var(--primary-rgb), 0) 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Layouts ────────────────────── */
.view {
    height: 100vh;
    width: 100vw;
    display: flex;
    transition: opacity 0.3s ease;
}

/* ─── Glass & Panels ──────────────── */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ─── Login Screen ────────────────── */
#login-view {
    justify-content: center;
    align-items: center;
    background-image: var(--gradient);
}
.login-container {
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.logo-box {
    background: var(--primary);
    width: 60px; height: 60px;
    border-radius: 12px;
    display: inline-flex; justify-content: center; align-items: center;
    font-size: 32px; color: white;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.4);
}
.subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 14px; }
.error-banner {
    background: rgba(248, 81, 73, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.3);
    padding: 10px; border-radius: 8px; font-size: 13px; margin-bottom: 20px;
}
.input-group {
    position: relative; margin-bottom: 16px;
}
.input-group i {
    position: absolute; left: 16px; top: 18px; color: var(--text-muted);
}
.input-group input {
    width: 100%; padding: 16px 16px 16px 45px;
    background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: 10px; color: white; font-size: 15px; outline: none;
    transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--primary); }

.btn-primary {
    width: 100%; padding: 16px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 10px; font-size: 16px; font-weight: 600;
    cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px;
    transition: background 0.2s, transform 0.1s; margin-top: 10px;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:hover { background: var(--primary-hover); }

/* ─── Dashboard Shell ─────────────── */
.sidebar {
    width: 250px; background: var(--bg-panel);
    border-right: 1px solid var(--border-color); display: flex; flex-direction: column;
}
.sidebar-header {
    padding: 24px; font-size: 20px; font-weight: 700; color: var(--primary);
    display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border-color);
}
.sidebar-logo { height: 32px; width: auto; object-fit: contain; }
.nav-links { list-style: none; padding: 20px 12px; flex: 1; }
.nav-links li {
    padding: 14px 16px; margin-bottom: 8px; border-radius: 8px;
    color: var(--text-muted); font-size: 15px; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; gap: 12px;
    transition: all 0.2s ease;
}
.nav-links li:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-links li.active { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); }
.sidebar-user {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 10px 14px 10px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user-left { display:flex; align-items:center; gap:10px; }
.sidebar-user-meta { display:flex; flex-direction:column; gap:2px; min-width: 0; }
.sidebar-user-title { font-size: 11px; color: var(--text-muted); letter-spacing: 0.3px; text-transform: uppercase; }
.sidebar-user-email { font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.92); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
#logout-btn {
    width: 100%; padding: 12px; background: transparent; border: 1px solid var(--border-color);
    color: var(--text-muted); border-radius: 8px; cursor: pointer; transition: 0.2s;
}
#logout-btn:hover { background: rgba(248, 81, 73, 0.1); color: var(--danger); border-color: var(--danger); }

.content { flex: 1; display: flex; flex-direction: column; background: var(--bg-dark); }
.avatar { background: var(--border-color); width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;}

.tab-content { padding: 40px; display: none; overflow-y: auto; flex: 1; }
.tab-content.active { display: block; animation: fadeUp 0.4s ease forwards; }
#files-tab.active { display: flex; flex-direction: column; }

h3 { margin-bottom: 24px; font-weight: 500; font-size: 22px;}

/* ─── Dash Metrics ────────────────── */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; }
.metric-card { padding: 24px; display: flex; align-items: center; gap: 20px; }
.metric-card i { font-size: 32px; color: var(--primary); opacity: 0.8;}
.metric-info { display: flex; flex-direction: column; }
.metric-info .label { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.metric-info .value { font-size: 28px; font-weight: 700; }

/* ─── Data Tables ─────────────────── */
.table-container { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 14px 20px; border-bottom: 1px solid var(--border-color); font-size: 14px;}
th { background: rgba(255,255,255,0.02); color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge { padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; background: rgba(255,255,255,0.1); }
.badge.active { background: rgba(63, 185, 80, 0.15); color: var(--success); border: 1px solid rgba(63, 185, 80, 0.3); }
.badge.inactive { background: rgba(248, 81, 73, 0.15); color: var(--danger); border: 1px solid rgba(248, 81, 73, 0.3); }

/* ─── Buttons ─────────────────────── */
.actions { display: flex; gap: 8px; }
.btn-icon { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid var(--border-color); width: 32px; height: 32px; border-radius: 6px; cursor: pointer; transition: 0.2s;}
.btn-icon:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-secondary { background: rgba(255,255,255,0.05); color: white; border: 1px solid var(--border-color); padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }
.btn-danger { background: rgba(248, 81, 73, 0.10); color: var(--danger); border: 1px solid rgba(248, 81, 73, 0.35); padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-danger:hover { background: rgba(248, 81, 73, 0.18); border-color: rgba(248, 81, 73, 0.55); }
.btn-success { background: rgba(63, 185, 80, 0.12); color: var(--success); border: 1px solid rgba(63, 185, 80, 0.35); padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-success:hover { background: rgba(63, 185, 80, 0.18); border-color: rgba(63, 185, 80, 0.55); }
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header-utils {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.search-box input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px 8px 36px;
    color: white;
    font-size: 14px;
    width: 240px;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.veh-dashboard {
    display: grid;
    grid-template-columns: minmax(520px, var(--veh-left-col, 1.55fr)) minmax(420px, 1fr);
    gap: 14px;
    align-items: stretch;
    position: relative;
    flex: 1;
    min-height: 0;
}

.veh-panel {
    padding: 14px;
}

.veh-resizable-panel {
    resize: vertical;
    overflow: auto;
    min-height: 220px;
}

.veh-panel-signals {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: none;
    height: 100%;
    min-height: 0;
}

.veh-dash-splitter {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    background: rgba(255,255,255,0.02);
    border-left: 1px solid rgba(255,255,255,0.08);
    border-right: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    z-index: 5;
}

.veh-dash-splitter:hover {
    background: rgba(255,255,255,0.05);
}

.veh-panel-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 420px;
    overflow: auto;
    min-height: 0;
}

.veh-panel-signals .table-container {
    max-height: none;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.veh-panel-overlay {
    position: fixed;
    top: 14px;
    right: 14px;
    bottom: 14px;
    left: 264px;
    z-index: 1000;
    padding: 14px;
    background: rgba(13, 17, 23, 0.65);
    backdrop-filter: blur(10px);
}

.veh-panel-expanded {
    height: 100%;
    width: 100%;
    overflow: hidden;
    resize: none;
}

.veh-signals-table th,
.veh-signals-table td {
    padding: 10px 12px;
}

.veh-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(13, 17, 23, 0.94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.veh-signals-table input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-main);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}

.veh-signals-table .sig-cell-wrap {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.veh-signals-table textarea.sig-ta {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-main);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    resize: none;
    min-height: 36px;
    max-height: 160px;
    overflow: hidden;
}

.veh-signals-table textarea.sig-ta.expanded {
    overflow: auto;
}

.veh-signals-table button.sig-expand {
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.86);
    cursor: pointer;
    user-select: none;
}

.veh-signals-table button.sig-expand:hover {
    background: rgba(255,255,255,0.08);
}

.veh-signals-table input:focus {
    border-color: rgba(var(--primary-rgb), 0.55);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    background: rgba(255,255,255,0.06);
}

.veh-signals-table textarea.sig-ta:focus {
    border-color: rgba(var(--primary-rgb), 0.55);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    background: rgba(255,255,255,0.06);
}

.veh-logic-list {
    max-height: 420px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    padding: 8px;
}

.veh-panel-fp {
    padding: 14px;
}

.veh-fp-summary {
    font-size: 12px;
    line-height: 1.35;
    color: rgba(255,255,255,0.86);
    max-height: 140px;
    overflow: auto;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
}

.veh-logicjson-text {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    color: white;
    border-radius: 12px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 12px;
    outline: none;
    min-height: 420px;
}

.veh-logicjson-text:focus {
    border-color: rgba(var(--primary-rgb), 0.55);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.section-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-top: -4px;
}

.form-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.checkbox-list {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.check-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.check-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.check-item label {
    font-size: 13px;
    cursor: pointer;
    margin: 0;
    flex-grow: 1;
}

.check-item .item-meta {
    font-size: 10px;
    color: var(--text-muted);
}

/* ─── Modals ──────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; pointer-events: none; transition: 0.2s; }
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal {
    background: #1a1b1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    width: 500px;
    max-width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.3s ease-out;
    padding: 24px;
    transform: translateY(20px);
    transition: 0.3s;
}
.modal-backdrop.active .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { margin: 0; font-size: 18px; }
.btn-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.btn-close:hover { color: white; }
.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: var(--text-muted); }
.form-group input, .form-group select { padding: 12px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 8px; color: white; outline: none; }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }

/* ─── Categorized Files ───────────── */
.file-categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}
.category-box {
    display: flex;
    flex-direction: column;
    height: 400px;
    overflow: hidden; /* container itself shouldn't scroll */
}
.category-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.category-header i {
    color: var(--primary);
    font-size: 18px;
}
.category-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.mini-table {
    flex: 1;
    border: none;
    border-radius: 0;
    margin-top: 0;
    overflow-y: auto; /* allow the table content to scroll */
}
.mini-table th {
    padding: 10px 20px;
}
.mini-table td {
    padding: 10px 20px;
}
.loading-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

/* ─── Animations ──────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.support-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--danger);
    vertical-align: middle;
    animation: supportPulse 1s ease-in-out infinite;
}

.support-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: rgba(248, 81, 73, 0.14);
    border-bottom: 1px solid rgba(248, 81, 73, 0.30);
    cursor: pointer;
    user-select: none;
}

.content.support-banner-on .tab-content {
    height: calc(100vh - 75px - 52px);
}

.support-focus td {
    background: rgba(248, 81, 73, 0.08) !important;
}

@keyframes supportPulse {
    0% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.65); opacity: 1; }
    70% { box-shadow: 0 0 0 10px rgba(248, 81, 73, 0); opacity: 0.8; }
    100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0); opacity: 1; }
}

/* ─── Toasts ──────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast { background: var(--bg-panel); color: white; padding: 16px 20px; border-radius: 8px; border-left: 4px solid var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.5); animation: fadeUp 0.3s ease; }
.toast.error { border-left-color: var(--danger); }

.heatmap-matrix {
    padding: 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    max-height: 360px;
    overflow: auto;
}

.hm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 6px 6px;
}

.hm-table th {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.hm-table th:first-child {
    text-align: left;
}

.hm-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
}

.hm-byte {
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    padding: 10px 0;
    min-width: 44px;
}

.hm-muted {
    opacity: 0.65;
}

@keyframes hmFlash {
    0% { box-shadow: 0 0 0 0 rgba(255, 50, 50, 0.65); }
    100% { box-shadow: 0 0 0 10px rgba(255, 50, 50, 0); }
}

.hm-flash {
    animation: hmFlash 0.35s ease-out;
}

.sig-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.25);
    margin-right: 8px;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.25) inset;
}

.hw-live-log {
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    max-height: 240px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}

/* Modern operations dashboard refresh */
:root {
    --bg-dark: #FFF7ED;
    --bg-panel: #FFFFFF;
    --bg-panel-2: #FFF3E6;
    --bg-input: #FFF3E6;
    --border-color: rgba(var(--primary-rgb), 0.18);
    --border-strong: rgba(var(--primary-rgb), 0.34);
    --primary: #ED8B00;
    --primary-rgb: 237, 139, 0;
    --primary-hover: #C97500;
    --primary-soft: rgba(var(--primary-rgb), 0.14);
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --danger: #FB7185;
    --success: #4ADE80;
    --warning: #FBBF24;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-panel: 0 18px 60px rgba(0, 0, 0, 0.38);
    --gradient: radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.16), transparent 34%),
        linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(255, 255, 255, 1));
}

body {
    background: var(--gradient);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.45;
}

button,
input,
select,
textarea {
    font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-links li:focus-visible,
.sidebar-user:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.glass-panel,
.table-container,
.modal,
.veh-panel,
.heatmap-matrix,
.mini-table {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 243, 230, 0.98));
    border-color: var(--border-color);
    box-shadow: var(--shadow-panel);
}

.sidebar {
    width: 278px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 243, 230, 0.98)),
        var(--bg-panel);
    border-right-color: var(--border-color);
}

.sidebar-header {
    padding: 22px 20px;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.sidebar-header span::after {
    content: "Ops";
    display: inline-flex;
    margin-left: 8px;
    padding: 2px 7px;
    border: 1px solid rgba(var(--primary-rgb), 0.26);
    border-radius: 999px;
    color: var(--primary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    vertical-align: middle;
}

.nav-links {
    padding: 16px 12px;
}

.nav-links li {
    border: 1px solid transparent;
    border-radius: 12px;
    min-height: 44px;
}

.nav-links li:hover {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.12);
}

.nav-links li.active {
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    box-shadow: inset 3px 0 0 var(--primary);
}

.content {
    background:
        radial-gradient(circle at 80% 0%, rgba(var(--primary-rgb), 0.10), transparent 30%),
        var(--bg-dark);
    min-width: 0;
}

.tab-content {
    padding: clamp(18px, 3vw, 36px);
}

.tab-content > h3,
.header-actions h3 {
    font-size: clamp(22px, 2.3vw, 30px);
    font-weight: 750;
    letter-spacing: -0.03em;
}

.metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
}

.dashboard-metric-link {
    width: 100%;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font: inherit;
    text-align: left;
    cursor: pointer;
    appearance: none;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.dashboard-metric-link:hover {
    transform: translateY(-2px);
    border-color: rgba(var(--primary-rgb), 0.6);
    box-shadow: 0 16px 42px rgba(var(--primary-rgb), 0.16);
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(var(--primary-rgb), 0.14), transparent 42%);
    pointer-events: none;
}

.metric-card i {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    font-size: 22px;
}

.metric-info .value {
    letter-spacing: -0.04em;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success,
.btn-icon,
#logout-btn {
    border-radius: var(--radius-sm);
}

.btn-primary {
    color: #FFFFFF;
    box-shadow: 0 12px 28px rgba(var(--primary-rgb), 0.22);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.08);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover,
.btn-icon:hover {
    background: rgba(var(--primary-rgb), 0.13);
    border-color: rgba(var(--primary-rgb), 0.45);
}

input,
select,
textarea,
.search-box input,
.form-group input,
.form-group select {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
}

input::placeholder,
textarea::placeholder {
    color: rgba(148, 163, 184, 0.72);
}

.table-container {
    overflow: auto;
}

table {
    min-width: 720px;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(255, 247, 237, 0.98);
}

td,
th {
    border-bottom-color: rgba(148, 163, 184, 0.14);
}

tr:hover td {
    background: rgba(var(--primary-rgb), 0.055);
}

.modal-backdrop {
    background: rgba(2, 6, 12, 0.72);
}

.modal {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
}

.btn-close {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: rgba(148, 163, 184, 0.12);
}

#toast-container {
    z-index: 2000;
}

.toast {
    border-radius: 12px;
    background: rgba(16, 23, 34, 0.96);
    border: 1px solid var(--border-color);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.veh-dashboard {
    grid-template-columns: minmax(440px, var(--veh-left-col, 1.45fr)) minmax(360px, 1fr);
}

.hardware-manage-dialog {
    max-width: 1180px;
    width: min(96vw, 1180px);
}

.hardware-manage-body {
    padding: 12px 0;
}

.hardware-summary-bar,
.hardware-primary-actions,
.hardware-admin-actions,
.hardware-vehicle-picker,
.hardware-workspace-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hardware-summary-bar {
    align-items: center;
    margin-bottom: 14px;
}

.hardware-primary-actions {
    margin-left: auto;
}

.hardware-admin-actions {
    align-items: center;
    margin-top: 10px;
}

.hardware-vehicle-picker {
    align-items: flex-end;
    margin-bottom: 12px;
}

.hardware-workspace-tabs {
    gap: 8px;
    margin-bottom: 10px;
}

@media (max-width: 1180px) {
    body {
        overflow: auto;
    }

    .view {
        min-height: 100vh;
        height: auto;
    }

    #dashboard-view {
        display: grid;
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .sidebar {
        width: 82px;
        position: sticky;
        top: 0;
        height: 100vh;
        z-index: 20;
    }

    .sidebar-header span,
    .nav-links li span,
    .nav-links li:not(.active)::after,
    .sidebar-user-meta,
    #logout-btn {
        display: none;
    }

    .sidebar-header {
        justify-content: center;
        padding-inline: 12px;
    }

    .nav-links li {
        justify-content: center;
        padding: 14px 10px;
    }

    .sidebar-footer {
        padding: 12px;
    }

    .sidebar-user {
        justify-content: center;
        padding: 10px;
    }

    .veh-dashboard {
        grid-template-columns: minmax(0, 1fr);
    }

    .veh-panel-stack {
        min-width: 0;
        overflow: visible;
    }

    #health-tab .stats-grid .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .veh-dash-splitter {
        display: none;
    }

    .veh-panel-overlay {
        left: 96px;
    }
}

@media (max-width: 760px) {
    #dashboard-view {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .sidebar {
        width: 100%;
        max-width: 100vw;
        min-width: 0;
        height: auto;
        min-height: auto;
        position: sticky;
        top: 0;
        overflow: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header {
        justify-content: flex-start;
        padding: 10px 14px;
        font-size: 16px;
    }

    .sidebar-header span {
        display: inline-flex;
    }

    .sidebar-logo {
        height: 26px;
    }

    .nav-links {
        display: flex;
        flex: none;
        width: 100%;
        min-width: 0;
        max-width: 100vw;
        gap: 8px;
        overflow-x: auto;
        padding: 8px 10px 10px;
        scrollbar-width: thin;
    }

    .nav-links li {
        min-width: 82px;
        margin: 0;
        padding: 8px 6px;
        flex-direction: column;
        gap: 4px;
        font-size: 11px;
        white-space: nowrap;
    }

    .nav-links .nav-label {
        display: block;
    }

    .sidebar-footer {
        display: none;
    }

    .header-actions,
    .header-utils {
        align-items: stretch;
        flex-direction: column;
    }

    .content {
        width: 100%;
        min-width: 0;
    }

    .tab-content {
        flex: none;
        width: 100%;
        min-width: 0;
        overflow: visible;
        padding: 16px;
    }

    #files-tab.active {
        display: block;
    }

    .metric-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px;
    }

    .metric-card {
        min-height: 104px;
        padding: 16px;
        gap: 14px;
    }

    .metric-info .value {
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .stats-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 14px;
    }

    .stat-card {
        min-width: 0;
        padding: 14px;
    }

    .support-banner {
        flex-wrap: wrap;
        padding: 10px 14px;
    }

    #db-tools-panel > div:first-child {
        align-items: flex-start !important;
        flex-wrap: wrap;
    }

    #db-tools-panel > div:first-child > div {
        width: 100%;
        margin-left: 0 !important;
        flex-wrap: wrap;
    }

    #db-tools-panel > div:nth-child(3) > div:first-child {
        min-width: 0 !important;
    }

    .vehicle-picker > .form-group,
    .vehicle-picker > button {
        flex: 1 1 170px;
        min-width: 0 !important;
    }

    .vehicle-picker > div:last-child {
        width: 100%;
        margin-left: 0 !important;
        padding-bottom: 0 !important;
    }

    .veh-dashboard,
    .veh-panel-stack {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
    }

    .veh-resizable-panel,
    .veh-panel-signals {
        height: auto;
        min-height: 0;
        resize: none;
        overflow: visible;
    }

    .veh-panel-header {
        align-items: flex-start !important;
        flex-wrap: wrap;
    }

    .veh-panel-header > div {
        width: 100%;
        margin-left: 0 !important;
        flex-wrap: wrap;
    }

    .veh-logic-workspace {
        flex-direction: column;
    }

    .veh-logic-workspace > div {
        width: 100% !important;
        min-width: 0 !important;
    }

    .veh-signals-table {
        max-height: 65vh !important;
    }

    .veh-panel-overlay {
        inset: 8px;
        overflow: auto;
    }

    .modal-backdrop {
        align-items: flex-start;
        padding: 8px;
        overflow-y: auto;
    }

    .modal {
        width: calc(100vw - 16px) !important;
        max-width: none !important;
        max-height: calc(100dvh - 16px);
        margin: 0;
        padding: 16px;
        overflow-y: auto;
    }

    .signal-form-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    #sigv-toolbar {
        align-items: flex-start !important;
        flex-wrap: wrap;
    }

    #sigv-live-status {
        margin-left: 0 !important;
    }

    #sigv-bytes,
    #sigv-bits {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .search-box input {
        width: 100%;
    }

    #hardware-tab .header-actions {
        gap: 10px;
    }

    #hardware-tab .header-utils,
    #hardware-tab .search-box {
        width: 100%;
    }

    .hardware-table-container {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .hardware-table {
        min-width: 0;
    }

    .hardware-table thead {
        display: none;
    }

    .hardware-table,
    .hardware-table tbody,
    .hardware-table tr,
    .hardware-table td {
        display: block;
        width: 100%;
    }

    .hardware-table tr {
        margin-bottom: 14px;
        padding: 8px 14px;
        border: 1px solid var(--border-color);
        border-radius: 14px;
        background: var(--bg-panel);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    }

    .hardware-table td {
        display: grid;
        grid-template-columns: minmax(105px, 0.42fr) minmax(0, 1fr);
        gap: 12px;
        align-items: center;
        min-height: 42px;
        padding: 9px 0 !important;
        text-align: left !important;
        border-bottom: 1px solid var(--border-color);
        max-width: none !important;
        overflow-wrap: anywhere;
    }

    .hardware-table td:last-child {
        border-bottom: 0;
    }

    .hardware-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .hardware-table td.actions .btn-secondary {
        width: 100%;
        justify-content: center;
        padding: 10px 12px !important;
    }

    #hardware-manage-modal {
        padding: 0;
        overflow: hidden;
    }

    .hardware-manage-dialog {
        width: 100vw !important;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        padding: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .hardware-manage-dialog > .modal-header {
        flex: none;
        margin: 0;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-panel);
        position: sticky;
        top: 0;
        z-index: 5;
    }

    .hardware-manage-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 14px 16px 24px;
    }

    .hardware-summary-bar {
        align-items: flex-start;
    }

    .hardware-summary-bar > :not(.hardware-primary-actions) {
        width: 100%;
    }

    .hardware-primary-actions,
    .hardware-admin-actions {
        width: 100%;
        margin-left: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hardware-primary-actions button,
    .hardware-admin-actions button {
        width: 100%;
        min-width: 0;
        justify-content: center;
    }

    .hardware-vehicle-picker {
        align-items: stretch;
    }

    .hardware-vehicle-picker > .form-group,
    .hardware-vehicle-picker > div {
        width: 100%;
        min-width: 0 !important;
        margin-left: 0 !important;
    }

    .hardware-vehicle-picker > div {
        flex-wrap: wrap;
    }

    .hardware-vehicle-picker button {
        flex: 1 1 170px;
        justify-content: center;
    }

    .hardware-workspace-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 6px;
        position: sticky;
        top: 0;
        z-index: 4;
        background: var(--bg-panel);
    }

    .hardware-workspace-tabs button {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .login-container {
        margin: 12px;
        padding: 24px 18px;
    }

    .metric-grid,
    #health-tab .stats-grid .metric-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .header-actions .btn-secondary,
    .vehicle-picker > button,
    .veh-panel-header .btn-secondary {
        justify-content: center;
    }

    th,
    td {
        padding: 10px 12px;
    }

    .hardware-primary-actions,
    .hardware-admin-actions {
        grid-template-columns: minmax(0, 1fr);
    }
}

html[data-theme="legacy-green"] {
    --bg-dark: #070B12 !important;
    --bg-panel: #101722 !important;
    --bg-panel-2: #141E2B !important;
    --bg-input: #0A111B !important;
    --border-color: rgba(148, 163, 184, 0.18) !important;
    --border-strong: rgba(148, 163, 184, 0.34) !important;
    --primary: #22C55E !important;
    --primary-rgb: 34, 197, 94 !important;
    --primary-hover: #16A34A !important;
    --primary-soft: rgba(var(--primary-rgb), 0.14) !important;
    --text-main: #EEF6FF !important;
    --text-muted: #94A3B8 !important;
    --gradient: radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.18), transparent 34%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(7, 11, 18, 1)) !important;
}

html[data-theme="legacy-green"] .glass-panel,
html[data-theme="legacy-green"] .table-container,
html[data-theme="legacy-green"] .modal,
html[data-theme="legacy-green"] .veh-panel,
html[data-theme="legacy-green"] .heatmap-matrix,
html[data-theme="legacy-green"] .mini-table {
    background: linear-gradient(180deg, rgba(20, 30, 43, 0.96), rgba(12, 18, 28, 0.96));
}

html[data-theme="legacy-green"] .sidebar {
    background:
        linear-gradient(180deg, rgba(16, 23, 34, 0.98), rgba(9, 14, 22, 0.98)),
        var(--bg-panel);
}

html[data-theme="legacy-green"] .content {
    background:
        radial-gradient(circle at 80% 0%, rgba(var(--primary-rgb), 0.08), transparent 30%),
        var(--bg-dark);
}

html[data-theme="legacy-green"] th {
    background: rgba(15, 23, 42, 0.98);
}

html[data-theme="legacy-green"] .btn-primary {
    color: #04110F;
    box-shadow: 0 12px 28px rgba(var(--primary-rgb), 0.22);
}
