/*
 * BuddyBeam for organisations. One stylesheet, no build step.
 * Colours and fonts follow the BuddyBeam app (lib/app/config/theme in the
 * Flutter app). html.is-app = shown inside the app's WebView: bottom tabs,
 * app bar, safe areas, no website menu or footer.
 */

:root {
    --bg: #FBFAFF;
    --surface: #FFFFFF;
    --surface-2: #F7F5FC;
    --ink: #1E1B2E;
    --ink-soft: #4A4760;
    --muted: #6E6A80;
    --line: #E9E4F5;
    --primary: #5B3FC4;
    --primary-ink: #FFFFFF;
    --primary-mist: #F1ECFD;
    --primary-press: #4A31A8;
    --ok: #1D6B6D;
    --ok-bg: #E2F3F1;
    --warn: #7A5200;
    --warn-bg: #FFF3D6;
    --danger: #B3261E;
    --danger-bg: #FCE8E6;
    --info: #2F5DA8;
    --info-bg: #EAF0FB;
    --shadow: 0 1px 2px rgba(30, 27, 46, .05), 0 4px 16px rgba(30, 27, 46, .05);
    --shadow-up: 0 -8px 32px rgba(30, 27, 46, .14);
    --radius: 18px;
    --radius-sm: 12px;
    --font-body: 'Atkinson Hyperlegible', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-head: 'Quicksand', var(--font-body);
    --tabbar-h: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --gutter: 16px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #14121F;
        --surface: #1F1C2E;
        --surface-2: #262236;
        --ink: #ECEAF5;
        --ink-soft: #C9C5DA;
        --muted: #A29DB8;
        --line: #34304A;
        --primary: #B9A6F5;
        --primary-ink: #14121F;
        --primary-mist: #2E2850;
        --primary-press: #A48FEF;
        --ok: #6FD8C9;
        --ok-bg: #173A38;
        --warn: #F6C76A;
        --warn-bg: #3A2F14;
        --danger: #FFB4AB;
        --danger-bg: #44201D;
        --info: #9DBBF0;
        --info-bg: #1E2A44;
        --shadow: none;
        --shadow-up: 0 -8px 32px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #14121F; --surface: #1F1C2E; --surface-2: #262236; --ink: #ECEAF5; --ink-soft: #C9C5DA;
    --muted: #A29DB8; --line: #34304A; --primary: #B9A6F5; --primary-ink: #14121F; --primary-mist: #2E2850;
    --primary-press: #A48FEF; --ok: #6FD8C9; --ok-bg: #173A38; --warn: #F6C76A; --warn-bg: #3A2F14;
    --danger: #FFB4AB; --danger-bg: #44201D; --info: #9DBBF0; --info-bg: #1E2A44; --shadow: none;
    --shadow-up: 0 -8px 32px rgba(0, 0, 0, .5); color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 var(--font-body);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--primary); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* The app should feel like an app: no page bounce (we have our own pull to refresh), no long-press text menus on controls. */
html.is-app, html.is-app body { overscroll-behavior-y: none; }
html.is-app .tab, html.is-app .btn, html.is-app .row-tap, html.is-app .segment, html.is-app .icon-btn,
html.is-app .quick-btn, html.is-app .fab, html.is-app .page-header h1 { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
a, button { touch-action: manipulation; }

/* ---------- Shell ---------- */

.shell { min-height: 100dvh; }
.main {
    padding: 0 var(--gutter) calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
    max-width: 1080px;
    margin: 0 auto;
    outline: none;
}
.page { animation: page-in .22s ease-out; }
.page:has(.fab) { padding-bottom: 72px; } /* the + button never covers the last row */
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }

.sidebar { display: none; }

