/* ═══════════════════════════════════════════════════════════
   SABRE GUARD — BROWSER EDITION
   A premium mobile-first progressive web app interface
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ───────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Brand Palette */
    --primary: #0F766E;
    --primary-light: #14B8A6;
    --primary-dark: #0D5A54;
    --primary-glow: rgba(20, 184, 166, 0.25);

    /* Status */
    --success: #22C55E;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Neutrals */
    --white: #FFFFFF;
    --black: #000000;
    --bg: #F0FDFA;
    --bg-card: #FFFFFF;
    --bg-muted: #F1F5F9;

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    /* Borders */
    --border: #E2E8F0;
    --border-light: #F1F5F9;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px var(--primary-glow);

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Safe areas */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Screens ────────────────────────────────────────────── */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
    transition: opacity .28s ease, transform .28s ease;
    z-index: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
    z-index: 10;
}
.screen.exiting {
    opacity: 0;
    transform: translateX(-20px);
    pointer-events: none;
}

/* ── Login Screen ───────────────────────────────────────── */
.login-gradient {
    min-height: 100dvh;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 60%, #062e2a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.login-gradient::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(20,184,166,0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(255,255,255,0.04) 0%, transparent 40%);
    animation: shimmer 12s ease-in-out infinite alternate;
}
@keyframes shimmer {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-3%, 2%) rotate(1deg); }
}

.login-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.6s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo {
    font-size: 56px;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
    animation: float 4s ease-in-out infinite;
}
@keyframes float {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.login-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -0.02em;
}
.login-subtitle {
    font-size: 0.95rem;
    color: var(--primary-light);
    margin-top: 4px;
    font-weight: 400;
}
.login-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 14px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    backdrop-filter: blur(8px);
}

.login-form {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 16px;
}

/* ── Form Elements ──────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Input Triggers (Buttons that look like inputs) ────── */
.input-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.input-trigger:active {
    transform: scale(0.98);
    border-color: var(--primary);
    background: var(--bg);
}
.trigger-icon {
    font-size: 1.2rem;
}
.trigger-text {
    flex: 1;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.trigger-text.has-value {
    color: var(--text-primary);
}
.trigger-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.signature-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}
.signature-preview img {
    max-width: 100%;
    max-height: 100px;
    object-fit: contain;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all .2s;
    position: relative;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: var(--white);
}
.btn-primary:hover { background: #0e6b64; box-shadow: var(--shadow-glow); }

.btn-success {
    background: var(--success);
    color: var(--white);
}
.btn-success:hover { background: #1fb855; }

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

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: rgba(15,118,110,0.06); }

.btn-outline-light {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.4);
    color: var(--white);
}

.btn-danger-outline {
    background: var(--white);
    border: 2px solid var(--danger);
    color: var(--danger);
}

.btn-ghost {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border-radius: var(--radius-full);
    padding: 8px 18px;
    font-size: 0.85rem;
    backdrop-filter: blur(8px);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 8px;
    cursor: pointer;
}
.btn-text:hover { color: var(--primary); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--white);
    font-size: 1.4rem;
    padding: 4px;
    transition: transform .2s;
}
.btn-icon:hover { transform: rotate(180deg); }

.btn[disabled] { opacity: 0.55; pointer-events: none; }

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.btn-label + .btn-spinner,
.btn-spinner + .btn-label { display: none; }

.btn-row { display: flex; gap: 10px; margin-top: 12px; }

/* ── Server Settings ────────────────────────────────────── */
.settings-toggle {
    display: block;
    margin: 8px auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--font);
    padding: 8px;
    transition: color 0.2s;
}
.settings-toggle:hover {
    color: var(--primary);
}

.settings-panel {
    display: none;
    background: var(--bg-muted);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 8px;
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}
.settings-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.settings-label:first-child { margin-top: 0; }

.preset-row {
    display: flex;
    gap: 8px;
}
.preset-btn {
    flex: 1;
    padding: 10px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: all .2s;
}
.preset-btn:hover, .preset-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.settings-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--text-primary);
    transition: border-color 0.2s;
    outline: none;
}
.settings-input:focus {
    border-color: var(--primary);
}

.demo-hint {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
    margin-top: 20px;
}

/* ── Home Screen ────────────────────────────────────────── */
.home-header {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    padding: 20px 20px 18px;
    padding-top: calc(20px + var(--safe-top));
    color: var(--white);
    flex-shrink: 0;
}
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.greeting {
    font-size: 0.85rem;
    color: var(--primary-light);
}
.guard-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}
.status-badge {
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white);
    background: rgba(255,255,255,0.12);
}
.status-badge.online { background: rgba(34,197,94,0.35); }
.status-badge.offline { background: rgba(239,68,68,0.35); }
.site-name {
    font-size: 0.85rem;
    color: var(--primary-light);
}

