/* ============================================
   LA VITRINA DE HORARIOS — token layer

   Self-hosted IBM Plex (OFL): the condensed
   voice face and the mono data face. Files live
   in app/assets/fonts/ with their OFL.txt; the
   url() references are relative so Propshaft
   fingerprints them against the load path.
   ============================================ */
@font-face {
  font-family: 'IBM Plex Sans Condensed';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-condensed-400-cdc174c4.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-condensed-600-0f47cdda.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-condensed-700-25799abc.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/ibm-plex-mono-400-a258e185.woff2") format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/ibm-plex-mono-600-ff146818.woff2") format('woff2');
}

/* ============================================
   DESIGN TOKENS
   Runtime custom-property layer. Colors, type
   and radii mirror the DESIGN.md frontmatter
   and the .impeccable/design.json sidecar,
   except the chart palette: its runtime source
   of truth is app/helpers/chart_helper.rb, and
   the frontmatter keeps those entries as
   documentation. The crema→marrón ramp is the
   ONLY neutral source — no gray hex exists
   outside it. Alpha-blended color functions appear
   only in this block (warm shadows + the celeste
   focus ring);
   every rule below consumes var(--…), never a
   literal. One type size for everything but the
   featured-metric display numeral; rank is
   carried by weight, case, reversal and rule.
   ============================================ */
:root {
  /* Colors: bed (the page ground is crema end to end) */
  --color-bed: #F0EBD8;
  --color-bed-raised: #F2F2F2;
  --color-bed-sunken: #DED8C6;
  --color-bed-inset: #CCC5B5;
  /* Colors: ramp hairlines and lines (crema→marrón steps 3-6) */
  --color-line: #BAB3A4;
  --color-hairline: #CCC5B5;
  --color-input-line: #A8A092;
  --color-scrollbar-thumb: #968E81;
  --color-scrollbar-thumb-hover: #847B70;
  /* Colors: glass (data surfaces) */
  --color-glass: #314C4B;
  --color-glass-deep: #263B3A;
  --color-on-glass: #F0EBD8;
  --color-on-glass-muted: #C4CCC5;
  /* Colors: celeste — the single working accent. accent-ink is
     the darkened celeste that carries 4.5:1 as text on bed and
     ivory; accent-deep is the hover fill (text on it flips to
     crema); accent-on-glass is the light celeste that carries
     4.5:1 as text on the glass itself. */
  --color-accent: #4CABC1;
  --color-accent-deep: #2A6E83;
  --color-accent-ink: #2A6E83;
  --color-accent-fill-soft: #D8EAEE;
  --color-accent-on-glass: #8CC7D6;
  /* Colors: inks (ramp steps 8-10) */
  --color-ink: #3D312B;
  --color-on-ivory-ink: #3D312B;
  --color-body-ink: #4F443C;
  --color-muted-ink: #61564D;
  --color-faint-ink: #6E655A;
  /* Colors: semantic traffic pair — appears only where something
     grows, declines or breaks; never as decoration. */
  --color-up-ink: #1E6B52;
  --color-down-ink: #A63A2E;
  /* Colors: notice family (verde tint) */
  --color-notice-fill: #DCE6E1;
  --color-notice-ink: #1B4A3E;
  --color-notice-line: #A9C4BB;
  /* Colors: alert family (rust tint) */
  --color-alert-fill: #A63A2E;
  --color-alert-ink: #8C2F24;
  --color-alert-line: #D9A79F;
  --color-alert-fill-soft: #F2DDD8;
  --color-alert-text: #A63A2E;
  /* Type: ONE size + the display exception (featured metric
     plate numeral and auth/error status numeral only) */
  --font-size-display: clamp(2.25rem, 2vw + 1.75rem, 3.5rem);
  --font-size-body: 1rem;
  /* Type: faces and grammar */
  --font-voice: 'IBM Plex Sans Condensed', 'Helvetica Neue', Arial, sans-serif;
  --font-data: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --tracking-caps: 0.08em;
  --rake: -8deg;
  /* Radii: printed sheets, not bubbles */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 9999px;
  /* Spacing: rem so it scales with the user's type preference; tokenize a
     declaration only when every length in it is on the scale */
  --spacing-sm: 0.5rem;
  --spacing-md: 0.75rem;
  --spacing-lg: 1rem;
  --spacing-xl: 1.5rem;
  --spacing-xxl: 2rem;
  /* Elevation (rank ladder: rest < toast < modal), warm marrón-tinted and
     softened — the bed does the depth work; shadows are for ivory panes
     and glass only. */
  --shadow-rest: 0 2px 4px rgba(61,49,43,0.14);
  --shadow-toast: 0 4px 12px rgba(61,49,43,0.18);
  --shadow-modal: 0 4px 24px rgba(61,49,43,0.12);
  /* Outside the rank ladder: input focus halo, not an elevation */
  --shadow-focus-ring: 0 0 0 3px rgba(76,171,193,0.25);
  /* Component variable, not a design token: the Okabe-Ito category hue a
     .category-chip carries, injected per element by the ERB from
     ChartHelper#category_color (the chart palette's single runtime source
     of truth — CSS must never hold a second copy). :root carries only the
     unknown-category fallback so the token-closure spec sees the var()
     reference defined; real values always arrive from the helper. The
     magnifier glyph is data-chrome, not a color token: a data URI cannot
     reference var(), so the icon lives here (stroked in muted-ink) and
     the call site consumes the variable. */
  --category-color: var(--color-faint-ink);
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2361564D' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='M21 21l-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Mobile tap highlight removal */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Safe area for iPhone notch. No scroll-behavior here ON PURPOSE: a
   global `smooth` turns Turbo Drive's programmatic reset-to-top into an
   animated scroll that async layout growth cancels mid-flight, parking
   the viewport at the previous page's offset after every navigation
   (pinned by the clients system specs). */
html {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* The bed owns the ground: crema end to end, prose in the voice face at
   the one size. Mono is for numerals and codes, never prose. */
body {
  font-family: var(--font-voice);
  font-size: var(--font-size-body);
  background: var(--color-bed);
  color: var(--color-body-ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  caret-color: var(--color-accent-ink);
}

/* Form controls inherit the voice face — the UA default would break the
   one-family rule inside buttons and inputs. */
button,
input,
select,
textarea {
  font: inherit;
}

/* Keyboard focus rings, themed from the palette: accent-ink (the darkened
   celeste) carries the 3:1 an outline owes against both beds; inputs pair
   the border shift with their own ring (see the Inputs rules below). */
a:focus-visible,
button:focus-visible,
input[type='submit']:focus-visible,
input[type='checkbox']:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-accent-ink);
  outline-offset: 2px;
}

/* Timetable precision: tabular numerals wherever data is counted, set in
   the mono data face — values, deltas, counts, table cells and codes. */
.metric-card .value,
.metric-card .delta,
.frequency-item .count,
.partner-item .count,
.data-table td,
.airport-card .count {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* Header: the verde glass bar, full-bleed. Chrome never floats on
   white — the glass carries it over the crema bed. */
.header {
  background: var(--color-glass);
  box-shadow: var(--shadow-rest);
  padding: var(--spacing-md) var(--spacing-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  /* Xl for the tabs between logo and controls — formerly re-declared
     unscoped at the clients module's tail, whose later source order
     out-cascaded the mobile gap overrides below and killed them. */
  gap: var(--spacing-xl);
}

.logo {
  font-size: var(--font-size-body);
  font-weight: 700;
  letter-spacing: var(--tracking-caps);
  color: var(--color-on-glass);
}

.logo-img {
  height: 28px;
  width: auto;
  display: block;
}

.auth-logo {
  display: block;
  height: 36px;
  width: auto;
  margin: 0 auto 1rem;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* Buttons: celeste works. Primary = celeste fill with CARBON text (the
   one fill/text pair that passes 4.5:1 on celeste); hover deepens to
   accent-deep and flips the text to crema. Sharp 4px radii — printed
   sheets, not bubbles. */
.btn {
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out;
  min-height: 44px;
  min-width: 44px;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-ink);
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--color-accent-deep);
  color: var(--color-on-glass);
}

/* Secondary = ivory fill carbon text: the quiet alternative to the
   celeste primary, not a second hue. */
.btn-secondary {
  background: var(--color-bed-raised);
  color: var(--color-ink);
}

.btn-secondary:hover,
.btn-secondary:active {
  background: var(--color-bed-sunken);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Compact icon action (header): the SVG is the whole affordance, so the
   words live in the title/aria-label pair baked by
   LayoutHelper#sync_button_title and rewritten by the sync controller —
   never in a visible label. 36px square reads quieter than the 44px text
   buttons; the ≤768px block restores the touch floor. After .btn on
   purpose: the size/padding overrides must win the same-specificity
   cascade. On the glass bar the icons are crema; hover is the celeste
   mark. */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  width: 36px;
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-on-glass);
}

.btn-icon:hover,
.btn-icon:active {
  background: var(--color-glass-deep);
  border-color: var(--color-glass-deep);
  color: var(--color-accent);
}

.btn-icon svg {
  stroke: currentColor;
}

/* Identities for the compact header actions, declared AFTER .btn-icon so
   they win the same-specificity cascade (same placement rule as
   .btn-logout). Calendar sync is the celeste-filled action; drive sync
   sits in a glass-deep well — two identities inside the one accent
   grammar, no second hue. Icons read via currentColor. */
.btn-icon--primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-ink);
}

.btn-icon--primary:hover,
.btn-icon--primary:active {
  background: var(--color-accent-deep);
  border-color: var(--color-accent-deep);
  color: var(--color-on-glass);
}

.btn-icon--secondary {
  background: var(--color-glass-deep);
  border-color: var(--color-glass-deep);
  color: var(--color-on-glass);
}

.btn-icon--secondary:hover,
.btn-icon--secondary:active {
  background: var(--color-glass-deep);
  border-color: var(--color-glass-deep);
  color: var(--color-accent);
}

/* Sync in flight: the sync controller adds .syncing on trigger and
   removes it on settle/abandon — the icon spins for exactly as long. */
.btn-icon.syncing svg {
  animation: sync-icon-spin 1s linear infinite;
}

@keyframes sync-icon-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Main */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-xxl);
}

/* Dashboard */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxl);
}

/* Metrics band: the glass pane carrying the season rail and the metric
   cards. Inside it the featured metric is the ONE reversed plate per
   screen (solid glass, crema display numeral) and its siblings are ivory
   panes — same size everywhere, rank by weight and reversal only. No
   hover lift and no gradient strips: hovering is the traveling bed-light
   (see the light-travel rules near the end of the file). */
.metrics-section {
  background: var(--color-glass);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-lg);
}

/* Sibling metrics: ivory panes, carbon mono numerals at 600, tracked-caps
   labels at 400 muted. */
.metric-card {
  background: var(--color-bed-raised);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
}

.metric-card h3 {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  margin-bottom: var(--spacing-sm);
  font-weight: 400;
  letter-spacing: var(--tracking-caps);
}