@media (min-width: 1024px) {
    html.is-web .shell { display: grid; grid-template-columns: 264px 1fr; }
    html.is-web .main { padding: 0 40px 48px; width: 100%; }
    html.is-web .tabbar, html.is-web .fab { display: none; }
    html.is-web .sidebar {
        display: flex; flex-direction: column; gap: 8px;
        position: sticky; top: 0; align-self: start; height: 100dvh; overflow-y: auto;
        padding: 24px 16px; border-right: 1px solid var(--line); background: var(--surface);
    }
}
@media (max-width: 1023px) { .hide-compact { display: none !important; } }
html.is-app .hide-compact { display: none !important; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 4px 8px 16px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 12px; flex: none;
    background: radial-gradient(circle at 30% 30%, #F6B73C 0 22%, transparent 23%), linear-gradient(135deg, #5B3FC4, #8E74E8);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-head); font-size: 1.1rem; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.brand-lg { justify-content: center; padding-bottom: 8px; }
.brand-lg .brand-mark { width: 44px; height: 44px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-group { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
.side-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 0; background: none; width: 100%;
    color: var(--ink-soft); text-decoration: none; font-weight: 700; text-align: left;
}
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.is-on { background: var(--primary-mist); color: var(--primary); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.side-user > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-user small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.web-foot { color: var(--muted); font-size: .875rem; text-align: center; padding: 40px 0 0; }

/* Bottom tabs: phones on the website, always in the app. */
.tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 30;
    display: flex; justify-content: space-around;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding: 0 8px var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--line);
}
.tab {
    flex: 1; max-width: 120px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 700;
    transition: color .15s;
}
.tab .icon { padding: 3px 16px; box-sizing: content-box; border-radius: 999px; transition: background .2s, transform .15s; }
.tab.is-on { color: var(--primary); }
.tab.is-on .icon { background: var(--primary-mist); }
.tab:active .icon { transform: scale(.9); }

/* ---------- Page header (the app bar in the app) ---------- */

.page-header {
    position: sticky; top: 0; z-index: 20;
    margin: 0 calc(var(--gutter) * -1) 12px;
    padding: calc(var(--safe-top) + 14px) var(--gutter) 10px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
html.is-web .page-header { position: static; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding-top: 28px; }
@media (min-width: 1024px) { html.is-web .page-header { margin: 0 0 16px; padding: 36px 0 8px; } }
.page-header-bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.page-header-text { flex: 1; min-width: 0; }
.page-header h1 { font-size: 1.6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-subtitle { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-actions { display: flex; gap: 8px; flex: none; }
.page-header-below { margin-top: 10px; }
.back-btn { margin-left: -8px; }
@media (min-width: 1024px) { html.is-web .back-btn { display: none; } }

.subnav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.subnav a {
    padding: 7px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .9rem; white-space: nowrap;
    color: var(--ink-soft); background: var(--surface-2);
}
.subnav a.is-on { background: var(--ink); color: var(--bg); }

/* ---------- Layout helpers ---------- */

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.toolbar { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 760px) { .toolbar { flex-direction: row; align-items: center; } .toolbar .search { flex: 1; } }

/* ---------- Cards, stats, lists ---------- */

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.pad { padding: 18px; }
.pad-x { padding-left: 18px; padding-right: 18px; }
.card.pad > * + * { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 2px; }
.card > .card-head.pad-x { padding-top: 16px; padding-bottom: 6px; }
.card-link { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: .9rem; text-decoration: none; }
.lead { font-size: 1.15rem; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } .stats-3 { grid-template-columns: repeat(3, 1fr); } }
.stats-3 > :first-child { grid-column: 1 / -1; }
@media (min-width: 760px) { .stats-3 > :first-child { grid-column: auto; } }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.stat-num { font-family: var(--font-head); font-weight: 700; font-size: 1.85rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-num-sm { font-size: 1.2rem; padding-top: 6px; }
.stat-note { color: var(--muted); font-size: .8rem; }

.list { overflow: hidden; }
.row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 16px; min-height: 64px;
    background: none; border: 0; text-align: left; color: inherit; text-decoration: none;
}
.list > .row + .row, .list > .row-form + .row, .list > .row + .row-form, .list > [wire\:key] + [wire\:key] { border-top: 1px solid var(--line); }
.row-form { margin: 0; }
.row-tap { transition: background .12s; }
.row-tap:hover { background: var(--surface-2); }
.row-tap:active { background: var(--primary-mist); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title.row-wrap { white-space: normal; font-weight: 400; }
.row-sub { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: flex; align-items: center; gap: 6px; flex: none; }
.row-end-stack { flex-direction: column; align-items: flex-end; gap: 4px; }
.row-chevron { color: var(--muted); }
.row-icon {
    width: 40px; height: 40px; border-radius: 12px; flex: none;
    display: grid; place-items: center; background: var(--primary-mist); color: var(--primary);
}
.row-icon.tone-ok { background: var(--ok-bg); color: var(--ok); }
.day-label { font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 4px 4px 8px; font-family: var(--font-body); }

.avatar {
    --hue: 260;
    width: 40px; height: 40px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    font-weight: 700; font-size: .85rem; letter-spacing: .02em;
    background: hsl(var(--hue) 70% 92%); color: hsl(var(--hue) 45% 32%);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--hue) 30% 26%); color: hsl(var(--hue) 70% 86%); } }
:root[data-theme="dark"] .avatar { background: hsl(var(--hue) 30% 26%); color: hsl(var(--hue) 70% 86%); }
.avatar.is-muted { filter: grayscale(1); opacity: .6; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

.profile-card { display: flex; align-items: center; gap: 14px; }
.card.pad.profile-card > * + * { margin-top: 0; }
.profile-card > div { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }

.chip {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
    font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--ink-soft);
}
.chip.tone-ok { background: var(--ok-bg); color: var(--ok); }
.chip.tone-warn { background: var(--warn-bg); color: var(--warn); }
.chip.tone-danger { background: var(--danger-bg); color: var(--danger); }
.chip.tone-primary { background: var(--primary-mist); color: var(--primary); }
.chip.tone-muted { background: var(--surface-2); color: var(--muted); }
.tone-danger-text { color: var(--danger); }
.tone-ok-text { color: var(--ok); }

.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.pairs dt { color: var(--muted); font-size: .8rem; font-weight: 700; }
.pairs dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pairs-list { grid-template-columns: 1fr; gap: 0; }
.pairs-list > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pairs-list > div:last-child { border-bottom: 0; }
.pairs-list dt { font-size: .9rem; font-weight: 400; flex: none; }
.pairs-stacked > div { flex-direction: column; align-items: flex-start; gap: 2px; }
.pairs-stacked dt { font-weight: 700; color: var(--ink); }
.pairs-stacked dd { text-align: left; font-weight: 400; color: var(--muted); justify-content: flex-start; }
.pairs-list dd { text-align: right; font-weight: 700; min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; justify-content: flex-end; }

/* Notices and banners */
.notice, .banner {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
    text-decoration: none; color: var(--ink); background: var(--info-bg);
}
.banner { align-items: flex-start; margin: 12px 0 0; }
.banner .icon { margin-top: 2px; }
.notice .icon, .banner .icon { color: var(--info); }
.notice-text { flex: 1; min-width: 0; }
.notice-action { display: inline-flex; align-items: center; font-weight: 700; font-size: .875rem; color: var(--primary); white-space: nowrap; }
.tone-warn.notice, .tone-warn.banner { background: var(--warn-bg); }
.tone-warn.notice .icon, .tone-warn.banner .icon { color: var(--warn); }
.tone-danger.notice { background: var(--danger-bg); }
.tone-danger.notice .icon { color: var(--danger); }
a.notice:active { transform: scale(.99); }

/* Quick actions: big, thumb-sized */
.quick { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter); }
.quick-btn {
    display: inline-flex; align-items: center; gap: 8px; flex: none;
    padding: 12px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
    font-weight: 700; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.quick-btn:first-child { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.quick-btn:active { transform: scale(.97); }

/* Seats used */
.meter-top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; }
.meter-num { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-num strong { color: var(--ink); }
.meter-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .5s ease; }
.meter.is-near .meter-fill { background: #E0A12A; }
.meter.is-full .meter-fill { background: var(--danger); }

/* New people per week */
.bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 132px; align-items: end; }
.bar { display: grid; grid-template-rows: 18px 1fr 18px; height: 100%; text-align: center; }
.bar-num { font-size: .75rem; font-weight: 700; color: var(--ink-soft); }
.bar-fill { align-self: end; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--bg))); min-height: 4px; }
.bar-label { font-size: .7rem; color: var(--muted); }

