/* ============================================================
   The Golf Lab — Quote Builder
   Brand-themed CSS: charcoal, paper white, brand red/blue/green accents.
   Premium feel. Inter typeface. No spreadsheet vibes.
   ============================================================ */

/* Design tokens ------------------------------------------------ */
:root {
  /* Brand palette (sampled from Golf Lab logo) */
  --brand-charcoal: #2D2D2D;
  --brand-charcoal-soft: #4A4A4A;
  --brand-red: #DC3027;
  --brand-blue: #1B6FB4;
  --brand-blue-light: #3DB7EA;
  --brand-green: #3D9C50;
  --brand-orange: #F58220;

  /* Neutrals */
  --paper: #FAFAF7;
  --surface: #FFFFFF;
  --surface-2: #F2F1ED;
  --surface-3: #E8E7E2;
  --ink: #1A1A1A;
  --ink-muted: #6E6E6A;
  --ink-faint: #9B9A95;
  --border: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.20);
  --focus-ring: rgba(27, 111, 180, 0.35);

  /* Semantic */
  --success: var(--brand-green);
  --warning: var(--brand-orange);
  --danger: var(--brand-red);
  --info: var(--brand-blue);

  /* Type scale */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Spacing */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lift: 0 4px 16px rgba(0,0,0,0.08), 0 12px 32px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

/* Numeric tabular alignment for prices/totals */
.num, td.num, .stat-value, input[type="number"] {
  font-variant-numeric: tabular-nums;
}

button { font-family: inherit; cursor: pointer; }

a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Layout: header / shell / main
   ============================================================ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--brand-charcoal);
  color: #FFF;
  border-bottom: 1px solid #000;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.app-header .brand img {
  height: 40px;
  width: auto;
  display: block;
  background: #FFF;
  border-radius: 4px;
  padding: 3px 6px;
}
.app-header .brand-text {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 15px;
}
.app-header .brand-text small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.app-header .spacer { flex: 1; }
.app-header .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}
.app-header label.fitter-pick {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,0.85);
}
.app-header select.fitter-select {
  background: rgba(255,255,255,0.10);
  color: #FFF;
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font: inherit;
}
.app-header .save-indicator {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  font-variant-numeric: tabular-nums;
}
.app-header .save-indicator.saving { color: var(--brand-orange); }
.app-header .save-indicator.saved { color: rgba(255,255,255,0.65); }
.app-header .icon-button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.20);
  color: #FFF;
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-size: 13px;
}
.app-header .icon-button:hover { background: rgba(255,255,255,0.10); }

.app-main {
  flex: 1;
  padding: 28px 24px 80px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 900px) {
  .app-main { padding: 20px 16px 60px; }
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  color: var(--brand-charcoal);
  letter-spacing: -0.01em;
}
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.3; }
h4 { font-size: 14px; line-height: 1.3; }

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.muted { color: var(--ink-muted); }
.tiny { font-size: 12px; }

/* ============================================================
   Cards / surfaces
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card.tight { padding: 14px 16px; }
.card.lifted { box-shadow: var(--shadow-card); }
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-header h2, .card-header h3 { margin: 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.btn.primary {
  background: var(--brand-charcoal);
  color: #FFF;
  border-color: var(--brand-charcoal);
}
.btn.primary:hover { background: #000; }
.btn.accent {
  background: var(--brand-red);
  color: #FFF;
  border-color: var(--brand-red);
}
.btn.accent:hover { background: #B7271F; }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand-blue);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.btn.danger-ghost:hover { background: rgba(220,48,39,0.06); }

/* ============================================================
   Forms
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label, .field .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.field .hint {
  font-size: 11px;
  color: var(--ink-faint);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--brand-charcoal-soft);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea { resize: vertical; min-height: 60px; }

select { appearance: none; -webkit-appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
  linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px), calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 800px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   Combobox (typeahead search)
   ============================================================ */
