:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --radius: 10px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Navigation */
.header {
    background: #0f172a;
    color: #ffffff;
    border-bottom: 1px solid #1e293b;
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #ffffff;
}

.logo-badge {
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: white;
}

.logo-img {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-img-login {
    width: 48px;
    height: 48px;
    border-radius: 11px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-sub {
    font-size: 0.75rem;
    color: #94a3b8;
    display: block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-item {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
}

.nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    color: #ffffff;
    background: #2563eb;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.header-object-area {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
}

.object-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.object-select {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    padding: 0.35rem 1.8rem 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    width: 250px;
    max-width: 250px;
    appearance: none;
    transition: all 0.2s ease;
}

.object-select:disabled {
    background: #182232;
    border-color: #243042;
    color: #cbd5e1;
    cursor: default;
    opacity: 0.9;
}

.object-select-arrow {
    position: absolute;
    right: 0.65rem;
    pointer-events: none;
    color: #94a3b8;
    font-size: 0.75rem;
}

.object-select:disabled + .object-select-arrow {
    opacity: 0.35;
}

.header-tariff-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tariff-badge-icon {
    font-size: 0.95rem;
}

.tariff-badge-name {
    font-weight: 700;
}

.tariff-badge-end {
    font-size: 0.76rem;
    opacity: 0.85;
}

/* Tariff themes in dark header */
.header-tariff-badge.tariff-badge-full {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.4);
}

.header-tariff-badge.tariff-badge-lite {
    background: rgba(14, 165, 233, 0.15);
    color: #7dd3fc;
    border-color: rgba(14, 165, 233, 0.4);
}

.header-tariff-badge.tariff-badge-readonly {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.4);
}

.header-tariff-badge.tariff-badge-expired {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.5);
}

