:root {
    --accent: #ff5722;
    --accent-dark: #e64a19;
    --accent-glow: rgba(255, 87, 34, 0.5);
    --neon-ring: #00f2ff;
    --bg-glass: rgba(255, 255, 255, 0.1);
    --bg-glass-dark: rgba(0, 0, 0, 0.3);
    --border-glass: rgba(255, 255, 255, 0.2);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Montserrat', sans-serif;
    color: var(--text-main);
    background: linear-gradient(135deg, #020617 0%, #111827 48%, #1f2937 100%);
    line-height: 1.5;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 0;
    pointer-events: none;
}

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

@keyframes rotateRing {
    to {
        transform: rotate(360deg);
    }
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.main-card {
    width: 100%;
    max-width: 480px;
    max-height: calc(100dvh - 74px);
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
}

.main-card::-webkit-scrollbar {
    width: 4px;
}

.main-card::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}

.hero-text {
    margin-bottom: 40px;
}

.hero-text h1 {
    margin-bottom: 12px;
    font-size: 2.5rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0;
}

.hero-text p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
}

.start-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.btn-start {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: #fff;
    border: none;
    z-index: 5;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px var(--accent-glow);
}

.btn-start .label,
.btn-start .icon {
    color: var(--accent);
    font-weight: 600;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.btn-start .label {
    font-size: 1.5rem;
}

.btn-start .icon {
    position: absolute;
    font-size: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
}

.gatepass-code-orb {
    margin-bottom: 30px;
}

.gatepass-pass-icon {
    pointer-events: none;
}

.gatepass-code-orb:hover .label {
    opacity: 0;
    transform: translateY(-10px);
}

.gatepass-code-orb:hover .icon {
    opacity: 1;
    transform: translateY(0);
}

@keyframes pulse-out {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: pulse-out 2s infinite;
}

.neon-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 180px;
    height: 180px;
    margin-top: -90px;
    margin-left: -90px;
    border-radius: 50%;
    pointer-events: none;
}

.neon-ring::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0%, transparent 70%, var(--neon-ring) 100%);
    animation: rotateRing 1s linear infinite;
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #fff 100%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #fff 100%);
}

.content {
    text-align: left;
}

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

.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 14px;
    background: var(--bg-glass-dark);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(255, 87, 34, 0.2);
}

.btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.btn:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-alt:hover {
    background: rgba(255, 255, 255, 0.18);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert svg {
    flex: 0 0 auto;
    margin-top: 1px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    color: #ffd5d5;
    border: 1px solid rgba(239, 68, 68, 0.28);
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    color: #b7f7dc;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.pass-status-banner {
    width: max-content;
    max-width: 100%;
    margin: -10px auto 20px;
    padding: 9px 14px;
    border-radius: 999px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pass-status-allowed {
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #b7f7dc;
}

.pass-status-warning {
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fde3ab;
}

.pass-status-danger {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #ffd5d5;
}

.pass-status-neutral {
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
}

.pass-code {
    margin-bottom: 8px;
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    font-size: 2.65rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    line-height: 1;
    text-shadow: 0 0 28px var(--accent-glow);
    word-break: break-word;
}

.pass-hint,
.scan-help,
.scan-auth-note,
.scan-state-note,
.success-note {
    color: var(--text-muted);
    font-size: 0.93rem;
    font-weight: 500;
    text-align: center;
}

.pass-hint {
    margin-bottom: 24px;
}

.pass-qr {
    width: 260px;
    height: 260px;
    margin: 0 auto 24px;
    padding: 20px;
    background: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 30px var(--accent-glow);
}

.pass-qr::before,
.pass-qr::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    pointer-events: none;
}

.pass-qr::before {
    border: 2px solid rgba(255, 87, 34, 0.55);
    opacity: 0.7;
}

.pass-qr::after {
    background: conic-gradient(from 0deg, transparent 0%, transparent 70%, var(--neon-ring) 100%);
    animation: rotateRing 1.15s linear infinite;
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #fff 100%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #fff 100%);
}

.pass-qr img {
    width: 220px;
    height: 220px;
    border-radius: 10px;
    position: relative;
    z-index: 1;
}

.pass-actions,
.scan-auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pass-actions {
    margin-top: 8px;
}

.pass-actions .btn,
.scan-auth-actions .btn {
    flex: 1 1 140px;
    margin-top: 0;
    padding: 13px 14px;
    font-size: 0.95rem;
}

.pass-info {
    margin-top: 22px;
    padding: 18px;
    background: var(--bg-glass-dark);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    text-align: left;
}

.pass-info-tight {
    margin-top: 0;
}

.pass-info-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.94rem;
}