.combobox {
  position: relative;
}
.combobox input {
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px), calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.combobox .cb-clear {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  display: none;
}
.combobox.has-value .cb-clear { display: block; }
.combobox-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lift);
  max-height: 280px;
  overflow-y: auto;
  z-index: 30;
}
.combobox-results .cbr {
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.combobox-results .cbr:last-child { border-bottom: none; }
.combobox-results .cbr:hover,
.combobox-results .cbr.cbr-active { background: var(--surface-2); }
.combobox-results .cbr .match-hl { background: rgba(245,130,32,0.30); border-radius: 2px; padding: 0 1px; }
.combobox-results .cbr .cbr-meta { color: var(--ink-faint); font-size: 11px; }
.combobox-results .cbr.cbr-create {
  color: var(--brand-blue);
  font-weight: 500;
}
.combobox-results .cbr-empty {
  padding: 12px;
  color: var(--ink-muted);
  font-size: 13px;
  font-style: italic;
  text-align: center;
}
.combobox-results .cbr-hint {
  padding: 6px 12px;
  background: var(--surface-2);
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  position: sticky;
  top: 0;
}

/* ============================================================
   Builder layout: two-column with sticky rollup
   ============================================================ */
.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}
.builder .builder-main { min-width: 0; }
.builder .rollup-rail {
  position: sticky;
  top: 80px;
}
@media (max-width: 1000px) {
  .builder { grid-template-columns: 1fr; }
  .builder .rollup-rail { position: static; }
}

/* ============================================================
   Customer picker
   ============================================================ */
.customer-search-wrap { position: relative; }
.customer-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-top: 6px;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}
.customer-results .row {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  cursor: pointer;
}
.customer-results .row:last-child { border-bottom: none; }
.customer-results .row:hover { background: var(--surface-2); }
.customer-results .row .meta { color: var(--ink-muted); font-size: 12px; }
.customer-results .row.create {
  color: var(--brand-blue);
  font-weight: 500;
}
.customer-selected {
  background: rgba(27,111,180,0.06);
  border: 1px solid rgba(27,111,180,0.18);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.customer-selected .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  flex: 0 0 36px;
}
.customer-selected .name { font-weight: 600; }
.customer-selected .submeta { font-size: 12px; color: var(--ink-muted); }
.customer-selected .swap { margin-left: auto; }

/* Quote history mini-panel */
.history-panel {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
}
.history-panel .h-title {
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.history-panel .h-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.history-panel .h-row:first-of-type { border-top: none; }
.history-panel .h-empty { color: var(--ink-muted); }

/* ============================================================
   Category sections (per club type)
   ============================================================ */
.cat-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
  overflow: hidden;
}
.cat-section .cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.cat-section .cat-head h3 {
  display: flex; align-items: center; gap: 10px;
}
.cat-section .cat-head .count {
  background: var(--brand-charcoal);
  color: #FFF;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}
.cat-section .cat-body {
  padding: 4px;
}
.cat-section.empty .cat-body { padding: 16px 18px; color: var(--ink-muted); font-size: 13px; }

/* Single line entry */
.line {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin: 8px 4px;
}
.line + .line { margin-top: 12px; }
.line-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.line-head .title {
  font-weight: 600; font-size: 14px;
}
.line-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 12px 0 6px;
}
.line .row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 720px) { .line .row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .line .row { grid-template-columns: 1fr; } }

.line .price-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
@media (max-width: 720px) { .line .price-bar { grid-template-columns: 1fr 1fr; } }

.price-source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-muted);
}
.price-source-pill::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-faint);
}
.price-source-pill.golf_town { background: rgba(61,156,80,0.10); color: var(--brand-green); }
.price-source-pill.golf_town::before { background: var(--brand-green); }
.price-source-pill.internal { background: rgba(27,111,180,0.10); color: var(--brand-blue); }
.price-source-pill.internal::before { background: var(--brand-blue); }
.price-source-pill.none { background: rgba(220,48,39,0.08); color: var(--brand-red); }
.price-source-pill.none::before { background: var(--brand-red); }
.price-source-pill.fuzzy { background: rgba(245,130,32,0.10); color: var(--brand-orange); }
.price-source-pill.fuzzy::before { background: var(--brand-orange); }
.price-source-pill.unset { background: var(--surface-3); color: var(--ink-faint); }

