:root {
    color-scheme: light;
    --navy: #123859;
    --navy-dark: #0b263d;
    --gold: #e5ad32;
    --surface: #ffffff;
    --background: #f2f5f8;
    --border: #d9e0e7;
    --text: #17202a;
    --muted: #637180;
    --success: #177245;
    --danger: #b42318;
    --warning: #8b5d00;
    --radius: 14px;
    --shadow: 0 12px 30px rgba(14, 36, 56, 0.08);
}

* { box-sizing: border-box; }

html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--background); color: var(--text); }
body { margin: 0; min-height: 100vh; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { display: grid; width: 58px; height: 58px; margin-bottom: 20px; place-items: center; border-radius: 16px; background: var(--navy); color: white; font-weight: 900; }

.auth-body { display: grid; place-items: center; padding: 30px 16px; background: linear-gradient(145deg, #eef3f7, #dfe8ef); }
.auth-card { width: min(460px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.wide-card { width: min(620px, 100%); }
.auth-card h1 { margin: 0 0 10px; }

.stack-form { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; color: #304052; font-size: .92rem; font-weight: 700; }
label small { font-weight: 500; color: var(--muted); }
input, select, textarea {
    width: 100%; padding: 11px 12px; border: 1px solid #bfc9d3; border-radius: 9px; background: white; color: var(--text); outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(18, 56, 89, .12); }
input[type="checkbox"] { width: auto; }
.checkbox-label { display: flex; align-items: center; gap: 9px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 750; }
.button-primary { background: var(--navy); color: white; }
.button-secondary { border-color: var(--border); background: white; color: var(--navy); }
.button-danger { background: #fff1f0; color: var(--danger); border-color: #f4c7c3; }
.button-small { min-height: 34px; padding: 7px 11px; font-size: .86rem; }

.alert { margin: 18px 0; padding: 13px 15px; border-radius: 10px; }
.alert-success { background: #e8f6ef; color: var(--success); }
.alert-error { background: #fff0ef; color: var(--danger); }
.alert-warning { background: #fff7df; color: var(--warning); }

.requirement-list { display: grid; gap: 8px; margin: 22px 0; }
.requirement { display: flex; gap: 9px; align-items: center; padding: 9px 11px; border-radius: 8px; background: #f6f8fa; }
.requirement span { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: white; font-weight: 900; }
.requirement.passed span { background: var(--success); }
.requirement.failed span { background: var(--danger); }

.public-header { border-bottom: 1px solid var(--border); background: white; }
.header-row { display: flex; min-height: 68px; align-items: center; justify-content: space-between; gap: 20px; }
.public-brand { color: var(--navy); font-size: 1.25rem; font-weight: 900; text-decoration: none; }
.public-header nav { display: flex; gap: 18px; }
.public-header nav a { text-decoration: none; font-weight: 700; }
.public-main { padding-top: 34px; padding-bottom: 60px; }
.hero { padding: clamp(28px, 6vw, 72px); border-radius: 24px; background: linear-gradient(135deg, var(--primary), #0b263d); color: white; box-shadow: var(--shadow); }
.hero .eyebrow { color: var(--secondary); }
.hero h1 { max-width: 850px; margin: 0; font-size: clamp(2rem, 6vw, 4.5rem); }
.hero h2 { margin: 10px 0 0; color: var(--secondary); }
.hero p { max-width: 760px; line-height: 1.65; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-meta span { padding: 8px 12px; border-radius: 99px; background: rgba(255,255,255,.14); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: 0 7px 20px rgba(14, 36, 56, .05); }
.card h3 { margin-top: 0; }
.empty-state { padding: 70px 20px; border: 1px dashed #aebbc7; border-radius: 18px; text-align: center; background: white; }

.admin-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: var(--navy-dark); color: white; overflow-y: auto; }
.sidebar-brand { margin: 0 10px 26px; font-size: 1.25rem; font-weight: 900; }
.sidebar-brand small { display: block; margin-top: 4px; color: #9db2c4; font-size: .72rem; font-weight: 600; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { padding: 10px 12px; border-radius: 8px; color: #dce7ef; text-decoration: none; font-weight: 650; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.1); color: white; }
.sidebar-footer { margin-top: 28px; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.12); color: #b9c9d6; font-size: .85rem; }
.sidebar-footer a { color: white; }
.admin-content { min-width: 0; padding: 30px clamp(18px, 4vw, 50px) 60px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header h1 { margin: 0 0 6px; }
.page-header p { margin: 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 18px; }
.toolbar label { min-width: 210px; }
.panel { margin-bottom: 22px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: 0 6px 18px rgba(14,36,56,.04); }
.panel h2, .panel h3 { margin-top: 0; }
.subpanel { margin-top: 18px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafb; }
.subpanel-new { border-style: dashed; background: #fbfcfd; }
.subpanel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.subpanel-head h2, .subpanel-head h3 { margin-bottom: 7px; }
.subpanel-head p { margin-top: 0; }
.danger-check { color: var(--danger); white-space: nowrap; }
.sync-status { margin: 16px 0 0; padding: 11px 13px; border-radius: 9px; background: #edf5e9; color: #30542a; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid #e6ebef; text-align: left; vertical-align: top; }
th { color: #536373; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; }
td.actions { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; background: #edf2f6; color: #425466; font-size: .78rem; font-weight: 750; }
.badge-success { background: #e4f5ec; color: var(--success); }
.badge-warning { background: #fff5d8; color: var(--warning); }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
.metric strong { display: block; margin-top: 5px; color: var(--navy); font-size: 2rem; }
.inline-form { display: inline; }
.section-divider { margin: 26px 0; border: 0; border-top: 1px solid var(--border); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 750; letter-spacing: .05em; }

.pass-shell { width: min(620px, calc(100% - 28px)); margin: 28px auto; }
.pass-card { overflow: hidden; border: 1px solid var(--border); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.pass-head { padding: 28px; background: var(--navy); color: white; text-align: center; }
.pass-body { padding: 28px; }
.qr-box { display: grid; width: 220px; min-height: 220px; margin: 20px auto; place-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: white; }
.qr-box img, .qr-box canvas { max-width: 100%; height: auto; }
.progress-track { height: 12px; overflow: hidden; border-radius: 99px; background: #e7edf2; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.station-list { display: grid; gap: 8px; margin-top: 18px; }
.station-row { display: flex; justify-content: space-between; gap: 10px; padding: 11px 12px; border-radius: 9px; background: #f4f7f9; }
.station-row.done { background: #e9f6ef; }

.scanner-shell { width: min(840px, calc(100% - 28px)); margin: 24px auto 60px; }
.scanner-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.scanner-panel { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: white; }
#reader { width: 100%; margin-top: 16px; }
.scan-success { padding: 22px; border: 2px solid #8fd0ad; border-radius: 14px; background: #eaf8f1; }

@media (max-width: 820px) {
    .admin-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
    .sidebar-brand { margin-bottom: 12px; }
    .sidebar nav { display: flex; overflow-x: auto; }
    .sidebar nav a { white-space: nowrap; }
    .sidebar-footer { display: none; }
    .admin-content { padding-top: 22px; }
}

@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .page-header, .scanner-header { display: block; }
    .page-header .button, .scanner-header .button { margin-top: 12px; }
    .auth-card { padding: 24px 20px; }
    .panel { padding: 17px; }
    .subpanel-head { display: block; }
    .subpanel-head form, .subpanel-head .danger-check { margin-top: 12px; }
}
