:root {
    --primary: #1e3a5f;
    --primary-light: #2c5282;
    --accent: #c9a227;
    --success: #276749;
    --danger: #c53030;
    --warning: #c05621;
    --bg: #f7fafc;
    --card: #ffffff;
    --text: #1a202c;
    --muted: #718096;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.container.narrow { max-width: 480px; }

/* Header */
.site-header {
    background: var(--primary);
    color: #fff;
    padding: 0.85rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.logo { display: flex; align-items: center; gap: 0.5rem; color: #fff; text-decoration: none; font-weight: 600; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-family: 'Playfair Display', serif; font-size: 1.15rem; }
.main-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.main-nav a { color: rgba(255,255,255,0.9); text-decoration: none; font-size: 0.95rem; font-weight: 500; }
.main-nav a:hover { color: var(--accent); }
.admin-link { color: var(--accent) !important; }

/* Flash */
.flash-wrap { padding: 1rem 0 0; }
.flash {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
}
.flash-success { background: #c6f6d5; color: #22543d; }
.flash-error { background: #fed7d7; color: #742a2a; }
.flash-warning { background: #feebc8; color: #7b341e; }
.flash-info { background: #bee3f8; color: #2a4365; }
.flash-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; opacity: 0.7; }

/* Main */
.main-content { flex: 1; padding: 2rem 0; }

/* Hero */
.hero {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 50%, #1a365d 100%);
    color: #fff;
    padding: 3.5rem 0 4rem;
    text-align: center;
}
.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    margin-bottom: 1rem;
}
.hero-tagline {
    font-size: 1.15rem;
    max-width: 640px;
    margin: 0 auto 2.5rem;
    opacity: 0.95;
    line-height: 1.7;
}
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}
.cat-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
}
.cat-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.cat-card h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.cat-card p { font-size: 0.9rem; opacity: 0.9; }

.hero-meta {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}
.meta-item { text-align: center; }
.meta-item strong { display: block; font-size: 1.2rem; color: var(--accent); }
.meta-item span { font-size: 0.85rem; opacity: 0.85; }

.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.closing-info { font-size: 0.95rem; opacity: 0.9; }
.closed-badge {
    background: var(--danger);
    color: #fff;
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    font-weight: 600;
    margin-bottom: 1rem;
    display: inline-block;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.65rem 1.4rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #1a202c; }
.btn-primary:hover { background: #dbb42c; }
.btn-outline { background: transparent; border-color: rgba(255,255,255,0.6); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.1); }
.btn-success { background: var(--success); color: #fff; }
.btn-lg { padding: 0.85rem 1.8rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-block { width: 100%; text-align: center; }
body:not(.quiz-mode) .btn-outline { border-color: var(--primary); color: var(--primary); }
body:not(.quiz-mode) .btn-outline:hover { background: var(--primary); color: #fff; }

/* Rules */
.rules-section { padding: 3rem 0; }
.rules-section h2 { text-align: center; margin-bottom: 1.5rem; font-family: 'Playfair Display', serif; }
.rules-list {
    max-width: 700px;
    margin: 0 auto;
    list-style: none;
}
.rules-list li {
    padding: 0.75rem 0 0.75rem 1.75rem;
    position: relative;
    border-bottom: 1px solid var(--border);
}
.rules-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

/* Forms */
.form-section { padding: 1rem 0 3rem; }
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.card h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.text-muted { color: var(--muted); margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}
.form-group input:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(44,82,130,0.15); }
.form-group small { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.8rem; }
.form-footer { text-align: center; margin-top: 1.5rem; font-size: 0.95rem; }
.form-footer a { color: var(--primary-light); font-weight: 600; }

/* Dashboard */
.dashboard-section { padding: 0.5rem 0 3rem; }
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}
.dash-header h1 { font-size: 1.6rem; }
.total-score-badge {
    background: var(--primary);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
}
.categories-status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.status-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    border: 2px solid transparent;
}
.status-card.completed { border-color: var(--success); }
.status-card.in-progress { border-color: var(--accent); }
.status-icon { font-size: 2rem; }
.status-body h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.score { margin-bottom: 0.5rem; }
.badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: #c6f6d5; color: #22543d; }
.badge-warning { background: #feebc8; color: #7b341e; }
.badge-info { background: #bee3f8; color: #2a4365; }
.badge-muted { background: #edf2f7; color: #4a5568; }
.dash-actions { text-align: center; }
.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; }
.alert-warning { background: #feebc8; color: #7b341e; }

/* Results */
.results-section h1 { margin-bottom: 0.5rem; }
.table-responsive { overflow-x: auto; margin-top: 1.5rem; }
.results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.results-table th, .results-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.results-table th {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.results-table tr:hover { background: #f7fafc; }
.results-table tr.pending { opacity: 0.7; }
.text-center { text-align: center; }

/* Admin */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

/* Quiz Mode */
body.quiz-mode {
    background: #0f172a;
    color: #e2e8f0;
}
.quiz-topbar {
    background: #1e293b;
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid #334155;
}
.quiz-cat { font-weight: 600; font-size: 1.05rem; }
.quiz-timer {
    background: #0f172a;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.25rem;
    color: #fbbf24;
}
.quiz-timer.danger { color: #f87171; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
.quiz-progress { font-size: 0.9rem; color: #94a3b8; }

.quiz-warning-banner {
    background: #c05621;
    color: #fff;
    text-align: center;
    padding: 0.6rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.quiz-container {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
    max-width: 1100px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}
@media (max-width: 800px) {
    .quiz-container { grid-template-columns: 1fr; }
    .camera-panel { order: -1; max-width: 280px; margin: 0 auto; }
}

.camera-panel {
    background: #1e293b;
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid #334155;
}
.camera-header { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; color: #94a3b8; }
#cameraPreview {
    width: 100%;
    border-radius: 8px;
    background: #0f172a;
    aspect-ratio: 4/3;
    object-fit: cover;
}
.camera-status { font-size: 0.8rem; margin-top: 0.5rem; color: #94a3b8; }
.camera-status.ok { color: #68d391; }
.camera-status.err { color: #fc8181; }
.camera-note { font-size: 0.75rem; color: #64748b; margin-top: 0.35rem; }

.questions-panel {
    background: #1e293b;
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid #334155;
}
.q-number { font-size: 0.85rem; color: #94a3b8; margin-bottom: 0.5rem; }
.q-text { font-size: 1.15rem; font-weight: 500; margin-bottom: 1.25rem; line-height: 1.5; }
.options { display: flex; flex-direction: column; gap: 0.65rem; }
.option-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.option-label:hover { border-color: #64748b; }
.option-label:has(input:checked) {
    border-color: var(--accent);
    background: rgba(201, 162, 39, 0.12);
}
.option-label input { margin-top: 0.2rem; accent-color: var(--accent); }
.opt-letter {
    font-weight: 700;
    color: var(--accent);
    min-width: 1.2rem;
}
.opt-text { flex: 1; }

.quiz-nav {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.75rem;
    flex-wrap: wrap;
}
.quiz-nav .btn-outline { border-color: #64748b; color: #e2e8f0; }
.quiz-nav .btn-outline:hover { background: #334155; }
.quiz-nav .btn-outline:disabled { opacity: 0.4; cursor: not-allowed; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.overlay-box {
    background: #1e293b;
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
}
.overlay-box h2 { margin-bottom: 0.75rem; color: #f87171; }
.overlay-box p { margin-bottom: 1.5rem; color: #94a3b8; }

/* Footer */
.site-footer {
    background: #1a202c;
    color: #a0aec0;
    text-align: center;
    padding: 1.5rem 0;
    font-size: 0.9rem;
}
.footer-note { margin-top: 0.35rem; font-size: 0.8rem; opacity: 0.8; }

/* ========== Proctoring / Admin Live Feed ========== */
.dash-header-actions { display: flex; align-items: center; gap: 1rem; }
.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #38a169;
    background: #c6f6d5;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
}
.live-dot {
    width: 8px; height: 8px;
    background: #38a169;
    border-radius: 50%;
    animation: livePulse 1.5s infinite;
}
.live-indicator.pulse { background: #fefcbf; color: #975a16; }
.live-indicator.pulse .live-dot { background: #d69e2e; }
@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.stat-card.stat-alert .stat-num { color: var(--danger); }
.stat-card.has-alerts { box-shadow: 0 0 0 2px var(--danger); }

.proctor-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.25rem;
    margin-top: 1.75rem;
}
@media (max-width: 900px) {
    .proctor-grid { grid-template-columns: 1fr; }
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.card-header-row h2 { margin: 0; font-size: 1.15rem; }

.alert-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.alert-filters label { cursor: pointer; display: flex; align-items: center; gap: 0.3rem; }

.alert-feed {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}
.feed-empty { padding: 2rem; text-align: center; color: var(--muted); }
.feed-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    transition: background 0.3s;
}
.feed-item:last-child { border-bottom: none; }
.feed-item.unread { background: #fff; border-left: 3px solid var(--primary); }
.feed-item.severity-critical { border-left-color: var(--danger); background: #fff5f5; }
.feed-item.severity-warning { border-left-color: var(--warning); background: #fffaf0; }
.feed-item.severity-info { border-left-color: #a0aec0; }
.feed-item.feed-new { animation: feedFlash 1.2s ease; }
@keyframes feedFlash {
    0% { background: #fefcbf; }
    100% { background: inherit; }
}
.feed-meta {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.75rem;
}
.feed-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.feed-sev {
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
}
.severity-critical .feed-sev { background: #fed7d7; color: #742a2a; }
.severity-warning .feed-sev { background: #feebc8; color: #7b341e; }
.severity-info .feed-sev { background: #e2e8f0; color: #4a5568; }
.feed-type { color: var(--muted); text-transform: capitalize; }
.feed-body p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; }
.feed-parish { font-size: 0.8rem; color: var(--muted); margin-left: 0.4rem; }
.feed-link {
    align-self: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-light);
    text-decoration: none;
}

.active-list { max-height: 420px; overflow-y: auto; }
.active-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.active-item:last-child { border-bottom: none; }
.active-meta { font-size: 0.8rem; color: var(--muted); }
.active-stats { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
