/* ============================================
   DESIGN TOKENS
   Runtime custom-property layer. Colors, type,
   radii and shadows 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. Typography is size-sorted
   here, not frontmatter-ordered. Colors, type,
   radii and shadows are token-only at the call
   site: consume with var(--…), never hardcode.
   Spacing is tokenized only when every length
   in the declaration is on the scale; off-scale
   spacing is deliberate (see DESIGN.md Layout).
   ============================================ */
:root {
  /* Colors: primary */
  --color-signal-blue: #3b82f6;
  --color-signal-blue-deep: #2563eb;
  /* Colors: traffic pair */
  --color-traffic-emerald: #10b981;
  --color-traffic-emerald-deep: #059669;
  --color-alert-red: #ef4444;
  --color-alert-red-deep: #dc2626;
  /* Colors: neutrals */
  --color-canvas: #f5f5f5;
  --color-surface: #ffffff;
  --color-surface-sunken: #f9fafb;
  --color-surface-inset: #f3f4f6;
  --color-line: #e5e7eb;
  --color-hairline: #eeeeee;
  --color-input-line: #d1d5db;
  --color-ink: #1a1a1a;
  --color-body-ink: #333333;
  --color-muted-ink: #666666;
  --color-label-ink: #374151;
  --color-graphite-ink: #1f2937;
  --color-steel-ink: #4b5563;
  --color-slate-ink: #6b7280;
  --color-faint-ink: #9ca3af;
  /* Colors: fills */
  --color-badge-blue-fill: #eff6ff;
  --color-notice-fill: #d1fae5;
  --color-notice-ink: #065f46;
  --color-notice-line: #a7f3d0;
  --color-alert-fill: #fee2e2;
  --color-alert-ink: #991b1b;
  --color-alert-line: #fecaca;
  --color-alert-fill-soft: #fef2f2;
  --color-alert-text: #b91c1c;
  /* Colors: accent flourish endpoints (metric-card hover strips only) */
  --color-accent-blue-soft: #60a5fa;
  --color-accent-emerald-soft: #34d399;
  --color-accent-amber: #f59e0b;
  --color-accent-amber-soft: #fbbf24;
  --color-accent-violet: #8b5cf6;
  --color-accent-violet-soft: #a78bfa;
  --color-accent-pink: #ec4899;
  --color-accent-pink-soft: #f472b6;
  /* Colors: scrollbar */
  --color-scrollbar-thumb: #c1c1c1;
  --color-scrollbar-thumb-hover: #a1a1a1;
  /* Typography (largest → smallest) */
  --font-size-display: clamp(1.625rem, 2vw + 1.25rem, 2.75rem);
  --font-size-heading-lg: 1.5rem;
  --font-size-heading-md: 1.375rem;
  --font-size-headline: 1.25rem;
  --font-size-body: 1rem;
  --font-size-action: 0.9375rem;
  --font-size-title: 0.875rem;
  --font-size-caption: 0.8125rem;
  --font-size-label: 0.75rem;
  --font-size-micro: 0.6875rem;
  --font-size-marker: 0.625rem;
  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --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 < hover < toast < modal) */
  --shadow-rest: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-hover: 0 8px 16px rgba(0,0,0,0.1);
  --shadow-soft-hover: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-toast: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-modal: 0 4px 24px rgba(0,0,0,0.1);
  /* Outside the rank ladder: input focus halo, not an elevation */
  --shadow-focus-ring: 0 0 0 3px rgba(59,130,246,0.15);
  /* 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. */
  --category-color: var(--color-faint-ink);
}

/* 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 */
html {
  scroll-behavior: smooth;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-canvas);
  color: var(--color-body-ink);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  caret-color: var(--color-signal-blue);
}

/* Keyboard focus rings, themed from the palette. Input controls are
   excluded: the shared .input control pairs the border shift with its 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 {
  outline: 2px solid var(--color-signal-blue);
  outline-offset: 2px;
}

/* Ledger precision: tabular numerals wherever data is counted */
.metric-card .value,
.metric-card .delta,
.frequency-item .count,
.partner-item .count,
.data-table td,
.airport-card .count,
.last-sync {
  font-variant-numeric: tabular-nums;
}

/* Header */
.header {
  background: var(--color-surface);
  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;
  gap: var(--spacing-sm);
}

.logo {
  font-size: var(--font-size-headline);
  font-weight: 700;
  color: var(--color-ink);
}

