/* Events Desk — all styling.
 *
 * Kept in its own file (rather than inline, as the original was) so the
 * Content-Security-Policy can forbid inline script and style entirely.
 *
 * IMPORTANT: `style-src 'self'` with no 'unsafe-inline' means a `style="…"`
 * attribute in markup is DISCARDED by the browser. Every rule needs a class
 * here — there is no escape hatch. See the `.u-*` utilities at the bottom.
 *
 * Colour is tokenised twice over: a neutral default so a demo install looks
 * like a product rather than one venue's tool, and a `--tenant-*` layer that
 * app.js fills in from the workspace's own brand colour. Contrast of every
 * text pair below was checked against WCAG AA (4.5:1 body, 3:1 non-text).
 */

/* ============================== tokens ================================== */
:root {
  /* --- neutral defaults. A tenant brand colour overrides --brand only. --- */
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f2ef;
  --line: #e3dfd8;
  --line-strong: #cfc9bf;
  --ink: #1b1b19;
  --muted: #5f5b54;

  /* --tenant-brand is the venue's raw value; --tenant-brand-fill is the shade
     app.js verified is both visible on a card and readable under its label. */
  --brand: var(--tenant-brand-fill, #3c4654);
  --brand-ink: var(--tenant-brand-ink, #ffffff);

  /* Link/accent text is a separate token from the brand fill: a tenant may
     pick a brand too light or too dark to read as text on a card. */
  --link: #1f5fbf;
  --focus: #1f5fbf;

  --hot: #a8371f;
  --warm: #7d5411;   /* was #b07d24 — 3.62:1 on white, failed AA */
  --cool: #5f5b54;
  --ok: #2f5d3a;
  --danger: #97271c;

  /* --- geometry --- */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 28, 26, .05);
  --shadow-lift: 0 2px 8px rgba(28, 28, 26, .07);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 22px;
  --space-6: 32px;

  /* Touch-first: 44px minimum, per WCAG 2.5.5 / platform HIG. Tightened
     below for mouse pointers only, so the laptop view stays dense. */
  --control-h: 44px;
  --tab-h: 48px;

  /* Height of the sticky header, measured by app.js. The tab strip sticks
     below it; both were top:0 before, so the tabs slid underneath. */
  --top-h: 64px;
}

@media (hover: hover) and (pointer: fine) {
  :root {
    --control-h: 34px;
    --tab-h: 42px;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a;
    --surface: #1d1f24;
    --surface-2: #252830;
    --line: #2f333b;
    --line-strong: #434954;
    --ink: #ecebe8;
    --muted: #a5a29b;

    --brand: var(--tenant-brand-dark, #62748f);
    --brand-ink: var(--tenant-brand-dark-ink, #ffffff);

    --link: #8ab4f8;
    --focus: #8ab4f8;

    --hot: #f0937a;
    --warm: #e0b35c;
    --cool: #a5a29b;
    --ok: #76b585;
    --danger: #f0937a;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 8px rgba(0, 0, 0, .38);
  }
}

* { box-sizing: border-box; }

html {
  /* Keep a focused control from hiding under the sticky header + tab strip
     (WCAG 2.4.11 Focus Not Obscured). */
  scroll-padding-top: calc(var(--top-h) + var(--tab-h) + var(--space-2));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* 16px base. Was 15px, which pushed every `font-size: 12px` label below the
     readable floor once the browser's own minimum was off. */
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--link); }
a:focus-visible,
summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--space-4) var(--space-6); }

/* Interactive state changes get a short, meaningful transition rather than
   snapping. Colour only — never width/height, which forces layout. */
.btn, .tab, .pill, .badge, a, summary, .kpi, .card {
  transition: background-color 140ms ease, border-color 140ms ease,
              color 140ms ease, box-shadow 140ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================== skip link =============================== */
.skip {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  text-decoration: none;
}
.skip:focus { top: var(--space-3); }

/* ================================ icons ================================= */
/* Inline SVG rather than ✎ / ↗ / ✓ glyphs: those render as a different weight
   and family on every platform, and a screen reader reads "pencil" or
   "north east arrow" in the middle of a sentence. */
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -.18em;
}

