/* customer.mendipsys — booking window rebuild.
   Colour tokens = ver5's palette SEMANTICS (MendipSys_v6 CLAUDE.md design
   system): green=add/save · red=delete/warn · yellow=caution/dates ·
   blue=neutral/info · grey=inactive. The meanings are preserved everywhere;
   the rendering is a modern token layer (light + dark via html[data-theme])
   with softer radii, subtle shadows and hover lift. */

:root {
  color-scheme: light;

  /* ── Surfaces / text / structure ── */
  --page-bg: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --surface-hover: #f6f3fb;
  --text: #202333;
  --text-strong: #151827;
  --text-muted: #73788b;
  --text-faint: #9ba0af;
  --border: #dfe2ea;
  --border-strong: #cdd2dd;
  --shadow-sm: 0 1px 3px rgba(28, 24, 40, 0.06);
  --shadow-md: 0 10px 30px rgba(35, 25, 66, 0.07), 0 2px 6px rgba(35, 25, 66, 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --brand-400: #c084fc;
  --brand-600: #9333ea;
  --brand-700: #7e22ce;
  --focus-ring: 0 0 0 3px rgba(168, 85, 247, 0.13);

  /* ── MendipSys semantic palette (light) ── */
  --ms-blue-bg: #e8f5fc;      --ms-blue-border: #b9deee;   --ms-blue-text: #176183;
  --ms-blue-lt-bg: #f0f9fe;   --ms-blue-lt-border: #c7e3f0;
  --ms-green-bg: #e8f7e5;     --ms-green-border: #c5e7c0;  --ms-green-text: #357234;
  --ms-green-lt-bg: #f1faee;
  --ms-red-bg: #ffe3e6;       --ms-red-border: #f1b8be;    --ms-red-text: #9a3440;
  --ms-red-dk-bg: #f7bcc3;    --ms-red-dk-border: #dd8b95;
  --ms-red-lt-bg: #fff0f1;
  --ms-yellow-bg: #fff5d9;    --ms-yellow-border: #efd17a; --ms-yellow-text: #785b00;
  --ms-yellow-lt-bg: #fffbef;
  --ms-orange-bg: #ffedd5;    --ms-orange-border: #f5aa4c; --ms-orange-text: #8a4b00;
  --ms-purple-bg: #f3e8ff;    --ms-purple-border: #d8b4fe; --ms-purple-text: #6b21a8;
  --ms-turq-bg: #e1f7f4;      --ms-turq-border: #b1dfda;   --ms-turq-text: #176a67;
  --ms-grey-bg: #eef0f4;      --ms-grey-border: #dfe2ea;
  --ms-nav: #f1f2f6;
  --ms-text: var(--text);
  --ms-link: #7e22ce;
  --ms-link-dk: #6b21a8;

  /* window theme (BS default) — overridden per personality.
     --theme-grad = the header (a shade deeper than the old washed-out tint);
     --page-grad = the body backdrop the panels sit on: theme tint at the top,
     paper through the middle, tint returning at the bottom — FIXED against
     scrolling (ver5's window had this depth; flat --page-bg read washed out). */
  --theme-bg: #d9edf9;
  --theme-border: #9cc8e2;
  --theme-lt: #eef8fe;
  --theme-grad: linear-gradient(135deg, #c7e1f2 0%, #aed2ea 55%, #97c3e2 100%);
  --page-grad: linear-gradient(180deg, #d7e8f4 0%, #f8fafd 220px, #f8fafd 65%, #cfe3f2 100%);
}

body.theme-cs {
  --theme-bg: #f0ddfb; --theme-border: #cb96e0; --theme-lt: #f9f0fe;
  --theme-grad: linear-gradient(135deg, #ecc7fc 0%, #e0adf7 55%, #d69af2 100%);
  --page-grad: linear-gradient(180deg, #f0e0fa 0%, #fbf9fe 220px, #fbf9fe 65%, #ecd8f8 100%);
}
body.theme-special {
  --theme-bg: #ddf0d5; --theme-border: #a9d8a0; --theme-lt: #f1faee;
  --theme-grad: linear-gradient(135deg, #d3edc6 0%, #c0e4ae 55%, #aeda99 100%);
  --page-grad: linear-gradient(180deg, #e2f2d9 0%, #f9fdf7 220px, #f9fdf7 65%, #daeecf 100%);
}
body.theme-future {
  --theme-bg: #e8eaee; --theme-border: #b9c0cd; --theme-lt: #f4f5f8;
  --theme-grad: linear-gradient(135deg, #dde0e7 0%, #d0d5de 55%, #c4cad6 100%);
  --page-grad: linear-gradient(180deg, #e3e6ec 0%, #f8f9fb 220px, #f8f9fb 65%, #dfe3ea 100%);
}

/* ── Dark theme — html[data-theme="dark"], toggled in the header ── */
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="dark"] body {
  --page-bg: #071426;
  --surface: #0e1c30;
  --surface-soft: #102139;
  --surface-hover: #182b46;
  --text: #e7edf7;
  --text-strong: #ffffff;
  --text-muted: #a9b5c8;
  --text-faint: #76859c;
  --border: #30435d;
  --border-strong: #435771;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.2);
  --focus-ring: 0 0 0 3px rgba(168, 85, 247, 0.3);

  --ms-blue-bg: rgba(30, 151, 211, 0.13);   --ms-blue-border: rgba(73, 183, 228, 0.42);  --ms-blue-text: #65d5ff;
  --ms-blue-lt-bg: rgba(30, 151, 211, 0.08); --ms-blue-lt-border: rgba(73, 183, 228, 0.3);
  --ms-green-bg: rgba(57, 180, 114, 0.14);  --ms-green-border: rgba(67, 199, 127, 0.38); --ms-green-text: #72e2a4;
  --ms-green-lt-bg: rgba(57, 180, 114, 0.09);
  --ms-red-bg: rgba(212, 75, 92, 0.2);      --ms-red-border: rgba(227, 89, 105, 0.45);   --ms-red-text: #ff9ca7;
  --ms-red-dk-bg: rgba(212, 75, 92, 0.35);  --ms-red-dk-border: rgba(227, 89, 105, 0.6);
  --ms-red-lt-bg: rgba(212, 75, 92, 0.11);
  --ms-yellow-bg: rgba(230, 157, 0, 0.16);  --ms-yellow-border: rgba(240, 170, 21, 0.48); --ms-yellow-text: #ffc84f;
  --ms-yellow-lt-bg: rgba(230, 157, 0, 0.07);
  --ms-orange-bg: rgba(240, 140, 20, 0.15); --ms-orange-border: rgba(245, 160, 60, 0.5);  --ms-orange-text: #ffb066;
  --ms-purple-bg: rgba(147, 51, 234, 0.18); --ms-purple-border: rgba(192, 132, 252, 0.35); --ms-purple-text: #dda9ff;
  --ms-turq-bg: rgba(31, 190, 181, 0.12);   --ms-turq-border: rgba(42, 199, 190, 0.4);    --ms-turq-text: #57e3da;
  --ms-grey-bg: rgba(255, 255, 255, 0.06);  --ms-grey-border: #30435d;
  --ms-nav: #0e1c30;
  --ms-link: #c88cff;
  --ms-link-dk: #dda9ff;

  --theme-bg: #13243b; --theme-border: #30435d; --theme-lt: #102139;
  --theme-grad: linear-gradient(135deg, #14273f 0%, #0e1f36 60%, #0c1830 100%);
  --page-grad: linear-gradient(180deg, #0c1d33 0%, #071426 220px, #071426 65%, #0c2038 100%);
}
html[data-theme="dark"] body.theme-cs {
  --theme-grad: radial-gradient(circle at 70% 0%, rgba(102, 47, 160, 0.35), transparent 45%),
                linear-gradient(135deg, #25103f 0%, #170c34 60%, #0c1830 100%);
  --theme-border: #392550;
}
html[data-theme="dark"] body.theme-special {
  --theme-grad: radial-gradient(circle at 70% 0%, rgba(47, 130, 70, 0.3), transparent 45%),
                linear-gradient(135deg, #10321c 0%, #0c2417 60%, #0c1830 100%);
  --theme-border: #25503a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  /* fixed = the gradient hangs on the viewport (stretching to the bottom of
     the window) and does NOT move when the page scrolls */
  background: var(--page-grad) fixed, var(--page-bg);
  transition: background-color 180ms ease, color 180ms ease;
}
a { color: var(--ms-link); }
a:hover { color: var(--ms-link-dk); }
h1, h2, h3 { margin: 0 0 .5em; }
button, input, select, textarea { font: inherit; }

.testing-banner {
  position: fixed; bottom: 0; left: 0; width: 100%;
  background: red; color: #fff; text-align: center;
  padding: 2px; font-size: 13px; opacity: .5; z-index: 9999;
  pointer-events: none;
}

/* ── Booking window ─────────────────────────────────────────────────────── */

.bw { max-width: 1440px; margin: 0 auto; }

.bw-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .6rem 1.25rem;
  background: var(--theme-grad);
  border-bottom: 1px solid var(--theme-border);
  box-shadow: 0 3px 14px rgba(83, 45, 101, 0.08);
}
.bw-line1 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-height: 34px; }
.bw-line1 h1 { font-size: 17px; font-weight: normal; margin: 0; }
.bw-org { margin-left: .35em; }
.bw-home { text-decoration: none; font-size: 18px; }
.bw-titleline { font-size: 14px; }
.bw-ref { margin-left: .3em; }

.bw-tools { display: flex; align-items: center; gap: .6rem; }
.tool { font-size: 16px; text-decoration: none; cursor: pointer; }
.veh-notbooked { filter: hue-rotate(140deg); }

.status-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.25); vertical-align: middle;
}
.status-blue   { background: #6ec6f0; }
.status-green  { background: #9ccb5a; }
.status-red    { background: #f06e6e; }
.status-yellow { background: #f0d84b; }

/* dark-mode switch (header) */
.theme-switch {
  position: relative; width: 40px; height: 22px; padding: 0; flex: 0 0 auto;
  background: rgba(72, 54, 78, 0.25); border: 0; border-radius: 999px;
  cursor: pointer; transition: 180ms ease;
}
.theme-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform 180ms ease;
}
html[data-theme="dark"] .theme-switch { background: var(--brand-600); }
html[data-theme="dark"] .theme-switch::after { transform: translateX(18px); }

.bw-overflow { position: relative; }
.bw-overflow summary { list-style: none; cursor: pointer; font-size: 18px; padding: 0 .4rem; }
.bw-overflow ul {
  position: absolute; right: 0; margin: 0; padding: .3rem 0; list-style: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); min-width: 150px; z-index: 50;
}
.bw-overflow li a { display: block; padding: .35rem .8rem; text-decoration: none; }
.bw-overflow li a:hover { background: var(--surface-hover); }

.bw-tabs {
  display: flex; flex-wrap: wrap; gap: 2px; padding: .4rem 1.25rem 0;
  background: var(--theme-grad); border-bottom: 1px solid var(--theme-border);
}
.bw-tab {
  padding: .4rem .8rem; text-decoration: none;
  background: var(--theme-lt); border: 1px solid var(--theme-border); border-bottom: none;
  border-radius: 7px 7px 0 0; color: var(--ms-link);
}
.bw-tab.selected { background: var(--page-bg); font-weight: 650; color: var(--text-strong); }

/* red count badge on a tab (chasers due today / overdue) */
.tab-badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px;
  margin-left: .35rem; padding: 0 4px; border-radius: 999px;
  background: #d63a4c; color: #fff; font-size: 10.5px; font-weight: 700;
  text-align: center; vertical-align: 1px;
}

/* burger replaces the tab strip on mobile (media query below) */
.bw-burger { display: none; }

.bw-subtabs {
  display: flex; flex-wrap: wrap; gap: 1rem; padding: .4rem 1.25rem;
  background: var(--ms-nav); border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.bw-subtab { text-decoration: none; }
.bw-subtab.selected { font-weight: 650; color: var(--text-strong); }

.bw-body { padding: 1.1rem 1.25rem; }

.bw-stub {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
  padding: 2rem; text-align: center; color: var(--text-muted);
  background: var(--surface-soft);
}
.bw-stub h2 { color: var(--text); }

/* ── Cover tab (cards + panels) ─────────────────────────────────────────── */

.cards { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; align-items: stretch; }
/* a card that takes extra room on wide screens but still WRAPS on narrow
   ones (flex-basis stays 300px — a 0 basis never triggers the wrap) */
fieldset.card.card-wide { flex: 2 1 300px; max-width: none; }

fieldset.card {
  flex: 1 1 300px; max-width: 460px; min-width: 0; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .85rem 1.1rem; position: relative; background: var(--surface);
  box-shadow: var(--shadow-sm);
}
fieldset.card:hover { border-color: var(--border-strong); }
.card h3 { font-size: 14px; margin: 0 0 .5rem; color: var(--text-strong); font-weight: 650; }
.card-edit {
  position: absolute; top: .5rem; right: .75rem;
  text-decoration: none; font-size: 14px;
}
.card dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: .2rem .75rem; margin: 0; }
.card dt { color: var(--text-muted); font-size: 13px; }
.card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.card dl.card-sep { border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .6rem; }
.card .warn { background: var(--ms-red-lt-bg); }

fieldset.panel {
  margin: 0 0 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .85rem 1.1rem; background: var(--surface);
  box-shadow: var(--shadow-sm);
}
fieldset.panel:hover { border-color: var(--border-strong); }

/* ── ⋮ card menu: descriptive actions with mobile-sized tap targets ── */
.card-menu { position: relative; margin-left: auto; }
.card-menu summary {
  list-style: none; cursor: pointer; padding: .1rem .55rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 17px; user-select: none;
}
.card-menu summary::-webkit-details-marker { display: none; }
.card-menu summary:hover { background: var(--surface-hover); color: var(--text); }
.card-menu[open] ul {
  position: absolute; right: 0; top: 100%; z-index: 40; margin: 3px 0 0; padding: .3rem 0;
  list-style: none; min-width: 185px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.card-menu ul a {
  display: block; padding: .55rem 1rem; text-decoration: none;
  font-size: 13.5px; white-space: nowrap;
}
.card-menu ul a:hover { background: var(--surface-hover); }

/* ── Rich-text editor (textarea.rich-text) ── */
.rt-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.rt-toolbar {
  display: flex; gap: 2px; flex-wrap: wrap; padding: .3rem .4rem;
  background: var(--surface-soft); border-bottom: 1px solid var(--border);
}
.rt-toolbar button {
  min-width: 30px; padding: .25rem .5rem; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 12.5px;
}
.rt-toolbar button:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.rt-toolbar button:first-child { font-weight: bold; }
.rt-editor {
  min-height: 180px; max-height: 480px; overflow-y: auto;
  padding: .6rem .8rem; font-size: 13.5px; line-height: 1.5; outline: none;
}
.rt-editor:focus { box-shadow: inset 0 0 0 2px rgba(168, 85, 247, 0.15); }
.rt-editor ul, .rt-editor ol { margin: .3rem 0 .3rem 1.4rem; }

/* Organisation picker results (Contact tab) */
.search-results .org-hit {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .45rem .7rem; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); margin: 0 0 .3rem;
}
.search-results .org-hit:hover { border-color: var(--brand-400); background: var(--surface-hover); }
.search-results .org-hit strong { color: var(--text-strong); }

/* Merge tab */
.merge-bar { display: flex; align-items: center; gap: .8rem; }
.merge-pick { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.merge-pick input { margin: 0; cursor: pointer; }
.merge-card.merge-picked { border-color: var(--ms-green-border); background: var(--ms-green-lt-bg); }

/* dc-list: on desktop the cards flatten into full-width one-per-line rows
   (table-like, so payment/invoice ORDER reads top-to-bottom); mobile keeps
   the stacked card layout, which already works well there */
@media (min-width: 901px) {
  .dc-cards.dc-list { display: flex; flex-direction: column; gap: .4rem; }
  .dc-list .dc-card {
    display: flex; flex-direction: row; flex-wrap: wrap; align-items: center;
    justify-content: flex-start; column-gap: 1rem; row-gap: .1rem; padding: .35rem .8rem;
  }
  .dc-list .dc-card .dc-top { display: contents; }
  .dc-list .dc-card .dc-line { margin: 0; display: inline-flex; align-items: baseline; gap: .35rem; }
  .dc-list .dc-card .dc-actions { order: 99; margin-left: auto; white-space: nowrap; }
}

.hidden-matches {
  margin: -.4rem 0 .8rem; padding: .45rem .8rem; font-size: 13px;
  background: var(--ms-yellow-lt-bg); border: 1px solid var(--ms-yellow-border);
  border-radius: var(--radius-sm); width: fit-content;
}

/* Home search results as clickable panels */
.sr-card { cursor: pointer; }
.sr-card:hover { border-color: var(--brand-400); box-shadow: var(--shadow-md); }
.sr-ref { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.sr-dept {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650;
  background: var(--ms-grey-bg); border: 1px solid var(--ms-grey-border);
}
.sr-dept-bs { background: var(--ms-blue-bg); border-color: var(--ms-blue-border); color: var(--ms-blue-text); }
.sr-dept-cs { background: var(--ms-purple-bg); border-color: var(--ms-purple-border); color: var(--ms-purple-text); }
.sr-dept-special { background: var(--ms-green-bg); border-color: var(--ms-green-border); color: var(--ms-green-text); }

/* Contact methods as emoji tiles (like the address boxes) */
.method-tiles { display: flex; flex-wrap: wrap; gap: .7rem; }
.method-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: .55rem .8rem; flex: 0 1 240px; min-width: 180px;
}
.method-tile:hover { border-color: var(--border-strong); }
.method-tile.method-default { border-color: var(--ms-green-border); background: var(--ms-green-lt-bg); }
.method-tile-top { display: flex; align-items: center; gap: .45rem; }
.method-emoji { font-size: 20px; }
.method-type { font-size: 11.5px; color: var(--text-muted); }
.method-value { margin-top: .3rem; font-weight: 650; overflow-wrap: anywhere; }
.method-note { margin-top: .2rem; font-size: 12px; }

/* Venue Sessions group-by — each group is a bordered, colour-accented block */
.vs-groupby { font-weight: normal; font-size: 12.5px; margin-left: .6rem; }
.vs-group {
  border: 1px solid var(--ms-blue-lt-border); border-left: 4px solid var(--ms-blue-border);
  border-radius: var(--radius-md); background: var(--ms-blue-lt-bg);
  padding: .55rem .7rem .7rem; margin: 0 0 .8rem;
}
.vs-group:last-child { margin-bottom: 0; }
.vs-group-head {
  margin: 0 0 .5rem; font-size: 13.5px; color: var(--ms-blue-text); font-weight: 650;
}
.vs-group .dc-cards { margin-top: 0; }
.vs-group .row-cards { gap: .45rem; }

/* Programme → Activities: one bordered block per DATE, sessions slotted
   into Morning / Afternoon / Evening columns like the diary */
.prog-day {
  border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-md); background: var(--surface-soft);
  padding: .55rem .7rem .7rem; margin: 0 0 .8rem;
}
/* one programme (ver5 diary card) inside a column — tinted by status */
.prog-slot {
  border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .4rem .5rem; margin: 0 0 .55rem;
  background: var(--surface-soft);
}
.prog-slot.prog-day-confirmed, .prog-slot.prog-day-confirmed_eve { border-left-color: var(--ms-green-border); background: var(--ms-green-lt-bg); }
.prog-slot.prog-day-provisional { border-left-color: var(--ms-blue-border); background: var(--ms-blue-lt-bg); }
.prog-slot-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin: 0 0 .4rem; }
.prog-slot-head .btn-mini { margin-left: auto; }
.prog-cycle img { display: block; height: 16px; }
.prog-sel-box input { margin: 0; cursor: pointer; }
.prog-tools { font-weight: normal; margin-left: .6rem; }
.ps-what { display: inline-flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ps-what .ps-loc { font-size: 11.5px; }
.ps-menu { position: relative; margin-left: auto; }
.ps-menu summary {
  list-style: none; cursor: pointer; padding: 0 .4rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 15px; user-select: none;
}
.ps-menu summary::-webkit-details-marker { display: none; }
.ps-menu summary:hover { background: var(--surface-hover); color: var(--text); }
.ps-menu[open] ul {
  position: absolute; right: 0; top: 100%; z-index: 30; margin: 2px 0 0; padding: .25rem 0;
  list-style: none; min-width: 110px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.ps-menu ul a { display: block; padding: .3rem .8rem; text-decoration: none; font-size: 12.5px; }
.ps-menu ul a:hover { background: var(--surface-hover); }
#cm_table { margin: .5rem 0; }
#cm_table input { padding: .15rem .4rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
#prog_cm_dialog hr { border: 0; border-top: 1px solid var(--border); margin: .5rem 0; }
#prog_cm_dialog label { display: block; margin: .25rem 0; }
.prog-day-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin: 0 0 .55rem; font-size: 13.5px; font-weight: normal;
}
.prog-day-head strong { font-size: 14px; color: var(--text-strong); }
.prog-day-add { margin-left: auto; }
/* dense grid so long_prog slots can SPAN two day-part columns while
   normal slots backfill the earliest free row in their own column */
.prog-cols {
  display: grid; grid-template-columns: repeat(3, 1fr);
  grid-auto-flow: row dense; gap: .3rem .6rem; align-items: start;
}
.prog-col-head, .prog-col h4 {
  margin: 0; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted); font-weight: 650;
}
.prog-slot-long { border-right: 4px solid var(--border-strong); }
.prog-slot-long.prog-day-confirmed, .prog-slot-long.prog-day-confirmed_eve { border-right-color: var(--ms-green-border); }
.prog-slot-long.prog-day-provisional { border-right-color: var(--ms-blue-border); }
.ps-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  padding: .3rem .55rem; margin: 0 0 .4rem; font-size: 13px;
}
.ps-main { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.ps-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-act { font-weight: 650; color: var(--text-strong); }
.ps-staff { color: var(--ms-blue-text); }
.ps-actions { margin-left: auto; white-space: nowrap; }
.ps-extra { display: block; padding-left: .5rem; }
.ps-none { margin: .2rem 0 0; }
.prog-day-note {
  margin-top: .55rem; padding: .4rem .6rem; font-size: 12.5px;
  background: var(--ms-yellow-lt-bg); border: 1px solid var(--ms-yellow-border);
  border-radius: var(--radius-sm);
}
@media (max-width: 900px) {
  /* block layout ignores the inline grid-column placements — DOM order is
     Morning + its slots, Afternoon + its slots, Evening + its slots */
  .prog-cols { display: block; }
  .prog-col-head { margin: .5rem 0 .3rem; }
  .prog-slot { margin-bottom: .45rem; }
}

/* Files: ver5 type icons + list ⇄ grid toggle */
.files-view-switch { font-weight: normal; margin-left: .6rem; }
.file-icon img { image-rendering: pixelated; width: 16px; height: 16px; vertical-align: -2px; }
.file-cards.files-grid { flex-direction: row; flex-wrap: wrap; }
.files-grid .file-card { flex: 0 1 190px; min-width: 160px; }
.files-grid .file-card .rc-head { flex-direction: column; align-items: center; gap: .35rem; text-align: center; }
.files-grid .file-icon img { width: 32px; height: 32px; }
.files-grid .file-title { overflow-wrap: anywhere; }
.files-grid .file-meta { font-size: 11.5px; }
.files-grid .file-actions { margin-left: 0; }

/* Booking tab: Accommodation Venues + Waves share a row on wide screens */
.cover-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.cover-two .panel { margin: 0; min-width: 0; }
.cover-two + fieldset.panel { margin-top: 1rem; }
@media (max-width: 900px) { .cover-two { grid-template-columns: 1fr; } }

/* ── Row-cards: table rows re-imagined as slim panels (mobile-friendly) ── */
.row-cards { display: flex; flex-direction: column; gap: .55rem; }
.row-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: .5rem .8rem;
}
.row-card:hover { border-color: var(--border-strong); }
.rc-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.rc-title { font-weight: 650; color: var(--text-strong); }
.rc-actions { margin-left: auto; white-space: nowrap; }
.rc-grid { display: flex; flex-wrap: wrap; gap: .15rem 1.6rem; margin-top: .3rem; font-size: 13px; }
.rc-field { min-width: 0; overflow-wrap: anywhere; }
.rc-label { color: var(--text-muted); margin-right: .4rem; }
.rc-label::after { content: ':'; }
.rc-body { margin-top: .35rem; font-size: 13px; }
.rc-inline { min-width: 0; overflow-wrap: anywhere; }
.row-cards-slim .row-card { padding: .3rem .7rem; box-shadow: none; }
.row-cards-slim { gap: .35rem; }

/* cover-note fields as flagged warnings — emoji + tone, hidden when empty */
.nf-panel { position: relative; border-left: 4px solid var(--border-strong); } /* anchors the ✎ card-edit */
.nf-panel.nf-yellow { border-left-color: var(--ms-yellow-border); background: var(--ms-yellow-lt-bg); }
.nf-panel.nf-blue   { border-left-color: var(--ms-blue-border);   background: var(--ms-blue-lt-bg); }
.nf-panel.nf-purple { border-left-color: var(--ms-purple-border); background: var(--ms-purple-bg); }
.nf-emoji { font-size: 17px; margin-right: .15rem; }
.nf-text { white-space: normal; font-size: 13.5px; }
.nf-panel .edit-form { margin-top: .5rem; }
.nf-add-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* Actions tab — the group panels pack into two columns (one on mobile) */
.actions { columns: 2; column-gap: 1rem; }
.actions .panel { break-inside: avoid; margin: 0 0 1rem; min-width: 0; }
.actions .panel table.data { width: 100%; }
@media (max-width: 800px) { .actions { columns: 1; } }
.panel h2 { font-size: 15px; margin: 0 0 .6rem; color: var(--text-strong); font-weight: 650; }
.panel h2 .updated { font-size: 11px; font-weight: normal; color: var(--text-faint); margin-left: .5rem; }

.note-box {
  border: 1px solid var(--ms-blue-border); background: var(--ms-blue-lt-bg);
  border-radius: var(--radius-sm); padding: .6rem .75rem; min-height: 3em;
  white-space: pre-wrap;
}

table.data th.group-l, table.data td.group-l { border-left: 1px solid var(--border); }
table.data th.group-r { border-right: 1px solid var(--border); }
.flag-warn { color: var(--ms-red-text); font-weight: bold; font-size: 12px; }

/* ── Notes / files / banners ────────────────────────────────────────────── */

.banner {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .5rem .8rem; margin-bottom: .6rem; border-radius: var(--radius-md);
  font-weight: 600; font-size: 13px; max-width: 640px;
}
.banner-orange { background: var(--ms-orange-bg); border: 1px solid var(--ms-orange-border); color: var(--ms-orange-text); }
.banner-red    { background: var(--ms-red-lt-bg);  border: 1px solid var(--ms-red-border); color: var(--ms-red-text); }

/* Each note is a card: meta header on top, body gets the full width.
   Notes carry ver5-authored HTML (file links, whole email bodies) — keep it
   from breaking out: wrap long content, cap embedded images/tables. */
.note-list-tools { display: flex; justify-content: space-between; gap: .5rem; margin: 0 0 .6rem; }
.note-cards { display: flex; flex-direction: column; gap: .7rem; }
.note-card {
  padding: .55rem .8rem .7rem; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.note-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding-bottom: .4rem; margin-bottom: .5rem;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.note-head strong { color: var(--text-strong); }
.note-head .note-actions { margin-left: auto; display: inline-flex; gap: .4rem; }
.note-type-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; line-height: 1.35;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--ms-grey-bg); border: 1px solid var(--ms-grey-border);
}
.note-body { max-width: 960px; overflow-wrap: anywhere; line-height: 1.5; }
.note-body img { max-width: 100%; height: auto; }
/* Embedded email tables reference ver5 CSS classes (booking__summary,
   table__header, …) that don't exist here — style ANY table in note content
   the way ver5 renders them: full grid + shaded header row. */
.note-body table {
  max-width: 100%; border-collapse: collapse; margin: .5rem 0;
  background: var(--surface);
}
.note-body th, .note-body td {
  border: 1px solid var(--border); padding: .3rem .6rem; text-align: left;
}
.note-body th { background: var(--ms-grey-bg); font-weight: 650; color: var(--text-strong); }
.note-green  { background: var(--ms-green-lt-bg);  border-color: var(--ms-green-border); }
.note-red    { background: var(--ms-red-lt-bg);    border-color: var(--ms-red-border); }
.note-orange { background: var(--ms-orange-bg);    border-color: var(--ms-orange-border); }
.note-yellow { background: var(--ms-yellow-lt-bg); border-color: var(--ms-yellow-border); }
.note-purple { background: var(--ms-purple-bg);    border-color: var(--ms-purple-border); }
.note-pinned { border-left: 3px solid var(--ms-orange-border); }
.note-public { color: var(--ms-red-text); background: var(--ms-red-lt-bg); border-color: var(--ms-red-border); }
.note-hidden { display: none; }
.note-hidden.shown { display: block; }
.note-card.note-hidden { background: var(--ms-grey-bg); color: var(--text-muted); }
.muted { color: var(--text-muted); font-weight: normal; font-size: 11px; }

.btn-mini {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: 11px; font-weight: 600; padding: 3px 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}
.btn-mini:hover { transform: translateY(-1px); background: var(--surface-hover); }
.btn-mini:active { transform: translateY(0); }

/* ── Contact tab ────────────────────────────────────────────────────────── */

dl.detail-list { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: .25rem .75rem; margin: 0; }
dl.detail-list dt { color: var(--text-muted); font-size: 13px; }
dl.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.default-number { font-weight: bold; }

.address-boxes { display: flex; flex-wrap: wrap; gap: 1rem; }
.address-box {
  border: 1px solid var(--ms-yellow-border); background: var(--ms-yellow-lt-bg);
  border-radius: var(--radius-sm); padding: .6rem .75rem; min-width: 200px;
}
.address-type { font-weight: bold; margin-bottom: .25rem; display: flex; align-items: center; gap: .4rem; }
.address-postcode { font-weight: bold; margin-top: .25rem; }
p.empty { color: var(--text-faint); }

/* ── Financial tabs ─────────────────────────────────────────────────────── */

td.overdue, strong.overdue { color: var(--ms-red-text); font-weight: bold; }
tr.quote-live td { background: var(--ms-green-lt-bg); }
.dc-card.quote-live-card { background: var(--ms-green-lt-bg); border-color: var(--ms-green-border); }

/* ── Programme tabs ─────────────────────────────────────────────────────── */

.prog-date-row td { background: var(--ms-grey-bg); border-top: 2px solid var(--border-strong); }

.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; line-height: 1.35;
  padding: 1px 8px; border-radius: 999px;
  margin-left: .4rem; vertical-align: 1px; white-space: nowrap;
}
.chip-blue  { background: var(--ms-blue-bg);  border: 1px solid var(--ms-blue-border);  color: var(--ms-blue-text); }
.chip-green { background: var(--ms-green-bg); border: 1px solid var(--ms-green-border); color: var(--ms-green-text); }
.chip-red   { background: var(--ms-red-bg);   border: 1px solid var(--ms-red-border);   color: var(--ms-red-text); }

table.data-nested { margin: .25rem 0; }
table.data-nested th { font-size: 12px; }

.pkg-day { margin: .75rem 0 1rem; }
.pkg-day h3 { font-size: 13px; margin: 0 0 .35rem; }
tr.pkg-extra td { background: var(--ms-yellow-lt-bg); font-size: 12px; }
table.data tfoot td { border-top: 2px solid var(--border-strong); }

/* ── Chasers ────────────────────────────────────────────────────────────── */

.chaser-form { display: flex; gap: 2rem; flex-wrap: wrap; }
.chaser-form-main { flex: 1 1 380px; max-width: 560px; }
.chaser-form-main label { display: block; margin: .4rem 0 .2rem; font-size: 13px; }
.chaser-form-main input[type=text], .chaser-form-main select {
  padding: .3rem .5rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.chaser-labels-pick { display: flex; flex-wrap: wrap; gap: .3rem; margin: .2rem 0 .4rem; }
.ch-label { text-decoration: none; opacity: .45; cursor: pointer; }
.ch-label.selected { opacity: 1; outline: 2px solid var(--brand-400); outline-offset: 1px; }
.chaser-urgency { display: flex; flex-wrap: wrap; gap: .9rem; margin: .2rem 0 .5rem; font-size: 13px; }
.chaser-presets { flex: 1 1 260px; }
.chaser-presets h4 { margin: .3rem 0 .4rem; font-size: 13px; }
.ch-preset {
  display: flex; gap: .5rem; align-items: baseline; padding: .35rem 0;
  border-top: 1px solid var(--border); font-size: 13px;
}
.ch-preset:first-of-type { border-top: 0; }
.ch-preset a { text-decoration: none; }
.ch-preset-text { flex: 1; overflow-wrap: anywhere; }
.ch-done-box {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  font-size: 12px; color: var(--text-muted); user-select: none;
  padding: .15rem .5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.ch-done-box:hover { border-color: var(--ms-green-border); color: var(--ms-green-text); }
.ch-done-box input { accent-color: var(--ms-green-text, #357234); cursor: pointer; margin: 0; }
.chaser-card.chaser-done .ch-done-box {
  background: var(--ms-green-bg); border-color: var(--ms-green-border); color: var(--ms-green-text);
}

/* recipient's chaser calendars (ver5 chaser_calendar) — a row along the
   bottom of the New-chaser panel */
.chaser-cals {
  display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-start;
  margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border);
}
.chaser-cal {
  border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border-strong); flex: 1 1 210px; max-width: 280px;
}
.chaser-cal thead th {
  background: var(--surface-soft); border-bottom: 1px solid var(--border);
  font-size: 11px; padding: 2px; text-align: center;
}
.chaser-cal tbody td {
  border: 1px solid var(--border); width: 32px; height: 26px;
  position: relative; text-align: center; padding: 0;
}
.chaser-cal tbody td.no-day { background: var(--surface-soft); }
.chaser-cal tbody td.weekend { background: var(--surface-soft); }
.chaser-cal tbody td.hol  { background: #fcc; }
.chaser-cal tbody td.lieu { background: #ddf; }
.chaser-cal tbody td.off  { background: #fee; }
.chaser-cal tbody td.today { background: var(--ms-green-lt-bg, #cfc); }
html[data-theme="dark"] .chaser-cal tbody td.hol  { background: #6b2f35; }
html[data-theme="dark"] .chaser-cal tbody td.lieu { background: #38406e; }
html[data-theme="dark"] .chaser-cal tbody td.off  { background: #55343c; }
.chaser-cal .cal-day {
  display: block; width: 100%; height: 100%; text-decoration: none; color: var(--text);
}
.chaser-cal .cal-day em {
  position: absolute; top: 1px; left: 2px; font-size: 8px; font-style: normal;
  color: var(--text-muted);
}
.chaser-cal .cal-day .cal-n {
  position: absolute; bottom: 0; right: 3px; font-size: 14px; color: var(--brand-600, #6186a3);
}
html[data-theme="dark"] .chaser-cal .cal-day .cal-n { color: var(--brand-300, #9dc3e0); }
.chaser-cal .cal-day.selected { outline: 2px solid var(--brand-400); outline-offset: -2px; }
/* chaser list — full-width panels, open ones on top, completed folded away */
.chaser-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  margin: 0 0 .6rem; overflow: hidden;
}
.chaser-card .note-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .45rem .8rem; background: var(--surface-soft);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.chaser-card.chaser-urgent .note-head { background: var(--ms-red-lt-bg); }
.chaser-card .note-body { padding: .55rem .8rem; }
.chaser-card-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.chaser-card.chaser-done { opacity: .65; }
.chaser-done-fold { margin-top: .8rem; }
.chaser-done-fold > summary {
  cursor: pointer; font-size: 13px; color: var(--text-muted);
  padding: .3rem 0; user-select: none;
}
.chaser-done-fold[open] > summary { margin-bottom: .6rem; }
.chaser-label {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  margin: 1px 2px 1px 0; border: 1px solid rgba(0,0,0,.15);
}
.label-orange { background: var(--ms-orange-bg); color: var(--ms-orange-text); }
.label-purple { background: var(--ms-purple-bg); color: var(--ms-purple-text); }
.label-yellow { background: var(--ms-yellow-bg); color: var(--ms-yellow-text); }
.label-blue   { background: var(--ms-blue-bg);   color: var(--ms-blue-text); }
.label-green  { background: var(--ms-green-bg);  color: var(--ms-green-text); }
.label-red    { background: var(--ms-red-bg);    color: var(--ms-red-text); }
.label-black  { background: #333; color: #fff; }

/* ── Funnel ─────────────────────────────────────────────────────────────── */

.funnel-strip { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
.funnel-offpath { margin-top: .6rem; }
.funnel-stage {
  flex: 1 1 110px; min-width: 110px; padding: .5rem .6rem; border-radius: var(--radius-md);
  background: var(--ms-grey-bg); border: 1px solid var(--ms-grey-border);
  opacity: .55; text-align: center;
}
.funnel-stage h4 { margin: 0 0 .2rem; font-size: 13px; }
.funnel-stage.reached { opacity: 1; background: var(--ms-blue-lt-bg); border-color: var(--ms-blue-border); }
.funnel-stage.current {
  opacity: 1; background: var(--ms-green-bg); border-color: var(--ms-green-border);
  font-weight: bold;
}
.funnel-stage.stage-off { flex: 0 1 160px; }
.funnel-stage.stage-off.current { background: var(--ms-red-bg); border-color: var(--ms-red-border); }
button.funnel-stage { cursor: pointer; font: inherit; color: inherit; }
button.funnel-stage:hover { outline: 2px solid var(--ms-link); }
button.funnel-stage:disabled { cursor: not-allowed; }
button.funnel-stage:disabled:hover { outline: none; }

/* the funnel drawn as a funnel: full-width New Lead narrowing to Closed */
.funnel-pyramid { display: flex; flex-direction: column; align-items: center; gap: .45rem; }
.funnel-tier { position: relative; display: flex; justify-content: center; }
.funnel-tier .funnel-stage { flex: 1 1 auto; min-width: 0; }
.funnel-unset {
  position: absolute; top: -6px; right: -6px; z-index: 5;
  width: 18px; height: 18px; line-height: 16px; text-align: center;
  border-radius: 50%; text-decoration: none; font-size: 13px;
  background: var(--ms-red-bg); border: 1px solid var(--ms-red-border);
  color: var(--ms-red-text);
}
.funnel-unset:hover { background: var(--ms-red-dk-bg); color: var(--ms-red-text); }
.funnel-off-wrap { position: relative; display: inline-flex; }
.funnel-offpath { justify-content: center; }

/* ── Write controls (Stage 4) ───────────────────────────────────────────── */

.btn-green { background: var(--ms-green-bg); border-color: var(--ms-green-border); color: var(--ms-green-text); }
.btn-red   { background: var(--ms-red-lt-bg); border-color: var(--ms-red-border); color: var(--ms-red-text); }

.tool-mini { text-decoration: none; font-size: 12px; margin-left: .3rem; }

.title-edit { display: none; align-items: center; gap: .3rem; }
.title-edit input {
  font-size: 13px; padding: 2px 6px; width: 280px;
  border: 1px solid var(--ms-yellow-border); background: var(--ms-yellow-lt-bg);
  border-radius: var(--radius-sm); color: var(--text);
}

.note-edit-box {
  display: block; width: 100%; max-width: 850px; min-height: 90px;
  padding: .5rem; margin-bottom: .4rem; font: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.note-add-controls { display: flex; gap: .5rem; align-items: center; }
.note-add-controls select, .note-editform select {
  padding: 3px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; background: var(--surface); color: var(--text);
}
.note-actions a { text-decoration: none; margin-right: .25rem; }
.note-editform textarea { min-height: 70px; }

.toast {
  position: fixed; bottom: 2.5rem; right: 1rem; z-index: 9999;
  background: var(--ms-green-bg); border: 1px solid var(--ms-green-border);
  color: var(--ms-green-text); padding: .5rem 1rem; border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); font-size: 13px; font-weight: 600;
}
.toast-error { background: var(--ms-red-bg); border-color: var(--ms-red-dk-border); color: var(--ms-red-text); }

/* ── Edit forms + dialogs (Stage 5) ─────────────────────────────────────── */

.edit-form {
  margin-top: .75rem; padding: .75rem; border-radius: var(--radius-md);
  background: var(--ms-yellow-lt-bg); border: 1px solid var(--ms-yellow-border);
}
.edit-form h4 { margin: 0 0 .5rem; font-size: 13px; }
.edit-form label { display: block; margin: .35rem 0; font-size: 13px; }
.edit-form label > input[type=text], .edit-form label > select, .edit-form label > textarea {
  display: block; margin-top: .15rem; width: 100%; max-width: 320px;
  padding: .35rem .5rem; font: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color 140ms ease, box-shadow 140ms ease;
}
.edit-form label > input[type=text]:focus, .edit-form label > select:focus, .edit-form label > textarea:focus {
  border-color: var(--brand-400); box-shadow: var(--focus-ring);
}
.edit-form .field-pair { display: flex; gap: .4rem; margin-top: .15rem; }
.edit-form .field-pair input { width: auto; padding: .35rem .5rem; font: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); }
.edit-form .form-buttons { margin-top: .6rem; display: flex; gap: .5rem; }
.edit-form-inline { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.edit-form-inline label { margin: 0; }
.edit-form-inline .form-buttons { margin: 0 0 .2rem; }

dialog.bw-dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  box-shadow: var(--shadow-md); width: min(480px, calc(100vw - 2rem));
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface);
}
dialog.bw-dialog::backdrop { background: rgba(10, 8, 20, .45); }
dialog.bw-dialog h3 { margin: 0 0 .5rem; font-size: 15px; color: var(--text-strong); font-weight: 650; }
dialog.bw-dialog .edit-form { margin-top: 0; }

.contact-switch { margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.search-results { margin: .4rem 0; display: flex; flex-direction: column; gap: .2rem; max-height: 160px; overflow-y: auto; }
.search-results a { font-size: 13px; }
.copy-methods { display: flex; flex-direction: column; gap: .2rem; margin: .3rem 0; }
.copy-method { font-size: 13px; }
h2 .btn-mini { margin-left: .5rem; text-decoration: none; font-weight: 600; }
.btn-mini { text-decoration: none; }

.mini-select {
  font-size: 11px; padding: 1px 4px; margin-left: .4rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}

/* ── Customer view ──────────────────────────────────────────────────────── */

.bw-customer {
  display: inline-block; margin-left: .4rem; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; text-decoration: none; vertical-align: 2px;
  background: var(--surface); border: 1px solid var(--ms-purple-border); color: var(--ms-link-dk);
}
.bw-customer:hover { background: var(--ms-purple-bg); }
tr.row-current td { background: var(--ms-yellow-lt-bg); font-weight: bold; }

/* The customer strip — the customer's bookings across every state of a CS window */
.cust-strip {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .5rem 1.25rem;
  background: var(--theme-grad);
  border-bottom: 1px solid var(--theme-border);
}
.cust-strip-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text); opacity: .6; align-self: center; font-weight: 700;
}
.cust-strip-divider {
  width: 1px; align-self: stretch; margin: 0 .35rem;
  background: var(--theme-border);
}
.cust-strip-none { align-self: center; font-size: 11px; }
.cust-strip-who {
  display: inline-flex; align-items: center; gap: .4rem;
  text-decoration: none; color: var(--text-strong); white-space: nowrap;
  padding: .3rem .8rem; border-radius: 999px; font-weight: 700;
  background: rgba(255, 255, 255, 0.87); border: 1px solid rgba(109, 54, 127, 0.22);
  box-shadow: var(--shadow-sm);
}
.cust-strip-who:hover { background: #fff; }
html[data-theme="dark"] .cust-strip-who {
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16);
}
html[data-theme="dark"] .cust-strip-who:hover { background: rgba(255, 255, 255, 0.14); }
.cust-strip-who .muted { margin-left: .3rem; font-size: 11px; font-weight: normal; }
.m-number { font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.cust-strip-who .m-number {
  margin-left: .35rem; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
  background: var(--ms-purple-bg); border: 1px solid var(--ms-purple-border);
  color: var(--ms-purple-text);
}
.cust-strip-chips { display: flex; gap: .45rem; flex-wrap: wrap; align-items: stretch; }
.cust-chip {
  display: flex; flex-direction: column; justify-content: center;
  min-width: 92px; padding: .3rem .6rem; border-radius: 7px;
  text-decoration: none; color: var(--text); line-height: 1.3;
  background: rgba(255, 255, 255, 0.88); border: 1px solid rgba(89, 57, 102, 0.16);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  transition: transform 140ms ease, border-color 140ms ease;
}
.cust-chip:hover { transform: translateY(-1px); border-color: var(--ms-link); }
html[data-theme="dark"] .cust-chip {
  background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.14);
}
.cust-chip .cust-chip-date { font-weight: 700; white-space: nowrap; }
.cust-chip .cust-chip-type { white-space: nowrap; }
.cust-chip .status-dot { width: 8px; height: 8px; }
.cust-chip.upcoming { background: var(--ms-yellow-lt-bg); border-color: var(--ms-yellow-border); }
.cust-chip.current {
  background: #4b4051; border-color: #4b4051; color: #fff;
  box-shadow: 0 5px 14px rgba(48, 35, 52, 0.2);
  pointer-events: none;
}
html[data-theme="dark"] .cust-chip.current { background: #07182c; border-color: #495770; }
.cust-chip.current .muted { color: #ccc; }
.cust-chip-more { justify-content: center; font-weight: 700; color: var(--ms-link); }
.cust-chip-past {
  justify-content: center; text-align: center; line-height: 1.1;
  background: var(--ms-grey-bg); border-color: var(--ms-grey-border);
  min-width: 52px; font-size: 10px;
}
.cust-chip-past strong { font-size: 13px; }
.cust-chip-past:hover { background: var(--surface); }

.bookings-tabs { margin: 0 .5rem; }
.bookings-tab { opacity: .65; }
.bookings-tab.selected {
  opacity: 1; background: var(--ms-blue-bg); border-color: var(--ms-blue-border);
  color: var(--ms-blue-text); font-weight: 700;
}
tr.row-dead td { background: var(--ms-red-lt-bg); }
tr.row-dead.row-open:hover td { background: var(--ms-red-bg); }

.card-slim { flex: 0 1 260px; }
.card-slim p.muted { font-size: 11px; margin: .4rem 0 0; }

.customer-edit { max-width: 1100px; }
.customer-edit-cols { display: flex; gap: 2rem; flex-wrap: wrap; }
.customer-edit-cols > div { flex: 1 1 380px; }
.customer-edit h4 { margin: .8rem 0 .3rem; font-size: 13px; }
.customer-edit h4:first-child { margin-top: 0; }
.customer-edit .edit-form { background: var(--surface); }

.cust-notes {
  margin: 0 0 1rem; padding: .4rem .75rem; border-radius: var(--radius-md);
  background: var(--ms-yellow-lt-bg); border: 1px solid var(--ms-yellow-border);
}
.cust-notes-empty { padding: .2rem .75rem; background: transparent; border-color: var(--border); }
.cust-notes-head { font-size: 13px; display: inline-flex; align-items: center; gap: .4rem; }
.cust-notes table { margin-top: .35rem; background: var(--surface); }

/* ── Bookings dossier cards ─────────────────────────────────────────────── */

.bookings-sort { font-size: 12px; color: var(--text-muted); margin-left: .75rem; font-weight: normal; }
#bk_search { margin-left: .5rem; font-size: 12px; padding: 2px 6px; }

.bk-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .8rem; margin-top: .5rem;
}
.bk-card {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .6rem .75rem; border-radius: var(--radius-md); text-decoration: none;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.bk-card:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.bk-card.this { background: var(--ms-yellow-lt-bg); border-color: var(--ms-yellow-border); }
.bk-card.dead { background: var(--ms-red-lt-bg); border-color: var(--ms-red-border); }
.bk-card-top { display: flex; align-items: center; gap: .4rem; }
.bk-card-top strong { font-size: 14px; color: var(--text-strong); }
.bk-chan { font-size: 13px; }
.bk-paid { margin-left: auto; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.bk-card-title {
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bk-card-event { font-size: 13px; font-weight: 650; }
.bk-card-booked { font-size: 11px; }
.bk-card-kinds { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .15rem; }
.bk-kind {
  font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--ms-turq-bg); border: 1px solid var(--ms-turq-border);
  color: var(--ms-turq-text); white-space: nowrap;
}
.bk-kind-type { background: var(--ms-blue-bg); border-color: var(--ms-blue-border); color: var(--ms-blue-text); }
.chip-yellow-soft {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 0 7px; border-radius: 999px;
  background: var(--ms-yellow-bg); border: 1px solid var(--ms-yellow-border);
  color: var(--ms-yellow-text); vertical-align: 1px;
}
.bk-more { margin-top: .6rem; display: flex; gap: .75rem; align-items: center; }

/* ── Data cards (CS combined views): a row of a table, as a card ────────── */

.dc-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: .8rem; margin-top: .5rem;
}
.dc-card {
  display: flex; flex-direction: column; gap: .25rem;
  padding: .6rem .75rem; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.dc-card:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.dc-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.dc-top strong { font-size: 13px; color: var(--text-strong); }
.dc-num { font-weight: 700; }
.dc-actions { margin-left: auto; display: inline-flex; gap: .35rem; align-items: center; }
.dc-actions a { text-decoration: none; }
.dc-line { display: block; }
.dc-line .mini-select { font-size: 11px; }
.dc-session { padding-left: .25rem; }
.dc-checkin { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.dc-checkin input, .checkbox input { accent-color: var(--brand-600); }

/* ── Messages (Freshdesk) ───────────────────────────────────────────────── */

#fd_panel .dc-cards { grid-template-columns: 1fr; } /* tickets stack full width */
.fd-ticket .fd-thread { margin-top: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.fd-msg-in  { border-left: 3px solid var(--ms-blue-border); }
.fd-msg-out { border-left: 3px solid var(--ms-green-border); }
.fd-msg-note { background: var(--ms-yellow-lt-bg); border-left: 3px solid var(--ms-yellow-border); }
.fd-expand { font-size: 12px; font-weight: 600; text-decoration: none; }
.fd-ticket.fd-this { background: var(--ms-yellow-lt-bg); border-color: var(--ms-yellow-border); }
.fd-booking-chip { margin-left: 0; }
.fd-unlink { text-decoration: none; font-size: 10px; }
.fd-attach { margin-left: .75rem; }
.fd-attach-select { max-width: 220px; }

/* ── Focus state (CS): booking card floats to the top, panes below ──────── */

.focus-card {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .65rem .9rem; margin-bottom: 1rem; border-radius: var(--radius-md);
  background: linear-gradient(90deg, #fffdf5, #fffaf0);
  border: 1px solid var(--ms-yellow-border);
  box-shadow: var(--shadow-sm);
}
html[data-theme="dark"] .focus-card {
  background: linear-gradient(90deg, rgba(17, 31, 50, 0.98), rgba(17, 31, 50, 0.82));
}
.focus-card-info { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-width: 0; }
.focus-card-info .bk-paid { margin-left: 0; font-size: 16px; }
.focus-card-info .bk-card-kinds { margin-top: 0; }
.focus-card-event { font-size: 15px; }
.focus-card-event strong { font-weight: 750; color: var(--text-strong); }
.focus-card-panes { display: flex; align-items: center; gap: .4rem; margin-left: auto; }
.focus-card-panes .btn-mini { font-size: 12px; padding: 5px 10px; }
.focus-card-panes .btn-mini.selected {
  color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
}
.focus-card-close {
  margin-left: .5rem; padding: .25rem .6rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: 14px;
  border: 1px solid var(--border-strong); background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}
.focus-card-close:hover { transform: translateY(-1px); border-color: var(--ms-red-border); background: var(--ms-red-lt-bg); }

.focus-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.focus-panes.cols-1 { grid-template-columns: 1fr; }
.focus-pane { min-width: 0; }
.focus-pane .panel { overflow-x: auto; }
@media (max-width: 1100px) { .focus-panes { grid-template-columns: 1fr; } }

.voucher-journey a { font-weight: bold; }

/* voucher families: a course parent card with its child vouchers folded in */
.voucher-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px; letter-spacing: .02em; color: var(--text-muted);
}
/* a course family takes the full grid width — its children need room to
   read as rows, not be squeezed into one narrow card column */
.dc-card.voucher-family { border-left: 4px solid var(--ms-blue-border); grid-column: 1 / -1; }
.voucher-kids { margin: .35rem 0 .1rem; }
.voucher-kids > summary {
  cursor: pointer; font-size: 12.5px; font-weight: 650; color: var(--ms-blue-text);
  padding: .2rem 0; user-select: none;
}
.voucher-kids[open] > summary { margin-bottom: .3rem; }
.vk-row {
  display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap;
  padding: .28rem .5rem; margin-bottom: .2rem; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.vk-row.vk-used { background: var(--surface-soft); }
.vk-title { font-weight: 650; color: var(--text-strong); }
.vk-state { margin-left: auto; display: inline-flex; align-items: baseline; gap: .35rem; }
.vk-pdf { text-decoration: none; }
.voucher-journey .muted div { margin-top: .1rem; }
.fin-actions { display: flex; gap: 1.25rem; font-size: 12px; }
.fin-actions a { color: var(--ms-link); text-decoration: none; font-weight: 600; }
.fin-actions a:hover { text-decoration: underline; }

/* ── Standard page (search etc.) ────────────────────────────────────────── */

.page { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.page-header { display: flex; justify-content: space-between; align-items: baseline; }
.page-user { font-size: 13px; }

.search { display: flex; gap: .5rem; margin: 1rem 0 1.5rem; }
.search input {
  flex: 1; padding: .5rem .75rem; font-size: 15px;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: var(--radius-sm); color: var(--text);
  outline: none; transition: border-color 140ms ease, box-shadow 140ms ease;
}
.search input:focus { border-color: var(--brand-400); box-shadow: var(--focus-ring); }
.search button {
  padding: .5rem 1.25rem; border: 1px solid var(--brand-700);
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  border-radius: var(--radius-sm); cursor: pointer;
  color: #fff; font-size: 14px; font-weight: 650;
  box-shadow: var(--shadow-sm);
}
.search button:hover { filter: brightness(1.08); }
.search-reset {
  display: inline-flex; align-items: center; padding: .5rem 1rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted);
  font-size: 14px; text-decoration: none;
}
.search-reset:hover { border-color: var(--ms-red-border); color: var(--ms-red-text); background: var(--ms-red-lt-bg); }

.search-filters { margin: -0.75rem 0 1.25rem; font-size: 13px; }
.search-filters summary {
  cursor: pointer; color: var(--text-muted); font-weight: 650; width: fit-content;
}
.sf-groups {
  display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: .6rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: .75rem 1rem;
}
.sf-groups fieldset { border: 0; margin: 0; padding: 0; min-width: 130px; }
.sf-groups legend {
  font-weight: 700; color: var(--text-strong); padding: 0; margin-bottom: .3rem;
}
.sf-groups label { display: block; padding: 1px 0; cursor: pointer; }
.sf-groups input { accent-color: var(--brand-600); margin-right: .35rem; }

table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; padding: .4rem .6rem; background: var(--surface-soft);
  border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted);
}
table.data td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
table.data tr.row-open { cursor: pointer; }
table.data tr.row-open:hover { background: var(--surface-hover); }
table.data td.empty { text-align: center; color: var(--text-faint); padding: 2rem; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .bw-header, .bw-tabs, .cust-strip { padding-left: .75rem; padding-right: .75rem; }

  /* long org names: the pill wraps instead of forcing sideways scroll,
     and the M-number drops onto its own line inside the pill */
  .bw-line1 { min-width: 0; max-width: 100%; }
  .cust-strip-who {
    white-space: normal; flex-wrap: wrap; max-width: 100%;
    overflow-wrap: anywhere; border-radius: var(--radius-md);
  }
  .cust-strip-who .m-number { flex-basis: 100%; align-self: flex-start; width: fit-content; margin-left: 0; }

  /* Actions tab: the Yes/No/N/A radios stack vertically (one per line) so
     the control column stops fighting the label for width */
  .actions td label { display: block; white-space: nowrap; margin: 0 0 .15rem; }
  .actions td.action-set-by { font-size: 11px; }

  /* tabs live behind a burger on mobile */
  .bw-tabs { padding-bottom: .4rem; }
  .bw-burger {
    display: flex; align-items: center; gap: .55rem; width: 100%;
    padding: .5rem .8rem; cursor: pointer;
    background: var(--theme-lt); border: 1px solid var(--theme-border);
    border-radius: var(--radius-sm); color: var(--text-strong);
    font-weight: 650; text-align: left;
  }
  .bw-burger-icon { font-size: 15px; line-height: 1; }
  .bw-tabs .bw-tab { display: none; }
  .bw-tabs.open .bw-tab {
    display: block; width: 100%; margin-top: 2px;
    border: 1px solid var(--theme-border); border-radius: var(--radius-sm);
  }
  .bw-tabs.open .bw-burger { margin-bottom: .3rem; }

  /* sub-tabs collapse the same way, showing the current sub */
  .bw-subtabs { flex-direction: column; }
  .bw-subtabs .bw-subtab { display: none; }
  .bw-subtabs.open .bw-subtab {
    display: block; width: 100%; margin-top: 2px; padding: .4rem .8rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .bw-subburger {
    background: var(--surface); border-color: var(--border-strong);
    color: var(--text); font-weight: 600;
  }
  .bw-header { align-items: flex-start; }
  .bw-tools { min-height: 34px; }
  .bw-body { padding: .75rem; }
  fieldset.panel, fieldset.card { padding: .7rem .8rem; }
  .card dl { grid-template-columns: 110px minmax(0, 1fr); }
  dl.detail-list { grid-template-columns: 120px minmax(0, 1fr); }

  /* wide content scrolls inside its container, never the page */
  fieldset.panel { overflow-x: auto; }
  .bw-body table.data { display: block; overflow-x: auto; }

  /* Bookings panel toolbar: filters / sort / search flow onto their own rows */
  .panel h2 { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
  .bookings-tabs { margin: 0; }
  .bookings-sort { margin-left: 0; }
  #bk_search { margin-left: 0; flex: 1 1 160px; min-width: 0; }

  /* focus title panel: info on top, pane buttons + close on their own row */
  .focus-card { gap: .5rem; padding: .55rem .7rem; }
  .focus-card-panes { margin-left: 0; width: 100%; }
  .focus-card-panes .focus-card-close { margin-left: auto; }

  .customer-edit-cols { gap: 1rem; }
}

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--page-bg); }
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 2rem; width: 320px; box-shadow: var(--shadow-md);
}
.login-box label { display: block; margin: .75rem 0; font-size: 13px; }
.login-box input {
  width: 100%; padding: .5rem; margin-top: .25rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px;
  background: var(--surface); color: var(--text);
}
.login-box button {
  width: 100%; margin-top: 1rem; padding: .6rem;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  border: 1px solid var(--brand-700);
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 650;
  cursor: pointer; color: #fff;
}
.login-error {
  background: var(--ms-red-lt-bg); border: 1px solid var(--ms-red-border);
  color: var(--ms-red-text);
  padding: .5rem .75rem; border-radius: var(--radius-sm); margin-bottom: .5rem; font-size: 13px;
}