/* ---------- Controls ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
    font-weight: 700; text-decoration: none; white-space: nowrap;
    transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; }
.btn-sm { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-press); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger); }
.icon-btn {
    width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--ink);
    display: inline-grid; place-items: center; flex: none; text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }

.fab {
    display: none;
    position: fixed; z-index: 25; right: 20px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
    width: 58px; height: 58px; border-radius: 20px; border: 0;
    background: var(--primary); color: var(--primary-ink);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 40%, transparent);
    place-items: center; transition: transform .12s;
}
.fab:active { transform: scale(.92); }
@media (max-width: 1023px) { .fab { display: grid; } }
html.is-app .fab { display: grid; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 700; font-size: .9rem; }
.field-hint { color: var(--muted); font-size: .85rem; }
.field-error { color: var(--danger); font-size: .875rem; font-weight: 700; }
.field input, .field select, .field textarea, .search input {
    width: 100%; min-height: 50px; padding: 0 14px;
    border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
    font-size: 1rem; /* 16px stops iOS zooming in on focus */
    transition: border-color .15s, box-shadow .15s;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field textarea { min-height: 110px; padding: 12px 14px; resize: vertical; }
.field input[type="file"] { min-height: 0; padding: 12px 14px; }

/* A tick box with its words beside it */
.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 4px 0; cursor: pointer; }
.check-row input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--primary); }
.check-row small { display: block; color: var(--muted); font-size: .85rem; }

