/* ═══════════════════════════════════════════════════════════════════════
   Earthly VMS — CMS shared components
   Adds primitives missing from itinerary_builder.css so every dashboard
   page can be built with the same design tokens.

   Tokens come from itinerary_builder.css `:root`:
     --gray-50..900, --blue-50..700, --green-*, --red-*, --amber-*
     --cms-radius (0.5), --cms-radius-lg (0.75), --cms-radius-xl (1rem)
     --cms-shadow-sm, --cms-shadow, --cms-shadow-md, --cms-ease

   Hard rules: Inter only, blue-600 primary, radii 8/12/16/9999 only.
   ═══════════════════════════════════════════════════════════════════════ */

/* Reduced motion — respect OS preference. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Skip-to-main-content link for keyboard users. */
.cms-skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  z-index: 2000;
  padding: 0.55rem 0.95rem;
  background: var(--blue-600);
  color: #fff;
  border-radius: var(--cms-radius);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 160ms var(--cms-ease);
}
.cms-skip-link:focus,
.cms-skip-link:focus-visible { top: 8px; outline: none; }

/* Focus-visible — every chrome control gets a visible focus ring. */
.cms-btn:focus-visible,
.cms-iconbtn:focus-visible,
.cms-modal__close:focus-visible,
.cms-topbar__burger:focus-visible,
.cms-mobilebar__burger:focus-visible,
.cms-side__collapse:focus-visible,
.cms-topbar__more-btn:focus-visible,
.cms-toast__close:focus-visible,
.cms-side__nav a:focus-visible,
.cms-side__nav button:focus-visible,
.cms-topbar__link:focus-visible,
.cms-tabs__tab:focus-visible,
.cms-segmented__btn:focus-visible,
.cms-dropdown__item:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: var(--cms-radius);
}

/* ── Surface card (generic content card) ─────────────────────────── */
.cms-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-xl);
  padding: 1.25rem;
  box-shadow: var(--cms-shadow);
  transition: box-shadow 200ms var(--cms-ease);
}
@media (min-width: 640px) { .cms-card { padding: 1.5rem; } }
.cms-card + .cms-card { margin-top: 1rem; }
.cms-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: -0.25rem 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}
.cms-card__title { font-size: 1.0625rem; font-weight: 700; color: var(--gray-900); margin: 0; line-height: 1.3; letter-spacing: -0.01em; }
.cms-card__sub { font-size: 0.8125rem; color: var(--gray-500); margin: 4px 0 0; }
/* phones: title + subtitle side by side collide once either wraps —
   stack them instead of letting the row layout overlap the texts */
@media (max-width: 640px) {
  .cms-card__head { flex-direction: column; align-items: stretch; gap: 0.25rem; }
}
.cms-card__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ── Form section (port of itinerary-form-section under generic name) — */
.cms-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-xl);
  padding: 1.25rem;
  box-shadow: var(--cms-shadow);
  transition: box-shadow 200ms var(--cms-ease);
}
@media (min-width: 640px) { .cms-section { padding: 1.75rem; } }
@media (min-width: 1024px) { .cms-section { padding: 2rem; } }
.cms-section + .cms-section { margin-top: 1.25rem; }
.cms-section:hover { box-shadow: var(--cms-shadow-md); }

.cms-section__title {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--gray-900);
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--blue-600);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
@media (min-width: 640px) { .cms-section__title { font-size: 1.25rem; } }
.cms-section__sub { font-size: 0.8125rem; color: var(--gray-500); margin: -0.5rem 0 1.25rem; }

/* ── Form fields ──────────────────────────────────────────────────── */
.cms-fieldgroup { display: flex; flex-direction: column; gap: 0.4rem; }
.cms-fieldgroup + .cms-fieldgroup { margin-top: 1rem; }

.cms-label {
  display: block;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--gray-700);
  letter-spacing: 0.005em;
  margin: 0;
}
.cms-label__required { color: var(--red-500); margin-left: 3px; }

.cms-input,
.cms-textarea,
.cms-select {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--cms-radius);
  box-shadow: var(--cms-shadow-sm);
  transition: border-color 160ms var(--cms-ease), box-shadow 160ms var(--cms-ease);
  appearance: none;
}
.cms-input:focus,
.cms-textarea:focus,
.cms-select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-50);
}
.cms-input::placeholder,
.cms-textarea::placeholder { color: var(--gray-400); }
.cms-textarea { min-height: 110px; resize: vertical; }

.cms-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='1.8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.65rem center;
  background-repeat: no-repeat;
  background-size: 18px;
  padding-right: 2.25rem;
  cursor: pointer;
}

.cms-checkbox,
.cms-radio { accent-color: var(--blue-600); width: 1rem; height: 1rem; cursor: pointer; }
.cms-check-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--gray-700); }

.cms-hint { font-size: 0.75rem; color: var(--gray-500); margin: 0; }
.cms-error { font-size: 0.75rem; color: var(--red-600); margin: 0; font-weight: 500; }

/* invalid border on inputs whose surrounding fieldgroup is .has-error */
.cms-fieldgroup.has-error .cms-input,
.cms-fieldgroup.has-error .cms-textarea,
.cms-fieldgroup.has-error .cms-select { border-color: var(--red-500); box-shadow: 0 0 0 3px var(--red-50); }

/* ── Layout helpers ──────────────────────────────────────────────── */
.cms-stack { display: flex; flex-direction: column; gap: 1rem; }
.cms-stack--lg { gap: 1.5rem; }
.cms-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.cms-row--between { justify-content: space-between; }
.cms-row--end { justify-content: flex-end; }
.cms-row--lg { gap: 1rem; }

.cms-grid-2,
.cms-grid-3,
.cms-grid-4 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .cms-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cms-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cms-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .cms-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cms-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.cms-grid__full { grid-column: 1 / -1; }

/* ── Sticky save bar (port of itinerary-sticky-actions) ─────────── */
.cms-sticky-actions {
  position: sticky;
  bottom: 1rem;
  z-index: 30;
  margin-top: 1.5rem;
}
.cms-sticky-actions__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--blue-600);
  border-radius: var(--cms-radius-xl);
  padding: 0.85rem 1rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px -8px rgba(37, 99, 235, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
}
.cms-sticky-actions__panel .cms-btn { padding: 0.65rem 1.4rem; font-size: 0.9375rem; }

/* ── Data table (sticky header, hoverable rows) ──────────────────── */
.cms-table-wrap {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-xl);
  overflow: hidden;
  box-shadow: var(--cms-shadow);
}
.cms-table-scroll {
  overflow-x: auto;
  max-width: 100%;
  max-height: 70vh;
}
.cms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.cms-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--gray-50);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.cms-table thead th.is-right { text-align: right; }
.cms-table thead th.is-center { text-align: center; }
.cms-table tbody td {
  padding: 0.85rem 1rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.cms-table tbody td.is-right { text-align: right; }
.cms-table tbody td.is-center { text-align: center; }
.cms-table tbody td.is-nowrap { white-space: nowrap; }
.cms-table tbody tr:last-child td { border-bottom: none; }
.cms-table tbody tr { transition: background 160ms; }
.cms-table tbody tr:hover { background: var(--gray-50); }
.cms-table .cms-table__primary { font-weight: 600; color: var(--gray-900); max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cms-table .cms-table__sub { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cms-table .cms-table__empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--gray-500);
  font-size: 0.875rem;
}
.cms-table .cms-table__empty a:not(.cms-btn) { color: var(--blue-600); font-weight: 500; }
.cms-table .cms-table__empty a:not(.cms-btn):hover { text-decoration: underline; }

/* row actions inline (small icon buttons) */
.cms-table__actions { display: inline-flex; gap: 0.25rem; }

/* ── Responsive data table → labelled cards ──────────────────────────
   Below tablet width a multi-column table can't fit the content area
   (sidebar eats ~250px on iPad), so columns crush to ~1ch and text wraps
   one letter per line. Instead, each row becomes a card and every cell
   shows its column name via `data-label` (set in cms/_data_table.html.erb).
   Card-grid list pages already reflow; this is only for `.cms-table`.
   Covers phone + iPad portrait & landscape (≤1024px); true desktop keeps
   the table. */
@media (max-width: 1024px) {
  .cms-table-wrap { overflow: visible; box-shadow: none; border: none; background: transparent; }
  .cms-table-scroll { overflow: visible; max-height: none; }
  .cms-table { min-width: 0; font-size: 0.9375rem; display: block; }
  .cms-table thead {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }
  .cms-table tbody { display: block; }
  .cms-table tbody tr {
    display: block;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--cms-radius-lg);
    box-shadow: var(--cms-shadow);
    padding: 0.35rem 0.95rem;
    margin-bottom: 0.75rem;
  }
  .cms-table tbody tr:hover { background: #fff; }
  .cms-table tbody td {
    display: flex;
    /* wrap: on narrow phones (or boosted system text) the value drops
       BELOW its label instead of crushing to one letter per line */
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.85rem;
    padding: 0.6rem 0;
    border: none;
    border-bottom: 1px solid var(--gray-100);
    text-align: left;
    min-width: 0;
  }
  .cms-table tbody td:last-child { border-bottom: none; }
  .cms-table tbody td.is-right,
  .cms-table tbody td.is-center { text-align: left; }
  .cms-table tbody td::before {
    content: attr(data-label);
    /* shrinkable with a floor — a rigid 8.5rem gutter starves the value
       column once large accessibility text inflates rem units */
    flex: 0 1 8.5rem;
    min-width: 5.5rem;
    color: var(--gray-500);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  /* the value side takes whatever the label leaves */
  .cms-table tbody td > * { flex: 1 1 8rem; }
  .cms-table tbody td > .cms-badge,
  .cms-table tbody td > .cms-hint--xs { flex: 0 0 auto; }
  /* legacy tables without data-labels: drop the empty gutter entirely
     instead of indenting every value by an invisible 5.5rem label */
  .cms-table tbody td:not([data-label])::before,
  .cms-table tbody td[data-label=""]::before { display: none; }
  /* the cell value fills the rest of the row and may shrink/ellipsise */
  .cms-table tbody td > * { min-width: 0; }
  .cms-table .cms-table__primary,
  .cms-table .cms-table__sub { max-width: 100%; }
  /* actions: drop the label, let buttons sit on their own line */
  .cms-table tbody td.cms-table__actions-cell::before { content: none; }
  .cms-table__actions { justify-content: flex-start; flex-wrap: wrap; }
  /* empty state spans the whole card, no label */
  .cms-table tbody td.cms-table__empty { display: block; text-align: center; border-bottom: none; }
  .cms-table tbody td.cms-table__empty::before { content: none; }
}

/* Tablet landscape & desktop: keep the table, but never let it crush. A floor
   width keeps columns readable; the wrapper (.cms-table-scroll, overflow-x:auto)
   scrolls horizontally — contained, not the page — when the content area is
   narrower, e.g. iPad LANDSCAPE where the sidebar leaves ~900px and the row
   would otherwise squeeze columns to one character. Below 1025px rows are cards
   (rule above), so this only governs real table mode. */
@media (min-width: 1025px) {
  /* `table.cms-table` (not bare `.cms-table`) so this beats the global
     `.cms-main * { min-width: 0 }` overflow guard, which otherwise ties on
     specificity and wins on source order — leaving the table free to crush.
     `table-layout: fixed` + per-cell ellipsis is the whole long-text fix in one
     place: EVERY cell of EVERY .cms-table (the ~30 index/history tables) clamps
     to one line, so no value — plain text or HTML — can widen a column or break
     the row. The full text is on the cell's `title` (hover), set in the partial. */
  table.cms-table { min-width: 880px; table-layout: fixed; }
  .cms-table th, .cms-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cms-table td > * { max-width: 100%; }
  /* the actions column holds buttons — never clip or ellipsise them */
  .cms-table td.cms-table__actions-cell { overflow: visible; white-space: normal; text-overflow: clip; }
}
.cms-iconbtn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--cms-radius);
  background: transparent;
  color: var(--gray-400);
  border: none;
  cursor: pointer;
  transition: all 160ms;
}
.cms-iconbtn:hover { background: var(--gray-100); color: var(--gray-700); }
.cms-iconbtn--primary:hover { color: var(--blue-600); }
.cms-iconbtn--danger:hover { background: var(--red-50); color: var(--red-600); }
.cms-iconbtn svg { width: 18px; height: 18px; }

