: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;
    justify-content: space-between;
}

.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-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;
}

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

.object-select {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    padding: 0.45rem 2rem 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    max-width: 260px;
    appearance: none;
}

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

.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;
    display: flex;
    flex-direction: column;
}

.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;
}

.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;
}

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

/* 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; }
}

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

    .nav-links {
        display: none;
    }

    .nav-links.mobile-active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 64px;
        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;
    }

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

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

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

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