/* Shared product foundations for every Schemes workspace.
   It deliberately uses the existing navy / yellow / cream visual language. */
:root {
  --sa-navy: #102d4f;
  --sa-navy-strong: #081f39;
  --sa-yellow: #ffd21f;
  --sa-yellow-soft: #fff4bd;
  --sa-cream: #f7f5ef;
  --sa-surface: #ffffff;
  --sa-surface-muted: #f3f7fa;
  --sa-line: #d7e0e8;
  --sa-text: #102d4f;
  --sa-muted: #60738a;
  --sa-positive: #16794d;
  --sa-warning: #9c4f09;
  --sa-danger: #b8412b;
  --sa-radius-sm: 8px;
  --sa-radius-md: 14px;
  --sa-radius-lg: 22px;
  --sa-shadow: 0 12px 30px rgba(16, 45, 79, .08);
}

html { scroll-behavior: smooth; }
body { color: var(--sa-text); background: var(--sa-cream); }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(255, 210, 31, .95);
  outline-offset: 3px;
}

/* A stable header keeps controls inside the viewport at every size. */
.app-topbar {
  gap: 20px;
  align-items: center;
  min-width: 0;
}
.app-topbar .brand { min-width: 0; }
.app-topbar .brand img { max-width: min(230px, 48vw); height: auto; object-fit: contain; }
.app-nav, .header-actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.app-nav-button { white-space: nowrap; }

/* Shared message, panel and form hierarchy. */
.notice, .message, [role="alert"] { border-radius: var(--sa-radius-sm); }
.form-grid > *, .workspace > *, .dashboard-summary > *, .summary > article {
  min-width: 0;
}
.field small, .slab-help, .scheme-flow-intro { color: var(--sa-muted); }
input, select, textarea { max-width: 100%; }

/* Settings are a guided, task-first flow—not an undifferentiated form. */
.scheme-flow-nav {
  scrollbar-width: thin;
  scroll-padding-inline: 8px;
}
.scheme-flow-nav button {
  min-height: 40px;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.scheme-flow-nav button:not(.active):hover { border-color: var(--sa-navy); color: var(--sa-navy); }
.scheme-flow-intro {
  max-width: 72ch;
  padding: 12px 14px;
  border-inline-start: 3px solid var(--sa-yellow);
  background: #fffdf4;
  border-radius: 0 var(--sa-radius-sm) var(--sa-radius-sm) 0;
}
.scheme-flow-actions { position: sticky; bottom: 12px; z-index: 4; background: color-mix(in srgb, var(--sa-cream) 92%, transparent); backdrop-filter: blur(8px); }
.selected-scheme-items, .composite-item-names, .slab-mode-choice, .category-hierarchy-picker {
  border-radius: var(--sa-radius-md);
}

/* Tables remain an information-dense workspace on desktop and readable on touch devices. */
.tracker-table, .tracker-table-wrap, .table-wrap { max-width: 100%; }
.tracker-table th { white-space: normal; }
.tracker-table td { vertical-align: top; }
.tracker-table tbody tr { transition: background-color .16s ease; }
.tracker-table tbody tr:nth-child(even) { background: #f7fafc; }
.tracker-table tbody tr:hover { background: #eef5f8; }
.tracker-table .dealer-name, .dealer-name { color: #111; font-weight: 800; }
.tracker-table .dealer-meta, .dealer-meta { color: var(--sa-muted); line-height: 1.45; }

/* Tracker: report controls and results share one predictable information rail. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
}
.filters > label, .filters > div { min-width: min(100%, 190px); }
.report-heading { gap: 20px; align-items: flex-end; }
.report-title-line { flex-wrap: wrap; gap: 10px 18px; }
.report-context { max-width: 62ch; }
.report-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.leaderboard-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.leaderboard-pagination { gap: 12px; flex-wrap: wrap; }

/* Campaign and message workspaces: clear stage boundaries, no decorative cards. */
.workspace, .campaign-workspace { align-items: start; }
.steps, .campaign-sidebar { position: sticky; top: 18px; }
.step-panel, .composer, .preview, .campaign-editor { border-radius: var(--sa-radius-md); }
.step-panel .panel-head, .campaign-editor .panel-head { border-bottom: 1px solid var(--sa-line); padding-bottom: 18px; }
.preview .phone { box-shadow: none; }
.campaign-list { scrollbar-width: thin; }
.dealer-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dealer-filters > * { min-width: 0; }
.dealer-filters small { grid-column: 1 / -1; color: var(--sa-muted); }
.select-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Public scheme viewing: make the switching rail and key rewards easy to scan. */
.scheme-list { scroll-margin-top: 18px; }
.scheme-list [role="tab"], .scheme-list button { min-height: 40px; }
.privacy-dialog, .privacy-modal { border-radius: var(--sa-radius-lg); }

@media (max-width: 900px) {
  .app-topbar { align-items: flex-start; }
  .app-nav, .header-actions { justify-content: flex-start; }
  .steps, .campaign-sidebar { position: static; }
  .dealer-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scheme-flow-actions { position: static; background: transparent; backdrop-filter: none; }
}

@media (max-width: 620px) {
  .app-topbar { gap: 12px; padding-block: 14px; }
  .app-topbar .brand img { max-width: 175px; }
  .app-nav, .header-actions { width: 100%; }
  .app-nav-button { min-height: 40px; font-size: 11px; }
  .scheme-flow-nav { margin-inline: -2px; }
  .scheme-flow-nav button { padding-inline: 11px; }
  .scheme-flow-intro { font-size: 13px; }
  .tracker-table-wrap, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tracker-table { min-width: 760px; }
  .tracker-table th, .tracker-table td { padding: 14px 11px; }
  .filters, .report-heading, .leaderboard-tools { align-items: stretch; }
  .filters > label, .filters > div { width: 100%; }
  .report-actions { justify-content: stretch; }
  .report-actions > button { flex: 1 1 145px; }
  .dealer-filters { grid-template-columns: 1fr; }
  .select-actions > button { flex: 1 1 120px; }
}

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