/* GPS Tracking System - Main CSS */
/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /*
     * Global UI scale
     * - Desktop defaults to 0.8 to match the previous “80% browser zoom” look.
     * - Tablet uses 0.9, mobile uses 1.0 (readability).
     */
    --ui-scale: 0.9;
    --primary-color: #2196f3;
    --secondary-color: #4caf50;
    --accent-color: #ff9800;
    --danger-color: #f44336;
    --background-color: #f5f5f5;
    --surface-color: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.15);
    --shadow-heavy: 0 4px 12px rgba(0,0,0,0.2);
    --border-radius: 4px;
    --transition: all 0.3s ease;
    --surface-hover: #f0f2f5;
    --selected-bg: rgba(33, 150, 243, 0.1);
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --scrollbar-thumb-hover: #a1a1a1;
    /* Panel animation */
    --panel-transition-duration: 320ms;
    --panel-ease: cubic-bezier(0.22, 1, 0.36, 1); /* easeOutCubic */
}

html {
    font-size: calc(16px * var(--ui-scale));
}

/* Tablet (768-1024px): Keep same scale as desktop - no change */
/* Only mobile gets scale=1 for touch readability */
@media (max-width: 768px) {
    :root {
        --ui-scale: 1;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #111820;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

html.theme-light #loading-screen {
    background: #ffffff;
}

html.theme-light #loading-screen .loading-spinner p {
    color: #333;
}

/* Session Expired Overlay */
.session-expired-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.session-expired-card {
    width: min(520px, 100%);
    background: var(--surface-color);
    border-radius: 10px;
    box-shadow: var(--shadow-heavy);
    border: 1px solid var(--border-color);
    padding: 18px 20px;
}

.session-expired-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.session-expired-title i {
    color: var(--danger-color);
}

.session-expired-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

.session-expired-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

.session-expired-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--border-radius);
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.session-expired-btn:hover {
    filter: brightness(0.95);
}

.loading-spinner {
    text-align: center;
    color: var(--primary-color);
}

.loading-spinner i {
    font-size: 48px;
    animation: spin 2s linear infinite;
    margin-bottom: 20px;
    display: block;
}

.loading-spinner p {
    font-size: 18px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Top Navigation Bar */
.top-nav {
    background: var(--surface-color);
    height: calc(50px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 calc(15px * var(--ui-scale));
    box-shadow: var(--shadow-light);
    z-index: 1500;
    position: relative;
}

.nav-icons {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--ui-scale));
}

.nav-icon {
    width: calc(32px * var(--ui-scale));
    height: calc(32px * var(--ui-scale));
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-secondary);
    position: relative;
}

.nav-icon.notification-icon.muted,
.nav-icon.notification-icon.muted i {
    color: var(--text-muted);
}

.nav-icon.notification-icon.muted {
    background: var(--background-color);
}

.nav-icon:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.nav-icon i {
    font-size: calc(16px * var(--ui-scale));
}

.nav-separator {
    width: 1px;
    height: calc(20px * var(--ui-scale));
    background: var(--border-color);
    margin: 0 calc(8px * var(--ui-scale));
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: calc(15px * var(--ui-scale));
}

.language-selector {
    background: none;
    border: none;
    font-size: calc(14px * var(--ui-scale));
    cursor: pointer;
    color: var(--text-secondary);
    padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.language-selector:hover {
    background: var(--background-color);
}

.alert-count, .cart-count {
    background: var(--accent-color);
    color: white;
    padding: calc(2px * var(--ui-scale)) calc(6px * var(--ui-scale));
    border-radius: 10px;
    font-size: calc(12px * var(--ui-scale));
    font-weight: 500;
    margin-left: 5px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--ui-scale));
    cursor: pointer;
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: var(--text-secondary);
}

.user-menu:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

/* User Dropdown Menu */
.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 150px;
    background: var(--surface-color);
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    border-radius: 6px;
    z-index: 9999;
    padding: 4px 0;
    text-align: left;
    border: 1px solid var(--border-color);
}

.user-dropdown a {
    display: block;
    padding: 10px 15px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: calc(13px * var(--ui-scale));
    transition: background 0.15s ease;
}

.user-dropdown a:hover {
    background: var(--background-color);
}

.user-dropdown a i {
    color: var(--text-secondary);
}

/* Dark theme dropdown overrides */
body.theme-dark .user-dropdown {
    background: #243647;
    border-color: #3a5268;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

body.theme-dark .user-dropdown a:hover {
    background: #2e4458;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - (50px * var(--ui-scale)));
    width: 100vw; /* span full viewport width */
}

/* Left Sidebar */

 .sidebar {
     width: calc(380px * var(--ui-scale));
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-medium);
    /* Collapse by width so the map reclaims space */
    flex: 0 0 auto;
    flex-basis: calc(380px * var(--ui-scale));
    transition: flex-basis var(--panel-transition-duration) var(--panel-ease), width var(--panel-transition-duration) var(--panel-ease), box-shadow 200ms ease;
    will-change: width, flex-basis;
    overflow: hidden; /* avoid showing content during animation */
}

.sidebar.collapsed {
    width: 0;
    flex-basis: 0;
    border-right: none;
    box-shadow: none;
    pointer-events: none; /* prevent hidden sidebar from catching clicks */
}

/* Hide inner content when collapsed */
.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .panel-content {
    display: none;
}