.spinner {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  vertical-align: -.15em;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { border-top-color: currentColor; opacity: .55; }
}

/* ================================ header ================================ */
.top {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-in {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
}
.brand { min-width: 0; }
.brand h1 {
  font-size: 17px;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-weight: 700;
  line-height: 1.2;
  /* A tenant name can be long; truncate rather than wrap the header to
     three rows on a phone. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand .tagline {
  display: block;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}
.top-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}
.top-meta select {
  width: auto;
  flex: 0 1 auto;
  min-width: 11rem;
  max-width: 16rem;
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  font-size: 15px;
}
.who { font-size: 13px; color: var(--muted); max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); display: inline-block; margin-right: 6px;
  flex: 0 0 auto;
}
.dot.stale { background: var(--warm); }
.dot.bad { background: var(--danger); }

@media (min-width: 980px) {
  .top-in { grid-template-columns: auto minmax(0, 1fr) auto; }
  .top-meta { grid-column: 2; justify-content: flex-end; }
  .top-actions { grid-column: 3; }
}

/* On a phone the identity chrome scrolls away and only the tab strip stays
   pinned — three sticky rows would eat a fifth of the viewport. */
@media (max-width: 639px) {
  .top { position: static; }
  .tabs { top: 0; }
  .top-meta select { flex: 1 1 100%; max-width: none; }
}

/* ================================= tabs ================================= */
.tabs {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: var(--top-h);
  z-index: 19;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
/* Six tabs, two of which fit on a phone. app.js adds these classes when the
   strip actually overflows, so a fade only appears where there is more to
   reach — a permanent fade would imply content that isn't there. */
.tabs.overflow-end { mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.tabs.overflow-start { mask-image: linear-gradient(to right, transparent, #000 32px); }
.tabs.overflow-start.overflow-end {
  mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}
.tabs-in {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  gap: var(--space-1);
  width: max-content;
  min-width: 100%;
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  min-height: var(--tab-h);
  padding: 0 var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: start;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.tab:hover { color: var(--ink); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; border-radius: 4px; }
.tab[aria-selected="true"] .pill { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

.pill {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ================================= KPIs ================================= */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
  margin: var(--space-5) 0;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow);
}
.kpi.hero { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
/* No opacity here. It used to be .88, which quietly cut the contrast of the
   label and sub-line below AA on some brand colours — and an opacity drop is
   invisible to a naive contrast check, so it never showed up. Size and weight
   carry the hierarchy instead. */
.kpi.hero .kpi-label, .kpi.hero .kpi-sub { color: inherit; font-weight: 500; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 2px; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.kpi-value.sm { font-size: 21px; }
.kpi-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ================================ cards ================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.card > header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.card > header h2 { font-size: 13px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.card-body { padding: var(--space-4); }
.spacer { flex: 1; }

.empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); font-size: 15px; }
.empty .icon { display: block; margin: 0 auto var(--space-2); width: 28px; height: 28px; color: var(--ok); }

/* --- loading skeleton: reserves the height the real rows will take, so the
       page doesn't jump when data lands (CLS). --- */
.skeleton { padding: var(--space-4); }
.sk-row {
  height: 14px;
  border-radius: 7px;
  margin-bottom: 10px;
  /* A sweep rather than a pulse. Opacity alone reads as "something is dim";
     a travelling highlight reads as "something is working", which is what a
     thirty-second first load needs to communicate. Both the gradient and the
     movement are composited, so ninety of these cost nothing. */
  background:
    linear-gradient(90deg,
      var(--surface-2) 0%,
      color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 50%,
      var(--surface-2) 100%)
    var(--surface-2);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.sk-row.w-40 { width: 40%; }
.sk-row.w-60 { width: 60%; }
.sk-row.w-80 { width: 80%; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* The global reduce rule stops the sweep after one pass, which would leave the
   gradient frozen mid-travel. Flatten it to a plain block instead. */
@media (prefers-reduced-motion: reduce) {
  .sk-row { background: var(--surface-2); animation: none; }
}

/* Serving cached data while a refresh runs behind it. Deliberately quiet — the
   numbers on screen are usable, and this is a footnote, not a warning. */
.dot.working {
  background: var(--cool);
  animation: breathe 1.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.working { animation: none; opacity: .7; } }

/* ============================== lead rows =============================== */
.lead { border-bottom: 1px solid var(--line); }
.lead:last-child { border-bottom: 0; }
.lead-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  align-items: start;
}
/* The whole left side of the row is the expand control. A button rather than a
   click handler on a div, so it is reachable by keyboard and announced as
   expandable; the value, wait and CRM link stay OUTSIDE it, because nesting
   interactive elements inside a button is invalid and makes the CRM link
   unreachable. */
.lead-toggle {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--control-h);
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.lead-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius); }

/* Drawn in CSS rather than shipped as an icon: it is pure decoration, and an
   inline SVG per row costs ninety-one of them. */
.chev {
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}
.lead.open .chev { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }

.lead-title { min-width: 0; }
/* The collapsed one-liner. Truncates rather than wrapping, so every row keeps
   the same height and the list stays scannable at a glance. */
.lead-gist {
  display: block;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead.open .lead-gist { display: none; }   /* the full meta replaces it */

/* Status as a word plus a dot. Never the dot alone — with every lead overdue,
   colour has stopped carrying any signal of its own. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status-pill.warn { color: var(--warm); }
.status-pill.ok   { color: var(--ok); }
.status-pill.cool { color: var(--cool); }
.status-pill.err  { color: var(--hot); }

/* What's already booked that night. Shown only when we actually have a
   reading — an empty-looking chip would say "the room is free" when the truth
   is "nobody checked", and that is how a venue double-books. */
.day-load {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
}
.day-load .icon { width: 14px; height: 14px; flex: none; }
/* Marks a fact — there is a private event that night — not a judgement about
   whether the space is still sellable. */
.day-load.warn { color: var(--warm); }
.day-load.stale { opacity: .65; font-weight: 500; }

.lead-body { padding: 0 var(--space-4) var(--space-3); }
.lead-body[hidden] { display: none; }

@media (max-width: 640px) {
  /* Three columns is too many at phone width — the gist would be squeezed to a
     few characters. Drop the status onto its own line under the name. */
  .lead-toggle {
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: start;
    row-gap: var(--space-1);
    padding: var(--space-1) 0;
  }
  .lead-toggle .status-pill,
  .lead-toggle .day-load { grid-column: 2; }
  /* The availability line matters most on a phone, where the manager is
     standing in the room being asked. Let it wrap rather than truncate. */
  .lead-toggle .day-load { white-space: normal; }
}

.lead-name { font-weight: 600; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.lead-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.lead-meta > * + *::before { content: " · "; }
.lead-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
.value { font-variant-numeric: tabular-nums; font-weight: 600; }
.est { font-weight: 400; color: var(--muted); font-size: 13px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid currentColor;
  white-space: nowrap;
}
/* A tint as well as the text label: the band must never be carried by colour
   alone (and in the leads table it previously was). */
.badge.hot  { color: var(--hot);  background: color-mix(in srgb, var(--hot) 12%, var(--surface)); }
.badge.warm { color: var(--warm); background: color-mix(in srgb, var(--warm) 12%, var(--surface)); }
.badge.cool { color: var(--cool); background: color-mix(in srgb, var(--cool) 10%, var(--surface)); }

.waited { font-size: 14px; font-variant-numeric: tabular-nums; }
.waited.bad { color: var(--hot); font-weight: 600; }

/* A 44×44 target for the otherwise 16px "open in CRM" affordance. */
.crm-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: var(--control-h);
  min-height: var(--control-h);
  padding: 0 var(--space-2);
  margin: calc(var(--space-1) * -1) 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-decoration: none;
}
.crm-link:hover { background: var(--surface-2); text-decoration: underline; }

/* =============================== controls =============================== */
.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  /* Keep adjacent targets from touching (8px minimum spacing). */
  margin: 0;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* In-flight: still focusable (see app.js) but not re-activatable. */
.btn[aria-disabled="true"] { opacity: .6; cursor: progress; }
.btn[aria-busy="true"] { cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover:not(:disabled) { background: var(--brand); filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); }

.draft { padding: 0 var(--space-4) var(--space-4); }
.draft label,
.field-label {
  display: block;
  font-size: 13px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
textarea, select, input[type="email"], input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px stops iOS Safari zooming the viewport on focus */
  padding: 10px 12px;
  min-height: var(--control-h);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}
textarea { min-height: 150px; line-height: 1.55; }
textarea[readonly] { background: var(--surface-2); color: var(--muted); }
textarea.compact { min-height: 76px; }

.hint { font-size: 13px; color: var(--muted); }
.hint.warn { color: var(--warm); }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--ok); }

details.coach { margin-top: var(--space-3); }
details.coach > summary {
  min-height: var(--control-h);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--link);
  width: fit-content;
  padding-right: var(--space-2);
}
details.coach > summary::marker { color: var(--muted); }
.coach-body { margin-top: var(--space-2); }

/* ================================= team ================================= */
.invite-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
}
@media (max-width: 640px) {
  .invite-grid { grid-template-columns: minmax(0, 1fr); }
}
/* The role picker sits inside a table cell; let it size to its content rather
   than stretching the column. */
.tbl select { width: auto; max-width: 100%; min-width: 12rem; font-size: 14px; }
@media (max-width: 720px) {
  /* In the stacked layout the value column is narrow; a 12rem minimum clips
     the role label. Let it take the width it has. */
  .tbl select { width: 100%; min-width: 0; }
}

/* ================================ tables ================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 10px var(--space-3); text-align: left; border-bottom: 1px solid var(--line); }
.tbl th {
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface);
  white-space: nowrap;
}
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Under 720px a nine-column table is unreadable however much it scrolls, so
   each row becomes a stacked label/value block. The labels come from
   data-label, which app.js sets on every cell. */
@media (max-width: 720px) {
  .scroll { overflow-x: visible; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }
  .tbl tr { border-bottom: 1px solid var(--line); padding: var(--space-3) var(--space-4); }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td {
    border: 0;
    padding: 2px 0;
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: var(--space-3);
    align-items: baseline;
    /* Without this a badge or a link stretches the full width of the value
       column and stops looking like a badge or a link. */
    justify-items: start;
  }
  .tbl td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
  }
  .tbl td.num { text-align: left; }
  /* The lead cell holds a name AND an email, which as grid items land in
     separate columns. Stack it instead: label on its own line, then both. */
  .tbl td.primary-cell { display: block; font-weight: 600; font-size: 17px; }
  .tbl td.primary-cell::before { display: block; font-weight: 600; margin-bottom: 2px; }
  .tbl td.primary-cell .hint { font-weight: 400; }
}

/* =============================== calendar =============================== */
.cal-day { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--space-4); }
.cal-day:last-child { border-bottom: 0; }
.cal-date { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-item { font-size: 15px; }
.cal-item + .cal-item { margin-top: var(--space-1); }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }

/* ================================ banners =============================== */
.banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  border-left-width: 4px;
  background: var(--surface);
  margin: var(--space-4) 0;
  font-size: 15px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.banner .banner-text { flex: 1; min-width: 0; }
.banner.warn { border-left-color: var(--warm); }
.banner.err { border-left-color: var(--danger); }
.banner .btn { flex: 0 0 auto; }

/* ================================= login ================================ */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh; /* iOS Safari: 100vh is taller than the visible area */
  display: grid;
  place-items: center;
  padding: var(--space-4);
}
.login {
  width: 100%;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-6) var(--space-5);
  box-shadow: var(--shadow-lift);
}
.login h1 { font-size: 19px; margin-bottom: 6px; }
.login p { color: var(--muted); font-size: 15px; margin: 0 0 var(--space-4); }
.login label { display: block; font-size: 14px; margin-bottom: 6px; font-weight: 500; }
.login .btn { width: 100%; margin-top: var(--space-4); min-height: 48px; }