.gate-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}
.gate-label {
    color: rgba(255,255,255,0.65);
    font-size: 0.85rem;
}
.gate-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--white);
}

.home-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(20px + var(--safe-bottom));
}

/* ── Stats ──────────────────────────────────────────────── */
.stats-row {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    flex: 1;
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    color: var(--white);
    box-shadow: var(--shadow-md);
    transition: transform .2s;
}
.stat-card.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-card.success { background: linear-gradient(135deg, var(--success), #16a34a); }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}
.stat-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 4px;
}

/* ── Section Title ──────────────────────────────────────── */
.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
}

/* ── Action Cards ───────────────────────────────────────── */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
.action-card {
    padding: 22px 14px;
    border-radius: var(--radius-lg);
    text-align: center;
    background: var(--white);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform .2s, box-shadow .2s;
    font-family: var(--font);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.action-card:active { transform: scale(0.97); }
.action-card.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: var(--shadow-glow);
}
.action-card.primary .action-title,
.action-card.primary .action-desc { color: var(--white); }

.action-icon { font-size: 2rem; }
.action-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.action-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ── Quick Actions ──────────────────────────────────────── */
.quick-action {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius-lg);
    border: none;
    width: 100%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform .2s;
    font-family: var(--font);
    text-align: left;
}
.quick-action:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.quick-icon { font-size: 1.6rem; }
.quick-text { flex: 1; }
.quick-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.quick-desc {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.quick-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* ── Screen Headers ─────────────────────────────────────── */
.screen-header {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    padding: 16px 20px 20px;
    padding-top: calc(16px + var(--safe-top));
    color: var(--white);
    flex-shrink: 0;
}
.screen-header.compact { padding-bottom: 14px; }
.screen-header.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.screen-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
}
.screen-header .header-subtitle {
    font-size: 0.9rem;
    color: var(--primary-light);
    margin-top: 4px;
}
.header-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-back {
    background: none;
    border: none;
    color: var(--white);
    font-size: 0.95rem;
    cursor: pointer;
    font-family: var(--font);
    padding: 4px 0;
    margin-bottom: 6px;
    transition: opacity .2s;
}
.btn-back:hover { opacity: 0.8; }

/* ── Camera Screens ─────────────────────────────────────── */
.camera-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--black);
}
.camera-header {
    padding: 12px 20px;
    padding-top: calc(12px + var(--safe-top));
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    z-index: 5;
}
.camera-header .btn-back {
    margin-bottom: 2px;
}
.camera-title {
    color: var(--white);
    font-size: 1.3rem;
    font-weight: 700;
}

.camera-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-viewport video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-viewport.small { max-height: 50vh; }

/* ── Scan Frame ─────────────────────────────────────────── */
.scan-frame {
    position: relative;
    width: 240px;
    height: 240px;
    z-index: 3;
}
.scan-frame.small { width: 200px; height: 200px; }

.corner {
    position: absolute;
    width: 36px;
    height: 36px;
    border-color: var(--primary-light);
    border-style: solid;
    border-width: 0;
}
.corner.tl { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; border-radius: 10px 0 0 0; }
.corner.tr { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; border-radius: 0 10px 0 0; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; border-radius: 0 0 0 10px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; border-radius: 0 0 10px 0; }

.corner.red { border-color: var(--danger); }

.scan-frame::after {
    content: '';
    position: absolute;
    left: 10%;
    width: 80%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
    animation: scanLine 2.5s ease-in-out infinite;
}
@keyframes scanLine {
    0% { top: 5%; opacity: 0; }
    30% { opacity: 1; }
    70% { opacity: 1; }
    100% { top: 95%; opacity: 0; }
}

.id-frame {
    position: relative;
    width: 300px;
    height: 190px;
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: var(--radius-lg);
    z-index: 3;
}
.id-frame .corner { border-color: var(--success); }

.photo-frame {
    position: relative;
    width: 250px;
    height: 330px;
    border: 3px solid rgba(255,255,255,0.8);
    border-radius: 50%;
    z-index: 3;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4);
}

.disc-frame {
    position: relative;
    width: 280px;
    height: 280px;
    border: 4px solid var(--primary-light);
    border-radius: 50%;
    z-index: 3;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.5);
}

.id-viewport { background: #111; }

/* ── Processing Overlay ─────────────────────────────────── */
.processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 500;
    z-index: 10;
    animation: fadeIn 0.3s;
}

