/* GATI Showroom — Vianne. Mobile-first, photo-first. */
:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #fbf9f5;
  --ink: #1d1b18;
  --ink-2: #3a3631;
  --muted: #6f695f;
  --line: #e6dfd2;
  --line-2: #efe9de;
  --gold: #a8834a;
  --gold-ink: #8a6a37;
  --gold-soft: #f1e7d4;
  --green: #2f7a4f;
  --green-soft: #e3f1e8;
  --blue: #2c5d8f;
  --blue-soft: #e4edf6;
  --violet: #6a4c93;
  --violet-soft: #eee8f6;
  --gray: #7d776d;
  --gray-soft: #efece6;
  --red: #b23a2e;
  --red-soft: #f8e6e3;
  --amber: #a86512;
  --amber-soft: #fbefdc;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29, 27, 24, .05), 0 6px 18px rgba(29, 27, 24, .06);
  --shadow-lg: 0 10px 40px rgba(29, 27, 24, .18);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 56px;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: rgba(247, 244, 238, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 28px; object-fit: contain; }
.brand .wordmark { font-family: var(--serif); letter-spacing: .28em; font-size: 17px; }
.brand .sub { font-size: 10.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.fresh {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
}
.fresh .short { display: none; }
.fresh .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.fresh.warn .dot { background: var(--amber); }
.fresh.stale .dot { background: var(--red); }
.desknav { display: none; gap: 4px; }
.desknav a {
  padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-size: 14px;
}
.desknav a.active { background: var(--ink); color: #fff; }
.desknav a:hover { text-decoration: none; background: var(--line-2); }
.desknav a.active:hover { background: var(--ink); }
.badge-count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; background: var(--gold); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ------------------------------------------------------------ bottom nav */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; position: relative;
}
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.active { color: var(--ink); }
.bottomnav a.active svg { stroke: var(--gold); }
.bottomnav svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.bottomnav .badge-count { position: absolute; top: 6px; left: 54%; }

/* ------------------------------------------------------------------ main */
main#view { max-width: 1400px; margin: 0 auto; padding: 12px 14px 28px; }
.page-title { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 6px 0 12px; letter-spacing: .01em; }
.section-title { font-family: var(--serif); font-weight: 400; font-size: 19px; margin: 22px 0 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 14px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 550; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #d8cfbf; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #33302b; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.gold:hover { background: var(--gold-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.section-gap { height: 12px; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.iconbtn svg { width: 20px; height: 20px; stroke: var(--ink-2); fill: none; stroke-width: 1.7; }
.iconbtn.active { border-color: var(--ink); background: var(--ink); }
.iconbtn.active svg { stroke: #fff; }

/* ---------------------------------------------------------------- inputs */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s; font-size: 16px;
}
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- search */
.searchbar {
  position: sticky; top: var(--header-h); z-index: 20;
  margin: -12px -14px 0; padding: 10px 14px 8px;
  background: linear-gradient(var(--bg) 82%, rgba(247, 244, 238, 0));
}
.searchrow { display: flex; gap: 8px; align-items: center; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 8px 0 14px; min-height: 46px; box-shadow: var(--shadow);
}
.search svg { width: 19px; height: 19px; stroke: var(--muted); fill: none; stroke-width: 1.8; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; padding: 10px 0; }
.search .clear { border: 0; background: var(--line-2); width: 26px; height: 26px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.on .n { color: #d9d3c8; }
.chip.filter { border-style: dashed; }
.chip .x { font-size: 15px; line-height: 1; margin-left: 2px; opacity: .7; }
.resultbar { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 0 10px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; color: var(--ink); position: relative;
  transition: box-shadow .2s, transform .2s;
}
.tile:hover { text-decoration: none; box-shadow: var(--shadow); }
.tile .ph { position: relative; aspect-ratio: 1 / 1; background: #fff; overflow: hidden; }
.tile .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tile .ph .noimg { position: absolute; inset: 0; }
.tile .ph .count { position: absolute; right: 7px; bottom: 7px; background: rgba(29,27,24,.66); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 999px; }
.noimg {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 12px; text-align: center; padding: 12px; background: repeating-linear-gradient(135deg, #fbf9f5, #fbf9f5 10px, #f6f2ea 10px, #f6f2ea 20px);
}
.noimg svg { width: 28px; height: 28px; stroke: #c4baa8; fill: none; stroke-width: 1.4; }
.tile .body { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile .t1 { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.tile .style { font-family: var(--serif); font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .price { font-weight: 650; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .code { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tile .pills { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.loadmore { display: flex; justify-content: center; padding: 18px 0 6px; }

/* ----------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  background: var(--gray-soft); color: var(--gray);
}
.pill.on_hand { background: var(--green-soft); color: var(--green); }
.pill.on_memo { background: var(--blue-soft); color: var(--blue); }
.pill.show { background: var(--violet-soft); color: var(--violet); }
.pill.sold { background: var(--gray-soft); color: var(--gray); }
.pill.split { background: var(--amber-soft); color: var(--amber); }
.pill.unverified { background: var(--red-soft); color: var(--red); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill.line { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }

/* ----------------------------------------------------------------- piece */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: 14px; margin: 4px 0 10px; cursor: pointer; background: none; border: 0; padding: 4px 0; }
.back svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.piece { display: grid; gap: 16px; }
.piece > *, .info, .costgrid > *, .traydesk > * { min-width: 0; }
.gallery .main {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; cursor: zoom-in;
}
.gallery .main img { width: 100%; height: 100%; object-fit: contain; }
.gallery .thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.gallery .thumbs button { flex: none; width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0; overflow: hidden; cursor: pointer; }
.gallery .thumbs button.on { border: 2px solid var(--gold); }
.gallery .thumbs img { width: 100%; height: 100%; object-fit: contain; }
.gallery .caption { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.ptitle { font-family: var(--serif); font-size: 30px; font-weight: 400; margin: 0; line-height: 1.15; letter-spacing: .01em; }
.psub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 4px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 14px 0; }
.fact { background: var(--surface); padding: 10px 12px; min-width: 0; }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fact .v { font-size: 15px; margin-top: 2px; overflow-wrap: anywhere; }
.fact .v .raw { display: block; font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.fact.wide { grid-column: 1 / -1; }
.callout { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; margin: 8px 0; display: flex; gap: 9px; align-items: flex-start; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.callout.warn { background: var(--amber-soft); color: #6e4510; }
.callout.danger { background: var(--red-soft); color: #7c271e; }
.callout.info { background: var(--blue-soft); color: #1f4369; }
.callout.ok { background: var(--green-soft); color: #1e5134; }
.callout.gold { background: var(--gold-soft); color: #5e4722; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.stickyact {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 15;
  display: flex; gap: 8px; padding: 8px; margin-top: 16px;
  background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg);
}
.stickyact .btn { flex: 1; }

/* ----------------------------------------------------------------- table */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; background: var(--surface-2); white-space: nowrap; }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tfoot td { font-weight: 650; background: var(--surface-2); }
.kind-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--gray); vertical-align: 1px; }
.kind-dot.diamond { background: #7aa7d9; }
.kind-dot.metal { background: var(--gold); }

/* --------------------------------------------------------------- timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--gold); }
.timeline li.current::before { background: var(--gold); }
.timeline li.muted::before { border-color: #cfc6b6; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { font-weight: 600; font-size: 14px; }
.timeline .detail { font-size: 13px; color: var(--ink-2); }

/* ----------------------------------------------------------- collapsible */
details.fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
details.fold > summary { list-style: none; cursor: pointer; padding: 13px 14px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "+"; font-size: 20px; color: var(--muted); font-weight: 300; }
details.fold[open] > summary::after { content: "–"; }
details.fold > .inner { padding: 0 14px 14px; }
dl.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.raw { background: #1d1b18; color: #ece6da; border-radius: var(--radius-sm); padding: 12px; overflow: auto; font-size: 12px; max-height: 60vh; }
pre.report { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; font-size: 12.5px; max-height: 70vh; overflow: auto; }

/* --------------------------------------------------------------- costing */
.costgrid { display: grid; gap: 12px; }
.costcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.costcard h3 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin: 0 0 2px; }
.costcard .kicker { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.bignum { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.bignum.incomplete { color: var(--red); font-size: 20px; }
.costrows { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.costrows td { padding: 5px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.costrows td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
.costrows tr.total td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--ink); }
.marginrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.marginrow .m { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.marginrow .m .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.marginrow .m .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ tray */
.traylist { display: grid; gap: 10px; }
.trayrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); }
.trayrow:hover { text-decoration: none; background: var(--surface-2); }
.trayrow .grow { flex: 1; min-width: 0; }
.trayrow .t { font-family: var(--serif); font-size: 17px; }
.tline { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line-2); }
.tline:last-child { border-bottom: 0; }
.tline .lph { width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.tline .lph img { width: 100%; height: 100%; object-fit: contain; }
.tline .lt { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.tline .lname { font-family: var(--serif); font-size: 16px; }
.tline .lcontrols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; align-items: end; }
.tline .lcontrols .field { margin: 0; }
.tline .ltotal { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.tline .lerr { color: var(--red); font-size: 12.5px; margin-top: 6px; }
.tline .lwarn { color: var(--amber); font-size: 12.5px; margin-top: 4px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.qty button { width: 38px; height: 40px; border: 0; background: transparent; font-size: 18px; cursor: pointer; }
.qty input { width: 52px; text-align: center; border: 0; outline: 0; font-size: 16px; background: transparent; }
.totalbar { display: flex; justify-content: space-between; align-items: baseline; padding: 14px; font-size: 15px; }
.totalbar .amt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.exportbox { display: grid; gap: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--gold); }

/* ----------------------------------------------------------------- sheet */
.scrim { position: fixed; inset: 0; background: rgba(29, 27, 24, .42); z-index: 60; opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px 16px calc(18px + var(--safe-b)); transform: translateY(100%); transition: transform .24s ease;
}
.sheet.show { transform: translateY(0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 2px 0 12px; }
.sheet .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(15, 14, 12, .94); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; background: #fff; border-radius: 6px; }
.lightbox .close { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.15); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; cursor: pointer; }

/* ----------------------------------------------------------------- toast */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 90; display: grid; gap: 8px; width: min(92vw, 440px); }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 11px 14px; font-size: 14px; box-shadow: var(--shadow-lg); animation: rise .2s ease; }
.toast.error { background: var(--red); }
.toast.ok { background: #24563a; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ----------------------------------------------------------------- login */
.loginwrap { min-height: calc(100vh - 40px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.loginbox { width: min(420px, 100%); text-align: center; }
.loginbox img.logo { width: 74px; margin: 0 auto 10px; }
.loginbox .wordmark { font-family: var(--serif); letter-spacing: .34em; font-size: 26px; margin-left: .34em; }
.loginbox .tag { color: var(--muted); font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; margin: 4px 0 26px; }
.loginbox form { text-align: left; }
.loginbox .err { color: var(--red); font-size: 13.5px; min-height: 20px; margin: 4px 0 8px; }
.loginbox .fine { color: var(--muted); font-size: 12px; margin-top: 18px; }
body.login-mode { padding-bottom: 0; }
body.login-mode .topbar, body.login-mode .bottomnav { display: none; }

/* ------------------------------------------------------------ exceptions */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.exrow { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.exrow:hover { text-decoration: none; background: var(--surface-2); }
.exrow .xph { width: 56px; height: 56px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.exrow .xph img { width: 100%; height: 100%; object-fit: contain; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; stroke: #cbbfa9; fill: none; stroke-width: 1.3; margin: 0 auto 8px; display: block; }
.skeleton { background: linear-gradient(90deg, #f1ece3 25%, #f8f5ef 50%, #f1ece3 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ responsive */
@media (max-width: 559px) {
  .brand .sub { display: none; }
  .brand .wordmark { font-size: 15px; letter-spacing: .22em; }
  .fresh .long { display: none; }
  .fresh .short { display: inline; }
  .searchrow { gap: 6px; }
  .searchrow .iconbtn { width: 40px; height: 40px; }
}
.costwide { margin-top: 18px; }
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .desknav { display: flex; }
  .topbar { padding: 0 24px; height: 62px; --header-h: 62px; }
  main#view { padding: 18px 24px 40px; }
  .searchbar { top: 62px; margin: -18px -24px 0; padding: 14px 24px 8px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
  .piece { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .piece .gallery { position: sticky; top: 80px; }
  .costgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, 92vw); border-radius: 20px; transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet .grab { display: none; }
  .stickyact { position: static; box-shadow: none; border-radius: var(--radius); }
  .toasts { bottom: 24px; }
  .traydesk { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
  .traydesk .side { position: sticky; top: 84px; }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Keep detail content within its grid/flex cell; do not hide overflow. */
.info, .costcard, .callout > div, .gallery .caption, .timeline .detail,
.timeline .what, dl.kv > *, .tline > *, .exrow > * {
  min-width: 0;
  overflow-wrap: anywhere;
}
.input { min-width: 0; max-width: 100%; }
.marginrow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.marginrow .m { min-width: 0; overflow-wrap: anywhere; }
.tline { grid-template-columns: 76px minmax(0, 1fr); }
.exrow { grid-template-columns: 56px minmax(0, 1fr); }
.sheet .row2, .tline .lcontrols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 559px) {
  /* Component costs used to sit offscreen inside a horizontally scrolling table. */
  table.components-table, .components-table tbody, .components-table tfoot { display: block; }
  .components-table thead { display: none; }
  .components-table tr { display: block; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  table.components-table td, table.components-table td.r {
    display: grid; grid-template-columns: minmax(76px, .75fr) minmax(0, 1.25fr);
    gap: 8px; padding: 5px 0; border: 0; text-align: left;
    white-space: normal; overflow-wrap: anywhere;
  }
  .components-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; }
  table.components-table td:first-child { display: block; font-weight: 600; padding-bottom: 8px; }
  .components-table td:first-child::before { display: none; }
  .components-table tfoot td:empty { display: none; }
  .components-table tfoot tr { background: var(--surface-2); }
  .stickyact { border-radius: var(--radius); }
  .stickyact .btn { min-width: 0; white-space: normal; padding: 8px; }
  .gallery .caption { flex-wrap: wrap; }
  .costrows td:first-child { overflow-wrap: anywhere; }
}
@media (max-width: 379px) {
  .tline .lcontrols, .sheet .row2 { grid-template-columns: minmax(0, 1fr); }
  .marginrow { grid-template-columns: minmax(0, 1fr); }
  dl.kv { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
}
/* Booth release: controls stay readable on small phones. */
.user-row, .followup-row { padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.user-row > div { min-width: 0; }
.scanner-video { width: 100%; max-height: 35vh; object-fit: contain; background: #111; border-radius: 10px; }
.err { color: var(--red); overflow-wrap: anywhere; }
@media (max-width:559px) { .bottomnav a { font-size:10px; min-width:0; } }
@media(max-width:359px){
  .topbar{gap:6px;padding-left:10px;padding-right:10px}
  .topbar .brand{gap:5px}
  .topbar .brand .wordmark{font-size:13px;letter-spacing:.15em}
  #buyer-toggle{font-size:11px;padding-left:8px;padding-right:8px;white-space:nowrap}
}