/* Things picked so far (documents, start times), each with a remove button */
.picked { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.picked li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: .9rem; }
.picked button { border: 0; background: none; padding: 2px; display: inline-flex; color: var(--muted); cursor: pointer; }
.inline-add { display: flex; gap: 8px; align-items: flex-end; }
.inline-add .field { flex: 1; }
.input-code { letter-spacing: .4em; font-size: 1.4rem !important; text-align: center; font-variant-numeric: tabular-nums; }
.input-with-btn { position: relative; display: block; }
.input-with-btn input { padding-right: 72px; }
.input-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--primary); font-weight: 700; padding: 8px 10px; }

.search { position: relative; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; border-radius: 999px; background: var(--surface); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search .spinner { position: absolute; right: 14px; }

.segments { display: flex; padding: 4px; gap: 2px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.segment {
    flex: 1; border: 0; background: none; padding: 8px 12px; border-radius: 10px; white-space: nowrap;
    font-weight: 700; font-size: .9rem; color: var(--ink-soft); transition: background .15s, color .15s;
}
.segment b { font-weight: 700; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.segment.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segment.is-on { background: var(--primary-mist); } }

.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; text-align: left;
    border: 1.5px solid var(--line); background: var(--surface);
}
.radio-row span:last-child { display: flex; flex-direction: column; }
.radio-row small { color: var(--muted); font-size: .85rem; }
.radio-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; transition: border .15s; }
.radio-row.is-on { border-color: var(--primary); background: var(--primary-mist); }
.radio-row.is-on .radio-dot { border: 7px solid var(--primary); }

.option-card { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.option-card.is-off { opacity: .6; }
.option-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 1.05rem; }
.ticks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.ticks li { display: flex; gap: 6px; align-items: flex-start; }
.ticks .icon { color: var(--ok); margin-top: 3px; }
.price-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.price-option {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 10px 12px;
    border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); text-align: left;
}
.price-option span { font-size: .85rem; color: var(--muted); font-weight: 700; }
.price-option.is-on { border-color: var(--primary); background: var(--primary-mist); }

