/*  Training Room Booking - one stylesheet for the public page and the admin.
 *  Phone first: modals turn into bottom sheets under 640px, inputs stay at 16px so iOS
 *  never zooms on focus.
 */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --brand: #1d4ed8;
  --brand-ink: #1e3a8a;
  --brand-soft: #eff4ff;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-line: #f59e0b;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --grey-soft: #f1f5f9;
  --wa: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button { font: inherit; }
.muted { color: var(--muted); }

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

.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--brand); background: var(--brand-soft); padding: 3px 10px; border-radius: 999px; }
@media (max-width: 640px) { .brand-tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; } }   /* may wrap to 2 lines on a phone */
.brand-lg .brand-mark { width: 38px; height: 38px; }
.brand-lg .brand-name { font-size: 18px; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* admin top bar: one row on a computer, two rows on a phone */
.admin-top .brand-tag { flex: none; }
.admin-top .user-name { margin-left: auto; min-width: 0; }
.admin-top .admin-logout { flex: none; }
@media (max-width: 640px) {
  .admin-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand out" "tag who"; align-items: center; gap: 6px 10px; padding-top: 8px; padding-bottom: 8px; }
  .admin-top .brand { grid-area: brand; }
  .admin-top .brand-tag { grid-area: tag; justify-self: start; }
  .admin-top .user-name { grid-area: who; justify-self: end; margin-left: 0; max-width: 45vw; }
  .admin-top .admin-logout { grid-area: out; }
}

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px; flex: 1; }
.foot { max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; color: var(--muted); font-size: 13px; }
.ver { font-variant-numeric: tabular-nums; }
.foot-right { display: inline-flex; align-items: center; gap: 14px; }
.foot-right a { color: var(--muted); }
.foot-right a:hover { color: var(--brand); }
.boot { padding: 80px 16px; text-align: center; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h2 { font-size: 17px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.banner { max-width: 1180px; margin: 12px auto 0; padding: 10px 14px; border-radius: 10px; font-size: 14px; width: calc(100% - 32px); }
.banner-warn { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; font-weight: 600; }

/* ---------- buttons + inputs ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid transparent; background: var(--grey-soft); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: #e7ecf3; }
.btn:focus-visible, .input:focus-visible, .pill-btn:focus-visible, .seg button:focus-visible, .tabs button:focus-visible, .pop-opt:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--grey-soft); }
.btn-ghost-red { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-ghost-red:hover { background: var(--red-soft); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: #166534; }
.btn-wa.is-sent { background: #fff; color: var(--wa); border-color: #86efac; }
.wa-text { resize: none; overflow: hidden; min-height: 0; }
.wa-link { display: block; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 10px; background: #f8fafc; font-size: 13px; color: var(--wa); overflow-wrap: anywhere; word-break: break-all; }
.btn-link { background: none; border: 0; color: var(--brand); padding: 6px 4px; min-height: 0; font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-ghost.is-busy::after, .btn-link.is-busy::after { border-color: rgba(29, 78, 216, .25); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--grey-soft); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: block; }
.field + .field { margin-top: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.req { color: var(--red); margin-left: 3px; font-weight: 700; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-error { display: block; font-size: 13px; color: var(--red); margin-top: 5px; font-weight: 600; }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); font: 16px/1.3 var(--font); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.input.is-bad { border-color: var(--red); box-shadow: 0 0 0 3px rgba(185, 28, 28, .12); }
textarea.input { min-height: 84px; resize: vertical; }
.input-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.input-btn::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); flex: none; }
.input-num { width: 90px; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-right: 0; border-radius: 10px 0 0 10px; background: var(--grey-soft); color: var(--muted); font-weight: 600; }
.input-group .input { border-radius: 0 10px 10px 0; }
.row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; margin-top: 0; }
.row-top { align-items: flex-start; }           /* fields line up at the top even when one has a hint below */
.row-times { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.row-times .to { color: var(--muted); font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.repeat-day { font-weight: 700; font-size: 16px; color: var(--ink); }   /* the label is 14px; the weekday +2 */
.form-error { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: 14px; font-weight: 600; }
.hp { position: absolute !important; left: -10000px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- pills, badges, chips ---------- */

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; line-height: 18px; border: 1px solid transparent; white-space: nowrap; }
.pill-btn { cursor: pointer; font-family: inherit; }
.pill-btn:hover { filter: brightness(.96); box-shadow: 0 0 0 2px rgba(15, 23, 42, .06); }
.pill-pending { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.pill-confirmed { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.pill-rejected { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.pill-cancelled { background: var(--grey-soft); color: #475569; border-color: var(--line); }   /* #475569: readable at 11px (4.5:1 and up) */
.pill-expired { background: #fff; color: var(--amber); border-color: var(--amber-line); }
.pill-red { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.pill-green { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.pill-amber { background: var(--amber-soft); color: var(--amber); border-color: #fde68a; }
.pill-grey { background: var(--grey-soft); color: #475569; border-color: var(--line); }
.pill-blue { background: var(--brand-soft); color: var(--brand); border-color: #c7d7fe; }
.pill-super { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; margin-left: 4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer; }
.chip:hover { background: var(--grey-soft); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--grey-soft); color: var(--ink-2); font-size: 12px; }
.chip .n.hot { background: var(--red); color: #fff; }
.chip.is-on .n { background: rgba(255, 255, 255, .2); color: #fff; }
.chip.is-on .n.hot { background: var(--red); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--grey-soft); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: #475569; cursor: pointer; min-height: 30px; }
.seg button.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.seg-step button { display: inline-grid; place-items: center; padding: 6px 10px; color: var(--ink-2); }
.seg-step button:hover:not(:disabled) { background: #fff; color: var(--ink); }
.seg-step button:disabled { opacity: .35; cursor: not-allowed; }
.seg-step svg { width: 16px; height: 16px; }

/* ---------- admin tabs ---------- */

.tabs { max-width: 1180px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; display: inline-flex; align-items: center; border: 0; background: none; padding: 10px 12px 11px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button.is-on { color: var(--brand); border-bottom-color: var(--brand); }
.tab-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.tab-head h2 { font-size: 20px; }
.tab-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- public hero ---------- */

.hero { padding: 6px 2px 14px; }
.hero h1 { font-size: 24px; letter-spacing: -.01em; }
.hero p { margin: 6px 0 12px; color: var(--ink-2); max-width: 720px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-sm { margin-top: 10px; font-size: 12px; }
.sw { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line-2); display: inline-block; }
.sw-free { background: #fff; }
.sw-pending { background: var(--amber-soft); border-color: var(--amber-line); }
.sw-booked { background: #cbd5e1; border-color: #94a3b8; }
.sw-closed { background: repeating-linear-gradient(135deg, #e2e8f0 0 4px, #f8fafc 4px 8px); }
.sw-confirmed { background: var(--green-soft); border-color: #4ade80; }
.sw-admin { background: var(--brand-soft); border-color: #93b4fd; }
.sw-past { background: #e9edf3; border-color: #cbd5e1; }
.sw-own { background: var(--amber-soft); border: 2px solid var(--brand); }
.sw-rejected { background: #f8fafc; border: 1px dashed #94a3b8; }
.sw-expired { background: var(--amber-soft); border-color: var(--amber-line); opacity: .55; }

/* ---------- calendar ---------- */

.cal-card { padding: 12px; }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-weight: 700; font-size: 16px; flex: 1; text-align: left; min-width: 150px; }
.cal-right { display: flex; align-items: center; gap: 8px; }
.cal-msg { margin: 10px 4px 0; color: var(--red); font-weight: 600; }
@media (max-width: 640px) {
  .cal-card { padding: 8px; border-radius: 12px; }
  .cal-title { order: -1; flex-basis: 100%; text-align: left; font-size: 15px; }
}

.fc { --fc-border-color: var(--line); --fc-today-bg-color: #f7faff; --fc-now-indicator-color: #dc2626; --fc-page-bg-color: #fff; --fc-neutral-bg-color: #f8fafc; --fc-highlight-color: rgba(29, 78, 216, .16); font-size: 13px; }
/* day headers stick just under our own sticky top bar (common.js measures it into --sticky-top) */
.fc .fc-scrollgrid-section-header.fc-scrollgrid-section-sticky > * { top: var(--sticky-top, 0px); z-index: 5; }
.fc .fc-timegrid-slot { height: 2.2em; }
.fc .fc-timegrid-slot-minor { border-top-style: dotted; }
.fc .fc-timegrid-slot-label-cushion, .fc .fc-timegrid-axis-cushion { font-size: 11px; color: var(--muted); }
.fc .fc-col-header-cell-cushion { padding: 6px 2px; color: var(--ink); text-decoration: none; }
.fc a { color: inherit; text-decoration: none; }
.dh { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; gap: 2px; }
.dh-dow { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.dh-day { font-size: 17px; font-weight: 700; min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 999px; }
.fc .fc-day-today .dh-day { background: var(--brand); color: #fff; }
.fc .fc-day-disabled { background: repeating-linear-gradient(135deg, #f1f5f9 0 6px, #f8fafc 6px 12px); }
.fc .fc-timegrid-now-indicator-line { border-width: 2px 0 0; }
.fc .fc-highlight { border-radius: 4px; }
@media (max-width: 640px) {
  .fc { font-size: 12px; }
  .fc .fc-timegrid-slot { height: 2.6em; }
  .dh-day { font-size: 15px; min-width: 24px; height: 24px; }
}

/* public: availability is painted as background blocks */
.fc .fc-bg-event { opacity: 1; }
.fc .fc-bg-event .fc-event-title { font-style: normal; font-weight: 700; font-size: 11px; margin: 4px 6px; line-height: 1.25; }
.fc .bg-booked { background: #cbd5e1; margin: 1px 2px; border: 1px solid #94a3b8; border-radius: 6px; }   /* each booking its own block, a gap between back-to-back ones */
.fc .bg-booked .fc-event-title { color: #334155; }
.fc .bg-pending { background: var(--amber-soft); box-shadow: inset 3px 0 0 var(--amber-line); }
.fc .bg-pending .fc-event-title { color: var(--amber); }
.fc .bg-closed { background: repeating-linear-gradient(135deg, #e2e8f0 0 6px, #f1f5f9 6px 12px); }
.fc .bg-closed .fc-event-title { color: var(--ink-2); }
.fc .bg-past { background: rgba(148, 163, 184, .18); }
.cal-public .fc-timegrid-col.fc-day-past { background: rgba(148, 163, 184, .12); }
.cal-public .fc-timegrid-body .fc-timegrid-col { cursor: pointer; }

/* public: one amber block per pending request; shared time is striped by book.js */
.fc .fc-v-event.ev-pubpending { background-color: var(--amber-soft); border: 1px solid var(--amber-line); border-left-width: 3px; box-shadow: 0 0 0 1px #fff; }
.fc .fc-v-event.ev-pubpending .ev-name { color: #92400e; }
.fc .fc-v-event.ev-pubpending .ev-time { color: #92400e; opacity: .85; }
/* your own request on the public calendar: outlined, and it can be dragged */
.fc .fc-v-event.ev-own { border-color: var(--brand); border-left-color: var(--brand); box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(29, 78, 216, .35); cursor: grab; }
.fc .fc-v-event.ev-own .ev-name { color: var(--brand-ink); }
.sw-overlap { background: repeating-linear-gradient(135deg, rgba(180, 83, 9, .45) 0 2px, var(--amber-soft) 2px 5px); border-color: var(--amber-line); }

/* admin: one block per booking */
.fc .fc-v-event { border-radius: 6px; border: 1px solid transparent; box-shadow: none; }
.fc .fc-v-event .fc-event-main { padding: 0; }
.fc .fc-v-event.ev-pending { background: var(--amber-soft); border-color: var(--amber-line); }
.fc .fc-v-event.ev-confirmed { background: var(--green-soft); border-color: #4ade80; }
.fc .fc-v-event.ev-confirmed.ev-admin { background: var(--brand-soft); border-color: #93b4fd; }
.fc .fc-v-event.ev-rejected, .fc .fc-v-event.ev-cancelled { background: #f8fafc; border-color: var(--line-2); border-style: dashed; }
.fc .fc-v-event.ev-expired { opacity: .65; }
.ev { position: relative; height: 100%; padding: 3px 6px; overflow: hidden; color: var(--ink); cursor: pointer; }
.ev-name { font-weight: 700; font-size: 12px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-time { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-pending .ev-name { color: #92400e; }
.ev-rejected .ev-name, .ev-cancelled .ev-name { color: var(--muted); text-decoration: line-through; }
.ev-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #fff; }

/* ---------- booking cards (admin) ---------- */

.cards { display: grid; gap: 12px; }
.list-group + .list-group { margin-top: 18px; }
.list-date { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 2px 8px; }
.bk-card { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.bk-card.bk-pending { border-left-color: var(--amber-line); }
.bk-card.bk-confirmed { border-left-color: #22c55e; }
.bk-card.bk-rejected { border-left-color: #f87171; }
.bk-card.bk-cancelled { border-left-color: var(--line-2); }
.bk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 8px; }
.bk-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.bk-id { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bk-when { margin-top: 2px; font-weight: 600; color: var(--ink-2); }
.bk-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 14px; }
.bk-mobile { font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums; }
.bk-purpose { color: var(--ink-2); overflow-wrap: anywhere; }
.bk-trail { margin-top: 6px; font-size: 13px; }
.bk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.bk-history { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-2); }
.trail { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.trail li { padding: 3px 0; color: var(--ink-2); }
.trail-when { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.list-more { display: flex; justify-content: center; margin-top: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 2px 14px; }
.search { max-width: 320px; }

/* callouts inside dialogs */
.callout { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout-amber { background: var(--amber-soft); color: #78350f; border: 1px solid #fde68a; }
.callout-green { background: var(--green-soft); color: #14532d; border: 1px solid #bbf7d0; }
.callout-red { background: var(--red-soft); color: #7f1d1d; border: 1px solid #fecaca; }
.callout-plan { background: #bbf7d0; color: #14532d; border: 1px solid #86efac; }   /* "N bookings will be added" */
.callout-plan .plan .ok .mark { color: #166534; }
.callout-grey { background: var(--grey-soft); color: var(--ink-2); border: 1px solid var(--line); }
.plan { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.plan li { display: flex; gap: 8px; align-items: baseline; }
.plan .mark { flex: none; width: 18px; font-weight: 700; }
.plan .ok .mark { color: var(--green); }
.plan .skip { color: var(--muted); }
.plan .skip .mark { color: var(--red); }

/* public: this tab's own requests */
.mine { margin-bottom: 16px; }
.mine-list { display: grid; gap: 10px; }
.mine-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.mine-main { flex: 1 1 260px; min-width: 0; }
.mine-when { font-weight: 700; margin-top: 6px; }
.mine-who { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.mine-note { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.mine-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- modal + bottom sheet ---------- */

.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .18s; }
.overlay.show { opacity: 1; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); transform: translateY(8px); transition: transform .18s; }
.overlay.show .modal { transform: none; }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.modal-title { font-size: 18px; }
.modal-x { border: 0; }
.modal-body { padding: 4px 18px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.modal:focus { outline: none; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  /* dvh = the screen actually visible, so with Safari's bar showing the title and X stay on screen */
  .modal, .modal-wide { max-width: none; max-height: 92vh; max-height: 92dvh; border-radius: 18px 18px 0 0; transform: translateY(24px); padding-bottom: env(safe-area-inset-bottom); }
  .modal-foot .btn { flex: 1 1 0; }
}

/* request form */
.slot-status { margin-top: 8px; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; }
.slot-free { background: var(--green-soft); color: var(--green); }
.slot-pending { background: var(--amber-soft); color: #92400e; }
.slot-none { background: var(--red-soft); color: var(--red); }
.done { text-align: center; padding: 10px 6px 4px; }
.done-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.done-icon svg { width: 30px; height: 30px; }
.done h3 { font-size: 18px; }
.done-msg { white-space: pre-line; line-height: 1.4; }     /* the message's two lines, stacked with no gap */
.done p { margin: 8px 0 0; color: var(--ink-2); }
.done .when { font-weight: 700; color: var(--ink); }

/* ---------- popover picker (instead of a native select) ---------- */

.pop { position: absolute; z-index: 200; width: 320px; max-width: calc(100vw - 24px); max-height: 340px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 10px; }
.pop-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 2px 4px 8px; }
.pop-grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 6px; }
.pop-opt { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 40px; padding: 4px 2px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.pop-opt:hover { background: var(--brand-soft); border-color: #c7d7fe; }
.pop-opt.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pop-opt:disabled { background: var(--grey-soft); color: #a3afc0; border-color: var(--line); cursor: not-allowed; text-decoration: line-through; }
.pop-opt.tone-pending:not(.is-on):not(:disabled) { background: var(--amber-soft); border-color: #fde68a; }
.pop-opt-note { font-size: 10px; font-weight: 600; opacity: .85; text-decoration: none; }
.pop-sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 60vh; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); }

/* ---------- toasts ---------- */

.toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 300; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 11px 14px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--red); }
.toast-ok { background: var(--green); }

/* ---------- login ---------- */

.login { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 24px; }
.login-card h1 { font-size: 20px; margin: 18px 0 16px; }
.login-card .btn-block { margin-top: 18px; }

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

.range-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.range-bar .field { flex: 0 1 170px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 14px 16px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chart-card { padding: 16px; }
.chart-card h3 { font-size: 15px; }
.chart-card .sub { font-size: 12px; color: var(--muted); margin: 2px 0 10px; }
.chart-box { position: relative; height: 240px; }
.chart-numbers { margin-top: 10px; font-size: 13px; }
.chart-numbers summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.chart-numbers .tbl { margin-top: 8px; }
.chart-numbers .tbl th, .chart-numbers .tbl td { padding: 6px 10px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #f8fafc; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .arrow { margin-left: 4px; }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.th-sort:hover { color: var(--ink); }
.th-sort:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }

/* ---------- settings ---------- */

.settings { display: grid; gap: 16px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day-toggle { min-width: 50px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer; }
.day-toggle.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tpl + .tpl { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.tpl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tpl-chip { border: 1px dashed var(--line-2); background: var(--grey-soft); border-radius: 8px; padding: 3px 8px; font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-2); cursor: pointer; }
.tpl-chip:hover { border-color: var(--brand); color: var(--brand); }
.bubble { margin-top: 8px; padding: 10px 12px; border-radius: 12px 12px 12px 4px; background: #e7fbe9; color: #14532d; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid #bbf7d0; }
.bubble-label { font-size: 12px; color: var(--muted); margin-top: 8px; }
.closed-list { list-style: none; margin: 12px 0 0; padding: 0; }
.closed-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.closed-list .what { min-width: 0; }
.closed-list .what strong { display: block; }

@media (prefers-reduced-motion: reduce) {
  .overlay, .modal, .toast { transition: none; }
}

/* ---------- admin List tab ---------- */

.agenda-day { padding: 4px 0; margin-bottom: 16px; overflow: hidden; }
.agenda-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; align-items: center; gap: 6px 16px; width: 100%; padding: 12px 16px; border: 0; border-left: 4px solid var(--line-2); background: #fff; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.agenda-row + .agenda-row { border-top: 1px solid var(--line); }
.agenda-row:hover { background: #f8fafc; }
.agenda-row.agenda-pending { border-left-color: var(--amber-line); }
.agenda-row.agenda-confirmed { border-left-color: #22c55e; }
.agenda-time { display: flex; flex-direction: column; font-weight: 700; font-size: 14px; }
.agenda-time .muted { font-weight: 400; font-size: 12px; }
.agenda-who { display: flex; flex-direction: column; min-width: 0; }
.agenda-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-who .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-pills { justify-content: flex-end; }
@media (max-width: 640px) {
  .agenda-row { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .agenda-pills { justify-content: flex-start; }
}

/* admin calendar: colour key on its own white card, 2px bigger than before (12 -> 14, 13 -> 15) */
.cal-legend { margin-top: 14px; padding: 14px 18px; }
.cal-legend .legend { font-size: 14px; gap: 10px 20px; }
.cal-legend .sw { width: 18px; height: 18px; }
.cal-legend .ev-dot { width: 10px; height: 10px; }
.cal-legend-hint { margin: 10px 0 0; font-size: 15px; color: var(--ink-2); }
