:root {
    --color-primary: #4f46e5;
    --color-primary-dark: #4338ca;
    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-error: #dc2626;
    --color-error-bg: #fef2f2;
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 40%);
    min-height: 100vh;
}

.scan-body { display: flex; }

.scan-page {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 24px 16px 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.scan-header {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    text-align: center;
}

.brand-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #818cf8);
    flex-shrink: 0;
}

.scan-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.scanner-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.scanner-instruction {
    font-weight: 600;
    color: var(--color-muted);
    margin: 0;
}

.reader-box {
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    min-height: 280px;
}

.reader-box video { border-radius: 12px; }

.scan-footer {
    text-align: center;
    margin-top: 18px;
}

.scan-footer a {
    color: var(--color-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    text-align: left;
}
.alert-error { background: var(--color-error-bg); color: var(--color-error); border: 1px solid #fecaca; }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #bbf7d0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform .12s ease, background .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--color-text); }
.btn-secondary:hover { background: #e2e8f0; }

/* ---------- Result screens ---------- */
.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

.result-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 24px;
    text-align: center;
}

.result-card h1 { font-size: 1.4rem; margin: 0 0 10px; }
.result-message { color: var(--color-muted); margin: 0 0 18px; font-size: 1rem; }

.result-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 16px;
}
.result-time-label { font-size: 0.8rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.result-time-value { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.result-status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    margin-bottom: 20px;
}

.result-success .result-status-badge,
.result-success .result-time-value { color: var(--color-success); }
.result-success .result-status-badge { background: var(--color-success-bg); }
.result-success h1 { color: var(--color-success); }

.result-warning .result-status-badge,
.result-warning .result-time-value { color: var(--color-warning); }
.result-warning .result-status-badge { background: var(--color-warning-bg); }
.result-warning h1 { color: var(--color-warning); }

.result-error h1 { color: var(--color-error); }

/* ---------- Standalone page version (public/scan.php) ---------- */
.scan-page > .result-card { margin: auto; }

@media (max-width: 380px) {
    .result-time-value { font-size: 1.6rem; }
}