.invoice-total { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.invoice-total strong { font-family: var(--font-head); font-size: 2rem; }

.link-center { display: block; text-align: center; font-weight: 700; padding: 8px; margin-top: 4px; }

/* ---------- Sheets (bottom sheet on phones, dialog on wide screens) ---------- */

.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 18, 31, .45); }
.sheet {
    position: relative; width: 100%; max-height: calc(100dvh - var(--safe-top) - 24px);
    display: flex; flex-direction: column;
    background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-up);
    padding-bottom: var(--safe-bottom);
}
.sheet-grab { width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 10px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 4px 20px; flex: none; }
.sheet-head h2 { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { padding: 8px 20px 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-body > * + * { margin-top: 12px; }
.sheet-foot { display: flex; flex-direction: column; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); flex: none; }
.sheet-confirm .sheet-body h2 { font-size: 1.2rem; }
.sheet-confirm .sheet-foot { flex-direction: row; border-top: 0; }
.sheet-confirm .sheet-foot .btn { flex: 1; }
.sheet-enter { transition: transform .32s cubic-bezier(.2, .9, .3, 1), opacity .2s; }
.sheet-leave { transition: transform .22s ease-in, opacity .2s; }
.sheet-from { transform: translateY(100%); }

@media (min-width: 760px) {
    html.is-web .sheet-wrap { align-items: center; padding: 24px; }
    html.is-web .sheet { max-width: 520px; border-radius: 24px; padding-bottom: 0; }
    html.is-web .sheet-grab { display: none; }
    html.is-web .sheet-head { padding-top: 16px; }
    html.is-web .sheet-from { transform: translateY(16px) scale(.98); opacity: 0; }
}

/* ---------- Toasts ---------- */

.toasts {
    position: fixed; z-index: 80; left: 0; right: 0; top: calc(var(--safe-top) + 12px);
    display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px;
}
.toast {
    pointer-events: auto; max-width: 480px; padding: 12px 18px; border-radius: 16px;
    background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
    animation: toast-in .28s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.tone-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.96); } }

/* ---------- Empty, loading ---------- */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; }
.empty-icon { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; background: var(--primary-mist); color: var(--primary); margin-bottom: 4px; }
.empty-icon.tone-danger { background: var(--danger-bg); color: var(--danger); }
.empty-title { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; }
.empty-text { color: var(--muted); max-width: 36ch; margin-bottom: 8px; }

.spinner {
    width: 22px; height: 22px; border-radius: 50%; display: inline-block;
    border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; opacity: .85;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.load-more { display: grid; place-items: center; min-height: 48px; color: var(--muted); }

.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.sk-title { height: 30px; width: 45%; }
.sk-line { height: 13px; width: 70%; margin: 4px 0; }
.sk-line.short { width: 40%; }
.sk-num { height: 30px; width: 50%; margin-top: 8px; }
.sk-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.sk-card { padding: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Pull to refresh (app only, portal.js) */
.ptr {
    position: fixed; z-index: 40; left: 50%; top: calc(var(--safe-top) + 8px);
    width: 40px; height: 40px; margin-left: -20px; border-radius: 50%;
    display: grid; place-items: center; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-up);
    transform: translateY(-80px); opacity: 0; pointer-events: none;
}
.ptr.is-loading .icon { animation: spin .7s linear infinite; }

/* ---------- Login and other pages without the menu ---------- */

.guest-main {
    min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
    padding: calc(var(--safe-top) + 24px) var(--gutter) calc(var(--safe-bottom) + 24px);
    background: radial-gradient(120% 60% at 50% 0%, var(--primary-mist), var(--bg) 70%);
}
.guest-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
html.is-web .guest-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 28px 24px; box-shadow: var(--shadow); }
.guest-card .banner { margin: 0; }
.guest-title { font-size: 1.6rem; }
.guest-card form { margin-top: 8px; }
.guest-foot { color: var(--muted); font-size: .875rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