.metric-card .value {
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 1.1;
  color: var(--color-ink);
  margin-bottom: var(--spacing-md);
}

.metric-card .delta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 600;
  width: fit-content;
}

.metric-card .delta.positive {
  background: var(--color-notice-fill);
  color: var(--color-up-ink);
}

.metric-card .delta.negative {
  background: var(--color-alert-fill-soft);
  color: var(--color-down-ink);
}

/* Neutral pill for non-status labels (e.g. "Per Passenger"): the meta
   chip grammar — bed-inset fill, body ink. */
.metric-card .delta:not(.positive):not(.negative) {
  background: var(--color-bed-inset);
  color: var(--color-body-ink);
}

/* The featured metric plate: first card of the band, solid glass, crema
   Display numeral in the mono face, carbon-weight label in tracked caps.
   Its deltas reverse into filled traffic chips (crema numeral on the
   semantic ink) because up/down text inks cannot pass on glass. */
.metric-cards .metric-card:first-child {
  background: var(--color-glass);
}

.metric-cards .metric-card:first-child h3 {
  color: var(--color-on-glass);
  font-weight: 600;
}

.metric-cards .metric-card:first-child .value {
  font-size: var(--font-size-display);
  font-weight: 600;
  color: var(--color-on-glass);
}

.metric-cards .metric-card:first-child .delta.positive {
  background: var(--color-up-ink);
  color: var(--color-on-glass);
}

.metric-cards .metric-card:first-child .delta.negative {
  background: var(--color-down-ink);
  color: var(--color-on-glass);
}

.metric-cards .metric-card:first-child .delta:not(.positive):not(.negative) {
  background: var(--color-glass-deep);
  color: var(--color-on-glass);
}

/* Chart sections: glass panes with ivory chart panes inside — Okabe-Ito
   was designed for white, so the canvas sits on ivory while the section
   head rides the glass in tracked caps on the rake. */
.chart-section {
  background: var(--color-glass);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

/* Section heads: ONE size, tracked caps at 600, rank carried by the
   raked plate behind the label (skewed plate, upright text — the
   counter-skew lives on the ::before, so no child element is needed).
   Glass panes set the label in crema on a glass-deep plate; the ivory
   .card below mirrors it in carbon on bed-sunken. */
.chart-section h2,
.card h2,
.col h2,
.origin-map h2 {
  display: inline-block;
  position: relative;
  z-index: 0;
  font-size: var(--font-size-body);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  padding: 0.125rem 0.75rem;
  margin-bottom: var(--spacing-lg);
  color: var(--color-on-glass);
}

.chart-section h2::before,
.col h2::before,
.origin-map h2::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: skewX(var(--rake));
  background: var(--color-glass-deep);
}

.card h2 {
  color: var(--color-ink);
}

.card h2::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: skewX(var(--rake));
  background: var(--color-bed-sunken);
}

/* Generic section card for reading surfaces (client detail pages, the
   clients index, changelog releases): the ivory pane — glass is for
   DATA, ivory for reading. Rest rank permanently (Rank Rule: only an
   interacted-with surface may rise). */
.card {
  background: var(--color-bed-raised);
  color: var(--color-on-ivory-ink);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

/* The ivory chart pane: the canvas ground inside the glass section. */
.chart-container {
  height: 300px;
  position: relative;
  background: var(--color-bed-raised);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md);
}

/* Season selector (season-scoped dashboard sections): celeste line-codes
   on the rake, riding the glass band. Inactive codes are light celeste
   mono with a celeste underline stroke (the code); the active one fills
   celeste with carbon text — the filled mark means "current season".
   Pills drive their section's Turbo Frame: local swap, no page
   re-render. */
.season-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.season-selector .season-pill {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--color-accent-on-glass);
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  /* 500 at rest AND active: the resolved weight is pinned by the clients
     system specs, and the no-bump rule is about active ≠ inactive
     (a weight change reflows the pill row on every click) — equality at
     500 satisfies both. */
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.2s ease-out, color 0.2s ease-out;
}

/* The line-code stroke, raked like every navigation mark. */
.season-selector .season-pill::before {
  content: '';
  position: absolute;
  inset: 6px 0 4px;
  z-index: -1;
  transform: skewX(var(--rake));
  border-bottom: 1px solid var(--color-accent);
  transition: background 0.2s ease-out;
}

.season-selector .season-pill:hover {
  color: var(--color-on-glass);
}

.season-selector .season-pill.active {
  background: transparent;
  color: var(--color-ink);
  /* No font-weight bump: the filled code already carries the selection,
     and a weight change reflows the pill row on every click (a layout
     shift with no information gain — at the clients page's former
     doubled-card width it also wrapped the last pill onto a second
     line). */
}

.season-selector .season-pill.active::before {
  background: var(--color-accent);
  inset: 4px -2px;
  border-bottom-color: var(--color-accent);
}

.season-selector .season-pill.active:hover {
  color: var(--color-ink);
}

.season-selector .season-pill:active {
  /* Press feedback lands on the pill itself: the container :active bleed
     used to scale the whole panel card behind the press instead (see the
     touch-feedback note near .metric-card:active). Instant by design —
     transform is deliberately kept out of the pill's transition list,
     matching the .btn:active press grammar; transitioning it would also
     invalidate the press spec's settled-transform sampling. */
  transform: scale(0.97);
}

/* Hairline separating the Historic (all-time) option from the seasons */
.season-selector .season-divider {
  width: 1px;
  height: 24px;
  background: var(--color-on-glass-muted);
}

/* Turbo Frames wrapping the VIP sections act as block containers so the
   swapped content keeps the section/column layout. */
turbo-frame {
  display: block;
}

/* Scroll anchoring opt-out for swap targets. Turbo replaces a frame's
   contents wholesale (delete + re-append), so any scroll anchor the browser
   selected inside it dies mid-render — Chrome then re-anchors and yanks the
   page (the production bug: clicking a season pill deep inside the clients
   charts region scrolled the viewport to the region's top, i.e. the
   Nationalities panel). Nothing inside a swapped frame survives a swap, so an
   anchor there could never be kept stable anyway; excluding the frames'
   subtrees makes the browser anchor on stable content outside the region —
   or not at all — and the parked scroll position survives every frame
   navigation (pinned by the scroll-preservation system specs). */
turbo-frame {
  overflow-anchor: none;
}

/* The VIP and service section groups nest inside the gapped .dashboard
   flex column; their own sections would lose that vertical rhythm, so each
   group repeats the parent's flex-column gap. Scoped here on purpose — the
   global turbo-frame rule above stays display-only. */
#vip_sections,
#service_sections {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxl);
}

/* Same situation on the clients page: the charts region frame nests inside
   the gapped .clients-page flex column and must keep repeating its vertical
   rhythm (--spacing-xxl = the page gap there too). */
#clients_charts {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxl);
}

/* Rows and columns */
.row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-lg);
}

.col {
  /* Grid item floor: without min-width 0 the column's min-content (a
     .table-wrapper's 400px table) would stretch the pane past the viewport
     instead of letting the wrapper scroll internally. */
  min-width: 0;
  background: var(--color-glass);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

/* Tables: glass panes — hairline dividers in on-glass-muted, header row
   in tracked caps crema 600 on glass-deep, rows tinting glass-deep on
   hover, data cells in the mono face. */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
}

.data-table th,
.data-table td {
  padding: var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid var(--color-on-glass-muted);
}

.data-table th {
  background: var(--color-glass-deep);
  font-weight: 600;
  color: var(--color-on-glass);
  font-size: var(--font-size-body);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}

.data-table td {
  color: var(--color-on-glass);
}

.data-table tr:hover {
  background: var(--color-glass-deep);
}

/* Ivory-pane tables (clients index and every .card reading surface)
   mirror the glass grammar in carbon and ramp steps. */
.card .data-table th,
.card .data-table td {
  border-bottom: 1px solid var(--color-line);
}

.card .data-table th {
  background: var(--color-bed-sunken);
  color: var(--color-body-ink);
}

.card .data-table td {
  color: var(--color-on-ivory-ink);
}

.card .data-table tr:hover {
  background: var(--color-bed-sunken);
}

/* Repeat-clients table: the client's indexed chart color as a leading dot,
   mirroring the partner-item dot. Chart data ink on chrome — the one
   sanctioned crossing, delivered as a runtime value. */
.data-table .color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  margin-right: var(--spacing-sm);
  vertical-align: middle;
}

/* Frequency lists on glass: crema names, glass-deep bar tracks, the
   count in mono crema. The bar fill keeps the row's chart palette color
   (injected inline by the ERB); the celeste default is only the fallback
   for rows without one. */
.frequency-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.frequency-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.frequency-item .rank {
  font-family: var(--font-data);
  font-weight: 400;
  color: var(--color-on-glass-muted);
  width: 2rem;
  font-size: var(--font-size-body);
}

/* min-width: 0 lets the name box shrink below its min-content when the
   nowrap count claims the row's fixed share — the name wraps instead of
   the row overflowing horizontally (the mobile 390 measure). */
.frequency-item .name {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-body);
  color: var(--color-on-glass);
}

.frequency-item .bar-container {
  flex: 2;
  background: var(--color-glass-deep);
  border-radius: var(--radius-xs);
  height: 8px;
  overflow: hidden;
}

.frequency-item .bar {
  background: var(--color-accent);
  height: 100%;
  border-radius: var(--radius-xs);
}

/* The count is one unbreakable right-aligned line: "16 (3 mo, 53.3%)"
   wrapped raggedly inside a fixed 3rem measure across three lines. The
   same treatment the partner rows already use — nowrap, no fixed width,
   numerals right-aligned in mono (the tables' numeric-cell grammar). */
.frequency-item .count {
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  font-size: var(--font-size-body);
  color: var(--color-on-glass);
}

/* Origin map: glass pane, city cards as glass-deep wells. */
.origin-map {
  background: var(--color-glass);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

.cities-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-lg);
}

.city-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--color-glass-deep);
  border-radius: var(--radius-md);
  transition: background-color 0.2s ease-out;
}

.city-card .rank {
  font-family: var(--font-data);
  font-weight: 400;
  color: var(--color-on-glass-muted);
  width: 2rem;
}

.city-card .city {
  flex: 1;
  font-size: var(--font-size-body);
  color: var(--color-on-glass);
}

.city-card .count {
  font-weight: 600;
  font-size: var(--font-size-body);
  color: var(--color-on-glass);
}

.airports-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-xl);
}

/* Airport Flow sub-heads (the frame's list titles and the origin/
   destination column heads): the glass grammar — crema tracked caps 600
   at the one size. They previously inherited the BED's body ink onto
   verde glass (~1:1, the marrón family spending the traffic pair where
   nothing breaks — Traffic-Only Rule). The h4s share the h3 rule: the
   markup's column heads are h4 and must not fall back to UA bold. */
#airport_flow h3,
.airport-section h3,
.airport-section h4 {
  font-size: var(--font-size-body);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  color: var(--color-on-glass);
  margin-bottom: var(--spacing-md);
}

