:root {
    --bg: #f5f6f8;
    --card: #fff;
    --text: #1d2330;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #3b4cca;
    --ok: #15803d;
    --warn: #b45309;
    --bad: #b91c1c;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
code { background: var(--line); padding: 0 .25rem; border-radius: 3px; }

.topbar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: .75rem 1.5rem;
    background: #1d2330;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: #fff; position: relative; }
.brand-logo { height: 2rem; width: auto; display: block; }
.brand-logo + .brand-name { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.nav-toggle {
    display: none;
    margin-left: auto;
    padding: .35rem;
    border: 1px solid rgb(255 255 255 / .25);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}
.nav-toggle:hover { background: rgb(255 255 255 / .08); }
.nav-toggle-bar { display: block; width: 1.25rem; height: 2px; background: currentColor; margin: 3px 0; border-radius: 1px; }

.site-nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin-left: auto; }
.site-nav-head { display: none; }
.site-nav-links { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: center; }
.site-nav a { color: #fff; opacity: .85; }
.site-nav a:hover { opacity: 1; }
.drawer-backdrop { display: none; }

main { max-width: 1180px; margin: 1.5rem auto; padding: 0 1rem; }
/* The dashboard uses the whole width: the filters take the left side, the content keeps its usual width. */
main.main-wide { max-width: none; padding: 0 1.5rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.card.narrow { max-width: 520px; }
.card-head, .page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.page-head { align-items: center; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }

table { width: 100%; border-collapse: collapse; }
table.card { padding: 0; overflow: hidden; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: .75rem 0; }
.bar span { display: block; height: 100%; background: var(--accent); }
.bar span.over { background: var(--bad); }

/* Sold seats: the number that matters most, right under the session date, and in each row. */
.sold-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .5rem; margin-top: .15rem; }
.sold-total { display: inline-block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sold-total .sold-number { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
td.sold-cell { font-weight: 700; font-size: 1.05rem; color: var(--text); }
td.platform-total { font-weight: 600; }

/* A platform row opens the tariff detail rows below it. The caret shows whether they are open. */
tbody.platform-group.has-tariffs tr.platform-row { cursor: pointer; }
tbody.platform-group.has-tariffs tr.platform-row:hover td { background: #f7f8fb; }
tbody.platform-group + tbody.platform-group tr.platform-row td { border-top: 2px solid var(--line); }
.row-toggle {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.row-toggle .caret {
    flex: none;
    width: .45rem;
    height: .45rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform .15s;
}
.row-toggle[aria-expanded="true"] .caret { transform: rotate(45deg); }
.row-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { .row-toggle .caret { transition: none; } }

tr.tariff-row { --tariff-background: #e7edf5; }
tr.tariff-row td { font-size: .9rem; color: #374151; background: var(--tariff-background); border-bottom-color: #cbd5e1; }
tr.tariff-row[hidden] { display: none; }
tr.tariff-row .tariff-cell { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr; }
tr.tariff-row .tariff-cell > div { min-width: 0; min-height: 0; }
tr.tariff-row.is-transitioning .tariff-cell { transition: grid-template-rows 160ms ease; }
tr.tariff-row.is-transitioning .tariff-cell > div { overflow: hidden; }
tr.tariff-row.is-transitioning td { transition: padding-top 160ms ease, padding-bottom 160ms ease; }
tr.tariff-row.is-collapsed .tariff-cell { grid-template-rows: 0fr; }
tr.tariff-row.is-collapsed td { padding-top: 0; padding-bottom: 0; border-bottom-width: 0; }
tr.tariff-row td.sold-cell { font-size: .95rem; color: var(--text); }
tr.tariff-row .muted, tr.tariff-row .tag:not(.ok):not(.warn):not(.bad):not(.busy) { color: #4b5563; }
td.tariff-label { padding-left: 2rem; box-shadow: inset 3px 0 #96a5bc; }
.tariff-name { display: block; max-width: min(14rem, 100%); padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; text-decoration: underline dotted; text-underline-offset: .15em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.tariff-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tariff-price { max-width: min(14rem, 100%); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tariff-name-full { max-width: min(26rem, calc(100vw - 2rem)); max-height: min(50vh, 20rem); padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); box-shadow: 0 6px 18px rgb(0 0 0 / .18); overflow-wrap: anywhere; }
@supports (position-area: bottom span-right) {
    .tariff-name-full { inset: auto; margin: .25rem 0 0; position-area: bottom span-right; position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline; }
}
form.quota-edit { margin: 0; }
.quota-input {
    width: 4.5rem;
    padding: .2rem .4rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: inherit;
}
.quota-input:hover { border-color: #cbd0d8; background: #fff; }
.quota-input:focus { border-color: var(--accent); background: #fff; outline: 2px solid rgb(59 76 202 / .25); }
.quota-input.dirty { border-color: var(--warn); background: #fffbeb; }
.quota-input:disabled { opacity: .6; cursor: progress; }
.quota-input::placeholder { color: #9ca3af; }
tr.tariff-row .quota-input::placeholder { color: #526070; }

.tag.busy { background: #dbeafe; color: #1d4ed8; position: relative; padding-left: 1.2rem; }
.tag.busy::before {
    content: '';
    position: absolute;
    left: .35rem;
    top: 50%;
    width: .55rem;
    height: .55rem;
    margin-top: -.3rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tag-spin .8s linear infinite;
}
@keyframes tag-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tag.busy::before { animation: none; } }

.tag { display: inline-block; padding: 0 .5rem; border-radius: 999px; font-size: .75rem; background: var(--line); color: var(--muted); }
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.warn { background: #fef3c7; color: var(--warn); }
.tag.bad { background: #fee2e2; color: var(--bad); }

.flash { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; background: #e0e7ff; }
.flash.success { background: #dcfce7; }
.flash.error { background: #fee2e2; color: var(--bad); }

/* Live action answers stay at the top of the viewport while the page is scrolled. */
.live-notices { position: sticky; top: .75rem; z-index: 20; }
.live-notices:empty { position: static; }
.live-notices .flash { box-shadow: 0 6px 18px rgb(0 0 0 / .12); }
.live-notices .flash:last-child { margin-bottom: 0; }

label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=file], select, textarea {
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid #cbd0d8;
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
input[type=checkbox] { margin-right: .4rem; }
.form-text, .help-text, small { color: var(--muted); display: block; font-size: .85rem; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 .75rem; padding: .5rem 1rem 1rem; }
legend { font-weight: 700; padding: 0 .4rem; }
ul li { color: var(--bad); }

button, .button {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-top: 1rem;
    padding: .5rem 1rem;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}
button.danger { background: var(--bad); }
form.inline { display: inline-block; }

.password-field { position: relative; }
.password-field input { padding-right: 2.75rem; }
.password-toggle {
    position: absolute;
    right: .35rem;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: .35rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.password-toggle:hover { background: #f3f4f8; color: var(--accent); }

/* Actions: a link or a button that looks like a button. Plain .btn is the quiet one; .primary and .danger stand out. */
.btn, button.btn, a.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin: 0;
    padding: .3rem .7rem;
    border: 1px solid #cbd0d8;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: .88rem;
    line-height: 1.4;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f3f4f8; border-color: var(--accent); color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { box-shadow: inset 0 1px 2px rgb(0 0 0 / .12); }
.btn:disabled { opacity: .55; cursor: progress; background: #f3f4f6; border-color: #cbd0d8; color: var(--muted); }
.btn.primary, button.btn.primary, a.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2f3eb0; border-color: #2f3eb0; color: #fff; }
.btn.danger, button.btn.danger { background: #fff; border-color: #f1b5b5; color: var(--bad); }
.btn.danger:hover { background: #fee2e2; border-color: var(--bad); color: var(--bad); }
.btn .icon { flex: none; }
.actions { display: inline-flex; flex-wrap: wrap; gap: .4rem; align-items: center; justify-content: flex-end; }
.actions form { margin: 0; }
.actions.start { justify-content: flex-start; }
.right > .btn { margin-left: .5rem; }
.btn-group { display: inline-flex; align-items: stretch; vertical-align: middle; }
.btn-group > form { display: flex; margin: 0; }
.btn-group > * + * { margin-left: -1px; }
.btn-group > .btn, .btn-group > form > .btn { border-radius: 0; }
.btn-group > .btn:first-child, .btn-group > form:first-child > .btn { border-radius: 6px 0 0 6px; }
.btn-group > .btn:last-child, .btn-group > form:last-child > .btn { border-radius: 0 6px 6px 0; }
.btn-group .btn:focus-visible { position: relative; z-index: 1; }
.btn.state-button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.state-button[aria-pressed="true"]:hover { background: #2f3eb0; border-color: #2f3eb0; color: #fff; }
.link-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.link-row:first-of-type { border-top: 0; }

/* Filter tabs and bulk-action bar above a list. */
.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: .75rem; }
.toolbar form { margin: 0; }
.segmented { display: inline-flex; border: 1px solid #cbd0d8; border-radius: 6px; overflow: hidden; background: #fff; }
.segmented a { padding: .3rem .8rem; color: var(--text); text-decoration: none; font-size: .88rem; border-left: 1px solid #cbd0d8; }
.segmented a:first-child { border-left: 0; }
.segmented a:hover { background: #f3f4f8; }
.segmented a.active { background: var(--accent); color: #fff; }
.segmented .count { display: inline-block; min-width: 1.4em; padding: 0 .35em; margin-left: .25rem; border-radius: 999px; background: var(--line); color: var(--muted); font-size: .75rem; text-align: center; }
.segmented a.active .count { background: rgb(255 255 255 / .25); color: #fff; }

/* Dashboard filters: the period stays in view, the button keeps its place, and the criteria open below it. */
.filter-panel { margin: 0; }
.filter-panel[hidden] { display: none; }
.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; margin: 0; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.filter-form .filter-field { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }
.filter-form input[type=date], .filter-form input[type=search] { padding: .3rem .5rem; border: 1px solid #cbd0d8; border-radius: 6px; font: inherit; color: var(--text); background: #fff; }
.show-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; margin-bottom: .75rem; }
.show-filter-label { font-size: .8rem; font-weight: 600; color: var(--muted); margin-right: .15rem; }
.filter-group { display: flex; flex-direction: column; gap: .35rem; }
.filter-group-head { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); }
.filter-group-title { font-weight: 600; }
.filter-reset { font-size: .8rem; font-weight: 400; }
.filter-choices { display: flex; flex-wrap: wrap; gap: .35rem .5rem; }
.filter-choice { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border: 1px solid #cbd0d8; border-radius: 999px; font-size: .85rem; color: var(--text); background: #fff; cursor: pointer; user-select: none; text-decoration: none; }
.filter-choice:hover { background: #f3f4f8; text-decoration: none; }
.filter-choice.active, .filter-choice:has(input:checked) { border-color: var(--accent); background: #eef2ff; color: var(--accent); }
.filter-choice input { margin: 0; cursor: pointer; }
.filter-dates { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
.filter-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
.session-count { margin: 0 0 .6rem; }
th.check, td.check { width: 2.5rem; padding-right: 0; }
input[type=checkbox] { cursor: pointer; }
tr.selected td { background: #eef2ff; }

/* Connector health. */
.nav-badge { display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; line-height: 1.4; text-align: center; vertical-align: top; }
.incident { margin: .75rem 0; padding: .75rem 1rem; border: 1px solid #f1b5b5; border-left: 4px solid var(--bad); border-radius: 6px; background: #fff8f8; }
.incident.seen { border-color: var(--line); border-left-color: #cbd0d8; background: #fafafa; }
.incident p { margin: .3rem 0; }

/* Session sheet, on screen and on paper. */
.sheet-head { margin-bottom: 1rem; }
.sheet-title { font-size: 1.4rem; margin: 0; }
.sheet-date { margin: .1rem 0 .75rem; color: var(--muted); font-size: 1.05rem; }
.sheet-figures { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0; }
.sheet-figures div { min-width: 5rem; }
.sheet-figures dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.sheet-figures dd { margin: 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-figures dd.over { color: var(--bad); }
.sheet-platform h3 { margin: 0; font-size: 1.05rem; }
.sheet-platform h4 { margin: 1rem 0 .25rem; font-size: .9rem; }
.sheet-platform tfoot th { border-top: 2px solid var(--text); border-bottom: 0; color: var(--text); text-transform: none; font-size: .95rem; letter-spacing: 0; }
table.detail td, table.detail th { padding-top: .3rem; padding-bottom: .3rem; font-size: .88rem; }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td .tag { text-decoration: none; }
.sheet-foot { display: flex; flex-direction: column; gap: .25rem; margin-top: 1rem; padding-top: .75rem; border-top: 2px solid var(--text); }

/* Door list: a real box to tick on screen, an empty box to tick on paper. */
table.guests th.presence, table.guests td.presence { width: 4.5rem; text-align: center; }
table.guests td { padding-top: .45rem; padding-bottom: .45rem; }
.guest-check { width: 1.15rem; height: 1.15rem; margin: 0; vertical-align: middle; }
.tick-box { display: none; width: 1.1rem; height: 1.1rem; border: 2px solid var(--text); border-radius: 3px; vertical-align: middle; }
.guest-toolbar { justify-content: space-between; margin: .75rem 0; }
.guest-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.guest-search, .guest-filter { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; }
.guest-search { color: var(--muted); }
.guest-search-field { position: relative; display: inline-flex; align-items: center; }
.guest-search-clear { position: absolute; top: 50%; right: .25rem; margin: -.7rem 0 0; display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.guest-search-clear[hidden] { display: none; }
.guest-search-clear:hover { background: var(--line); color: var(--text); }
.guest-search input::-webkit-search-cancel-button { display: none; }
.guest-search input { padding: .3rem .5rem; border: 1px solid #cbd0d8; border-radius: 6px; font: inherit; color: var(--text); background: #fff; }
.guest-search-field input { padding-right: 1.9rem; }
.guest-filter { cursor: pointer; }
.guest-filter input { cursor: pointer; }
.guest-all-done { margin: .75rem 0 0; }
.guest-summary { margin-top: 1rem; }
.guest-summary-title { margin: 0 0 .25rem; font-size: .95rem; }
.guest-platform-summary { padding: .75rem 0; border-top: 1px solid var(--line); }
.guest-platform-summary:first-of-type { border-top: 0; }
.guest-platform-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.guest-platform-head h4 { margin: 0; font-size: .95rem; }
.guest-platform-total { font-weight: 700; font-variant-numeric: tabular-nums; }
table.summary { width: 100%; margin: .35rem 0 0; }
table.summary th, table.summary td { padding: .15rem 0; font-size: .85rem; }
table.summary th { color: var(--muted); font-weight: 400; text-align: left; }
table.summary td.num { width: 4rem; padding-left: 1.5rem; }
@media screen {
    table.guests tr.filtered-out { display: none; }
    table.guests tr.is-present td { color: var(--muted); }
    table.guests tr.is-present td:nth-child(2) { text-decoration: line-through; }
}
table.guests tr.unnamed td { color: var(--muted); border-top: 2px dashed #cbd0d8; }
table.guests tfoot th { border-top: 2px solid var(--text); border-bottom: 0; color: var(--text); text-transform: none; font-size: .95rem; letter-spacing: 0; }

/* Dashboard layout: filters in a sticky sidebar on the left, content on the right. */
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
/* Wide screens: the content is centered on the window like on the other pages; the filters sit in the left margin, and the content takes the room left over when the window is too narrow for both. */
@media screen and (min-width: 1101px) {
    .dashboard-layout { grid-template-columns: minmax(calc(250px + 1.5rem), 1fr) minmax(0, 1180px) minmax(0, 1fr); gap: 0; }
    .dashboard-sidebar { width: 250px; }
}
.dashboard-sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
}
.sidebar-section + .sidebar-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.dashboard-main { min-width: 0; width: 100%; }
.dashboard-sidebar .segmented { display: flex; width: 100%; }
.dashboard-sidebar .segmented a { flex: 1; text-align: center; padding-left: .4rem; padding-right: .4rem; }
.dashboard-page-head { margin-bottom: 1rem; }
.dashboard-sidebar .filter-form { border: 0; padding: 0; background: transparent; }
.dashboard-sidebar .filter-dates { flex-direction: column; align-items: stretch; }
.dashboard-sidebar .filter-dates .filter-field { width: 100%; }
.dashboard-sidebar .filter-actions { width: 100%; }
.dashboard-sidebar .filter-actions .btn { width: 100%; justify-content: center; }
.dashboard-sidebar .show-filter-bar { margin-bottom: 0; }
.dashboard-sidebar .filter-choices { flex-direction: column; align-items: stretch; }
.dashboard-sidebar .filter-choice { justify-content: flex-start; }

.revenue-summary { margin-bottom: 1rem; }
.revenue-summary-main { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.revenue-summary-label { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.revenue-summary-amount { margin: .15rem 0 0; font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.revenue-summary-note, .revenue-summary-warning { margin: .35rem 0 0; }
@media screen {
    html:has(.dashboard-quotas) { scrollbar-gutter: stable; }
    .dashboard-table-scroll { overflow-x: auto; }
}
@media screen and (min-width: 761px) {
    .dashboard-quotas { table-layout: fixed; min-width: 950px; }
    .dashboard-quotas col:nth-child(2) { width: 5rem; }
    .dashboard-quotas col:nth-child(3) { width: 11rem; }
    .dashboard-quotas col:nth-child(4) { width: 8.5rem; }
    .dashboard-quotas col:nth-child(5) { width: 11rem; }
    .dashboard-quotas col:nth-child(6) { width: 12rem; }
    .dashboard-quotas td { overflow-wrap: anywhere; }
}
@media screen and (min-width: 761px) {
    .quota-changes { table-layout: fixed; }
    .quota-changes th:nth-child(1) { width: 5rem; }
    .quota-changes th:nth-child(3) { width: 6rem; }
    .quota-changes th:nth-child(4) { width: 35%; }
    .quota-changes td { overflow-wrap: break-word; }
}
.dashboard-session-head { flex-wrap: wrap; }
.session-heading { flex: 1 1 14rem; min-width: 0; }
.session-date { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: 0 0 .2rem; }
.session-day { display: inline-block; font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.session-day::first-letter { text-transform: uppercase; }
.session-time { padding: .05rem .6rem; border-radius: 6px; background: var(--accent); color: #fff; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.session-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; flex: 0 1 24rem; min-width: 0; }
.session-metrics.single { grid-template-columns: minmax(0, 1fr); flex-basis: 12rem; }
.session-revenue { display: flex; flex-direction: column; min-width: 0; padding: .35rem .85rem; border: 1px solid #bbf7d0; border-radius: 8px; background: #ecfdf3; text-align: right; }
.session-revenue-label { display: block; color: var(--ok); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.session-revenue-amount { display: block; color: var(--ok); font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.session-revenue-note { margin-top: auto; color: var(--muted); font-size: .75rem; }
/* The actions of a platform stack in their column instead of spilling out of the card. */
.platform-row .actions { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; }
.platform-row .actions .btn { width: 100%; justify-content: flex-start; }
.btn.small, button.btn.small { padding: .15rem .55rem; font-size: .8rem; }
.revenue-incomplete { font-size: .7rem; }
.quota-forecast { max-width: 16rem; margin-bottom: .5rem; padding: .5rem; border: 1px solid #fcd34d; border-radius: 6px; background: #fffbeb; color: #78350f; font-size: .8rem; text-align: left; }
.quota-forecast form { margin-top: .35rem; }
.quota-forecast .btn { white-space: normal; }
.quota-error { color: var(--bad); }
.quota-details { margin-top: .3rem; font-size: .8rem; }
.quota-details summary { cursor: pointer; color: var(--accent); }

.admin-issues { margin-bottom: 1rem; border: 1px solid #f1b5b5; border-radius: 8px; background: #fff8f8; }
.admin-issues-summary { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; cursor: pointer; font-weight: 600; list-style: none; }
.admin-issues-summary::-webkit-details-marker { display: none; }
.admin-issues-summary::before { content: '▸'; color: var(--muted); font-size: .8rem; }
.admin-issues[open] > .admin-issues-summary::before { content: '▾'; }
.admin-issues-body { padding: 0 1rem 1rem; }
.admin-issues-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .75rem; }
.admin-issue { padding: .75rem; background: #fff; border: 1px solid #fecaca; border-radius: 6px; }
.admin-issue-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .25rem; }
.admin-issue-message { white-space: pre-wrap; word-break: break-word; font-size: .9rem; }
.drawer-close { margin-top: 0; }

@media screen and (max-width: 860px) {
    .nav-toggle { display: inline-flex; flex-direction: column; justify-content: center; }
    .site-nav {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        width: min(20rem, calc(100vw - 2rem));
        background: #1d2330;
        color: #fff;
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin-left: 0;
        overflow-y: auto;
        z-index: 60;
        transform: translateX(100%);
        transition: transform .2s ease;
        box-shadow: -8px 0 24px rgb(0 0 0 / .2);
    }
    .topbar.is-open .site-nav { transform: translateX(0); }
    .site-nav-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 0 .75rem; margin-bottom: .5rem; border-bottom: 1px solid rgb(255 255 255 / .15); }
    .site-nav-title { font-weight: 700; font-size: 1rem; }
    .site-nav .drawer-close { color: #fff; border-color: rgb(255 255 255 / .25); background: transparent; }
    .site-nav .drawer-close:hover { background: rgb(255 255 255 / .1); color: #fff; }
    .site-nav-links { flex-direction: column; align-items: stretch; gap: 0; }
    .site-nav-links a { display: flex; align-items: center; gap: .4rem; padding: .65rem .25rem; opacity: 1; border-bottom: 1px solid rgb(255 255 255 / .08); }
    .site-nav-links a:hover { background: rgb(255 255 255 / .06); }
    .site-nav-logout { margin-top: .5rem; color: #fca5a5 !important; }
    .topbar.is-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgb(0 0 0 / .35);
        z-index: 55;
    }
    body.drawer-open { overflow: hidden; }
}

/* Narrow screens: the filters sit above the content instead of beside it. */
@media screen and (max-width: 1100px) {
    main.main-wide { padding: 0 1rem; }
    .dashboard-sidebar { position: static; max-height: none; overflow-y: visible; }
    .dashboard-sidebar .filter-dates { flex-direction: row; }
    .dashboard-sidebar .filter-dates .filter-field { flex: 1 1 7rem; width: auto; }
    .dashboard-sidebar .filter-choices { flex-direction: row; align-items: center; }
    .dashboard-sidebar .filter-actions .btn { width: auto; }
}

/* Small screens: the page stops fighting for width, and tables become labelled cards.
   The table markup is untouched for print and wide screens; data-label on each cell mirrors
   its <th>, so the layout needs no JS and survives the live refresh of the dashboard. */
@media screen and (max-width: 760px) {
    .topbar { flex-wrap: wrap; gap: .5rem 1rem; padding: .6rem 1rem; }
    main { margin: 1rem auto; padding: 0 .75rem; }
    main.main-wide { padding: 0 .75rem; }
    h1 { font-size: 1.4rem; }
    .card { padding: .85rem 1rem; }
    .page-head, .card-head { flex-direction: column; align-items: stretch; }
    .session-metrics, .session-metrics.single { width: 100%; flex: initial; }
    .session-revenue, .session-metrics .session-managed { text-align: left; }
    .session-metrics .session-managed-over { justify-content: flex-start; }
    .page-head .actions, .card-head .right, .card-head > .actions, .actions { justify-content: flex-start; }
    .toolbar { align-items: flex-start; }
    code { overflow-wrap: anywhere; }
    .sheet-figures div { min-width: 4rem; }
    .filter-dates, .filter-actions { width: 100%; }
    .filter-dates > .filter-field { flex: 1 1 7rem; }
    .btn, button.btn, a.btn { min-height: 2.25rem; padding: .45rem .8rem; }
    .filter-choice { min-height: 2.25rem; }

    table.responsive {
        display: block;
        overflow: visible;
        margin: 0;
        padding: 0;
        border: 0;
        background: none;
    }
    /* Headers stay in the accessibility tree but out of the card layout. */
    table.responsive thead {
        position: absolute;
        width: 1px; height: 1px;
        margin: -1px; padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }
    table.responsive tbody, table.responsive tfoot { display: block; }
    table.responsive tbody.platform-group { margin: 0; }
    table.responsive tr {
        display: block;
        position: relative;
        margin: 0 0 .75rem;
        padding: .5rem .75rem;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--card);
    }
    table.responsive tr[hidden] { display: none; }
    table.responsive tr.tariff-row { margin-left: 1rem; border-left: 3px solid #96a5bc; background: var(--tariff-background); }
    table.responsive tr.tariff-row.is-transitioning { transition: padding-top 160ms ease, padding-bottom 160ms ease, margin-bottom 160ms ease; }
    table.responsive tr.tariff-row.is-collapsed { padding-top: 0; padding-bottom: 0; margin-bottom: 0; border-top-width: 0; border-bottom-width: 0; }
    table.responsive tr.tariff-row td.tariff-label { padding-left: 0; box-shadow: none; }
    .tariff-name, .tariff-price { max-width: 100%; }
    table.responsive tbody.platform-group + tbody.platform-group tr.platform-row td { border-top: 0; }
    table.responsive td, table.responsive tfoot th {
        display: block;
        width: auto;
        padding: .3rem 0 .45rem;
        border-bottom: 1px solid var(--line);
        text-align: left;
    }
    table.responsive tr > :last-child { border-bottom: 0; padding-bottom: .2rem; }
    table.responsive td[data-label]::before, table.responsive tfoot th[data-label]::before,
    table.responsive tr.tariff-row .tariff-cell > div[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: .1rem;
        color: var(--muted);
        font-size: .72rem;
        font-weight: 600;
        line-height: 1.3;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: .03em;
    }
    table.responsive tr.tariff-row td[data-label]::before { display: none; }
    table.responsive tr.tariff-row .tariff-cell > div[data-label]::before { color: #4b5563; }
    table.responsive tr > :first-child::before { display: none; }
    table.responsive tr > :first-child { font-size: 1.02rem; font-weight: 700; }
    table.responsive td.num, table.responsive tfoot th.num { text-align: right; }
    /* Tables with a selection checkbox: the checkbox sits in the corner, the next cell is the title. */
    table.responsive.has-check tr:has(> :nth-child(2)) { padding-right: 3rem; }
    table.responsive.has-check tr > :first-child {
        position: absolute;
        top: .55rem; right: .6rem;
        padding: 0; border: 0;
        font-size: 1rem;
    }
    table.responsive.has-check tr > :nth-child(2)::before { display: none; }
    table.responsive.has-check tr > :nth-child(2) { padding-top: 0; font-size: 1.02rem; font-weight: 700; }
    table.guests.responsive tr.unnamed { border-style: dashed; }
    table.guests.responsive tr.unnamed td { border-top: 0; }
}

@media print {
    @page { margin: 14mm; }
    body { background: #fff; color: #000; font-size: 11pt; }
    .topbar, .flash, .no-print, .toolbar { display: none !important; }
    main { max-width: none; margin: 0; padding: 0; }
    a { color: inherit; text-decoration: none; }
    .card { border: 0; border-bottom: 1px solid #999; border-radius: 0; padding: .4rem 0 .8rem; margin: 0; break-inside: avoid; }
    th, td { border-bottom-color: #bbb; }
    .tag { border: 1px solid #999; background: none; color: #000; }
    .sheet-foot { break-inside: avoid; }
    /* What says the list is incomplete must be on the paper too. */
    .flash.guest-warning { display: block !important; background: none; color: #000; border: 2px solid #000; padding: .4rem .6rem; margin-bottom: .6rem; }
    table.guests { break-inside: auto; }
    table.guests tr { break-inside: avoid; }
    table.guests thead { display: table-header-group; }
    /* The paper boxes, not the on-screen checkboxes. */
    .tick-box { display: inline-block; }
    /* The sales recap is part of the sheet too: readable in black, platforms kept whole. */
    .guest-summary { break-inside: auto; }
    .guest-platform-summary { border-top-color: #bbb; break-inside: avoid; }
    table.summary th { color: #000; }
    .sheet-date, .muted { color: #444; }
}

/* Places managed on a session, against the seats that can be sold: red as soon as the quotas exceed them. */
.session-managed { display: flex; flex-direction: column; min-width: 0; padding: .35rem .85rem; border: 1px solid #c7d2fe; border-radius: 8px; background: #eef2ff; text-align: right; }
.session-managed-label { display: block; color: var(--accent); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.session-managed-figure { display: block; color: var(--accent); font-size: 1.1rem; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.session-managed-number { font-size: 1.5rem; }
.session-managed-room { display: block; margin-top: auto; color: var(--muted); font-size: .75rem; }
.session-managed-over { display: inline-flex; align-items: center; justify-content: flex-end; gap: .25rem; margin-top: auto; font-size: .8rem; font-weight: 700; }
.session-managed.is-over { border-color: var(--bad); background: var(--bad); }
.session-managed.is-over .session-managed-label,
.session-managed.is-over .session-managed-figure,
.session-managed.is-over .session-managed-over { color: #fff; }
.overrun-alert { display: flex; align-items: flex-start; gap: .6rem; margin-top: .5rem; padding: .6rem .8rem; border: 1px solid #f1b5b5; border-left: 4px solid var(--bad); border-radius: 6px; background: #fee2e2; color: var(--bad); font-size: .85rem; }
.overrun-alert .icon { flex: none; width: 20px; height: 20px; margin-top: .1rem; }
.overrun-alert strong { display: block; font-size: 1rem; }
.overrun-alert span { color: #7f1d1d; }