.line-meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 8px;
  font-size: 12px; color: var(--ink-muted);
}
.line-meta a { font-size: 12px; }

/* ============================================================
   Rollup rail
   ============================================================ */
.rollup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.rollup .quote-id {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.rollup .status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-muted);
}
.rollup .status-pill.draft { background: var(--surface-3); color: var(--ink-muted); }
.rollup .status-pill.submitted { background: rgba(27,111,180,0.10); color: var(--brand-blue); }
.rollup .lines {
  margin: 16px 0;
}
.rollup .lines .line-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-top: 1px dashed var(--border);
}
.rollup .lines .line-row:first-child { border-top: none; }
.rollup .totals {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--brand-charcoal);
}
.rollup .totals .row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}
.rollup .totals .row.grand {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-charcoal);
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.rollup .submit-bar {
  margin-top: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.rollup .submit-bar .btn { justify-content: center; padding: 12px; font-size: 15px; }
.rollup .warning-block {
  margin-top: 12px;
  background: rgba(245,130,32,0.10);
  color: #8A4A0E;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
}

/* ============================================================
   Dashboard
   ============================================================ */
.dash-hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
}
.dash-hero h1 { font-size: 32px; }
.dash-list {
  display: grid;
  gap: 10px;
}
.dash-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.dash-row:hover { border-color: var(--brand-charcoal-soft); background: var(--surface); text-decoration: none; }
.dash-row .who { font-weight: 600; }
.dash-row .qid { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }
.dash-row .when { font-size: 12px; color: var(--ink-muted); }
.dash-row .total { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 90px; text-align: right; }
@media (max-width: 720px) {
  .dash-row { grid-template-columns: 1fr auto; gap: 6px; }
  .dash-row .qid, .dash-row .when { grid-column: 1; }
  .dash-row .total { grid-column: 2; grid-row: 1 / span 3; }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--ink-muted);
}
.empty-state h3 { margin-bottom: 6px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,20,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lift);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 18px; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 18px;
}

/* ============================================================
   Errors / validation
   ============================================================ */
.error-block {
  background: rgba(220,48,39,0.08);
  color: #851D17;
  border: 1px solid rgba(220,48,39,0.25);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin: 8px 0;
}

/* ============================================================
   Notes section
   ============================================================ */
.notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .notes-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Submitted (placeholder) screen
   ============================================================ */
.submitted-screen {
  text-align: center;
  padding: 60px 20px;
}
.submitted-screen .icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--brand-green);
  color: #FFF;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: 20px;
}
.submitted-screen h1 { font-size: 32px; margin-bottom: 8px; }
.submitted-screen p.muted { max-width: 460px; margin: 8px auto 24px; }

/* ============================================================
   Status rail (replaces the old rollup rail)
   ============================================================ */