.airport-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-glass-deep);
  border-radius: var(--radius-sm);
}

.airport-card .rank {
  font-family: var(--font-data);
  font-weight: 400;
  color: var(--color-on-glass-muted);
  width: 1.5rem;
  font-size: var(--font-size-body);
}

.airport-card .code {
  flex: 1;
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  color: var(--color-on-glass);
}

.airport-card .count {
  font-weight: 600;
  color: var(--color-on-glass);
  font-size: var(--font-size-body);
}

/* Footer: a quiet rule on the bed — the ground carries it, no floating
   chrome. */
.footer {
  background: transparent;
  border-top: 1px solid var(--color-line);
  padding: var(--spacing-xl) var(--spacing-xxl);
  text-align: center;
  margin-top: var(--spacing-xxl);
}

.footer p {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
}

/* The footer version doubles as a shortcut to the changelog: it reads as
   plain muted text at rest (parity with the paragraph around it) and
   gains the ink + underline only on hover, so the affordance shows
   without dressing the whole footer line up as a link. */
.footer a.footer-version {
  color: inherit;
  text-decoration: none;
}

.footer a.footer-version:hover {
  color: var(--color-ink);
  text-decoration: underline;
}

/* ============================================
   FLASH MESSAGES — toasts in the world grammar:
   notice = glass fill, crema text, up-ink mark
   chip; alert = rust fill, ivory text.
   ============================================ */
.flash {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: var(--spacing-lg) var(--spacing-xl);
  border-radius: var(--radius-md);
  font-size: var(--font-size-body);
  font-weight: 500;
  z-index: 1000;
  animation: slideIn 0.3s ease, fadeOut 0.5s ease 4.5s forwards;
  box-shadow: var(--shadow-toast);
  /* Pure notification: nothing inside the toast is interactive, so it must
     never intercept pointer events — before, during, or after its fade.
     fadeOut only animates opacity, and an opacity:0 element still
     hit-tests: without this line, a faded "Signed in successfully." toast
     keeps silently swallowing clicks on the header's top-right icon
     cluster (sync drive, logout) until the next navigation repaints the
     header without it. */
  pointer-events: none;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.flash-notice {
  background: var(--color-glass);
  color: var(--color-on-glass);
  border: 1px solid var(--color-notice-line);
}

/* The up-mark: a filled notice-ink chip with the crema glyph — up-ink
   text inks cannot pass 4.5:1 on glass, so the semantic green arrives as
   a filled mark (state is a mark, §1.8). */
.flash-notice::before {
  content: '▲';
  display: inline-block;
  font-family: var(--font-data);
  color: var(--color-on-glass);
  background: var(--color-notice-ink);
  border-radius: var(--radius-xs);
  padding: 0 0.375rem;
  margin-right: var(--spacing-sm);
}

.flash-alert {
  background: var(--color-alert-fill);
  color: var(--color-bed-raised);
  border: 1px solid transparent;
}

/* ============================================
   USER NAVIGATION
   ============================================ */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

/* Email is a code: mono, muted on the glass. */
.user-email {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  color: var(--color-on-glass-muted);
  font-weight: 400;
}

/* Logout keeps its destructive identity as an icon: the rust fill reads
   at a glance beside the two celeste/glass sync actions. Sizing, shape and
   interaction come from .btn/.btn-icon — only the color pair and the
   link hygiene live here. Placed after .btn-icon so the hover pair wins
   the same-specificity cascade. */
.btn-logout {
  background: var(--color-alert-fill);
  color: var(--color-bed-raised);
  border-color: transparent;
  text-decoration: none;
}

.btn-logout:hover,
.btn-logout:active {
  background: var(--color-alert-ink);
  color: var(--color-bed-raised);
}

/* Responsive */
@media (max-width: 1024px) {
  .metric-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .row {
    grid-template-columns: 1fr;
  }

  .cities-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0.625rem 0.875rem;
  }

  .header-content {
    gap: var(--spacing-md);
  }

  /* Two-row header: row 1 = logo + identity + controls (email truncates,
     sync/logout right-aligned), row 2 = the tab strip. The strip's own
     order: 3 + width: 100% (clients-module responsive block) is what
     pushes it to row 2 — nothing else may claim width: 100%. */
  .header-nav {
    /* flex: 1 1 0 is load-bearing twice. Line breaking measures the nav's
       flex BASE size — with basis 0 the row is logo + nothing, so the nav
       can never wrap below the logo even though Chrome's intrinsic-width
       calc for the nav still counts the email's FULL text (basis 0 on the
       email does not zero that contribution; this really wrapped at 390px
       and 700px before the nav got basis 0). Then flex-grow hands the nav
       every leftover pixel, so the email grows beside the logo and pushes
       the controls flush right; min-width: 0 lets the nav shrink so the
       email — never the buttons — absorbs a narrow line. flex-end
       right-aligns the signed-out Login, which has no growing email. */
    flex: 1 1 0;
    min-width: 0;
    justify-content: flex-end;
  }

  .user-email {
    /* Basis 0 keeps the full address out of flex line-breaking (a long
       email would otherwise push the whole nav onto its own row);
       min-width: 0 + ellipsis clips the paint. The DOM text is never cut —
       screen readers get the whole value, the title attr the hoverers. */
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Icon actions hold the 44px touch floor at every fold width: the
     compact 36px squares are desktop-only polish, and the icons are
     already far narrower than the text buttons they replaced — the old
     ≤640px 32px exception had no surviving reason and is retired. */
  .btn-icon {
    height: 44px;
    width: 44px;
    min-height: 44px;
    min-width: 44px;
  }

  .metric-cards {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 240px;
  }

  .main {
    padding: 1rem 0.875rem;
  }

  .col {
    padding: var(--spacing-lg);
  }

  .chart-section,
  .card,
  .metrics-section,
  .origin-map {
    padding: var(--spacing-lg);
  }
}

@media (max-width: 640px) {
  .header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .header-content {
    flex-direction: row;
    align-items: center;
    /* wrap is still load-bearing, for one reason only: .header-tabs
       carries order: 3 + width: 100% from the clients-module ≤768px block
       (the later media query holding the tabs rules), so the strip must
       fall to its own row 2. nowrap would cram logo + tabs + nav into one
       min-content line and push documentElement past the viewport (the
       body scrolling sideways). */
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  .logo-img {
    height: 22px;
  }

  .header-nav {
    flex-direction: row;
    gap: 0.25rem;
    /* nowrap is the point: the email clips (≤768px rules above), the
       controls never wrap to a second line. The old wrap served the sync
       row's own centered line — that row no longer exists. */
    align-items: center;
  }

  .sync-status {
    flex-direction: row;
    gap: 0.25rem;
    flex-wrap: nowrap;
  }

  .metric-cards {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .metric-card {
    padding: var(--spacing-lg);
  }

  .chart-container {
    height: 200px;
  }

  .cities-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }

  .frequency-item {
    gap: var(--spacing-sm);
  }

  /* The count's nowrap line already carries its own measure (see the
     desktop rule): nothing fixed to widen or truncate at 390 — the name
     side yields instead. */
}

/* ============================================
   WORLD POLISH
   ============================================ */

/* .section-subtitle lives on glass panes only (airport flow list titles,
   the VIP mix summary lines; the staff-list h2 variant is fully
   overridden by the .col h2 head rule above it in specificity). Crema is
   load-bearing here: the inherited body ink is a BED ink and dies on
   verde glass. */
.section-subtitle {
  margin-top: var(--spacing-xxl);
  color: var(--color-on-glass);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: var(--font-size-body);
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--color-accent-fill-soft);
  color: var(--color-accent-ink);
}

.empty-state {
  color: var(--color-faint-ink);
  font-size: var(--font-size-body);
  font-style: italic;
  padding: 1rem 0;
}

/* Trend arrows on semantic pills: mono glyphs (marks and numerals are
   mono — §1.9). */
.delta.positive::before {
  content: '▲';
  font-family: var(--font-data);
}

.delta.negative::before {
  content: '▼';
  font-family: var(--font-data);
}

/* Table rows tint one step on hover, 0.2s ease-out. */
.data-table tbody tr {
  transition: background-color 0.2s ease-out;
}

/* City cards brighten to the mark on hover instead of traveling — they
   are wells inside a pane, not panes themselves. */
.city-card:hover {
  background: var(--color-on-glass-muted);
}

/* Loading state for sync buttons */
.btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

/* Touch feedback for mobile — leaf tiles only. :active matches every
   ancestor of the activated element, so container cards here scaled the
   whole panel behind any pressed pill or button; feedback belongs to the
   pressed surface (pills and .btn scale on their own), never to the card
   holding it. */
.metric-card:active,
.city-card:active {
  transform: scale(0.99);
  transition: transform 0.1s;
}

/* Selection: celeste ground, carbon text — the one fill/text pair that
   passes on celeste. */
::selection {
  background: var(--color-accent);
  color: var(--color-ink);
}

/* Scrollbar: ramp thumb on a bed-sunken track (browser surfaces themed
   from the palette — craft floor). */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-bed-sunken);
}

::-webkit-scrollbar-thumb {
  background: var(--color-scrollbar-thumb);
  border-radius: var(--radius-xs);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-scrollbar-thumb-hover);
}

/* Touch overflow scrolling */
.table-wrapper,
.chart-container,
.frequency-list {
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   THE LIGHT TRAVELS (§1.10) — the world's one
   authored interaction. Hovering a pane moves
   the bed-light to it: the hovered glass pane
   gains a celeste top-edge hairline while its
   sibling panes dim one step. :has() on the
   section containers; 0.2s ease-out; parked
   entirely under prefers-reduced-motion and
   absent on touch surfaces.
   ============================================ */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .chart-section,
  .metrics-section,
  .origin-map,
  .col {
    transition: opacity 0.2s ease-out, box-shadow 0.2s ease-out;
  }

  /* Sibling panes dim one step while one of them is hovered. The gap
     between panes belongs to no pane, so the light only travels when the
     pointer is actually over a section. */
  .dashboard:has(:hover) > :not(:hover),
  #vip_sections:has(:hover) > :not(:hover),
  #service_sections:has(:hover) > :not(:hover),
  #clients_charts:has(:hover) > :not(:hover) {
    opacity: 0.85;
  }

  /* The hovered glass pane carries the light: full brightness plus the
     celeste top-edge hairline (an inset line, never a lift). */
  .chart-section:hover,
  .metrics-section:hover,
  .origin-map:hover,
  .col:hover {
    box-shadow: var(--shadow-rest), inset 0 2px 0 var(--color-accent);
  }
}

/* ============================================
   AUTHENTICATION (Devise) — ivory pane on the
   bed with a glass header band behind the logo.
   ============================================ */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 80px);
  padding: var(--spacing-lg);
}