/* ── KPI stat card (port of cms-stat + grid) ─────────────────────── */
.cms-kpi-grid {
  display: grid;
  /* 2-up at phone widths so the dashboard isn't a single tall column.
     Step up at 640px (3) and 1024px (4) for more breathing room. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) { .cms-kpi-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; } }
@media (min-width: 1024px) { .cms-kpi-grid { grid-template-columns: repeat(4, 1fr); } }

.cms-kpi {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-xl);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--cms-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: box-shadow 200ms var(--cms-ease), transform 200ms var(--cms-ease);
}
.cms-kpi:hover { box-shadow: var(--cms-shadow-md); transform: translateY(-1px); }
.cms-kpi__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.cms-kpi__value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.cms-kpi__delta { font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.2rem; }
.cms-kpi__delta--up { color: var(--green-600); }
.cms-kpi__delta--down { color: var(--red-600); }

/* ── Tabs (link-style nav tabs) ──────────────────────────────────── */
.cms-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.cms-tabs__tab {
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  white-space: nowrap;
  /* the global min-width:0 guard lets flex squeeze tabs until adjacent
     labels touch — the row must scroll, never crush */
  flex: 0 0 auto;
  transition: color 160ms, border-color 160ms;
}
.cms-tabs__tab:hover { color: var(--gray-900); }
.cms-tabs__tab.is-active { color: var(--blue-700); border-bottom-color: var(--blue-600); font-weight: 600; }

/* ── Segmented control (filter button group) ─────────────────────── */
.cms-segmented {
  display: inline-flex;
  background: var(--gray-100);
  padding: 3px;
  border-radius: var(--cms-radius);
  gap: 2px;
  /* Cap at the container and scroll surplus chips sideways (WhatsApp-style)
     instead of forcing a page-wide horizontal overflow at phone widths. */
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cms-segmented__btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-600);
  background: transparent;
  border: none;
  border-radius: var(--cms-radius);
  cursor: pointer;
  transition: all 160ms;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  /* Chips never squash or wrap mid-label — surplus scrolls (see above). */
  white-space: nowrap;
  flex-shrink: 0;
}
.cms-segmented__btn:hover { color: var(--gray-900); }
.cms-segmented__btn.is-active { background: #fff; color: var(--gray-900); box-shadow: var(--cms-shadow-sm); }

/* ── Breadcrumb ──────────────────────────────────────────────────── */
.cms-breadcrumb { font-size: 0.8125rem; color: var(--gray-500); margin-bottom: 0.75rem; }
.cms-breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0; align-items: center; }
.cms-breadcrumb a { color: var(--gray-500); text-decoration: none; transition: color 160ms; }
.cms-breadcrumb a:hover { color: var(--gray-900); }
.cms-breadcrumb li:not(:last-child)::after { content: "›"; margin-left: 0.4rem; color: var(--gray-300); }
.cms-breadcrumb li:last-child { color: var(--gray-900); font-weight: 600; }

/* ── Pagination ──────────────────────────────────────────────────── */
.cms-pagination {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  align-items: center;
  padding: 1.25rem 0 0;
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.cms-pagination a,
.cms-pagination span {
  padding: 0.45rem 0.75rem;
  border-radius: var(--cms-radius);
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
  background: #fff;
  text-decoration: none;
  font-weight: 500;
  min-width: 36px;
  text-align: center;
  transition: all 160ms;
}
.cms-pagination a:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); }
.cms-pagination .is-current,
.cms-pagination .current { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.cms-pagination .is-disabled,
.cms-pagination .disabled { color: var(--gray-300); pointer-events: none; }

/* ── Modal ───────────────────────────────────────────────────────── */
.cms-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.cms-modal.is-open { display: flex; animation: cms-fade-in 160ms var(--cms-ease); }
.cms-modal__panel {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: var(--cms-radius-xl);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: cms-slide-up 200ms var(--cms-ease);
}
.cms-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}
.cms-modal__title { font-size: 1rem; font-weight: 700; color: var(--gray-900); margin: 0; }
.cms-modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 0.25rem;
  border-radius: var(--cms-radius);
  transition: all 160ms;
}
.cms-modal__close:hover { background: var(--gray-100); color: var(--gray-700); }
.cms-modal__close svg { width: 20px; height: 20px; display: block; }
.cms-modal__body { padding: 1.25rem; color: var(--gray-700); font-size: 0.9375rem; line-height: 1.5; }
.cms-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

@keyframes cms-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cms-slide-up { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Toast (floating notice) ────────────────────────────────────── */
.cms-toast-host {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
  pointer-events: none;
}
.cms-toast {
  pointer-events: auto;
  background: #fff;
  border-radius: var(--cms-radius-lg);
  padding: 0.85rem 2.4rem 0.85rem 1rem;
  font-size: 0.875rem;
  color: var(--gray-800);
  box-shadow: var(--cms-shadow-md), 0 8px 24px rgba(0, 0, 0, 0.08);
  border-left: 4px solid var(--blue-600);
  position: relative;
  animation: cms-toast-in 240ms var(--cms-ease);
}
.cms-toast--ok { border-left-color: var(--green-600); }
.cms-toast--err { border-left-color: var(--red-500); }
.cms-toast__close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--cms-radius);
}
.cms-toast__close:hover { background: var(--gray-100); color: var(--gray-700); }
@keyframes cms-toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Dropdown / popover ─────────────────────────────────────────── */
.cms-dropdown { position: relative; display: inline-block; }
.cms-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-lg);
  box-shadow: var(--cms-shadow-md);
  padding: 0.35rem;
  display: none;
  animation: cms-fade-in 120ms var(--cms-ease);
}
.cms-dropdown__menu.is-open { display: block; }
.cms-dropdown__menu--left { right: auto; left: 0; }
.cms-dropdown__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-radius: var(--cms-radius);
  font-size: 0.8125rem;
  color: var(--gray-700);
  background: none;
  border: none;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.cms-dropdown__item:hover { background: var(--gray-100); color: var(--gray-900); }
.cms-dropdown__item--danger { color: var(--red-600); }
.cms-dropdown__item--danger:hover { background: var(--red-50); color: var(--red-700); }
.cms-dropdown__divider { height: 1px; background: var(--gray-100); margin: 0.35rem 0; }

/* ── Tooltip (CSS-only via data-tooltip) ────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.6rem;
  background: var(--gray-900);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms;
  z-index: 100;
  border-radius: var(--cms-radius);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after { opacity: 1; }

/* ── Skeleton loader ─────────────────────────────────────────────── */
.cms-skeleton {
  background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-200) 50%, var(--gray-100) 100%);
  background-size: 200% 100%;
  border-radius: var(--cms-radius);
  animation: cms-shimmer 1.4s linear infinite;
  display: block;
}
@keyframes cms-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Dropzone (file upload area) ────────────────────────────────── */
.cms-dropzone {
  display: block;
  border: 2px dashed var(--gray-300);
  border-radius: var(--cms-radius-xl);
  padding: 1.5rem;
  background: var(--gray-50);
  text-align: center;
  color: var(--gray-500);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 160ms var(--cms-ease);
}
.cms-dropzone:hover,
.cms-dropzone.is-dragover { border-color: var(--blue-500); background: var(--blue-50); color: var(--blue-700); }
.cms-dropzone input[type="file"] { display: none; }
.cms-dropzone__icon { width: 32px; height: 32px; margin: 0 auto 0.5rem; color: var(--gray-400); }
.cms-dropzone__main { font-weight: 600; color: var(--gray-700); }
.cms-dropzone__sub { font-size: 0.75rem; color: var(--gray-500); margin-top: 4px; }

/* ── Badge variants missing from itinerary_builder.css ─────────── */
.cms-badge--red { background: var(--red-50); color: var(--red-600); }
.cms-badge--yellow { background: var(--amber-50); color: var(--amber-700); }

/* ── Detail/show pairs (label-value rows) ──────────────────────── */
.cms-deflist { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
@media (min-width: 640px) { .cms-deflist { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cms-deflist__row { display: flex; flex-direction: column; gap: 4px; }
.cms-deflist__label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-500); }
.cms-deflist__value { font-size: 0.9375rem; color: var(--gray-900); font-weight: 500; word-break: break-word; }
.cms-deflist__value--muted { color: var(--gray-500); font-weight: 400; font-style: italic; }

/* ── Auth/login surfaces (Devise + simple settings cards) ─────── */
.cms-auth-card {
  max-width: 460px;
  margin: 2rem auto;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-xl);
  padding: 2rem;
  box-shadow: var(--cms-shadow-md);
}
.cms-auth-card h1 { font-size: 1.5rem; font-weight: 800; color: var(--gray-900); margin: 0 0 0.5rem; letter-spacing: -0.01em; }
.cms-auth-card p.lead { font-size: 0.875rem; color: var(--gray-500); margin: 0 0 1.5rem; }

/* ── Public-facing notice variants used outside itinerary view ── */
.cms-notice--info { background: var(--blue-50); color: var(--blue-700); }
.cms-notice--warn { background: var(--amber-50); color: var(--amber-700); }

/* ═══════════════════════════════════════════════════════════════════════
   OVERRIDES — production polish that supersedes itinerary_builder.css
   ═══════════════════════════════════════════════════════════════════════ */

/* Screen padding-bottom must clear sticky save bar */
.cms-screen { padding-bottom: 7rem; }
@media (min-width: 640px)  { .cms-screen { padding-bottom: 7rem; } }
@media (min-width: 1024px) { .cms-screen { padding-bottom: 7rem; } }

/* Filter bar — production layout: search row + field grid + actions row */
.cms-filterbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-xl);
  box-shadow: var(--cms-shadow-sm);
  margin-bottom: 1.5rem;
  align-items: stretch;
}
@media (min-width: 768px) {
  .cms-filterbar { padding: 1.1rem 1.25rem; gap: 1rem; }
}

.cms-filterbar__search {
  position: relative;
  display: flex;
  align-items: center;
}
.cms-filterbar__search svg {
  position: absolute;
  left: 0.95rem;
  width: 16px;
  height: 16px;
  color: var(--gray-400);
  pointer-events: none;
}
.cms-filterbar .cms-filterbar__search input,
.cms-filterbar__search input {
  flex: 1;
  width: 100%;
  padding: 0.625rem 0.95rem 0.625rem 2.6rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: var(--gray-50);
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
}
.cms-filterbar__search input::placeholder { color: var(--gray-500); }
.cms-filterbar__search input:focus {
  outline: none;
  border-color: var(--blue-500);
  background: #fff;
  box-shadow: 0 0 0 3px var(--blue-50);
}