.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;
}

.last-sync {
  font-size: var(--font-size-caption);
  color: var(--color-muted-ink);
}

.btn {
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-title);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  min-height: 44px;
  min-width: 44px;
}

.btn-primary {
  background: var(--color-signal-blue);
  color: var(--color-surface);
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--color-signal-blue-deep);
}

.btn-secondary {
  background: var(--color-traffic-emerald);
  color: var(--color-surface);
}

.btn-secondary:hover,
.btn-secondary:active {
  background: var(--color-traffic-emerald-deep);
}

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

/* 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: one section card grouping the shared season nav and the
   five metric cards, mirroring .chart-section/.col so the pills sit inside
   the section like every other selector. The Rank Rule forbids shadowed
   cards stacked on a card, so the inner cards step DOWN a rank: Surface
   Sunken wells (the table-header/city-card level) with no shadow — the
   wrapper floats, the wells recede, and hover still lifts a card out of
   its well. */
.metrics-section {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

.metrics-section .metric-card {
  background: var(--color-surface-sunken);
  box-shadow: none;
}

/* Neutral delta pills ("Active", "Per Passenger") are Surface Sunken at
   the top level; on the sunken wells they would dissolve, so inside the
   band they drop one step to Surface Inset. */
.metrics-section .metric-card .delta:not(.positive):not(.negative) {
  background: var(--color-surface-inset);
}

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

.metric-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

.metric-card h3 {
  font-size: var(--font-size-title);
  color: var(--color-muted-ink);
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.metric-card .value {
  font-size: var(--font-size-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  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-pill);
  font-size: var(--font-size-label);
  font-weight: 600;
  width: fit-content;
}

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

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

/* Neutral pill for non-status labels (e.g. "Per Passenger") */
.metric-card .delta:not(.positive):not(.negative) {
  background: var(--color-surface-sunken);
  color: var(--color-muted-ink);
}

/* Charts */
.chart-section {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

.chart-section h2,
.card h2,
.col h2,
.origin-map h2 {
  font-size: var(--font-size-headline);
  font-weight: 600;
  color: var(--color-ink);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--color-hairline);
  margin-bottom: var(--spacing-lg);
}

/* Generic section card for non-chart surfaces (today: the client detail
   pages and the clients index table). Deliberately the same container
   treatment as .chart-section — one card system, not a second family —
   minus the hover lift: these are static reading surfaces, so they hold
   Rest rank permanently (Rank Rule: only an interacted-with surface may
   rise). */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

.chart-container {
  height: 300px;
  position: relative;
}

/* Season selector (season-scoped dashboard sections): one row of pill links
   above the charts. Inactive pills stay recessive (Surface Inset + Label
   Ink); the active one carries Signal Blue — the design system's selection
   color — with white text. 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 {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface-inset);
  color: var(--color-label-ink);
  font-size: var(--font-size-title);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease;
}

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

.season-selector .season-pill.active {
  background: var(--color-signal-blue);
  color: var(--color-surface);
  font-weight: 600;
}

.season-selector .season-pill.active:hover {
  background: var(--color-signal-blue-deep);
}

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

/* 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 regions. 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 swap region 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 region frames nest inside the gapped .dashboard flex
   column; their own sections would lose that vertical rhythm, so each
   region 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 {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-rest);
}

/* Tables */
.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-hairline);
}

.data-table th {
  background: var(--color-surface-sunken);
  font-weight: 600;
  color: var(--color-muted-ink);
  font-size: var(--font-size-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

/* Repeat-clients table: the client's indexed chart color as a leading dot,
   mirroring the partner-item dot. */
.data-table .color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: var(--spacing-sm);
  vertical-align: middle;
}

/* Frequency lists */
.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-weight: 600;
  color: var(--color-muted-ink);
  width: 2rem;
  font-size: var(--font-size-title);
}

.frequency-item .name {
  flex: 1;
  font-size: var(--font-size-title);
}

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

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

.frequency-item .count {
  font-weight: 600;
  width: 3rem;
  text-align: right;
  font-size: var(--font-size-title);
}

/* Origin map */
.origin-map {
  background: var(--color-surface);
  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-surface-sunken);
  border-radius: var(--radius-md);
}

.city-card .rank {
  font-weight: 600;
  color: var(--color-muted-ink);
  width: 2rem;
}