.auth-card {
  position: relative;
  overflow: hidden;
  background: var(--color-bed-raised);
  color: var(--color-on-ivory-ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 0 var(--spacing-xl) var(--spacing-xl);
  width: 100%;
  max-width: 420px;
}

/* The glass band: the pane's verde header, carrying the logo the way the
   app header carries it. Absolute, so it costs the flow nothing; the
   card's own overflow:hidden clips it to the rounded corners. */
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--color-glass);
}

.auth-logo {
  position: relative;
  margin-top: var(--spacing-md);
}

@media (min-width: 641px) {
  .auth-container {
    padding: var(--spacing-xxl);
  }

  .auth-card {
    padding: 0 2.5rem 2.5rem;
  }
}

.auth-card h2 {
  font-size: var(--font-size-body);
  font-weight: 700;
  letter-spacing: var(--tracking-caps);
  color: var(--color-ink);
  margin-bottom: var(--spacing-sm);
  text-align: center;
}

.auth-card .auth-subtitle {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

@media (min-width: 641px) {
  .auth-card .auth-subtitle {
    margin-bottom: var(--spacing-xxl);
  }
}

.field {
  margin-bottom: 1.25rem;
}

/* Labels: tracked caps at 600 in carbon — rank by weight and case, never
   by size. */
.field label {
  display: block;
  font-size: var(--font-size-body);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  color: var(--color-ink);
  margin-bottom: 0.375rem;
}

/* Shared input control: ivory fill, 1.5px input-line border, 4px radius,
   10px/14px padding and a 44px touch-target floor. Focus pairs the
   accent-ink border shift with the celeste ring. The auth .field inputs
   join the same rule — the control was extracted FROM them — so the two
   vocabularies can never drift; the clients filter controls consume
   .input directly. */
.input,
.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--color-input-line);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  color: var(--color-ink);
  background: var(--color-bed-raised);
  min-height: 44px;
  transition: border-color 0.2s ease-out, box-shadow 0.2s ease-out;
  outline: none;
  box-sizing: border-box;
}

/* Email is a code: mono face in the email input. */
.field input[type="email"] {
  font-family: var(--font-data);
}

/* Focus pairs the accent-ink border shift with the 3px celeste ring.
   outline is re-suppressed on :focus so .input selects — which the
   global :focus-visible rule would otherwise double-ring — get the same
   single treatment as text inputs. */
.input:focus,
.field input[type="email"]:focus,
.field input[type="password"]:focus,
.field input[type="text"]:focus {
  border-color: var(--color-accent-ink);
  box-shadow: var(--shadow-focus-ring);
  outline: none;
}

.field em {
  font-size: var(--font-size-body);
  color: var(--color-faint-ink);
  display: block;
  margin-top: 0.25rem;
}

.field .checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.field .checkbox-wrapper label {
  margin-bottom: 0;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  font-size: var(--font-size-body);
  cursor: pointer;
}

.field input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* Password reveal toggle */
.password-wrapper {
  position: relative;
}

.password-wrapper input[type="password"],
.password-wrapper input[type="text"] {
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--color-faint-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease-out;
  line-height: 0;
}

.password-toggle:hover {
  color: var(--color-muted-ink);
}

.actions {
  margin-top: var(--spacing-xl);
}

.actions .btn-primary,
.actions input[type="submit"] {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-accent);
  color: var(--color-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out, transform 0.1s;
}

.actions input[type="submit"]:hover {
  background: var(--color-accent-deep);
  color: var(--color-on-glass);
}

.actions input[type="submit"]:active {
  transform: scale(0.98);
}

.auth-links {
  margin-top: var(--spacing-xl);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.auth-links p {
  margin: 0;
  font-size: var(--font-size-body);
}

/* Links: celeste works — as accent-ink text, the darkened celeste that
   passes 4.5:1 on bed and ivory. */
.auth-links a {
  color: var(--color-accent-ink);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease-out;
}

.auth-links a:hover {
  color: var(--color-ink);
  text-decoration: underline;
}

/* Auth error messages: the rust family at its softest. */
#error_explanation {
  background: var(--color-alert-fill-soft);
  border: 1px solid var(--color-alert-line);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

#error_explanation h2 {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-alert-ink);
  margin-bottom: var(--spacing-sm);
  text-align: left;
}

#error_explanation ul {
  margin: 0;
  padding-left: 1.25rem;
}

#error_explanation li {
  font-size: var(--font-size-body);
  color: var(--color-alert-text);
  margin-bottom: 0.25rem;
}

/* Cancel account section */
.cancel-account {
  margin-top: var(--spacing-xxl);
  padding-top: var(--spacing-xl);
  border-top: 1px solid var(--color-line);
  text-align: center;
}

.cancel-account h3 {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-alert-ink);
  margin-bottom: var(--spacing-sm);
}

.cancel-account .btn-danger {
  background: var(--color-alert-fill);
  color: var(--color-bed-raised);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: var(--font-size-body);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease-out;
}

.cancel-account .btn-danger:hover {
  background: var(--color-alert-ink);
}

.back-link {
  display: block;
  text-align: center;
  margin-top: var(--spacing-lg);
  font-size: var(--font-size-body);
  color: var(--color-accent-ink);
  text-decoration: none;
}

.back-link:hover {
  color: var(--color-ink);
  text-decoration: underline;
}

/* ============================================
   PARTNER BREAKDOWN LIST
   ============================================ */
/* Visually-hidden but available to screen readers (used for any SR-only chart
   captions). Standard clip rule, based on the HTML5 Boilerplate pattern. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.partner-breakdown-list {
  margin-top: 1.25rem;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  padding-right: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

/* Partner rows: glass-deep wells inside the glass pane, dot + code-chip
   grammar kept (chip = ramp bed-inset fill, body-ink mono). */
.partner-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-glass-deep);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease-out;
  border: 1px solid transparent;
}

.partner-item:hover {
  background: var(--color-on-glass-muted);
}

.partner-item .color-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.partner-item .partner-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 140px;
  max-width: 200px;
}

.partner-item .partner-name {
  font-size: var(--font-size-body);
  font-weight: 500;
  color: var(--color-on-glass);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Partner code chips — one species: the frequency-list chip and the
   standalone .partner-code-chip (client detail rows, booking history
   table) share the exact treatment so the two can never drift. */
.partner-item .partner-code,
.partner-code-chip {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-body-ink);
  background: var(--color-bed-inset);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* The chip reads on ivory reading panes too (booking history lives in a
   .card): same ramp fill, same mono, carbon family ink. */
.card .partner-code-chip {
  color: var(--color-on-ivory-ink);
}

.partner-item .bar-container {
  flex: 1;
  background: var(--color-glass-deep);
  border-radius: var(--radius-xs);
  height: 6px;
  overflow: hidden;
}

.partner-item .bar {
  height: 100%;
  border-radius: var(--radius-xs);
}

.partner-item .count {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-on-glass);
  white-space: nowrap;
  text-align: right;
  min-width: 75px;
}