.pass-info-row:last-child {
    margin-bottom: 0;
}

.pass-info-label {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-weight: 500;
}

.pass-info-value {
    min-width: 0;
    color: #fff;
    font-weight: 700;
    text-align: right;
    overflow-wrap: anywhere;
}

.scan-help {
    margin-top: 22px;
}

.scan-auth-note,
.scan-state-note {
    margin: 22px 0 16px;
}

.code-input-uppercase {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

.otp-input {
    letter-spacing: 4px;
    font-size: 1.45rem;
    text-align: center;
}

.footer {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    margin-top: 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.85rem;
    text-align: center;
    z-index: 1;
}

.public-login-footer {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 100;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    padding: 10px 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-align: center;
}

.public-login-footer a {
    color: #fff;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.public-login-footer + .footer {
    bottom: 68px;
}

@media (max-width: 600px) {
    body {
        padding: 0;
        justify-content: stretch;
    }

    .container {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        max-height: none;
        max-width: none;
        padding: 30px 20px;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .app-container {
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
        padding: 0;
    }

    .hero-text h1 {
        font-size: 2rem;
    }

    .start-container {
        width: 180px;
        height: 180px;
    }

    .btn-start,
    .pulse-ring {
        width: 144px;
        height: 144px;
    }

    .neon-ring {
        width: 162px;
        height: 162px;
        margin-top: -81px;
        margin-left: -81px;
    }

    .pass-code {
        font-size: 2.1rem;
    }

    .pass-qr {
        width: 230px;
        height: 230px;
        padding: 16px;
    }

    .pass-qr img {
        width: 196px;
        height: 196px;
    }

    .pass-info-row {
        display: block;
    }

    .pass-info-value {
        display: block;
        margin-top: 3px;
        text-align: left;
    }

    .footer {
        display: none;
    }

    .public-login-footer {
        bottom: 12px;
        max-width: calc(100% - 24px);
        padding: 8px 12px;
        font-size: 0.82rem;
    }
}

/* =============================================
   GatePass UI Enhancements
   Loading states, animations, copy toast, etc.
   ============================================= */

/* --- Loading state on buttons --- */
.btn.loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}
.btn.loading::after {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* --- Staggered entrance animations --- */
.stagger-enter > * {
    opacity: 0;
    transform: translateY(18px);
    animation: staggerFadeIn 0.5s cubic-bezier(0.16,1,0.3,1) forwards;
}
.stagger-enter > *:nth-child(1) { animation-delay: 0s; }
.stagger-enter > *:nth-child(2) { animation-delay: 0.08s; }
.stagger-enter > *:nth-child(3) { animation-delay: 0.16s; }
.stagger-enter > *:nth-child(4) { animation-delay: 0.24s; }
.stagger-enter > *:nth-child(5) { animation-delay: 0.32s; }
.stagger-enter > *:nth-child(6) { animation-delay: 0.40s; }
.stagger-enter > *:nth-child(7) { animation-delay: 0.48s; }
.stagger-enter > *:nth-child(8) { animation-delay: 0.56s; }
@keyframes staggerFadeIn {
    to { opacity: 1; transform: translateY(0); }
}

/* --- Copy code toast --- */
.copy-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 200;
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(16,185,129,0.92);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    white-space: nowrap;
}
.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Copy code button --- */
.copy-code-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    background: var(--bg-glass-dark);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    vertical-align: middle;
}
.copy-code-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.3);
}
.copy-code-btn.copied {
    background: rgba(16,185,129,0.18);
    border-color: rgba(16,185,129,0.35);
    color: #b7f7dc;
}