/* ============================== utilities =============================== */
/* These exist because the CSP forbids `style="…"`. Anything that used to be
   an inline style lives here. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.u-mt-2 { margin-top: var(--space-2); }
.u-mt-3 { margin-top: var(--space-3); }
.u-mt-4 { margin-top: var(--space-4); }

@media (max-width: 640px) {
  .lead-head { grid-template-columns: minmax(0, 1fr); }
  .lead-right { align-items: flex-start; text-align: left; }
  .cal-day { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .kpi-value { font-size: 26px; }
  /* Five stacked cards pushed the actual work two screens down. The hero keeps
     its full width; the supporting numbers pair up. */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi { padding: var(--space-3); }
}

/* --------------------------------- settings -------------------------------- */
/* Auto-fit rather than a fixed column count: the scoring card has five narrow
   weight inputs and the sending card has four wide ones, and both should reflow
   on the same rules instead of each needing its own breakpoint. */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3);
  align-items: start;
}

.set-field { min-width: 0; }
.set-field label,
.set-legend {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: var(--space-1);
}
/* Each hint sits directly under its own control, so the stack needs a little
   breathing room without opening a gap big enough to read as a new section. */
.set-field .hint { margin-top: var(--space-1); }
.set-field input,
.set-field select,
.set-field textarea { width: 100%; }
.set-field textarea { min-height: 6.5rem; resize: vertical; }

