:root {
    --sec-bg: #f1f5f9;
    --sec-surface: #ffffff;
    --sec-primary: #2563eb;
    --sec-accent: #f59e0b;
    --sec-danger: #ef4444;
    --sec-text: #1e293b;
    --sec-text-light: #64748b;
    --font-main: 'Be Vietnam Pro', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background-color: var(--sec-bg);
    height: 100vh;
    overflow: hidden;
    color: var(--sec-text);
}

/* --- LAYOUT --- */
.sec-header {
    height: 60px;
    background: var(--sec-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 10;
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    height: 32px;
}

.brand-info h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--sec-primary);
}

.brand-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--sec-text-light);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #10b981;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    animation: pulse 2s infinite;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    /* Split Screen */
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* --- CAMERA ZONE (LEFT) --- */
.camera-zone {
    background-color: #000;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.camera-viewport {
    width: 100%;
    flex: 1;
    /* Allow it to fill the remaining vertical space */
    position: relative;
    overflow: hidden;
    background: black;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-viewport.scanned {
    animation: flashSuccess 0.3s ease-out;
}

.camera-viewport.error {
    animation: flashError 0.3s ease-out;
}

@keyframes flashSuccess {

    0%,
    100% {
        box-shadow: none;
    }

    50% {
        box-shadow: inset 0 0 50px rgba(16, 185, 129, 0.8);
    }
}

@keyframes flashError {

    0%,
    100% {
        box-shadow: none;
    }

    50% {
        box-shadow: inset 0 0 50px rgba(239, 68, 68, 0.8);
    }
}

.hud-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    /* Scan Area */
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    /* Dim outside */
    pointer-events: none;
    /* Allows clicking through the frame */
}

.hud-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--sec-primary);
    border-style: solid;
}

.hud-tl {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
}

.hud-tr {
    top: -2px;
    right: -2px;
    border-width: 4px 4px 0 0;
}

.hud-bl {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 4px 4px;
}

.hud-br {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
}

.hud-scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--sec-primary);
    box-shadow: 0 0 4px var(--sec-primary);
    animation: scanLine 2s linear infinite;
}

.camera-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    color: white;
}

.camera-title {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(4px);
}

.camera-controls {
    position: absolute;
    bottom: 2rem;
    z-index: 5;
}

/* --- RESULT CONSOLE (RIGHT) --- */
.result-console {
    background: var(--sec-bg);
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    overflow-y: auto;
}

.console-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.result-card-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Idle State */
.idle-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--sec-text-light);
    opacity: 0.6;
}

.radar-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: var(--sec-text-light);
}

/* --- VERIFICATION CARD (NEW PREMIUM STYLE) --- */
.verification-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    /* Soft Shadow */
    overflow: hidden;
    display: none;
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.verification-card.active {
    display: block;
}

/* Header with Gradient */
.v-header {
    background: #3b82f6;
    /* Solid Blue as per image */
    color: white;
    padding: 2rem 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plate-number {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-main);
    letter-spacing: 0.5px;
    margin: 0;
}

.v-status {
    align-self: flex-start;
    display: inline-block;
    padding: 6px 16px;
    background: #dcfce7;
    /* Light green */
    color: #166534;
    /* Dark green text */
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
}

.v-body {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.v-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #f1f5f9;
    padding-bottom: 1rem;
}

/* Special Location Layout */
.special-location {
    justify-content: flex-start;
    gap: 1.5rem;
    align-items: center;
}

.loc-icon-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--sec-text-light);
}

.loc-icon-group svg {
    width: 32px;
    height: 32px;
    stroke-width: 2px;
}

.special-location .v-label {
    font-size: 0.8rem;
}

.special-location .v-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--sec-text);
    line-height: 1.4;
}

.v-label {
    font-size: 0.9rem;
    color: var(--sec-text-light);
}

.v-value {
    font-weight: 600;
    font-size: 1rem;
}