/* Alert banners in view cards */
.tariff-alert-banner {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.86rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.tariff-alert-banner.banner-readonly {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    color: #92400e;
}

.tariff-alert-banner.banner-readonly svg {
    color: #d97706;
    flex-shrink: 0;
}

.tariff-alert-banner.banner-lite {
    background: #f0f9ff;
    border: 1px solid #e0f2fe;
    color: #0369a1;
}

.tariff-alert-banner.banner-lite svg {
    color: #0284c7;
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding-left: 0.5rem;
    border-left: 1px solid #334155;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #334155;
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-info-text {
    line-height: 1.2;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #f8fafc;
}

.user-role-badge {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: #7c3aed;
    color: white;
}

.role-user {
    background: #0ea5e9;
    color: white;
}

.role-manager {
    background: #4f46e5;
    color: white;
}

.btn-logout {
    background: transparent;
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-logout:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* Mobile Toggle */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Main Container */
.main-content {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1.25rem;
    flex: 1;
    width: 100%;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

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

/* Common Card */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: 8px;
}

.filter-input, .filter-select {
    padding: 0.5rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.88rem;
    outline: none;
    background: white;
    color: var(--text-main);
}

.filter-input:focus, .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-box input {
    width: 100%;
    padding-left: 2.2rem;
}

.search-box-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: #e2e8f0;
    color: #334155;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.custom-table th {
    background: #f8fafc;
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.custom-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background-color: #f8fafc;
}

/* License Plate Visual Pill - Kazakhstan Format */
.plate-badge {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid #0f172a;
    border-radius: 4px;
    background: #ffffff;
    color: #0f172a;
    font-family: 'Arial Black', Impact, sans-serif;
    font-weight: 900;
    font-size: 0.95rem;
    letter-spacing: 1.5px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    user-select: none;
    overflow: hidden;
    height: 32px;
}

.plate-badge-main {
    padding: 0 8px;
    font-size: 0.98rem;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

/* Diplomatic Plates: Red background, white text, no KZ box */
.plate-badge-diplo {
    background: #dc2626 !important;
    border-color: #991b1b !important;
    color: #ffffff !important;
}

.plate-badge-diplo .plate-badge-main {
    color: #ffffff !important;
}

/* Non-resident Plates: Yellow background, black text */
.plate-badge-nonresident {
    background: #facc15 !important;
    border-color: #0f172a !important;
    color: #0f172a !important;
}

.plate-badge-nonresident .plate-badge-main {
    color: #0f172a !important;
}

.plate-badge-nonresident .plate-badge-kz {
    background: #facc15 !important;
    border-left-color: #0f172a !important;
}

.plate-badge-nonresident .plate-kz-text,
.plate-badge-nonresident .plate-badge-region {
    color: #0f172a !important;
}

.plate-badge-kz {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-left: 1.5px solid #0f172a;
    padding: 2px 5px;
    background: #ffffff;
    min-width: 34px;
    height: 100%;
    box-sizing: border-box;
}

.plate-badge-country {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 1px;
}

.plate-flag-kz {
    width: 11px;
    height: 6px;
    background: #00afca;
    border-radius: 1px;
    position: relative;
    display: inline-block;
}

.plate-flag-kz::after {
    content: '';
    position: absolute;
    width: 2.5px;
    height: 2.5px;
    border-radius: 50%;
    background: #facc15;
    top: 1.7px;
    left: 4px;
}

.plate-kz-text {
    font-size: 0.58rem;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: 0.5px;
    line-height: 1;
}

.plate-badge-region {
    font-size: 0.92rem;
    font-weight: 900;
    line-height: 1;
    color: #0f172a;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-whiteList {
    background: var(--success-bg);
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge-blackList {
    background: var(--danger-bg);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.badge-unknown {
    background: var(--warning-bg);
    color: #b45309;
    border: 1px solid #fde68a;
}

.badge-online {
    background: #ecfdf5;
    color: #047857;
}

.badge-offline {
    background: #fef2f2;
    color: #b91c1c;
}

/* Thumbnail Photo in Reports */
.report-thumb {
    width: 80px;
    height: 50px;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    object-fit: cover;
    background: #0f172a;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.report-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Sub-tabs in Admin */
.subtabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.subtab-btn {
    background: transparent;
    border: none;
    padding: 0.65rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.subtab-btn:hover {
    color: var(--primary);
}

.subtab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.subtab-content {
    display: none;
}

.subtab-content.active {
    display: block;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
}

.modal-card form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-card-lg {
    max-width: 820px;
}

.modal-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
    flex-shrink: 0;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    background: white;
    transition: border 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > * {
    flex: 1;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border);
    padding: 0.65rem;
    border-radius: 6px;
    background: #f8fafc;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    cursor: pointer;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: 380px;
}

.toast {
    background: white;
    border-left: 4px solid var(--primary);
    border-radius: 6px;
    padding: 0.85rem 1.1rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    animation: slideIn 0.25s ease;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.btn-text-mobile,
.nav-logout-mobile {
    display: none;
}

/* Responsive Media Queries */
@media (max-width: 900px) {
    .header-container {
        padding: 0 1rem;
    }

    .header-right .btn-logout {
        display: none !important;
    }

    .user-profile {
        border-left: none;
        padding-left: 0;
    }

    .nav-links {
        display: none;
    }

    .nav-links.mobile-active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #0f172a;
        padding: 1rem;
        border-bottom: 1px solid #334155;
        gap: 0.5rem;
        z-index: 50;
    }

    .nav-item {
        width: 100%;
        padding: 0.75rem;
    }

    .nav-logout-mobile {
        display: flex !important;
        align-items: center;
        gap: 0.65rem;
        color: #ef4444 !important;
        border-top: 1px solid #334155;
        margin-top: 0.5rem;
        padding: 0.75rem;
        font-weight: 600;
        cursor: pointer;
    }

    .nav-logout-mobile:hover {
        background: rgba(239, 68, 68, 0.15) !important;
        color: #f87171 !important;
    }

    .mobile-menu-btn {
        display: block;
    }

    .user-info-text {
        display: none;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (max-width: 768px) {
    /* 1. Header: Stack system title and object switcher vertically */
    .header-container {
        height: auto;
        min-height: auto;
        padding: 0.75rem 1rem;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 0.65rem;
        column-gap: 0.5rem;
        align-items: center;
    }

    .logo-area {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        min-width: 0;
    }

    .header-right {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        margin-left: 0;
        justify-self: end;
        flex-shrink: 0;
    }

    .header-object-area {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .object-select-wrapper {
        width: 100%;
    }

    .object-select {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .header-tariff-badge {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        justify-content: center;
        padding: 0.3rem 0.5rem;
        font-size: 0.78rem;
    }

    /* 2. Filter Bar: Equal width for search, select and buttons strictly inside container */
    .filter-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 0.75rem !important;
        gap: 0.65rem;
    }

    .filter-bar > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .filter-bar .search-box {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .filter-bar .search-box input,
    .filter-bar .filter-input,
    .filter-bar .filter-select,
    .filter-bar .btn {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Card & Container Spacing */
    .main-content {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }

    .card {
        padding: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .card-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* 3. Table: Multi-line row card display without horizontal scroll */
    .table-responsive {
        overflow-x: visible;
        width: 100%;
        max-width: 100%;
    }

    .custom-table,
    .custom-table tbody {
        display: block;
        width: 100%;
    }

    .custom-table thead {
        display: none;
    }

    .custom-table tr.plate-row,
    .custom-table tr.report-row {
        display: block;
        width: 100%;
        margin-bottom: 1rem;
        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        padding: 0.85rem 1rem;
        box-sizing: border-box;
    }

    .custom-table tr.plate-row td,
    .custom-table tr.report-row td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.45rem 0;
        border-bottom: 1px dashed #f1f5f9;
        font-size: 0.88rem;
        text-align: right;
        width: 100%;
        box-sizing: border-box;
    }

    .custom-table tr.plate-row td > div,
    .custom-table tr.plate-row td > span,
    .custom-table tr.report-row td > div,
    .custom-table tr.report-row td > span {
        text-align: right;
        word-break: break-word;
        max-width: 65%;
    }

    /* Hide camera details and remarks in mobile card view */
    .camera-sub-info,
    .remark-sub-info {
        display: none !important;
    }

    .custom-table tr.plate-row td:last-child,
    .custom-table tr.report-row td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .custom-table tr.plate-row td::before,
    .custom-table tr.report-row td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        font-size: 0.8rem;
        text-align: left;
        margin-right: 0.75rem;
        flex-shrink: 0;
    }

    .custom-table tr.plate-row td.cell-plate,
    .custom-table tr.report-row td.cell-report-plate {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0.35rem 0 0.75rem 0;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 0.25rem;
    }

    .custom-table tr.plate-row td.cell-plate::before,
    .custom-table tr.report-row td.cell-report-plate::before {
        display: none;
    }

    .custom-table tr.plate-row td.cell-actions {
        display: flex;
        justify-content: stretch;
        gap: 0.5rem;
        padding-top: 0.75rem;
        margin-top: 0.35rem;
        border-top: 1px solid #f1f5f9;
        border-bottom: none;
    }

    .custom-table tr.plate-row td.cell-actions::before {
        display: none;
    }

    .custom-table tr.plate-row td.cell-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.82rem;
    }

    .btn-text-mobile {
        display: inline;
        margin-left: 0.35rem;
    }

    .custom-table tr td[colspan] {
        display: block;
        width: 100%;
        text-align: center;
        padding: 2rem 1rem;
    }

    .custom-table tr td[colspan]::before {
        display: none;
    }

    /* 4. Modals: Vertical scroll and pinned footer on mobile */
    .modal-overlay {
        padding: 0.5rem;
        align-items: center;
    }

    .modal-card {
        max-height: 88vh;
        max-height: 88dvh;
        width: 100%;
        margin: auto;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .modal-card form {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .modal-header {
        padding: 0.85rem 1rem;
        flex-shrink: 0;
    }

    .modal-title {
        font-size: 1.05rem;
    }

    .modal-body {
        padding: 1rem;
        flex: 1;
        min-height: 0;
        max-height: calc(88dvh - 130px);
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-shrink: 0;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100% !important;
        justify-content: center;
    }
}

/* =========================================================
   STATISTICS MODULE
   ========================================================= */

.stats-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1.25rem;
}

.stats-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.stats-preset-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.stats-date-inputs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.stats-date-field {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stats-date-field .form-input {
    width: auto;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.stats-top-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.2fr) minmax(260px, 1.2fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.stats-kpi-card,
.stats-gauge-card,
.stats-chart-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.stats-kpi-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    border-color: #dbeafe;
}

.stats-kpi-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stats-kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.1;
    margin-bottom: 0.45rem;
}

.stats-kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-gauge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stats-gauge-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text);
}

.stats-gauge-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    margin-bottom: 0.6rem;
}

.stats-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 260px;
}

.stats-gauge-container svg {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 220 / 128;
    flex-shrink: 0;
}

.stats-gauge-facts {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-gauge-fact {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stats-gauge-fact strong {
    font-size: 0.95rem;
    color: var(--text);
}

.stats-chart-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stats-chart-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.stats-chart-subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.stats-chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.stats-chart-tabs {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stats-chart-tab {
    border: none;
    background: transparent;
    padding: 0.4rem 0.75rem;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.stats-chart-tab.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    font-weight: 600;
}

.stats-month-picker .form-input {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    width: auto;
}

.stats-bar-chart {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.stats-bar-svg {
    display: block;
    width: 100%;
    min-width: 560px;
    height: auto;
}

.stats-bar-rect {
    transition: opacity 0.15s ease;
    cursor: pointer;
}

.stats-bar-rect:hover {
    opacity: 0.82;
}

@media (max-width: 992px) {
    .stats-top-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-date-inputs {
        width: 100%;
    }

    .stats-date-field {
        flex: 1;
    }

    .stats-date-field .form-input {
        width: 100%;
    }

    .stats-chart-tabs {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-chart-tab {
        text-align: center;
        padding: 0.45rem 0.35rem;
        font-size: 0.78rem;
    }
}
