:root {
  --bg: #faf8f4;
  --ink: #1d1d1b;
  --muted: #5d5a54;
  --line: #e3ded4;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --card: #ffffff;
  --soft: #f3efe7;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --info: #1d4ed8;
  --info-bg: #eff4ff;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --ink: #f1eee8;
    --muted: #a8a39a;
    --line: #2e2b27;
    --accent: #fb923c;
    --accent-ink: #1d1d1b;
    --card: #1f1d1a;
    --soft: #262420;
    --ok: #4ade80;
    --ok-bg: #12251a;
    --info: #93b4ff;
    --info-bg: #161e33;
    --err: #f87171;
    --err-bg: #2a1515;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: clamp(24px, 4.5vw, 32px); line-height: 1.2; letter-spacing: -0.015em; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1080px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-row { display: flex; align-items: baseline; gap: 14px; padding: 16px 0 6px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.logo span { color: var(--accent); }
.shop-name { color: var(--muted); font-size: 15px; }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { padding: 8px 12px 10px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a.on, .nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }

.demo-banner { background: var(--ink); color: var(--bg); font-size: 15px; }
.demo-banner-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.demo-banner form { margin: 0; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 20px 0 32px; }

/* Buttons */
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 8px; cursor: pointer; text-decoration: none;
  text-align: center; line-height: 1.3;
}
.btn:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-small { padding: 6px 12px; font-size: 14px; }
.btn-block { display: block; width: 100%; margin: 14px 0 8px; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; padding: 6px 0; text-decoration: underline; }
.link-btn[hidden] { display: none; }

/* Cards and layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin: 0 0 16px; min-width: 0; }
fieldset.card { margin: 0 0 16px; }
.card.empty { text-align: center; padding: 32px 18px; }
.line-title { font-weight: 700; padding: 0 6px; margin-left: -6px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 8px 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { margin: 0; font-size: 14px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.col { min-width: 0; }

/* Notices */
.notice { border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; border: 1px solid; }
.notice p:last-child { margin-bottom: 0; }
.notice-ok { background: var(--ok-bg); border-color: var(--ok); }
.notice-info { background: var(--info-bg); border-color: var(--info); }
.notice-error { background: var(--err-bg); border-color: var(--err); }
.errors { margin: 6px 0 0; padding-left: 20px; }

/* Badges */
.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
.badge-viewed { border-color: var(--info); color: var(--info); background: var(--info-bg); }
.badge-approved { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); min-width: 0; }
.field > span { font-weight: 600; }
input, select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); flex: none; margin-top: 2px; }
input[type="file"] { padding: 8px; }
fieldset { border: 1px solid var(--line); }
fieldset[disabled] input, fieldset[disabled] select { opacity: 0.85; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.four { grid-template-columns: 2fr 1fr 1fr 1fr; }
.grid.four .span-2 { grid-column: auto; }
.line-grid { grid-template-columns: repeat(4, 1fr); }
.line-grid .span-2 { grid-column: span 4; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; cursor: pointer; margin: 6px 0; }
.finishes { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 2px 20px; align-items: flex-start; }
.finishes-label { font-size: 14px; font-weight: 600; color: var(--muted); width: 100%; }
.line-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.line-msg { color: var(--err); font-size: 14px; }
.line-total { font-weight: 700; margin-left: auto; }
.form-foot { display: flex; justify-content: flex-end; }
.upload { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.approve { display: flex; flex-direction: column; gap: 10px; }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.builder-main, .builder-side { min-width: 0; }
.sticky { position: sticky; top: 12px; }

/* Breakdown and totals */
.breakdown { font-size: 14px; }
.bd-line { border-bottom: 1px dashed var(--line); padding: 0 0 10px; margin: 0 0 10px; }
.bd-head { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; font-weight: 600; }
.bd-steps { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.bd-steps li { margin: 2px 0; overflow-wrap: anywhere; }
.totals { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
.totals th { text-align: left; font-weight: 400; padding: 5px 0; color: var(--muted); }
.totals td { text-align: right; padding: 5px 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals tr.strong th, .totals tr.strong td { font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); }

/* Quote list */
.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list th, .list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--soft); }
.list tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* Pricing tables */
.edit { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.edit th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.edit td { padding: 4px 6px; vertical-align: middle; }
.edit td:first-child { width: 50%; }

/* Quote status */
.timeline { list-style: none; padding: 0; margin: 0 0 8px; }
.timeline li { padding: 6px 0 6px 26px; position: relative; color: var(--muted); }
.timeline li span:first-child { font-weight: 600; margin-right: 6px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 12px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); }
.timeline li.done { color: var(--ink); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.copy-field { display: flex; gap: 8px; margin: 8px 0 10px; }
.copy-field input { font-size: 14px; }
.proof { margin: 0 0 12px; }
.proof img { display: block; max-width: 100%; max-height: 260px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 4px; background: var(--soft); }

/* Customer page */
.cq-head { margin: 8px 0 18px; }
.cq-shop { font-weight: 800; font-size: 20px; color: var(--accent); }
.cq-head h1 { margin: 4px 0 4px; }
.demo-note { margin: 0 0 4px; }
.items { border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.item { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item-title { font-weight: 600; }
.item-meta { font-size: 15px; }
.item-detail { font-size: 13px; color: var(--muted); }
.item-amount { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.proof-figure { margin: 0 0 10px; }
.proof-figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.proof-figure figcaption { margin-top: 6px; }
.pay summary { list-style: none; display: inline-block; }
.pay summary::-webkit-details-marker { display: none; }
.pay[open] summary { margin-bottom: 12px; }
.pay .notice { margin: 0; }

@media (max-width: 860px) {
  .builder { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .cols { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: 1fr 1fr; }
  .grid.four .span-2 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .grid.two { grid-template-columns: 1fr; }
  .line-grid { grid-template-columns: 1fr 1fr; }
  .line-grid .span-2 { grid-column: span 2; }
  .card { padding: 14px; }
  /* Stack table rows as cards on phones. */
  .list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list thead { display: none; }
  .list tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .list tr:last-child { border-bottom: 0; }
  .list td { border: 0; padding: 3px 14px; display: flex; justify-content: space-between; gap: 12px; }
  .list td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  .num { text-align: left !important; }
  .edit thead { display: none; }
  .edit, .edit tbody, .edit tr, .edit td { display: block; width: 100% !important; }
  .edit tr { border-top: 1px solid var(--line); padding: 8px 0; }
  .edit td { padding: 3px 0; }
  .edit td::before { content: attr(data-label); display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
}