.city-card .city {
  flex: 1;
  font-size: var(--font-size-title);
}

.city-card .count {
  font-weight: 600;
  font-size: var(--font-size-title);
}

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

.airport-section h3 {
  font-size: var(--font-size-title);
  font-weight: 600;
  color: var(--color-label-ink);
  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-surface-inset);
  border-radius: var(--radius-sm);
}

.airport-card .rank {
  font-weight: 600;
  color: var(--color-slate-ink);
  width: 1.5rem;
  font-size: var(--font-size-title);
}

.airport-card .code {
  flex: 1;
  font-size: var(--font-size-title);
  color: var(--color-graphite-ink);
}

.airport-card .count {
  font-weight: 600;
  color: var(--color-signal-blue-deep);
  font-size: var(--font-size-title);
}

/* Footer */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-hairline);
  padding: var(--spacing-xl) var(--spacing-xxl);
  text-align: center;
  margin-top: var(--spacing-xxl);
}

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

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash {
  position: fixed;
  top: 1rem;
  right: 1rem;
  padding: var(--spacing-lg) var(--spacing-xl);
  border-radius: var(--radius-md);
  font-size: var(--font-size-title);
  font-weight: 500;
  z-index: 1000;
  animation: slideIn 0.3s ease, fadeOut 0.5s ease 4.5s forwards;
  box-shadow: var(--shadow-toast);
}

@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-notice-fill);
  color: var(--color-notice-ink);
  border: 1px solid var(--color-notice-line);
}

.flash-alert {
  background: var(--color-alert-fill);
  color: var(--color-alert-ink);
  border: 1px solid var(--color-alert-line);
}

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

.user-email {
  font-size: var(--font-size-title);
  color: var(--color-muted-ink);
  font-weight: 500;
}

.btn-logout {
  background: var(--color-alert-red);
  color: var(--color-surface);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-title);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background-color 0.2s;
}

.btn-logout:hover {
  background: var(--color-alert-red-deep);
}

/* 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);
  }

  .header-nav {
    width: 100%;
    justify-content: space-between;
  }

  .sync-status {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .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 load-bearing: the ≤768px block gives .header-tabs
       order: 3 + width: 100%, so it must fall onto its own row. nowrap
       crams logo + tabs + nav into one min-content line that pushes
       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;
    /* Same collision, one level down: .sync-status carries order: 3 +
       width: 100% from the ≤768px block and needs its own centered row —
       nowrap here would overflow the nav line instead. */
    flex-wrap: wrap;
    align-items: center;
  }

  .last-sync {
    display: none;
  }

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

  .sync-status .btn {
    padding: 0.375rem 0.5rem;
    font-size: var(--font-size-label);
    min-height: 32px;
    min-width: auto;
  }

  .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);
  }

  .frequency-item .name {
    font-size: var(--font-size-caption);
  }

  .frequency-item .count {
    width: 2rem;
    font-size: var(--font-size-caption);
  }
}

/* ============================================
   MVP POLISH - Enhanced Visual Styles
   ============================================ */

/* Typography improvements */
h1, h2, h3 {
  letter-spacing: -0.025em;
}

.section-subtitle {
  margin-top: var(--spacing-xxl);
}

/* Metric card enhancements */
.metric-card {
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-signal-blue), var(--color-traffic-emerald));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-card:nth-child(1)::before { background: linear-gradient(90deg, var(--color-signal-blue), var(--color-accent-blue-soft)); }
.metric-card:nth-child(2)::before { background: linear-gradient(90deg, var(--color-traffic-emerald), var(--color-accent-emerald-soft)); }
.metric-card:nth-child(3)::before { background: linear-gradient(90deg, var(--color-accent-amber), var(--color-accent-amber-soft)); }
.metric-card:nth-child(4)::before { background: linear-gradient(90deg, var(--color-accent-violet), var(--color-accent-violet-soft)); }
.metric-card:nth-child(5)::before { background: linear-gradient(90deg, var(--color-accent-pink), var(--color-accent-pink-soft)); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: var(--font-size-label);
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--color-badge-blue-fill);
  color: var(--color-signal-blue-deep);
}

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

/* Section styling */
.chart-section,
.metrics-section,
.col,
.origin-map {
  transition: box-shadow 0.2s ease;
}

.chart-section:hover,
.metrics-section:hover,
.col:hover,
.origin-map:hover {
  box-shadow: var(--shadow-soft-hover);
}

