:root {
    /* Colors */
    --bg-dark: #070B14;
    --bg-card: rgba(13, 19, 33, 0.6);
    --primary-cyan: #00F0FF;
    --primary-cyan-glow: rgba(0, 240, 255, 0.4);
    --primary-blue: #0057FF;
    --success-green: #00FF88;
    --success-glow: rgba(0, 255, 136, 0.4);
    --danger-red: #FF003C;
    --danger-glow: rgba(255, 0, 60, 0.4);
    --text-main: #FFFFFF;
    --text-muted: #8B9BB4;
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(0, 240, 255, 0.3);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Spacing & Radii */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
#background-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--primary-blue), transparent 70%);
    top: -10%;
    left: -10%;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.3), transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-delay: -5s;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.5;
    transform: perspective(500px) rotateX(60deg) scale(2.5) translateY(-100px);
    transform-origin: top center;
    pointer-events: none;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.2); }
}

/* App Container */
#app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 24px;
    margin: auto 0;
}

@media (min-width: 500px) {
    #app-container {
        min-height: 850px;
        height: auto;
        border: 1px solid var(--border-glass);
        border-radius: 32px;
        background: rgba(7, 11, 20, 0.4);
        backdrop-filter: blur(20px);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        margin: 40px auto;
    }
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: var(--primary-cyan);
    text-shadow: 0 0 10px var(--primary-cyan-glow);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success-glow);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Screens */
.screen {
    position: absolute;
    top: 80px;
    left: 24px;
    right: 24px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.98);
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.screen.active {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    z-index: 5;
    flex-grow: 1;
    margin-bottom: 24px;
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    backdrop-filter: blur(16px);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 20px rgba(255,255,255,0.02);
}

.card-header {
    margin-bottom: 32px;
}

.card-header.center {
    text-align: center;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.card-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Forms */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group label i {
    margin-right: 6px;
    color: var(--primary-cyan);
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition-fast);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-cyan);
    box-shadow: 0 0 15px var(--primary-cyan-glow);
    background: rgba(0, 240, 255, 0.05);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius-md);
    border: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition-fast);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-cyan));
    color: white;
    box-shadow: 0 10px 20px rgba(0, 87, 255, 0.3);
    margin-top: 10px;
}

.primary-btn:hover {
    box-shadow: 0 12px 25px rgba(0, 240, 255, 0.5);
    transform: translateY(-2px);
}

.primary-btn.pulse {
    animation: btn-pulse 2s infinite;
}