.camera-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-bottom));
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    text-align: center;
    color: var(--white);
    z-index: 5;
}
.camera-footer p {
    margin-bottom: 10px;
    font-size: 0.9rem;
}
.camera-hint {
    font-size: 0.78rem !important;
    color: rgba(255,255,255,0.7) !important;
}

/* ── Capture Button (ID Scan) ───────────────────────────── */
.capture-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    border: 4px solid var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 10px auto;
    transition: transform .15s;
}
.capture-btn:active { transform: scale(0.9); }
.capture-btn-inner {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--white);
    transition: background .15s;
}
.capture-btn:active .capture-btn-inner { background: #ddd; }
.capture-label {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
}

/* ── PIN Input ──────────────────────────────────────────── */
.pin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.pin-inputs {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}
.pin-box {
    width: 48px;
    height: 58px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}
.pin-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.pin-box.filled {
    border-color: var(--primary);
    background: var(--bg);
}
.pin-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
    line-height: 1.5;
    max-width: 320px;
    margin: 20px auto;
}

/* ── Form Content (Walk-in, etc.) ───────────────────────── */
.form-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(20px + var(--safe-bottom));
}
.form-section {
    margin-bottom: 24px;
}
.form-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.scan-id-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--white);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg);
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    margin-bottom: 20px;
    transition: background .2s;
}
.scan-id-btn:hover { background: rgba(15,118,110,0.04); }

/* ── Confirm Screen ─────────────────────────────────────── */
.confirm-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.valid-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--success);
    color: var(--white);
    padding: 14px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    font-size: 1.05rem;
    font-weight: 700;
}
.valid-icon {
    font-size: 1.3rem;
    font-weight: 800;
}

.info-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}
.card-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.card-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-detail {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.88rem;
}
.detail-row span:first-child { color: var(--text-secondary); }
.detail-row span:last-child { font-weight: 500; }

.recurring-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(20,184,166,0.1);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
}

.confirm-actions {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Onsite List / Exit List ────────────────────────────── */
.list-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-bottom));
}

.count-badge {
    background: var(--white);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 4px 14px;
    border-radius: var(--radius-full);
}

.visitor-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    transition: transform .15s;
    animation: fadeIn 0.3s ease;
}
.visitor-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.visitor-card.overdue {
    border: 2px solid var(--danger);
    background: #fff5f5;
}

.visitor-info { flex: 1; min-width: 0; }
.visitor-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.visitor-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.visitor-time {
    font-size: 0.78rem;
    color: var(--primary);
    margin-top: 3px;
    font-weight: 500;
}
.visitor-time .overdue-note { color: var(--danger); font-weight: 600; }

.exit-btn {
    padding: 8px 18px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    flex-shrink: 0;
    transition: background .2s;
}
.exit-btn:hover { background: #dc2626; }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.4s;
}
.empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.empty-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Search / Count Bar ─────────────────────────────────── */
.search-bar {
    padding: 12px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
}
.search-bar input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-muted);
    border: none;
    border-radius: var(--radius-lg);
    outline: none;
}
.search-bar input:focus {
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.count-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(20,184,166,0.07);
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 500;
}

/* ── Loading / Spinner ──────────────────────────────────── */
.loading-box {
    text-align: center;
    padding: 40px 20px;
}
.loading-box p {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 12px;
}
.loading-box .sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 4px;
}

.spinner, .spinner-lg {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}
.spinner-lg { width: 44px; height: 44px; border-width: 4px; border-top-color: var(--white); border-color: rgba(255,255,255,0.2); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── ID Preview ─────────────────────────────────────────── */
.id-preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 0;
    background: #111;
}
.result-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}
.result-content .form-group {
    padding: 0 20px;
}
.result-content .form-section-title {
    padding: 0 20px;
    margin-top: 16px;
}
.result-content .btn-row {
    padding: 0 20px;
    margin-top: 20px;
}

/* ── Toast Notifications ────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--text-primary);
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    pointer-events: auto;
    animation: toastIn 0.35s ease, toastOut 0.3s ease forwards;
    animation-delay: 0s, 3.5s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #000; }

@keyframes toastIn  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ── Responsive ─────────────────────────────────────────── */
@media (min-width: 600px) {
    .login-form { padding: 36px; }
    .pin-box { width: 56px; height: 66px; font-size: 1.7rem; }
    .actions-grid { gap: 16px; }
    .action-card { padding: 28px 18px; }
    .scan-frame { width: 280px; height: 280px; }
}

@media (min-width: 768px) {
    body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,0.15); }
}