.status-rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.sr-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.sr-qid {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
}
.sr-customer {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.sr-customer-empty { color: var(--ink-muted); font-size: 13px; }
.sr-customer-name { font-weight: 600; font-size: 14px; }
.sr-customer-sub { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.sr-section { margin-top: 14px; }
.sr-section-title {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.sr-saved {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.sr-saved-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
}
.sr-lines-grid {
  display: grid; grid-template-columns: 1fr auto;
  row-gap: 4px; font-size: 13px;
}
.sr-line-label { color: var(--ink); }
.sr-line-count { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.sr-empty { grid-column: 1 / -1; color: var(--ink-faint); font-size: 12px; font-style: italic; }
.sr-attention {
  background: rgba(245, 130, 32, 0.10);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.sr-attention-title {
  font-size: 12px; font-weight: 600; color: #8A4A0E;
  margin-bottom: 4px;
}
.sr-attention-list {
  margin: 0; padding-left: 18px;
  font-size: 11px; color: #8A4A0E; line-height: 1.5;
}
.sr-attention-more { font-style: italic; }
.sr-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Generate-quote action bar (replaces submit-bar)
   ============================================================ */
.generate-bar {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.generate-bar-inner {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.btn.big { padding: 12px 22px; font-size: 15px; }
.generate-bar-meta { font-size: 13px; color: var(--ink-muted); }
.generate-bar-meta .needs-attn { color: var(--brand-orange); font-weight: 500; }
[data-tooltip] { position: relative; }
[data-tooltip][disabled]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--brand-charcoal);
  color: #FFF;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  white-space: nowrap;
  z-index: 50;
  font-weight: 400;
}
[data-tooltip][disabled]:hover::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px); left: 18px;
  width: 8px; height: 8px;
  background: var(--brand-charcoal);
  transform: rotate(45deg);
  z-index: 51;
}

/* Flash a problematic line when the fitter is taken back to it */
.line-flash {
  animation: lineFlash 1.2s ease-out;
}
@keyframes lineFlash {
  0%   { box-shadow: 0 0 0 3px rgba(245,130,32,0.6); }
  100% { box-shadow: 0 0 0 0   rgba(245,130,32,0); }
}

/* ============================================================
   Customer-facing summary screen
   ============================================================ */
.summary-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0 12px;
  gap: 12px;
}
.summary-toolbar-actions { display: flex; gap: 8px; }
.sm-partial-banner {
  background: rgba(245,130,32,0.10);
  color: #8A4A0E;
  font-size: 12px; padding: 6px 10px; border-radius: var(--r-sm);
}
.summary-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 30px 38px;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: var(--shadow-card);
}
.sm-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--brand-charcoal);
}
.sm-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--ink-muted); margin: 0;
}
.sm-title {
  font-size: 24px; font-weight: 700; margin: 4px 0 0;
  color: var(--brand-charcoal); letter-spacing: -0.01em;
}
.sm-sub { font-size: 13px; color: var(--ink-muted); margin: 6px 0 0; }
.sm-header-total { text-align: right; }
.sm-total-num { font-size: 28px; font-weight: 700; margin: 4px 0 0; color: var(--brand-charcoal); font-variant-numeric: tabular-nums; }
.sm-table {
  width: 100%; border-collapse: collapse; margin-top: 18px;
  font-variant-numeric: tabular-nums;
}
.sm-table th {
  font-size: 11px; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  text-align: right;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--border-strong);
}
.sm-table th.sm-left { text-align: left; }
.sm-table td {
  padding: 14px 0; border-bottom: 1px solid var(--border);
  font-size: 14px; vertical-align: top; text-align: right;
}
.sm-table td.sm-item { text-align: left; padding-right: 14px; max-width: 380px; }
.sm-item-title { font-weight: 600; color: var(--ink); }
.sm-item-desc {
  color: var(--ink-muted); font-size: 12px;
  margin-top: 3px; line-height: 1.5;
}
.sm-num { font-variant-numeric: tabular-nums; }
.sm-num-th { text-align: right; }
.sm-gt { color: var(--ink-muted); text-decoration: line-through; }
.sm-save { color: var(--success); font-weight: 600; }
.sm-na { color: var(--ink-faint); font-style: italic; }
.sm-pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  vertical-align: 1px; margin-left: 4px;
}
.sm-pill-amber { background: rgba(245,130,32,0.10); color: #8A4A0E; }
.sm-pill-gray  { background: var(--surface-3); color: var(--ink-muted); }
.sm-totals {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-strong);
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 8px;
  font-size: 14px;
}
.sm-totals-row { display: contents; }
.sm-totals-row > div { padding: 4px 0; }
.sm-totals-row > div:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.sm-totals-sub { color: var(--ink-faint); font-size: 12px; }
.sm-totals-grand > div {
  font-weight: 700; font-size: 15px;
  padding-top: 10px; border-top: 1px solid var(--border);
  color: var(--brand-charcoal);
}
.sm-savings {
  margin-top: 22px;
  padding: 18px 22px;
  background: rgba(61, 156, 80, 0.10);
  border-radius: var(--r-md);
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
}
.sm-savings-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em;
  color: #27500A; margin: 0; font-weight: 600;
}
.sm-savings-sub { font-size: 12px; color: #3B6D11; margin: 4px 0 0; }
.sm-savings-num { font-size: 32px; font-weight: 700; color: #27500A; margin: 0; font-variant-numeric: tabular-nums; }
.sm-footnote {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--ink-faint); line-height: 1.5;
}
.sm-empty { text-align: center; color: var(--ink-muted); padding: 30px 0; }

/* ============================================================
   Print stylesheet — for the customer summary
   ============================================================ */
@media print {
  body { background: #FFF; }
  .app-header, .no-print { display: none !important; }
  .app-main { padding: 0; max-width: none; }
  .summary-page {
    box-shadow: none; border: none; border-radius: 0;
    padding: 24px 28px; max-width: none;
  }
  .sm-savings { background: #EAF3DE; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sm-pill, .sm-save, .sm-gt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Avoid breaking individual table rows across pages */
  .sm-table tr, .sm-savings, .sm-totals { break-inside: avoid; page-break-inside: avoid; }
}

/* ============================================================
   UI v2 — fallback banner (when canonical-brands.json fetch fails)
   ============================================================ */
.fallback-banner {
  background: rgba(245,130,32,0.12);
  color: #8A4A0E;
  font-size: 13px;
  text-align: center;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(245,130,32,0.25);
}

/* ============================================================
   UI v2 — Stage 1: empty-state tile (prompt "Pick a brand")
   ============================================================ */
.stage-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 28px 24px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  font-family: inherit;
  color: var(--ink);
}
.stage-tile:hover {
  background: var(--surface);
  border-color: var(--brand-charcoal-soft);
  border-style: solid;
}
.stage-tile:active { transform: scale(0.99); }
.stage-tile-eyebrow {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.10em; color: var(--ink-muted);
}
.stage-tile-prompt {
  font-size: 18px; font-weight: 600; color: var(--brand-charcoal);
}
.stage-tile-arrow { font-size: 20px; color: var(--ink-muted); }

.stage-prompt {
  font-size: 13px; color: var(--ink-muted);
  margin: 6px 4px 12px;
}
.stage-empty-state {
  padding: 24px 18px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  color: var(--ink-muted);
  font-size: 13px;
  text-align: center;
}

/* ============================================================
   UI v2 — Stage 2: brand grid + brand cards
   ============================================================ */
.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 4px 4px 12px;
}
.brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
  color: var(--ink);
}
.brand-card:hover {
  border-color: var(--brand-charcoal-soft);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.brand-card-logo { max-width: 80%; max-height: 56px; object-fit: contain; }
.brand-card-initials {
  font-size: 24px; font-weight: 700;
  color: var(--brand-charcoal);
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}
.brand-card-typo { background: var(--surface-2); }
.brand-card-name { font-size: 12px; font-weight: 500; color: var(--ink-muted); }
@media (max-width: 1024px) and (orientation: portrait) {
  .brand-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) and (orientation: landscape) {
  .brand-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   UI v2 — Stage 3: model cards
   ============================================================ */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 4px 4px 12px;
}
.model-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  min-height: 200px;
}
.model-card:hover {
  border-color: var(--brand-charcoal-soft);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.model-card-img {
  width: 100%; height: 130px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.model-card-noimg {
  width: 100%; height: 130px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  position: relative;
}
.model-card-noimg::after {
  content: "no image yet";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-faint); font-style: italic;
}
.model-card-name {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.model-card-skeleton {
  display: inline-block;
  width: 80%; height: 14px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  border-radius: 3px;
  animation: skeleton 1.4s infinite;
}
@keyframes skeleton {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.model-card-price-gt {
  font-size: 12px; color: var(--brand-green); font-weight: 500;
}
.model-card-price-int {
  font-size: 12px; color: var(--brand-blue); font-weight: 500;
}
.model-card-price-none {
  font-size: 12px; color: var(--ink-faint); font-style: italic;
}
.model-grid-fallback {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.model-grid-fallback-label {
  font-size: 12px; color: var(--ink-muted);
  margin-bottom: 8px;
}
.line-head-brand { color: var(--brand-blue); }

/* ============================================================
   UI v2 — Stage 4: summary strip
   ============================================================ */
.summary-strip {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 10px;
}
.strip-brand { display: flex; align-items: center; justify-content: center; }
.strip-logo { max-width: 48px; max-height: 40px; object-fit: contain; }
.strip-initials {
  width: 48px; height: 48px;
  background: var(--surface-2); color: var(--brand-charcoal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  font-family: var(--font-display);
}
.strip-main { min-width: 0; }
.strip-title {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip-sub-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 4px;
}
.strip-sub { color: var(--ink-faint); font-size: 12px; font-weight: 400; }
.strip-gtlink { font-size: 14px; color: var(--brand-blue); text-decoration: none; }
.strip-gtlink:hover { text-decoration: underline; }
.strip-fetched { color: var(--ink-faint); }
.strip-price {
  font-size: 18px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--brand-charcoal);
}
.strip-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
@media (max-width: 720px) {
  .summary-strip { grid-template-columns: 56px 1fr; }
  .strip-price { grid-column: 2; }
  .strip-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ============================================================
   UI v2 — Stage 4: shaft chips + shaft overlay
   ============================================================ */
.shaft-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.shaft-chip-row {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  flex: 1; min-width: 0;
}
.shaft-chip {
  padding: 6px 12px;
  font-size: 13px; font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: background 0.12s, border-color 0.12s;
}
.shaft-chip:hover { background: var(--surface-3); }
.shaft-chip-active {
  background: var(--brand-charcoal);
  color: #FFF;
  border-color: var(--brand-charcoal);
}
.shaft-chip-pinned { background: var(--surface); border-color: var(--border-strong); }
.shaft-chip-pinned.shaft-chip-active { background: var(--brand-charcoal); color: #FFF; }
.shaft-chip-upcharge.shaft-chip-active { background: var(--brand-orange); color: #FFF; border-color: var(--brand-orange); }
.shaft-chip-divider {
  width: 1px; height: 22px;
  background: var(--border-strong);
  margin: 0 6px;
}
.shaft-qty-flex { display: flex; gap: 10px; align-items: end; }
.shaft-qty-flex .field { min-width: 90px; }
.shaft-detail {
  padding: 10px 16px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  font-size: 13px;
}
.shaft-detail-stock { color: var(--ink-muted); font-style: italic; }
.shaft-detail-upcharge {
  background: rgba(245,130,32,0.08);
  color: #8A4A0E;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.shaft-detail-upcharge input { width: 160px; }
.shaft-detail-hint { flex: 1; }
.shaft-detail-priced { display: flex; gap: 12px; align-items: end; background: var(--surface); border: 1px solid var(--border); }
.shaft-row-putter { background: var(--surface-2); }

/* ============================================================
   UI v2 — Stage 4: specs accordion
   ============================================================ */
.specs-accordion {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.specs-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
  color: var(--ink-muted);
}
.specs-accordion > summary::-webkit-details-marker { display: none; }
.specs-accordion > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--ink-faint);
  transition: transform 0.15s;
}
.specs-accordion[open] > summary::before { transform: rotate(90deg); }
.specs-accordion-label { font-weight: 500; color: var(--ink); }
.specs-accordion-summary {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  margin-left: auto;
}
.specs-accordion-body {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

/* Settings pop-out */
.settings-popover {
  position: absolute;
  top: 56px; right: 12px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  width: 320px;
  padding: 16px;
  box-shadow: var(--shadow-lift);
  z-index: 50;
}
.settings-popover h3 { margin-bottom: 10px; }
.settings-popover .ok-pill {
  margin-top: 8px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.settings-popover .ok-pill.ok { background: rgba(61,156,80,0.10); color: var(--brand-green); }
.settings-popover .ok-pill.fail { background: rgba(220,48,39,0.10); color: var(--brand-red); }
.settings-popover .ok-pill.idle { background: var(--surface-3); color: var(--ink-muted); }