@keyframes btn-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(0, 240, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.text-btn {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 10px;
}

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

/* Zone Grid */
.zone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.zone-option {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
    color: var(--text-main);
}

.zone-option i {
    font-size: 1.8rem;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.zone-option span {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
}

.security-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.security-badge.level-5 { color: var(--danger-red); background: rgba(255,0,60,0.15); border: 1px solid rgba(255,0,60,0.3); }
.security-badge.level-4 { color: #FF9900; background: rgba(255,153,0,0.15); border: 1px solid rgba(255,153,0,0.3); }
.security-badge.level-3 { color: #E2E8F0; }
.security-badge.level-1 { color: var(--success-green); background: rgba(0,255,136,0.15); border: 1px solid rgba(0,255,136,0.3); }

.zone-option:hover, .zone-option.selected {
    border-color: var(--primary-cyan);
    background: rgba(0, 240, 255, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.zone-option:hover i, .zone-option.selected i {
    color: var(--primary-cyan);
}

/* Scanner */
.scanner-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 24px;
    background: #000;
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.camera-feed {
    width: 100%;
    height: 100%;
}

.camera-feed img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(20%) contrast(120%) brightness(80%);
    transition: filter 0.5s;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.8);
}

.corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.top-left { top: 20px; left: 20px; border-top-color: var(--primary-cyan); border-left-color: var(--primary-cyan); border-top-left-radius: 12px; }
.top-right { top: 20px; right: 20px; border-top-color: var(--primary-cyan); border-right-color: var(--primary-cyan); border-top-right-radius: 12px; }
.bottom-left { bottom: 20px; left: 20px; border-bottom-color: var(--primary-cyan); border-left-color: var(--primary-cyan); border-bottom-left-radius: 12px; }
.bottom-right { bottom: 20px; right: 20px; border-bottom-color: var(--primary-cyan); border-right-color: var(--primary-cyan); border-bottom-right-radius: 12px; }

.scanner-overlay.scanning .corner {
    border-color: var(--success-green);
    width: 30px;
    height: 30px;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-cyan);
    box-shadow: 0 0 20px 4px var(--primary-cyan-glow);
    opacity: 0;
}

.scanner-overlay.scanning .scan-line {
    opacity: 1;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

.facial-points {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 160px;
    background-image: radial-gradient(circle, var(--primary-cyan) 2px, transparent 2px);
    background-size: 20px 20px;
    opacity: 0;
    mask-image: radial-gradient(ellipse, black 40%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse, black 40%, transparent 70%);
}

.scanner-overlay.scanning .facial-points {
    animation: points-fade 2s infinite alternate;
}

@keyframes points-fade {
    0% { opacity: 0; }
    100% { opacity: 0.6; }
}

.scan-progress-container {
    margin-bottom: 20px;
    text-align: center;
}

.scan-progress-container.hidden {
    display: none;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-cyan));
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--primary-cyan);
    font-family: var(--font-heading);
    letter-spacing: 1px;
}

.scan-actions {
    display: flex;
    gap: 16px;
    margin-top: auto;
}

/* Result Screen */
.result-card {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.result-icon-container {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 32px;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}

.ring.outer {
    width: 100%;
    height: 100%;
    border-top-color: var(--success-green);
    border-bottom-color: var(--success-green);
    animation: spin 3s linear infinite;
}

.ring.inner {
    width: 80%;
    height: 80%;
    border-left-color: rgba(0, 255, 136, 0.5);
    border-right-color: rgba(0, 255, 136, 0.5);
    animation: spin-reverse 2s linear infinite;
}

.result-icon-container i {
    font-size: 3rem;
    color: var(--success-green);
    text-shadow: 0 0 20px var(--success-glow);
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes spin-reverse { 100% { transform: rotate(-360deg); } }

.result-card h2 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--success-green);
    margin-bottom: 8px;
}

.result-card p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

/* Result Modes - Failure */
.result-card.denied h2 { color: var(--danger-red); }
.result-card.denied .result-icon-container i { color: var(--danger-red); text-shadow: 0 0 20px var(--danger-glow); }
.result-card.denied .ring.outer { border-top-color: var(--danger-red); border-bottom-color: var(--danger-red); }
.result-card.denied .ring.inner { border-left-color: rgba(255,0,60,0.5); border-right-color: rgba(255,0,60,0.5); }

.stats-panel {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}

.stat-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.stat-value {
    font-family: var(--font-heading);
    font-weight: 600;
}

.stat-value.highlight {
    color: var(--primary-cyan);
    font-size: 1.2rem;
}

/* History Screen */
.history-list {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 24px;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar customization */
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 4px; }
.history-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.history-item {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-fast);
}

.history-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--border-highlight);
}

.history-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.history-item.granted .history-icon {
    background: rgba(0,255,136,0.1);
    color: var(--success-green);
}

.history-item.denied .history-icon {
    background: rgba(255,0,60,0.1);
    color: var(--danger-red);
}

.history-details {
    flex-grow: 1;
}

.history-zone {
    font-family: var(--font-heading);
    font-weight: 500;
    margin-bottom: 4px;
}

.history-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-score {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-cyan);
}

/* --- Mobile Responsiveness for Result Screen --- */
@media (max-width: 480px), (max-height: 800px) {
    .app-header {
        padding-bottom: 12px;
    }
    
    .screen {
        top: 60px;
        bottom: 12px;
        left: 12px;
        right: 12px;
    }
    
    .glass-card {
        padding: 16px 12px;
    }
    
    .result-icon-container {
        width: 80px;
        height: 80px;
        margin-bottom: 12px;
    }
    
    .result-icon-container i {
        font-size: 2rem;
    }
    
    .result-card h2 {
        font-size: 1.6rem;
        margin-bottom: 4px;
    }
    
    .result-card p {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }
    
    .stats-panel {
        padding: 12px;
        gap: 8px;
        margin-bottom: 16px;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value.highlight {
        font-size: 1rem;
    }
    
    .btn {
        padding: 12px;
        font-size: 0.9rem;
        margin-top: 8px;
    }
    
    .secondary-btn {
        margin-top: 8px; 
    }
    
    .text-btn {
        margin-top: 8px;
        padding: 8px;
    }
    
    .history-list {
        margin-bottom: 12px;
    }
    
    .history-item {
        padding: 12px;
        gap: 12px;
    }
}