.set-sub {
  font-size: 14px;
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
  color: var(--muted);
}

/* Night chips. The checkbox stays in the DOM rather than being hidden, because
   a hidden input is unreachable by keyboard and invisible to a screen reader —
   the label wraps it so the whole chip is the hit target either way. */
.day-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.day-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.day-chip:hover { border-color: var(--line-strong); }
/* :has keeps the checked styling on the chip itself. Where it isn't supported
   the checkbox still shows its own state, so this degrades to plain but
   correct rather than to ambiguous. */
.day-chip:has(input:checked) {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}
.day-chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.day-chip input { width: auto; min-height: 0; margin: 0; }
.day-chip:has(input:disabled) { opacity: .6; cursor: default; }

.set-blockers {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-4);
  color: var(--warm);
  font-size: 14px;
}
.set-blockers li { margin: var(--space-1) 0; }

/* A read-only field must not look like an editable one the operator simply
   failed to click into. */
.set-field input[readonly],
.set-field textarea[readonly],
.set-field select:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

/* Honour an OS high-contrast preference by firming up every border. */
@media (prefers-contrast: more) {
  :root { --line: var(--line-strong); }
  .btn, .pill, .tag, .badge { border-width: 2px; }
  .day-chip { border-width: 2px; }
}

/* ----------------------------- Kailee's playbook --------------------------- */
/* Long-form prose the operator will actually read and edit, so the box is tall
   and keeps the body font; a code font would make a voice guide feel like
   configuration rather than writing. */