/* --- OTP countdown --- */
.otp-timer {
    text-align: center;
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.otp-timer .timer-count {
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.otp-timer .timer-count.warning { color: var(--warning); }
.otp-timer .timer-count.expired { color: var(--error); }
.otp-resend {
    display: inline-block;
    margin-top: 4px;
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}
.otp-resend.active {
    opacity: 1;
    pointer-events: auto;
}
.otp-resend.active:hover { color: var(--accent-dark); }

/* --- Inline validation --- */
.form-control.error {
    border-color: var(--error) !important;
    box-shadow: 0 0 12px rgba(239,68,68,0.25) !important;
}
.form-control.valid {
    border-color: var(--success) !important;
    box-shadow: 0 0 12px rgba(16,185,129,0.2) !important;
}
.field-error {
    display: none;
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #ffd5d5;
}
.field-error.visible { display: block; }

/* --- Scan gate hero layout --- */
.scan-hero {
    text-align: center;
    padding: 12px 0;
}
.scan-hero .guest-name {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}
.scan-hero .guest-code {
    margin: 6px 0 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}
.scan-hero .scan-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.scan-hero .scan-status-badge.allowed {
    background: rgba(16,185,129,0.15);
    color: #b7f7dc;
    border: 1px solid rgba(16,185,129,0.3);
}
.scan-hero .scan-status-badge.denied {
    background: rgba(239,68,68,0.15);
    color: #ffd5d5;
    border: 1px solid rgba(239,68,68,0.3);
}
.scan-hero .scan-status-badge.pending {
    background: rgba(245,158,11,0.15);
    color: #fde3ab;
    border: 1px solid rgba(245,158,11,0.3);
}
.scan-hero .scan-status-badge.neutral {
    background: rgba(148,163,184,0.15);
    color: #e2e8f0;
    border: 1px solid rgba(148,163,184,0.3);
}

/* --- Collapsible details toggle --- */
.details-toggle {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 10px;
    background: none;
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
}
.details-toggle:hover {
    background: var(--bg-glass-dark);
    border-color: rgba(255,255,255,0.25);
}
.details-toggle .arrow {
    display: inline-block;
    margin-left: 6px;
    transition: transform 0.2s;
}
.details-toggle.open .arrow { transform: rotate(180deg); }
.details-content {
    display: none;
    margin-top: 12px;
}
.details-content.open { display: block; }

/* --- Success overlay --- */
.success-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    border-radius: 24px;
    background: rgba(16,185,129,0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    animation: successIn 0.5s cubic-bezier(0.16,1,0.3,1) forwards;
    color: #fff;
}
@keyframes successIn {
    from { opacity: 0; scale: 0.92; }
    to { opacity: 1; scale: 1; }
}
.success-overlay .checkmark {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    animation: checkPop 0.4s 0.15s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes checkPop {
    0% { scale: 0; }
    100% { scale: 1; }
}
.success-overlay .checkmark svg {
    width: 36px;
    height: 36px;
    stroke: #fff;
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.success-overlay h2 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
}
.success-overlay p {
    margin: 0;
    font-size: 0.95rem;
    opacity: 0.85;
}

/* --- Inline form validation icons --- */
.form-group { position: relative; }
.form-group .validation-icon {
    position: absolute;
    right: 14px;
    top: 38px;
    width: 18px;
    height: 18px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.form-group .validation-icon.visible { opacity: 1; }

@media print {
    body {
        display: block;
        min-height: auto;
        padding: 0;
        background: #fff;
        color: #111827;
    }

    body::before,
    .footer,
    .public-login-footer,
    .pass-actions,
    .scan-help {
        display: none;
    }

    .app-container {
        display: block;
        min-height: auto;
        height: auto;
        padding: 0;
    }

    .container {
        max-width: 100%;
        max-height: none;
        padding: 24px;
        background: #fff;
        color: #111827;
        border: 0;
        box-shadow: none;
        overflow: visible;
    }

    .header p,
    .pass-hint,
    .pass-info-label {
        color: #4b5563;
    }

    .pass-code,
    .pass-info-value {
        color: #111827;
        text-shadow: none;
    }

    .pass-info {
        background: #fff;
        border-color: #d1d5db;
    }
}