/* ── Search Box in Header ─────────────────────────────── */
.screen-header .search-box {
    margin-top: 12px;
}
.screen-header .search-box input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: all .2s;
}
.screen-header .search-box input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}
.screen-header .search-box input:focus {
    background: var(--white);
    color: var(--text-primary);
    border-color: var(--white);
    box-shadow: var(--shadow-lg);
}

/* ── Floating Action Button (FAB) ──────────────────────── */
.fab-container {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    right: 20px;
    z-index: 100;
}

/* ── Modal Overlay ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding-bottom: 0;
    animation: modalFadeIn 0.3s ease;
}

.modal-overlay[hidden], [hidden] {
    display: none !important;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 24px;
    padding-bottom: calc(24px + var(--safe-bottom));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-modal {
    background: var(--bg-muted);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.details-item {
    display: flex;
    flex-direction: column;
}

.details-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.details-item span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.details-item.full {
    grid-column: span 2;
}

.plate-badge {
    background: #FFD700; /* Yellow plate color */
    color: #000;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
    border: 1px solid #C0C0C0;
    display: inline-block;
    vertical-align: middle;
}
/* ── Search Input Styles ────────────────────────────────── */
.input-with-action {
    display: flex;
    gap: 8px;
    align-items: center;
}
.input-with-action input {
    flex: 1;
}
.btn-inline-search {
    background: var(--primary-muted, rgba(15, 118, 110, 0.1));
    color: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.btn-inline-search:active {
    transform: scale(0.92);
    background: rgba(15, 118, 110, 0.2);
}

.history-results {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-top: 8px;
    overflow: hidden;
    z-index: 100;
}
.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.history-item:last-child {
    border-bottom: none;
}
.history-item:active {
    background: var(--bg-muted);
}
.history-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}
.history-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}


/* Onsite List Authorization Badges */
.visitor-card.paid-border {
    border-left: 5px solid var(--success) !important;
}

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

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

.plate-badge {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* ── Barcode Scanner Frame ──────────────────────────────── */
.barcode-scan-frame {
    position: relative;
    width: 85vw;
    max-width: 340px;
    height: 100px;
    border: 2.5px solid rgba(99, 102, 241, 0.9);
    border-radius: var(--radius-md);
    z-index: 3;
    box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.55),
                0 0 30px rgba(99, 102, 241, 0.4);
    overflow: hidden;
}

.barcode-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #818cf8, #6366f1, #818cf8, transparent);
    animation: barcodeLineAnim 1.8s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.8);
}

@keyframes barcodeLineAnim {
    0%   { top: 5%; opacity: 0.5; }
    25%  { opacity: 1; }
    75%  { opacity: 1; }
    100% { top: 90%; opacity: 0.5; }
}

/* ── Barcode Review Card ─────────────────────────────────── */
.barcode-review-card {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: var(--radius-xl);
    padding: 28px 20px;
    text-align: center;
    color: white;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
    margin-bottom: 4px;
}

.barcode-review-icon { font-size: 3rem; margin-bottom: 8px; }

.barcode-review-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.75);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.barcode-review-id {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    font-family: 'Courier New', monospace;
    color: white;
    word-break: break-all;
}

/* ── Alert Banners ──────────────────────────────────────── */
.alert-banner {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 12px;
}

.alert-banner.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1.5px solid var(--warning);
    color: #92400e;
}

.alert-banner.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border: 1.5px solid var(--danger);
    color: #991b1b;
}

.alert-banner.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1.5px solid var(--success);
    color: #14532d;
}

/* ── Utility Button Sizes ────────────────────────────────── */
.btn-xs { padding: 5px 12px; font-size: 0.75rem; }

.btn-primary-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    width: 100%;
}
.btn-primary-outline:hover { background: rgba(15,118,110,0.06); }

.flex-1 { flex: 1; }

/* ── Signature Preview ─────────────────────────────────── */
.signature-preview {
    margin-top: 12px;
    text-align: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
}
.signature-preview img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}
/* ── Passenger Card (New Unified Model) ────────────────── */
.passenger-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    animation: slideInUp 0.3s ease;
}

.passenger-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.passenger-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-remove-passenger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
}

.passenger-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.passenger-full {
    grid-column: span 2;
}

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

/* ── Image Previews ─────────────────────────────────────── */
.p-media-previews, .media-previews {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    cursor: grab;
    scroll-behavior: auto; /* auto is better for drag scrolling than smooth */
    overflow-x: auto;
}
.p-media-previews::-webkit-scrollbar, .media-previews::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}
.p-media-previews.active, .media-previews.active {
    cursor: grabbing;
}
.p-media-previews img, .media-previews img {
    -webkit-user-drag: none;
    user-select: none;
}