.cms-filterbar__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 0.85rem;
}
@media (min-width: 768px)  { .cms-filterbar__fields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .cms-filterbar__fields { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1440px) { .cms-filterbar__fields { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.cms-filterbar__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.cms-filterbar__field label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-500);
}

/* Selects / inputs INSIDE the filter bar — full width within their grid cell */
.cms-filterbar select,
.cms-filterbar input[type="text"],
.cms-filterbar input[type="search"],
.cms-filterbar input[type="date"],
.cms-filterbar input[type="datetime-local"],
.cms-filterbar input[type="number"],
.cms-filterbar input[type="email"] {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius);
  background: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--gray-900);
  cursor: pointer;
  box-shadow: var(--cms-shadow-sm);
  transition: border-color 160ms, box-shadow 160ms;
}
.cms-filterbar input[type="date"] { font-family: inherit; min-height: 38px; }
.cms-filterbar select:focus,
.cms-filterbar input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-50);
}
.cms-filterbar select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='1.8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.6rem center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 2rem;
  appearance: none;
}

.cms-filterbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.cms-filterbar__count {
  margin-right: auto;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* Sticky actions — give content above breathing room */
.cms-sticky-actions {
  position: sticky;
  bottom: 1rem;
  z-index: 30;
  margin-top: 2rem;
  padding-top: 0.25rem;
  pointer-events: none;
}
.cms-sticky-actions__panel { pointer-events: auto; }

/* Tables — give body extra wrap on narrow viewports */
.cms-table-scroll { max-height: none; }
.cms-table thead th { position: sticky; top: 0; background: var(--gray-50); }

/* Definition list — single column on narrow screens, force 2 col on wide */
@media (min-width: 1024px) { .cms-deflist { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Card grid — tighten gaps on mobile */
@media (max-width: 639px) {
  .cms-cardgrid { gap: 0.85rem; }
  .cms-screen   { padding-left: 1rem; padding-right: 1rem; }
}

/* Page head — keep H1 truly aligned at small sizes */
.cms-pagehead h1 { overflow-wrap: anywhere; }

/* Form section — tighter mobile padding */
@media (max-width: 639px) {
  .cms-section { padding: 1.1rem; }
}

/* Inputs/textareas/selects rendered standalone (no wrapper) inside cms-section
   inherit the same look as .cms-input — guarantees forms always feel consistent */
.cms-section input[type="text"]:not(.cms-input):not([class*="ss-"]):not(.trix-input),
.cms-section input[type="email"]:not(.cms-input),
.cms-section input[type="tel"]:not(.cms-input),
.cms-section input[type="url"]:not(.cms-input),
.cms-section input[type="number"]:not(.cms-input),
.cms-section input[type="password"]:not(.cms-input),
.cms-section input[type="date"]:not(.cms-input),
.cms-section input[type="datetime-local"]:not(.cms-input),
.cms-section input[type="search"]:not(.cms-input),
.cms-section textarea:not(.cms-textarea):not(.trix-input):not(.ss-search-input),
.cms-section select:not(.cms-select):not(.cms-input) {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--cms-radius);
  box-shadow: var(--cms-shadow-sm);
  transition: border-color 160ms, box-shadow 160ms;
}
.cms-section input:focus, .cms-section textarea:focus, .cms-section select:focus {
  outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-50);
}

/* Trix toolbar inside form section */
.cms-section trix-toolbar { border: 1px solid var(--gray-200); border-radius: var(--cms-radius) var(--cms-radius) 0 0; padding: 0.4rem; background: var(--gray-50); }
.cms-section trix-editor   { border: 1px solid var(--gray-200); border-top: 0; border-radius: 0 0 var(--cms-radius) var(--cms-radius); padding: 0.85rem 1rem; min-height: 160px; font-family: inherit; font-size: 0.9375rem; color: var(--gray-900); background: #fff; }

/* SlimSelect inside CMS form sections — align to cms-input style */
.cms-section .ss-main,
.cms-filterbar .ss-main { min-height: 40px; border-radius: var(--cms-radius) !important; padding: 0.35rem 0.75rem !important; box-shadow: var(--cms-shadow-sm) !important; border: 1px solid var(--gray-300) !important; }

/* Hide turbo-frame placeholders */
turbo-frame:empty { display: block; }

/* Empty state polish */
.cms-empty { padding: 3rem 1.25rem; }

/* Layout-toggle button in topbar should never wrap */
.cms-layout-toggle { white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE — slide-out drawer + PWA + touch-friendly sizing
   ═══════════════════════════════════════════════════════════════════════ */

.cms-mobilebar { display: none; }
.cms-shell__backdrop { display: none; }

@media (max-width: 900px) {
  .cms-mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: max(0.55rem, env(safe-area-inset-top)) 0.85rem 0.55rem;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 70;
    min-height: calc(56px + env(safe-area-inset-top, 0px));
  }
  .cms-mobilebar__burger {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border-radius: var(--cms-radius); background: transparent; border: none;
    color: var(--gray-700); cursor: pointer;
  }
  .cms-mobilebar__burger:active { background: var(--gray-100); }
  .cms-mobilebar__burger svg { width: 22px; height: 22px; }
  .cms-mobilebar__brand { display: inline-flex; align-items: center; flex: 1; justify-content: center; }
  .cms-mobilebar__brand img { height: 28px; width: auto; }
  .cms-mobilebar__avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--blue-50); color: var(--blue-700);
    display: grid; place-items: center;
    font-weight: 700; font-size: 0.875rem; overflow: hidden;
  }
  .cms-mobilebar__avatar img { width: 100%; height: 100%; object-fit: cover; }

  /* Shell single column on mobile */
  .cms-shell { grid-template-columns: 1fr !important; display: grid !important; grid-template-rows: auto 1fr; }
  .cms-shell.is-collapsed { grid-template-columns: 1fr !important; }

  /* Sidebar -> slide-out drawer */
  .cms-side {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 85vw;
    height: 100vh !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 20px 14px 16px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    border-right: 1px solid var(--gray-200) !important;
    border-bottom: none !important;
    transform: translateX(-100%);
    transition: transform 240ms var(--cms-ease);
    z-index: 95;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    gap: 0 !important;
  }
  .cms-shell.is-drawer-open .cms-side { transform: translateX(0); }

  .cms-shell__backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(2px);
    z-index: 90; opacity: 0; pointer-events: none;
    transition: opacity 200ms var(--cms-ease);
  }
  .cms-shell.is-drawer-open .cms-shell__backdrop { opacity: 1; pointer-events: auto; }
  .cms-shell.is-drawer-open { overflow: hidden; }

  /* Restore vertical nav in drawer */
  .cms-side__scroll { flex: 1; overflow-y: auto; }
  .cms-side__group { display: block !important; margin-bottom: 14px !important; }
  .cms-side__group h6 { display: block !important; }
  .cms-side__nav { flex-direction: column !important; gap: 2px !important; }
  .cms-side__nav svg { display: inline-block !important; width: 18px !important; height: 18px !important; }
  .cms-side__nav a, .cms-side__nav button { padding: 12px 14px !important; font-size: 15px !important; }
  .cms-side__brand { display: flex !important; padding: 8px 0 18px !important; }
  .cms-side__brand img { height: 36px; width: auto; }
  .cms-side__footer { display: block !important; }
  .cms-side__user { display: flex; }
  .cms-side__collapse { display: none !important; }
  .cms-side__layouttoggle { display: block !important; }

  .cms-main { width: 100%; min-width: 0; }

  /* Tighten page padding */
  .cms-screen { padding: 1rem 1rem 6rem !important; }
  .cms-pagehead h1 { font-size: 1.5rem; }
  .cms-pagehead { flex-direction: column !important; align-items: stretch !important; }
  .cms-pagehead__actions { width: 100%; }
  .cms-pagehead__actions .cms-btn { flex: 1 1 auto; }

  /* Touch-friendly — WCAG 2.5.5 recommends 44×44 minimum. */
  .cms-btn { min-height: 44px; padding: 0.65rem 1rem; }
  .cms-iconbtn { width: 44px; height: 44px; }
  .cms-segmented__btn { min-height: 44px; }
  .cms-input, .cms-select, .cms-textarea { min-height: 44px; font-size: 16px; }
  .cms-filterbar select, .cms-filterbar input { font-size: 16px !important; min-height: 44px; }
  .cms-filterbar input[type="date"] { min-height: 44px; }
  .cms-table thead th { font-size: 0.625rem; padding: 0.6rem 0.65rem; }
  .cms-table tbody td { padding: 0.75rem 0.65rem; font-size: 0.875rem; }
  .cms-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .cms-card, .cms-section { padding: 1rem !important; }
  .cms-section__title { font-size: 1.05rem; }

  .cms-sticky-actions { bottom: env(safe-area-inset-bottom, 0); }
  .cms-sticky-actions__panel { padding: 0.75rem 0.85rem; }
  .cms-sticky-actions__panel .cms-btn { flex: 1 1 auto; padding: 0.75rem 1rem; }

  .cms-modal__panel { max-width: 92vw; max-height: 88vh; overflow-y: auto; }

  .cms-topbar { display: none; }

  /* Force max-width screens to use full width */
  .cms-screen .cms-section,
  .cms-screen .cms-sticky-actions__panel { max-width: none !important; }
}

/* Tablet portrait (iPad) — narrower sidebar */
@media (min-width: 901px) and (max-width: 1100px) {
  .cms-shell { grid-template-columns: 220px 1fr; }
}

/* Prevent horizontal overflow WITHOUT killing the sticky sidebar.
   Previously this set `overflow-x: hidden` on .cms-shell which created
   a new containing block / scroll context — that disables
   `position: sticky` on .cms-side, so the sidebar would scroll up
   with the page instead of pinning to the viewport.

   Fix: keep overflow on .cms-shell explicitly visible so sticky works,
   contain stray horizontal overflow on .cms-main (the right-hand
   sibling, NOT an ancestor of .cms-side) using `overflow-x: clip`.
   `clip` does not establish a new formatting context — sticky on
   sibling .cms-side keeps working. */
.cms-shell { max-width: 100vw; overflow: visible; }
.cms-main  { min-width: 0; max-width: 100%; overflow-x: clip; }
@media (min-width: 901px) {
  /* Belt-and-braces: ensure desktop sidebar pins regardless of any
     specificity-equal rule that might land later in the cascade. */
  .cms-side { position: sticky !important; top: 0 !important; height: 100vh !important; }
}

/* Disabled select softer */
select:disabled,
.cms-select:disabled,
.cms-filterbar select:disabled {
  background: var(--gray-100) !important;
  color: var(--gray-500) !important;
  cursor: not-allowed;
  opacity: 1;
}