.playbook-field + .playbook-field { margin-top: var(--space-5); }
.playbook-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}
.playbook-head label { margin-bottom: 0; margin-right: auto; }
.set-field textarea.playbook { min-height: 22rem; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.hint.err[data-count] { font-weight: 600; }

/* -------------------------------- Maintenance ------------------------------ */
/* A list of pending database changes. Unstyled <ul> markers read as prose
   bullets here, which is wrong for a list of identifiers. */
ul.plain { list-style: none; margin: var(--space-2) 0 0 0; padding: 0; }
ul.plain li { padding: var(--space-2) 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }
ul.plain li .hint { display: block; }

/* ---------------------------------- Texts ---------------------------------- */
/* A conversation, which is a sequence and is marked up as one: an ordered list
   of messages, so a screen reader announces how many there are and which way
   each one went. The visual left/right split is decoration on top of that —
   `msg-meta` names the sender in words, because side alone carries no meaning
   to anyone not looking at it. */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.msg {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
  max-width: 44rem;
  background: var(--surface);
}
/* Inbound sits left and plain; outbound sits right and tinted, the convention
   every messaging app has trained people on. */
.msg-in  { justify-self: start; }
.msg-out { justify-self: end; background: var(--surface-2); }
.msg-meta {
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}
/* A text is whatever the guest typed, newlines and all. pre-wrap keeps the
   shape they gave it without letting a long URL blow out the column. */
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* A button that reads as a link. Used for opening a conversation: it navigates
   within the app, so a link is the right affordance, but it has no href and
   must stay a <button> for the keyboard and for screen readers. */
.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover { text-decoration-thickness: 2px; }
.linkish:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

@media (max-width: 700px) {
  /* On a phone the two columns are most of the width anyway, and the tint plus
     the named sender carry the direction. */
  .msg { max-width: 100%; }
}

/* ----------------------------------- BEO ---------------------------------- */
.beo-grid { display: grid; gap: var(--space-4); padding: 0 var(--space-4) var(--space-4); }
.beo-sec h3 { margin: 0 0 var(--space-2); font-size: 15px; }
.beo-sec textarea { width: 100%; }
.beo-line {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 7rem auto;
  gap: var(--space-2);
  align-items: start;
  margin-bottom: var(--space-2);
}
.beo-line input, .beo-line textarea { width: 100%; min-width: 0; }
.beo-line-head { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.beo-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-2); }
.beo-actions a.btn { text-decoration: none; }
.beo-bill { max-width: 28rem; }
.beo-bill th { text-align: left; font-weight: 500; }
.beo-bill .beo-total th, .beo-bill .beo-total td { font-weight: 700; }
.beo-open { margin: 0; padding-left: 1.2rem; }
#beo-conversation { width: 100%; }
@media (max-width: 640px) {
  .beo-line { grid-template-columns: 1fr 1fr; }
  .beo-line textarea { grid-column: 1 / -1; grid-row: 1; }
  .beo-line-head { display: none; }
}
.beo-off { margin: -4px 0 var(--space-2) 5.5rem; }
@media (max-width: 640px) { .beo-off { margin-left: 0; } }