/* Sidebar Header */
.sidebar-header {
    padding: calc(15px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.tab-buttons {
    display: flex;
    background: var(--background-color);
    border-radius: 6px;
    padding: calc(2px * var(--ui-scale));
    gap: calc(2px * var(--ui-scale));
}

.tab-button {
    flex: 1;
    padding: calc(10px * var(--ui-scale)) calc(8px * var(--ui-scale));
    background: none;
    border: none;
    border-radius: 4px;
    font-size: calc(11px * var(--ui-scale));
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(4px * var(--ui-scale));
}

.tab-button i {
    font-size: calc(14px * var(--ui-scale));
}

.tab-button.active {
    background: var(--surface-color);
    color: var(--primary-color);
    box-shadow: var(--shadow-light);
}

.tab-button:hover:not(.active) {
    background: rgba(255, 255, 255, 0.5);
}

/* Panel Content */
.panel-content {
    display: none;
    flex-direction: column;
    height: calc(100% - (80px * var(--ui-scale)));
}

.panel-content.active {
    display: flex;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.filter-tab {
    flex: 1;
    padding: calc(10px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border: none;
    background: none;
    font-size: calc(11px * var(--ui-scale));
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
}

.filter-tab.active {
    background: var(--surface-color);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.filter-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
}

/* Search Container */
.search-container {
    padding: calc(10px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: calc(8px * var(--ui-scale));
}

.search-input {
    flex: 1;
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: calc(12px * var(--ui-scale));
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.search-btn {
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.search-btn:hover {
    background: var(--primary-color);
    color: var(--surface-color);
    border-color: var(--primary-color);
}

/* Add Object button */
.add-object-btn {
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.add-object-btn:hover {
    background: var(--secondary-color);
    color: var(--surface-color);
    border-color: var(--secondary-color);
}

/* Inputs in modal */
.text-input {
    width: 100%;
    padding: calc(10px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: calc(14px * var(--ui-scale));
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* List Header */
.list-header {
    display: flex;
    align-items: center;
    padding: calc(8px * var(--ui-scale)) calc(15px * var(--ui-scale));
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    font-size: calc(11px * var(--ui-scale));
    color: var(--text-secondary);
    font-weight: 500;
}

.header-checkbox {
    margin-right: calc(8px * var(--ui-scale));
    width: calc(14px * var(--ui-scale));
    height: calc(14px * var(--ui-scale));
}

.header-text {
    flex: 1;
}

.header-icon {
    width: calc(30px * var(--ui-scale));
    text-align: center;
    font-size: calc(12px * var(--ui-scale));
}

/* Object List */
.object-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface-color);
    min-height: 0;
}

.object-list.loading .object-item {
    display: none;
}

/* Vehicle Group Sections */
.vehicle-group-section {
    margin-bottom: 0;
}

.vehicle-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
}

.vehicle-group-header:hover {
    background: var(--surface-hover, rgba(0,0,0,0.04));
}

.group-toggle-icon {
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.group-name {
    flex: 1;
    font-size: 12px;
    letter-spacing: 0.1px;
}

.vehicle-group-content {
    background: var(--surface-color);
}

.object-item {
    display: flex;
    align-items: center;
    padding: calc(10px * var(--ui-scale)) calc(15px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    font-size: calc(12px * var(--ui-scale));
}

.object-item:hover {
    background: var(--surface-hover, rgba(0,0,0,0.04));
}

.object-item.selected {
    background: var(--selected-bg, rgba(33,150,243,0.1));
    border-left: 3px solid var(--primary-color);
}

.object-checkbox {
    margin-right: calc(8px * var(--ui-scale));
    width: calc(14px * var(--ui-scale));
    height: calc(14px * var(--ui-scale));
}

.object-icon {
    width: calc(28px * var(--ui-scale));
    height: calc(28px * var(--ui-scale));
    margin-right: calc(10px * var(--ui-scale));
    border-radius: 3px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(12px * var(--ui-scale));
    flex-shrink: 0;
}

.object-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.object-icon.car { background: var(--accent-color); }
.object-icon.van { background: var(--primary-color); }
.object-icon.motorbike { background: #9c27b0; }
.object-icon.bus { background: #e91e63; }

.object-details {
    flex: 1;
    min-width: 0;
}

.object-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.object-time {
    color: var(--text-secondary);
    font-size: calc(11px * var(--ui-scale));
    display: flex;
    align-items: center;
    gap: 0;
}

.object-time .time-text {
    /* Time text comes after status indicator */
}

.object-status {
    display: inline-block;
    width: calc(8px * var(--ui-scale));
    height: calc(8px * var(--ui-scale));
    border-radius: 50%;
    margin-right: calc(5px * var(--ui-scale));
}

.object-status.online { background: var(--secondary-color); }
.object-status.offline { background: var(--text-muted); }
.object-status.idle { background: var(--accent-color); }
.object-status.moving { background: var(--primary-color); }

.object-speed {
    margin-left: calc(8px * var(--ui-scale));
    font-size: calc(11px * var(--ui-scale));
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: calc(50px * var(--ui-scale));
    text-align: right;
}

.object-actions {
    margin-left: calc(8px * var(--ui-scale));
    opacity: 0;
    transition: opacity 0.15s ease;
    /* Ensure button stays clickable even when fading */
    pointer-events: auto;
}

.object-item:hover .object-actions,
.object-item:focus-within .object-actions {
    opacity: 1;
}

/* Keep action buttons visible while being clicked */
.object-actions:focus-within,
.object-actions.active {
    opacity: 1;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: calc(4px * var(--ui-scale));
    margin-left: calc(4px * var(--ui-scale));
    opacity: 0.6;
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.action-btn:hover {
    opacity: 1;
    background: var(--background-color);
}

.action-btn.follow-btn.follow-active {
    opacity: 1;
    color: var(--primary-color);
    background: var(--selected-bg, rgba(33, 150, 243, 0.12));
}

.object-actions .follow-btn {
    opacity: 0.75;
}

.object-actions .follow-btn.follow-active {
    opacity: 1;
}

/* History Panel Styles */
.history-filters {
    padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    overflow: visible;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--ui-scale));
    margin-bottom: calc(8px * var(--ui-scale));
}

.filter-label {
    font-size: calc(11px * var(--ui-scale));
    color: var(--text-secondary);
    display: block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    width: calc(62px * var(--ui-scale));
    min-width: calc(62px * var(--ui-scale));
    flex-shrink: 0;
}

.filter-select {
    flex: 1;
    min-width: 0;
    padding: calc(7px * var(--ui-scale)) calc(10px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: calc(12.5px * var(--ui-scale));
    background: var(--surface-color);
    transition: var(--transition);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 10px;
    padding-right: 24px;
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.date-time-group {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: calc(6px * var(--ui-scale));
    align-items: center;
}

.date-input {
    flex: 1;
    min-width: 0;
    padding: calc(7px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: calc(12.5px * var(--ui-scale));
    background: var(--surface-color);
    color: var(--text-primary);
    transition: var(--transition);
}

.time-input {
    width: 80px;
    flex-shrink: 0;
    padding: calc(7px * var(--ui-scale)) calc(6px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: calc(12.5px * var(--ui-scale));
    background: var(--surface-color);
    color: var(--text-primary);
    transition: var(--transition);
}

/* Dark theme: style native date/time picker popups */
body.theme-dark .date-input,
body.theme-dark .time-input {
    color-scheme: dark;
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .date-input:hover,
body.theme-dark .time-input:hover,
body.theme-dark .date-input:focus,
body.theme-dark .time-input:focus {
    border-color: #1da1f2;
}

body.theme-dark .date-input::-webkit-calendar-picker-indicator,
body.theme-dark .time-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.date-input:hover,
.time-input:hover {
    border-color: var(--primary-color);
}

.date-input:focus,
.time-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.filter-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.filter-btn {
    padding: calc(8px * var(--ui-scale)) calc(6px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-color);
    font-size: calc(11.5px * var(--ui-scale));
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-align: center;
}

.filter-btn:hover {
    background: var(--background-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.primary {
    background: var(--primary-color);
    color: var(--surface-color);
    border-color: var(--primary-color);
    grid-column: span 3;
    font-weight: 600;
}

.filter-btn.primary:hover {
    background: #1976d2;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

/* Active state for toggle buttons (e.g. "Hide Stops") */
.filter-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.filter-btn.active:hover {
    background: #1976d2;
    border-color: #1976d2;
}

/* Tiny loading spinner next to stops dropdown */
.stops-loading-spinner {
    display: none;
    align-items: center;
    justify-content: center;
    font-size: calc(13px * var(--ui-scale, 1));
    color: var(--primary-color);
    animation: stops-spinner-fadein 0.15s ease;
    flex-shrink: 0;
    margin-left: -2px;
}

@keyframes stops-spinner-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Custom Searchable Vehicle Dropdown */
.vehicle-dropdown-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    z-index: 100;
}

/* Inline hint when no vehicle selected */
.object-select-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #e0245e;
    background: rgba(224, 36, 94, 0.08);
    border: 1px solid rgba(224, 36, 94, 0.25);
    border-radius: 6px;
    animation: hintSlideIn 0.25s ease;
    transition: opacity 0.3s ease;
}

.object-select-hint.fade-out {
    opacity: 0;
}

.object-select-hint i {
    font-size: 13px;
}

@keyframes hintSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.vehicle-dropdown-trigger.shake {
    animation: triggerShake 0.5s ease;
}

@keyframes triggerShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(2px); }
}

.vehicle-dropdown-trigger {
    width: 100%;
    min-width: 0;
    padding: calc(7px * var(--ui-scale)) calc(10px * var(--ui-scale));
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: calc(12.5px * var(--ui-scale));
    background: var(--surface-color);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
}

.vehicle-dropdown-trigger:hover {
    border-color: var(--primary-color);
}

.vehicle-dropdown-trigger.open {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.vehicle-dropdown-trigger .trigger-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.vehicle-dropdown-trigger .trigger-text.placeholder {
    color: var(--text-muted);
}

.vehicle-dropdown-trigger .trigger-icon {
    color: var(--text-muted);
    transition: transform 0.2s ease;
    font-size: 12px;
}

.vehicle-dropdown-trigger.open .trigger-icon {
    transform: rotate(180deg);
}

.vehicle-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.vehicle-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.vehicle-dropdown-search {
    padding: 5px 4px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.vehicle-dropdown-search input {
    width: 100%;
    padding: 5px 12px 5px 32px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface-color);
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
}

.vehicle-dropdown-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.vehicle-dropdown-search input::placeholder {
    color: var(--text-muted);
}

.vehicle-dropdown-list {
    overflow-y: auto;
    flex: 1;
    padding: 0;
    scrollbar-width: thin;
}

.vehicle-dropdown-list::-webkit-scrollbar {
    width: 5px;
}

.vehicle-dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.vehicle-dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.35);
    border-radius: 3px;
}

.vehicle-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.55);
}

.vehicle-dropdown-group {
    padding: 0;
}

.vehicle-dropdown-group-label {
    padding: 8px 14px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-color);
    background: var(--background-color);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.vehicle-dropdown-group-label:hover {
    background: var(--surface-hover);
}

.vehicle-dropdown-group-label .group-label-text {
    flex: 1;
}

.vehicle-dropdown-group-label .group-toggle-icon {
    font-size: 10px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.vehicle-dropdown-group.collapsed .group-toggle-icon {
    transform: rotate(-90deg);
}

.vehicle-dropdown-items {
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.vehicle-dropdown-group.collapsed .vehicle-dropdown-items {
    display: none;
}

.vehicle-dropdown-item {
    padding: 3px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.vehicle-dropdown-item:hover {
    background: var(--surface-hover);
}

.vehicle-dropdown-item.highlighted {
    background: var(--selected-bg);
    outline: none;
}

.vehicle-dropdown-item.selected {
    background: var(--selected-bg);
    font-weight: 500;
}

.vehicle-dropdown-item .vehicle-icon {
    width: 24px;
    height: 24px;
    background: var(--background-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
}

.vehicle-dropdown-item .vehicle-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vehicle-dropdown-item .vehicle-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.vehicle-dropdown-item .vehicle-status.online {
    background: var(--secondary-color);
}

.vehicle-dropdown-item .vehicle-status.offline {
    background: var(--text-muted);
}

.vehicle-dropdown-empty {
    padding: 20px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.vehicle-dropdown-empty i {
    display: block;
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* History Content */
.history-content {
    flex: 1;
    overflow-y: auto;
    background: var(--surface-color);
}

/* History Playback (separate from list) */
.history-playback {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.playback-controls .playback-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.playback-buttons {
    display: flex;
    gap: 6px;
}

.playback-btn {
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.playback-btn.active {
    background: var(--selected-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.playback-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.progress-slider { flex: 1; }

.progress-info { font-size: 12px; color: var(--text-secondary); }

.playback-admin-timing {
    font-size: 11px;
    padding: 3px 6px;
    margin-top: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-variant-numeric: tabular-nums;
}

.playback-admin-timing-mariadb {
    color: #1e88e5;
    background: rgba(30, 136, 229, 0.08);
    border: 1px solid rgba(30, 136, 229, 0.25);
}

.playback-admin-timing-postgres {
    color: #e67e22;
    background: rgba(230, 126, 34, 0.08);
    border: 1px solid rgba(230, 126, 34, 0.25);
}

.playback-admin-timing i { font-size: 10px; }



.no-data {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.6s ease, transform 0.3s ease;
}

.no-data i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: var(--text-muted);
    transition: color 0.6s ease, text-shadow 0.6s ease;
}

/* Red alert pulse — applied briefly then removed to settle back to gray */
@keyframes noDataIconPulse {
    0%   { color: #dc3545; text-shadow: 0 0 14px rgba(220, 53, 69, 0.5); }
    100% { color: #dc3545; text-shadow: 0 0 4px rgba(220, 53, 69, 0.2); }
}

@keyframes noDataTextPulse {
    0%   { color: #dc3545; }
    100% { color: #dc3545; }
}

.no-data.no-data--alert {
    color: #dc3545;
}

.no-data.no-data--alert i {
    color: #dc3545;
    animation: noDataIconPulse 1.6s ease-out;
    text-shadow: 0 0 10px rgba(220, 53, 69, 0.4);
}

.no-data.no-data--alert p {
    color: #dc3545;
    animation: noDataTextPulse 1.6s ease-out;
}

/* ── History Loading Indicator ───────────────────────────── */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 40px;
    gap: 0;
    user-select: none;
}

.loading-state .ls-icon-ring {
    position: relative;
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
}

.loading-state .ls-icon-ring .ls-spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    animation: ls-spin 0.9s linear infinite;
}

.loading-state .ls-icon-ring .ls-center-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: var(--primary-color);
    opacity: 0.85;
}

@keyframes ls-spin {
    to { transform: rotate(360deg); }
}

.loading-state .ls-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.loading-state .ls-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 18px;
    min-height: 16px;
}

.loading-state .ls-progress-track {
    width: 100%;
    max-width: 220px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.loading-state .ls-progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    width: 0%;
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Indeterminate shimmer when width is 0 */
.loading-state .ls-progress-fill.ls-indeterminate {
    width: 40% !important;
    animation: ls-shimmer 1.4s ease-in-out infinite;
}

@keyframes ls-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.loading-state .ls-progress-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    min-height: 14px;
}

/* ── Dark-mode overrides ─────────────────────────────────── */
body.theme-dark .loading-state .ls-spinner {
    border-color: #2a3f52;
    border-top-color: #1da1f2;
}

body.theme-dark .loading-state .ls-center-icon {
    color: #1da1f2;
}

body.theme-dark .loading-state .ls-title {
    color: #e8edf2;
}

body.theme-dark .loading-state .ls-subtitle {
    color: #8899a6;
}

body.theme-dark .loading-state .ls-progress-track {
    background: #2a3f52;
}

body.theme-dark .loading-state .ls-progress-fill {
    background: #1da1f2;
}

body.theme-dark .loading-state .ls-progress-label {
    color: #5c7080;
}

.history-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: var(--surface-hover);
}

.history-item.selected {
    background: var(--selected-bg);
    border-left: 3px solid var(--primary-color);
}

.history-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.history-location {
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-weight: 500;
}

.history-details {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 15px;
}

.history-speed {
    color: var(--secondary-color);
}

.history-status {
    color: var(--accent-color);
}

/* Events and Places Panels */
.events-container,
.places-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.events-header,
.places-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.events-header h3,
.places-header h3 {
    font-size: 14px;
    color: var(--text-primary);
    margin: 0;
}

.refresh-btn,
.add-place-btn {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.refresh-btn:hover,
.add-place-btn:hover {
    background: var(--primary-color);
    color: var(--surface-color);
    border-color: var(--primary-color);
}

.events-list,
.places-list {
    flex: 1;
    overflow-y: auto;
    background: var(--surface-color);
}

/* Place Item Styling */
.place-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.place-item:hover {
    background: var(--background-color);
    transform: translateX(2px);
    border-left: 3px solid var(--primary-color);
}

.place-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.place-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0; /* Allows text truncation */
}

.place-name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-actions-inline {
    display: flex;
    gap: 2px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.place-item:hover .place-actions-inline {
    opacity: 1;
}

.place-btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.place-btn-icon:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.place-description {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.place-coordinates {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
    background: var(--background-color);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

/* Map Container */
.map-container {
    flex: 1 1 auto;
    position: relative;
    /* transparent to avoid visible gray when neighbors collapse */
    background: transparent;
    /* Allow subtle layout animation when siblings change size */
    transition: flex var(--panel-transition-duration) var(--panel-ease), width var(--panel-transition-duration) var(--panel-ease), margin var(--panel-transition-duration) var(--panel-ease), padding var(--panel-transition-duration) var(--panel-ease);
}

.map-content {
    width: 100%;
    height: 100%;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 0; /* allow flex parent to control height properly */
}

/* Suppress browser focus outline on Leaflet container –
   Leaflet sets tabindex="0" for keyboard nav, causing a visible
   black outline (most noticeable on the left edge next to the sidebar)
   whenever the map receives focus via click or tab-switch. */
#map:focus,
.leaflet-container:focus {
    outline: none;
}

body.theme-dark #map {
    background: #1a1a2e;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: calc(20px * var(--ui-scale));
    right: calc(20px * var(--ui-scale));
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--ui-scale));
    z-index: 1000;
}

.control-group {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    padding: calc(5px * var(--ui-scale));
    display: flex;
    flex-direction: column;
    gap: calc(2px * var(--ui-scale));
}

body.theme-dark .control-group {
    background: rgba(15, 25, 35, 0.92);
    border: 1px solid #2a3f52;
}

body.theme-dark .control-btn {
    color: #8899a6;
}

body.theme-dark .control-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.control-btn {
    width: calc(32px * var(--ui-scale));
    height: calc(32px * var(--ui-scale));
    border: none;
    background: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.control-btn:hover {
    background: var(--primary-color);
    color: var(--surface-color);
}

.control-btn.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 8px rgba(var(--primary-color-rgb, 59,130,246), 0.4);
}

/* Layer Selector Panel */
.layer-selector-panel {
    position: absolute;
    top: calc(20px * var(--ui-scale));
    right: calc(60px * var(--ui-scale));
    width: 220px;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    z-index: 1001;
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: layerPanelIn 0.15s ease-out;
}

@keyframes layerPanelIn {
    from { opacity: 0; transform: translateX(10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.layer-selector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.layer-selector-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    font-size: 13px;
    line-height: 1;
    transition: color 0.15s;
}

.layer-selector-close:hover {
    color: var(--text-primary);
}

.layer-selector-list {
    padding: 6px 0;
    max-height: 340px;
    overflow-y: auto;
}

.layer-selector-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-primary);
    font-size: 13px;
}

.layer-selector-item:hover {
    background: var(--hover-color);
}

.layer-selector-item.active {
    background: rgba(var(--primary-rgb, 59,130,246), 0.12);
    color: var(--primary-color);
}

.layer-theme-icon {
    width: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.layer-selector-item.active .layer-theme-icon {
    color: var(--primary-color);
}

.layer-name {
    flex: 1;
}

.layer-check {
    font-size: 11px;
    color: var(--primary-color);
    flex-shrink: 0;
}

/* Status Bar */
.status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--border-color);
    padding: calc(8px * var(--ui-scale)) calc(15px * var(--ui-scale));
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: calc(12px * var(--ui-scale));
    color: var(--text-secondary);
    backdrop-filter: blur(5px);
    z-index: 1200; /* ensure on top of Leaflet panes and controls */
    pointer-events: auto;
}

.status-left {
    display: flex;
    gap: calc(15px * var(--ui-scale));
}

.status-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: var(--text-secondary);
}

.status-btn.active {
    background: var(--primary-color);
    color: var(--surface-color);
}

.status-btn:hover:not(.active) {
    background: var(--background-color);
}

.status-center {
    flex: 1;
    text-align: center;
}

.status-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: calc(4px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: var(--text-secondary);
}

.status-close:hover {
    background: var(--danger-color);
    color: var(--surface-color);
}

/* Right Event Panel */
.event-panel {
    width: calc(300px * var(--ui-scale));
    background: var(--surface-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-medium);
    position: relative; /* anchor for toggle handle */
    z-index: 1300; /* keep above map content and bottom panel */
    flex: 0 0 auto;
    flex-basis: calc(300px * var(--ui-scale)); /* occupy scaled width in flex layout */
    transition: flex-basis var(--panel-transition-duration) var(--panel-ease), width var(--panel-transition-duration) var(--panel-ease), box-shadow 200ms ease;
    will-change: width, flex-basis;
    overflow: visible; /* allow collapsed toggle to sit over map */
    contain: layout style;
    backface-visibility: hidden;
}

.event-panel.collapsed {
    /* Release all space so map expands, keep only the toggle handle */
    width: 0;
    flex-basis: 0;
    background: transparent;
    border-left: none;
    box-shadow: none;
    pointer-events: none; /* map is fully interactive except toggle */
    overflow: visible; /* allow toggle handle to remain visible outside bounds */
}

/* Suppress content reflow during open/close animation */
.event-panel.animating .event-panel-content {
    overflow: hidden;
    pointer-events: none;
}

.event-panel-header {
    padding: calc(15px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.event-panel-header h3 {
    font-size: calc(14px * var(--ui-scale));
    color: var(--text-primary);
    margin: 0;
}

.panel-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: calc(4px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: var(--text-secondary);
}

.panel-toggle:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

/* Keep a visible handle when collapsed */
.event-panel.collapsed .event-panel-header h3 {
    display: none;
}

.event-panel.collapsed .panel-toggle {
    position: absolute;
    right: 0;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    width: calc(28px * var(--ui-scale));
    height: calc(28px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 4px 0 0 4px;
    box-shadow: var(--shadow-medium);
    pointer-events: auto;
}

.event-panel.collapsed .event-panel-header {
    background: transparent;
    border-bottom: none;
}

.event-panel.collapsed .event-panel-content {
    display: none;
}

.event-panel-content {
    flex: 1;
    overflow-y: auto;
}

.event-item {
    padding: calc(15px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    margin-bottom: calc(2px * var(--ui-scale));
    transition: var(--transition);
}

.event-item:hover {
    background: var(--surface-hover, rgba(0,0,0,0.04));
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(8px * var(--ui-scale));
}

.event-title {
    background: var(--danger-color);
    color: white;
    padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border-radius: 3px;
    font-size: calc(11px * var(--ui-scale));
    font-weight: 500;
}

.event-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: calc(16px * var(--ui-scale));
    padding: calc(2px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.event-close:hover {
    background: var(--danger-color);
    color: var(--surface-color);
}

.event-object {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: calc(4px * var(--ui-scale));
    font-size: calc(13px * var(--ui-scale));
}

.event-type,
.event-location,
.event-time {
    color: var(--text-secondary);
    font-size: calc(12px * var(--ui-scale));
    margin-bottom: calc(4px * var(--ui-scale));
}

.show-event-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: calc(12px * var(--ui-scale));
    text-decoration: underline;
    margin-top: calc(8px * var(--ui-scale));
    padding: calc(2px * var(--ui-scale)) 0;
    transition: var(--transition);
}

.show-event-btn:hover {
    color: #1976d2;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    padding: calc(8px * var(--ui-scale)) 0;
    font-size: calc(12px * var(--ui-scale));
    z-index: 2000;
    display: none;
    min-width: 180px;
}

.context-menu-item {
    padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: calc(10px * var(--ui-scale));
    color: var(--text-primary);
}

.context-menu-item:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.context-menu-item i {
    width: calc(14px * var(--ui-scale));
    text-align: center;
}

.context-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: calc(20px * var(--ui-scale));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

/* prevent selecting page text while dragging modals */
.no-select-drag {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: var(--text-secondary);
}

.modal-close:hover {
    background: var(--danger-color);
    color: var(--surface-color);
}

.modal-body {
    padding: calc(20px * var(--ui-scale));
    overflow-y: auto;
}

/* IO Mapping modal (match Object Properties design) */
.io-config-modal {
    width: 520px;
    max-width: 520px;
    min-width: 520px;
    max-height: 80vh;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    background: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.io-config-modal .modal-header {
    padding: 20px 24px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
}

.io-config-modal .modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.io-config-modal .modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.io-config-modal .modal-close:hover {
    background: #e2e8f0;
    color: #475569;
}

.io-config-modal .modal-body {
    padding: 20px 24px;
    overflow-y: auto;
}

.io-config-modal .io-config-desc {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 16px;
}

.io-config-modal .form-group {
    margin-bottom: 14px;
}

.io-config-modal .filter-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
}

.io-config-modal .text-input,
.io-config-modal select.text-input,
.io-config-modal input.text-input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    background: #f3f4f6;
    color: #1e293b;
    font-size: 14px;
}

.io-config-modal .text-input:focus,
.io-config-modal select.text-input:focus {
    outline: none;
    background: #e5e7eb;
}

.io-config-modal .modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.io-config-modal .filter-btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
}

.io-config-modal .filter-btn.primary {
    background: #0ea5e9;
    border: none;
    color: #ffffff;
}

.io-config-modal .filter-btn.primary:hover {
    background: #0284c7;
}

/* IO Mapping - calibration layout (TSX parity) */
.io-config-modal .cal-modal-panel {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
}

.io-config-modal .cal-modal-panel .cal-panel-body {
    border: none;
    background: transparent;
    padding: 0;
    max-height: none;
}

.io-config-modal .io-calibration-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.io-config-modal .io-calibration-desc {
    margin: 4px 0 10px;
    font-size: 12px;
    color: #64748b;
}

.io-config-modal .io-calibration-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #3d97e3;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 0 0 2px rgba(61, 151, 227, 0.25), 0 6px 16px rgba(61, 151, 227, 0.25);
}

.io-config-modal .io-calibration-name {
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    text-transform: lowercase;
}

.io-config-modal .io-calibration-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.io-config-modal .io-cal-btn {
    height: 26px;
    padding: 0 10px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.io-config-modal .io-cal-btn-edit {
    background: rgba(255, 255, 255, 0.9);
    color: #1e293b;
}

.io-config-modal .io-cal-btn-edit:hover {
    background: #ffffff;
}

.io-config-modal .io-cal-btn-delete {
    background: rgba(255, 255, 255, 0.85);
    color: #1e293b;
}

.io-config-modal .io-cal-btn-delete:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.io-config-modal .io-cal-btn-cancel {
    background: rgba(255, 255, 255, 0.85);
    color: #1e293b;
}

.io-config-modal .io-cal-btn-cancel:hover {
    background: #f1f5f9;
    color: #475569;
}

/* Inline calibration list buttons (Edit/Save Edit/Delete) */
.io-config-modal .inline-cal-edit,
.io-config-modal .inline-cal-delete {
    height: 26px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.io-config-modal .inline-cal-edit:hover {
    border-color: #0ea5e9;
    color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.io-config-modal .inline-cal-delete {
    border-color: #f1f5f9;
    color: #64748b;
}

.io-config-modal .inline-cal-delete:hover {
    border-color: #fecaca;
    color: #b91c1c;
    background: #fef2f2;
}

.io-config-modal .io-calibration-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.io-config-modal .io-calibration-controls label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.io-config-modal #modal-inline-cal-method {
    height: 36px;
    min-width: 140px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    font-size: 13px;
    color: #1e293b;
}

.io-config-modal #modal-inline-cal-formula {
    height: 40px;
    min-width: 200px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f3f4f6;
    color: #0f172a;
    font-size: 13px;
    display: none;
}

.io-config-modal #modal-inline-cal-formula:focus {
    outline: none;
    border-color: #0ea5e9;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.io-config-modal .io-calibration-list {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

/* Hide duplicate inline calibration row in modal (keep top bar) */
.io-config-modal #modal-cal-list {
    display: none;
}

.io-config-modal .io-calibration-table {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    height: 220px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    background: #ffffff;
}

.io-config-modal .io-calibration-table-head {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 16px;
    padding: 12px 16px;
    background: #ffffff;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 1;
}

.io-config-modal .io-calibration-table-body {
    padding: 0;
}

.io-config-modal .io-calibration-table-body .inline-row {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 16px;
    padding: 10px 16px;
    margin: 0;
    border-bottom: 1px solid #f8fafc;
    background: #ffffff;
    transition: background 0.15s ease;
}

.io-config-modal .io-calibration-table-body .inline-row:last-child {
    border-bottom: none;
}

.io-config-modal .io-calibration-table-body .inline-row:hover {
    background: #fafbfc;
}

.io-config-modal .io-calibration-table-body .inline-row input.row-x,
.io-config-modal .io-calibration-table-body .inline-row input.row-y {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    font-size: 14px;
    color: #374151;
    text-align: left;
}

.io-config-modal .io-calibration-table-body .inline-row input.row-x:focus,
.io-config-modal .io-calibration-table-body .inline-row input.row-y:focus {
    outline: none;
    background: #f0f9ff;
}

.io-config-modal .io-calibration-table-body .inline-row input.row-x:disabled,
.io-config-modal .io-calibration-table-body .inline-row input.row-y:disabled {
    color: #6b7280;
    cursor: default;
    background: transparent;
}

.io-config-modal .io-calibration-table-body .inline-row input::placeholder {
    color: #d1d5db;
}

.io-config-modal .io-calibration-table-body .inline-row .cal-remove-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    align-self: center;
}

.io-config-modal .io-calibration-table-body .inline-row .cal-remove-btn:hover {
    border-color: #fecaca;
    color: #b91c1c;
    background: #fef2f2;
}

.io-config-modal .io-calibration-table-body .inline-row .cal-remove-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.io-config-modal .io-calibration-actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.io-config-modal .io-calibration-actions-row .filter-btn {
    height: 36px;
    padding: 0 16px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #374151;
    font-weight: 500;
    transition: all 0.15s ease;
}

.io-config-modal .io-calibration-actions-row .filter-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Disabled state for calibration actions row */
.io-config-modal .io-calibration-actions-row.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.io-config-modal .io-calibration-actions-row.is-disabled .filter-btn {
    background: #f5f5f5;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

.io-config-modal .io-calibration-points {
    margin-top: 0;
}

/* Empty state inside modal calibration table */
.io-config-modal .io-calibration-points .no-io-data,
.io-config-modal .io-calibration-table-body .no-io-data {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
}

.io-config-modal .io-calibration-table-body .no-cal-data {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
}

/* IO Dictionary panel (mirrors calibration panel style) */
.io-config-modal .dict-modal-panel {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
}

.io-config-modal .io-dict-header h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.io-config-modal .io-dict-desc {
    margin: 4px 0 10px;
    font-size: 12px;
    color: #64748b;
}

.io-config-modal .io-dict-table {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    height: 220px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    background: #ffffff;
}

.io-config-modal .io-dict-table-head {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 16px;
    padding: 12px 16px;
    background: #ffffff;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 1;
}

.io-config-modal .io-dict-table-body {
    padding: 0;
}

.io-config-modal .io-dict-table-body .dict-row {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 16px;
    padding: 10px 16px;
    margin: 0;
    border-bottom: 1px solid #f8fafc;
    background: #ffffff;
    transition: background 0.15s ease;
}

.io-config-modal .io-dict-table-body .dict-row:last-child {
    border-bottom: none;
}

.io-config-modal .io-dict-table-body .dict-row:hover {
    background: #fafbfc;
}

.io-config-modal .io-dict-table-body .dict-row input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    font-size: 14px;
    color: #374151;
    text-align: left;
}

.io-config-modal .io-dict-table-body .dict-row input:focus {
    outline: none;
    background: #f0f9ff;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.io-config-modal .io-dict-table-body .dict-row .dict-remove-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #ffffff;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    align-self: center;
}

.io-config-modal .io-dict-table-body .dict-row .dict-remove-btn:hover {
    border-color: #fecaca;
    color: #b91c1c;
    background: #fef2f2;
}

.io-config-modal .io-dict-table-body .no-dict-data {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
}

.io-config-modal .io-dict-actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.io-config-modal .io-dict-actions-row .filter-btn {
    height: 36px;
    padding: 0 16px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #374151;
    font-weight: 500;
    transition: all 0.15s ease;
}

.io-config-modal .io-dict-actions-row .filter-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Disabled state for dictionary panel (non-custom, non-ignition types) */
.io-config-modal .dict-modal-panel.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.io-config-modal .dict-modal-panel.is-disabled .io-dict-table::after {
    content: 'Dictionary is only available for Custom and Ignition type sensors';
    display: block;
    padding: 6px 16px 10px;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    font-style: italic;
}

/* Disabled state for calibration panel (ignition type uses dictionary instead) */
.io-config-modal .cal-modal-panel.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.io-config-modal .cal-modal-panel.is-disabled .cal-panel-body::after {
    content: 'Calibration is not available for Ignition type sensors. Use the Dictionary section below.';
    display: block;
    padding: 6px 16px 10px;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    font-style: italic;
}

.io-config-modal .sensor-settings-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.io-config-modal .sensor-settings-section h5 {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.io-config-modal .sensor-settings-section p {
    margin: 0 0 8px;
    font-size: 12px;
    color: #64748b;
}

.io-config-modal .sensor-settings-btn {
    width: 100%;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #1397d2;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.io-config-modal .sensor-settings-btn:hover {
    background: #1aa9e8;
    box-shadow: 0 0 20px rgba(19, 151, 210, 0.35);
}

.io-config-modal .sensor-settings-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.io-config-modal .sensor-settings-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #94a3b8;
    font-style: italic;
}

/* Toast Notifications */

/* Centralized calibration panel inside IO Mapping modal */
.cal-modal-panel .cal-panel-body,
.io-cal-panel .cal-panel-body {
    width: 100%;
    max-height: 60vh;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

.cal-list .inline-cal-item,
.io-cal-panel .cal-list .inline-cal-item,
#modal-cal-list .inline-cal-item {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.inline-row input.row-x,
.inline-row input.row-y {
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.filter-btn.small {
    padding: 6px 8px;
    font-size: 12px;
}

/* ── Event Overlay Toggle Bar ──────────────────────────── */
.event-overlay-bar {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.evt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--surface-color);
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1;
    position: relative;
    user-select: none;
}

.evt-toggle i {
    font-size: 10px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.evt-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(33, 150, 243, 0.06);
}

.evt-toggle:hover i { opacity: 1; }

.evt-toggle.active {
    border-color: var(--active-color, var(--primary-color));
    background: var(--active-bg, rgba(33, 150, 243, 0.12));
    color: var(--active-color, var(--primary-color));
}

.evt-toggle.active i { opacity: 1; }

/* Per-event accent colors */
.evt-toggle[data-event="fuel_fill"] { --active-color: #2ed573; --active-bg: rgba(46,213,115,0.12); --active-color-light: #1a8a44; --active-bg-light: rgba(31,168,85,0.14); }
.evt-toggle[data-event="fuel_theft"] { --active-color: #ff6b6b; --active-bg: rgba(255,107,107,0.12); --active-color-light: #c0392b; --active-bg-light: rgba(217,68,68,0.14); }
.evt-toggle[data-event="parkings"]  { --active-color: #a29bfe; --active-bg: rgba(162,155,254,0.12); --active-color-light: #6c5ce7; --active-bg-light: rgba(108,92,231,0.14); }
.evt-toggle[data-event="overspeed"] { --active-color: #feca57; --active-bg: rgba(254,202,87,0.12); --active-color-light: #b8860b; --active-bg-light: rgba(184,134,11,0.14); }

.evt-badge {
    display: none;
    min-width: 16px;
    height: 14px;
    padding: 0 4px;
    border-radius: 7px;
    background: var(--active-color, var(--text-secondary));
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

.evt-toggle.has-data .evt-badge { display: inline-block; }

.evt-label { letter-spacing: 0.01em; }

/* ── Fuel fill map marker ──────────────────────────────── */
.fuel-fill-marker {
    background: transparent;
    border: none;
}

.fuel-fill-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 20px;
    color: #2ed573;
    filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.3));
    cursor: pointer;
    transition: all 0.2s ease;
}

.fuel-fill-icon:hover { transform: scale(1.15); }

/* Unified fuel event label (qty + duration) under map icon */
.fuel-event-label {
    position: absolute;
    top: 24px;
    background: rgba(30, 35, 45, 0.90);
    color: #2ed573;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(46,213,115,0.3);
    white-space: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    line-height: 1.15;
    letter-spacing: 0.01em;
    pointer-events: none;
}

.fuel-theft-icon .fuel-event-label {
    color: #ff6b6b;
    border-color: rgba(255,107,107,0.3);
}

/* ── Fuel theft map marker ─────────────────────────────── */
.fuel-theft-marker {
    background: transparent;
    border: none;
}

.fuel-theft-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 20px;
    color: #ff6b6b;
    filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.3));
    cursor: pointer;
    transition: all 0.2s ease;
}

.fuel-theft-icon:hover { transform: scale(1.15); }

/* ── Fuel fill/theft popup ─────────────────────────────── */
.fuel-event-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: rgba(30, 35, 45, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px 14px;
    color: #e8edf2;
    min-width: 200px;
}

.fuel-event-popup .fep-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    font-size: 13px;
}

.fuel-event-popup .fep-icon {
    width: 28px; height: 28px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; flex-shrink: 0;
}

.fuel-event-popup .fep-icon.fill  { background: rgba(46,213,115,0.18); color: #2ed573; }
.fuel-event-popup .fep-icon.theft { background: rgba(255,107,107,0.18); color: #ff6b6b; }

.fuel-event-popup .fep-row {
    display: flex; gap: 6px; align-items: center;
    font-size: 11.5px; padding: 3px 0; color: #b0bec5;
}

.fuel-event-popup .fep-row i { width: 14px; text-align: center; font-size: 10px; opacity: 0.7; }
.fuel-event-popup .fep-row-value { margin-left: auto; color: #e8edf2; font-weight: 500; }

/* ── Places popup (marker/route/zone) ─────────────────── */
.place-popup-shell .leaflet-popup-content-wrapper {
    background: rgba(20, 25, 35, 0.90);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.place-popup-shell .leaflet-popup-tip {
    background: rgba(20, 25, 35, 0.90);
}

.place-popup-shell .leaflet-popup-content {
    margin: 0;
}

.place-popup-card {
    min-width: 220px;
    max-width: 290px;
    color: #e8edf2;
    padding: 12px 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.place-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.place-popup-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.place-popup-title-wrap {
    min-width: 0;
}

.place-popup-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-popup-type {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(180, 198, 220, 0.88);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.place-popup-description {
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
    line-height: 1.45;
    color: rgba(220, 228, 238, 0.95);
    white-space: pre-wrap;
    word-break: break-word;
}

.place-popup-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    color: rgba(185, 200, 220, 0.92);
}

.place-popup-row i {
    width: 13px;
    text-align: center;
    font-size: 10px;
    opacity: 0.8;
}

.place-popup-row-value {
    margin-left: auto;
    color: #f4f7fb;
    font-weight: 600;
}

/* Temporary label shown when clicking eye icon */
.place-focus-popup-shell .leaflet-popup-content-wrapper {
    background: rgba(20, 25, 35, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.place-focus-popup-shell .leaflet-popup-tip {
    background: rgba(20, 25, 35, 0.86);
}

.place-focus-popup-shell .leaflet-popup-content {
    margin: 0;
}

.place-focus-popup {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    color: #f4f8ff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1;
}

.place-focus-popup-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(173, 196, 222, 0.92);
    letter-spacing: 0.35px;
}

.place-focus-popup-name {
    font-size: 12.5px;
    font-weight: 700;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Light-mode: fuel event markers ────────────────────── */
body.theme-light .fuel-fill-icon {
    color: #1fa855;
    filter: drop-shadow(1px 2px 4px rgba(0,0,0,0.18));
}
body.theme-light .fuel-theft-icon {
    color: #d94444;
    filter: drop-shadow(1px 2px 4px rgba(0,0,0,0.18));
}
body.theme-light .fuel-event-label {
    background: rgba(255, 255, 255, 0.94);
    color: #1a8a44;
    border-color: rgba(31, 168, 85, 0.25);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
body.theme-light .fuel-theft-icon .fuel-event-label {
    color: #c0392b;
    border-color: rgba(217, 68, 68, 0.25);
}

/* ── Light-mode: fuel event popup ──────────────────────── */
body.theme-light .fuel-event-popup {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(0, 0, 0, 0.08);
    color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}
body.theme-light .fuel-event-popup .fep-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
    color: #1a1a1a;
}
body.theme-light .fuel-event-popup .fep-row {
    color: #6b7785;
}
body.theme-light .fuel-event-popup .fep-row-value {
    color: #2c3e50;
}
body.theme-light .fuel-event-popup .fep-icon.fill {
    background: rgba(31, 168, 85, 0.12);
    color: #1a8a44;
}
body.theme-light .fuel-event-popup .fep-icon.theft {
    background: rgba(217, 68, 68, 0.12);
    color: #c0392b;
}

body.theme-light .place-popup-shell .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

body.theme-light .place-popup-shell .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.96);
}

body.theme-light .place-popup-card {
    color: #1f2a36;
}

body.theme-light .place-popup-type {
    color: #6f7f90;
}

body.theme-light .place-popup-description {
    border-top-color: rgba(0, 0, 0, 0.08);
    color: #445566;
}

body.theme-light .place-popup-row {
    color: #5f7082;
}

body.theme-light .place-popup-row-value {
    color: #1b2733;
}

body.theme-light .place-focus-popup-shell .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

body.theme-light .place-focus-popup-shell .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.96);
}

body.theme-light .place-focus-popup {
    color: #18232f;
}

body.theme-light .place-focus-popup-type {
    color: #6b7f95;
}

/* ── Light-mode: toggle buttons ────────────────────────── */
body.theme-light .evt-toggle {
    border-color: rgba(0, 0, 0, 0.12);
    background: #f5f5f5;
    color: #555;
}
body.theme-light .evt-toggle:hover {
    border-color: var(--active-color-light, var(--primary-color));
    color: var(--active-color-light, var(--primary-color));
}
body.theme-light .evt-toggle.active {
    border-color: var(--active-color-light, var(--active-color));
    background: var(--active-bg-light, var(--active-bg, rgba(33,150,243,0.12)));
    color: var(--active-color-light, var(--active-color));
}
body.theme-light .evt-badge {
    color: #fff;
}

.toast-container {
    position: fixed;
    top: calc(70px * var(--ui-scale));
    right: calc(20px * var(--ui-scale));
    z-index: 4000;
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--ui-scale));
}

.toast {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    padding: 12px 16px;
    min-width: 250px;
    max-width: 350px;
    transform: translateX(100%);
    animation: slideIn 0.3s ease forwards;
    position: relative;
}

.toast.success {
    border-left: 4px solid var(--secondary-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--accent-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

@keyframes slideIn {
    to {
        transform: translateX(0);
    }
}

.toast-close {
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Scrollbar Styling */
.object-list::-webkit-scrollbar,
.history-content::-webkit-scrollbar,
.event-panel-content::-webkit-scrollbar,
.events-list::-webkit-scrollbar,
.places-list::-webkit-scrollbar {
    width: 6px;
}

.object-list::-webkit-scrollbar-track,
.history-content::-webkit-scrollbar-track,
.event-panel-content::-webkit-scrollbar-track,
.events-list::-webkit-scrollbar-track,
.places-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track, #f1f1f1);
}

.object-list::-webkit-scrollbar-thumb,
.history-content::-webkit-scrollbar-thumb,
.event-panel-content::-webkit-scrollbar-thumb,
.events-list::-webkit-scrollbar-thumb,
.places-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb, #c1c1c1);
    border-radius: 3px;
}

.object-list::-webkit-scrollbar-thumb:hover,
.history-content::-webkit-scrollbar-thumb:hover,
.event-panel-content::-webkit-scrollbar-thumb:hover,
.events-list::-webkit-scrollbar-thumb:hover,
.places-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover, #a1a1a1);
}

/* Vehicle Status Indicators */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
    flex-shrink: 0;
    /* Smooth color transition to prevent visual jumps on status change */
    transition: background-color 0.3s ease;
    /* Only pulse for online/moving status - applied via specific classes */
}

.status-indicator.online {
    background: var(--secondary-color); /* green */
    animation: pulseGreen 2.4s ease-in-out infinite;
}

.status-indicator.offline {
    background: #bbb; /* gray */
    animation: none;
}

.status-indicator.idle {
    background: var(--accent-color); /* orange */
    animation: none;
}

.status-indicator.moving {
    background: var(--primary-color); /* blue */
    animation: pulseBlue 2.4s ease-in-out infinite;
}

@keyframes pulseGreen {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.45);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 6px 3px rgba(76, 175, 80, 0.25);
        opacity: 0.85;
    }
}

@keyframes pulseBlue {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(30, 110, 255, 0.45);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 6px 3px rgba(30, 110, 255, 0.25);
        opacity: 0.85;
    }
}

/* Prevent action button flicker - keep visible when interacting */
.object-item:focus-within .object-actions,
.object-item:active .object-actions {
    opacity: 1;
}

/* Map Marker Styles */
.custom-marker {
    width: 12px;
    height: 12px;
    background: var(--secondary-color);
    border: 2px solid var(--surface-color);
    border-radius: 50%;
    box-shadow: var(--shadow-medium);
    cursor: pointer;
    transition: var(--transition);
}

.custom-marker:hover {
    transform: scale(1.2);
}

.custom-marker.selected {
    background: var(--danger-color);
    transform: scale(1.3);
}

/* Stop Marker Styles */
.stop-marker {
    background: transparent;
    border: none;
}

.stop-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 16px;
    color: #e74c3c;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.3));
    cursor: pointer;
    transition: color 0.2s ease;
}

.stop-icon:hover {
    color: #c0392b;
}

.stop-duration {
    position: absolute;
    top: 18px;
    background: rgba(30, 35, 45, 0.9);
    color: #f0f0f0;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Stop cluster marker */
.stop-cluster-marker {
    background: transparent;
    border: none;
}
.stop-cluster-icon {
    width: 28px;
    height: 28px;
    background: rgba(231, 76, 60, 0.85);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    border: 2px solid rgba(255,255,255,0.3);
}

/* ── Stop Popup (glassmorphism, dark-mode first) ──────── */
.stop-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: rgba(30, 35, 45, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 16px 18px;
    color: #e8edf2;
    min-width: 240px;
}

.stop-popup .sp-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stop-popup .sp-header .sp-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(231, 76, 60, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e74c3c;
    font-size: 14px;
    flex-shrink: 0;
}

.stop-popup .sp-header .sp-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

.stop-popup .sp-header .sp-duration-badge {
    margin-left: auto;
    margin-right: 18px;
    background: rgba(231, 76, 60, 0.15);
    color: #ff6b6b;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.stop-popup .sp-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
}

.stop-popup .sp-row .sp-row-icon {
    width: 16px;
    text-align: center;
    color: #5c7080;
    font-size: 11px;
    margin-top: 2px;
    flex-shrink: 0;
}

.stop-popup .sp-row .sp-row-label {
    font-size: 11px;
    color: #8899a6;
    min-width: 50px;
    flex-shrink: 0;
}

.stop-popup .sp-row .sp-row-value {
    font-size: 12px;
    color: #e8edf2;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Light-mode overrides for stop popup */
body.theme-light .stop-popup {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.08);
    color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

body.theme-light .stop-popup .sp-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .stop-popup .sp-header .sp-title {
    color: #1a1a1a;
}

body.theme-light .stop-popup .sp-row .sp-row-label {
    color: #888;
}

body.theme-light .stop-popup .sp-row .sp-row-value {
    color: #333;
}

body.theme-light .stop-duration {
    background: rgba(255, 255, 255, 0.92);
    color: #333;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Stop popup leaflet wrapper overrides */
.stop-popup-wrapper .leaflet-popup-content {
    min-width: 240px;
}

.stop-popup-wrapper .leaflet-popup-close-button {
    top: 14px !important;
    right: 14px !important;
}

body.theme-light .stop-popup-wrapper .leaflet-popup-close-button {
    color: rgba(0, 0, 0, 0.35) !important;
}

body.theme-light .stop-popup-wrapper .leaflet-popup-close-button:hover {
    color: rgba(0, 0, 0, 0.7) !important;
}

/* ── Position & Route Popups (modern glassmorphism, dark-mode first) ── */
.position-popup,
.route-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: rgba(30, 35, 45, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 0;
    color: #e8edf2;
    min-width: 230px;
    overflow: hidden;
}

/* Header */
.pp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pp-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.pp-icon-position {
    background: rgba(33, 150, 243, 0.18);
    color: #42a5f5;
}

.pp-icon-start {
    background: rgba(76, 175, 80, 0.18);
    color: #66bb6a;
}

.pp-icon-end {
    background: rgba(244, 67, 54, 0.18);
    color: #ef5350;
}

.pp-header-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.pp-title {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
}

.pp-subtitle {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Body rows */
.pp-body {
    padding: 10px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.pp-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pp-row-icon {
    width: 16px;
    text-align: center;
    color: #5c7080;
    font-size: 11px;
    flex-shrink: 0;
}

.pp-row-label {
    font-size: 11px;
    color: #8899a6;
    min-width: 48px;
    flex-shrink: 0;
}

.pp-row-value {
    font-size: 12px;
    color: #e8edf2;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

/* ── Light-mode overrides ── */
body.theme-light .position-popup,
body.theme-light .route-popup {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(0, 0, 0, 0.08);
    color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

body.theme-light .pp-header {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.theme-light .pp-title {
    color: #1a1a2e;
}

body.theme-light .pp-subtitle {
    color: rgba(0, 0, 0, 0.4);
}

body.theme-light .pp-row-label {
    color: #6b7785;
}

body.theme-light .pp-row-value {
    color: #2c3e50;
}

body.theme-light .pp-row-icon {
    color: #90a0b0;
}

body.theme-light .pp-icon-position {
    background: rgba(33, 150, 243, 0.12);
    color: #1e88e5;
}

body.theme-light .pp-icon-start {
    background: rgba(76, 175, 80, 0.12);
    color: #43a047;
}

body.theme-light .pp-icon-end {
    background: rgba(244, 67, 54, 0.12);
    color: #e53935;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.loading {
    pointer-events: none;
    opacity: 0.6;
}

.text-center {
    text-align: center;
}

.text-primary {
    color: var(--primary-color);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-success {
    color: var(--secondary-color);
}

.text-warning {
    color: var(--accent-color);
}

.text-danger {
    color: var(--danger-color);
}

.bg-primary {
    background-color: var(--primary-color);
}

.bg-secondary {
    background-color: var(--secondary-color);
}

.bg-warning {
    background-color: var(--accent-color);
}

.bg-danger {
    background-color: var(--danger-color);
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Status Drawer */
.status-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 44px; /* sits just above the status bar */
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -6px 18px rgba(0,0,0,0.12);
    max-height: 60vh;
    transform: translateY(100%);
    transition: transform var(--panel-transition-duration) var(--panel-ease);
    z-index: 1199; /* just under status bar which is 1200 */
    display: flex;
    flex-direction: column;
}

.status-drawer.open {
    transform: translateY(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
}

.drawer-title { font-weight: 600; color: var(--text-primary); }

.drawer-actions .drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
}

.drawer-actions .drawer-close:hover {
    background: var(--background-color);
}

.drawer-body {
    position: relative;
    display: flex;
    flex: 1;
}

.drawer-view { 
    display: none; 
    width: 100%; 
    height: 100%; 
    overflow: auto;
    padding: 8px;
}
.drawer-view.active { display: flex; flex-direction: column; }

/* Detailed Data View Styles */
.detailed-data-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow-light);
    border-left: 4px solid var(--primary-color);
}

.detailed-data-info h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.detailed-data-info h4 i {
    color: var(--primary-color);
}

.detailed-data-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

.detailed-data-actions {
    display: flex;
    gap: 8px;
}

.detailed-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.detailed-btn:hover {
    background: #1976d2;
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.detailed-btn i {
    font-size: 12px;
}

.detailed-data-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.signal-group {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.signal-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid var(--border-color);
}

.signal-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.signal-group-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.signal-list {
    padding: 0;
    margin: 0;
}

.signal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.signal-item:last-child {
    border-bottom: none;
}

.signal-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.signal-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.signal-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.signal-type {
    background: #e3f2fd;
    color: #1976d2;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.signal-value {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.signal-current {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.signal-unit {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.signal-timestamp {
    font-size: 10px;
    color: var(--text-muted);
}

/* Status indicators for signal values */
.signal-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
}

.signal-status.online {
    background: var(--secondary-color);
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.4);
}

.signal-status.warning {
    background: var(--accent-color);
    box-shadow: 0 0 4px rgba(255, 152, 0, 0.4);
}

.signal-status.error {
    background: var(--danger-color);
    box-shadow: 0 0 4px rgba(244, 67, 54, 0.4);
}

/* Data Table Styles */
.data-table-container {
    padding: 16px;
    height: 100%;
    overflow-y: auto;
}

.data-table-header {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.data-table-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.data-table-header h4 i {
    color: var(--primary-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover:not(.data-separator) {
    background-color: #f8f9fa;
}

.data-row td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.data-row:last-child td {
    border-bottom: none;
}

.data-key {
    font-weight: 500;
    color: var(--text-primary);
    background-color: #fafafa;
    width: 40%;
    min-width: 120px;
    font-size: 14px;
}

.data-value {
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    word-break: break-all;
}

/* Vehicle info rows */
.vehicle-info .data-key {
    background-color: #e3f2fd;
    color: var(--primary-color);
    font-weight: 600;
}

.vehicle-info .data-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* IO data rows */
.io-data .data-key {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.io-data .data-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Separator row */
.data-separator td {
    padding: 16px;
    text-align: center;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}

.data-separator .separator-line {
    display: inline-block;
    width: 40px;
    height: 1px;
    background-color: var(--border-color);
    vertical-align: middle;
}

.separator-text {
    margin: 0 12px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* No IO data row */
.no-io-data .no-data-cell {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-style: italic;
}

.no-data-cell i {
    margin-right: 8px;
    color: var(--accent-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .data-table-container {
        padding: 12px;
    }
    
    .data-key,
    .data-value {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .data-key {
        width: 45%;
        min-width: 100px;
    }
}

/* Graph */
.graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
}

.graph-metrics {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.graph-metrics label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface-color);
}

.graph-select {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    font-size: 12px;
}

.graph-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
}

.graph-legend { font-size: 12px; color: var(--text-secondary); }

/* Compare tool — removed */
.graph-actions { display:none; }
.graph-btn { display:none; }
.graph-btn.active { display:none; }
.graph-compare-popup { display:none !important; }

/* IO Configuration Styles */
.vehicle-info {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.vehicle-info h4 {
    margin: 0 0 5px 0;
    color: var(--text-primary);
    font-size: 16px;
}

.vehicle-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.io-configuration {
    margin-top: 20px;
}

.io-configuration h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 16px;
}

.io-description {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.available-ios, .configured-ios {
    margin-bottom: 20px;
}

.available-ios h5, .configured-ios h5 {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.io-list, .io-mappings {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface-color);
}

/* Keep inline calibration panel visually stable when rows are hidden */
.io-cal-panel .cal-panel-body {
    /* Fixed width, flexible height */
    width: 498px;
    min-width: 498px;
    max-width: 498px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* allow vertical growth but constrain to viewport */
    max-height: 70vh;
    overflow: hidden; /* inner areas will scroll instead */
}
.io-cal-panel .cal-list {
    max-height: 90px;
    overflow-y: auto;
}
.io-cal-panel .cal-add-row {
    min-height: 48px; /* reserve space for Add row + controls */
}

/* When rows area contains many rows allow its own scrolling */
.io-cal-panel [id^="inline-cal-rows-"] {
    overflow-y: auto;
    max-height: 160px;
}

.io-cal-panel .cal-add-row > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.io-cal-panel .cal-add-row .filter-btn {
    min-width: 120px;
}

.io-cal-panel .cal-add-controls {
    margin-top: 6px;
    display: flex;
    gap: 8px;
}
.io-cal-panel .cal-add-controls .filter-btn {
    min-width: 120px;
}

.io-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.io-item:last-child {
    border-bottom: none;
}

.io-item:hover {
    background: var(--background-color);
}

/* Inline calibration rows and items (small UX polish) */
.inline-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
}
.inline-row .row-x,
.inline-row .row-y {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    width: 120px;
}
.filter-btn.small {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 4px;
}
.filter-btn.small.danger {
    background: var(--danger-color);
    color: white;
}

.inline-cal-item {
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    margin-bottom: 4px;
    color: var(--text-secondary);
}
.inline-cal-item:hover {
    background: rgba(33,150,243,0.04);
    color: var(--text-primary);
}
.inline-cal-item.selected {
    font-weight: 700;
    background: #e8f4ff;
    border-left: 3px solid var(--primary-color);
    color: var(--text-primary);
}

.inline-cal-item { display: flex; align-items: center; justify-content: space-between; }
.inline-cal-label { flex: 1; }
.inline-cal-delete {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.inline-cal-delete:hover { opacity: 0.9; }

.inline-cal-edit{
background:var(--primary-color);
color:#fff;
border:none;
padding:6px 8px;
border-radius:4px;
cursor:pointer;
font-size:12px
}
.inline-cal-edit:hover{
opacity:.9
}

.io-info {
    flex: 1;
}

.io-key {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 13px;
}

.io-value {
    color: var(--text-secondary);
    margin-top: 2px;
    font-size: 11px;
}

.io-actions {
    display: flex;
    gap: 5px;
}

.io-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.io-btn.config {
    background: var(--primary-color);
    color: white;
}

.io-btn.config:hover {
    background: #1976d2;
}

.io-btn.delete {
    background: var(--danger-color);
    color: white;
}

.io-btn.delete:hover {
    background: #c62828;
}

.io-mapping {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.io-mapping:last-child {
    border-bottom: none;
}

.io-mapping:hover {
    background: var(--background-color);
}

.mapping-info {
    flex: 1;
}

.mapping-name {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 13px;
}

.mapping-details {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.3;
}

.mapping-type {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    margin-right: 5px;
    letter-spacing: 0.5px;
}

.mapping-type.fuel { background: #e3f2fd; color: #1976d2; }
.mapping-type.ignition { background: #fff3e0; color: #f57c00; }
.mapping-type.temperature { background: #ffebee; color: #d32f2f; }
.mapping-type.voltage { background: #e8f5e8; color: #388e3c; }
.mapping-type.door { background: #f3e5f5; color: #7b1fa2; }
.mapping-type.odometer { background: #fff8e1; color: #f57f17; }
.mapping-type.custom { background: #f5f5f5; color: #666; }

.loading-message {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.no-io-data {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.no-io-data i {
    font-size: 24px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Formula field styling */
#modal-inline-cal-formula {
    height: 40px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background-color: #f3f4f6;
    color: #1e293b;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    font-weight: 500;
    min-width: 200px;
}

#modal-inline-cal-formula:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.7;
}

#modal-inline-cal-formula:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

#modal-inline-cal-method:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
    cursor: not-allowed;
    opacity: 0.7;
}

#modal-inline-cal-formula::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Calibration item styling */
.inline-cal-item {
    padding: 8px 12px;
    margin: 4px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
}

.inline-cal-item:hover {
    background-color: #f8f9fa;
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.inline-cal-item.selected {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

.inline-cal-label {
    font-weight: 500;
    flex: 1;
    color: inherit;
}

.inline-cal-delete,
.inline-cal-edit {
    padding: 4px 8px;
    margin-left: 6px;
    font-size: 12px;
    border: 1px solid #ccc;
    background-color: #f8f9fa;
    color: #333;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    font-weight: 500;
}

.inline-cal-delete:hover {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

.inline-cal-edit:hover {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.inline-cal-item.selected .inline-cal-delete,
.inline-cal-item.selected .inline-cal-edit {
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    border-color: rgba(255, 255, 255, 0.5);
}

.inline-cal-item.selected .inline-cal-delete:hover {
    background-color: #dc3545;
    color: white;
}

.inline-cal-item.selected .inline-cal-edit:hover {
    background-color: #007bff;
    color: white;
}

.inline-cal-cancel-edit {
    padding: 4px 8px;
    margin-left: 4px;
    font-size: 12px;
    border: 1px solid #ccc;
    background-color: #f8f9fa;
    color: #333;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    font-weight: 500;
}

.inline-cal-cancel-edit:hover {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
}

.inline-cal-item.selected .inline-cal-cancel-edit {
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    border-color: rgba(255, 255, 255, 0.5);
}

.inline-cal-item.selected .inline-cal-cancel-edit:hover {
    background-color: #6c757d;
    color: white;
}

/* IO Table Wrapper - Fixed rows, horizontal scroll */
.io-table-wrapper {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid #eee;
    border-radius: 4px;
    max-height: none;
}

.io-table {
    width: auto;
    min-width: 100%;
    font-size: 12px;
    border-collapse: collapse;
    table-layout: fixed;
}

.io-table thead th {
    position: sticky;
    top: 0;
    background: #fafafa;
    z-index: 2;
    text-align: left;
    padding: 4px 8px;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
}

.io-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 120px;
    border-right: 1px solid #ddd;
}

.io-table tbody td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.io-table tbody td:first-child {
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
    border-right: 1px solid #ddd;
    font-weight: 500;
}

.io-table tbody tr:hover {
    background-color: #f8f9fa;
}

.io-table tbody tr:hover td:first-child {
    background-color: #f8f9fa;
}

/* Scrollbar styling for IO table */
.io-table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.io-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.io-table-wrapper::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.io-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Data List Items - ITL GPS Style */
.datalist-item-list {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    background: #fff;
    border-radius: 4px;
}

.datalist-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    min-height: 40px;
}

.datalist-item:last-child {
    border-bottom: none;
}

.datalist-item.even {
    background-color: #fafafa;
}

.datalist-item.odd {
    background-color: #ffffff;
}

.datalist-item:hover {
    background-color: #f0f8ff;
}

.datalist-item-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 14px;
}

.datalist-item-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    margin-right: 12px;
    min-width: 0;
    word-wrap: break-word;
}

.datalist-item-value {
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    text-align: right;
    flex-shrink: 0;
    max-width: 150px;
    word-wrap: break-word;
}

/* Icon classes for different IO types */
.icon-default-sensor::before { content: "⚡"; }
.icon-warning::before { content: "⚠️"; }
.icon-fuel::before { content: "⛽"; }
.icon-temperature::before { content: "🌡️"; }
.icon-voltage::before { content: "🔋"; }
.icon-engine::before { content: "🔧"; }
.icon-gps::before { content: "📍"; }
.icon-gsm::before { content: "📶"; }

/* Scrollbar for datalist */
.datalist-item-list::-webkit-scrollbar {
    width: 8px;
}

.datalist-item-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.datalist-item-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.datalist-item-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Fuel Sensor Settings Modal Styles */
.settings-section {
    margin: 16px 0;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fafafa;
}

.settings-section h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.text-readonly {
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Toggle Switch Styles */
.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    gap: 10px;
    position: relative;
}

.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
    min-width: 38px;
    background: #ccc;
    border-radius: 20px;
    transition: var(--transition);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-label input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

.toggle-label:hover .toggle-slider {
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* Settings button for fuel sensors */
.sensor-settings-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    margin-left: 8px;
}

.sensor-settings-btn:hover {
    background: #1976d2;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.sensor-settings-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Error message styling */
.error-message {
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: var(--border-radius);
    padding: 10px;
    margin: 10px 0;
    color: #c62828;
    font-size: 14px;
}

/* Sensor badge for showing current settings */
.sensor-badge {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 5px;
    font-weight: 500;
}

.sensor-badge.enabled {
    background: var(--secondary-color);
}

.sensor-badge.disabled {
    background: #999;
}

/* =============================================
   Vehicle Popup - Glassmorphism Dark Mode Style
   ============================================= */

/* Override Leaflet popup default styles */
.leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    min-width: 220px;
}

.leaflet-popup-tip-container {
    display: none !important;
}

.leaflet-popup-close-button {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 17px !important;
    font-weight: 300 !important;
    top: 8px !important;
    right: 8px !important;
    width: 20px !important;
    height: 20px !important;
    z-index: 10;
    transition: color 0.2s ease;
}

.leaflet-popup-close-button:hover {
    color: #ffffff !important;
}

/* Main Glassmorphism Card Container */
.vehicle-popup-glass {
    background: rgba(24, 28, 36, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    padding: 14px 16px;
    min-width: 230px;
    max-width: 290px;
    box-shadow: 
        0 6px 24px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    color: #ffffff;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Header Section */
.popup-glass-header {
    margin-bottom: 12px;
}

.popup-glass-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 4px 0;
    letter-spacing: 0.2px;
    padding-right: 16px;
}

.popup-glass-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-glow-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    animation: statusPulse 2.4s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.status-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 400;
}

/* Data Grid - 2x2 Layout */
.popup-glass-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.popup-glass-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
}

.popup-glass-icon {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 1px;
    width: 14px;
    text-align: center;
}

.popup-glass-icon.critical {
    color: #ff4444;
}

.popup-glass-icon.warning {
    color: #ff9800;
}

.popup-glass-data {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.popup-glass-label {
    font-size: 9.5px;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 500;
}

.popup-glass-value {
    font-size: 12px;
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
}

.popup-glass-value.critical {
    color: #ff4444;
}

.popup-glass-value.warning {
    color: #ff9800;
}

/* Horizontal Divider between grid rows */
.popup-glass-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.15) 20%, 
        rgba(255, 255, 255, 0.15) 80%, 
        transparent
    );
    margin: 2px 0;
}

/* Action Buttons Row */
.popup-glass-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.popup-glass-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.popup-glass-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: translateY(-1px);
}

.popup-glass-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.12);
}

.popup-glass-btn i {
    font-size: 10px;
    opacity: 0.7;
}

/* ==========================================
   Object Properties Panel - Figma Design
   Refined for visual parity (Jan 2026)
   ========================================== */

/* Base font stack - Inter/system */
.object-properties-panel,
.object-properties-panel * {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.object-properties-panel {
    display: flex;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    width: 800px;
    max-width: 800px;
    min-width: 800px;
    height: 80vh;
    max-height: 700px;
    overflow: hidden;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Prevent parent stretching */
#editVehicleModal .object-properties-panel {
    flex-shrink: 0;
    flex-grow: 0;
}

/* Command Terminal Modal */
.command-terminal {
    background: rgba(30, 30, 40, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

.terminal-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(50, 50, 60, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-dots {
    display: flex;
    gap: 8px;
    margin-right: 16px;
}

.terminal-dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.terminal-dots .dot.red { background: #ff5f56; }
.terminal-dots .dot.yellow { background: #ffbd2e; }
.terminal-dots .dot.green { background: #27ca40; }

.terminal-title {
    flex: 1;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.terminal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.terminal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.terminal-info {
    padding: 12px 16px;
    background: rgba(40, 40, 50, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.terminal-vehicle-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.terminal-status {
    font-size: 14px;
}

.terminal-status.online { color: #27ca40; }
.terminal-status.offline { color: #ff5f56; }

.terminal-vehicle-name {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.terminal-group {
    color: rgba(100, 180, 255, 0.9);
    font-size: 12px;
    background: rgba(100, 180, 255, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
}

.terminal-imei {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.terminal-output {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    min-height: 200px;
    max-height: 350px;
    color: #00ff88;
    font-size: 13px;
    line-height: 1.6;
}

.terminal-output::-webkit-scrollbar {
    width: 8px;
}

.terminal-output::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.terminal-output::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.terminal-welcome {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 4px;
}

.terminal-hint {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    margin-bottom: 12px;
}

.terminal-line {
    margin-bottom: 8px;
    word-wrap: break-word;
}

.terminal-line.cmd {
    color: #64b5f6;
}

.terminal-line.response {
    color: #00ff88;
}

.terminal-line.error {
    color: #ff5f56;
}

.terminal-line.info {
    color: rgba(255, 255, 255, 0.5);
}

.terminal-line .timestamp {
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    margin-right: 8px;
}

.terminal-input-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(40, 40, 50, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    gap: 10px;
}

.terminal-prompt {
    color: #27ca40;
    font-size: 14px;
    font-weight: 600;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    caret-color: #27ca40;
}

.terminal-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.terminal-send {
    background: linear-gradient(135deg, #27ca40, #1e9e33);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.terminal-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(39, 202, 64, 0.4);
}

.terminal-send:active {
    transform: scale(0.95);
}

/* Light mode command terminal overrides */
body.theme-light .command-terminal {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

body.theme-light .terminal-header {
    background: rgba(240, 242, 245, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme-light .terminal-title {
    color: rgba(0, 0, 0, 0.65);
}

body.theme-light .terminal-close {
    color: rgba(0, 0, 0, 0.4);
}

body.theme-light .terminal-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1a1a1a;
}

body.theme-light .terminal-info {
    background: rgba(245, 247, 250, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-light .terminal-vehicle-name {
    color: #1a2332;
}

body.theme-light .terminal-group {
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.1);
}

body.theme-light .terminal-imei {
    color: rgba(0, 0, 0, 0.45);
}

body.theme-light .terminal-output {
    color: #15803d;
    background: #fafbfc;
}

body.theme-light .terminal-output::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}

body.theme-light .terminal-output::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

body.theme-light .terminal-welcome {
    color: #1a2332;
}

body.theme-light .terminal-hint {
    color: rgba(0, 0, 0, 0.4);
}

body.theme-light .terminal-line.cmd {
    color: #1d4ed8;
}

body.theme-light .terminal-line.response {
    color: #15803d;
}

body.theme-light .terminal-line.error {
    color: #b91c1c;
}

body.theme-light .terminal-line.info {
    color: rgba(0, 0, 0, 0.45);
}

body.theme-light .terminal-line .timestamp {
    color: rgba(0, 0, 0, 0.3);
}

body.theme-light .terminal-input-row {
    background: rgba(245, 247, 250, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme-light .terminal-prompt {
    color: #15803d;
}

body.theme-light .terminal-input {
    color: #1a2332;
    caret-color: #15803d;
}

body.theme-light .terminal-input::placeholder {
    color: rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.op-sidebar {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
    background: #ffffff;
    border-right: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    padding: 24px 0 24px 0;
    flex-shrink: 0;
}

.op-sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 8px;
}

.op-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.op-icon-wrapper {
    width: 36px;
    height: 36px;
    background: #4a7ab0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.op-vehicle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border-left: 3px solid #4a7ab0;
}

.op-vehicle-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.3;
    word-break: break-word;
}

.op-vehicle-imei {
    font-size: 11px;
    color: #6c757d;
    font-weight: 500;
    font-family: 'Consolas', 'Monaco', monospace;
    letter-spacing: 0.3px;
}

.op-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.2;
}

/* Navigation */
.op-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    gap: 2px;
}

.op-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    transition: all 0.12s ease;
    cursor: pointer;
}

.op-nav-item i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    opacity: 0.8;
}

.op-nav-item:hover {
    background: #f8fafc;
    color: #334155;
}

.op-nav-item.active {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 500;
}

.op-nav-item.active i {
    color: #1e293b;
    opacity: 1;
}

/* Content Area */
.op-content {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    padding: 24px 28px 24px;
    overflow: hidden;
    position: relative;
    background: #ffffff;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    height: 100%;
}

/* Fixed close button - always visible */
.op-close-btn {
    position: absolute;
    top: 24px;
    right: 28px;
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.12s ease;
    z-index: 100;
    font-size: 16px;
}

.op-close-btn:hover {
    background: #e2e8f0;
    color: #475569;
}

/* Section */
.op-section {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    max-height: 100%;
}

/* Fixed header with close button (for Sensors section) */
.op-section-header-fixed {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-shrink: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 16px;
}

.op-section-header-content {
    flex: 1;
}

.op-section-header-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 6px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.op-close-btn-inline {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.12s ease;
    font-size: 16px;
    flex-shrink: 0;
    margin-left: 16px;
}

.op-close-btn-inline:hover {
    background: #e2e8f0;
    color: #475569;
}

/* Scrollable section content */
.op-section-scroll {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    padding-bottom: 120px;
    margin-right: -4px;
    min-height: 0;
    max-height: 100%;
    box-sizing: border-box;
}

.op-section-scroll::-webkit-scrollbar {
    width: 6px;
}

.op-section-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.op-section-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.op-section-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.op-section-header {
    flex-shrink: 0;
    margin-bottom: 20px;
    padding-right: 40px; /* Space for close button */
}

.op-section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 6px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.op-section-desc {
    font-size: 14px;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
}

.op-vehicle-badge {
    display: inline-flex;
    flex-direction: column;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 12px;
}

.op-vehicle-badge span:first-child {
    font-weight: 600;
    color: #0369a1;
    font-size: 14px;
}

.op-imei {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

/* Tabs - Figma pill style */
.op-tabs {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
    gap: 0;
    flex-shrink: 0;
}

.op-tab {
    padding: 8px 20px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.12s ease;
    line-height: 1.4;
}

.op-tab:hover {
    color: #475569;
}

.op-tab.active {
    background: #ffffff;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Form - Label above input style (Figma) */
.op-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 24px;
}

/* Scrollable form for Main section */
.op-form-scrollable {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    margin-right: -8px;
}

.op-form-scrollable::-webkit-scrollbar {
    width: 6px;
}

.op-form-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.op-form-scrollable::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.op-form-scrollable::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.op-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.op-form-inline-group {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.op-form-inline-group .op-label {
    flex: 0 0 auto;
}

.op-input-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.op-label {
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    line-height: 1.4;
}

.op-input {
    height: 40px;
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    background: #f3f4f6;
    color: #1e293b;
    transition: all 0.12s ease;
    line-height: 40px;
}

/* Select dropdown styling */
.op-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
}

/* Small input/select variants for inline groups */
.op-input-sm {
    width: 80px;
    text-align: right;
}

.op-select-sm {
    width: 90px;
}

/* Section divider for Counters */
.op-form-section-divider {
    font-size: 13px;
    font-weight: 600;
    color: #0ea5e9;
    padding: 12px 0 4px;
    margin-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.op-input:focus {
    outline: none;
    background: #e5e7eb;
}

.op-input:read-only {
    background: #f3f4f6;
    color: #64748b;
}

/* Cards */
.op-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.op-card-header {
    padding: 14px 18px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.op-card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.op-card-body {
    padding: 0;
}

/* IO List */
.op-io-list {
    display: flex;
    flex-direction: column;
}

.op-io-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s ease;
}

.op-io-item:last-child {
    border-bottom: none;
}

.op-io-item:hover {
    background: #f9fafb;
}

.op-io-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.op-io-key {
    font-weight: 600;
    color: #111827;
    font-size: 13px;
}

.op-io-value {
    font-size: 12px;
    color: #6b7280;
}

.op-io-note {
    font-size: 11px;
    color: #9ca3af;
    font-style: italic;
}

.op-io-actions {
    display: flex;
    gap: 6px;
}

/* Mappings List */
.op-mappings-list {
    display: flex;
    flex-direction: column;
}

.op-mapping-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s ease;
}

.op-mapping-item:last-child {
    border-bottom: none;
}

.op-mapping-item:hover {
    background: #f9fafb;
}

.op-mapping-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.op-mapping-name {
    font-weight: 600;
    color: #111827;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.op-mapping-details {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 8px;
}

.op-mapping-type {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.op-mapping-type.fuel { background: #dbeafe; color: #1d4ed8; }
.op-mapping-type.ignition { background: #ffedd5; color: #c2410c; }
.op-mapping-type.temperature { background: #fee2e2; color: #b91c1c; }
.op-mapping-type.voltage { background: #dcfce7; color: #15803d; }
.op-mapping-type.door { background: #f3e8ff; color: #7c3aed; }
.op-mapping-type.odometer { background: #fef9c3; color: #a16207; }
.op-mapping-type.custom { background: #f3f4f6; color: #4b5563; }

.op-mapping-actions {
    display: flex;
    gap: 6px;
}

/* Buttons */
.op-btn {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.op-btn-primary {
    background: #111827;
    color: white;
    border: none;
}

.op-btn-primary:hover {
    background: #1f2937;
}

.op-btn-secondary {
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.op-btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.op-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.op-btn-edit {
    background: #3b82f6;
    color: white;
    border: none;
}

.op-btn-edit:hover {
    background: #2563eb;
}

.op-btn-configure {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.op-btn-configure:hover {
    background: #dcfce7;
}

.op-btn-calibrate {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.op-btn-calibrate:hover {
    background: #dcfce7;
}

.op-btn-calibrate:disabled {
    background: #f9fafb;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

.op-btn-settings {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.op-btn-settings:hover {
    background: #dbeafe;
}

.op-btn-delete {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.op-btn-delete:hover {
    background: #fee2e2;
}

/* Footer */
.op-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 0 0;
    margin-top: 16px;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

/* Figma-style footer buttons */
.op-btn-outline {
    height: 40px;
    padding: 0 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.12s ease;
    line-height: 1;
}

.op-btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.op-btn-primary {
    height: 40px;
    padding: 0 20px;
    background: #1e293b;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.12s ease;
    line-height: 1;
}

.op-btn-primary:hover {
    background: #334155;
}

/* Blue variant for Save button (Figma cyan) */
.op-btn-primary.op-btn-save {
    background: #0ea5e9;
}

.op-btn-primary.op-btn-save:hover {
    background: #0284c7;
}

/* PHASE 7: Saving state for buttons - prevents flicker and shows feedback */
.is-saving,
button.is-saving,
.op-btn.is-saving,
.inline-cal-edit.is-saving {
    pointer-events: none;
    opacity: 0.7;
    cursor: wait !important;
    position: relative;
}

.is-saving::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin-saving 0.8s linear infinite;
}

@keyframes spin-saving {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Placeholder for future sections */
.op-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #9ca3af;
    text-align: center;
}

.op-placeholder i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.op-placeholder p {
    font-size: 14px;
    margin: 0;
}

/* Sensor Badge */
.op-sensor-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: #15803d;
}

.op-sensor-badge.disabled {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

/* Responsive */
@media (max-width: 860px) {
    .object-properties-panel {
        width: 95vw;
        min-width: auto;
        max-width: 95vw;
        height: auto;
        max-height: 90vh;
        flex-direction: column;
    }
    
    .op-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        flex-direction: row;
        padding: 12px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid #f1f5f9;
    }
    
    .op-sidebar-header {
        display: none;
    }
    
    .op-nav {
        flex-direction: row;
        padding: 0;
        gap: 4px;
    }
    
    .op-nav-item {
        padding: 8px 12px;
        white-space: nowrap;
    }
    
    .op-nav-item span {
        display: none;
    }
    
    .op-content {
        padding: 20px;
    }
}

/* ============================================
   Form Table Layout (Figma Jan 2026)
   ============================================ */

.op-form-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.op-form-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    min-height: 48px;
}

.op-form-label {
    flex: 0 0 140px;
    font-size: 14px;
    font-weight: 400;
    color: #475569;
    line-height: 1.4;
}

.op-form-value {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    color: #1e293b;
    line-height: 40px;
}

.op-form-value:focus {
    outline: none;
    background: #e5e7eb;
}

.op-form-value[readonly] {
    background: #f3f4f6;
    color: #64748b;
}

.op-form-select {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    color: #1e293b;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 36px;
}

.op-form-select:focus {
    outline: none;
    background: #e5e7eb;
}

.op-form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #0ea5e9;
    padding: 16px 0 8px;
    margin-top: 8px;
}

.op-form-inline {
    display: flex;
    flex: 1;
    gap: 12px;
    align-items: center;
}

.op-form-select-sm {
    width: 100px;
    height: 40px;
    padding: 0 12px;
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    color: #1e293b;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 14px;
    padding-right: 28px;
}

.op-form-value-sm {
    width: 80px;
    height: 40px;
    padding: 0 12px;
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    color: #1e293b;
    text-align: right;
    line-height: 40px;
}
/* ============================================
   Settings Panel Specific Styles
   ============================================ */

/* Settings Table Container */
.settings-table-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.settings-search {
    position: relative;
    flex: 0 0 300px;
}

.settings-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
}

.settings-search .op-input {
    padding-left: 38px;
    height: 38px;
    width: 100%;
}

/* Settings Table */
.settings-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #f1f5f9;
}

.settings-table thead {
    background: #f8fafc;
}

.settings-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid #e2e8f0;
}

.settings-table tbody tr {
    transition: background-color 0.15s ease;
}

.settings-table tbody tr:hover {
    background: #f8fafc;
}

.settings-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f1f5f9;
}

.settings-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: #1e293b;
}

.settings-table td:first-child,
.settings-table th:first-child {
    width: 40px;
    text-align: center;
}

.settings-table td:last-child,
.settings-table th:last-child {
    width: 100px;
    text-align: center;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}

.status-badge.active {
    background: #dcfce7;
    color: #16a34a;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #dc2626;
}

/* Action Buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
}

.action-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.action-btn:hover i.fa-edit {
    color: #1397D2;
}

.action-btn:hover i.fa-trash {
    color: #dc2626;
}

/* Settings Modal specific adjustments */
#settingsModal .object-properties-panel {
    max-width: 1100px;
    width: 92%;
    min-width: 900px;
    height: 85vh;
    max-height: 85vh;
    min-height: 500px;
}

#settingsModal .op-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    max-height: 100%;
}

#settingsModal .op-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#settingsModal .op-section-scroll {
    max-height: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 20px;
}

#settingsModal .op-section-scroll::-webkit-scrollbar {
    width: 8px;
}

#settingsModal .op-section-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

#settingsModal .op-section-scroll::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
    min-height: 40px;
}

#settingsModal .op-section-scroll::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Ensure Actions column is always visible */
.settings-table th:last-child,
.settings-table td:last-child {
    min-width: 100px;
    white-space: nowrap;
}

/* Checkbox styling */
.settings-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1397D2;
}

/* Group Properties Modal - Higher z-index to show above settings modal */
#groupPropertiesModal {
    z-index: 4000 !important;
}

#groupPropertiesModal .modal-content {
    animation: modalSlideIn 0.2s ease-out;
    max-width: 450px !important;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Group Objects Container */
.group-objects-container {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.group-objects-header {
    padding: 8px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.group-search-box {
    position: relative;
    flex: 1;
}

.group-search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 12px;
}

.group-search-input {
    width: 100%;
    height: 32px;
    padding: 0 10px 0 32px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 13px;
    background: #ffffff;
    color: #1e293b;
    transition: all 0.2s ease;
}

.group-search-input:focus {
    outline: none;
    border-color: #1397D2;
    box-shadow: 0 0 0 2px rgba(19, 151, 210, 0.1);
}

.group-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    padding: 6px 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.group-select-all:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.group-select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1397D2;
}

.group-select-all span {
    user-select: none;
}

.group-objects-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}

.group-objects-list::-webkit-scrollbar {
    width: 6px;
}

.group-objects-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.group-objects-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.group-objects-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.group-object-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.group-object-item:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.group-object-item.hidden {
    display: none;
}

.group-object-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1397D2;
    flex-shrink: 0;
}

.group-object-item label {
    display: flex;
    flex-direction: column;
    gap: 1px;
    cursor: pointer;
    flex: 1;
    user-select: none;
}

.group-object-name {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.3;
}

.group-object-imei {
    font-size: 11px;
    color: #64748b;
    font-family: 'Courier New', monospace;
}

.group-objects-empty {
    padding: 30px 15px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.group-objects-count {
    padding: 8px 12px;
    text-align: center;
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* Dark mode — Edit Group / Group Properties modal */
body.theme-dark .group-objects-container {
    border-color: #2a3f52;
    background: #1e2d3d;
}

body.theme-dark .group-objects-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .group-search-input {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .group-search-input::placeholder {
    color: #5c7080;
}

body.theme-dark .group-select-all {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #8899a6;
}

body.theme-dark .group-select-all:hover {
    background: #243647;
    border-color: #3a5068;
}

body.theme-dark .group-object-item:hover {
    background: #243647;
    border-color: #2a3f52;
}

body.theme-dark .group-object-name {
    color: #e8edf2;
}

body.theme-dark .group-object-imei {
    color: #5c7080;
}

body.theme-dark .group-objects-empty {
    color: #5c7080;
}

body.theme-dark .group-objects-count {
    color: #5c7080;
    background: #0f1923;
    border-top-color: #2a3f52;
}

body.theme-dark .group-objects-list::-webkit-scrollbar-track {
    background: #1a2733;
}

body.theme-dark .group-objects-list::-webkit-scrollbar-thumb {
    background: #2a3f52;
}

body.theme-dark .group-objects-list::-webkit-scrollbar-thumb:hover {
    background: #3a5068;
}

/* =============================================================================
   MODERN BOTTOM PANEL (v2) — Replaces old status-bar + status-drawer
   ============================================================================= */

/* Dark theme variables (bottom panel specific, scoped) */
.bottom-panel-v2 {
    --bp-bg-primary: #0f1923;
    --bp-bg-secondary: #1a2733;
    --bp-bg-card: #1e2d3d;
    --bp-bg-card-hover: #243647;
    --bp-border: #2a3f52;
    --bp-text-primary: #e8edf2;
    --bp-text-secondary: #8899a6;
    --bp-text-muted: #5c7080;
    --bp-accent-blue: #1da1f2;
    --bp-accent-green: #17bf63;
    --bp-accent-orange: #ffad1f;
    --bp-accent-red: #e0245e;
    --bp-accent-purple: #7856ff;
    --bp-accent-teal: #00c9a7;
    --bp-shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --bp-shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --bp-radius-sm: 8px;
    --bp-radius-md: 12px;

    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bp-bg-primary);
    border-top: 1px solid var(--bp-border);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    min-height: 230px;
    max-height: 420px;
    transform: translateY(calc(100% - 44px)); /* Show only tab bar */
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--bp-text-primary);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    contain: layout style;
}

/* Light theme overrides */
body.theme-light .bottom-panel-v2 {
    --bp-bg-primary: #f0f2f5;
    --bp-bg-secondary: #ffffff;
    --bp-bg-card: #ffffff;
    --bp-bg-card-hover: #f7f9fb;
    --bp-border: #e1e5ea;
    --bp-text-primary: #1a2332;
    --bp-text-secondary: #5f6b7a;
    --bp-text-muted: #9ca3af;
    --bp-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --bp-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

.bottom-panel-v2.open {
    transform: translateY(0);
}

.bottom-panel-v2.collapsed {
    transform: translateY(100%);
}

/* Resize handle */
.bp-resize-handle {
    height: 6px;
    background: var(--bp-bg-secondary);
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--bp-border);
    flex-shrink: 0;
}

.bp-resize-handle::after {
    content: '';
    width: 40px;
    height: 3px;
    background: var(--bp-border);
    border-radius: 2px;
}

.bp-resize-handle:hover::after {
    background: var(--bp-accent-blue);
}

/* Panel header */
.bp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: var(--bp-bg-secondary);
    border-bottom: 1px solid var(--bp-border);
    gap: 10px;
    flex-shrink: 0;
    min-height: 38px;
}

.bp-vehicle-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 1;
}

.bp-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bp-status-dot.stopped {
    background: var(--bp-accent-red);
    box-shadow: 0 0 8px rgba(224, 36, 94, 0.5);
}

.bp-status-dot.moving {
    background: var(--bp-accent-green);
    box-shadow: 0 0 8px rgba(23, 191, 99, 0.5);
    animation: bp-pulse-green 2.4s ease-in-out infinite;
}

.bp-status-dot.idle {
    background: var(--bp-accent-orange);
    box-shadow: 0 0 8px rgba(255, 173, 31, 0.5);
}

.bp-status-dot.offline {
    background: #5c7080;
}

@keyframes bp-pulse-green {
    0%, 100% { box-shadow: 0 0 8px rgba(23, 191, 99, 0.3); }
    50% { box-shadow: 0 0 16px rgba(23, 191, 99, 0.7); }
}

.bp-vehicle-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--bp-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.bp-vehicle-plate {
    font-size: 10px;
    font-weight: 500;
    color: var(--bp-accent-blue);
    background: rgba(29, 161, 242, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Tabs */
.bp-tabs {
    display: flex;
    gap: 2px;
    background: var(--bp-bg-primary);
    border-radius: var(--bp-radius-sm);
    padding: 3px;
    flex-shrink: 0;
}

.bp-tab {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--bp-text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
}

.bp-tab:hover {
    color: var(--bp-text-primary);
    background: var(--bp-bg-card);
}

.bp-tab.active {
    color: var(--bp-accent-blue);
    background: var(--bp-bg-card);
    box-shadow: var(--bp-shadow-sm);
}

.bp-tab .tab-icon {
    font-size: 12px;
}

.bp-tab .bp-badge {
    background: var(--bp-accent-red);
    color: white;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 10px;
    line-height: 1.2;
}

/* Header controls */
.bp-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.bp-ctrl-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bp-bg-card);
    color: var(--bp-text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.bp-ctrl-btn:hover {
    background: var(--bp-bg-card-hover);
    color: var(--bp-text-primary);
}

.bp-ctrl-btn.active {
    background: rgba(29, 161, 242, 0.18);
    color: var(--bp-accent-blue);
    box-shadow: inset 0 0 0 1px rgba(29, 161, 242, 0.45);
}

.bp-ctrl-btn.close-btn:hover {
    background: rgba(224, 36, 94, 0.15);
    color: var(--bp-accent-red);
}

.bp-ctrl-btn.open-btn:hover {
    background: rgba(23, 191, 99, 0.15);
    color: var(--bp-accent-green);
}

.bp-ctrl-btn.bp-refresh-raw {
    background: var(--bp-accent-blue);
    color: #fff;
}

.bp-ctrl-btn.bp-refresh-raw:hover {
    filter: brightness(1.15);
    background: var(--bp-accent-blue);
    color: #fff;
}

/* Panel content area */
.bp-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.bp-view {
    display: none;
    width: 100%;
    overflow-y: hidden;
    overflow-x: hidden;
    padding: 4px 5px 2px 5px;
}

.bp-view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.bp-smooth-switch .bp-view.active {
    animation: bpViewFadeIn 0.2s ease;
}

@keyframes bpViewFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bp-view {
    scrollbar-width: thin;
    scrollbar-color: var(--bp-border) var(--bp-bg-primary);
}

.bp-view::-webkit-scrollbar {
    width: 4px;
}

.bp-view::-webkit-scrollbar-track {
    background: var(--bp-bg-primary);
}

.bp-view::-webkit-scrollbar-thumb {
    background: var(--bp-border);
    border-radius: 2px;
}

/* ---- DATA tab layout ---- */
.bp-data-layout {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* Speed / Status summary card */
.bp-status-summary {
    flex-shrink: 0;
    width: 180px;
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 2px solid var(--bp-border);
    margin-bottom: 5px;
}

.bp-speed-gauge {
    position: relative;
    width: 90px;
    height: 90px;
}

.bp-speed-gauge svg {
    transform: rotate(-90deg);
}

.bp-speed-gauge .gauge-bg {
    fill: none;
    stroke: var(--bp-border);
    stroke-width: 6;
}

.bp-speed-gauge .gauge-fill {
    fill: none;
    stroke: var(--bp-accent-green);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 251;
    stroke-dashoffset: 251;
    transition: stroke-dashoffset 1s ease, stroke 0.5s ease;
}

.bp-speed-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.bp-speed-number {
    font-size: 22px;
    font-weight: 700;
    color: var(--bp-text-primary);
    line-height: 1;
}

.bp-speed-unit {
    font-size: 9px;
    color: var(--bp-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bp-status-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bp-status-label.stopped { background: rgba(224,36,94,0.12); color: var(--bp-accent-red); }
.bp-status-label.moving  { background: rgba(23,191,99,0.12); color: var(--bp-accent-green); }
.bp-status-label.idle    { background: rgba(255,173,31,0.12); color: var(--bp-accent-orange); }
.bp-status-label.offline { background: rgba(92,112,128,0.12); color: #5c7080; }

.bp-status-duration {
    font-size: 10px;
    color: var(--bp-text-muted);
}

/* Data grid */
.bp-data-grid {
    --grid-rows: 3;
    display: grid;
    grid-template-rows: repeat(var(--grid-rows), auto);
    grid-auto-flow: column;
    grid-auto-columns: minmax(200px, 1fr);
    gap: 6px;
    align-content: start;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    padding-top: 4px;
    padding-bottom: 2px;
    flex: 1;
    min-height: 0;
}

.bp-data-grid {
    scrollbar-color: var(--bp-border) var(--bp-bg-primary);
}

.bp-data-grid::-webkit-scrollbar {
    height: 5px;
}

.bp-data-grid::-webkit-scrollbar-track {
    background: var(--bp-bg-primary);
}

.bp-data-grid::-webkit-scrollbar-thumb {
    background: var(--bp-border);
    border-radius: 3px;
}

/* Disable transitions during resize for instant repositioning */
.bottom-panel-v2.resizing .bp-data-item,
.bottom-panel-v2.resizing .bp-data-grid {
    transition: none !important;
}

/* Suppress fade-in animation during context switches (History <-> Objects) */
.no-animate .bp-data-item,
.no-animate .bp-sensor-card,
.no-animate .bp-raw-item {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

.bp-data-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--bp-radius-sm);
    background: var(--bp-bg-card);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.bp-data-item:hover {
    border-color: var(--bp-border);
    background: var(--bp-bg-card-hover);
}

.bp-data-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.bp-data-icon.blue   { background: rgba(29,161,242,0.12); color: var(--bp-accent-blue); }
.bp-data-icon.green  { background: rgba(23,191,99,0.12);  color: var(--bp-accent-green); }
.bp-data-icon.orange { background: rgba(255,173,31,0.12); color: var(--bp-accent-orange); }
.bp-data-icon.purple { background: rgba(120,86,255,0.12); color: var(--bp-accent-purple); }
.bp-data-icon.teal   { background: rgba(0,201,167,0.12);  color: var(--bp-accent-teal); }
.bp-data-icon.red    { background: rgba(224,36,94,0.12);  color: var(--bp-accent-red); }

.bp-data-text {
    min-width: 0;
    flex: 1;
}

.bp-data-label {
    font-size: 9px;
    font-weight: 500;
    color: var(--bp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
}

.bp-data-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--bp-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bp-data-value.copyable { cursor: pointer; }
.bp-data-value.copyable:hover { color: var(--bp-accent-blue); }

/* ---- SENSORS tab ---- */
.bp-sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
    flex: 1;
    min-height: 0;
    align-content: start;
}

/* When sensors grid has only a no-data child, center it */
.bp-sensors-grid:has(> .no-data:only-child),
.bp-sensors-grid:has(> .no-io-data:only-child) {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Same for history stats grid */
.bp-history-stats:has(> .no-data:only-child) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bp-sensor-card {
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-md);
    padding: 12px;
    border: 1px solid var(--bp-border);
    transition: all 0.2s ease;
}

.bp-sensor-card:hover {
    border-color: var(--bp-accent-blue);
    box-shadow: 0 0 0 1px rgba(29,161,242,0.2);
}

.bp-sensor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.bp-sensor-name {
    font-size: 10px;
    font-weight: 500;
    color: var(--bp-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bp-sensor-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bp-accent-green);
}

.bp-sensor-status.warning { background: var(--bp-accent-orange); }
.bp-sensor-status.error   { background: var(--bp-accent-red); }

.bp-sensor-value-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 6px;
}

.bp-sensor-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--bp-text-primary);
    line-height: 1;
}

.bp-sensor-unit {
    font-size: 11px;
    color: var(--bp-text-muted);
}

.bp-sensor-bar {
    height: 4px;
    background: var(--bp-border);
    border-radius: 2px;
    overflow: hidden;
}

.bp-sensor-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.bp-sensor-bar-fill.green  { background: var(--bp-accent-green); }
.bp-sensor-bar-fill.orange { background: var(--bp-accent-orange); }
.bp-sensor-bar-fill.red    { background: var(--bp-accent-red); }
.bp-sensor-bar-fill.blue   { background: var(--bp-accent-blue); }

.bp-sensor-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 9px;
    color: var(--bp-text-muted);
}

/* ---- Sensor cards (prototype style) ---- */
.bp-sensors-grid .sensor-card {
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-md, 12px);
    padding: 14px;
    border: 1px solid var(--bp-border);
    transition: all 0.25s ease;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.bp-sensors-grid .sensor-card:hover {
    border-color: var(--bp-accent-blue);
    box-shadow: 0 0 0 1px rgba(29,161,242,0.2);
}

.bp-sensors-grid .sensor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.bp-sensors-grid .sensor-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--bp-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bp-sensors-grid .sensor-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bp-accent-green);
}
.bp-sensors-grid .sensor-status.warning { background: var(--bp-accent-orange); }
.bp-sensors-grid .sensor-status.error   { background: var(--bp-accent-red); }

.bp-sensors-grid .sensor-value-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 8px;
}

.bp-sensors-grid .sensor-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--bp-text-primary);
    line-height: 1;
}

.bp-sensors-grid .sensor-unit {
    font-size: 12px;
    color: var(--bp-text-muted);
}

.bp-sensors-grid .sensor-bar {
    height: 4px;
    background: var(--bp-border);
    border-radius: 2px;
    overflow: hidden;
}

.bp-sensors-grid .sensor-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.bp-sensors-grid .sensor-bar-fill.green  { background: var(--bp-accent-green); }
.bp-sensors-grid .sensor-bar-fill.orange { background: var(--bp-accent-orange); }
.bp-sensors-grid .sensor-bar-fill.red    { background: var(--bp-accent-red); }
.bp-sensors-grid .sensor-bar-fill.blue   { background: var(--bp-accent-blue); }

.bp-sensors-grid .sensor-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 10px;
    color: var(--bp-text-muted);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- HISTORY tab ---- */
.bp-history-tab {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.bp-history-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bp-history-range-btn {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--bp-border);
    background: var(--bp-bg-card);
    color: var(--bp-text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.bp-history-range-btn:hover {
    border-color: var(--bp-accent-blue);
    color: var(--bp-text-primary);
}

.bp-history-range-btn.active {
    background: var(--bp-accent-blue);
    border-color: var(--bp-accent-blue);
    color: white;
}

.bp-history-export {
    margin-left: auto;
}

.bp-history-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    flex: 1;
    min-height: 0;
    align-content: start;
}

.bp-history-stat {
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-sm, 8px);
    padding: 12px;
    border: 1px solid var(--bp-border);
    text-align: center;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.bp-history-stat:nth-child(1) { animation-delay: 0.02s; }
.bp-history-stat:nth-child(2) { animation-delay: 0.06s; }
.bp-history-stat:nth-child(3) { animation-delay: 0.10s; }
.bp-history-stat:nth-child(4) { animation-delay: 0.14s; }
.bp-history-stat:nth-child(5) { animation-delay: 0.18s; }
.bp-history-stat:nth-child(6) { animation-delay: 0.22s; }
.bp-history-stat:nth-child(7) { animation-delay: 0.26s; }
.bp-history-stat:nth-child(8) { animation-delay: 0.30s; }

.bp-history-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--bp-text-primary);
}

.bp-history-stat-label {
    font-size: 10px;
    color: var(--bp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ---- ALERTS tab ---- */
.bp-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.bp-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-sm, 8px);
    border: 1px solid var(--bp-border);
    transition: all 0.2s ease;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.bp-alert-item:hover {
    background: var(--bp-bg-card-hover);
}

.bp-alert-text {
    flex: 1;
}

.bp-alert-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--bp-text-primary);
    margin-bottom: 2px;
}

.bp-alert-desc {
    font-size: 11px;
    color: var(--bp-text-secondary);
}

/* ---- RAW DATA tab ---- */
/* Old raw-data-header styles restored for Sensors view */
.bp-raw-data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--bp-border);
    flex-shrink: 0;
}

.bp-raw-data-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--bp-text-primary);
}

.bp-raw-data-title i {
    color: var(--bp-accent-blue);
}

.bp-raw-actions {
    display: flex;
    gap: 6px;
}

.bp-raw-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--bp-accent-blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.bp-raw-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.bp-raw-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4px;
    flex: 1;
}

.bp-raw-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: var(--bp-bg-card);
    border-radius: 6px;
    gap: 8px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    min-height: 34px;
}

.bp-raw-item:hover {
    border-color: var(--bp-border);
    background: var(--bp-bg-card-hover);
}

.bp-raw-item-icon {
    font-size: 12px;
    color: var(--bp-accent-blue);
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.bp-raw-item-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--bp-text-secondary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bp-raw-item-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--bp-text-primary);
    font-family: 'Courier New', monospace;
    flex-shrink: 0;
}

/* ---- GRAPH tab (re-styled container, keep existing graph.js structure) ---- */
.bp-view .graph-toolbar {
    background: var(--bp-bg-card);
    border-radius: var(--bp-radius-sm);
    padding: 6px 10px;
    margin-bottom: 6px;
    border: 1px solid var(--bp-border);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 10;
}

.bp-view .graph-toolbar strong {
    color: var(--bp-text-primary);
    font-size: 11px;
    margin-right: 4px;
}

.bp-view .graph-btn {
    display: none;
}

.bp-view .graph-container {
    flex: 1;
    min-height: 0;
    border-radius: var(--bp-radius-sm);
    overflow: hidden;
    position: relative;
}

.bp-view .graph-legend {
    color: var(--bp-text-secondary);
    font-size: 11px;
}

/* Live cursor readout badges */
.bp-view .graph-legend.cursor-readout {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.bp-view .graph-legend.cursor-readout .cr-badge:not(.cr-timestamp) {
    flex-shrink: 0;
}

.cr-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', -apple-system, sans-serif;
    border: 1.5px solid transparent;
    background: var(--bp-bg-card, #1e2d3d);
    white-space: nowrap;
    line-height: 1.3;
}

body.theme-light .cr-badge {
    background: #ffffff;
    border-color: #e0e4e8;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.cr-badge.cr-timestamp {
    font-weight: 500;
    font-size: 12px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-variant-numeric: tabular-nums;
    width: 156px;
    justify-content: flex-end;
    text-align: right;
    color: var(--bp-text-muted, #5c7080);
    border-color: transparent;
    background: transparent;
    padding: 2px 4px;
    flex-shrink: 0;
}

body.theme-light .cr-badge.cr-timestamp {
    color: #374151;
    font-weight: 600;
}

.cr-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cr-value {
    font-weight: 700;
    color: var(--bp-text-primary, #e8edf2);
    font-variant-numeric: tabular-nums;
}

body.theme-light .cr-value {
    color: #111827;
}

.cr-name {
    font-weight: 400;
    color: var(--bp-text-muted, #5c7080);
    font-size: 10px;
}

body.theme-light .cr-name {
    color: #6b7280;
}

.bp-view .graph-metrics {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.bp-view .graph-empty .no-data {
    color: var(--bp-text-muted);
}

/* ---- uPlot dark mode theming ---- */
body.theme-dark .uplot,
body:not(.theme-light) .uplot {
    background: transparent;
}

body.theme-dark .u-wrap,
body:not(.theme-light) .u-wrap {
    background: transparent !important;
}

body.theme-dark .u-over,
body:not(.theme-light) .u-over {
    background: transparent !important;
}

body.theme-dark .u-legend,
body:not(.theme-light) .u-legend {
    background: var(--bp-bg-card, #1e2d3d) !important;
    border: 1px solid var(--bp-border, #2a3f52) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    color: var(--bp-text-primary, #e8edf2) !important;
}

body.theme-dark .u-legend .u-series,
body:not(.theme-light) .u-legend .u-series {
    color: var(--bp-text-secondary, #8899a6) !important;
}

body.theme-dark .u-legend .u-series .u-value,
body:not(.theme-light) .u-legend .u-series .u-value {
    color: var(--bp-text-primary, #e8edf2) !important;
    font-weight: 600 !important;
}

body.theme-dark .u-legend .u-marker,
body:not(.theme-light) .u-legend .u-marker {
    border-radius: 3px !important;
}

body.theme-dark .u-select,
body:not(.theme-light) .u-select {
    background: rgba(29, 161, 242, 0.12) !important;
}

body.theme-dark .u-cursor-x,
body.theme-dark .u-cursor-y,
body:not(.theme-light) .u-cursor-x,
body:not(.theme-light) .u-cursor-y {
    border-color: rgba(136, 153, 166, 0.4) !important;
}

/* ---- ApexCharts dark mode theming ---- */
body.theme-dark .apexcharts-canvas,
body:not(.theme-light) .apexcharts-canvas {
    background: transparent !important;
}

body.theme-dark .apexcharts-tooltip,
body:not(.theme-light) .apexcharts-tooltip {
    background: var(--bp-bg-card, #1e2d3d) !important;
    border: 1px solid var(--bp-border, #2a3f52) !important;
    color: var(--bp-text-primary, #e8edf2) !important;
}

body.theme-dark .apexcharts-tooltip .apexcharts-tooltip-title,
body:not(.theme-light) .apexcharts-tooltip .apexcharts-tooltip-title {
    background: var(--bp-bg-primary, #0d1b2a) !important;
    border-bottom-color: var(--bp-border, #2a3f52) !important;
    color: var(--bp-text-primary, #e8edf2) !important;
}

body.theme-dark .apexcharts-xaxistooltip,
body:not(.theme-light) .apexcharts-xaxistooltip {
    background: var(--bp-bg-card, #1e2d3d) !important;
    border-color: var(--bp-border, #2a3f52) !important;
    color: var(--bp-text-primary, #e8edf2) !important;
}

body.theme-dark .apexcharts-xaxistooltip::before,
body.theme-dark .apexcharts-xaxistooltip::after,
body:not(.theme-light) .apexcharts-xaxistooltip::before,
body:not(.theme-light) .apexcharts-xaxistooltip::after {
    border-bottom-color: var(--bp-bg-card, #1e2d3d) !important;
}

body.theme-dark .apexcharts-toolbar svg,
body:not(.theme-light) .apexcharts-toolbar svg {
    fill: var(--bp-text-secondary, #8899a6) !important;
}

body.theme-dark .apexcharts-menu,
body:not(.theme-light) .apexcharts-menu {
    background: var(--bp-bg-card, #1e2d3d) !important;
    border-color: var(--bp-border, #2a3f52) !important;
    color: var(--bp-text-primary, #e8edf2) !important;
}

body.theme-dark .apexcharts-menu-item:hover,
body:not(.theme-light) .apexcharts-menu-item:hover {
    background: var(--bp-bg-card-hover, #253d56) !important;
}

/* Graph view flex fill for proper resizing */
#statusGraph.bp-view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
}

#statusGraph .graph-toolbar {
    flex-shrink: 0;
}

#statusGraph .graph-container {
    flex: 1;
    height: 0 !important;       /* Prevent chart content from inflating the flex item */
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden;
    position: relative;
    transition: opacity 0.1s ease-out;
}

#statusGraph .graph-container.chart-fade-out {
    opacity: 0;
}

#statusGraph .graph-container.chart-fade-in {
    opacity: 1;
}

/* Make uPlot fill the container */
#statusGraph .graph-container .uplot {
    width: 100% !important;
    height: 100% !important;
}

#statusGraph .graph-container .u-wrap {
    height: 100% !important;
}

/* uPlot legend — hidden; we use our own cursor readout bar */
.u-legend {
    display: none !important;
}

/* Hard-constrain ApexCharts to never exceed its container */
#statusGraph .graph-container .apexcharts-canvas {
    max-height: 100% !important;
    min-height: 0 !important;
    height: 100% !important;
}
#statusGraph .graph-container .apexcharts-canvas svg {
    min-height: 0 !important;
    max-height: 100% !important;
    height: 100% !important;
}
#statusGraph .graph-container > div[id^="apexcharts"] {
    max-height: 100% !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Reduce uPlot x-axis label space */
.u-axis.u-x {
    height: auto !important;
}

/* ---- MESSAGES tab ---- */
.bp-messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: var(--bp-text-muted);
    gap: 8px;
    flex: 1;
    min-height: 0;
}

.bp-messages-empty i {
    font-size: 28px;
    opacity: 0.5;
}

.bp-messages-empty p {
    font-size: 12px;
}

/* ---- No data placeholder ---- */
.bp-view .no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: var(--bp-text-muted);
    gap: 8px;
    text-align: center;
    flex: 1;
    min-height: 0;
}

.bp-view .no-data i {
    font-size: 28px;
    opacity: 0.5;
}

.bp-view .no-data p {
    font-size: 12px;
}

/* Center no-io-data inside sensors panel */
.bp-view .no-io-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    color: var(--bp-text-muted);
    gap: 8px;
    text-align: center;
    padding: 30px;
}

.bp-view .no-io-data i {
    font-size: 28px;
    opacity: 0.5;
}

/* ---- Animations ---- */
@keyframes bp-fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bp-data-item, .bp-sensor-card, .bp-raw-item {
    animation: bp-fadeInUp 0.25s ease forwards;
}

/* Stagger the first few items */
.bp-data-item:nth-child(1), .bp-sensor-card:nth-child(1) { animation-delay: 0.02s; }
.bp-data-item:nth-child(2), .bp-sensor-card:nth-child(2) { animation-delay: 0.04s; }
.bp-data-item:nth-child(3), .bp-sensor-card:nth-child(3) { animation-delay: 0.06s; }
.bp-data-item:nth-child(4), .bp-sensor-card:nth-child(4) { animation-delay: 0.08s; }
.bp-data-item:nth-child(5), .bp-sensor-card:nth-child(5) { animation-delay: 0.10s; }
.bp-data-item:nth-child(6), .bp-sensor-card:nth-child(6) { animation-delay: 0.12s; }

/* ---- Theme toggle button ---- */
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: calc(4px * var(--ui-scale));
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: calc(14px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(32px * var(--ui-scale));
    height: calc(32px * var(--ui-scale));
}

.theme-toggle-btn:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

body.theme-light .theme-toggle-btn {
    color: #ffad1f;
}

/* ---- Dark theme global overrides ---- */
body.theme-dark {
    --background-color: #111820;
    --surface-color: #1a2733;
    --surface-hover: #243647;
    --selected-bg: rgba(33, 150, 243, 0.15);
    --text-primary: #e8edf2;
    --text-secondary: #8899a6;
    --text-muted: #5c7080;
    --border-color: #2a3f52;
    --shadow-light: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-heavy: 0 4px 12px rgba(0,0,0,0.5);
    --scrollbar-track: #111820;
    --scrollbar-thumb: #2a3f52;
    --scrollbar-thumb-hover: #3a5268;
    background: #111820;
    color: #e8edf2;
}

/* Nav */
body.theme-dark .top-nav {
    background: #1a2733;
    border-bottom-color: #2a3f52;
}

/* Sidebar */
body.theme-dark .sidebar {
    background: #1a2733;
    border-right-color: #2a3f52;
}

body.theme-dark .sidebar-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .filter-tabs {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .filter-tab {
    color: #8899a6;
}

body.theme-dark .filter-tab.active {
    color: #1da1f2;
    border-bottom-color: #1da1f2;
}

body.theme-dark .tab-buttons {
    background: #0f1923;
}

body.theme-dark .tab-button {
    color: #8899a6;
}

body.theme-dark .tab-button.active {
    background: #1a2733;
    color: #e8edf2;
}

/* Search area */
body.theme-dark .search-input {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .search-input::placeholder {
    color: #5c7080;
}

body.theme-dark .search-btn,
body.theme-dark .add-object-btn {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #8899a6;
}

body.theme-dark .search-btn:hover,
body.theme-dark .add-object-btn:hover {
    background: #2196f3;
    color: white;
    border-color: #2196f3;
}

/* Group headers */
body.theme-dark .vehicle-group-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .vehicle-group-header:hover {
    background: #1a2733;
}

body.theme-dark .group-count {
    color: #5c7080;
}

/* Object items */
body.theme-dark .object-item {
    border-bottom-color: #2a3f52;
}

body.theme-dark .object-item:hover {
    background: #243647;
}

body.theme-dark .object-item.selected {
    background: rgba(33, 150, 243, 0.15);
}

/* Event panel */
body.theme-dark .event-panel {
    background: #1a2733;
    border-left-color: #2a3f52;
}

body.theme-dark .event-panel-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .event-item {
    border-bottom-color: #2a3f52;
    background: #1a2733;
}

body.theme-dark .event-item:hover {
    background: #243647;
}

body.theme-dark .event-panel.collapsed .panel-toggle {
    background: #1a2733;
    border-color: #2a3f52;
}

/* Modals */
body.theme-dark .modal-content {
    background: #1a2733;
    color: #e8edf2;
}

body.theme-dark .modal-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

/* Form inputs */
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .text-input {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

/* Filter select & inputs dark mode */
body.theme-dark .filter-select {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238899a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 10px;
}

body.theme-dark .filter-select:hover,
body.theme-dark .filter-select:focus {
    border-color: #1da1f2;
}

body.theme-dark .vehicle-dropdown-trigger {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .vehicle-dropdown-trigger:hover {
    border-color: #1da1f2;
}

body.theme-dark .vehicle-dropdown-trigger .trigger-text {
    color: #e8edf2;
}

body.theme-dark .vehicle-dropdown-trigger .trigger-text.placeholder {
    color: #5c7080;
}

/* Panels + no-data */
body.theme-dark .no-data {
    color: #5c7080;
}

body.theme-dark .vehicle-group-content {
    background: #1a2733;
}

/* List header */
body.theme-dark .list-header {
    background: #0f1923;
    color: #8899a6;
}

/* Vehicle dropdown */
body.theme-dark .vehicle-dropdown-menu {
    background: #1a2733;
    border-color: #2a3f52;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

body.theme-dark .vehicle-dropdown-search {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .vehicle-dropdown-search input {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .vehicle-dropdown-group-label {
    background: #0f1923;
    color: #1da1f2;
}

body.theme-dark .vehicle-dropdown-group-label:hover {
    background: #1a2733;
}

body.theme-dark .vehicle-dropdown-item {
    color: #e8edf2;
}

body.theme-dark .vehicle-dropdown-item:hover {
    background: #243647;
}

body.theme-dark .vehicle-dropdown-item.highlighted,
body.theme-dark .vehicle-dropdown-item.selected {
    background: rgba(33, 150, 243, 0.15);
}

/* History playback & items */
body.theme-dark .history-playback {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .history-item {
    border-bottom-color: #2a3f52;
}

body.theme-dark .history-item:hover {
    background: #243647;
}

body.theme-dark .history-item.selected {
    background: rgba(33, 150, 243, 0.15);
}

body.theme-dark .history-load-more {
    background: #1a2733;
}

body.theme-dark .playback-admin-timing-mariadb {
    background: rgba(30, 136, 229, 0.12);
    border-color: rgba(30, 136, 229, 0.35);
}

body.theme-dark .playback-admin-timing-postgres {
    background: rgba(230, 126, 34, 0.12);
    border-color: rgba(230, 126, 34, 0.35);
}

/* Playback btn active */
body.theme-dark .playback-btn {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #8899a6;
}

body.theme-dark .playback-btn.active {
    background: rgba(33, 150, 243, 0.15);
    border-color: #1da1f2;
    color: #1da1f2;
}

/* Events/Places headers */
body.theme-dark .events-header,
body.theme-dark .places-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

/* Filter buttons */
body.theme-dark .filter-btn {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .filter-btn:hover {
    background: #243647;
}

body.theme-dark .filter-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

body.theme-dark .modal-footer {
    border-top-color: #2a3f52;
}

body.theme-dark .modal-body {
    color: #e8edf2;
}

/* IO Config Modal */
body.theme-dark .io-config-modal {
    background: #1a2733;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

body.theme-dark .io-config-modal .modal-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .io-config-modal .modal-header h3 {
    color: #e8edf2;
}

body.theme-dark .io-config-modal .modal-close {
    background: #1e2d3d;
    color: #8899a6;
}

body.theme-dark .io-config-modal .modal-close:hover {
    background: #243647;
    color: #e8edf2;
}

body.theme-dark .io-config-modal .io-config-desc {
    color: #5c7080;
}

body.theme-dark .io-config-modal .filter-label {
    color: #8899a6;
}

body.theme-dark .io-config-modal .text-input,
body.theme-dark .io-config-modal select.text-input,
body.theme-dark .io-config-modal input.text-input {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .io-config-modal .text-input:focus,
body.theme-dark .io-config-modal select.text-input:focus {
    background: #243647;
}

body.theme-dark .io-config-modal .modal-footer {
    border-top-color: #2a3f52;
}

body.theme-dark .io-config-modal .filter-btn {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .io-config-modal .filter-btn.primary {
    background: #0ea5e9;
    color: white;
    border-color: transparent;
}

body.theme-dark .io-config-modal .cal-modal-panel {
    border-color: #2a3f52;
    background: #1e2d3d;
}

body.theme-dark .io-config-modal .io-calibration-header h5 {
    color: #e8edf2;
}

body.theme-dark .io-config-modal .io-calibration-desc {
    color: #5c7080;
}

body.theme-dark .io-config-modal .io-calibration-table {
    border-color: #2a3f52;
    background: #1a2733;
}

body.theme-dark .io-config-modal .io-calibration-table-head {
    background: #1a2733;
    color: #5c7080;
    border-bottom-color: #2a3f52;
}

body.theme-dark .io-config-modal .io-calibration-table-body .inline-row {
    background: #1a2733;
    border-bottom-color: #2a3f52;
}

body.theme-dark .io-config-modal .io-calibration-table-body .inline-row:hover {
    background: #1e2d3d;
}

body.theme-dark .io-config-modal .io-calibration-table-body .inline-row input.row-x,
body.theme-dark .io-config-modal .io-calibration-table-body .inline-row input.row-y {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .io-config-modal .io-calibration-table-body .inline-row input.row-x:focus,
body.theme-dark .io-config-modal .io-calibration-table-body .inline-row input.row-y:focus {
    background: #243647;
}

body.theme-dark .io-config-modal .io-calibration-table-body .inline-row input.row-x:disabled,
body.theme-dark .io-config-modal .io-calibration-table-body .inline-row input.row-y:disabled {
    color: #5c7080;
    background: transparent;
}

body.theme-dark .io-config-modal .inline-cal-edit,
body.theme-dark .io-config-modal .inline-cal-delete {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .io-config-modal .inline-cal-edit:hover {
    border-color: #1da1f2;
    color: #1da1f2;
}

body.theme-dark .io-config-modal .inline-cal-delete:hover {
    border-color: #e0245e;
    color: #e0245e;
    background: rgba(224, 36, 94, 0.1);
}

body.theme-dark .io-config-modal .io-calibration-controls label {
    color: #8899a6;
}

body.theme-dark .io-config-modal #modal-inline-cal-method {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .io-config-modal #modal-inline-cal-formula {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .io-config-modal #modal-inline-cal-formula:focus {
    border-color: #1da1f2;
    background: #243647;
}

body.theme-dark .io-config-modal .io-calibration-actions-row {
    border-top-color: #2a3f52;
}

body.theme-dark .io-config-modal .io-calibration-actions-row .filter-btn {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #8899a6;
}

body.theme-dark .io-config-modal .io-calibration-actions-row .filter-btn:hover {
    background: #243647;
    border-color: #3a5268;
}

body.theme-dark .io-config-modal .io-calibration-list {
    color: #5c7080;
}

/* Dictionary panel dark mode */
body.theme-dark .io-config-modal .dict-modal-panel {
    border-color: #2a3f52;
    background: #1e2d3d;
}

body.theme-dark .io-config-modal .io-dict-header h5 {
    color: #e8edf2;
}

body.theme-dark .io-config-modal .io-dict-desc {
    color: #5c7080;
}

body.theme-dark .io-config-modal .io-dict-table {
    border-color: #2a3f52;
    background: #1a2733;
}

body.theme-dark .io-config-modal .io-dict-table-head {
    background: #1a2733;
    color: #5c7080;
    border-bottom-color: #2a3f52;
}

body.theme-dark .io-config-modal .io-dict-table-body .dict-row {
    background: #1a2733;
    border-bottom-color: #2a3f52;
}

body.theme-dark .io-config-modal .io-dict-table-body .dict-row:hover {
    background: #1e2d3d;
}

body.theme-dark .io-config-modal .io-dict-table-body .dict-row input {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .io-config-modal .io-dict-table-body .dict-row input:focus {
    background: #243647;
    border-color: #1da1f2;
    box-shadow: 0 0 0 3px rgba(29, 161, 242, 0.15);
}

body.theme-dark .io-config-modal .io-dict-table-body .dict-row .dict-remove-btn {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #5c7080;
}

body.theme-dark .io-config-modal .io-dict-table-body .dict-row .dict-remove-btn:hover {
    border-color: rgba(224, 36, 94, 0.4);
    color: #e0245e;
    background: rgba(224, 36, 94, 0.1);
}

body.theme-dark .io-config-modal .io-dict-table-body .no-dict-data {
    color: #5c7080;
}

body.theme-dark .io-config-modal .io-calibration-table-body .no-cal-data {
    color: #5c7080;
}

body.theme-dark .io-config-modal .io-dict-actions-row {
    border-top-color: #2a3f52;
}

body.theme-dark .io-config-modal .io-dict-actions-row .filter-btn {
    border-color: #2a3f52;
    background: #1e2d3d;
    color: #8899a6;
}

body.theme-dark .io-config-modal .io-dict-actions-row .filter-btn:hover {
    background: #243647;
    border-color: #3a5268;
}

/* Drawer header */
body.theme-dark .drawer-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .drawer-title {
    color: #e8edf2;
}

/* Signal groups */
body.theme-dark .signal-group-header {
    background: linear-gradient(135deg, #1a2733, #1e2d3d);
    border-bottom-color: #2a3f52;
}

body.theme-dark .signal-item {
    border-bottom-color: #2a3f52;
}

/* Data tables */
body.theme-dark .data-table {
    background: #1a2733;
}

body.theme-dark .data-table tbody tr:hover:not(.data-separator) {
    background-color: #243647;
}

body.theme-dark .data-row td {
    border-bottom-color: #2a3f52;
}

body.theme-dark .data-key {
    background-color: #0f1923;
    color: #e8edf2;
}

body.theme-dark .vehicle-info .data-key {
    background-color: rgba(33, 150, 243, 0.12);
    color: #1da1f2;
}

body.theme-dark .io-data .data-key {
    background-color: rgba(120, 86, 255, 0.12);
    color: #a78bfa;
}

body.theme-dark .data-separator td {
    background-color: #0f1923;
    border-bottom-color: #2a3f52;
}

/* Graph toolbar */
body.theme-dark .graph-toolbar {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

/* Calibration items */
body.theme-dark .inline-cal-item {
    background-color: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .inline-cal-item:hover {
    background-color: #243647;
    border-color: #3a5268;
}

body.theme-dark .inline-cal-delete,
body.theme-dark .inline-cal-edit {
    background-color: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark #modal-inline-cal-method:disabled,
body.theme-dark #modal-inline-cal-formula:disabled {
    background-color: #1a2733;
    color: #5c7080;
    border-color: #2a3f52;
}

/* IO table */
body.theme-dark .io-table-wrapper {
    border-color: #2a3f52;
}

body.theme-dark .io-table thead th {
    background: #0f1923;
    border-bottom-color: #2a3f52;
    color: #8899a6;
}

body.theme-dark .io-table thead th:first-child {
    border-right-color: #2a3f52;
}

body.theme-dark .io-table tbody td {
    border-bottom-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .io-table tbody td:first-child {
    background: #1a2733;
    border-right-color: #2a3f52;
}

body.theme-dark .io-table tbody tr:hover,
body.theme-dark .io-table tbody tr:hover td:first-child {
    background-color: #243647;
}

/* Datalist items */
body.theme-dark .datalist-item-list {
    background: #1a2733;
}

body.theme-dark .datalist-item {
    border-bottom-color: #2a3f52;
}

body.theme-dark .datalist-item.even {
    background-color: #1a2733;
}

body.theme-dark .datalist-item.odd {
    background-color: #1e2d3d;
}

body.theme-dark .datalist-item:hover {
    background-color: #243647;
}

body.theme-dark .datalist-item-icon {
    color: #8899a6;
}

/* Settings section */
body.theme-dark .settings-section {
    background: #0f1923;
    border-color: #2a3f52;
}

body.theme-dark .settings-section h4 {
    color: #e8edf2;
}

body.theme-dark .text-readonly {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #8899a6;
}

body.theme-dark .toggle-slider {
    background: #2a3f52;
}

body.theme-dark .toggle-label {
    color: #e8edf2;
}

body.theme-dark .filter-label {
    color: #8899a6;
}

/* Object Properties sidebar */
body.theme-dark .op-sidebar {
    background: #1a2733;
    border-right-color: #2a3f52;
}

body.theme-dark .op-sidebar-header {
    border-bottom-color: #2a3f52;
}

body.theme-dark .op-vehicle-info {
    background: linear-gradient(135deg, #1e2d3d, #243647);
    border-left-color: #1da1f2;
}

body.theme-dark .op-vehicle-name {
    color: #e8edf2;
}

body.theme-dark .op-vehicle-imei {
    color: #5c7080;
}

/* OP panel titles and labels */
body.theme-dark .op-title {
    color: #e8edf2;
}

body.theme-dark .op-nav-item {
    color: #8899a6;
}

body.theme-dark .op-nav-item:hover {
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .op-nav-item.active {
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .op-content {
    background: #1a2733;
}

body.theme-dark .op-close-btn,
body.theme-dark .op-close-btn-inline {
    background: #1e2d3d;
    color: #8899a6;
}

body.theme-dark .op-close-btn:hover,
body.theme-dark .op-close-btn-inline:hover {
    background: #243647;
    color: #e8edf2;
}

body.theme-dark .op-section-header-fixed {
    border-bottom-color: #2a3f52;
}

body.theme-dark .op-section-header-content h2,
body.theme-dark .op-section-header h2 {
    color: #e8edf2;
}

body.theme-dark .op-section-desc {
    color: #5c7080;
}

body.theme-dark .op-vehicle-badge {
    background: rgba(29, 161, 242, 0.08);
    border-color: #2a3f52;
}

body.theme-dark .op-vehicle-badge span:first-child {
    color: #1da1f2;
}

body.theme-dark .op-imei {
    color: #5c7080;
}

body.theme-dark .op-tabs {
    background: #0f1923;
}

body.theme-dark .op-tab {
    color: #8899a6;
}

body.theme-dark .op-tab:hover {
    color: #e8edf2;
}

body.theme-dark .op-tab.active {
    background: #1e2d3d;
    color: #e8edf2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body.theme-dark .op-label {
    color: #8899a6;
}

body.theme-dark .op-input {
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .op-input:focus {
    background: #243647;
}

body.theme-dark .op-input:read-only {
    background: #1e2d3d;
    color: #5c7080;
}

body.theme-dark .op-form-section-divider {
    border-top-color: #2a3f52;
}

body.theme-dark .op-card {
    background: #1e2d3d;
    border-color: #2a3f52;
}

body.theme-dark .op-card-header {
    background: #0f1923;
    border-bottom-color: #2a3f52;
}

body.theme-dark .op-card-header h3 {
    color: #e8edf2;
}

body.theme-dark .op-io-item {
    border-bottom-color: #2a3f52;
}

body.theme-dark .op-io-item:hover {
    background: #243647;
}

body.theme-dark .op-io-key {
    color: #e8edf2;
}

body.theme-dark .op-io-value {
    color: #8899a6;
}

body.theme-dark .op-io-note {
    color: #5c7080;
}

body.theme-dark .op-mapping-item {
    border-bottom-color: #2a3f52;
}

body.theme-dark .op-mapping-item:hover {
    background: #243647;
}

body.theme-dark .op-mapping-name {
    color: #e8edf2;
}

body.theme-dark .op-mapping-details {
    color: #8899a6;
}

body.theme-dark .op-btn-secondary {
    background: #1e2d3d;
    color: #e8edf2;
    border-color: #2a3f52;
}

body.theme-dark .op-btn-secondary:hover {
    background: #243647;
}

body.theme-dark .op-btn-outline {
    background: #1e2d3d;
    border-color: #2a3f52;
    color: #e8edf2;
}

body.theme-dark .op-btn-outline:hover {
    background: #243647;
    border-color: #3a5268;
}

body.theme-dark .op-footer {
    border-top-color: #2a3f52;
}

body.theme-dark .op-section-scroll::-webkit-scrollbar-thumb,
body.theme-dark .op-form-scrollable::-webkit-scrollbar-thumb {
    background: #3a5268;
}

body.theme-dark .op-section-scroll::-webkit-scrollbar-thumb:hover,
body.theme-dark .op-form-scrollable::-webkit-scrollbar-thumb:hover {
    background: #4a6a85;
}

body.theme-dark #settingsModal .op-section-scroll::-webkit-scrollbar-track {
    background: #1a2d3d;
    border-radius: 4px;
}

body.theme-dark #settingsModal .op-section-scroll::-webkit-scrollbar-thumb {
    background: #3a5268;
    border-radius: 4px;
}

body.theme-dark #settingsModal .op-section-scroll::-webkit-scrollbar-thumb:hover {
    background: #4a6a85;
}

body.theme-dark .op-btn-configure,
body.theme-dark .op-btn-calibrate {
    background: rgba(23, 191, 99, 0.1);
    border-color: rgba(23, 191, 99, 0.2);
    color: #17bf63;
}

body.theme-dark .op-btn-settings {
    background: rgba(29, 161, 242, 0.1);
    border-color: rgba(29, 161, 242, 0.2);
    color: #1da1f2;
}

body.theme-dark .op-btn-delete {
    background: rgba(224, 36, 94, 0.1);
    border-color: rgba(224, 36, 94, 0.2);
    color: #e0245e;
}

body.theme-dark .op-btn-calibrate:disabled {
    background: #1a2733;
    color: #5c7080;
    border-color: #2a3f52;
}

/* Badge overlay colors in dark mode — transparent overlays with original hue */
body.theme-dark .op-mapping-type.fuel {
    background: rgba(29, 78, 216, 0.15);
    color: #60a5fa;
}

body.theme-dark .op-mapping-type.odometer {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

body.theme-dark .op-mapping-type.voltage {
    background: rgba(21, 128, 61, 0.15);
    color: #4ade80;
}

body.theme-dark .op-mapping-type.ignition {
    background: rgba(194, 65, 12, 0.15);
    color: #fb923c;
}

body.theme-dark .op-mapping-type.temperature {
    background: rgba(185, 28, 28, 0.15);
    color: #f87171;
}

body.theme-dark .op-mapping-type.door {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
}

body.theme-dark .op-mapping-type.custom {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

body.theme-dark .op-sensor-badge {
    background: rgba(21, 128, 61, 0.12);
    border-color: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

body.theme-dark .op-sensor-badge.disabled {
    background: rgba(185, 28, 28, 0.12);
    border-color: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

body.theme-dark .mapping-type.fuel {
    background: rgba(29, 78, 216, 0.15);
    color: #60a5fa;
}

body.theme-dark .mapping-type.odometer {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

body.theme-dark .mapping-type.voltage {
    background: rgba(21, 128, 61, 0.15);
    color: #4ade80;
}

body.theme-dark .mapping-type.ignition {
    background: rgba(194, 65, 12, 0.15);
    color: #fb923c;
}

body.theme-dark .mapping-type.temperature {
    background: rgba(185, 28, 28, 0.15);
    color: #f87171;
}

body.theme-dark .mapping-type.door {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
}

body.theme-dark .mapping-type.custom {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

body.theme-dark .sensor-badge {
    background: rgba(29, 161, 242, 0.15);
    color: #60a5fa;
}

body.theme-dark .sensor-badge.enabled {
    background: rgba(21, 128, 61, 0.15);
    color: #4ade80;
}

body.theme-dark .sensor-badge.disabled {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

/* Object Properties Panel base */
body.theme-dark .object-properties-panel {
    background: #1a2733;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Settings Table - dark theme */
body.theme-dark .settings-table-header {
    border-bottom-color: #2a3f52;
}

body.theme-dark .settings-search i {
    color: #5c7080;
}

body.theme-dark .settings-table {
    background: #1a2733;
    border-color: #2a3f52;
}

body.theme-dark .settings-table thead {
    background: #0f1923;
}

body.theme-dark .settings-table th {
    color: #8899a6;
    border-bottom-color: #2a3f52;
}

body.theme-dark .settings-table tbody tr:hover {
    background: #243647;
}

body.theme-dark .settings-table tbody tr:not(:last-child) td {
    border-bottom-color: #2a3f52;
}

body.theme-dark .settings-table td {
    color: #e8edf2;
}

body.theme-dark .status-badge.active {
    background: rgba(23, 191, 99, 0.15);
    color: #17bf63;
}

body.theme-dark .status-badge.inactive {
    background: rgba(224, 36, 94, 0.15);
    color: #e0245e;
}

body.theme-dark .action-btn {
    color: #8899a6;
}

body.theme-dark .action-btn:hover {
    background: #1e2d3d;
    color: #e8edf2;
}

body.theme-dark .bp-ctrl-btn.active {
    background: rgba(29, 161, 242, 0.22);
    color: #1da1f2;
    box-shadow: inset 0 0 0 1px rgba(29, 161, 242, 0.55);
}

body.theme-dark .action-btn.follow-btn.follow-active {
    background: rgba(29, 161, 242, 0.18);
    color: #1da1f2;
}

body.theme-dark .settings-table input[type="checkbox"] {
    accent-color: #1da1f2;
}

/* ---- Light theme explicit overrides ---- */
body.theme-light {
    --background-color: #f5f5f5;
    --surface-color: #ffffff;
    --surface-hover: #f0f2f5;
    --selected-bg: rgba(33, 150, 243, 0.08);
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --scrollbar-thumb-hover: #a1a1a1;
    background: #f5f5f5;
    color: #333333;
}

body.theme-light .top-nav {
    background: #ffffff;
}

body.theme-light .sidebar {
    background: #ffffff;
}

body.theme-light .sidebar-header {
    background: #fafafa;
}

body.theme-light .filter-tabs {
    background: #fafafa;
}

body.theme-light .event-panel {
    background: #ffffff;
}

body.theme-light .event-panel-header {
    background: #fafafa;
}

body.theme-light .vehicle-group-header {
    background: #f8f9fa;
    color: #2c3e50;
}

body.theme-light .vehicle-group-header:hover {
    background: #eceff1;
}

/* ---- Responsive for bottom panel ---- */
@media (max-width: 900px) {
    .bp-data-layout {
        flex-direction: column;
    }
    .bp-status-summary {
        width: 100%;
        flex-direction: row;
        padding: 10px;
    }
    .bp-speed-gauge {
        width: 60px;
        height: 60px;
    }
    .bp-speed-number { font-size: 18px; }
    .bp-data-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 600px) {
    .bp-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .bp-header {
        flex-wrap: wrap;
    }
    .bp-data-grid, .bp-sensors-grid, .bp-raw-data-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─────────────────────────────────────────────
   Modern Tooltip System
   ───────────────────────────────────────────── */
.modern-tooltip {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
    letter-spacing: 0.01em;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(6px) scale(0.97);
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    /* Light theme default — dark tooltip on light background */
    background: #1e1e1e;
    color: #f0f0f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), 0 1.5px 4px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.modern-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Tooltip arrow */
.modern-tooltip::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: inherit;
    border-radius: 1.5px;
    transform: rotate(45deg);
}

/* Arrow position: bottom (tooltip is above element) */
.modern-tooltip.arrow-bottom::after {
    bottom: -4px;
    left: 50%;
    margin-left: -4px;
}

/* Arrow position: top (tooltip is below element) */
.modern-tooltip.arrow-top::after {
    top: -4px;
    left: 50%;
    margin-left: -4px;
}

/* Dark theme — light tooltip on dark background */
body.theme-dark .modern-tooltip,
body:not(.theme-light) .modern-tooltip {
    background: #f5f5f5;
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32), 0 1.5px 4px rgba(0, 0, 0, 0.18);
}

/* Light theme explicit override (when class is set) */
body.theme-light .modern-tooltip {
    background: #1e1e1e;
    color: #f0f0f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), 0 1.5px 4px rgba(0, 0, 0, 0.12);
}