/* Reusable 3-col grid for cascading location selects */
.cms-form-row-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 700px) { .cms-form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* iOS safe-area for installed PWA — scoped to CMS shell so the public
   marketing site isn't padded. */
.cms-shell { padding-bottom: env(safe-area-inset-bottom, 0); }
@supports (padding: max(0px)) {
  .cms-mobilebar { padding-left: max(0.85rem, env(safe-area-inset-left)); padding-right: max(0.85rem, env(safe-area-inset-right)); }
}

/* ─── Production polish pass ──────────────────────────────────── */

/* Add real bottom clearance so sticky save bar never covers content */
.cms-screen > form,
.cms-screen > .cms-stack,
.cms-screen > div[data-controller] { padding-bottom: 5rem; }

/* File inputs — apply consistent CMS styling instead of raw browser default */
.cms-section input[type="file"]:not([class*="ss-"]),
.cms-filterbar input[type="file"],
.cms-fieldgroup .cms-input[type="file"] {
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
  background: var(--gray-50);
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 0.85rem;
  padding: 0.45rem 0.95rem;
  border: 0;
  border-radius: var(--cms-radius);
  background: var(--blue-600);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 160ms;
}
input[type="file"]::file-selector-button:hover { background: var(--blue-700); }

/* When filter bar has no fields block, collapse vertical space */
.cms-filterbar:not(:has(.cms-filterbar__fields)) { gap: 0.65rem; }

/* Apply button shouldn't stretch full width — keep it as a proper CTA */
.cms-filterbar__actions input[type="submit"] { padding: 0.55rem 1.25rem; }
.cms-filterbar__search,
.cms-filterbar__fields,
.cms-filterbar__actions { grid-column: 1 / -1; }
.cms-filterbar > input[type="submit"] { justify-self: end; padding: 0.55rem 1.25rem; width: auto; }
.cms-filterbar > .cms-filter-clear { justify-self: end; }

/* Tables — proper empty state inside table cell */
.cms-table tbody td.cms-table__empty,
.cms-table .cms-table__empty {
  padding: 3.5rem 1rem;
  color: var(--gray-500);
  font-size: 0.9375rem;
}
.cms-table__empty a:not(.cms-btn) { color: var(--blue-600); font-weight: 600; text-decoration: none; }
.cms-table__empty a:not(.cms-btn):hover { text-decoration: underline; }

/* Smaller bottom padding on cms-pagehead when subtitle absent */
.cms-pagehead { margin-bottom: 1.25rem; }
.cms-pagehead h1 { font-size: clamp(1.5rem, 1.1rem + 1vw, 2rem); white-space: normal; }

/* Section title sub */
.cms-section__title { margin-bottom: 1.25rem; }

/* Card grid — wider gap on desktop */
@media (min-width: 1024px) {
  .cms-cardgrid { gap: 1.25rem; }
}

/* Resource card actions area — desktop only. Mobile inherits the 44×44
   touch baseline from the @media (max-width: 900px) block above. */
@media (min-width: 901px) {
  .cms-itincard .cms-iconbtn { width: 32px; height: 32px; }
}

/* Make sticky-actions panel feel grounded with subtle scroll-shadow */
.cms-sticky-actions { padding-bottom: 0; }
.cms-sticky-actions__panel {
  background: rgba(255, 255, 255, 0.98) !important;
  box-shadow: 0 12px 36px -10px rgba(15, 23, 42, 0.18), 0 4px 14px rgba(15, 23, 42, 0.06), 0 0 0 1px var(--blue-600) !important;
  border: none !important;
}

/* Form sections — comfortable reading width on big screens */
.cms-screen .cms-section { max-width: 1100px; margin-left: auto; margin-right: auto; }
.cms-screen .cms-sticky-actions__panel { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* Pagehead row alignment — let h1 column take the bulk, actions wrap */
.cms-pagehead { align-items: flex-start; gap: 1rem; }
.cms-pagehead > div:first-child { flex: 1 1 auto; min-width: 0; }
.cms-pagehead__actions { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; }

/* Cards on resource-grid get a hover lift */
.cms-itincard .cms-iconbtn:hover { background: #fff; }

/* Empty-state inside data-table-wrap when block also rendered */
.cms-table tbody tr td.cms-table__empty { background: var(--gray-50); }

/* ═══════════════════════════════════════════════════════════════════════
   Round-5 primitives — promoted from inline styles in views.
   Promoted because: (1) inline styles can't theme, (2) they bypass the
   reduced-motion contract, (3) they break the "extend, don't fork" rule.
   ═══════════════════════════════════════════════════════════════════════ */

/* Generic link inside body copy (mail_to, simple anchors) */
.cms-link { color: var(--blue-600); text-decoration: none; }
.cms-link:hover { text-decoration: underline; }

/* Resource-card slots (was inline) */
.cms-itincard__cover { aspect-ratio: 16/9; background: var(--gray-100); overflow: hidden; }
.cms-itincard__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cms-itincard__body { padding: 1.1rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.cms-itincard__title { font-size: 1.05rem; font-weight: 800; color: var(--gray-900); margin: 0; letter-spacing: -0.01em; line-height: 1.3; }
.cms-itincard__sub { font-size: 0.8125rem; color: var(--gray-500); margin: 0; }
.cms-itincard__body-clip { font-size: 0.8125rem; color: var(--gray-600); margin: 0; min-height: 2.5em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }
.cms-itincard__badges { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.cms-itincard__footer { display: flex; justify-content: flex-end; gap: 0.25rem; padding: 0.65rem 1.1rem; background: var(--gray-50); border-top: 1px solid var(--gray-100); }
.cms-itincard__meta { display: flex; gap: 0.75rem; font-size: 0.8125rem; color: var(--gray-500); margin: 0.4rem 0 0; flex-wrap: wrap; }
.cms-itincard__highlight { color: var(--blue-700); font-weight: 600; }
.cms-itincard__chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
.cms-itincard__footer-link { font-size: 0.8125rem; color: var(--blue-600); text-decoration: none; font-weight: 600; }
.cms-itincard__footer-link:hover { text-decoration: underline; }

/* Empty-state slots (was inline) */
.cms-empty__icon { color: var(--gray-400); margin-bottom: 0.75rem; }
.cms-empty__title { font-size: 1.0625rem; font-weight: 700; color: var(--gray-900); margin: 0 0 0.4rem; }
.cms-empty__body { font-size: 0.875rem; color: var(--gray-500); margin: 0 auto 1rem; max-width: 38ch; }
.cms-empty--inline { font-size: 0.875rem; color: var(--gray-500); padding: 1.5rem 0; text-align: center; }

/* Data-table empty hash branch (was inline) */
.cms-table__empty-block { padding: 1.5rem 0; }
.cms-table__empty-block h3 { font-size: 1.0625rem; font-weight: 700; color: var(--gray-900); margin: 0 0 0.4rem; }
.cms-table__empty-block p { font-size: 0.875rem; color: var(--gray-500); margin: 0 auto 1rem; max-width: 38ch; }

/* Owner cell in lead/vendor tables */
.cms-table__owner { font-weight: 500; color: var(--gray-700); }

/* Pagehead actions form / select width */
.cms-pagehead__actions form { gap: 0.5rem; }
.cms-pagehead__actions .cms-select { min-width: 10rem; }

/* Chart-card empty placeholder */
.cms-chart-empty { color: var(--gray-500); text-align: center; padding: 2.5rem 0; margin: 0; font-size: 0.875rem; }

/* Dashboard list rows (was inline on top_vendors / active_vendors) */
.cms-listrow { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--gray-100); font-size: 0.875rem; }
.cms-listrow:last-child { border-bottom: none; }
.cms-listrow__primary { font-weight: 600; color: var(--gray-900); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cms-listrow__meta { color: var(--gray-500); font-size: 0.8125rem; }
.cms-stack--tight { display: flex; flex-direction: column; gap: 0.4rem; }

/* Nested-row pattern shared across vendors/_form, hotels/_form, invoices/_form */
.cms-nested-row {
  padding: 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-lg);
  margin-bottom: 0.75rem;
  position: relative;
}
.cms-nested-row--grid-2-action {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}
.cms-nested-row--contact { margin-bottom: 1rem; }
.cms-nested-row__remove {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
}
.cms-nested-add { margin-top: 0.5rem; }
@media (max-width: 700px) {
  .cms-nested-row--grid-2-action { grid-template-columns: 1fr; }
}

/* Contact card used in vendors/_vendor */
.cms-contact-card { padding: 1rem; background: var(--gray-50); border: 1px solid var(--gray-100); border-radius: var(--cms-radius-lg); }
.cms-contact-card__name { font-weight: 700; color: var(--gray-900); margin: 0 0 0.5rem; font-size: 0.9375rem; }
.cms-contact-card__row { margin: 0.2rem 0; color: var(--gray-700); font-size: 0.875rem; }
.cms-contact-card__sep { color: var(--gray-500); font-size: 0.75rem; }

/* Service tags pill list — was inline on vendors/_vendor */
.cms-tag-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.cms-tag-list__item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.6rem 0.75rem; background: var(--gray-50); border: 1px solid var(--gray-100); border-radius: var(--cms-radius); }
.cms-tag-list__empty { color: var(--gray-500); font-style: italic; font-size: 0.75rem; }

/* Subsection title for region-hub etc. */
.cms-subsection-title { font-size: 1.25rem; font-weight: 800; color: var(--gray-900); margin: 0; }

/* Stepper used on leads/show */
.cms-stepper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  padding: 1rem 0 2rem;
  margin-bottom: 1rem;
}
.cms-stepper__rail {
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 1.5rem;
  height: 2px;
  background: var(--gray-200);
  z-index: 1;
}
.cms-stepper__step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.cms-stepper__node {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.875rem;
  background: #fff;
  color: var(--gray-400);
  border: 2px solid var(--gray-200);
}
.cms-stepper__node--completed { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.cms-stepper__node--active    { background: var(--blue-600);  color: #fff; border-color: var(--blue-600); box-shadow: 0 0 0 4px var(--blue-50); }
.cms-stepper__node--won       { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.cms-stepper__node--lost      { background: var(--red-500);   color: #fff; border-color: var(--red-500); }
.cms-stepper__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-400);
  text-align: center;
}
.cms-stepper__label--strong { color: var(--gray-900); }

/* Generic timeline used on leads/show + location_defaults */
.cms-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.cms-timeline__item {
  border-left: 2px solid var(--gray-200);
  padding-left: 1rem;
  position: relative;
}
.cms-timeline__dot {
  position: absolute;
  left: -7px;
  top: 0.3rem;
  width: 12px;
  height: 12px;
  background: var(--blue-600);
  border-radius: 9999px;
  border: 2px solid #fff;
}
.cms-timeline__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.35rem; }
.cms-timeline__primary { font-weight: 600; color: var(--gray-900); font-size: 0.875rem; }
.cms-timeline__sub { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--blue-700); }
.cms-timeline__time { font-size: 0.75rem; color: var(--gray-500); }
.cms-timeline__meta { margin-top: 0.4rem; font-size: 0.6875rem; color: var(--gray-400); }
.cms-timeline__notes {
  margin-top: 0.5rem;
  padding: 0.65rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--cms-radius);
  font-size: 0.8125rem;
  color: var(--gray-700);
}

/* Assignment history — same vertical list, simpler styling */
.cms-historylist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.cms-historylist__item { padding: 0.5rem 0; border-bottom: 1px solid var(--gray-100); font-size: 0.875rem; }
.cms-historylist__item:last-child { border-bottom: none; }
.cms-historylist__primary { color: var(--gray-700); }
.cms-historylist__strong { color: var(--gray-900); font-weight: 600; }
.cms-historylist__meta { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; }
.cms-historylist__time { font-size: 0.6875rem; color: var(--gray-400); margin-top: 2px; }

/* Day-template card (location_defaults/edit) */
.cms-day-template { /* uses .cms-card; this is just the inner layout helpers */ }
.cms-day-template__row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.cms-day-template__main { flex: 1; min-width: 0; }
.cms-day-template__title { font-size: 1rem; font-weight: 700; color: var(--gray-900); margin: 0; }
.cms-day-template__chips { display: flex; gap: 0.75rem; font-size: 0.8125rem; color: var(--gray-500); margin-top: 0.4rem; flex-wrap: wrap; }
.cms-day-template__budget { color: var(--blue-700); font-weight: 600; }
.cms-day-template__excerpt { margin-top: 0.65rem; font-size: 0.8125rem; color: var(--gray-600); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Inline-spacing helpers (kept narrow — only what views actually need) */
.cms-stacked { display: flex; flex-direction: column; gap: 1rem; }
.cms-space-top  { margin-top: 1rem; }
.cms-space-top--sm { margin-top: 0.5rem; }
.cms-space-top--md { margin-top: 0.75rem; }
.cms-space-top--lg { margin-top: 1.25rem; }

/* Notes/body copy inside a cms-card */
.cms-card__body-text { font-size: 0.9375rem; color: var(--gray-700); line-height: 1.6; margin: 0; }

/* Follow-up notice variation that needs space-between */
.cms-notice--row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cms-notice__sub { font-size: 0.75rem; opacity: 0.85; }
.cms-notice__strong { font-weight: 800; }

/* Small typographic helpers, used in invoices and elsewhere
   (replaces text-[10px] / text-[11px] / text-[12px] Tailwind arbitrary sizes) */
.cms-meta-text { font-size: 0.625rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.2em; color: var(--gray-400); margin: 0 0 4px; }
.cms-hint--xs { font-size: 0.6875rem; color: var(--gray-500); margin-top: 0.25rem; }
.cms-hint--sm { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; }

/* KPI compact sub-label (was inline) */
.cms-kpi__sub { font-size: 0.75rem; color: var(--gray-500); }

/* Grid utilities used by leads/show etc. */
.cms-grid__span-2 { grid-column: span 2; min-width: 0; }
@media (max-width: 900px) { .cms-grid__span-2 { grid-column: span 1; } }

/* Lead-comments overlay/pins host (was inline position:relative) */
.cms-comments-host { position: relative; }
.cms-comments-host__overlay { position: absolute; inset: 0; z-index: 40; }
.cms-comments-host__overlay:not(.hidden) { display: block; }
.cms-comments-host__pins { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.cms-comments-host__pins:not(.hidden) { display: block; }

/* Row split — primary actions left, terminal actions right */
.cms-row--split { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; }

/* Modal footer flush with the body of the cms-modal__panel */
.cms-modal__foot--flush { margin: 1rem -1.25rem -1.25rem; }

/* XS button for inline "+ Add" affordances inside form rows */
.cms-btn--xs { padding: 0.25rem 0.55rem; font-size: 0.75rem; }
.cms-btn--xs.cms-btn { min-height: auto; }
@media (max-width: 900px) { .cms-btn--xs.cms-btn { min-height: 36px; } }

/* Subsection title used inside a card or panel */
.cms-section__title-sm { font-size: 0.875rem; font-weight: 700; color: var(--gray-900); margin: 0 0 0.5rem; }

/* Section hint sits flush under the title (replaces inline negative margin) */
.cms-section__hint { margin: -0.5rem 0 0.85rem; color: var(--gray-500); }

/* Spaced variant of the section title (used when not inside a section header) */
.cms-section__title--spaced { margin: 1.75rem 0 0.75rem; }

/* Wrap around the "+ Add row" button after a nested-row list */
.cms-nested-add-wrap { margin-top: 0.5rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }

/* Reveal-on-check panel inside a cms-nested-row */
.cms-nested-row__panel { margin-top: 0.5rem; }
.cms-nested-row__panel.is-hidden,
.is-hidden { display: none !important; }

/* Compact card padding for collapsible/details */
.cms-card--compact { padding: 1rem 1.25rem; }
.cms-card__summary { cursor: pointer; font-size: 0.875rem; font-weight: 700; color: var(--gray-700); }
.cms-card__summary:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; border-radius: var(--cms-radius); }

/* Bottom-align checkbox alongside other fields */
.cms-check-row--bottom { align-self: end; padding-bottom: 0.65rem; }

/* Row helper: end-justified */
.cms-row--end { justify-content: flex-end; gap: 0.5rem; }

/* Primary text inside a CMS table cell */
.cms-table__primary { font-weight: 600; color: var(--gray-900); max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Invoice item nested row — supersedes inline style on _invoice_item_fields */
.cms-nested-row--invoice-item { margin-bottom: 0.85rem; position: relative; }

/* Divider between two stacked field groups inside a section */
.cms-divider { padding-top: 1rem; border-top: 1px solid var(--gray-100); }

/* Centered hint copy (CSV importer description, etc.) */
.cms-hint--centered { text-align: center; }

/* Image preview thumbnail used after file_field controls */
.cms-image-preview {
  margin-top: 0.65rem;
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: var(--cms-radius);
  border: 1px solid var(--gray-200);
}

/* Topbar right-side tool cluster (was inline) */
.cms-topbar__tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Form wrapper with zero outer chrome (used inside icon buttons) */
.cms-form--flush { margin: 0; padding: 0; }

/* Wrap an entire resource card in an <a>: kill underline + inherit color */
.cms-card-link { text-decoration: none; color: inherit; display: block; }
.cms-card-link:hover .cms-itincard { box-shadow: var(--cms-shadow-md); transform: translateY(-2px); }

/* Resource card that acts as a click target (the whole card is the action) */
.cms-itincard--clickable { cursor: pointer; transition: box-shadow 200ms var(--cms-ease), transform 200ms var(--cms-ease); }

/* Variant of the footer that justifies-between for icon trailing affordances */
.cms-itincard__footer--spaced { justify-content: space-between; align-items: center; font-size: 0.8125rem; font-weight: 600; color: var(--blue-600); }

/* Invoice card amount + invoice id (was inline) */
.cms-itincard--invoice .cms-itincard__sub { margin-bottom: 6px; }
.cms-itincard__inv-id { color: var(--gray-900); font-weight: 700; }
.cms-itincard__amount { margin: 10px 0 4px; }

/* Form-errors panel (was inline) */
.cms-form-errors { margin-bottom: 1rem; }
.cms-form-errors__list { margin: 0.35rem 0 0; padding-left: 1.25rem; }

/* Row variant: space-between with bottom margin */
.cms-row--spaced-below { margin-bottom: 1rem; }

/* Hoverable table row (was Tailwind hover:bg-gray-50) */
.cms-row-hover:hover { background: var(--gray-50); transition: background 160ms; }

/* Inline monospace cell (broadcast index column) */
.cms-mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace; color: var(--gray-500); }

/* Progress bar — campaigns + future use */
.cms-progress-wrap { margin-top: 1.5rem; }
.cms-progress__head { display: flex; justify-content: space-between; font-size: 0.875rem; margin-bottom: 0.5rem; }
.cms-progress__label { font-weight: 700; color: var(--gray-700); }
.cms-progress__count { color: var(--gray-500); }
.cms-progress {
  width: 100%;
  height: 16px;
  background: var(--gray-100);
  border-radius: 9999px;
  overflow: hidden;
}
/* Width driven by --cms-progress-pct (set inline by the view because the
   value is per-record dynamic). Single-variable inline style is the
   approved escape hatch for data-driven values — Rule 1 still holds
   because no style PROPERTIES live in the view, only a numeric value. */
.cms-progress__bar {
  height: 100%;
  width: var(--cms-progress-pct, 0%);
  background: linear-gradient(to right, var(--blue-500), var(--blue-600));
  border-radius: 9999px;
  transition: width 500ms var(--cms-ease);
}
.cms-progress__bar--complete { background: var(--green-600); }
.cms-progress__pct { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 0.625rem; font-weight: 700; color: #fff; }
.cms-progress__error { font-size: 0.75rem; color: var(--red-500); margin-top: 0.25rem; }

/* Canva sync card */
.cms-canva-card { max-width: 640px; margin-left: auto; margin-right: auto; }
.cms-canva-card__title { font-size: 1.5rem; font-weight: 800; color: var(--gray-900); margin: 0.5rem 0 0.25rem; letter-spacing: -0.01em; }
.cms-canva-card__source { color: var(--gray-500); font-size: 0.875rem; margin: 0 0 1.5rem; font-weight: 500; }
.cms-canva-card__refresh {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  padding: 0.75rem 0.95rem;
  background: var(--blue-50, #eff6ff);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--cms-radius-md, 12px);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700, #374151);
}

.cms-canva-steps { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-direction: column; gap: 0.75rem; }
.cms-canva-steps__item { display: flex; align-items: center; gap: 0.75rem; }
.cms-canva-steps__node {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-400);
}
.cms-canva-steps__node--current   { background: var(--blue-600);  color: #fff; animation: cms-pulse 1.4s ease-in-out infinite; }
.cms-canva-steps__node--completed { background: var(--green-50);  color: var(--green-600); }
.cms-canva-steps__label { font-size: 0.875rem; font-weight: 600; color: var(--gray-400); }
.cms-canva-steps__label--strong { color: var(--gray-700); }
.cms-canva-steps .cms-canva-steps__node--current ~ .cms-canva-steps__label { color: var(--gray-900); }
@keyframes cms-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Notice variant slots */
.cms-notice__heading { margin: 0 0 0.25rem; }
.cms-notice__body { font-size: 0.875rem; font-weight: 500; margin: 0; word-break: break-word; }

/* Code block (was inline-styled <pre>) */
.cms-codeblock {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--cms-radius);
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--gray-800);
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0;
}

/* Stack of message variants in the campaign show page — visible
   gap + per-variant label so the operator can tell them apart at
   a glance. */
.cms-variant-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.75rem; }
.cms-variant-list__item { display: flex; flex-direction: column; gap: 0.375rem; }
.cms-variant-list__label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

/* Inline code chip used in hints (`http://...`, `poppler-utils`, etc.) */
.cms-code-inline {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: var(--cms-radius);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  font-size: 0.8125rem;
}

/* Table-wrap variant with no chrome (used inside a cms-card) */
.cms-table-wrap--flush { border: none !important; box-shadow: none !important; }

/* Select with a hard-capped width (e.g. inline form on workers card) */
.cms-select--capped { max-width: 320px; }

/* Inline per-row form (select + Save) that lives INSIDE a data-table cell —
   e.g. the AI operators roster's pref control. LAYOUT reuses the .cms-row
   primitive (the same select+button inline form the campaigns workers card
   uses); .cms-rowform is only a behaviour HOOK for the two table-cell rules
   below, so we never duplicate the .cms-row flex declaration. */
/* A table cell clamps to one line + clips overflow on desktop (table-layout:
   fixed). A form is interactive, not text, so opt this cell out of the clamp
   the same way the actions column does — never hide a Save button. */
@media (min-width: 1025px) {
  table.cms-table td:has(.cms-rowform) { overflow: visible; white-space: normal; text-overflow: clip; }
}
/* The roster's data-table cards convert at ≤1024px (incl. iPad portrait); give
   BOTH the select (the control the operator actually taps) and Save the full
   44px touch target there, per the touch-target hard rule — not just Save. */
@media (max-width: 1024px) {
  .cms-rowform .cms-select,
  .cms-rowform .cms-btn--save { min-height: 44px; }
}

/* Row variants */
.cms-row--tight { gap: 0.65rem; }
.cms-row--top { align-items: flex-start; }
.cms-row--shrink { flex-shrink: 0; }

/* Campaign card slots */
.cms-campaign__main { flex: 1; min-width: 0; }
.cms-campaign__title { font-size: 1rem; font-weight: 700; color: var(--gray-900); text-decoration: none; }
.cms-campaign__title:hover { color: var(--blue-600); }
.cms-campaign__meta { gap: 1.25rem; margin-top: 0.4rem; font-size: 0.75rem; color: var(--gray-500); flex-wrap: wrap; }
.cms-campaign__failed { color: var(--red-600); }
.cms-campaign__account { color: var(--gray-700); font-weight: 600; }
.cms-campaign__region { color: var(--blue-600); font-weight: 600; }
/* Lazy pool-stats frame: display:contents so its spans join the flex meta row */
.cms-campaign__pool { display: contents; }
.cms-campaign__pool-loading { color: var(--gray-400); }
.cms-campaign__progress-row { margin-top: 0.35rem; font-size: 0.6875rem; color: var(--gray-400); }

/* Thin progress bar variant (campaign card) */
.cms-progress--thin { height: 8px; }

/* Canva AI tag (was inline strong) */
.cms-canva-ai-tag { margin-left: 6px; color: var(--amber-700); }

/* Strong link variant — inline brand-colored anchor in body copy */
.cms-link--strong { font-weight: 600; }

/* Bottom-spacing helper */
.cms-space-bottom { margin-bottom: 1rem; }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE-FIRST OVERFLOW GUARDS — round-7
   Every CMS surface (including .itinerary-*) must fit a 320px viewport.
   No horizontal scroll anywhere except where explicitly opted in via
   `.cms-table-scroll` or `.cms-side` (mobile chip-row).
   ═══════════════════════════════════════════════════════════════════════ */

/* Shell-level horizontal bounds.
   IMPORTANT: do NOT set `overflow-x: hidden|clip` on html, body,
   .cms-shell, or .cms-main. Any of those silently disables every
   `position: sticky` descendant (builder rail, sticky save bar, sticky
   table headers). Containment is handled instead by the per-element
   guards below (min-width: 0, max-width: 100%, word-break). */
.cms-shell, .cms-main { max-width: 100%; min-width: 0; }

/* Grid + flex children must not push their parent wider than the viewport.
   The browser default `min-width: auto` resolves to content width, which is
   what causes long URLs / long button labels to blow out a 360px column. */
.cms-shell *,
.cms-shell *::before,
.cms-shell *::after { box-sizing: border-box; }
.cms-screen *,
.itinerary-screen *,
.itinerary-builder *,
.cms-main * { min-width: 0; }

/* Long unwrappable content (URLs, slugs, words without whitespace) needs an
   explicit break point at narrow widths or it will force horizontal scroll. */
.cms-screen p,
.cms-screen td,
.cms-screen th,
.cms-screen li,
.cms-screen dd,
.cms-screen span,
.cms-screen strong,
.itinerary-form-section p,
.itinerary-form-section td,
.itinerary-form-section li { overflow-wrap: anywhere; }

/* Form controls — never exceed their parent. Tailwind base already sets
   box-sizing: border-box but custom widgets (SlimSelect, AjaxSelect) need
   the explicit max-width to behave. */
.cms-screen input,
.cms-screen select,
.cms-screen textarea,
.itinerary-form-section input,
.itinerary-form-section select,
.itinerary-form-section textarea,
.itinerary-field { max-width: 100%; }
.ss-content,
.ss-main,
.ss-single-selected,
.ss-multi-selected { max-width: 100% !important; }

/* Card / section padding — pull in on the smallest devices so the
   60px of horizontal padding doesn't eat the content area. */
@media (max-width: 480px) {
  .cms-screen { padding-left: 0.85rem !important; padding-right: 0.85rem !important; }
  .cms-card { padding: 0.9rem !important; }
  .cms-section { padding: 1rem !important; }
  .cms-pagehead h1 { font-size: 1.375rem; }
  .cms-pagehead p { font-size: 0.8125rem; }

  /* itinerary-* surface — explicit-ticket fix per CLAUDE.md.
     The base padding of 1.25rem is fine, but inputs + sticky save bar
     overflow on 360-wide devices when the wrapping section has its own
     1px border + the box-shadow halo. Tighten. */
  .itinerary-form-section { padding: 0.9rem !important; }
  .itinerary-screen,
  .itinerary-screen--form { padding-left: 0.85rem !important; padding-right: 0.85rem !important; }
  .itinerary-section-heading { font-size: 1.125rem !important; padding-bottom: 0.4rem; }

  /* Hotel / activity / transfer nested rows — stack actions vertically so
     the +Add button has its own row instead of squishing the heading. */
  .nested-row,
  .itinerary-highlight-card { padding: 0.85rem !important; }
  .nested-row__head { flex-direction: column !important; align-items: stretch !important; }
  .nested-row__head .nested-row__remove,
  .nested-row__head .itinerary-add-button { width: 100%; }

  /* Sticky panel buttons stack vertically on narrow viewports — they were
     truncating with two long labels side-by-side. */
  .itinerary-sticky-panel,
  .cms-sticky-actions__panel { padding: 0.65rem 0.75rem !important; }
  .itinerary-sticky-panel .itinerary-primary-link,
  .itinerary-sticky-panel .itinerary-outline-link,
  .cms-sticky-actions__panel .cms-btn { width: 100%; }

  /* Day cards — tighter padding and a single column for any nested grid. */
  .day-fields { padding: 0.85rem !important; }
  .nested-grid,
  .nested-grid--2,
  .nested-grid--3 { grid-template-columns: 1fr !important; gap: 0.65rem !important; }

  /* Builder rail (right sidebar) should never sit fixed-width on mobile. */
  .builder-rail { padding: 0.9rem !important; }

  /* Pagehead actions wrap onto their own row, full width. */
  .cms-pagehead { flex-direction: column !important; align-items: stretch !important; }
  .cms-pagehead__actions { width: 100%; flex-wrap: wrap; }
  .cms-pagehead__actions .cms-btn,
  .cms-pagehead__actions form { flex: 1 1 auto; min-width: 0; }
  .cms-pagehead__actions form .cms-select { width: 100%; }

  /* Deflists collapse to one column on narrow screens. */
  .cms-deflist { grid-template-columns: 1fr !important; }

  /* Stepper compresses to small nodes with a wrapping label row. */
  .cms-stepper { padding: 0.65rem 0; gap: 0.25rem; }
  .cms-stepper__node { width: 28px; height: 28px; font-size: 0.75rem; }
  .cms-stepper__label { font-size: 0.55rem; letter-spacing: 0.04em; }

  /* Modal: full-width on tiny screens (was already 92vw). Reduce padding. */
  .cms-modal { padding: 0.5rem; }
  .cms-modal__panel { max-height: 92vh; }
  .cms-modal__head,
  .cms-modal__body,
  .cms-modal__foot { padding-left: 1rem; padding-right: 1rem; }

  /* Topbar drawer items wrap. */
  .cms-topbar__drawer a { padding: 0.7rem 0.85rem; font-size: 0.875rem; }

  /* Comment overlay grid breakouts on lead show. */
  .cms-grid__span-2 { grid-column: span 1 !important; }
}

/* Tablet portrait — soften the 768px cliff so two columns don't immediately
   demand 700+ of horizontal space. */
@media (min-width: 481px) and (max-width: 767px) {
  .cms-filterbar__fields { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .nested-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* Tables: force at-least readable column widths but never trigger page-level
   horizontal scroll. .cms-table-scroll has overflow-x: auto already; this
   guards the wrapper itself. */
.cms-table-wrap { max-width: 100%; }
.cms-table { width: 100%; min-width: 0; }

/* Long button labels on mobile should not overflow row actions. */
@media (max-width: 480px) {
  .cms-row { flex-wrap: wrap; gap: 0.5rem; }
  .cms-row > * { min-width: 0; }
  .cms-btn,
  .cms-btn--secondary,
  .cms-btn--primary,
  .cms-btn--danger { max-width: 100%; white-space: normal; }
  /* But the icon-bar (data-table row actions) keeps single-line w/ icons. */
  .cms-table__actions { flex-wrap: nowrap; }
  .cms-table__actions .cms-iconbtn { flex-shrink: 0; }
}

/* Builder rail buttons (publish, share, archive…) full width on mobile so
   they don't truncate inside a 290px column. */
@media (max-width: 480px) {
  .builder-rail .cms-btn,
  .builder-rail button { width: 100%; }
}

/* Lead pipeline stepper terminal node — keep visible on mobile. */
@media (max-width: 360px) {
  .cms-stepper { justify-content: space-around; }
}

/* NOTE: do NOT add `overflow-x: clip|hidden` to .cms-main. It silently
   breaks `position: sticky` on the builder rail and any other sticky
   element inside the main content area. Horizontal containment is
   handled entirely by per-element guards above (min-width: 0,
   max-width: 100%, word-break). If a stray element overflows, fix THAT
   element — do not clip the whole shell. */

/* Itinerary builder: highlight-card headers (Hotels & Stays, Transfers,
   Activities) use `flex items-center justify-between gap-4` which squishes
   the "+ Add" pill on a 360-wide viewport. Stack vertically at <480px so
   the button gets its own row + full width. */
@media (max-width: 480px) {
  .itinerary-highlight-card > .flex.items-center.justify-between {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
  .itinerary-highlight-card > .flex.items-center.justify-between button {
    width: 100%;
    white-space: normal;
  }
}

/* File-field with Tailwind `file:mr-4 file:py-2 file:px-4 ...` overflows
   its container on 360. Constrain. */
@media (max-width: 480px) {
  input[type="file"].w-full { font-size: 0.75rem; }
  input[type="file"]::file-selector-button { padding: 0.4rem 0.75rem; font-size: 0.75rem; }
}

/* Builder rail (right-hand summary) — on mobile, drop the sticky+narrow
   constraint and let it flow naturally below the form. */
@media (max-width: 900px) {
  .builder-rail-wrap { position: static !important; width: 100% !important; max-width: 100% !important; }
}

/* Itinerary header bar buttons full width on mobile */
@media (max-width: 480px) {
  .itinerary-header-bar { gap: 0.75rem; }
  .itinerary-header-bar .itinerary-primary-link,
  .itinerary-header-bar .itinerary-outline-link,
  .itinerary-header-bar .cms-btn { width: 100%; }
}

/* Source-picker (canva imports) */
.cms-source-pick {
  cursor: pointer;
  display: block;
  padding: 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--cms-radius-lg);
  background: var(--gray-50);
  transition: all 160ms var(--cms-ease);
}
.cms-source-pick:hover { border-color: var(--blue-200); }
.cms-source-pick.is-selected {
  background: var(--blue-50);
  border-color: var(--blue-500);
}
.cms-source-pick__inner { display: flex; align-items: flex-start; gap: 0.65rem; }
.cms-source-pick__radio { margin-top: 4px; }
.cms-source-pick__label { font-weight: 700; font-size: 0.875rem; color: var(--gray-900); }
.cms-source-pick__hint { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; line-height: 1.45; }

/* Replace bare app-header-links from layouts/application.html.erb */
.app-header-links { display: flex; gap: 1rem; }
@media (max-width: 639px) {
  .app-header-links { flex-wrap: wrap; font-size: 0.875rem; }
}

/* Body font-family — moved from <style> in layouts/application.html.erb */
body, input, textarea, select, button {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

/* FOUC-prevention: pre-paint sidebar collapsed state from the synchronous
   <head> script in layouts/application.html.erb. Mirrored at runtime by
   cms_sidebar_controller.js (which toggles .is-collapsed on .cms-shell). */
html.cms-pref-collapsed .cms-shell { grid-template-columns: 80px 1fr; }
@media (max-width: 900px) {
  html.cms-pref-collapsed .cms-shell { grid-template-columns: 1fr; }
}

/* ─── Upload progress bar (direct-upload to GCS) ──────────────────────── */
.cms-upload-progress {
  margin-top: 0.85rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.03));
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--cms-radius-md, 12px);
}
.cms-upload-progress__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}
.cms-upload-progress__label {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray-900, #0f172a);
}
.cms-upload-progress__pct {
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--blue-700, #1d4ed8);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.cms-upload-progress__track {
  height: 10px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.cms-upload-progress__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue-500, #3b82f6), var(--blue-600, #2563eb));
  border-radius: 999px;
  transition: width 200ms ease;
  position: relative;
}
.cms-upload-progress__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: cms-upload-stripes 1.4s linear infinite;
}
.cms-upload-progress__fill.is-error {
  background: var(--red-500, #ef4444);
}
.cms-upload-progress__fill.is-done {
  background: linear-gradient(90deg, var(--green-500, #10b981), var(--green-600, #059669));
}
.cms-upload-progress__fill.is-done::after,
.cms-upload-progress__fill.is-error::after {
  animation: none;
  background: none;
}
.cms-upload-progress__sub {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--gray-600, #475569);
  font-weight: 500;
}
@keyframes cms-upload-stripes {
  from { background-position: 200% 0; }
  to   { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cms-upload-progress__fill::after { animation: none; }
}

/* ─── Busy submit-button state (form-busy controller) ─────────────────── */
.cms-btn.is-busy,
.cms-btn[disabled] {
  opacity: 0.75;
  cursor: progress;
  pointer-events: none;
  position: relative;
}
.cms-btn.is-busy::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.55rem;
  vertical-align: -0.15em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cms-spin 0.7s linear infinite;
}
@keyframes cms-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .cms-btn.is-busy::after { animation: none; }
}

/* ─── Live-status pulse dot (sync history, in-progress rows) ──────────── */
.cms-pulse-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--blue-500, #3b82f6);
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.65);
  animation: cms-pulse 1.4s ease-in-out infinite;
  vertical-align: middle;
}
.cms-status-live {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
@keyframes cms-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.65); }
  60%  { box-shadow: 0 0 0 0.5rem rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .cms-pulse-dot { animation: none; }
}