@media (max-width: 640px) {
  .partner-breakdown-list {
    max-height: 240px;
  }

  .partner-item {
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
  }

  .partner-item .partner-info {
    min-width: 100px;
    max-width: 130px;
  }

  .partner-item .count {
    min-width: 55px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   CLIENTS CRM MODULE
   ══════════════════════════════════════════════════════════════════════ */

/* ── Header navigation tabs: raked notches on the glass bar. The rake
   marks navigation only — skewed plate behind an upright label, so no
   child element is needed and the geometry contract (single row, 44px
   targets) is untouched. Active tab = ivory notch plate with carbon
   text; inactive = crema-muted on glass. ─────────────────────────── */
.header-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
  /* Desktop row grammar (DESIGN.md, Navigation): logo + tabs are the
     left cluster, the right group sits flush right, everything left over
     is the blank between them. The auto margin absorbs the free space
     that justify-content: space-between would otherwise split evenly
     across BOTH gaps — without it the logo-to-Dashboard gap would grow
     with the viewport instead of staying at the row's own gap. */
  margin-right: auto;
}

.header-tab {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: var(--font-size-body);
  font-weight: 500;
  color: var(--color-on-glass-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease-out;
  height: 100%;
  min-height: 44px;
}

/* The notch plate: transparent at rest, glass-deep on hover, ivory when
   active. The 3px border-bottom stays structurally transparent — the
   plate is the marker (kept for the mobile 2px re-declaration below). */
.header-tab::before {
  content: '';
  position: absolute;
  inset: 5px 2px 3px;
  z-index: -1;
  transform: skewX(var(--rake));
  background: transparent;
  transition: background-color 0.2s ease-out;
}

.header-tab:hover {
  color: var(--color-on-glass);
  border-bottom-color: transparent;
}

.header-tab:hover::before {
  background: var(--color-glass-deep);
}

.header-tab.active {
  color: var(--color-ink);
  border-bottom-color: transparent;
  font-weight: 600;
}

.header-tab.active::before {
  background: var(--color-bed-raised);
}

/* The Changelog entry exists twice by design: this strip copy is the
   mobile row-2 tab (hidden on desktop, returned by the ≤768px block
   below), while .header-nav's .header-tab--desktop-only copy opens the
   desktop right cluster. A single DOM node cannot migrate between two
   flex containers across a breakpoint, so the duplication IS the
   responsive mechanism — both copies render under the same policy gate
   and the same active-state match. This hide must stay ABOVE the ≤768px
   show in source order: same specificity, cascade order decides. */
.header-tabs .header-tab--mobile-only {
  display: none;
}

/* ── Clients page layout ────────────────────────────────────────────── */
.clients-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Page-level actions row (family-group identity S5): right-aligned so the
   queue entry reads as a task CTA at the page's top-right, opposite the
   metric band below it. One row today — the flex + gap keeps a second
   action on-rhythm if one ever lands. */
.clients-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

/* ── Filter bar: an ivory reading pane (forms are reading surfaces,
   not data grids). ─────────────────────────────────────────────────── */
.client-filters {
  background: var(--color-bed-raised);
  color: var(--color-on-ivory-ink);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-rest);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  /* 8px floor of the spacing rhythm: today a single control rides the field
     (the gap is dormant), but labels land above these controls in a later
     phase and must arrive on-scale, not at an off-rhythm 4px. */
  gap: var(--spacing-sm);
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 220px;
}

.filter-field--search {
  flex: 2 1 240px;
  max-width: 340px;
}

/* The magnifier glyph is a data-URI icon (it cannot reference var()), so
   it lives in :root as --icon-search, stroked in muted-ink — a ramp ink,
   never a gray. */
.search-input {
  background-image: var(--icon-search);
  background-repeat: no-repeat;
  background-position: 10px center;
  /* The icon gutter beats .input's left padding on source order alone —
    both selectors are single-class, and this rule comes later — so the
    !important was vestigial armor from the .field input era. */
  padding-left: 2rem;
}

.filter-select {
  cursor: pointer;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-text {
  /* 44px tap floor (DESIGN.md Buttons/Mobile): a text button is still a
     button on a touch surface — inline-flex centers the label in the
     enlarged hit area without inflating the visual chrome. Text buttons:
     muted ink → ink. */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color 0.2s ease-out;
}

.btn-text:hover {
  color: var(--color-ink);
}

/* Export: the outline button — 1.5px accent-ink border, fills celeste
   with carbon text on hover. */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 44px;
  padding: 0 1rem;
  font-size: var(--font-size-body);
  font-weight: 500;
  color: var(--color-accent-ink);
  background: transparent;
  border: 1.5px solid var(--color-accent-ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease-out, color 0.2s ease-out;
}

.btn-export:hover {
  background: var(--color-accent);
  color: var(--color-ink);
}

/* ── Export column picker ──────────────────────────────────────────── */
.export-columns {
  position: relative;
}

/* The summary wears the .btn-export chrome; kill the UA disclosure
   triangle so the inline chevron is the panel's only marker. */
.export-columns summary {
  list-style: none;
}

.export-columns summary::-webkit-details-marker {
  display: none;
}

.export-columns-chevron {
  transition: transform 0.15s;
}

.export-columns[open] .export-columns-chevron {
  transform: rotate(180deg);
}

/* Floating overlay anchored to its trigger: toast-rank shadow per the Rank
   Rule (rest < toast < modal — this floats above page content),
   right-aligned so it grows away from the filter bar's trailing edge. The
   vw clamp keeps the panel inside a phone viewport. Ivory pane, line
   border. */
.export-columns-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 100;
  min-width: 16rem;
  max-width: min(22rem, calc(100vw - 2rem));
  background: var(--color-bed-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-toast);
  padding: 0.75rem;
}

.export-columns-hint {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  padding: 0 0.5rem 0.5rem;
}

/* 23 options × the 44px tap floor would stand ~1000px tall — cap the list
   and let it scroll instead of stretching the page. */
.export-columns-list {
  max-height: 18.75rem;
  overflow-y: auto;
}

.export-columns-option {
  /* 44px tap floor (DESIGN.md Buttons/Mobile): a whole-row label is the
     checkbox's hit area on a touch surface. */
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 0.5rem;
  font-size: var(--font-size-body);
  color: var(--color-body-ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.export-columns-option:hover {
  background: var(--color-bed-sunken);
}

/* Celeste check accent scoped to the picker — the auth .field checkbox
   treatment stays untouched. */
.export-columns-option input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.export-columns-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--color-hairline);
  margin-top: 0.5rem;
  padding: 0.75rem 0.5rem 0.25rem;
}

/* ── Client table: ivory-pane mirror (carbon/ramp steps; see the
   .card .data-table rules in the Tables section). ─────────────────── */
.client-table .sort-header {
  cursor: pointer;
  color: var(--color-body-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--font-size-body);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
}

.client-table .sort-header:hover {
  color: var(--color-ink);
}

.client-table .sort-header--active {
  color: var(--color-accent-ink);
}

.client-table .client-row {
  cursor: pointer;
}

.client-link {
  color: var(--color-ink);
  text-decoration: none;
  font-weight: 500;
}

.client-link:hover {
  color: var(--color-accent-ink);
  text-decoration: underline;
}

.contact-cell {
  font-size: var(--font-size-body);
  color: var(--color-body-ink);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.origin-cell {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  max-width: 160px;
}

/* Numeric columns: header and cell share the class so the th tracks its
   .number-cell column. Scoped under .data-table on purpose — the bare
   single-class form lost to `.data-table td { text-align: left }` on
   specificity, leaving the "right-aligned" cells silently left-aligned. */
.data-table .number-cell {
  text-align: right;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* Dates are codes: mono, muted. */
.date-cell {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  white-space: nowrap;
}

.muted {
  color: var(--color-faint-ink);
}

/* ── Family-group review queue (S5) ─────────────────────────────────── */
/* One decision per row: the file that would join (client) → the group's
   proposed head, the evidence chips that queued the pair, provenance, and
   the Accept/Dismiss buttons. Reuses the show page's chip vocabulary
   (partner-code-chip file numbers, badge rules, meta-chip source) — this
   section only shapes cells, it mints no new chip species. */
.group-review-party {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.group-review-party .file-number-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* The merge direction glyph: muted, centered — decoration whose meaning
   the header's sr-only label already carries (DESIGN.md Utilities). */
.group-review-arrow {
  color: var(--color-faint-ink);
  text-align: center;
  font-size: var(--font-size-body);
}

/* Evidence cell: rule badge + the shared key (and surname) at the one
   type size the contact cells use; the bucket-B triage prose is one
   ellipsized line with the full text in a title fallback. */
.group-review-evidence {
  font-size: var(--font-size-body);
  color: var(--color-body-ink);
  min-width: 160px;
  max-width: 260px;
}

.group-review-key {
  display: block;
  color: var(--color-muted-ink);
  overflow-wrap: anywhere;
}

.group-review-note {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* button_to wraps each action in its own mini form (one POST per
   decision): inline them so the pair sits on one line, the house .btn
   44px floor included. The cell never wraps mid-pair. */
.group-review-actions {
  white-space: nowrap;
}

.group-review-actions form {
  display: inline-flex;
  vertical-align: middle;
}

.group-review-actions form + form {
  margin-left: var(--spacing-sm);
}

/* ── Pagination: the outline grammar shared with .btn-export. ──────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1rem 0;
}

.page-link {
  /* 44px tap floor (DESIGN.md Buttons/Mobile): pagination arrows are
     primary-thumb controls; the border keeps its visual size, the hit
     area grows. */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--font-size-body);
  color: var(--color-accent-ink);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--color-accent-ink);
  border-radius: var(--radius-sm);
  transition: background 0.2s ease-out, color 0.2s ease-out;
}

.page-link:hover {
  background: var(--color-accent);
  color: var(--color-ink);
}

.page-info {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
}

.result-count {
  text-align: center;
  padding: 0.75rem 0;
  font-size: var(--font-size-body);
  color: var(--color-body-ink);
}

/* ── Client detail page ─────────────────────────────────────────────── */
.client-detail {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.detail-back {
  padding-bottom: 0.25rem;
}

/* .client-profile is just .card — the empty forwarding rule is gone. */
.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
  /* Space from the composite header down to the detail rows: 24px, the
     rhythm step the old off-scale 1.25rem literal was reaching for. */
  margin-bottom: var(--spacing-xl);
}

.profile-main {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ONE type size: the name ranks by weight (700) alone, never by size —
   the reversal hierarchy replaced the old scale. No text-transform: the
   visible name is pinned by the clients specs, so it renders as shipped. */
.client-name-display {
  font-size: var(--font-size-body);
  font-weight: 700;
  letter-spacing: var(--tracking-caps);
  color: var(--color-ink);
  margin: 0;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Meta chip: bed-inset fill, body ink — the one chip size is the type
   size, 4px radius. */
.meta-chip {
  display: inline-block;
  /* Badge padding convention (0.2rem x 8px): the vertical micro-length is
     the documented off-scale chip exception; the horizontal length is the
     8px rhythm step. */
  padding: 0.2rem 0.5rem;
  background: var(--color-bed-inset);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 500;
  color: var(--color-body-ink);
}

/* The accent variant joins the badge species: celeste tint, accent-ink
   text. */
.meta-chip--blue {
  background: var(--color-accent-fill-soft);
  border-color: transparent;
  color: var(--color-accent-ink);
}

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

/* Tag chip: bed-inset + faint-ink, square-ish. */
.tag-chip {
  display: inline-block;
  /* Badge padding convention (0.2rem x 8px), matching .meta-chip — one
     chip padding rhythm, not per-species oddities like the old 0.6rem. */
  padding: 0.2rem 0.5rem;
  background: var(--color-bed-inset);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 500;
  color: var(--color-faint-ink);
  /* Uppercase Boundary Rule: no text-transform here — tracked
     uppercase belongs to table headers and section heads. Tags render as
     written ("wine", not "WINE"). */
}

.profile-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-row {
  display: flex;
  gap: 1rem;
  font-size: var(--font-size-body);
}

.detail-label {
  min-width: 110px;
  color: var(--color-muted-ink);
  font-weight: 500;
  flex-shrink: 0;
}

.detail-value {
  color: var(--color-body-ink);
}

/* File-number chip group: the partner-code species repeated once per
   (season, number) pair on the client detail row. Only layout — the chips
   themselves are the untouched species. Flex-wrap with the same 0.5rem
   gap .profile-meta gives the profile's other chip groups — spelled here
   as the spacing token — so a long client history wraps instead of
   overflowing its detail row on a narrow viewport. */
.file-number-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

/* family-group identity S4: a table cell stacking a file-number chip (or
   chips) with the file's name — booking-history rows and the Family files
   section both pair "which number" with "which file". Only layout: the
   chip keeps its species, the name keeps .muted's. */
.file-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
}

/* ── Contacts card ──────────────────────────────────────────────────── */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.contact-group-label {
  display: block;
  font-size: var(--font-size-body);
  font-weight: 600;
  /* Uppercase Boundary Rule: a group caption is a label, not a table
     header — it reads "Phones" in sentence case, no tracking. */
  color: var(--color-body-ink);
  margin-bottom: 0.75rem;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  /* 8px row rhythm (was an off-scale 6.4px literal) */
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-hairline);
}

.contact-row:last-child {
  border-bottom: none;
}

.contact-value {
  font-size: var(--font-size-body);
  color: var(--color-body-ink);
  font-weight: 500;
}

.contact-link {
  color: var(--color-accent-ink);
  text-decoration: none;
}

.contact-link:hover {
  color: var(--color-ink);
  text-decoration: underline;
}

.contact-name {
  font-size: var(--font-size-body);
}

/* ── manual-data-overrides T3: contact correction affordances ────────── */
.contact-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  /* Right-anchor the action cluster: values and chips wrap naturally in
     the flex row while the actions hold the row's trailing edge. */
  margin-left: auto;
}

/* The quiet tertiary action (DESIGN.md Text button) as a real <button>:
   the anchor-flavored .btn-text never needed a UA reset — background,
   border, font — but a button element does. 44px tap floor per the
   Buttons contract: inline-flex centers the label in the hit area
   without inflating the visual chrome. */
.contact-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.25rem 0.375rem;
  font-size: var(--font-size-body);
  font-family: inherit;
  color: var(--color-muted-ink);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.2s ease-out;
}

.contact-action:hover {
  color: var(--color-ink);
}

/* Suppression is a strike-out, not a deletion: the value stays readable
   enough to recognize (and decide to restore) while reading as out of the
   pool — muted ink + line-through, the ledger's voided-row gesture
   (matches the override contract: suppression is state, never
   deletion). */
.contact-row--suppressed .contact-value,
.contact-row--suppressed .contact-name {
  color: var(--color-muted-ink);
  text-decoration: line-through;
}

/* ── manual-data-overrides T3: origin correction disclosure ──────────── */
/* The export picker's details pattern: the summary is the affordance, the
   UA disclosure triangle gives way to the btn-text chrome. */
.origin-edit {
  margin-top: 0.25rem;
}

.origin-edit summary {
  list-style: none;
}