/* -------------------------------- lead desk ------------------------------- */
.desk { display: grid; grid-template-columns: 18rem minmax(0, 1fr); gap: 0; align-items: start; }
.desk.with-panel { grid-template-columns: 18rem minmax(0, 1fr) 17rem; }
.desk-rail { padding: var(--space-4); border-right: 1px solid var(--line); display: grid; gap: var(--space-2); }
.desk-rail input { width: 100%; }
.desk-modes { display: flex; flex-wrap: wrap; gap: 4px; }
.desk-modes .btn { flex: 1 1 auto; justify-content: center; padding-inline: 8px; }
.desk-list { display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.desk-row {
  display: grid; gap: 4px; width: 100%; text-align: left; padding: 10px 12px;
  background: var(--surface); color: inherit; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.desk-row:hover { background: var(--surface-2); }
.desk-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.desk-row.on { background: var(--surface-2); border-color: var(--ink); }
.desk-row-top { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.desk-row-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.desk-main { padding: var(--space-4); display: grid; gap: var(--space-4); min-width: 0; }
.desk-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); align-items: flex-start; }
.desk-name { margin: 0; font-size: 20px; }
.desk-verdict { display: grid; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.desk-verdict-top { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: space-between; }
.desk-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.desk-check { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: var(--space-2); font-size: 14px; }
.desk-check-kind { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ok); }
.desk-check.warn .desk-check-kind { color: var(--warm); }
.desk-check.fail .desk-check-kind { color: var(--danger); }
.desk-discard { display: grid; gap: 6px; max-width: 28rem; }
.desk-discard select, .desk-discard input { width: 100%; }
.desk-panel { padding: var(--space-4); border-left: 1px solid var(--line); display: grid; gap: var(--space-2); font-size: 14px; }
.desk-panel h3 { margin: var(--space-2) 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.desk-dates, .desk-others { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.desk-dates li { display: flex; justify-content: space-between; gap: var(--space-2); padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.desk-dates li.req { border-color: var(--ink); font-weight: 600; }
.desk-guest { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 4px var(--space-2); margin: 0; }
.desk-guest dt { color: var(--muted); }
.desk-guest dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 1000px) {
  .desk.with-panel { grid-template-columns: 16rem minmax(0, 1fr); }
  .desk-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 700px) {
  .desk, .desk.with-panel { grid-template-columns: minmax(0, 1fr); }
  .desk-rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .desk-list { max-height: 40vh; }
}

/* Venue voices: one block per venue inside the card, separated by a rule so
   two venues' boxes are never read as one form. */
.venue-voice { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }
.venue-voice:first-of-type { border-top: 0; margin-top: 8px; padding-top: 0; }
.venue-voice-name { margin: 0 0 8px; font-size: 1rem; font-weight: 600; color: var(--ink); }
.venue-voice-box { min-height: 220px; }