/* ─── Canva import live log (show page) ──────────────────────────────── */
.cms-canva-log {
  /* Sits INSIDE the parent .cms-canva-card. Hairline divider on top
     instead of a full panel border so it reads as a section of the same
     card, not a separate floating card stacked beneath. */
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--gray-200, #e5e7eb);
}
.cms-canva-log__summary {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--gray-800, #1f2937);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.cms-canva-log__list {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 12rem;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78125rem;
  line-height: 1.55;
}
.cms-canva-log__item {
  display: flex;
  gap: 0.65rem;
  padding: 0.2rem 0;
  border-bottom: 1px dashed rgba(15, 23, 42, 0.06);
}
.cms-canva-log__item:last-child { border-bottom: none; }
.cms-canva-log__item--warn  .cms-canva-log__msg { color: var(--amber-700, #b45309); }
.cms-canva-log__item--error .cms-canva-log__msg { color: var(--red-700, #b91c1c); }
.cms-canva-log__time {
  color: var(--gray-500, #6b7280);
  flex-shrink: 0;
  width: 5.5rem;
}
.cms-canva-log__msg { color: var(--gray-900, #0f172a); }

/* ---------- FullCalendar polish ----------
   The FullCalendar global build inlines its own base CSS; these rules
   tune it to the Earthly tokens + tighten mobile rendering so the week
   view doesn't wrap header text on 360px screens. */
.cms-fullcal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.cms-fullcal__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.cms-fullcal__nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cms-fullcal__label {
  font-weight: 600;
  color: var(--gray-900, #0f172a);
  font-size: .95rem;
}
.cms-fullcal__container {
  background: #fff;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}
/* Status colors driven by JSON className from Booking#calendar_event_payload. */
.fc .fc-event.is-status-confirmed   { background: #dcfce7; border-color: #16a34a; color: #14532d; }
.fc .fc-event.is-status-in_progress { background: #fef3c7; border-color: #d97706; color: #78350f; }
.fc .fc-event.is-status-completed   { background: #dbeafe; border-color: #2563eb; color: #1e3a8a; }
.fc .fc-event.is-status-cancelled   { background: #f3f4f6; border-color: #9ca3af; color: #6b7280; text-decoration: line-through; }
.fc .fc-event.is-status-draft       { background: #f9fafb; border-color: #d1d5db; color: #374151; }
/* Tighter day-of-week headers — the default truncates ugly on phones. */
.fc .fc-col-header-cell-cushion {
  font-size: .8rem;
  padding: 6px 4px;
}
/* Month grid keeps readable cell heights so an empty month still reads as a
   calendar (a grid, like Google/Apple) rather than a thin collapsed strip. */
.fc .fc-daygrid-day-frame { min-height: 84px; }
.fc .fc-daygrid-day-number { padding: 6px 8px; color: var(--gray-700, #374151); }
.fc .fc-day-today { background: var(--blue-50, #eff6ff); }

/* Touch targets — calendar toolbar controls meet the 44px WCAG minimum on
   coarse pointers (iPad / phone PWA) while staying compact on the desktop. */
@media (pointer: coarse) {
  .cms-fullcal__toolbar .cms-iconbtn { width: 44px; height: 44px; }
  .cms-fullcal__views .cms-segmented__btn { min-height: 44px; }
}

@media (max-width: 600px) {
  /* At phone widths the controller swaps Week/Day to list views; align the
     styling to the same breakpoint and let the four view buttons share the
     row as a full-width segmented control (like Apple/Google's toggle). */
  .cms-fullcal__container { padding: 6px; }
  .cms-fullcal__views { width: 100%; }
  .cms-fullcal__views .cms-segmented__btn { flex: 1 1 0; justify-content: center; }
  .fc .fc-daygrid-day-frame { min-height: 64px; }
  .fc .fc-col-header-cell-cushion { font-size: .7rem; padding: 4px 2px; white-space: nowrap; }
  .fc .fc-timegrid-slot-label-cushion { font-size: .7rem; }
  .fc .fc-list-day-cushion { padding: 8px 10px; background: var(--gray-50, #f9fafb); }
  .fc .fc-list-event td { padding: 10px; }
}

/* ---------- cms-filterbar search slot ----------
   The partial puts a <svg> + <input> inside .cms-filterbar__search. Position
   the SVG absolutely + pad the input left so the text never collides with
   the icon. Without this rule the search text overlaps the magnifier. */
.cms-filterbar__search {
  position: relative;
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  min-width: 0;
}
.cms-filterbar__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--gray-500, #6b7280);
  pointer-events: none;
}
.cms-filterbar__search input[type="search"],
.cms-filterbar__search input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: 8px;
  background: #fff;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--gray-900, #0f172a);
  -webkit-appearance: none;
  appearance: none;
}
.cms-filterbar__search input:focus {
  outline: none;
  border-color: var(--blue-500, #3b82f6);
  box-shadow: 0 0 0 3px var(--blue-50, #eff6ff);
}

/* ---------- cms-empty icon size guard ----------
   Bare SVGs inherit viewBox dimensions when no width is set. Bound them so
   they don't blow up to viewport-fill. Icon partials under cms/icons are
   pure <svg viewBox=...> with no width/height — that's by design (callers
   set context-appropriate sizing) and we set it once here for empty states. */
.cms-empty__icon { display: inline-flex; }
.cms-empty__icon svg { width: 48px; height: 48px; }

/* ---------- cms-search inside filterbar specificity guard ----------
   `.cms-filterbar input[type="text"]` (defined alongside the select +
   datepicker resets earlier) beats `.cms-search input` on specificity
   because the attribute selector adds a weight that the plain element
   does not. That collision wipes the left padding the search icon
   relies on, so every search field with the `.cms-search` slot ends
   up with text overlapping the magnifier. Re-pin the padding with the
   matching higher-specificity selector. */
.cms-filterbar .cms-search input,
.cms-search input[type="text"],
.cms-search input[type="search"] {
  padding: 0.6rem 0.85rem 0.6rem 2.3rem;
}

/* ---------- cms-filterbar legacy layout fallback ----------
   The production filterbar partial wraps its children in `__search`,
   `__fields`, `__actions` slots and the grid layout above stacks those
   slots vertically. Pages that drop raw children straight into
   `.cms-filterbar` (e.g. itineraries/index pre-dating the partial)
   would also stack vertically under that grid — looks broken because
   each filter takes a full row. Detect the raw-children usage via
   :not(:has(__search)) and fall back to a flex-wrap row layout. */
.cms-filterbar:not(:has(.cms-filterbar__search)) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.cms-filterbar:not(:has(.cms-filterbar__search)) > .cms-search {
  flex: 1 1 240px;
  min-width: 0;
}

/* ---------- cms-campaign card responsive ----------
   The campaign card header uses .cms-row--split (justify-content:
   space-between) with the action buttons row marked .cms-row--shrink
   (flex-shrink:0). On phone widths the 3-4 buttons keep their natural
   width and squeeze the campaign__main into a ~50px column — title
   text wraps to one character per line. Below 640px, stack the rows
   vertically so the title gets full width and the action buttons sit
   on their own line. */
@media (max-width: 640px) {
  .cms-card .cms-row--split {
    flex-direction: column;
    align-items: stretch;
  }
  .cms-card .cms-row--split .cms-row--shrink {
    flex-shrink: 1;
    flex-wrap: wrap;
    width: 100%;
  }
  .cms-card .cms-row--split .cms-row--shrink > * {
    flex: 1 1 auto;
  }
  .cms-campaign__title {
    line-height: 1.3;
    word-break: break-word;
  }
  .cms-campaign__meta {
    gap: 0.5rem 0.85rem;
  }
}

/* ---------- color-scheme + FullCalendar event text contrast ----------
   Match the <meta name="color-scheme" content="light"> in the layout. Some
   browsers honour CSS but ignore the meta — this is a belt-and-braces
   declaration so form inputs + native widgets don't flip to dark.
   FullCalendar default theme paints event titles white, which on our
   soft-tint event backgrounds (dcfce7 etc.) drops below WCAG AA. Force
   the title color to the same dark token as the border so titles read. */
:root { color-scheme: light; }
.fc .fc-event.is-status-confirmed,
.fc .fc-event.is-status-confirmed .fc-event-title,
.fc .fc-event.is-status-confirmed .fc-event-time,
.fc .fc-event.is-status-confirmed .fc-list-event-title a { color: #14532d !important; }
.fc .fc-event.is-status-in_progress,
.fc .fc-event.is-status-in_progress .fc-event-title,
.fc .fc-event.is-status-in_progress .fc-list-event-title a { color: #78350f !important; }
.fc .fc-event.is-status-completed,
.fc .fc-event.is-status-completed .fc-event-title,
.fc .fc-event.is-status-completed .fc-list-event-title a { color: #1e3a8a !important; }
.fc .fc-event.is-status-cancelled,
.fc .fc-event.is-status-cancelled .fc-event-title,
.fc .fc-event.is-status-cancelled .fc-list-event-title a { color: #6b7280 !important; text-decoration: line-through; }
.fc .fc-event.is-status-draft,
.fc .fc-event.is-status-draft .fc-event-title,
.fc .fc-event.is-status-draft .fc-list-event-title a { color: #374151 !important; }

/* ---------- cms-trip-detail row + icon sizing ----------
   Trip-detail rows on the booking show page. The kind icon (.cms-trip-detail__icon)
   sits left of the detail body — without a size guard the bare <svg viewBox=...>
   fills its grid cell (same bug class as the empty-state icon). Pin to 28x28
   inside a circular tile so hotel / flight / car icons stay glanceable. */
/* Mobile-first: two columns (icon + body); the actions row — send button +
   edit/trash — wraps UNDER the body so a wide button can't crush the text
   at 360px. From 481px the actions move back to a third column. */
.cms-trip-detail {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 8px 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 12px;
  background: #fff;
  margin: 8px 0;
}
@media (min-width: 481px) {
  .cms-trip-detail { grid-template-columns: 40px 1fr auto; gap: 12px; }
}
.cms-trip-detail__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--gray-50, #f9fafb);
  color: var(--gray-600, #4b5563);
}
.cms-trip-detail__icon svg { width: 22px; height: 22px; }
.cms-trip-detail__body { min-width: 0; }
.cms-trip-detail__title { margin: 0 0 4px; font-size: 0.95rem; }
.cms-trip-detail__meta {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--gray-600, #4b5563);
  word-break: break-word;
}
.cms-trip-detail__actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
@media (min-width: 481px) { .cms-trip-detail__actions { grid-column: auto; } }
.cms-trip-details { list-style: none; margin: 0; padding: 0; }

/* ---------- cms-paymenttable mobile polish ---------- */
.cms-paymenttable { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cms-paymenttable thead th { white-space: nowrap; }
@media (max-width: 480px) {
  .cms-paymenttable__actions { flex-direction: column; align-items: stretch; }
  .cms-paymenttable__actions form,
  .cms-paymenttable__actions .cms-btn { width: 100%; }
  .cms-paymenttable tbody td { padding: 0.6rem; font-size: 0.8125rem; }
}

/* ---------- cms-pagehead actions wrap cleanly on mobile ---------- */
@media (max-width: 640px) {
  .cms-pagehead__actions { width: 100%; }
  .cms-pagehead__actions form { display: inline-flex; }
  .cms-pagehead__actions > * { flex: 1 1 auto; min-width: 0; }
}

/* ---------- cms-actionbar: equal-width action grid ----------
   Used in cms-pagehead actions on screens where buttons should all
   look the same size + intent-color-coded. Each child takes 1 grid
   slot. On desktop the grid auto-fits as many 160px+ cells as fit;
   phones drop to 2 cells per row. button_to wraps in <form> — that
   becomes the grid cell; the inner button is full width inside. */
.cms-actionbar {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  width: 100%;
}
.cms-actionbar__cell { margin: 0; min-width: 0; }
.cms-actionbar form { margin: 0; }
@media (max-width: 480px) {
  .cms-actionbar { grid-template-columns: repeat(2, 1fr); }
}

/* Block (full-width) variant — use inline-flex so leading icon + label stay
   centered (display:block would left-align them inside the cell). */
.cms-btn--block,
.cms-actionbar form .cms-btn,
.cms-actionbar__cell .cms-btn {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

/* ---------- cms-btn icon + collapsible label ----------
   Action buttons follow the Apple / Google / Samsung pattern: leading
   icon + label on desktop, icon-only on phones (label collapses, the
   tile stays a 44x44 touch target so accessibility holds). Tooltip
   (title="…") restores the verb when label is hidden. */
.cms-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.cms-btn__label { display: inline; }
@media (max-width: 480px) {
  .cms-btn--collapse .cms-btn__label { display: none; }
  .cms-btn--collapse {
    min-height: 44px;
    min-width: 44px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .cms-btn--collapse svg { width: 22px; height: 22px; }
}

/* ---------- Support thread (admin ticket view) ----------
   Customer/staff conversation bubbles. Customer on the left (neutral
   gray), staff replies on the right (blue tint). */
.cms-thread { display: flex; flex-direction: column; gap: 0.625rem; margin-bottom: 1.25rem; }
.cms-msg { max-width: 80%; padding: 0.625rem 0.875rem; border-radius: 12px; font-size: 0.875rem; line-height: 1.45; }
.cms-msg p { margin: 0; }
.cms-msg p + p { margin-top: 0.5rem; }
.cms-msg__who { font-size: 0.6875rem; font-weight: 700; color: var(--gray-500); margin-bottom: 3px; }
.cms-msg__time { font-size: 0.6875rem; color: var(--gray-400); margin-top: 4px; }
.cms-msg--customer { align-self: flex-start; background: var(--gray-100); }
.cms-msg--staff { align-self: flex-end; background: var(--blue-50); }
/* Tap-to-download chip on a "downloadable" media bubble (history / cap-
   evicted). The compact cms-btn--xs look, but a full 44px touch target so it
   never drops below WCAG 2.5.5 inside a chat bubble (xs alone caps at 36px on
   mobile — fine for inline "+ Add", not for a primary tap affordance here). */
.cms-msg__download.cms-btn { min-height: 44px; margin-top: 4px; }

/* ---------- Traveller manifest (admin booking) ---------- */
.cms-manifest { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.cms-manifest li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.cms-manifest__meta { font-size: 0.8125rem; color: var(--gray-500); }

/* ---------- Support attachments (thread) ---------- */
.cms-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.cms-attach__thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; display: block; }
.cms-attach__file { display: inline-block; padding: 6px 10px; background: var(--gray-100); border-radius: 8px; font-size: 0.8125rem; text-decoration: none; color: var(--gray-700); }
.cms-ticket-actions { margin-bottom: 0.875rem; }

/* ── Admin AI usage filter grid (was an inline <style> in the view) ── */
.ai-usage-filter { display: grid; grid-template-columns: 1fr; gap: 0.75rem; align-items: end; }
@media (min-width: 720px) { .ai-usage-filter { grid-template-columns: repeat(4, 1fr) auto; } }
.ai-usage-filter .cms-label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-500); }

/* ---------- Staff bell (CMS notifications) ---------- */
/* One bell per surface: topbar (dropdown), mobile header + sidebar footer
   (plain link). Badge lives in a .js-staff-bell-badge slot so live Turbo
   broadcasts can update every rendered bell at once. Mobile-first: the
   44x44 button is the WCAG touch target. */
.cms-bell { position: relative; display: inline-flex; }
.cms-bell__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  border-radius: var(--cms-radius);
  color: var(--gray-500);
  cursor: pointer;
}
.cms-bell__btn:hover { background: var(--gray-100); color: var(--gray-700); }
.cms-bell__btn svg { width: 22px; height: 22px; }
.cms-bell__slot { position: absolute; top: 4px; right: 4px; pointer-events: none; }
.cms-bell__badge {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9999px;
  background: var(--red-500);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cms-bell__menu { width: min(340px, calc(100vw - 2rem)); padding: 0; }
.cms-bell__menuhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--gray-700);
}
.cms-bell__markall {
  border: 0;
  background: transparent;
  color: var(--blue-600);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0.25rem; /* keeps the tap target comfortable in the menu */
}
.cms-bell__list { max-height: 60vh; overflow-y: auto; }
.cms-bell__empty { padding: 1rem 0.85rem; font-size: 0.8125rem; color: var(--gray-500); }
.cms-bell__viewall {
  display: block;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--gray-100);
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--blue-600);
  text-decoration: none;
}
.cms-side__bell { display: flex; justify-content: center; margin-bottom: 0.5rem; }

/* Notification rows — shared by the bell menu and the full page. */
.cms-notiflist {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--cms-radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}
.cms-notifrow { border-bottom: 1px solid var(--gray-100); }
.cms-notifrow:last-child { border-bottom: 0; }
.cms-notifrow__link {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 0.85rem;
  min-height: 44px;
  text-decoration: none;
  color: inherit;
}
.cms-notifrow__link:hover { background: var(--gray-50); }
.cms-notifrow__dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 9999px;
  background: transparent;
}
.cms-notifrow.is-unread .cms-notifrow__dot { background: var(--blue-600); }
.cms-notifrow.is-unread .cms-notifrow__title { font-weight: 700; }
.cms-notifrow__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cms-notifrow__title { font-size: 0.8125rem; font-weight: 600; color: var(--gray-800); }
.cms-notifrow__body { font-size: 0.75rem; color: var(--gray-600); overflow-wrap: anywhere; }
.cms-notifrow__time { font-size: 0.6875rem; color: var(--gray-400); }

/* ---------- Booking status chips (bookings index) ---------- */
/* Mobile-first: chips wrap; each is a full-height 44px tap target. */
.cms-statuschips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0 1rem; }
.cms-statuschips__chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.8rem;
  border: 1px solid var(--gray-200);
  border-radius: 9999px;
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-600);
  text-decoration: none;
}
.cms-statuschips__chip:hover { border-color: var(--gray-300); color: var(--gray-800); }
.cms-statuschips__chip.is-active {
  background: var(--blue-50);
  border-color: var(--blue-600);
  color: var(--blue-700);
}

/* ---------- Customer pulse (booking show: daily check-ins + feedback) ---------- */
.cms-pulse { display: flex; flex-direction: column; gap: 0.5rem; }
.cms-pulse__row {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--gray-100);
  border-radius: var(--cms-radius-lg);
  background: var(--gray-50);
}
.cms-pulse__row.is-flagged { border-color: var(--red-500); background: var(--red-50); }
.cms-pulse__day {
  flex: none;
  min-width: 52px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding-top: 2px;
}
.cms-pulse__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cms-pulse__stars { color: var(--amber-700); font-size: 0.9rem; letter-spacing: 1px; }
.cms-pulse__stars-off { color: var(--gray-300); }
.cms-pulse__body { font-size: 0.8125rem; color: var(--gray-800); overflow-wrap: anywhere; }
.cms-pulse__meta { font-size: 0.6875rem; color: var(--gray-400); }
.cms-pulse__flag { color: var(--red-600); font-weight: 700; }

/* ---------- Trip-document delivery (booking show) ---------- */
.cms-trip-details__sendall { margin-bottom: 0.75rem; }
.cms-trip-detail__send { min-height: 44px; white-space: nowrap; }