.origin-edit summary::-webkit-details-marker {
  display: none;
}

.origin-edit-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
  max-width: 22rem;
}

.origin-edit-form .origin-field {
  display: grid;
  gap: 0.25rem;
}

.origin-edit-form .origin-field label {
  font-size: var(--font-size-body);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  color: var(--color-ink);
}

.origin-edit-help {
  font-size: var(--font-size-body);
  margin: 0;
  color: var(--color-faint-ink);
}

.origin-manual-badge {
  margin-left: 0.375rem;
  vertical-align: middle;
}

/* ── Stats row: the detail page's metric band as one ivory pane. ───── */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--color-bed-raised);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-rest);
  overflow: hidden;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* 24px all around, the card-padding step — the stat strip is the show
     page's metric band, so it carries the metric-card padding rhythm
     (was an off-scale 20px/24px literal pair). */
  padding: var(--spacing-xl);
  flex: 1 1 120px;
  border-right: 1px solid var(--color-hairline);
  text-align: center;
}

.stat-item:last-child {
  border-right: none;
}

/* Sibling-metric grammar: carbon mono numeral at 600, the one size. */
.stat-value {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  font-weight: 700;
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--font-size-body);
  font-weight: 400;
  color: var(--color-muted-ink);
  margin-top: 0.25rem;
  /* Uppercase Boundary Rule: the stat caption is Title-style label type,
     not a table header — sentence case, no tracking. */
}

/* ── Category chip (service timeline) ──────────────────────────────── */
/* Semantic Chart Rule: a category keeps its Okabe-Ito color on every
   surface, and the runtime source is ChartHelper#category_color — the
   ERB injects it per chip as --category-color (the same delivery channel
   the dashboard's color dots and bars use), so CSS holds zero category
   hex and no per-variant rules. Every category, including `other` and
   unknown (grey via the :root fallback), resolves through the helper.

   Contrast: several Okabe-Ito hues (sky, yellow, orange) cannot carry
   white text at 4.5:1, so solid fills are out. The chip renders the hue
   as a light tint with ink-darkened text derived from the same variable
   — the badge's fill/text split, tinted from the hue per the craft
   floor. Chrome tokens stop moonlighting as category colors here. */
.category-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 500;
  background: color-mix(in srgb, var(--category-color) 14%, var(--color-bed-raised));
  color: color-mix(in srgb, var(--category-color) 30%, var(--color-ink));
}

/* ── Files table inline image (drive-crm-files slice 5) ────────────── */
/* Same-origin #raw thumbnails: a fixed height keeps table rows uniform
   across portrait/landscape photos; width auto preserves each photo's
   aspect ratio. Tokens only — the design-token layer stays hex-free. */
.files-table .file-thumb {
  display: block;
  height: 48px;
  width: auto;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-hairline);
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-tabs {
    order: 3;
    width: 100%;
    border-top: 1px solid var(--color-on-glass-muted);
    padding-top: 0.25rem;
    /* The tabs row is itself the scroll container (.table-wrapper
       pattern): a tab strip that outgrows the viewport scrolls inside
       the header — the tabs keep one row and full 44px targets while
       the BODY never scrolls horizontally. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .header-tab {
    padding: 0.5rem 0.75rem;
    font-size: var(--font-size-body);
    border-bottom-width: 2px;
    /* DESIGN.md floor: tap targets hold 44px minimum on mobile — compress
       padding, never the target. The padding + the one-size type stays
       under it, so min-height carries the row. */
    min-height: 44px;
  }

  /* The Changelog fold swap: the strip copy returns (all four tabs live
     in row 2, Chat before Changelog) and the right-group copy steps
     aside. Sourced after the base hide above — cascade order is the
     switch. */
  .header-tabs .header-tab--mobile-only {
    display: flex;
  }

  .header-nav .header-tab--desktop-only {
    display: none;
  }

  .filters-row {
    gap: 0.5rem;
  }

  .filter-field {
    flex: 1 1 calc(50% - 0.5rem);
    max-width: none;
  }

  .filter-field--search {
    flex: 1 1 100%;
    max-width: none;
  }

  .filter-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .stat-row {
    flex-wrap: wrap;
  }

  .stat-item {
    flex: 1 1 45%;
    border-right: none;
    border-bottom: 1px solid var(--color-hairline);
  }

  .stat-item:nth-last-child(-n+2) {
    border-bottom: none;
  }

  .contacts-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Changelog page ──────────────────────────────────────────────────── */
/* A reading timeline, not a data surface: it borrows the .card container
   grammar (ivory pane) and adds only layout. Every color, size and radius
   below resolves through the :root vocabulary pinned by
   spec/design_tokens_spec.rb, so this section adds rules only and the
   token closure spec stays untouched. */

.changelog-page {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxl);
}

/* The intro is a lede, not a section label: it drops the shared .card h2
   raked plate and the tracked-caps shout — sentence case at the one size,
   ranking by weight. Number Reigns: the loudest type on this page is a
   mono version numeral at 700, never a heading. */
.changelog-intro h2 {
  font-size: var(--font-size-body);
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-ink);
  padding: 0;
  margin-bottom: 0;
}

.changelog-intro h2::before {
  display: none;
}

.changelog-lede {
  margin-top: var(--spacing-sm);
  color: var(--color-muted-ink);
}

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

/* Head grammar shared by release cards and era bands: number, headline,
   date on one baseline row, wrapping to full lines when narrow. */
.release-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--spacing-sm) var(--spacing-md);
}

/* Number Reigns in the world grammar: the version is the page's loudest
   type by FACE and WEIGHT — the mono data face at 700, tabular numerals
   keeping the ledger rhythm — never by size (the one-size rule). */
.release-card .release-version {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  font-weight: 700;
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
}

.release-title {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-ink);
}

/* Dates are codes: mono, muted. */
.release-date {
  margin-left: auto;
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
}

.release-summary {
  margin-top: var(--spacing-md);
  color: var(--color-body-ink);
}

.release-items {
  list-style: none;
  margin-top: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.release-items li {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.release-item-text {
  color: var(--color-body-ink);
}

/* Kind chips — badge convention (0.2rem 0.5rem) on the chip species: the
   accent tint carries feature, the ramp carries improvement, and fix is
   the outline variant (line border on ivory). Traffic-Only holds: neither
   chip borrows the up/down pair. */
.kind-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 500;
  flex-shrink: 0;
}

.kind-chip--feature {
  background: var(--color-accent-fill-soft);
  color: var(--color-accent-ink);
}

.kind-chip--improvement {
  background: var(--color-bed-inset);
  color: var(--color-body-ink);
}

.kind-chip--fix {
  background: var(--color-bed-raised);
  color: var(--color-muted-ink);
  border: 1px solid var(--color-line);
}

/* "Qué podés probar": a sunken well inside the card — one step down the
   ramp from the ivory pane, the same well treatment the world uses for
   inset surfaces. */
.release-try {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--color-bed-sunken);
  border-radius: var(--radius-md);
}

.release-try-title {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-ink);
}

.release-try ul {
  list-style: disc;
  margin: var(--spacing-sm) 0 0 var(--spacing-xl);
  color: var(--color-body-ink);
}

.release-internal {
  margin-top: var(--spacing-md);
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  /* Provenance lines quote long machine identifiers (table names, rake
     tasks). They fit at the old sub-body size; at the world's one size
     they overflow the card and push documentElement past the viewport —
     the chat-bubble anywhere-wrap rule for the same hazard. */
  overflow-wrap: anywhere;
}

/* Era band: a recessed chapter divider. Bed-sunken with no shadow — one
   step below the .card ivory pane so releases sit and eras recede. */
.changelog-era {
  background: var(--color-bed-sunken);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg) var(--spacing-xl);
}

/* The era's range number never outranks a release version: same mono
   face, same weight, one rung down the ink ramp. */
.changelog-era .release-version {
  color: var(--color-body-ink);
}

.changelog-era .release-title {
  color: var(--color-body-ink);
}

.changelog-era .release-summary {
  color: var(--color-muted-ink);
}

