/* Shivam Wood Art – Studio
   Warm, calm, organised: ivory surfaces, walnut ink, one saffron-wood accent. */
:root {
  --bg: #f6f2ec;
  --surface: #ffffff;
  --surface-2: #faf7f2;
  --ink: #2a1d14;
  --ink-2: #5e4f43;
  --muted: #8c7d70;
  --line: #ebe3d8;
  --line-2: #ddd2c3;
  --accent: #b5561d;
  --accent-ink: #8f3f10;
  --accent-soft: #fbeee3;
  --brown: #5a2a0c;
  --ok: #2f7d4f; --ok-soft: #e4f3ea;
  --warn: #a8670f; --warn-soft: #fbf0dc;
  --bad: #b42318; --bad-soft: #fbe6e4;
  --wa: #1f9d55;
  --radius: 14px; --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(42, 29, 20, .05);
  --shadow: 0 1px 2px rgba(42, 29, 20, .04), 0 6px 20px rgba(42, 29, 20, .06);
  --shadow-lg: 0 24px 60px rgba(42, 29, 20, .22);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--ink); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
.muted, small { color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 10px 28px; background: rgba(255, 255, 255, .86); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.logo { width: 42px; height: 42px; flex: none; filter: drop-shadow(0 2px 4px rgba(90, 42, 12, .25)); }
.brand h1 { font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--brown); line-height: 1.1; white-space: nowrap; }
.brand h1 span { color: var(--accent); font-style: italic; font-weight: 600; }
.brand small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 7px 22px; font-weight: 600; color: var(--muted); border-radius: 9px; }
.tab:hover { color: var(--ink); }
.tab.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(42, 29, 20, .12); }
.head-right { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.status { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
@media (max-width: 900px) {
  header { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; } .tab { flex: 1; }
  .status { display: none; }
}

/* ---------- controls ---------- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }
label .opt { font-weight: 400; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 86, 29, .14); }
button {
  font: inherit; font-weight: 550; cursor: pointer; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); padding: 8px 14px; transition: background .15s, border-color .15s, transform .05s;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 2px rgba(143, 63, 16, .3); }
button.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
button.big { width: 100%; padding: 13px; margin-top: 18px; font-size: 15px; border-radius: 12px; }
button.danger { color: var(--bad); } button.danger:hover:not(:disabled) { background: var(--bad-soft); border-color: transparent; }
button.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
button.wa:hover:not(:disabled) { background: #188247; border-color: #188247; }
.icon-btn { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: 50%; border-color: transparent; background: var(--surface-2); color: var(--ink-2); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row-inline.tight { margin: 0; }
.row-inline.end { justify-content: flex-end; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); padding: 6px 13px; border-radius: 99px; font-size: 13px; font-weight: 500; }
.chip:hover { border-color: var(--muted); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters { margin: 4px 0 16px; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cat-grid .chip { border-radius: var(--radius-sm); text-align: left; padding: 9px 12px; font-size: 13px; }
.cat-grid .chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- layout: designs ---------- */
main { display: grid; grid-template-columns: 340px 1fr; gap: 24px; padding: 24px 28px 48px; align-items: start; max-width: 1600px; margin: 0 auto; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; padding: 16px; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: sticky; top: 86px; max-height: calc(100vh - 106px); overflow: auto; }
@media (max-width: 900px) { .panel { position: static; max-height: none; } }
.panel-head { display: flex; gap: 12px; align-items: flex-start; }
.panel-head p { margin-top: 2px; }
.panel-head.small { align-items: center; margin: 18px 0 4px; }
.step { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 13px; }
.gen-msg { margin-top: 8px; text-align: center; min-height: 1em; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; padding: 18px; border: 1.5px dashed var(--line-2); border-radius: 12px; cursor: pointer; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop b { color: var(--ink); font-size: 14px; }
.drop .muted { font-weight: 400; }
.drop-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--accent); margin-bottom: 6px; }

.section-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; }
.count { display: inline-block; margin-left: 6px; padding: 1px 9px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); vertical-align: 2px; }
.count:empty { display: none; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s, border-color .2s; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-2); }
.card .img { aspect-ratio: 1; background: #fff; display: grid; place-items: center; cursor: pointer; position: relative; border-bottom: 1px solid var(--line); }
.card img { width: 100%; height: 100%; object-fit: contain; }
.card .body { padding: 10px 12px 4px; flex: 1; }
.card .title { font-weight: 600; font-size: 14px; }
.card .var { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.card .actions { display: flex; gap: 6px; padding: 8px 12px 12px; }
.card .actions button { padding: 6px 9px; font-size: 12px; }
.card .actions .grow { flex: 1; background: var(--surface-2); }
.card .actions .grow:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.badge { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: rgba(42, 29, 20, .78); color: #fff; backdrop-filter: blur(4px); }
.badge.ok { background: var(--ok); } .badge.bad { background: var(--bad); }
.fav.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.card.loading .img { background: linear-gradient(110deg, #f6f1ea 30%, #fff 50%, #f6f1ea 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.card.failed .img { color: var(--bad); font-size: 12px; padding: 14px; text-align: center; background: var(--bad-soft); }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; padding: 56px 20px; border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: rgba(255, 255, 255, .5); }
.empty-icon { font-size: 30px; margin-bottom: 6px; }
.empty b { display: block; font-size: 15px; margin-bottom: 4px; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(1100px, 96vw); max-height: 92vh; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(32, 22, 14, .5); backdrop-filter: blur(3px); }
dialog.wide { width: min(1180px, 97vw); }
#settings, #bizDlg, #stockDlg, #moveDlg { width: min(540px, 94vw); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.settings { padding: 22px 24px; }
.settings .row { margin-top: 20px; }

.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px; position: relative; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.detail img { width: 100%; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.detail details { margin-top: 10px; font-size: 13px; } .detail summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
.close { position: absolute; top: 14px; right: 14px; z-index: 2; }
#dTitle { font-family: var(--serif); font-size: 24px; color: var(--brown); padding-right: 40px; }
#viewerWrap { position: relative; height: 340px; border-radius: 12px; background: radial-gradient(circle at 50% 40%, #fbf7f1, #ece3d6); border: 1px solid var(--line); overflow: hidden; margin: 14px 0; }
#viewer { position: absolute; inset: 0; }
.viewer-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); pointer-events: none; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px auto; }
.progress > div { height: 100%; background: var(--accent); transition: width .5s; }
.dims { padding: 9px 0; font-weight: 600; }
#stlList { margin-top: 10px; } #stlList a { display: block; font-size: 13px; color: var(--accent-ink); margin-top: 4px; }

/* ---------- bills page ---------- */
.bills { padding: 24px 28px 48px; max-width: 1600px; margin: 0 auto; }
@media (max-width: 900px) { .bills { padding: 16px; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-family: var(--serif); font-size: 28px; color: var(--brown); }
.search { width: 280px; padding-left: 34px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238c7d70' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px 50%; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat span { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.stat b { display: block; font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table-wrap.flat { box-shadow: none; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 11px; color: var(--muted); font-weight: 600; background: var(--surface-2); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.r { text-align: right; }
table.list tbody tr { cursor: pointer; transition: background .12s; } table.list tbody tr:hover { background: var(--surface-2); }
table.list td small { font-size: 12px; }
.st { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }
.st.Paid, .st.Delivered { background: var(--ok-soft); color: var(--ok); }
.st.Ready, .st[class~="In"] { background: #e8eefb; color: #3155a6; }
.st.Cancelled { background: var(--bad-soft); color: var(--bad); }
.overdue { color: var(--bad); font-weight: 600; }

/* bill editor */
.bill-form, .pick { padding: 22px 24px; }
.bill-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; margin-top: 14px; }
.bill-main { min-width: 0; }
dialog { overflow-x: hidden; }
#openSettings, .tab, .page-head button { white-space: nowrap; }
@media (max-width: 900px) { .bill-body { grid-template-columns: 1fr; } }
.fsection { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.fsection > h3, .fsection-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.fsection > h3 + * label:first-child, .fsection > h3 + .grid2 label, .fsection > h3 + .grid3 label { margin-top: 10px; }
.fsection > h3 + textarea { margin-top: 10px; }
.fsection-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
table.items th, table.items td { padding: 8px 8px; }
table.items input { padding: 7px 9px; }
table.items td:nth-child(1) { width: 58px; }
table.items img { width: 46px; height: 46px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; display: block; }
table.items td:nth-child(2) input { min-width: 200px; }
table.items td:nth-child(3) input, table.items td:nth-child(4) input { width: 96px; }
table.items td:nth-child(5) input { width: 64px; text-align: right; }
table.items td:nth-child(6) input { width: 92px; text-align: right; }
table.items .amt { font-weight: 600; white-space: nowrap; }
table.items td:last-child button { border: 0; background: transparent; color: var(--muted); padding: 4px 8px; }
table.items td:last-child button:hover { color: var(--bad); background: var(--bad-soft); }
.bill-side { position: sticky; top: 0; align-self: start; }
.sum { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.sum h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 8px; }
.sum > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; color: var(--ink-2); }
.sum b { color: var(--ink); }
.sum input, .sum select { width: 130px; text-align: right; padding: 6px 9px; }
.sum .big { font-size: 16px; border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 10px; color: var(--ink); font-weight: 600; }
.sum .big b { font-size: 18px; }
.sum .accent b { color: var(--accent-ink); }
.side-actions { display: grid; gap: 8px; margin-top: 14px; }
.side-actions button { padding: 11px; }
#billMsg { margin-top: 10px; text-align: center; }
.pickgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 58vh; overflow: auto; margin: 14px 0; padding: 2px; }
.pickgrid .card { cursor: pointer; } .pickgrid .card.sel { outline: 3px solid var(--accent); outline-offset: -1px; }
.pickgrid .card .body { font-size: 12px; padding-bottom: 10px; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; max-width: 90vw; z-index: 50; box-shadow: var(--shadow-lg); font-weight: 500; }

/* STL box */
.hint { font-size: 12px; margin-top: 6px; }
.dims-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dims-row .dims { padding: 0; }
.stl-actions { margin-top: 12px; }
.stl-actions #exportStl { margin-left: auto; }

/* style memory */
.memory { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; font-weight: 400; }
.memory input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.memory b { display: block; color: var(--ink); font-size: 13px; }
.memory small { font-size: 12px; }
.card .actions { flex-wrap: wrap; }
.badge.draft { left: auto; right: 10px; background: rgba(255,255,255,.92); color: var(--ink-2); border: 1px solid var(--line); }
.badge.draft.hd { background: var(--accent); color: #fff; border-color: var(--accent); }
.share-box { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.lan { margin-top: 10px; padding: 10px 12px; background: var(--ok-soft); border-radius: var(--radius-sm); font-size: 13px; color: var(--ok); }
.lan code { display: inline-block; margin: 2px 6px 0 0; padding: 2px 8px; background: #fff; border-radius: 6px; color: var(--ink); font-size: 13px; user-select: all; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; }
  header { padding: 8px 12px; gap: 8px; }
  .brand small { display: none; }
  .brand h1 { font-size: 19px; }
  .logo { width: 36px; height: 36px; }
  main, .bills { padding: 12px 12px 40px; gap: 16px; }
  .panel { padding: 16px; }
  input, select, textarea { font-size: 16px; } /* stops iPhone zooming in */
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card .body { padding: 8px 10px 2px; }
  .card .title { font-size: 13px; }
  .card .actions { padding: 6px 8px 10px; gap: 4px; }
  .card .actions button { padding: 6px 7px; }
  .card .actions .grow { flex-basis: 100%; order: -1; }
  .badge { top: 6px; left: 6px; font-size: 10px; } .badge.draft { right: 6px; }
  .page-head { margin-bottom: 12px; } .page-title { font-size: 24px; }
  .page-head .row-inline { width: 100%; }
  .search { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; } .stat b { font-size: 18px; } .stat span { font-size: 10px; }
  /* bills table becomes cards */
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.list td { border: 0; padding: 1px 0; }
  table.list td:nth-child(1) { font-size: 12px; color: var(--muted); }
  table.list td:nth-child(3) { font-size: 15px; font-weight: 600; margin: 2px 0; }
  table.list td:nth-child(2), table.list td:nth-child(4), table.list td:nth-child(7) { display: inline; font-size: 12px; color: var(--muted); margin-right: 8px; }
  table.list td:nth-child(5) { position: absolute; top: 12px; right: 14px; width: auto; font-weight: 700; }
  table.list td:nth-child(6) { position: absolute; top: 34px; right: 14px; width: auto; font-size: 12px; color: var(--accent-ink); }
  table.list td:nth-child(6)::before { content: "Due "; color: var(--muted); }
  table.list td:nth-child(8) { position: absolute; bottom: 12px; right: 64px; width: auto; }
  table.list td:nth-child(9) { position: absolute; bottom: 8px; right: 12px; width: auto; }
  table.list td:nth-child(9) button { padding: 4px 9px; font-size: 12px; }
  dialog, dialog.wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .bill-form, .pick, .settings, .detail { padding: 16px; }
  .fsection { padding: 14px; }
  .pickgrid { grid-template-columns: 1fr 1fr; max-height: none; }
  #viewerWrap { height: 300px; }
  .stl-actions #exportStl { margin-left: 0; flex-basis: 100%; }
}

/* ---------- stock ---------- */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.scard { display: grid; grid-template-columns: 76px 1fr auto; grid-template-rows: auto auto; gap: 0 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-sm); }
.simg { grid-row: 1 / 3; width: 76px; height: 76px; border-radius: 10px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; font-size: 28px; overflow: hidden; cursor: pointer; }
.simg img { width: 100%; height: 100%; object-fit: contain; }
.sbody { min-width: 0; cursor: pointer; }
.sbody b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbody small { display: block; font-size: 12px; }
.sline { display: flex; gap: 10px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.scount { text-align: center; min-width: 74px; padding: 6px 8px; border-radius: 10px; }
.scount b { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -.02em; }
.scount span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.scount.ok { background: var(--ok-soft); color: var(--ok); } .scount.low { background: var(--warn-soft); color: var(--warn); } .scount.out { background: var(--bad-soft); color: var(--bad); }
.sbtns { grid-column: 2 / 4; display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.sbtns button { padding: 6px 12px; font-size: 13px; border-color: var(--line); background: var(--surface-2); }
.sbtns button:first-child { color: var(--ok); } .sbtns button:last-child { color: var(--accent-ink); }
.warn-t { color: var(--warn); }
.stock-pick { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.stock-thumb { width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; font-size: 26px; overflow: hidden; flex: none; }
.stock-thumb img { width: 100%; height: 100%; object-fit: contain; }
.stock-log { margin-top: 18px; } .stock-log h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 6px; }
.stock-log div { display: grid; grid-template-columns: 56px 110px 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.stock-log span, .stock-log small { color: var(--muted); }
.stock-log .made { color: var(--ok); } .stock-log .sold { color: var(--accent-ink); } .stock-log .damaged { color: var(--bad); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-top: 16px; }
.seg button { border: 0; background: transparent; padding: 8px 4px; font-size: 13px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(42, 29, 20, .12); }
.qty { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; }
.qty input { text-align: center; font-size: 22px; font-weight: 650; padding: 10px; }
.qty button { font-size: 22px; padding: 0; }
@media (max-width: 640px) {
  .stock-grid { grid-template-columns: 1fr; }
  .tab { padding: 7px 10px; }
}
