/* Smart Estimate — look and layout (phone first, then computer, then print) */
:root {
  color-scheme: light;
  --bg: #f5f1ec;
  --card: #ffffff;
  --ink: #221b15;
  --muted: #6e6359;
  --line: #e6ddd3;
  --line-strong: #d3c6b8;
  --brand: #6b3a17;
  --brand-2: #8a5226;
  --brand-soft: #f4e8dc;
  --ok: #1d7a4c;
  --ok-soft: #e4f4ea;
  --warn-bg: #fff4e0;
  --warn-line: #f0a441;
  --warn-ink: #8a4a00;
  --bad: #b42318;
  --info-bg: #eef4ff;
  --info-line: #9db8ee;
  --wa: #1f9d55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 35, 10, .06), 0 4px 14px rgba(60, 35, 10, .05);
  --nav-h: 62px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font);
  padding-bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
a { color: var(--brand); }
q { quotes: "“" "”"; font-style: italic; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }

/* ---------- top bar + navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px;
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; flex: 1; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabs a.on { color: var(--brand); }
.tabs a.on svg { stroke-width: 2.6; }
.sync-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .14); position: relative; padding: 0;
}
.sync-dot::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: #c9b8a8; }
.sync-dot.ok::after { background: #5fd394; }
.sync-dot.wait::after, .sync-dot.run::after { background: #ffc15a; }
.sync-dot.run::after { animation: pulse 1s infinite alternate; }
.sync-dot.err::after { background: #ff6b5b; }
@keyframes pulse { to { opacity: .35; } }

/* ---------- page + cards ---------- */
.page { max-width: 1000px; margin: 0 auto; padding: 16px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.card.warn h2 { color: var(--warn-ink); }
.card.info { background: var(--info-bg); border-color: var(--info-line); }
.group-title { margin: 22px 4px 10px; color: var(--brand); }
.empty { padding: 22px 8px; text-align: center; color: var(--muted); }

/* ---------- form parts ---------- */
.field { margin-bottom: 12px; min-width: 0; }
.field > label, .line label, .toggles label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(138, 82, 38, .18); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); }
input[type="file"] { padding: 8px; }
.grid2, .grid3 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.radio { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; color: var(--ink) !important; font-size: 15px !important; margin: 6px 0; }
details.more summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; margin: 2px 0 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #faf6f1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.busy { opacity: .6; pointer-events: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: #f6eee6; color: var(--bad); }
.linkbtn { border: 0; background: none; color: var(--brand); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 4px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.tag { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-style: normal; }

/* ---------- party name box with suggestions ---------- */
.combo { position: relative; }
.combo input { padding-right: 44px; font-weight: 600; }
.clear-x {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; border-radius: 8px;
}
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
  max-height: 320px; overflow-y: auto;
}
.sug { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sug:last-child { border-bottom: 0; }
.sug span { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.sug small { font-weight: 400; color: var(--muted); }
.sug:hover, .sug.on { background: var(--brand-soft); }
.sug-x { border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; font-size: 20px; color: var(--muted); cursor: pointer; }
.sug-x:hover { color: var(--bad); background: #fff; }

/* ---------- problem rows ---------- */
.problem { border-top: 1px dashed var(--warn-line); padding-top: 12px; margin-top: 12px; }
.problem input { margin: 6px 0; background: #fff; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- estimate lines ---------- */
.line { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fff; }
.line.has-issue { border-color: var(--warn-line); background: #fffaf2; }
.line-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ln-no {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px;
}
.line-head .prod { flex: 1; min-width: 0; font-weight: 600; }
.line-dims { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.line label { margin: 0; }
.line label input, .line label select { margin-top: 4px; }
.inwrap { display: flex; gap: 4px; margin-top: 4px; }
.inwrap input, .inwrap select { margin-top: 0 !important; }
.inwrap select { width: 76px; flex: none; padding: 8px 6px; }
.line-rate { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-top: 10px; }
.line-rate .grow { flex: 1 1 260px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important;
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink) !important; font-size: 13px !important; cursor: pointer; min-height: 40px;
}
.chip.on { background: var(--brand-soft); border-color: var(--brand-2); color: var(--brand) !important; }
.line-calc {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin-top: 10px; padding: 10px 12px; background: #faf6f1; border-radius: 10px;
}
.calc-qty { font-weight: 700; }
.op { color: var(--muted); }
.rate-wrap { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.rate { width: 110px; min-height: 38px; padding: 6px 10px; font-weight: 700; }
.amt { margin-left: auto; font-size: 17px; }
.issues { color: var(--warn-ink); font-size: 13px; font-weight: 600; }
.issues div { margin-top: 6px; }
.line-src { margin-top: 8px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- totals ---------- */
.charges .charge { display: grid; grid-template-columns: 1fr 120px 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.btnrow.wrap { margin-bottom: 12px; }
.toggles { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; margin: 8px 0 14px; }
.toggles label.switch { display: inline-flex; align-items: center; gap: 10px; margin: 0; color: var(--ink); font-size: 15px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 44px; height: 26px; border-radius: 999px; background: #d8ccc0; position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(138, 82, 38, .3); }
.gst-rate { display: inline-flex; align-items: center; gap: 6px; }
.gst-rate input { width: 70px; min-height: 36px; padding: 6px 8px; }
.qty-sum { margin-bottom: 8px; color: var(--muted); }
table.sum { width: 100%; border-collapse: collapse; }
table.sum td { padding: 7px 0; border-bottom: 1px solid var(--line); }
table.sum td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sum tr.grand td { font-size: 19px; font-weight: 800; border-bottom: 0; padding-top: 10px; color: var(--brand); }

/* ---------- bottom action bar ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.total-box { flex: 1; display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.total-box span { font-size: 12px; color: var(--muted); font-weight: 600; }
.total-box b { font-size: 20px; color: var(--brand); white-space: nowrap; }

/* ---------- lists ---------- */
.search { margin-bottom: 12px; }
.est-list { display: flex; flex-direction: column; gap: 10px; }
.est-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 12px 16px; box-shadow: var(--shadow); flex-wrap: wrap; }
.est-main { flex: 1 1 220px; min-width: 0; text-decoration: none; color: inherit; }
.est-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.est-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est-top .amt { margin: 0; font-weight: 700; color: var(--brand); white-space: nowrap; font-size: 16px; }
.est-actions { display: flex; gap: 6px; align-items: center; }

/* ---------- preview ---------- */
.seg { display: flex; background: #eadfd4; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: none; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.out { margin-bottom: 14px; }
.sheet-fit { position: relative; overflow: hidden; width: 100%; }
.sheet { transform-origin: top left; box-shadow: 0 4px 24px rgba(40, 20, 0, .14); background: #fff; }
.wa-text {
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0;
  background: #e7f7ec; border: 1px solid #bfe5cc; border-radius: var(--radius); padding: 16px;
  font: 14.5px/1.5 var(--font);
}
.share-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px 10px;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.share-bar .btn { flex-direction: column; gap: 2px; padding: 6px 2px; min-height: 56px; font-size: 12px; }

/* ---------- price list editor ---------- */
details.prod { padding: 0; }
details.prod > summary { padding: 14px 16px; cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.prod > summary::-webkit-details-marker { display: none; }
details.prod > summary::before { content: "▸"; color: var(--brand); transition: transform .15s; }
details.prod[open] > summary::before { transform: rotate(90deg); }
details.prod > :not(summary) { margin-left: 16px; margin-right: 16px; }
details.prod[open] { padding-bottom: 12px; }
.rows-scroll { overflow-x: auto; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; }
table.rows { border-collapse: collapse; width: 100%; min-width: 760px; }
table.rows th { font-size: 12px; text-align: left; color: var(--muted); padding: 8px 6px; background: #faf6f1; white-space: nowrap; }
table.rows td { padding: 4px; border-top: 1px solid var(--line); }
table.rows input { min-height: 38px; padding: 6px 8px; font-size: 15px; }
table.rows .rate-in { font-weight: 700; color: var(--brand); }
.saved.ok { color: var(--ok); font-weight: 700; }
.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-prev { height: 48px; border-radius: 8px; border: 1px solid var(--line); }
.sync-status { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  background: #2a211a; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-weight: 500;
}
.toast.bad { background: #8a2a10; }
.toast button { background: none; border: 0; color: #ffcf8a; font: inherit; font-weight: 700; cursor: pointer; padding: 4px; }

/* ---------- computer screens ---------- */
@media (min-width: 760px) {
  body { padding-bottom: 100px; }
  .topbar { height: 60px; padding: 0 24px; }
  .brand { flex: 0 0 auto; margin-right: 18px; }
  .tabs {
    position: static; display: flex; height: auto; padding: 0; background: none; border: 0; flex: 1; gap: 4px;
  }
  .tabs a { flex-direction: row; gap: 8px; color: rgba(255,255,255,.78); font-size: 14.5px; padding: 8px 14px; border-radius: 10px; }
  .tabs a:hover { background: rgba(255,255,255,.1); color: #fff; }
  .tabs a.on { color: #fff; background: rgba(255,255,255,.18); }
  .page { padding: 24px; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1.3fr 1fr 1fr; }
  .line-dims { grid-template-columns: 1fr 1fr 1.4fr 1.6fr; }
  .actionbar, .share-bar { bottom: 0; }
  .actionbar { padding: 12px max(24px, calc((100% - 952px) / 2)); }
  .share-bar { display: flex; justify-content: center; padding: 12px 24px; }
  .share-bar .btn { flex-direction: row; min-height: 44px; font-size: 14.5px; padding: 0 18px; }
  .toast { bottom: 96px; }
}

/* =========================================================
   THE ESTIMATE DOCUMENTS (screen, image, PDF and print)
   Fixed sizes, never depend on the screen.
   ========================================================= */
.capture { position: fixed; left: -12000px; top: 0; background: #fff; }
.capture.fitted .doc.pro { min-height: 0; }
.capture.fitted .pro-foot { padding-top: 28px; }
.doc { background: #fff; color: #161616; font: 13px/1.45 var(--font); }
.doc .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc .c { text-align: center; }
.doc .sub { color: #6b6b6b; font-size: 11.5px; font-weight: 400; }
.doc .lbl { color: #777; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.doc table.grid { width: 100%; border-collapse: collapse; }
.doc table.grid th { background: #6b3a17; color: #fff; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 8px; text-align: left; }
.doc table.grid th.num { text-align: right; }
.doc table.grid td { padding: 8px 8px; border-bottom: 1px solid #e3dcd4; vertical-align: top; }
.doc table.grid tbody tr:nth-child(even) td { background: #faf7f3; }
.doc table.totals { border-collapse: collapse; min-width: 280px; margin-left: auto; }
.doc table.totals td { padding: 5px 8px; }
.doc table.totals tr.grand td { font-size: 17px; font-weight: 800; color: #fff; background: #6b3a17; padding: 9px 10px; }

.doc.pro { width: 794px; min-height: 1123px; padding: 44px 46px; display: flex; flex-direction: column; }
.pro-head { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 16px; border-bottom: 3px solid #6b3a17; }
.pro-head .logo { height: 64px; width: auto; }
.pro-head .shop { flex: 1; color: #444; }
.pro-head .shop-name { font-size: 26px; font-weight: 800; color: #6b3a17; line-height: 1.15; margin-bottom: 2px; }
.pro-head .doc-title { font-size: 20px; font-weight: 800; letter-spacing: .18em; color: #6b3a17; border: 2px solid #6b3a17; padding: 6px 14px; border-radius: 6px; }
.pro-meta { display: flex; justify-content: space-between; gap: 20px; margin: 18px 0; }
.pro-meta .party { font-size: 18px; font-weight: 700; }
.pro-meta .right { text-align: right; }
.pro-meta .right > div { margin-bottom: 4px; }
.pro-bottom { display: flex; gap: 24px; margin-top: 16px; align-items: flex-start; }
.pro-bottom .words { flex: 1; }
.pro-foot { margin-top: auto; padding-top: 40px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.pro-foot .note { flex: 1; color: #555; font-size: 12px; }
.pro-foot .sign { text-align: center; min-width: 200px; }
.pro-foot .sign-line { margin-top: 44px; border-top: 1px solid #444; padding-top: 4px; font-size: 12px; color: #555; }

.doc.tbl { width: 640px; padding: 24px; }
.tbl-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; color: #6b3a17; border-bottom: 2px solid #6b3a17; padding-bottom: 8px; }
.tbl-head span { font-size: 13px; color: #555; }
.tbl-party { margin: 10px 0 12px; font-size: 15px; }
.doc.tbl table.totals { margin-top: 12px; }

/* ---------- print ---------- */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body.printing { background: #fff; padding: 0; }
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  #print-area .doc.pro { width: 210mm; min-height: 296mm; }
  #print-area .doc.tbl { width: auto; padding: 12mm; }
  #print-area .wa-text { padding: 12mm; border: 0; background: #fff; }
  .doc table.grid th, .doc table.totals tr.grand td, .doc table.grid tbody tr:nth-child(even) td {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .doc table.grid tr { break-inside: avoid; }
}

/* price list: copy row, repeated size, save state */
table.rows td.row-btns { white-space: nowrap; }
table.rows tr.dup td { background: #fde8e6; }
table.rows tr.dup input { border-color: var(--bad); }
.pl-state { flex: 1; font-weight: 600; }
.warn-text { color: var(--warn-ink); }

/* ---------- 5 menu tabs ---------- */
.tabs { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 759px) { .tabs a { font-size: 11px; } }

/* ---------- estimate lines: one box per item, one short row per size ---------- */
.grp { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fff; overflow: hidden; }
.grp.no-item { border-color: var(--warn-line); }
.grp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--brand-soft); border-bottom: 1px solid var(--line);
}
.grp.no-item .grp-head { background: var(--warn-bg); }
.grp-title { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.grp-title .badge { background: #fff; }
.grp-sum { display: flex; align-items: baseline; gap: 10px; margin-left: auto; }
.grp-sum b { color: var(--brand); font-size: 16px; white-space: nowrap; }
.grp-pick { display: block; padding: 10px 12px 0; font-size: 13px; font-weight: 600; color: var(--warn-ink); }
.grp-pick select { margin-top: 4px; }
.grp-hint { padding: 8px 12px 0; }
.lrow { padding: 10px 12px; border-top: 1px solid var(--line); }
.grp-hint + .lrow { border-top: 0; }
.lrow.has-issue { background: #fffaf2; box-shadow: inset 3px 0 0 var(--warn-line); }
.lrow.open { background: #fcfaf7; }
.lr-size { display: flex; align-items: center; gap: 3px; }
.lr-size .ln-no { width: 24px; height: 24px; font-size: 12px; margin-right: 3px; }
input.dim { width: 52px; min-height: 40px; padding: 6px 4px; text-align: center; font-weight: 600; }
.lr-size .x { color: var(--muted); width: 10px; text-align: center; flex: none; }
.lr-size .u { color: var(--muted); font-size: 13px; min-width: 16px; margin: 0 2px; }
.lr-calc { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding-left: 27px; }
.lr-calc .calc-qty { font-weight: 700; font-size: 14px; white-space: nowrap; }
.lr-calc .rate { width: 76px; min-height: 38px; padding: 6px 8px; }
.rate.manual { border-color: var(--warn-line); background: var(--warn-bg); }
.lr-calc .amt { margin-left: auto; font-size: 15.5px; white-space: nowrap; }
.more-btn { width: 36px; height: 36px; }
.more-btn svg { transition: transform .15s; }
.lrow.open .more-btn svg { transform: rotate(180deg); }
.lrow .issues { padding-left: 27px; }
.lr-more { margin: 10px 0 2px 27px; padding-top: 10px; border-top: 1px dashed var(--line-strong); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.lr-more label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; }
.lr-more select { margin-top: 4px; }
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; width: 100%; }
.more-grid label:nth-child(-n+2) { grid-column: 1 / -1; }
.lr-more .line-src { margin: 0; }
.add-to { margin: 4px 8px 8px; }
.add-line { width: 100%; margin-top: 2px; border-style: dashed; }

@media (max-width: 759px) {
  .page.editor { padding-left: 12px; padding-right: 12px; }
  .page.editor .card { padding: 14px 10px; }
  .grp-head, .lrow { padding-left: 8px; padding-right: 8px; }
  .grp-hint { padding-left: 8px; }
}
@media (min-width: 760px) {
  .lrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
  .lr-calc { flex: 1; margin-top: 0; padding-left: 0; min-width: 300px; }
  .lrow .issues, .lr-more { flex-basis: 100%; }
  input.dim { width: 64px; }
  .more-grid { grid-template-columns: 1.4fr 1.4fr 1fr 1fr; }
  .more-grid label:nth-child(-n+2) { grid-column: auto; }
}

/* ---------- size sheet ---------- */
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 13px; margin-right: 8px; vertical-align: 1px;
}
.sheet-top { display: flex; gap: 12px; }
.sheet-top .grow { flex: 1; min-width: 0; }
.date-f { flex: 0 0 118px; }
textarea.slip {
  font: 15px/1.5 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: #fbf8f3; min-height: 180px; white-space: pre; overflow-x: auto; resize: vertical;
}
.card.warn.inner { margin: 12px 0 0; box-shadow: none; }
.card.warn.inner ul { margin: 6px 0 0; padding-left: 20px; }
.sheet-btns { margin-top: 12px; }
details.card.ref > summary { cursor: pointer; }
details.card.ref[open] > summary { margin-bottom: 10px; }
table.ref-table { border-collapse: collapse; width: 100%; min-width: 460px; }
table.ref-table th, table.ref-table td { text-align: left; padding: 7px 10px; border-top: 1px solid var(--line); font-size: 14px; }
table.ref-table th { background: #faf6f1; color: var(--muted); font-size: 12px; }
table.ref-table td.to { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--brand); }

/* keep the item boxes inside the phone screen */
.grp { overflow: clip; }
.lrow, .lr-more, .more-grid > label { min-width: 0; }
.lr-more { max-width: calc(100% - 27px); }
.lr-more .chips, .lr-more .line-src { max-width: 100%; }
@media (max-width: 420px) {
  input.dim { width: 47px; padding: 6px 2px; }
  .lr-size { gap: 2px; }
  .lr-size .x { width: 9px; }
  .lr-size .u { font-size: 12px; margin: 0 1px; }
  .sheet-top { flex-wrap: wrap; }
  .date-f { flex: 1 1 100%; }
}
@media (max-width: 759px) {
  .lr-calc, .lrow .issues { padding-left: 0; }
  .lr-calc { gap: 5px; }
  .lr-calc .rate { width: 70px; }
  .lr-more { margin-left: 0; max-width: 100%; }
}
.lr-calc { flex-wrap: wrap; row-gap: 4px; }
.amt-wrap { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.amt-wrap .amt { margin-left: 0; }
@media (max-width: 400px) {
  .actionbar { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .actionbar .btn { padding: 0 11px; }
  .total-box b { font-size: 17px; }
}

/* ---------- Size Sheet: two columns on a computer ---------- */
@media (min-width: 900px) {
  .sheet-page { max-width: 1200px; }
  .sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .sheet-grid > .card { margin-bottom: 14px; }
  .sheet-out { position: sticky; top: 76px; }
  .sheet-out textarea.slip { max-height: calc(100vh - 300px); }
}
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.label-row label { margin: 0; }
.paste-btn { min-height: 34px; padding: 0 12px; }
.paste-btn svg { width: 17px; height: 17px; }
.card-head .paste-btn { margin-left: auto; }

/* ---------- WhatsApp choice ---------- */
.btn.wa-biz { background: #0c6b58; border-color: #0c6b58; color: #fff; }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(20, 12, 5, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 420px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.modal h2 { margin: 0 0 4px; }
@media (min-width: 760px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }
.label-row label { font-size: 13px; font-weight: 600; color: var(--muted); }
