:root {
    --ink: #0d1b2a;
    --ink-soft: #1d3349;
    --body: #132435;
    --muted: #64748b;
    --line: #dde5ee;
    --bg: #eef2f7;
    --panel: #ffffff;
    --primary: #0e7c66;
    --primary-dark: #0a5f4e;
    --primary-soft: #e3f5f0;
    --amber: #b45309;
    --amber-soft: #fdf1dd;
    --red: #b42318;
    --red-soft: #fdeceb;
    --blue-soft: #e7eefc;
    --blue: #1f4ba8;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(13, 27, 42, .06), 0 12px 28px -18px rgba(13, 27, 42, .35);
    --font: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--body);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -.01em; }

button, input, textarea { font: inherit; color: inherit; }

.muted { color: var(--muted); margin: 0; font-size: 13px; }

/* ---------- app bar ---------- */

.app-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 12px 28px;
    background: var(--ink);
    color: #f8fafc;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(150deg, #14a085, #0a5f4e);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -.03em;
}

.brand-mark-image {
    overflow: hidden;
    background: rgba(255, 255, 255, .1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.brand-mark-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .01em; }
.brand-text small { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: #8fa3b8; }

.tabs { display: flex; gap: 4px; }

.tab {
    padding: 9px 15px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #b9c8d8;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.tab:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.tab.is-active { background: rgba(255, 255, 255, .12); color: #fff; }

.bar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    background: rgba(255, 255, 255, .06);
    color: #dce6f0;
    font-size: 12.5px;
    cursor: pointer;
}

.sync-pill:hover { background: rgba(255, 255, 255, .12); }

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}

.sync-pill[data-state="offline"] .sync-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.sync-pill[data-state="busy"] .sync-dot { background: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, .18); }
.sync-pill[data-state="error"] .sync-dot { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .18); }

/* ---------- layout ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 28px 28px 64px; }

.view[hidden] { display: none; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-head h1 { font-size: 23px; font-weight: 650; color: var(--ink); }
.page-head .muted { margin-top: 4px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 { font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }

.count {
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 550;
    cursor: pointer;
    transition: background .14s ease, border-color .14s ease, color .14s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfe6dc; }
.btn-secondary:hover { background: #d3eee7; }

.btn-quiet { background: var(--panel); color: var(--body); border-color: var(--line); }
.btn-quiet:hover { background: #f6f9fc; }

.app-bar .btn-quiet { background: rgba(255, 255, 255, .08); color: #e6eef6; border-color: rgba(255, 255, 255, .18); }
.app-bar .btn-quiet:hover { background: rgba(255, 255, 255, .16); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 5px 8px; font-size: 12.5px; }
.btn-ghost:hover { color: var(--red); background: var(--red-soft); }

.btn-danger { background: var(--red-soft); color: var(--red); border-color: #f6d4d1; }

/* ---------- stats ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stat-value { margin-top: 8px; font-size: 28px; font-weight: 650; color: var(--ink); letter-spacing: -.02em; line-height: 1; }
.stat-note { margin-top: 7px; font-size: 12.5px; color: var(--muted); }
.stat[data-tone="alert"] { border-color: #f3d6a7; background: linear-gradient(180deg, #fffdf8, #fff); }
.stat[data-tone="alert"] .stat-value { color: var(--amber); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; }

/* ---------- lists ---------- */

.list { display: flex; flex-direction: column; }

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    border-top: 1px solid #eef2f7;
}

