/* Builders Workbench — component styles.
   Uses only the variables in theme.css; edit theme.css to restyle. */

*, *::before, *::after { box-sizing: border-box; }

/* Anything with the hidden attribute stays hidden, even if its class sets display (e.g. .card). */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background-color: var(--ground);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-pitch) var(--grid-pitch);
  color: var(--ink);
  font: var(--text-body);
}

a { color: var(--ink); text-underline-offset: 3px; }
a:hover { color: var(--ink-muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Top navigation ---------- */
.topbar { background: var(--nav); padding: 0 var(--space-8); }
.topbar-inner {
  max-width: var(--page-max-width); margin: 0 auto; min-height: 64px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-tile {
  width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: var(--on-accent);
}
.brand-name { font: var(--text-title); font-size: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.tab {
  color: var(--ink); text-decoration: none; padding: 10px 14px; font-weight: 500;
  border-bottom: 3px solid transparent; min-height: var(--control-height); display: inline-flex; align-items: center;
  opacity: 0.85;
}
.tab:hover { color: var(--ink); opacity: 1; }
.tab[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; opacity: 1; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }
.mode-toggle {
  font: var(--text-small); font-weight: 600; background: transparent; color: var(--ink);
  border: 1px solid var(--ink); border-radius: var(--radius-pill); padding: 0 14px;
  min-height: var(--control-height); cursor: pointer;
}
.mode-toggle[aria-pressed="true"] { background: var(--ink); color: var(--nav); }
.avatar {
  width: 36px; height: 36px; border-radius: var(--radius-pill); background: var(--surface);
  color: var(--ink); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; text-decoration: none;
}

/* ---------- Page layout ---------- */
.page {
  max-width: var(--page-max-width); margin: 0 auto;
  padding: 40px var(--space-8) 56px; display: flex; flex-direction: column; gap: 28px;
}
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.page-head-text { display: flex; flex-direction: column; gap: 6px; }
.eyebrow { font: var(--text-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
h1 { margin: 0; font: var(--text-display); letter-spacing: -0.01em; }
h2 { margin: 0; font: var(--text-title); }
h3 { margin: 0; font: var(--text-section); }
.muted { color: var(--ink-muted); }
.small { font: var(--text-small); }
.actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }
.two-col { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.two-col > .main-col { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-6); }
.two-col > .side-col { flex: 1 1 280px; display: flex; flex-direction: column; gap: var(--space-4); }
.breadcrumb { font: var(--text-small); color: var(--ink-muted); }
.breadcrumb a { color: var(--ink-muted); }

/* ---------- Buttons ---------- */
.btn {
  font: var(--text-body); font-weight: 600; border-radius: var(--radius-sm);
  padding: 0 18px; min-height: var(--control-height);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  cursor: pointer; text-decoration: none; border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { color: var(--ink); background: var(--surface-raised); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; padding: 0 10px; }
.btn-ghost:hover { color: var(--ink); background: var(--surface-raised); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn svg, .tab svg { flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3);
}
.card.raised { background: var(--surface-raised); }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.card-foot { border-top: 1px solid var(--line); padding-top: var(--space-3); }
.card p { margin: 0; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.empty-tile {
  font: var(--text-body); font-weight: 600; background: transparent; color: var(--ink-muted);
  border: 2px dashed var(--line); border-radius: var(--radius-sm); min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  text-decoration: none;
}
.empty-tile:hover { color: var(--ink); border-color: var(--ink-muted); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block; font: var(--text-label); background: var(--chip); color: var(--ink);
  border-radius: var(--radius-pill); padding: 4px 10px; white-space: nowrap;
}
.chip-amber { background: var(--accent-amber); color: var(--on-accent); }
.meta { display: inline-flex; align-items: center; gap: var(--space-1); font: var(--text-small); color: var(--ink-muted); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font: var(--text-small); font-weight: 600; color: var(--ink); }
.field .hint { font: var(--text-small); color: var(--ink-muted); }
input, select, textarea {
  font: var(--text-body); color: var(--ink); background: var(--ground);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  min-height: var(--control-height); padding: 0 14px; width: 100%;
}
textarea { padding: 12px 14px; min-height: 140px; resize: vertical; font: var(--text-figure); }
input[type="number"], .mono { font: var(--text-figure); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input[type="file"] { padding: 9px 14px; }
.error { color: var(--danger); font: var(--text-small); margin: 0; }
.notice { color: var(--ink-muted); font: var(--text-small); margin: 0; }

/* ---------- Pallet table ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
caption { text-align: left; padding: var(--space-4) 14px var(--space-1); font: var(--text-section); }
th {
  text-align: left; font: var(--text-label); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-muted); padding: 12px 14px; border-bottom: 1px solid var(--line);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
td .mono, td.mono { font: var(--text-figure); }
td.price { font: var(--text-figure); color: var(--ink-muted); white-space: nowrap; }
td.price.median { color: var(--ink); font-weight: 700; }
td input, td select { min-height: 40px; }
td input.qty { width: 96px; text-align: right; }
td input.unit { width: 84px; }
td input.cost { width: 110px; }
td .item-name { font-weight: 600; }
.add-row td { background: var(--surface-raised); }

.total-figure { font: var(--text-figure-large); }

/* ---------- Budget states on the Pallet total card ---------- */
.budget-bar { display: block; height: 8px; background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.budget-bar[hidden] { display: none; }
.budget-fill { display: block; height: 100%; width: 0; background: var(--ink-muted); transition: width 200ms ease; }
.budget-status { margin: 0; font: var(--text-small); font-weight: 600; display: flex; align-items: center; gap: var(--space-1); color: var(--ink-muted); }
.budget-card { transition: border-color 200ms ease; }
.budget-card[data-budget="under"] .budget-status { color: var(--ink); }
.budget-card[data-budget="near"] { border-color: var(--near-budget); }
.budget-card[data-budget="near"] .budget-status { color: var(--near-budget); }
.budget-card[data-budget="near"] .budget-fill { background: var(--near-budget); }
.budget-card[data-budget="over"] { border: 2px solid var(--over-budget); }
.budget-card[data-budget="over"] .total-figure,
.budget-card[data-budget="over"] .budget-status { color: var(--over-budget); }
.budget-card[data-budget="over"] .budget-fill { background: var(--over-budget); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-8); }
.auth-card { width: 100%; max-width: 420px; }
.auth-switch { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); }
.auth-switch button {
  font: var(--text-body); font-weight: 600; background: transparent; color: var(--ink-muted);
  border: none; border-bottom: 3px solid transparent; padding: 10px 4px; min-height: var(--control-height); cursor: pointer; margin-right: var(--space-4);
}
.auth-switch button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .topbar { padding: 0 var(--space-4); }
  .page { padding: var(--space-6) var(--space-4) 40px; }
  h1 { font-size: 32px; line-height: 36px; }
}

/* ---------- Pallet: My cost, line types and specs ---------- */
.btn-small { min-height: 36px; padding: 0 10px; font: var(--text-small); font-weight: 600; }
td .btn-small { margin-top: var(--space-1); }
.chip-type { margin-left: var(--space-2); vertical-align: middle; }
.spec-summary { margin-top: 2px; }
.median-cell { display: flex; flex-direction: column; gap: 2px; }
td.price.median { display: table-cell; }
.price-source { display: block; font: var(--text-label); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); margin-top: 2px; }
tr.has-specs td { border-bottom-color: transparent; }
tr.spec-row td { background: var(--surface-raised); padding: var(--space-4) 14px var(--space-6); }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4); }
.spec-field label { font: var(--text-small); font-weight: 600; }
.spec-drives { font-weight: 400; color: var(--ink-muted); }

/* ---------- Admin: spec catalog ---------- */
.admin-list { display: flex; flex-direction: column; gap: var(--space-3); }
details.admin-cat > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  min-height: var(--control-height);
}
details.admin-cat > summary::-webkit-details-marker { display: none; }
details.admin-cat > summary::before { content: "+"; font: var(--text-figure); color: var(--accent); width: 16px; }
details.admin-cat[open] > summary::before { content: "−"; }
.admin-cat-name { font: var(--text-section); }
.admin-field { border-top: 1px solid var(--line); padding-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.admin-field.new { border-top-style: dashed; }
.retired { opacity: 0.6; }
.options-box { min-height: 96px; font: var(--text-small); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); font: var(--text-small); font-weight: 600; min-height: var(--control-height); cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }

/* ---------- AI drafts ---------- */
.ai-panel { border-color: var(--accent); }
.ai-panel h3, .ai-describe-field label { display: flex; align-items: center; gap: var(--space-2); }
.ai-busy { display: flex; align-items: center; gap: var(--space-3); font-weight: 600; min-height: 64px; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: var(--radius-pill); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.draft-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 60vh; overflow-y: auto; padding-right: var(--space-1); }
.draft-row { display: flex; gap: var(--space-3); align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); }
.draft-row.low { border-left: 3px solid var(--near-budget); }
.draft-row.off { opacity: 0.5; }
.draft-check { padding-top: 10px; }
.draft-check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.draft-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.draft-fields { display: grid; grid-template-columns: minmax(200px, 2.2fr) minmax(160px, 1.4fr) 96px 84px 110px; gap: var(--space-2); }
.draft-fields input, .draft-fields select { min-height: 40px; }
.draft-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; }
.draft-note { color: var(--near-budget); }
.draft-source { flex-basis: 100%; }
.draft-info ul { margin: var(--space-1) 0 0; padding-left: 20px; font: var(--text-small); }
.draft-info.pro { border: 1px solid var(--near-budget); border-radius: var(--radius-sm); padding: var(--space-3); }
@media (max-width: 760px) { .draft-fields { grid-template-columns: 1fr 1fr; } }