/* Trend arrows on semantic pills */
.delta.positive::before {
  content: '▲';
  font-size: var(--font-size-marker);
}

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

/* Table improvements */
.data-table tbody tr {
  transition: background-color 0.15s ease;
}

/* City card enhancements */
.city-card {
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.city-card:hover {
  border-color: var(--color-line);
  transform: translateX(4px);
}

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

/* Touch feedback for mobile */
.metric-card:active,
.chart-section:active,
.metrics-section:active,
.col:active,
.origin-map:active,
.city-card:active {
  transform: scale(0.99);
  transition: transform 0.1s;
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Selection color */
::selection {
  background: var(--color-signal-blue);
  color: var(--color-surface);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface-inset);
}

::-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;
}

/* ============================================
   AUTHENTICATION (Devise)
   ============================================ */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 80px);
  padding: var(--spacing-lg);
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: var(--spacing-xl);
  width: 100%;
  max-width: 420px;
}

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

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

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

@media (min-width: 641px) {
  .auth-card h2 {
    font-size: var(--font-size-heading-lg);
  }
}

.auth-card .auth-subtitle {
  font-size: var(--font-size-title);
  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;
}

.field label {
  display: block;
  font-size: var(--font-size-title);
  font-weight: 600;
  color: var(--color-label-ink);
  margin-bottom: 0.375rem;
}

/* Shared input control (DESIGN.md Inputs): 1.5px Input Line border, 8px
   radius, white fill, 10px/14px padding and a 44px touch-target floor.
   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-md);
  font-size: var(--font-size-body);
  color: var(--color-label-ink);
  background: var(--color-surface);
  min-height: 44px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  box-sizing: border-box;
}

/* Focus pairs the Signal Blue border shift with the 3px 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-signal-blue);
  box-shadow: var(--shadow-focus-ring);
  outline: none;
}

.field em {
  font-size: var(--font-size-caption);
  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;
  font-size: var(--font-size-title);
  cursor: pointer;
}

.field input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-signal-blue);
  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;
  line-height: 0;
}

.password-toggle:hover {
  color: var(--color-slate-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-signal-blue);
  color: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-action);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

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

.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-title);
}

.auth-links a {
  color: var(--color-signal-blue);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

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

/* Auth error messages */
#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-title);
  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-caption);
  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-title);
  font-weight: 600;
  color: var(--color-alert-ink);
  margin-bottom: var(--spacing-sm);
}

.cancel-account .btn-danger {
  background: var(--color-alert-red);
  color: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: var(--font-size-caption);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

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

.back-link:hover {
  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-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, transform 0.15s ease;
  border: 1px solid var(--color-surface-inset);
}

.partner-item:hover {
  background: var(--color-surface-inset);
  transform: translateX(2px);
}

.partner-item .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  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-caption);
  font-weight: 500;
  color: var(--color-graphite-ink);
  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-size: var(--font-size-micro);
  font-weight: 600;
  color: var(--color-steel-ink);
  background: var(--color-line);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.partner-item .bar-container {
  flex: 1;
  background: var(--color-line);
  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-label);
  font-weight: 600;
  color: var(--color-label-ink);
  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;
    font-size: var(--font-size-micro);
  }
}

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

/* ── Header navigation tabs ────────────────────────────────────────── */
.header-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
}

.header-tab {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-muted-ink);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  height: 100%;
  min-height: 44px;
}

.header-tab:hover {
  color: var(--color-ink);
  border-bottom-color: var(--color-line);
}

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

/* Push tabs slightly so the header-content layout stays balanced */
.header-content {
  /* Override to accommodate tabs between logo and user controls */
  gap: 1.5rem;
}

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

/* ── Filter bar ─────────────────────────────────────────────────────── */
.client-filters {
  background: var(--color-surface);
  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;
}

.search-input {
  background-image: 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='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  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. */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.875rem;
  color: var(--color-muted-ink);
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

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

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 44px;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-signal-blue);
  background: transparent;
  border: 1.5px solid var(--color-signal-blue);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-export:hover {
  background: var(--color-signal-blue);
  color: var(--color-surface);
}

