:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #dde1e7;
    --text: #1b2230;
    --muted: #5d6778;
    --accent: #0f6e78;
    --accent-ink: #ffffff;
    --accent-soft: #e1f1f2;
    --danger: #b3261e;
    --danger-soft: #fbe9e7;
    --ok: #1c7c3c;
    --ok-soft: #e5f4ea;
    --warn: #8a5a00;
    --warn-soft: #fdf3dc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11151c;
        --surface: #181d26;
        --surface-2: #1f2530;
        --border: #2c3442;
        --text: #e6e9ef;
        --muted: #98a2b3;
        --accent: #3fb6c1;
        --accent-ink: #062a2e;
        --accent-soft: #15333a;
        --danger: #f2877e;
        --danger-soft: #3a1d1b;
        --ok: #6fd28e;
        --ok-soft: #173222;
        --warn: #f0c060;
        --warn-soft: #362a12;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- frame */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: .75rem 16px;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 650;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.brand-mark {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
}

.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }

.nav a {
    color: var(--muted);
    text-decoration: none;
    padding: .35rem .65rem;
    border-radius: 7px;
}

.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .sep { width: 1px; background: var(--border); margin: .25rem .4rem; }

.who { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .9rem; }

.page { max-width: 1100px; margin: 0 auto; padding: 1.75rem 16px 4rem; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-head p { margin: 0; }

.guest {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 16px;
}

.guest-card { width: 100%; max-width: 440px; }
.guest-card.wide { max-width: 640px; }
.guest-brand { justify-content: center; margin-bottom: 1.25rem; font-size: 1.05rem; }

/* ---------------------------------------------------------------- blocks */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.card + .card, .card + .section, .section + .card { margin-top: 1.25rem; }
.card > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.zone-card { display: flex; flex-direction: column; gap: .75rem; text-decoration: none; color: inherit; }
.zone-card:hover { border-color: var(--accent); }
.zone-card h2 { font-family: var(--mono); font-size: 1.05rem; margin: 0; word-break: break-all; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }

.meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}

.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.count {
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: .72rem;
    padding: 0 .4rem;
    margin-left: .25rem;
    font-weight: 700;
}

/* ---------------------------------------------------------------- alerts */

.alert {
    border-radius: var(--radius);
    padding: .8rem 1rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert ul { margin: 0; padding-left: 1.1rem; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .83rem; margin-top: .3rem; }
.error-text { color: var(--danger); font-size: .85rem; margin-top: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .55rem .7rem;
}

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

textarea { min-height: 90px; resize: vertical; }

.code-input {
    font-family: var(--mono);
    font-size: 1.5rem !important;
    letter-spacing: .4em;
    text-align: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font: inherit;
    font-weight: 600;
    border-radius: 8px;
    padding: .55rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.link { border: 0; background: none; color: var(--muted); padding: .3rem .4rem; font-weight: 500; }
.btn.link:hover { color: var(--text); }

.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 140px; margin-bottom: 0; }
.row > .field.grow { flex: 3 1 220px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }

.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 0 -1.5rem; padding: 0 1.5rem; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th, td { padding: .6rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions-cell { text-align: right; white-space: nowrap; }
td .row { flex-wrap: nowrap; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------------------------------------------------------------- 2FA */

.challenge { text-align: center; }

.challenge-number {
    font-size: 3.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .05em;
    color: var(--accent);
    line-height: 1.1;
    margin: .5rem 0;
    min-height: 4rem;
}

.challenge-status { color: var(--muted); min-height: 1.5rem; }
.challenge-status.error { color: var(--danger); }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    vertical-align: -2px;
    margin-right: .35rem;
}

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

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.qr {
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    display: inline-block;
    line-height: 0;
    border: 1px solid var(--border);
}

.qr svg { width: 220px; height: 220px; max-width: 100%; }

.steps { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; justify-items: center; } }

.summary-box {
    background: var(--warn-soft);
    color: var(--text);
    border-left: 3px solid var(--warn);
    border-radius: 6px;
    padding: .75rem 1rem;
    margin: 1rem 0;
    font-weight: 600;
}

details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details[open] summary { margin-bottom: .75rem; }

.pagination { display: flex; gap: .5rem; margin-top: 1rem; justify-content: center; }

@media (max-width: 640px) {
    .card { padding: 1.1rem; }
    .table-wrap { margin: 0 -1.1rem; padding: 0 1.1rem; }
    .who .name { display: none; }
}

.flush { margin: 0; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }

progress.meter {
    appearance: none;
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: 3px;
    background: var(--surface-2);
    overflow: hidden;
}
progress.meter::-webkit-progress-bar { background: var(--surface-2); }
progress.meter::-webkit-progress-value { background: var(--accent); }
progress.meter::-moz-progress-bar { background: var(--accent); }

pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
    overflow-x: auto;
    white-space: pre;
}