/* Whole Jobsite card is clickable */
.card-link { cursor: pointer; transition: border-color 150ms ease; }
.card-link:hover { border-color: var(--accent); }

/* Back to Jobsites: orange outline, so the filled orange stays reserved for the main action */
.back-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.btn-back { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-back:hover { color: var(--on-accent); background: var(--accent); }

/* ---------- Overhead, profit & tax ---------- */
.op-card h3 { margin-bottom: var(--space-1); }
.op-grid { display: grid; grid-template-columns: minmax(120px, 160px) 1fr minmax(110px, auto); gap: var(--space-3) var(--space-4); align-items: center; }
.op-grid > :nth-child(3n) { text-align: right; font: var(--text-figure); }
.op-label { font-weight: 600; }
.op-total { font: var(--text-section); }
.op-grand { font: var(--text-figure-large); font-size: 24px; line-height: 30px; }
.op-grid > .op-total, .op-grid > .op-total ~ * { border-top: 1px solid var(--line); padding-top: var(--space-3); }
.op-control { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.op-control select { width: auto; }
.op-input { width: 110px; }
.seg-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg { font: var(--text-figure); font-weight: 700; background: var(--ground); color: var(--ink-muted); border: none; min-width: 44px; min-height: var(--control-height); cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
@media (max-width: 640px) {
  .op-grid { grid-template-columns: 1fr; gap: var(--space-2); }
  .op-grid > :nth-child(3n) { text-align: left; margin-bottom: var(--space-3); }
}

/* ---------- Pallet layout (v0.5.1): full-width lines, no sideways scroll ---------- */
.pallet-summary { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.pallet-main { display: flex; flex-direction: column; gap: var(--space-6); }
table.pallet-table { min-width: 0; table-layout: auto; }
.pallet-table th, .pallet-table td { padding-left: 10px; padding-right: 10px; }
.pallet-table td:first-child { min-width: 220px; }
.pallet-table td select { width: 100%; min-width: 130px; max-width: 190px; }
.pallet-table td input.qty { width: 80px; }
.pallet-table td input.unit { width: 68px; }
.pallet-table td input.cost { width: 96px; }
.pallet-table td .item-name { overflow-wrap: anywhere; }
.pallet-table .cell-remove { width: 1%; white-space: nowrap; }
@media (max-width: 900px) {
  .pallet-summary { grid-template-columns: 1fr; }
  /* Narrow screens: each line becomes a stacked card instead of a wide row */
  .pallet-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .pallet-table, .pallet-table tbody, .pallet-table tr, .pallet-table td { display: block; width: 100%; }
  .pallet-table tr { border-bottom: 1px solid var(--line); padding: var(--space-3) 0; }
  .pallet-table td { border-bottom: none; padding: 6px 14px; }
  .pallet-table td[data-label] { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
  .pallet-table td[data-label]::before { content: attr(data-label); font: var(--text-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
  .pallet-table td.cell-hide-narrow { display: none; }
  .pallet-table td.cell-remove { width: 100%; text-align: right; }
  .pallet-table td.num { text-align: right; }
}

/* ---------- No O&P lines (v0.6) ---------- */
.item-tools { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-1); }
.no-op-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-muted); cursor: pointer; white-space: nowrap; }
.no-op-toggle input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
tr.no-op .no-op-toggle { color: var(--near-budget); font-weight: 600; }

/* ---------- Supply Run (v0.7) ---------- */
.sr-controls { display: flex; flex-direction: column; gap: var(--space-3); }
.sr-fields { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(110px, 1fr) minmax(120px, 1fr) auto; gap: var(--space-3); align-items: end; }
.sr-go { justify-content: flex-end; }
@media (max-width: 900px) { .sr-fields { grid-template-columns: 1fr 1fr; } .sr-go { grid-column: 1 / -1; } }
@media (max-width: 520px) { .sr-fields { grid-template-columns: 1fr; } }
.vendor-grid { margin-top: var(--space-2); }
.vendor-card { display: flex; flex-direction: column; gap: var(--space-2); }
.vendor-card h3 { overflow-wrap: anywhere; }
.vendor-distance { color: var(--accent); font-weight: 700; white-space: nowrap; }
.vendor-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.vendor-carries { color: var(--accent); font-weight: 600; }
.vendor-card .card-foot { margin-top: auto; }
.coverage-table tr.no-match td { color: var(--ink-muted); }
.sr-attrib { margin-top: var(--space-4); }

/* ---------- Plan my run + online (v0.8) ---------- */
.plan-card { border-color: var(--accent); display: flex; flex-direction: column; gap: var(--space-3); }
.plan-headline { font: var(--text-section); }
.plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.plan-stop { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.plan-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.plan-left { color: var(--near-budget); display: flex; gap: 6px; align-items: flex-start; }
.chip-online { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.cover-meter { display: flex; align-items: center; gap: var(--space-2); }
.cover-bar { flex: 1; height: 6px; background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.cover-fill { display: block; height: 100%; background: var(--accent); }

/* ---------- Route window (v0.9) ---------- */
.route-box { border-top: 1px solid var(--line); padding-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.route-controls { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(180px, 1.5fr) auto; gap: var(--space-3); align-items: end; }
@media (max-width: 760px) { .route-controls { grid-template-columns: 1fr; } }
.route-map { height: 440px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--ground); z-index: 0; }
@media (max-width: 640px) { .route-map { height: 320px; } }
/* Dark, blueprint-style map tiles to match the theme */
.route-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
.route-map .leaflet-control-attribution { background: rgba(28, 29, 31, 0.8); color: var(--ink-muted); }
.route-map .leaflet-control-attribution a { color: var(--ink-muted); }
.map-pin { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font: 700 13px/1 var(--font-mono, monospace); border: 2px solid #1C1D1F; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.map-pin-start { background: #F4F1EA; color: #1C1D1F; }
.route-order { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Confidence levels + stock checks (v1.0) ---------- */
.plan-toggles { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.level-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.level-chip { display: inline-flex; align-items: center; gap: 6px; font: var(--text-small); font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.level-verified { background: rgba(76, 175, 80, 0.16); border-color: #4CAF50; color: #A5D6A7; }
.level-confirmed { background: transparent; border-color: var(--accent); color: var(--accent); }
.level-likely { background: transparent; border-style: dashed; color: var(--ink-muted); }
.chip-action { background: none; border: none; color: var(--ink); font: var(--text-small); text-decoration: underline; cursor: pointer; padding: 0; }
.report-box { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); border-top: 1px dashed var(--line); padding-top: var(--space-2); }
.report-btn { color: var(--ink-muted); }
.stock-card { display: flex; flex-direction: column; gap: var(--space-3); }
.stock-table td.stock-yes, .stock-yes { color: #A5D6A7; font-weight: 700; }
.stock-table td.stock-no, .stock-no { color: var(--over-budget, #FF8A80); }
.pick-list { list-style: none; margin: var(--space-2) 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.pick-item { display: flex; align-items: center; gap: var(--space-3); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }
.pick-item img { border-radius: 4px; background: #fff; flex: none; }
.pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-suggest { margin-bottom: var(--space-2); }
.pick-reuse { margin-bottom: var(--space-3); }
.apply-offer { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }

/* ---------- Buy qty, budget, totals, search (v1.1) ---------- */
.stock-table td.stock-online, .stock-online { color: var(--near-budget); font-weight: 700; }
.buy-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.buy-row input.buy-qty { width: 72px; min-height: 34px; padding: 4px 8px; text-align: right; }
.over-budget-text { color: var(--over-budget, #FF8A80); }
.under-budget-text { color: #A5D6A7; }
.pick-search { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-2); }
.pick-search-row { display: flex; gap: var(--space-2); }
.pick-search-row input { flex: 1; min-width: 0; }
.pick-totals { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-3); }

/* ---------- Estimate vs store price (v1.2) ---------- */
.price-source.src-ai { color: var(--near-budget); }
.price-source.src-learned { color: #A5D6A7; }
.price-tools { display: flex; flex-direction: column; gap: var(--space-2); }
.median-cell { display: flex; flex-direction: column; gap: 2px; }

/* ---------- v1.3: totals trio, warnings, pack minimum, order online ---------- */
.total-trio { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--space-4); align-items: end; }
@media (max-width: 640px) { .total-trio { grid-template-columns: 1fr 1fr; } }
.total-col { display: flex; flex-direction: column; gap: 2px; }
.total-figure-sm { font-size: 22px; line-height: 28px; }
.match-warn { display: flex; align-items: flex-start; gap: 4px; color: var(--near-budget); font-weight: 600; margin-bottom: 4px; }
.pack-min { color: var(--near-budget); }
.order-online { display: block; margin-top: 2px; color: var(--accent); font-weight: 600; }
.level-partial { border-style: dashed; }
.rec-guess { color: var(--near-budget); }


/* ---------- v1.4: search elsewhere, needs summary, store list filters ---------- */
.pick-else { border-top: 1px dashed var(--line); margin-top: var(--space-3); padding-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.else-links { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.else-links a { color: var(--accent); font-weight: 600; }
.typed-price { display: flex; flex-direction: column; gap: 4px; }
.typed-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(140px, 2fr) minmax(90px, 0.8fr) minmax(120px, 1.4fr) auto; gap: var(--space-2); align-items: center; }
.typed-row input { min-width: 0; min-height: 36px; padding: 4px 8px; }
@media (max-width: 760px) { .typed-row { grid-template-columns: 1fr 1fr; } }
.store-tag { color: var(--accent); font-weight: 600; }
.cov-summary { margin: 2px 0 0; color: var(--ink-muted); }
.cov-status { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.stores-card { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-2); }
.store-filters { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(140px, 1.4fr) minmax(160px, 1.4fr) minmax(120px, 1fr) minmax(130px, 1fr) auto; gap: var(--space-3); align-items: end; }
@media (max-width: 1000px) { .store-filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .store-filters { grid-template-columns: 1fr; } }
.stores-card .vendor-grid { margin-top: 0; }

/* ---------- v1.5: plan-based total card, Supply Run button ---------- */
.supply-run-btn { flex-wrap: wrap; gap: 6px; }
.supply-run-btn .btn-sub { flex-basis: 100%; text-align: center; font-weight: 500; font-size: 12px; opacity: 0.85; }

/* ---------- v1.6: Pro bid card ---------- */
.bid-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--space-3); }
.bid-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.flag-warn { color: var(--near-budget); border-color: var(--near-budget); }
.flag-suggest { color: var(--accent); border-color: var(--accent); }
.flag-ok { color: #A5D6A7; border-color: #A5D6A7; }
.bid-break { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: var(--space-3) 0; }
@media (max-width: 640px) { .bid-break { grid-template-columns: 1fr 1fr; } }
.bid-cell { display: flex; flex-direction: column; gap: 2px; }
.bid-num { font-size: 18px; font-weight: 700; }
.cost-line { margin: 0; }
button.price-source.price-accept { background: none; border: 1px dashed currentColor; border-radius: 999px; padding: 1px 8px; cursor: pointer; font: inherit; font-size: 12px; min-height: 0; }
.bid-box { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
button.bid-figure { background: none; border: 1px dashed transparent; border-radius: var(--radius-sm); padding: 0 6px; margin-left: -6px; color: inherit; cursor: text; display: inline-flex; align-items: baseline; gap: 8px; min-height: 0; }
button.bid-figure:hover, button.bid-figure:focus-visible { border-color: var(--accent); }
.bid-edit-hint { font-size: 12px; font-weight: 600; color: var(--accent); }
.bid-edit-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.bid-input { font-size: 28px; font-weight: 700; width: 220px; min-height: 48px; padding: 4px 10px; }
.bid-vs { margin: 4px 0 0; }

/* ---------- v1.7: everything on a line is editable ---------- */
.item-name-input { width: 100%; min-width: 180px; font-weight: 600; background: transparent; border: 1px solid transparent; padding: 4px 6px; margin-left: -6px; min-height: 34px; }
.item-name-input:hover { border-color: var(--line); }
.item-name-input:focus { border-color: var(--accent); background: var(--surface-raised); }
input.line-total-input { font-weight: 700; }
.median-cell input.cost { width: 100%; max-width: 120px; }

/* ---------- v1.8: The Clipboard ---------- */
.cb-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: var(--space-4); align-items: start; margin-bottom: var(--space-4); }
@media (max-width: 900px) { .cb-layout { grid-template-columns: 1fr; } }
.cb-opts { display: flex; flex-direction: column; gap: var(--space-2); }
.cb-opts .field { margin: 0; }
.cb-h { margin: var(--space-3) 0 0; font-size: 15px; }
.cb-actions { margin-top: var(--space-3); }
.cb-main { padding: 0; overflow: hidden; }
.cb-preview { width: 100%; height: 900px; border: 0; background: #fff; display: block; }
@media (max-width: 900px) { .cb-preview { height: 640px; } }
.cb-email { display: flex; flex-direction: column; gap: var(--space-2); border-top: 1px solid var(--line); padding-top: var(--space-3); }
.cb-email textarea, .logo-box textarea { width: 100%; }
.logo-box { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.logo-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.logo-preview { max-width: 200px; max-height: 80px; background: #fff; border-radius: var(--radius-sm); padding: 6px; }
.logo-empty { display: inline-flex; align-items: center; justify-content: center; width: 200px; height: 80px; border: 1px dashed var(--line); border-radius: var(--radius-sm); }

/* ---------- v1.8.4: Jobsite card scope ---------- */
.scope-box { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.scope-full { white-space: pre-line; }
.link-btn { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }

/* ---------- v1.9: line notes, wrapping names ---------- */
textarea.item-name-input { resize: none; overflow: hidden; line-height: 1.35; font: inherit; font-weight: 600; display: block; }
.line-note { color: var(--ink-muted); font-style: italic; margin: 2px 0 4px; white-space: pre-line; }
.line-note-field { margin-bottom: var(--space-3); }
.line-note-input { width: 100%; }
.pre-line { white-space: pre-line; }