.v-footer {
    background: #f8fafc;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--sec-text-light);
    border-top: 1px solid #e2e8f0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Alert Box */
.security-alert-box {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    gap: 12px;
    color: #ef4444;
}

.alert-icon {
    min-width: 24px;
}

.alert-title {
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.alert-content p {
    margin: 0;
    font-size: 0.9rem;
}

/* CCCD Specifics (Premium Redesign) */
.cccd-card .v-header {
    background: linear-gradient(135deg, #14b8a6, #0f766e);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cccd-card .plate-number {
    font-family: var(--font-main);
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: normal;
    text-transform: none;
    /* Keep natural casing */
    margin: 0;
    text-shadow: none;
}

.cccd-card .v-status {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 16px;
    border-radius: 99px;
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    margin-top: 8px;
}

.cccd-card .v-body {
    padding: 1.5rem 2rem;
    gap: 1.25rem;
}

.cccd-card .v-row {
    border-bottom: 2px dashed #f1f5f9;
    padding-bottom: 1rem;
}

.cccd-card .v-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
    flex-direction: column !important;
    /* Force override inline style if present */
    align-items: center;
    text-align: center;
    gap: 8px !important;
}

.cccd-card .v-row:last-child .v-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.cccd-card .v-row:last-child .v-value {
    font-size: 1.1rem;
    line-height: 1.5;
    font-weight: 600;
}

/* Start Screen */
#start-screen {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--sec-bg);
    /* Light background instead of dark overlay */
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1;
    /* Ensure it stays in the left column */
    border-right: 1px solid #e2e8f0;
    /* Separator for right panel */
}

.btn-large-start {
    background: var(--sec-primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s;
}

.btn-large-start:hover {
    transform: scale(1.05);
}

#btn-test-voice {
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Common Buttons */
.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.control-btn.btn-stop {
    background: rgba(239, 68, 68, 0.8);
    border-color: transparent;
}

/* Animations */
@keyframes scanLine {
    0% {
        top: 0;
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0.5;
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUpSpring {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Animations --- */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUpSpring {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* (Global Immersive styles removed to preserve Desktop Grid) */
/* Mobile Immersive styles are handled in the media query below */
/* --- RESPONSIVE MOBILE LAYOUT (Scoped to Scanning Mode) --- */
@media (max-width: 768px) {

    /* 1. LAYOUT RESET & IMMERSIVE PREP */
    body {
        position: fixed;
        /* Lock scroll on mobile */
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    .dashboard-grid {
        display: block !important;
        height: 100dvh !important;
        position: relative;
    }

    /* 2. HEADER (Floating Transparent Overlay) */
    .sec-header {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        min-height: 60px;
        z-index: 30;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%) !important;
        border: none;
        box-shadow: none;
        padding-top: env(safe-area-inset-top);
        pointer-events: none;
        /* Let touches pass through open space */
    }

    .brand-info,
    .header-controls {
        pointer-events: auto;
        /* Re-enable buttons */
    }

    .brand-info h1 {
        color: white !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    .brand-info p {
        color: rgba(255, 255, 255, 0.9) !important;
    }

    .system-status {
        display: none;
        /* Hide status to save header space */
    }

    /* 3. START SCREEN (Centered & Pulsing) */
    #start-screen {
        position: absolute;
        inset: 0;
        z-index: 50;
        background: #f8fafc;
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-bottom: 80px;
        /* Visual offset */
    }

    /* Hide when scanning */
    body.scanning-mode #start-screen {
        display: none !important;
    }

    /* Large Pulse Button */
    .btn-large-start {
        width: 200px;
        height: 200px;
        border-radius: 50%;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        font-size: 1.25rem;
        gap: 16px;
        background: linear-gradient(135deg, #2563eb, #1d4ed8);
        box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4), 0 0 0 0 rgba(37, 99, 235, 0.7);
        animation: pulseShadow 2s infinite;
    }

    .btn-large-start svg {
        width: 48px;
        height: 48px;
    }

    @keyframes pulseShadow {
        0% {
            transform: scale(0.95);
            box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
        }

        70% {
            transform: scale(1);
            box-shadow: 0 0 0 30px rgba(37, 99, 235, 0);
        }

        100% {
            transform: scale(0.95);
            box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
        }
    }

    /* 4. CAMERA ZONE (Fullscreen) */
    .camera-zone {
        position: fixed !important;
        inset: 0;
        z-index: 0;
        background: black;
        width: 100% !important;
        height: 100% !important;
    }

    .camera-viewport {
        border-radius: 0;
        height: 100%;
    }

    /* HUD Adjustments */
    .hud-overlay {
        width: 70vw;
        height: 70vw;
        max-width: 300px;
        max-height: 300px;
        border-color: rgba(255, 255, 255, 0.5);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    }

    .hud-scanner-line {
        box-shadow: 0 0 15px #3b82f6;
        background: white;
        height: 3px;
    }

    /* 5. THUMB CONTROLS (Floating Buttons) */

    /* Stop Button (Bottom Left) */
    .camera-controls {
        position: fixed !important;
        bottom: 32px;
        left: 24px;
        right: auto;
        top: auto;
        z-index: 60;
        width: auto;
    }

    #btn-stop-scan {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: rgba(239, 68, 68, 0.9);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        border: 2px solid rgba(255, 255, 255, 0.2);
        font-size: 0;
        /* Hide text */
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #btn-stop-scan svg {
        width: 28px;
        height: 28px;
        margin: 0;
    }

    /* Flash Button (Bottom Right) */
    #btn-toggle-flash {
        position: fixed !important;
        bottom: 32px;
        right: 24px;
        top: auto;
        z-index: 60;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        color: white;
    }

    #btn-toggle-flash svg {
        width: 28px;
        height: 28px;
    }

    #btn-toggle-flash.active {
        background: rgba(255, 255, 0, 0.3);
        border-color: rgba(255, 255, 0, 0.6);
        color: #fef08a;
        /* Yellow text/icon */
        box-shadow: 0 0 15px rgba(253, 224, 71, 0.5);
    }

    .camera-title {
        display: none;
    }

    /* Clean view */

    /* 6. BOTTOM SHEET (Result Cards) */
    .result-console {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        background: transparent !important;
        border: none;
        padding: 0;
        pointer-events: none;
        /* Click-through empty space */
        justify-content: flex-end;
        /* Align cards to bottom */
    }

    /* Hide the 'Dữ liệu Xác minh' text */
    .result-console .console-header {
        display: none !important;
    }

    .result-card-container {
        pointer-events: none;
        padding: 0;
        width: 100%;
    }

    .idle-state#idle-panel {
        display: none !important;
    }

    /* The Cards */
    .verification-card,
    .cccd-card {
        pointer-events: auto;
        width: 100%;
        margin: 0 !important;
        border-radius: 28px 28px 0 0 !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(16px);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25) !important;
        border: none;
        padding-bottom: max(20px, env(safe-area-inset-bottom));

        /* Slide Up Animation */
        animation: slideUpSpring 0.6s cubic-bezier(0.19, 1, 0.22, 1);
        transform-origin: bottom center;
    }

    /* Drag Handle (Visual) */
    .verification-card::before,
    .cccd-card::before {
        content: '';
        display: block;
        width: 40px;
        height: 5px;
        background: #e2e8f0;
        border-radius: 10px;
        margin: 12px auto 0;
        /* Top center */
    }

    .v-header,
    .cccd-card .v-header {
        border-radius: 20px 20px 0 0;
        padding: 1rem 1.5rem;
    }

    .plate-number {
        font-size: 2.2rem;
        /* Larger for readability */
    }

    /* Close Button (Designed) */
    .btn-close-card {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid #e2e8f0;
        border-radius: 50%;
        color: #ef4444;
        /* Red for close */
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: 10;
        cursor: pointer;
    }

    .btn-close-card svg {
        width: 24px;
        height: 24px;
        stroke-width: 2.5px;
    }
}

```