@media (max-width: 768px) {
  .changelog-page {
    gap: var(--spacing-lg);
  }

  .changelog-era {
    padding: var(--spacing-md);
  }

  .release-date {
    margin-left: 0;
    flex-basis: 100%;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   CHAT TAB
   ══════════════════════════════════════════════════════════════════════ */
/* A conversation surface, not a data grid. The page widens past the
   changelog's 820px to host the history sidebar; the transcript column
   inside keeps that reading width (1100 − 280 sidebar − lg gap ≈ 804px). */
.chat-page {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* Two columns: transcript + composer left, history right. align-items:
   flex-start keeps the short sidebar from stretching down to the
   composer's height — it is chrome, not a peer panel. */
.chat-layout {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-lg);
}

/* min-width: 0 lets the column shrink (and its ellipsis work) instead of
   the flex row overflowing on narrow viewports. */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.chat-header {
  display: flex;
  align-items: center;
}

/* The header is a page title, not a section label: no raked plate, no
   tracked caps — the one size at 700, sentence case (the changelog-intro
   precedent). */
.chat-header h2 {
  font-size: var(--font-size-body);
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-ink);
  margin-bottom: 0;
}

/* The frame itself is the scroll container, so a long conversation
   scrolls inside the pane while the composer stays put. 55vh keeps both
   halves on first paint. The transcript is an ivory reading pane — glass
   is for data grids, conversation is reading. */
.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  background: var(--color-bed-raised);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
  max-height: 55vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Bubbles: the user's own words take the celeste fill with carbon text
   (the one fill/text pair that passes on celeste) and a softened tail
   corner; assistant answers recede into bed-sunken wells. 85% width keeps
   a reading line, and anywhere-wrap keeps a long URL from stretching the
   scroll container sideways. */
.chat-message {
  max-width: 85%;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-body);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* simple_format emits one <p> per paragraph block; consecutive blocks
   get the transcript's smallest rhythm step. */
.chat-message p + p {
  margin-top: var(--spacing-sm);
}

.chat-message--user {
  align-self: flex-end;
  background: var(--color-accent);
  color: var(--color-ink);
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message--assistant {
  align-self: flex-start;
  background: var(--color-bed-sunken);
  color: var(--color-body-ink);
  border: 1px solid var(--color-hairline);
  border-bottom-left-radius: var(--radius-sm);
}

/* Failure answers (provider died, question rejected): the rust family at
   its softest — tinted, never shouting. The row must read as "something
   went wrong", not as the model's answer. */
.chat-message--assistant.chat-message--failure {
  background: var(--color-alert-fill-soft);
  border-color: var(--color-alert-line);
  color: var(--color-alert-ink);
}

/* Assistant markdown prose: the bubble renders sanitized GFM (bold, lists,
   tables, code), so the sunken well needs its own micro typography. In
   the world grammar there is no size scale to shrink onto — headings rank
   by weight at the one size. Scoped to .chat-message--assistant only —
   failure rows render plain text (simple_format), so these rules never
   fire there. The global reset zeroes element margins, so every block's
   rhythm is declared here, with the first-child reset keeping the
   bubble's top padding as the only leading. */
.chat-message--assistant h3,
.chat-message--assistant h4 {
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 1.3;
}

.chat-message--assistant h3 {
  color: var(--color-ink);
}

.chat-message--assistant h4 {
  color: var(--color-body-ink);
}

.chat-message--assistant ul,
.chat-message--assistant ol {
  padding-left: var(--spacing-lg);
}

/* 0.25rem is deliberately not a spacing token: list items are one step
   tighter than the paragraph rhythm (sm) — a compact run of bullets, not
   separate blocks (the pending-dot precedent). */
.chat-message--assistant li + li {
  margin-top: 0.25rem;
}

/* GFM tables on the ivory table grammar, compressed to bubble scale:
   hairline borders, a header row one step deeper than the sunken well
   (bed-inset against bed-sunken), tracked-caps headers per the table
   grammar, sm cell padding. width:100% plus the bubble's inherited
   overflow-wrap keeps wide answer tables inside the 85% column. */
.chat-message--assistant table {
  width: 100%;
  border-collapse: collapse;
}

.chat-message--assistant th,
.chat-message--assistant td {
  padding: var(--spacing-sm);
  text-align: left;
  border: 1px solid var(--color-hairline);
}

.chat-message--assistant th {
  background: var(--color-bed-inset);
  font-weight: 600;
  color: var(--color-body-ink);
  font-size: var(--font-size-body);
  letter-spacing: var(--tracking-caps);
}

/* Code: the mono data face — codes and machine output are mono per the
   world grammar (§1.9), and the world OWNS a data face now (IBM Plex
   Mono, vendored), so the old ride-the-UA-monospace compromise is
   retired. The chip is a bed-inset well at sm radius; inline code takes
   em paddings (a chip, not a rhythm step); pre is a block that scrolls
   its own long lines instead of stretching the transcript. */
.chat-message--assistant code {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  background: var(--color-bed-inset);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

.chat-message--assistant pre {
  font-family: var(--font-data);
  background: var(--color-bed-inset);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md);
  overflow-x: auto;
  line-height: 1.5;
}

/* pre > code is content, not a chip: undo the inline well inside blocks. */
.chat-message--assistant pre code {
  background: none;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
}

.chat-message--assistant blockquote {
  border-left: 1px solid var(--color-line);
  padding-left: var(--spacing-md);
  color: var(--color-muted-ink);
}

.chat-message--assistant a {
  color: var(--color-accent-ink);
}

.chat-message--assistant a:hover {
  color: var(--color-ink);
}

.chat-message--assistant hr {
  border: none;
  border-top: 1px solid var(--color-hairline);
}

/* Block rhythm: consecutive markdown blocks get the transcript's smallest
   step (p + p lives above, shared with the user bubble). */
.chat-message--assistant > h3 + *,
.chat-message--assistant > h4 + *,
.chat-message--assistant > ul + *,
.chat-message--assistant > ol + *,
.chat-message--assistant > pre + *,
.chat-message--assistant > blockquote + *,
.chat-message--assistant > table + *,
.chat-message--assistant > hr + *,
.chat-message--assistant > * + h3,
.chat-message--assistant > * + h4,
.chat-message--assistant > * + ul,
.chat-message--assistant > * + ol,
.chat-message--assistant > * + pre,
.chat-message--assistant > * + blockquote,
.chat-message--assistant > * + table,
.chat-message--assistant > * + hr,
.chat-message--assistant > p + h3,
.chat-message--assistant > p + h4,
.chat-message--assistant > p + ul,
.chat-message--assistant > p + ol,
.chat-message--assistant > p + pre,
.chat-message--assistant > p + blockquote,
.chat-message--assistant > p + table,
.chat-message--assistant > p + hr {
  margin-top: var(--spacing-sm);
}

/* The first block leads flush against the bubble's padding, never a double
   gap. :first-child (not of-type) so whichever block opens the answer
   behaves the same. */
.chat-message--assistant > h3:first-child,
.chat-message--assistant > h4:first-child,
.chat-message--assistant > ul:first-child,
.chat-message--assistant > ol:first-child,
.chat-message--assistant > pre:first-child,
.chat-message--assistant > blockquote:first-child,
.chat-message--assistant > table:first-child {
  margin-top: 0;
}

/* Provenance label (Gemini · gemini-2.5-flash): mono muted under the
   bubble's body ink — provenance is a code line, not content. */
.chat-provenance {
  display: block;
  margin-top: var(--spacing-sm);
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  font-weight: 400;
  color: var(--color-muted-ink);
}

/* Composer: the house ivory-pane grammar, one column — question textarea
   full width, controls row beneath (provider, optional model, Send). */
.chat-composer {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  background: var(--color-bed-raised);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

/* Two comfortable rows above the .input 44px floor; vertical-only resize
   cannot fight the pane's width. */
.chat-composer-text {
  min-height: 88px;
  resize: vertical;
}

.chat-composer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--spacing-md);
}

.chat-composer-field {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Labels: tracked caps at 600 in carbon — rank by weight and case, never
   by size (the auth field-label grammar). */
.chat-composer-field label {
  font-size: var(--font-size-body);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  color: var(--color-ink);
}

.chat-composer select {
  cursor: pointer;
}

/* Send right-aligns opposite the fields (the .filter-actions idiom). */
.chat-composer-controls .btn {
  margin-left: auto;
}

/* Pending placeholder bubble (chat v2): appended inside the transcript by
   the create stream while the background turn runs, replaced by the real
   answer on the poller's frame reload. Assistant bubble grammar with
   animated dots — no text, so nothing to localize and no timer to keep
   honest. Muted-ink dots on the sunken assistant well. */
.chat-message--pending {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* 6px is deliberately not a spacing token: it is a dot, not a rhythm step
   in the spacing scale — the closest token (8px) reads as a bullet at
   this scale. */
.chat-pending-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-muted-ink);
  animation: chat-pending-pulse 1.2s ease-in-out infinite;
}

.chat-pending-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-pending-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-pending-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-pending-dot {
    animation: none;
    opacity: 0.6;
  }

  /* The disabled + opacity state still says "in flight" without the spin. */
  .btn-icon.syncing svg {
    animation: none;
  }
}

/* Conversation history sidebar (history slice): a quiet picker beside the
   conversation — no pane of its own, the items ARE the surface (ramp
   inset wells on the crema bed, the season-pill grammar as rows), so the
   sidebar reads as chrome, never as a peer of the transcript. */
.chat-history {
  flex-shrink: 0;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.chat-history-reset {
  width: 100%;
}

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* One row per conversation: the whole well is the hit area (the link
   fills it), the delete affordance rides at the tail inside the same
   well. */
.chat-history-item {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-sm);
  background: var(--color-bed-inset);
  transition: background-color 0.2s ease-out;
}

.chat-history-item:hover {
  background: var(--color-bed-sunken);
}

/* Active row: the celeste fill with carbon text — the same "selected"
   endpoint the primary buttons and the active season pill use; the
   conversation on screen is the selected one. */
.chat-history-item--active,
.chat-history-item--active:hover {
  background: var(--color-accent);
}

.chat-history-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-sm) var(--spacing-md);
  text-decoration: none;
}

.chat-history-title {
  font-size: var(--font-size-body);
  font-weight: 500;
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dates are codes: mono, muted. */
.chat-history-date {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
}

.chat-history-item--active .chat-history-title {
  color: var(--color-ink);
}

.chat-history-item--active .chat-history-date {
  color: var(--color-ink);
  opacity: 0.75;
}

/* button_to wraps the delete control in a form — neutralize it so the
   button centers against the row instead of adding an inline gap. */
.chat-history-item form.button_to {
  display: flex;
  align-items: center;
}

/* 32px is deliberately not a token: a compact tail affordance next to a
   link that already carries the row's tap target, not a primary action
   on the 44px .btn floor. */
.chat-history-delete {
  margin-right: var(--spacing-sm);
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: var(--radius-xs);
  color: var(--color-muted-ink);
  font-size: var(--font-size-body);
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

/* Destructive hover: the rust family at its softest, never a filled red
   button sitting beside every row. */
.chat-history-delete:hover {
  color: var(--color-down-ink);
  background: var(--color-alert-fill-soft);
}

/* On the celeste active row the delete reads in carbon; its destructive
   hover swaps to the full rust pair (fill + ivory text). */
.chat-history-item--active .chat-history-delete {
  color: var(--color-ink);
}

.chat-history-item--active .chat-history-delete:hover {
  color: var(--color-bed-raised);
  background: var(--color-alert-fill);
}

@media (max-width: 640px) {
  .chat-message {
    max-width: 92%;
  }

  .chat-transcript {
    padding: var(--spacing-lg);
  }

  .chat-composer {
    padding: var(--spacing-lg);
  }

  /* Thumb-width band: Send goes full width instead of squeezing the two
     fields it shares the row with. */
  .chat-composer-controls .btn {
    width: 100%;
    margin-left: 0;
  }

  /* History collapses to a horizontally scrollable chip row ABOVE the
     conversation: switching is the page-level action, and chips keep
     every entry one tap away with pure CSS — no disclosure widget, no
     JS, the same DOM reflows. order: -1 lifts the aside (declared after
     .chat-main for the desktop reading order) above the transcript. */
  .chat-layout {
    flex-direction: column;
  }

  .chat-history {
    order: -1;
    width: 100%;
  }

  .chat-history-list {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--spacing-sm);
  }

  .chat-history-item {
    flex: 0 0 auto;
    max-width: 240px;
  }
}

/* ── ITINERARIOS MODULE (plan 009, T4) ────────────────────────────────
   The catalog section's reading surfaces: page frame, resource
   switcher, card grid, detail pages, forms and the photo manager.
   Ivory panes throughout — the catalog is a reading/loading surface,
   not a data grid, so glass stays with the dashboard's charts. Every
   color rides the shared tokens; the module adds vocabulary, not
   palette. */

.itineraries-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Resource switcher under the header tab: the five card families are
   peers the team hops between, so the rail is one row of quiet links.
   Active state is the ink swap + celeste underline stroke — the season
   pill grammar, rank by contrast not size. */
.catalog-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
}

.catalog-subnav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease-out, border-color 0.2s ease-out;
}

.catalog-subnav-link:hover {
  color: var(--color-ink);
}

.catalog-subnav-link.active {
  color: var(--color-accent-ink);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

/* Page title row: sentence case at 700 (the chat-header/changelog-intro
   precedent — page titles are not section plates), actions right. */
.resource-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
}

.resource-heading {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  min-width: 0;
}

.resource-title {
  font-size: var(--font-size-body);
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  color: var(--color-ink);
  margin: 0;
  overflow-wrap: anywhere;
}

.resource-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
}

.resource-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* The delete button's inline form must not stretch between the action
   row's flex items. */
.resource-delete-form {
  display: inline-flex;
  margin: 0;
}

/* Destructive action: the alert pair (soft fill, alert ink), never the
   solid red — a catalog delete is a considered action, not a siren. */