.list-row:first-child { border-top: 0; }
.list-row:hover { background: #fafcfe; }

.avatar {
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 650;
    font-size: 14px;
    text-transform: uppercase;
}

.avatar[data-tone="warn"] { background: var(--amber-soft); color: var(--amber); }

.who { min-width: 0; flex: 1; }
.who strong { display: block; font-size: 14px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-meta { font-size: 12.5px; color: var(--muted); text-align: right; white-space: nowrap; }
.row-meta strong { display: block; color: var(--body); font-weight: 600; }

.row-actions { display: flex; gap: 6px; }

.empty {
    padding: 34px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}

.empty strong { display: block; color: var(--body); font-size: 15px; font-weight: 600; margin-bottom: 4px; }

.empty .btn { margin-top: 14px; }

/* ---------- table ---------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.chips { display: inline-flex; gap: 4px; padding: 4px; background: #e3eaf3; border-radius: 11px; }

.chip {
    padding: 7px 13px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
}

.chip:hover { color: var(--ink); }
.chip.is-active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(13, 27, 42, .12); }

.search {
    min-width: 280px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    font-size: 14px;
}

.search:focus, .field input:focus, .field textarea:focus {
    outline: 2px solid rgba(14, 124, 102, .28);
    outline-offset: 1px;
    border-color: var(--primary);
}

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 11.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    white-space: nowrap;
}

.table td { padding: 13px 18px; border-top: 1px solid #eef2f7; vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: #fafcfe; }

.col-actions { text-align: right; }

.person { display: flex; align-items: center; gap: 11px; min-width: 190px; }

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status[data-status="onsite"] { background: var(--primary-soft); color: var(--primary-dark); }
.status[data-status="expected"] { background: var(--blue-soft); color: var(--blue); }
.status[data-status="checked_out"] { background: #eef1f5; color: #526072; }
.status[data-status="overstay"] { background: var(--amber-soft); color: var(--amber); }
.status[data-status="late"] { background: var(--amber-soft); color: var(--amber); }

.cell-when { font-size: 13px; color: var(--body); white-space: nowrap; }
.cell-when small { display: block; color: var(--muted); font-size: 12px; }
.cell-host { font-size: 13px; color: var(--body); min-width: 130px; }
.cell-host small { display: block; color: var(--muted); font-size: 12px; }

.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- form ---------- */

.form { padding: 20px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field em { color: var(--primary); font-style: normal; }

.field input, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfdfe;
    font-size: 14px;
}

.field textarea { resize: vertical; min-height: 62px; }

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

.form-note { font-size: 12.5px; color: var(--muted); }
.form-note[data-tone="error"] { color: var(--red); font-weight: 550; }
.form-note[data-tone="ok"] { color: var(--primary); font-weight: 550; }

/* ---------- branding ---------- */

.logo-note { margin: 8px 0 0; max-width: 64ch; font-size: 13.5px; line-height: 1.6; }

.logo-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
}

.logo-preview-mark { display: grid; place-items: center; min-width: 38px; }

.logo-preview-text { display: flex; flex-direction: column; gap: 2px; }
.logo-preview-text strong { font-size: 13.5px; color: var(--ink); }
.logo-preview-text span { font-size: 12.5px; color: var(--muted); }

.logo-preview-icon {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-left: auto;
    padding-left: 16px;
    border-left: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}

.logo-preview-icon img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(13, 27, 42, .22);
}

@media (max-width: 560px) {
    .logo-preview-icon { margin-left: 0; padding-left: 0; border-left: 0; }
}
.field-hint[data-tone="error"] { color: var(--red); }

/* ---------- toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 60;
    transform: translate(-50%, 18px);
    padding: 11px 18px;
    border-radius: 11px;
    background: var(--ink);
    color: #f2f6fa;
    font-size: 13.5px;
    box-shadow: 0 16px 32px -16px rgba(13, 27, 42, .7);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- badge ---------- */

.badge-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(9, 18, 30, .62);
    backdrop-filter: blur(3px);
}

.badge-overlay[hidden] { display: none; }

.badge-sheet { display: flex; flex-direction: column; gap: 16px; align-items: center; }

.badge-card {
    width: 340px;
    padding: 22px 22px 18px;
    border-radius: 16px;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .55);
}

.badge-org {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--ink);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: var(--muted);
}

.badge-org strong { color: var(--ink); letter-spacing: .06em; font-size: 13px; }
.badge-role { margin: 14px 0 2px; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--primary); font-weight: 700; }
.badge-name { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.badge-company { font-size: 13.5px; color: var(--body); margin-top: 2px; }

.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 16px 0 14px; }
.badge-grid dt { font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.badge-grid dd { margin: 1px 0 0; font-size: 12.5px; font-weight: 550; color: var(--ink); }

.badge-code-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    background: #f4f7fa;
}

.badge-code-box span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.badge-code-box strong { font-family: var(--mono); font-size: 15px; letter-spacing: .08em; }

