/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg: #f7f6f4;
  --surface: #ffffff;
  --surface-2: #f3f1ee;
  --border: #e8e4de;
  --border-strong: #d5cfc6;
  --text: #1c1917;
  --text-muted: #6b645c;
  --accent: #fb923c;          /* light orange — fills */
  --accent-hover: #f97f1e;
  --accent-text: #c2550c;     /* orange that's readable as text */
  --accent-soft: #fff3e8;
  --accent-ring: rgba(251, 146, 60, 0.28);
  --on-accent: #2a1405;       /* text on orange fills */
  --success: #15803d;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 6px 20px -6px rgba(28, 25, 23, 0.12), 0 2px 4px -2px rgba(28, 25, 23, 0.05);
  --shadow-lg: 0 18px 36px -14px rgba(234, 120, 30, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100e;
    --surface: #1b1815;
    --surface-2: #24201c;
    --border: #2f2a25;
    --border-strong: #423b34;
    --text: #f1ede8;
    --text-muted: #a39a90;
    --accent: #fdba74;
    --accent-hover: #fed7aa;
    --accent-text: #fdba74;
    --accent-soft: rgba(253, 186, 116, 0.1);
    --accent-ring: rgba(253, 186, 116, 0.25);
    --on-accent: #2a1405;
    --success: #4ade80;
    --danger: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 18px 36px -14px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12100e;
  --surface: #1b1815;
  --surface-2: #24201c;
  --border: #2f2a25;
  --border-strong: #423b34;
  --text: #f1ede8;
  --text-muted: #a39a90;
  --accent: #fdba74;
  --accent-hover: #fed7aa;
  --accent-text: #fdba74;
  --accent-soft: rgba(253, 186, 116, 0.1);
  --accent-ring: rgba(253, 186, 116, 0.25);
  --on-accent: #2a1405;
  --success: #4ade80;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 36px -14px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.has-items { padding-bottom: 72px; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent-text); }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); font-weight: 400; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1280px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__mark svg { width: 36px; height: 36px; display: block; }
.brand__mark rect { fill: var(--accent); }
.brand__mark path { stroke: var(--on-accent); stroke-width: 3; stroke-linecap: round; fill: none; }
.brand__name { font-weight: 700; letter-spacing: -0.01em; }
.brand__sub { font-size: 0.8rem; color: var(--text-muted); }

/* ==========================================================================
   Page & sections
   ========================================================================== */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 40px; }
.section { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section__head p { margin-top: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 600px) {
  .page { padding: 20px 16px 40px; gap: 32px; }
  .topbar__inner { padding: 10px 16px; }
  .brand__sub { display: none; }
}

/* ==========================================================================
   Product images
   ========================================================================== */
.pimg {
  display: grid; place-items: center; flex-shrink: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
}
.pimg img { width: 100%; height: 100%; object-fit: contain; padding: 12%; display: block; }
.pimg--sm { width: 36px; height: 36px; border-radius: 9px; }
.pimg--md { width: 52px; height: 52px; border-radius: 12px; }
.pimg--lg { width: 64px; height: 64px; border-radius: 14px; }
.pimg.is-placeholder {
  border-color: transparent;
  background:
    repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--accent) 10%, transparent) 6px 7px),
    var(--accent-soft);
}
.pimg__ph { font-weight: 700; color: var(--accent-text); letter-spacing: 0.02em; }
.pimg--sm .pimg__ph { font-size: 0.72rem; }
.pimg--md .pimg__ph { font-size: 0.95rem; }
.pimg--lg .pimg__ph { font-size: 1.15rem; }

/* ==========================================================================
   Catalog
   ========================================================================== */