.btn-danger {
  background: var(--color-alert-fill-soft);
  color: var(--color-alert-ink);
}

.btn-danger:hover,
.btn-danger:active {
  background: var(--color-alert-fill);
  color: var(--color-on-glass);
}

/* ── The card grid ────────────────────────────────────────────────── */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--spacing-lg);
}

/* A catalog card is one big link (thumbnail, name, badge — the whole
   surface is the target, the 44px floor everywhere). Layout only; the
   pane itself is the shared .card species. */
.catalog-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  text-decoration: none;
  color: var(--color-on-ivory-ink);
}

/* Thumb well: fixed aspect whatever the upload's shape — the variant
   already cropped to the slot, this keeps the grid's rhythm. The well
   is sunken (a bed for the image), so no border on the img itself. */
.catalog-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-bed-sunken);
  display: block;
}

/* Photoless placeholder: the sunken well with a faint frame glyph —
   a broken <img> icon is a lie, an empty bed says "load me". The SVG
   fill is %23-encoded to keep the no-hex-literal rule intact (the
   --icon-search precedent in :root). */
.catalog-thumb--empty {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E655A' stroke-width='1.25'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='10' r='1.75'/%3E%3Cpath d='M4.5 17.5 10 12l3.5 3.5L16 13l3.5 3.5'/%3E%3C/svg%3E") center center / 48px 48px no-repeat,
    var(--color-bed-sunken);
}

.catalog-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.catalog-card-name {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

.catalog-card-meta {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  min-height: 1.4em;
}

/* The card's completeness fraction: mono numerals (marks and numerals
  are mono — §1.9) in a chip. Progress ink, never traffic ink: the
  Traffic-Only Rule reserves up/down coloration for growth/decline. */
.completeness-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2rem 0.5rem;
  background: var(--color-bed-inset);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-sm);
  font-family: var(--font-data);
  font-size: var(--font-size-body);
  color: var(--color-body-ink);
}

/* ── Detail page: the per-field mark row ──────────────────────────── */

.completeness-marks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm) var(--spacing-lg);
  list-style: none;
  margin: var(--spacing-lg) 0 0;
  padding: 0;
}

.completeness-marks li {
  font-size: var(--font-size-body);
  color: var(--color-faint-ink);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.completeness-marks li::before {
  /* Open/done circles in mono: the mark IS the state, words carry it —
     accent-ink for done (the celeste mark), faint for the gap. No
     traffic colors (progress, not growth). */
  content: '○';
  font-family: var(--font-data);
  color: var(--color-faint-ink);
}

.completeness-marks li.is-done {
  color: var(--color-body-ink);
}

.completeness-marks li.is-done::before {
  content: '●';
  color: var(--color-accent-ink);
}

/* Detail rows already ride the shared .detail-row grammar; the prose
   variant just lets long descriptions breathe next to their label. */
.detail-prose {
  max-width: 60ch;
  white-space: pre-line;
}

/* ── The photo gallery (show pages) ───────────────────────────────── */

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-lg);
}

.photo-gallery-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.photo-gallery-item img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-hairline);
  display: block;
}

.photo-role-badge {
  align-self: flex-start;
  text-transform: none;
}

/* ── Forms ────────────────────────────────────────────────────────── */

.form-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-lg) var(--spacing-xl);
  align-items: start;
}

/* Full-rail fields (aliases, descriptions, comma lists, photo upload):
  span every column so the reading rhythm is field pairs with the long
  inputs on their own lines. */
.field--full {
  grid-column: 1 / -1;
}

.field .field-hint {
  font-size: var(--font-size-body);
  color: var(--color-faint-ink);
  margin: 0.375rem 0 0;
}

.input-textarea {
  resize: vertical;
  font-family: inherit;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

/* Inline validation box: the alert family's softest register — soft
   fill, alert ink, no siren solid. It renders INSIDE the form so the
   422 re-render keeps every typed value. */
.form-errors {
  background: var(--color-alert-fill-soft);
  border: 1px solid var(--color-alert-line);
  border-radius: var(--radius-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.form-errors-title {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-alert-ink);
  margin: 0 0 0.375rem;
}

.form-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.form-errors li {
  font-size: var(--font-size-body);
  color: var(--color-alert-ink);
}

/* ── The photo manager (edit pages) ───────────────────────────────── */

.photo-manager-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* One photo row: grip, thumb, role select. draggable="true" is set in
   the markup; the cursor says so here. The row is a sunken well (the
   image's bed), so dragging reads as moving the well. */
.photo-manager-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  background: var(--color-bed-sunken);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm);
  cursor: grab;
}

.photo-manager-row--dragging {
  opacity: 0.5;
}

/* The drop marker: a celeste hairline on the insertion edge — the
   traveling-light family's thinnest stroke, not a filled outline. */
.photo-manager-row--over {
  box-shadow: inset 0 2px 0 0 var(--color-accent);
}

.photo-manager-grip {
  font-size: var(--font-size-body);
  color: var(--color-faint-ink);
  min-width: 1.25rem;
  text-align: center;
}

.photo-manager-thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  display: block;
}

.photo-manager-role {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* The role select stays compact (auto width, not the full .input
   stretch): it annotates the row, it is not the row's main field. */
.photo-role-select {
  width: auto;
  min-height: 44px;
}

/* Status line: the polite live region the Stimulus controller speaks
   through. Quiet muted ink; --error swaps to alert ink, same bed. */
.photo-manager-status {
  font-size: var(--font-size-body);
  color: var(--color-faint-ink);
  margin: var(--spacing-md) 0 0;
  min-height: 1.5em;
}

.photo-manager-status--error {
  color: var(--color-alert-ink);
}

@media (max-width: 768px) {
  /* The form grid folds to one column at phone width: field pairs read
     top-to-bottom, nothing narrower than the gutter. */
  .form-fields {
    grid-template-columns: 1fr;
  }

  /* The role select hops under the thumb on narrow rows: 72px thumb +
     select side by side still fits 390px with the grip. */
  .photo-manager-row {
    flex-wrap: wrap;
  }

  .photo-manager-role {
    margin-left: calc(1.25rem + var(--spacing-md) + 72px);
  }
}

/* ── Phase 5 (T20): the itinerary review surface ─────────────────── */

/* The queue's rows: one ivory pane per itinerary, dense — client and
   title on the left, the two marks that rank the work (status pill,
   version numeral) on the right. The pane is the shared .card species;
   the row's own padding tightens it from a reading card to a list row. */
.itinerary-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.itinerary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  text-decoration: none;
  color: var(--color-on-ivory-ink);
}

.itinerary-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.itinerary-row-title {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

.itinerary-row-client {
  font-size: var(--font-size-body);
  color: var(--color-muted-ink);
  min-width: 0;
}

.itinerary-row-side {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-shrink: 0;
}

/* Status pills: the meta chip by default (pipeline in flight, done —
   states, not work). needs_review is the queue's actionable state, so
   it wears the celeste badge family ("where you operate"); failed is
   the only broken state and takes the alert family at its softest.
   No traffic inks: nothing grows or declines on this surface. */
.status-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-sm);
  background: var(--color-bed-inset);
  color: var(--color-body-ink);
  font-size: var(--font-size-body);
  font-weight: 500;
}

.status-pill--needs_review {
  border-color: transparent;
  background: var(--color-accent-fill-soft);
  color: var(--color-accent-ink);
  font-weight: 600;
}

.status-pill--failed {
  border-color: var(--color-alert-line);
  background: var(--color-alert-fill-soft);
  color: var(--color-alert-ink);
}

/* Version numerals are marks: mono, in the inset chip (the changelog's
   numeral grammar — loud by face, never by size). */
.version-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-bed-inset);
  border: 1px solid var(--color-hairline);
  color: var(--color-body-ink);
  font-family: var(--font-data);
  font-size: var(--font-size-body);
}

/* The review page: preview pane left, honesty panels right, folding to
   a single column at the analysis-row breakpoint. */
.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--spacing-xl);
  align-items: start;
}

.review-side {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  min-width: 0;
}

@media (max-width: 1024px) {
  .review-grid {
    grid-template-columns: 1fr;
  }
}

/* The A4 preview frame: max-width is A4 at CSS 96dpi (794px) so the
   document reads at its true page proportion, with an internal scroll
   for the stacked pages. Bed-raised ground behind the sheet, one line
   border — a paper document lying on the bed, not app chrome. The
   sandboxed srcdoc content carries its own self-contained print CSS. */
.itinerary-preview-frame {
  display: block;
  width: 100%;
  max-width: 794px;
  height: 72vh;
  min-height: 480px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-bed-raised);
}

/* Validation issues: errors lead (alert family — impossible data),
   warnings follow (celeste family — work to do). The mono code is a
   mark; the message is prose. */
.issue-list,
.missing-photo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.issue-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid;
  border-radius: var(--radius-sm);
}

.issue-item--error {
  border-color: var(--color-alert-line);
  background: var(--color-alert-fill-soft);
  color: var(--color-alert-ink);
}

.issue-item--warning {
  border-color: transparent;
  background: var(--color-accent-fill-soft);
  color: var(--color-accent-ink);
}

.issue-code {
  font-family: var(--font-data);
  font-size: var(--font-size-body);
}

/* Missing photo slots: the slot name in a mono tag chip plus the page
   it belongs to — a gap is stated, never decorated. */
.missing-photo-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--color-body-ink);
}

.review-empty {
  color: var(--color-faint-ink);
  font-style: italic;
}

/* The per-page editor: an ordered list mirroring the preview's page
   order. Hairline rules between pages; the index numeral is a mono
   mark; locked pages say so in faint ink instead of silently bouncing
   the post. */
.review-page-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.review-page + .review-page {
  border-top: 1px solid var(--color-line);
  padding-top: var(--spacing-lg);
}

.review-page-head {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.review-page-index {
  font-family: var(--font-data);
  color: var(--color-muted-ink);
}

.review-page-label {
  font-size: var(--font-size-body);
  font-weight: 600;
  color: var(--color-ink);
}

.review-page-locked {
  color: var(--color-faint-ink);
}

.review-page-note {
  margin: var(--spacing-sm) 0 0;
  color: var(--color-faint-ink);
}

/* Inline edit forms: quiet, reading-width, one submit per page — the
   work surface vocabulary, never a settings page. */
.inline-edit-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-sm);
  max-width: 60ch;
  margin: var(--spacing-md) 0 0;
}

/* Manual flights: a dense grid row per flight (five inputs + remove),
   collapsing to pairs at phone width. Labels are sr-only by
   containment — see the partial. */
.flight-rows {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0 0;
}

.flight-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.2fr) 44px;
  gap: var(--spacing-sm);
  align-items: center;
}

.flight-cell {
  display: block;
  min-width: 0;
}

.flight-remove {
  justify-self: end;
}

@media (max-width: 768px) {
  .flight-row {
    grid-template-columns: 1fr 1fr;
  }

  .flight-remove {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