.badge-foot { margin-top: 12px; font-size: 10.5px; color: var(--muted); text-align: center; }

.badge-toolbar { display: flex; gap: 10px; }

/* ---------- print ---------- */

#print-root { display: none; }

.print-page { color: #000; font-family: var(--font); }

.roster-page h1 { font-size: 19px; margin-bottom: 2px; }
.roster-page .roster-meta { font-size: 12px; margin-bottom: 14px; color: #333; }

.roster-page table { width: 100%; border-collapse: collapse; font-size: 12px; }
.roster-page th, .roster-page td { padding: 7px 8px; border-bottom: 1px solid #999; text-align: left; }
.roster-page th { border-bottom: 2px solid #000; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }

@media print {
    @page { margin: 12mm; }

    body.is-printing > *:not(#print-root) { display: none !important; }
    body.is-printing #print-root { display: block; }

    .badge-card {
        width: 88mm;
        min-height: 120mm;
        padding: 8mm 7mm;
        border: 1px solid #000;
        border-radius: 4mm;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .badge-card .badge-name { font-size: 21pt; }
    .badge-card .badge-role { font-size: 8pt; }
    .badge-card .badge-company { font-size: 10pt; }
    .badge-card .badge-grid dd { font-size: 9pt; }
    .badge-card .badge-code-box strong { font-size: 12pt; }
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .app-bar { flex-wrap: wrap; gap: 10px; padding: 10px 14px 12px; }
    .app-bar .brand { margin-right: auto; }

    /* On a phone the bar's links become one full-width row of thumb-sized
       buttons instead of a cramped line beside the brand. */
    .bar-tools {
        order: 4;
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
        gap: 8px;
    }

    .bar-tools .btn { flex: 1 1 0; min-width: 0; min-height: 44px; }
    .app-bar .whoami-static { display: none; }

    .tabs {
        order: 3;
        width: 100%;
        gap: 4px;
        padding-bottom: 2px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex: 1 0 auto; min-height: 40px; padding: 10px 14px; text-align: center; }

    .page { padding: 20px 16px 56px; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .col-host { display: none; }
    .cell-host { display: none; }
    .search { min-width: 0; width: 100%; }
    .col-actions { text-align: left; }
    .actions { justify-content: flex-start; }

    /* The desk's main action is the easiest thing on the page to reach. */
    .scan-panel { flex-direction: column; align-items: stretch; }
    .scan-panel .btn { width: 100%; min-height: 48px; font-size: 15px; }

    .roster-actions .btn { min-height: 44px; }
}

@media (max-width: 460px) {
    .stats { grid-template-columns: minmax(0, 1fr); }
    .badge-card { width: 100%; }
}

/* ---------- staff identity ---------- */

.whoami {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 4px;
    font-size: 13px;
    color: #cfdae6;
    white-space: nowrap;
    text-decoration: none;
}

.whoami-avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 12px;
    font-weight: 650;
}

/* ---------- sign in ---------- */

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 36px 20px;
    background:
        radial-gradient(1100px 520px at 50% -140px, #16324a 0%, transparent 62%),
        var(--bg);
}

.auth-stack { width: 100%; max-width: 412px; }

.auth-card {
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 28px 60px -34px rgba(13, 27, 42, .55);
}

.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-brand .brand-text strong { color: var(--ink); font-size: 16px; }
.auth-brand .brand-text small { color: var(--muted); }

.auth-card h1 { font-size: 21px; font-weight: 650; color: var(--ink); margin-bottom: 5px; }
.auth-card .muted { font-size: 13.5px; line-height: 1.55; }

.auth-form { display: flex; flex-direction: column; gap: 15px; margin-top: 22px; }
.btn-block { width: 100%; padding: 11px 16px; }

.auth-error {
    margin: 16px 0 0;
    padding: 10px 13px;
    border: 1px solid #f6d4d1;
    border-radius: 10px;
    background: var(--red-soft);
    color: var(--red);
    font-size: 13px;
}

.auth-note {
    margin: 16px 0 0;
    padding: 10px 13px;
    border: 1px solid #f3d6a7;
    border-radius: 10px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 13px;
}

.auth-foot {
    margin: 18px 0 0;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .02em;
}

@media (max-width: 760px) {
    .whoami-name { display: none; }
    .auth-card { padding: 24px 20px; }
}

/* ---------- staff administration ---------- */

a.tab { display: inline-flex; align-items: center; text-decoration: none; }

.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 18px; }

.panel-title {
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ink-soft);
}

.row-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.role-select {
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fcfdfe;
    font-size: 12.5px;
    color: var(--body);
}

.role-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.role-pill.role-top {
    background: var(--amber-soft);
    color: var(--amber);
}

.profile-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.action-note { font-size: 12.5px; }

.secret-panel {
    margin-top: 12px;
    padding: 16px 18px;
    border-color: #f3d6a7;
    background: #fffdf8;
}

.secret-panel p { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--amber); }

.secret-line {
    margin: 0;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--ink);
}

.secret-line code {
    padding: 3px 8px;
    border-radius: 6px;
    background: #f2e6cf;
    color: var(--ink);
    font-size: 14px;
    letter-spacing: .05em;
}

.field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfdfe;
    font-size: 14px;
}

/* ---------- registration form extras ---------- */

.field-hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.field[hidden] { display: none; }

.segmented {
    display: flex;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fcfdfe;
}

.seg {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.seg input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.seg:has(input:checked) {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.seg:focus-within { outline: 2px solid var(--primary-soft); }

/* ---------- administration shell ---------- */

.admin-body { background: var(--bg); }

.admin-shell {
    display: grid;
    grid-template-columns: 244px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-side {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 22px;
    height: 100vh;
    padding: 22px 16px;
    background: #0d1b2a;
    color: #cfdae6;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
}

.admin-brand .brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.admin-brand .brand-text strong { font-size: 15px; }
.admin-brand .brand-text small { font-size: 11.5px; color: #8fa6bd; letter-spacing: .03em; }

.admin-nav { display: flex; flex-direction: column; gap: 4px; }

.side-link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #b9c8d8;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.25;
}

.side-link small { font-size: 11.5px; color: #849bb3; }
.side-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-link.is-active { background: rgba(255, 255, 255, .13); color: #fff; font-weight: 600; }
.side-link.is-active small { color: #b9c8d8; }
.side-link-quiet { margin-top: 10px; border-top: 1px solid rgba(255, 255, 255, .09); border-radius: 0; padding-top: 14px; }

.admin-account {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, .09);
}

.admin-me {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    margin: 0 -8px;
    padding: 6px 8px;
    border-radius: 10px;
    color: #fff;
    text-decoration: none;
}

.admin-me:hover { background: rgba(255, 255, 255, .07); }

.admin-me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.admin-me-text .whoami-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-me-role { overflow: hidden; font-size: 11px; color: #849bb3; text-overflow: ellipsis; white-space: nowrap; }

.admin-account form { margin: 0; }
.side-signout { width: 100%; color: #cfdae6; border-color: rgba(255, 255, 255, .18); }
.side-signout:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.admin-main {
    width: 100%;
    max-width: 1080px;
    padding: 28px 30px 48px;
}

.admin-head { margin-bottom: 18px; }
.admin-head h1 { font-size: 22px; font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.admin-head .muted { font-size: 13.5px; }

@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; }

    .admin-side {
        position: static;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 14px;
        padding: 14px 16px;
    }

    .admin-nav { flex-direction: row; flex-wrap: wrap; }
    .side-link small { display: none; }
    .side-link-quiet { margin-top: 0; border-top: 0; padding-top: 9px; }
    .admin-account {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin-top: 0;
        margin-left: auto;
        padding-top: 0;
        border-top: 0;
    }

    .admin-me-text { display: none; }
    .side-signout { width: auto; }
    .admin-main { padding: 20px 16px 40px; }
    .admin-head h1 { font-size: 20px; }
    .side-link { justify-content: center; min-height: 44px; padding: 11px 14px; }
}

/* ---------- host live search ---------- */

.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

.combo { position: relative; }

.combo-list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 18px 40px -22px rgba(13, 27, 42, .45);
}

.combo-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.combo-list li.is-active,
.combo-list li:hover { background: var(--primary-soft); }

.combo-list li span { font-weight: 600; }

.combo-list li small { color: var(--muted); font-size: 12px; }

/* ---------- group bookings ---------- */

.tag {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 11.5px;
    font-weight: 600;
}

.tag-quiet { background: #eef2f7; color: var(--muted); }

.import-group { margin-top: 16px; }
.import-group strong {
    display: block;
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-soft);
}
.import-names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.import-names .tag { margin-top: 0; }
.import-group .muted { margin-top: 6px; }

.badge-group {
    margin: -6px 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

/* ---------- walk-in photo ---------- */

.photo-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.photo-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
}

.badge-photo {
    display: block;
    width: 76px;
    height: 76px;
    object-fit: cover;
    margin: 0 0 10px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, .35);
}

/* ---------- children & group members ---------- */

.checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    font-size: 13.5px;
    cursor: pointer;
}

.checkline input { width: 16px; height: 16px; accent-color: var(--primary); }

.checkline[hidden] { display: none; }

.age-set {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.age-set .field span { font-weight: 550; }

/* ---------- cars on a booking ---------- */

#car-list { gap: 10px; }

.car-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcfe;
}

.car-head {
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.car-card .form-grid { gap: 12px 14px; }

.car-line {
    display: block;
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--ink-soft);
}

/* ---------- reports & analytics ---------- */

.report-filters { margin-bottom: 18px; }
.report-filters .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 440px; }
.report-filters .form-actions { flex-wrap: wrap; }

.report-export { margin-bottom: 18px; }

.report-export-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
}

.report-export-row .panel-title { margin-bottom: 4px; }
.report-export-row .muted { max-width: 62ch; }
.report-export-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

.trend {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    padding: 18px;
    overflow-x: auto;
}

.trend-col {
    display: flex;
    flex: 1 0 16px;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 16px;
}

.trend-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    max-width: 30px;
    height: 150px;
}

.trend-bar {
    display: flex;
    flex-direction: column-reverse;
    width: 100%;
    min-height: 3px;
    border-radius: 5px 5px 0 0;
    overflow: hidden;
    background: #9ad3c7;
}

.trend-seg { display: block; width: 100%; }
.trend-seg[data-kind="walkin"] { background: var(--primary); }
.trend-seg[data-kind="pre"] { background: #9ad3c7; }

.trend-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

.split { display: flex; flex-direction: column; }

.split-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    border-top: 1px solid #eef2f7;
}

.split-row:first-child { border-top: 0; }

.split-name { flex: 0 0 132px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }

.split-track {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: var(--bg);
    overflow: hidden;
}

.split-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

.split-fill[data-tone="soft"] { background: #9ad3c7; }

.split-value { flex: 0 0 118px; text-align: right; font-size: 12.5px; color: var(--muted); }
.split-value strong { color: var(--ink); font-size: 14px; }

@media (max-width: 640px) {
    .trend-track { height: 110px; }
    .split-name { flex-basis: 100px; }
    .split-value { flex-basis: 96px; }
}

/* ---------- employee photos, roster & check-in ---------- */

.app-bar a.brand { text-decoration: none; }

a.tab { display: inline-flex; align-items: center; text-decoration: none; }

.whoami-static { cursor: default; }

.search-wide { flex: 1 1 320px; max-width: 460px; }

.avatar-photo { object-fit: cover; background: var(--bg); }

.photo-field {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.photo-field .photo-thumb {
    flex: 0 0 76px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--panel);
}

.photo-field .photo-thumb[hidden] { display: none; }

.photo-field-text { display: flex; flex: 1; flex-direction: column; gap: 6px; min-width: 220px; }

.photo-field-text input[type="file"] { font-size: 13px; }

.filter-empty {
    padding: 22px 18px;
    border-top: 1px solid #eef2f7;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.filter-empty[hidden] { display: none; }

.combo-list li { flex-direction: row; align-items: center; gap: 9px; }

.combo-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.combo-avatar {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--blue-soft);
}

.combo-avatar-initial {
    display: grid;
    place-items: center;
    color: var(--blue);
    font-size: 12px;
    font-weight: 650;
}

/* ---------- attendance ---------- */

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

.roster-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.roster-card[hidden] { display: none; }

.roster-person { display: flex; align-items: center; gap: 11px; min-width: 0; }

.roster-photo {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--bg);
}

.roster-initial { flex: 0 0 44px; width: 44px; height: 44px; font-size: 16px; }

.roster-state { margin: 0; font-size: 12.5px; color: var(--muted); }
.roster-state[data-state="in"] { color: var(--primary-dark); font-weight: 600; }

.roster-actions { display: flex; gap: 8px; margin-top: auto; }
.roster-actions .btn { flex: 1; }

.list-photo {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--line);
}