/* ── Client table ───────────────────────────────────────────────────── */
.client-table .sort-header {
  cursor: pointer;
  color: var(--color-label-ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.client-table .sort-header--active {
  color: var(--color-signal-blue);
}

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

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

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

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

.origin-cell {
  font-size: 0.8125rem;
  color: var(--color-steel-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-variant-numeric: tabular-nums;
}

.date-cell {
  font-size: 0.8125rem;
  color: var(--color-muted-ink);
  white-space: nowrap;
}

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

/* ── Pagination ─────────────────────────────────────────────────────── */
.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: 0.875rem;
  color: var(--color-signal-blue);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--color-signal-blue);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.page-link:hover {
  background: var(--color-signal-blue);
  color: var(--color-surface);
}

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

.result-count {
  text-align: center;
  padding: 0.75rem 0;
  font-size: 0.875rem;
}

/* ── 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;
}

.client-name-display {
  /* The heading-lg scale step (1.5rem) — a named size, not a coincidental
     literal. It tops the detail page's type but sits far under the metric
     Display step, so the Number Reigns hierarchy survives. */
  font-size: var(--font-size-heading-lg);
  font-weight: 700;
  color: var(--color-ink);
  margin: 0;
}

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

.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-surface-inset);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-graphite-ink);
}

.meta-chip--blue {
  background: var(--color-badge-blue-fill);
  border-color: transparent;
  color: var(--color-signal-blue-deep);
}

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

.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-surface-inset);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-xs);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-steel-ink);
  /* Uppercase Boundary Rule: no text-transform here — letter-spaced
     uppercase belongs to table headers and nothing else. 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: 0.875rem;
}

.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);
}

/* ── 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: 0.75rem;
  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-label-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: 0.875rem;
  color: var(--color-body-ink);
  font-weight: 500;
}

.contact-link {
  color: var(--color-signal-blue);
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

.contact-name {
  font-size: 0.8125rem;
}

/* ── Stats row ──────────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--color-surface);
  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;
}

.stat-value {
  /* heading-lg scale step — the largest type on the detail page, matching
     .client-name-display, still far under the metric Display step. */
  font-size: var(--font-size-heading-lg);
  font-weight: 700;
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  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; the
   Traffic-Only pair returns to traffic duty. */
.category-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 500;
  background: color-mix(in srgb, var(--category-color) 14%, var(--color-surface));
  color: color-mix(in srgb, var(--category-color) 30%, var(--color-ink));
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-tabs {
    order: 3;
    width: 100%;
    border-top: 1px solid var(--color-hairline);
    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: 0.8125rem;
    border-bottom-width: 2px;
    /* DESIGN.md floor: tap targets hold 44px minimum on mobile — compress
       type and padding, never the target. The padding (8px × 2 + 13px type
       ≈ 29px content) stays under it, so min-height carries the row. */
    min-height: 44px;
  }

  .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 and adds only layout. ZERO new tokens — every color, type step
   and radius below resolves through the existing :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 heading sits one step BELOW the version numbers (Number
   Reigns: the loudest type on this page is a version number, not a
   heading) and drops the shared .card h2 underline — this is a lede, not
   a section header. */
.changelog-intro h2 {
  font-size: var(--font-size-heading-md);
  font-weight: 700;
  color: var(--color-ink);
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.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: the release version is the biggest type on the page
   (heading-lg/700); tabular numerals keep the ledger rhythm. */
.release-card .release-version {
  font-size: var(--font-size-heading-lg);
  font-weight: 700;
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
}

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

.release-date {
  margin-left: auto;
  font-size: var(--font-size-caption);
  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) with the Traffic-Only
   Rule honored: fix is line + steel, NOT green; green belongs to the
   up/down traffic pair on metric cards. */
.kind-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: var(--font-size-label);
  font-weight: 500;
  flex-shrink: 0;
}

.kind-chip--feature {
  background: var(--color-badge-blue-fill);
  color: var(--color-signal-blue-deep);
}

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

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

/* "Qué podés probar": a sunken well inside the card — one step down the
   surface ladder, the same treatment the metric wells use. */
.release-try {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-md);
}

.release-try-title {
  font-size: var(--font-size-title);
  font-weight: 600;
  color: var(--color-label-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-caption);
  color: var(--color-muted-ink);
}

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

/* The era's range number leads its band but never outranks a release
   version: heading-md, one step below the cards' heading-lg. */
.changelog-era .release-version {
  font-size: var(--font-size-heading-md);
  color: var(--color-graphite-ink);
}

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

.changelog-era .release-summary {
  color: var(--color-steel-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%;
  }
}
