:root {
    --ink: #1a2b3c;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #0b6fa4;
    --brand-dark: #095a86;
    --bg: #f6f9fc;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

/* --- buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }

/* --- auth gate --- */
.auth-overlay {
    position: fixed;
    inset: 0;
    /* Opaque: the app behind it must be completely hidden until a PIN is
       entered. A translucent tint would leak the whole site through. */
    background: linear-gradient(160deg, #0b2a3f 0%, #0b6fa4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: min(92vw, 380px);
    box-shadow: 0 20px 50px rgba(10, 37, 64, 0.25);
    text-align: center;
}
.auth-card h1 { margin: 0 0 8px; }
.auth-card p { color: var(--muted); margin: 0 0 20px; }
.auth-card input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 12px;
}
.auth-card .btn { width: 100%; }
.error-text { color: #b91c1c; margin-top: 10px; font-size: 0.9rem; }

/* --- shell + sidebar --- */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.shell[hidden] { display: none; }

.sidebar { display: none; }
body.is-manager .sidebar:not([hidden]) {
    display: flex;
    flex-direction: column;
    width: 232px;
    flex: 0 0 232px;
    background: linear-gradient(180deg, #0b2a3f 0%, #0d3a55 100%);
    color: #e2eef6;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    min-height: 100vh;
}
.sidebar-brand { font-size: 1.05rem; font-weight: 700; padding: 4px 10px 18px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    color: #cfe2ef;
    font: inherit;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-radius: 9px;
    cursor: pointer;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.nav-ico { font-size: 1rem; width: 18px; text-align: center; }
.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    padding: 1px 6px;
    border-radius: 999px;
}
.sidebar-foot { margin-top: auto; padding: 12px 6px 4px; }
.sidebar-foot .role-badge { background: rgba(255, 255, 255, 0.14); color: #eaf4fb; }

/* --- layout --- */
.app { flex: 1 1 auto; max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; width: 100%; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 0;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
}
.topbar-title h1 { margin: 0; font-size: 1.6rem; }
.topbar-title p { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }
.topbar-controls { display: flex; align-items: center; gap: 14px; }
.venue-pick { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.venue-pick select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; }

.card {
    background: #fff;
    border-radius: 14px;
    padding: 22px 24px;
    margin-top: 22px;
    box-shadow: 0 4px 16px rgba(10, 37, 64, 0.06);
}
.card h2 { margin: 0 0 6px; font-size: 1.2rem; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }
.hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

/* --- form --- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 14px; }
.form-grid label { display: block; font-size: 0.85rem; color: #475569; margin-bottom: 4px; }
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}
.form-grid textarea { min-height: 76px; resize: vertical; }
.field-wide { grid-column: 1 / -1; }
.checkbox-field { display: flex; align-items: flex-end; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; }
.photo-field { grid-column: 1 / -1; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.photo-preview { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; background: #f1f5f9; border: 1px solid var(--line); display: none; }
.photo-preview.has-image { display: block; }

.message { margin-top: 12px; font-size: 0.92rem; }
.message.success { color: #15803d; }
.message.error { color: #b91c1c; }

/* --- table --- */
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f8fafc; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.thumb-empty { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 8px; border: 1px dashed #cbd5e0; color: #94a3b8; font-size: 0.68rem; text-align: center; }
.badge { padding: 2px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.badge-on { background: #c6f6d5; color: #22543d; }
.badge-off { background: #edf2f7; color: #475569; }

/* --- toggle switch --- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e0; border-radius: 999px; transition: 0.15s; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; }
.switch input:checked + .slider { background: #16a34a; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: default; }

/* --- role badge / pending tag / flag badge --- */
.role-badge { background: #e0f2fe; color: #075985; padding: 5px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.badge-flag { background: #fee2e2; color: #991b1b; }
.pending-tag { display: inline-block; margin-left: 6px; vertical-align: middle; background: #fef3c7; color: #92400e; padding: 1px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 600; }

/* --- approvals queue --- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head-controls { display: flex; align-items: center; gap: 8px; }
.card-head-controls select { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; }
.approvals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 12px; }
.approval-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.approval-card.flagged { border-color: #fca5a5; box-shadow: 0 0 0 1px #fca5a5 inset; }
.approval-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #f1f5f9; }
.approval-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.approval-title { font-weight: 600; font-size: 0.95rem; }
.approval-meta { color: var(--muted); font-size: 0.82rem; }
.approval-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.approval-flag { background: #fef2f2; color: #991b1b; border-radius: 8px; padding: 6px 8px; font-size: 0.82rem; }
.approval-trace { color: var(--muted); font-size: 0.74rem; word-break: break-word; }
.approval-actions { margin-top: 8px; }

/* --- settings --- */
.settings-status {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 4px 0 16px;
    font-size: 0.9rem;
    line-height: 1.7;
}
.settings-status .warn { color: #b45309; }
#settings-form input[type="password"],
#settings-form input[type="text"] {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
}
#s-clear-key { color: #b91c1c; }

@media (max-width: 640px) {
    body.is-manager .shell { flex-direction: column; }
    body.is-manager .sidebar:not([hidden]) {
        width: auto; flex: none; min-height: 0; position: static; flex-direction: row;
        flex-wrap: wrap; align-items: center; gap: 6px;
    }
    body.is-manager .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    body.is-manager .sidebar-brand { width: 100%; padding-bottom: 8px; }
    body.is-manager .sidebar-foot { margin: 0 0 0 auto; padding: 0; }
}