.catalog { display: grid; grid-template-columns: 250px minmax(0, 1fr); overflow: hidden; }
.catalog__nav { border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.catalog__main { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.catalog__heading { display: flex; align-items: baseline; gap: 10px; }
.catalog__heading .muted { font-size: 0.85rem; }

.search { position: relative; display: block; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 36px; }

.catnav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.catnav__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.catnav__btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 0; border-radius: 8px;
  background: transparent;
  font: inherit; font-size: 0.875rem; font-weight: 500;
  color: var(--text-muted);
  text-align: left; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.catnav__btn span:nth-child(2) { flex: 1; }
.catnav__btn .icon { width: 16px; height: 16px; }
.catnav__btn:hover { background: var(--surface); color: var(--text); }
.catnav__btn.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.catnav__btn.is-active .icon { color: var(--accent-text); }
.catnav__count { font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 12px; }
.tile {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.tile:has(.tile__open:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile__top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.tile__badge {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: 0.72rem; font-weight: 700;
}
.tile__badge .icon { width: 12px; height: 12px; stroke-width: 3; }
.tile__name { font-size: 0.95rem; font-weight: 650; margin: 0; }
.tile__open {
  font: inherit; color: inherit; text-align: left;
  padding: 0; border: 0; background: none; cursor: pointer;
}
.tile__open:focus-visible { outline: none; }
.tile__desc { font-size: 0.8rem; color: var(--text-muted); flex: 1; }
.tile__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.tile__price { font-size: 0.78rem; color: var(--text-muted); }
.tile__price strong { color: var(--text); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.tile__add {
  display: inline-flex; align-items: center; gap: 4px;
  font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tile__add .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.tile__add:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.empty-search { padding: 24px 0; text-align: center; }

@media (max-width: 860px) {
  .catalog { grid-template-columns: minmax(0, 1fr); }
  .catalog__nav { border-right: 0; border-bottom: 1px solid var(--border); }
  .catnav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 2px; scrollbar-width: none; }
  .catnav::-webkit-scrollbar { display: none; }
  .catnav__sep { display: none; }
  .catnav__btn { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
  .catnav__btn.is-active { border-color: var(--accent); }
  .catnav__count { display: none; }
  .catalog__main { padding: 16px; }
}

/* ==========================================================================
   Estimate header & customer details
   ========================================================================== */
.estimate__head { align-items: center; }
.estimate__title { flex: 1; min-width: 220px; }
.title-input {
  font: inherit; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text);
  border: 1px solid transparent; border-radius: 8px;
  background: transparent;
  padding: 2px 8px; margin-left: -9px;
  width: 100%; max-width: 520px;
  transition: border-color 0.15s, background 0.15s;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
.title-input::placeholder { color: var(--text); opacity: 1; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; }

.details-card summary {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  cursor: pointer; list-style: none;
  font-size: 0.9rem;
}
.details-card summary::-webkit-details-marker { display: none; }
.details-card__title { font-weight: 650; }
.details-card summary .muted { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.details-card__chev { color: var(--text-muted); transition: transform 0.2s; }
.details-card[open] .details-card__chev { transform: rotate(180deg); }
.details-card .grid { padding: 0 18px 18px; }

/* ==========================================================================
   Form fields
   ========================================================================== */
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 0.78rem; font-weight: 600; }
.static-value { padding: 10px 0; font-size: 0.9rem; }

:where(input[type="text"], input[type="search"], input[type="number"], select, textarea) {
  font: inherit; font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* Drop the native select styling (Safari ignores padding on it) so selects match the inputs. */
:where(select) {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8178' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  text-overflow: ellipsis;
  cursor: pointer;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
textarea { resize: vertical; min-height: 76px; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.input-affix { position: relative; }
.input-affix input { padding-right: 32px; }
.input-affix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

.stepper {
  display: flex; align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.stepper input { border: 0; border-radius: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: none !important; padding-right: 6px; min-width: 0; }
.stepper__unit { font-size: 0.8rem; color: var(--text-muted); padding-right: 10px; white-space: nowrap; min-width: 64px; }
.stepper__btn {
  font: inherit; font-size: 1.1rem;
  width: 40px; align-self: stretch; flex-shrink: 0;
  border: 0; background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.stepper__btn:hover { background: var(--accent-soft); color: var(--accent-text); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.9rem; padding: 8px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s; }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(110px, 100%), 1fr));
  gap: 4px; padding: 4px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.segmented__opt { position: relative; cursor: pointer; }
.segmented__opt input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__opt span {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 8px; min-height: 46px; border-radius: 7px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented__opt small { font-size: 0.7rem; color: var(--success); font-weight: 600; }
.segmented__opt:hover span { color: var(--text); }
.segmented__opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.segmented__opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ==========================================================================
   Estimate items
   ========================================================================== */
.items { display: flex; flex-direction: column; gap: 10px; }
.items:empty { display: none; }
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s, border-color 0.3s;
  animation: item-in 0.25s ease-out;
}
.item.is-flash { box-shadow: 0 0 0 4px var(--accent-ring), var(--shadow-md); }
@keyframes item-in { from { opacity: 0; transform: translateY(-4px); } }

.item__head { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 10px; }
.item__toggle {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-muted); cursor: pointer;
}
.item__toggle:hover { background: var(--surface-2); color: var(--text); }
.item__toggle .icon { transform: rotate(-90deg); transition: transform 0.2s; }
.item.is-open .item__toggle .icon { transform: rotate(0); }
.item__title { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.item__name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__label { font-weight: 400; color: var(--text-muted); }
.item__summary { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__cost { text-align: right; display: flex; flex-direction: column; flex-shrink: 0; }
.item__amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.item__period { font-size: 0.75rem; color: var(--text-muted); }
.item__actions { display: flex; gap: 2px; flex-shrink: 0; }

.item__body { display: none; padding: 4px 18px 18px 56px; flex-direction: column; gap: 14px; }
.item.is-open .item__body { display: flex; }
.item__desc { font-size: 0.85rem; }
.item__math {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 14px; border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.84rem; font-variant-numeric: tabular-nums;
}
.item__math div { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.item__math span { color: var(--text-muted); }
.item__math .is-waived strong { text-decoration: line-through; color: var(--text-muted); font-weight: 500; }

@media (max-width: 640px) {
  .item__head { flex-wrap: wrap; padding: 10px; gap: 10px; }
  .item__head .pimg { display: none; }
  .item__title { flex-basis: calc(100% - 140px); }
  .item__cost { order: 3; flex: 1; flex-direction: row; align-items: baseline; gap: 6px; padding-left: 40px; text-align: left; }
  .item__actions { order: 4; }
  .item__body { padding: 4px 14px 14px; }
}

.link-btn {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: middle;
  font: inherit; font-weight: 600; color: var(--accent-text);
  padding: 0; margin-left: 6px; border: 0; background: none; cursor: pointer;
}
.link-btn .icon { width: 14px; height: 14px; }
.link-btn:hover { text-decoration: underline; }

/* Per-option quantities on an estimate line */
.field--wide { grid-column: 1 / -1; }
.optqty { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.optqty__row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.optqty__row:last-child { border-bottom: 0; }
.optqty__name { flex: 1; min-width: 140px; font-size: 0.9rem; font-weight: 500; }
.optqty__price { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stepper--sm { width: 130px; flex-shrink: 0; }
.stepper--sm input { text-align: center; padding: 6px 4px; }
.stepper--sm .stepper__btn { width: 34px; }
.item__math-total { border-top: 1px solid var(--border-strong); padding-top: 4px; margin-top: 2px; }
.item__math-total span { color: var(--text) !important; font-weight: 600; }

/* Empty state */
.empty { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; border-style: dashed; box-shadow: none; }
.empty__icon { width: 44px; height: 44px; padding: 11px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 6px; }
.empty .btn { margin-top: 10px; text-decoration: none; }

/* ==========================================================================
   Totals
   ========================================================================== */
.totals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.totals__settings { padding: 24px; display: flex; flex-direction: column; gap: 16px; border-right: 1px solid var(--border); }
.totals__summary { padding: 24px; display: flex; flex-direction: column; gap: 16px; background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
@media (max-width: 860px) {
  .totals { grid-template-columns: minmax(0, 1fr); }
  .totals__settings { border-right: 0; border-bottom: 1px solid var(--border); }
  .totals__summary { border-radius: 0 0 var(--radius) var(--radius); }
}
@media (max-width: 600px) { .totals__settings, .totals__summary { padding: 18px; } }

.lines { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.lines td { padding: 6px 0; font-variant-numeric: tabular-nums; }
.lines td.num { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 12px; }
.lines .is-discount td.num { color: var(--success); }
.lines .is-sep td { border-top: 1px dashed var(--border-strong); padding-top: 10px; }

.hero-number {
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 20px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #fed7aa, #fb923c);
  color: var(--on-accent);
}
.hero-number__label { font-size: 0.8rem; font-weight: 600; opacity: 0.8; }
.hero-number__value { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; flex-direction: column; min-width: 0; }
.kpi--wide { grid-column: 1 / -1; }
.kpi__label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.kpi__value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 480px) { .actions { grid-template-columns: 1fr; } }
.disclaimer { font-size: 0.72rem; color: var(--text-muted); text-align: center; }

/* ==========================================================================
   Sticky total bar
   ========================================================================== */
.totalbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
}
body.has-items .totalbar { transform: none; }
.totalbar__inner { max-width: 1280px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 20px; }
.totalbar__count { font-size: 0.85rem; color: var(--text-muted); flex: 1; }
.totalbar__figures { display: flex; gap: 24px; }
.totalbar__figures div { display: flex; flex-direction: column; align-items: flex-end; }
.totalbar__label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.totalbar__value { font-weight: 700; font-variant-numeric: tabular-nums; }
.totalbar__value--main { color: var(--accent-text); font-size: 1.1rem; }
@media (max-width: 600px) {
  .totalbar__inner { padding: 8px 16px; gap: 12px; }
  .totalbar__count { display: none; }
  .totalbar__figures { flex: 1; justify-content: flex-start; gap: 18px; }
  .totalbar__figures div { align-items: flex-start; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--accent); }
.btn--ghost { background: transparent; color: var(--text-muted); padding: 8px 10px; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--ghost.btn--danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn--icon { padding: 7px; }
.btn--sm { padding: 7px 12px; }

/* ==========================================================================
   Product details dialog (side panel)
   ========================================================================== */
.product-dialog {
  margin: 0 0 0 auto; padding: 0;
  width: min(520px, 100vw); max-width: 100vw;
  height: 100dvh; max-height: 100dvh;
  border: 0; border-left: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  box-shadow: -20px 0 40px -20px rgba(0, 0, 0, 0.35);
}
.product-dialog[open] { animation: panel-in 0.22s ease-out; }
.product-dialog::backdrop { background: rgba(20, 16, 12, 0.45); backdrop-filter: blur(2px); }
@keyframes panel-in { from { transform: translateX(32px); opacity: 0; } }

.pd { display: flex; flex-direction: column; height: 100%; }
.pd__head { display: flex; align-items: center; gap: 14px; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--border); }
.pd__titles { flex: 1; min-width: 0; }
.pd__cat { font-size: 0.75rem; font-weight: 600; color: var(--accent-text); text-transform: uppercase; letter-spacing: 0.04em; }
.pd__titles h2 { font-size: 1.25rem; }
.pd__body { flex: 1; overflow-y: auto; padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.pd__body h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; }
.pd__lead { font-size: 1rem; font-weight: 500; }
.pd__overview { color: var(--text-muted); font-size: 0.9rem; }
.pd__facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pd__facts div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; }
.pd__facts span { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.pd__facts strong { font-size: 0.85rem; }
.pd__fact-cap::first-letter { text-transform: uppercase; }
.pd__includes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }
.pd__includes li { display: flex; gap: 10px; align-items: flex-start; }
.pd__includes .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--success); stroke-width: 2.5; }
.pd__options { display: flex; flex-direction: column; gap: 8px; }
.pd__option {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.pd__option:hover { border-color: var(--border-strong); }
.pd__option input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.pd__radio {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); border-radius: 50%;
  display: grid; place-items: center;
  transition: border-color 0.15s;
}
.pd__radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform 0.15s; }
.pd__option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pd__option:has(input:checked) .pd__radio { border-color: var(--accent); }
.pd__option:has(input:checked) .pd__radio::after { transform: scale(1); }
.pd__option:has(input[type="radio"]:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pd__hint { font-size: 0.82rem; margin: -4px 0 10px; }
.pd__sum { margin-top: 10px; font-size: 0.85rem; color: var(--text-muted); }
.pd__qty { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.pd__qty .stepper { width: 220px; }
.pd__sum-setup { color: var(--text-muted); white-space: nowrap; }
.pd__sum strong { color: var(--text); font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.pd__option--qty { cursor: default; flex-wrap: wrap; }
.pd__option--qty:hover { border-color: var(--border); }
.pd__option-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.info-btn {
  width: 22px; height: 22px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.info-btn .icon { width: 16px; height: 16px; }
.info-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.info-pop {
  position: fixed; inset: auto; margin: 0;
  width: min(300px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem; line-height: 1.45;
}
.info-pop strong { display: block; margin-bottom: 4px; }
.info-pop p { color: var(--text-muted); }
.pd__option-price { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pd__option-price span { display: block; font-size: 0.72rem; color: var(--text-muted); }
.pd__foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.pd__foot .muted { flex: 1; font-size: 0.82rem; }
@media (max-width: 480px) {
  .pd__facts { grid-template-columns: 1fr; }
  .pd__head, .pd__body, .pd__foot { padding-left: 16px; padding-right: 16px; }
  .pd__foot .btn--secondary { display: none; }
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: 88px; z-index: 100;
  display: flex; align-items: center; gap: 14px;
  transform: translate(-50%, 16px);
  padding: 10px 12px 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  font-size: 0.875rem; font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast__action {
  font: inherit; font-size: 0.8rem; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--on-accent); cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Mobile & touch refinements (desktop is unaffected)
   ========================================================================== */
.pd__foot-total { display: none; }

/* Touch devices: no hover lift, bigger hit areas for small icon buttons */
@media (hover: none) {
  .tile:hover { transform: none; box-shadow: none; border-color: var(--border); }
  .info-btn { position: relative; }
  .info-btn::before { content: ""; position: absolute; inset: -9px; }
  /* The dialog focuses its close button on open; don't ring it on touch screens */
  .pd__head [data-close]:focus-visible { outline: none; }
}

@media (max-width: 600px) {
  /* 16px text stops iOS Safari zooming in when a field is focused */
  :where(input[type="text"], input[type="search"], input[type="number"], select, textarea) { font-size: 16px; }

  /* Compact product cards: image beside the text, price + Add underneath */
  .tiles { gap: 10px; }
  .tile {
    display: grid; grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px; row-gap: 2px; padding: 12px;
  }
  .tile__top { grid-column: 1; grid-row: 1 / span 2; margin: 0; }
  .tile .pimg--md { width: 44px; height: 44px; border-radius: 10px; }
  .tile__badge { position: absolute; top: 10px; right: 10px; }
  .tile__name { grid-column: 2; padding-right: 40px; }
  .tile__desc {
    grid-column: 2;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .tile__foot { grid-column: 1 / -1; margin-top: 8px; padding-top: 8px; }
  .tile__add { padding: 8px 14px; }

  /* Bigger touch targets */
  .btn--icon { padding: 10px; }
  .item__toggle { width: 36px; height: 36px; }
  .catnav__btn { padding: 9px 12px; }

  /* Per-option quantity rows: name + price on the left, stepper on the right */
  .optqty__row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name step" "price step";
    column-gap: 10px; row-gap: 0; padding: 8px 8px 8px 12px;
  }
  .optqty__name { grid-area: name; min-width: 0; }
  .optqty__price { grid-area: price; font-size: 0.75rem; }
  .optqty__row .stepper--sm { grid-area: step; }
  .stepper--sm { width: 120px; }

  /* Product details: full-screen sheet that slides up */
  .product-dialog { width: 100vw; border-left: 0; }
  .product-dialog[open] { animation: sheet-in 0.25s ease-out; }
  .pd__head { padding: 14px 16px; gap: 12px; }
  .pd .pimg--lg { width: 52px; height: 52px; border-radius: 12px; }
  .pd__titles h2 { font-size: 1.1rem; }
  .pd__body { padding: 16px 16px 20px; gap: 18px; }
  .pd__lead { font-size: 0.95rem; }
  /* Facts as compact label/value rows instead of three stacked boxes */
  .pd__facts { grid-template-columns: 1fr; gap: 0; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px 12px; }
  .pd__facts div { flex-direction: row; justify-content: space-between; align-items: baseline; padding: 8px 0; background: none; border-radius: 0; }
  .pd__facts div + div { border-top: 1px solid var(--border); }
  .pd__facts span { font-size: 0.8rem; }
  .pd__option { padding: 10px 12px; gap: 10px; }
  .pd__option--qty { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name step" "price step"; row-gap: 2px; }
  .pd__option--qty .pd__option-name { grid-area: name; }
  .pd__option--qty .pd__option-price { grid-area: price; text-align: left; display: flex; gap: 4px; align-items: baseline; }
  .pd__option--qty .pd__option-price span { display: inline; }
  .pd__option--qty .stepper--sm { grid-area: step; }
  .pd__foot { padding: 12px 16px; }
  .pd__foot .btn--secondary { display: none; }
  .pd__foot .btn--primary { flex: 1; padding: 12px 16px; }
  /* Running total stays visible in the footer while scrolling long option lists */
  .pd__foot-total { display: flex; flex-direction: column; line-height: 1.2; }
  .pd__foot-total span { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
  .pd__foot-total strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
  .pd__foot:has(.pd__foot-total) .pd__foot-note { display: none; }
  .pd__foot .pd__foot-note:empty { display: none; }
  .pd__foot .pd__foot-note { flex: 1; }

  /* Totals: actions stay full-width; tighten the hero number */
  .hero-number__value { font-size: 2rem; }

  /* Toast sits just above the total bar */
  .toast { bottom: 76px; }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }

/* ==========================================================================
   Print — only the generated estimate sheet is printed
   ========================================================================== */
.print-sheet { display: none; }

@media print {
  body { background: #fff; color: #000; padding: 0 !important; font-size: 10.5pt; }
  .topbar, .page, .totalbar, .toast { display: none !important; }
  .print-sheet { display: block; }
  .print-sheet header { border-bottom: 3px solid #fb923c; padding-bottom: 10px; margin-bottom: 16px; }
  .print-sheet h1 { font-size: 18pt; margin-bottom: 4px; }
  .print-sheet h2 { font-size: 11pt; margin: 16px 0 4px; }
  .print-sheet header p { color: #444; }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th { text-align: left; font-size: 8.5pt; text-transform: uppercase; letter-spacing: 0.04em; color: #555; border-bottom: 1px solid #999; padding: 6px 6px 6px 0; }
  .print-sheet td { padding: 6px 6px 6px 0; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
  .print-sheet td span { color: #666; font-size: 9pt; }
  .print-sheet .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .print-sheet tfoot td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; }
  .print-sheet tfoot tr:first-child td { padding-top: 12px; }
  .print-sheet tfoot td:first-child { text-align: right; }
  .print-sheet tfoot .strong td { font-weight: 700; font-size: 11.5pt; }
  .print-sheet .pre { white-space: pre-wrap; }
  .print-sheet .fine { margin-top: 24px; font-size: 8.5pt; color: #777; }
}