.camera-dialog {
    width: min(460px, 92vw);
    padding: 0;
    border: 0;
    border-radius: 16px;
    box-shadow: 0 40px 80px -30px rgba(13, 27, 42, .55);
}

.camera-dialog::backdrop { background: rgba(13, 27, 42, .55); }

.camera-dialog form { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 20px; }

.camera-dialog h2 { margin: 0 0 2px; font-size: 17px; }
.camera-dialog header p { margin: 0; }

.camera-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 220px;
    overflow: hidden;
    border-radius: 12px;
    background: #0d1b2a;
}

.camera-stage video,
.camera-stage img { display: block; width: 100%; max-height: 320px; object-fit: cover; }

.camera-stage video[hidden],
.camera-stage img[hidden] { display: none; }

.camera-stage[hidden] { display: none; }

/* The employee photo camera is framed like a passport photo: the preview shows
   exactly the part of the frame that is saved. */
#employee-photo-stage {
    position: relative;
    width: 100%;
    max-width: 300px;
    min-height: 0;
    margin: 0 auto;
    aspect-ratio: 3 / 4;
}

#employee-photo-stage video {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
}

#employee-photo-stage.is-live::after {
    content: "";
    position: absolute;
    inset: 6% 12% 18%;
    border: 2px dashed rgba(255, 255, 255, 0.45);
    border-radius: 50% / 42%;
    pointer-events: none;
}

.camera-note { margin: 0; padding: 20px 16px; color: #cbd5e1; font-size: 13px; text-align: center; }
.camera-note[hidden] { display: none; }

.camera-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.camera-actions .btn[hidden] { display: none; }

/* The scan dialog's buttons only appear once a person is recognised, so they
   must not be forced visible by the button display rule. */
.form-actions .btn[hidden] { display: none; }

/* Face scanning: the panel that opens the scan, and the person it recognises. */
.scan-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.scan-panel .panel-title { margin: 0 0 4px; }

.scan-panel p { margin: 0; max-width: 62ch; }

.scan-panel .btn { flex: 0 0 auto; }

.scan-match {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.scan-match[hidden] { display: none; }

.scan-face {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
}

.scan-face[hidden] { display: none; }

.scan-initial { width: 56px; height: 56px; font-size: 20px; }

.scan-match-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.scan-match-who strong { font-size: 15px; }
.camera-actions[hidden] { display: none; }

.file-btn { position: relative; overflow: hidden; cursor: pointer; }

/* The camera switch sits on the picture, so the lens can be changed without
   leaving the scan. */
.camera-flip {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    background: rgba(13, 27, 42, .74);
    color: #fff;
    border-color: rgba(255, 255, 255, .3);
}

.camera-flip:hover { background: rgba(13, 27, 42, .9); }
.camera-flip[hidden] { display: none; }

@media (max-width: 520px) {
    /* On a phone the camera dialog becomes a bottom sheet: full width, and the
       buttons under the thumb rather than over the keyboard area. */
    .camera-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        margin: auto auto 0 auto;
        border-radius: 18px 18px 0 0;
        overflow: auto;
    }

    .camera-dialog form { gap: 12px; padding: 18px 16px 22px; }

    .camera-stage { aspect-ratio: 4 / 3; min-height: 0; }

    .camera-stage video,
    .camera-stage img { height: 100%; max-height: none; object-fit: cover; }

    .form-actions .btn { flex: 1 1 auto; min-height: 46px; }
    .form-actions .form-note { flex-basis: 100%; }

    /* A field below 16px makes iOS zoom the whole page when it takes focus. */
    .page input, .page select, .page textarea, .search { font-size: 16px; }
}

