:root {
  --milk: #FFF8F5;
  --cream: #FFFDFC;
  --blush: #FCE7ED;
  --petal: #F3C1CF;
  --ribbon: #E58AA5;
  --rose: #BE4468;
  --rose-dark: #9C3454;
  --cocoa: #5B3A45;
  --mauve: #86616D;
  --line: #F1D3DC;

  --ok-bg: #E4F1E7;     --ok: #3E6B4D;
  --low-bg: #FFF0CC;    --low: #7F5A08;
  --out-bg: #F9D5DD;    --out: #962B4A;
  --ship-bg: #ECE5F7;   --ship: #5A4683;
  --grey-bg: #EFEAEB;   --grey: #6F6266;

  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--cocoa);
  background-color: var(--milk);
  background-image: radial-gradient(var(--blush) 1.3px, transparent 1.5px);
  background-size: 22px 22px;
}

h1, h2 { font-family: var(--serif); font-style: italic; font-weight: 600; margin: 0; color: var(--cocoa); }
h1 { font-size: 2rem; margin-bottom: 18px; }
h2 { font-size: 1.3rem; margin-bottom: 12px; }
.hint { color: var(--mauve); font-size: .9rem; margin: 8px 2px 20px; }

:focus-visible { outline: 3px solid rgba(190, 68, 104, .45); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  background: var(--blush);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px 24px; padding: 12px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--rose-dark);
  font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 1.7rem; }
.top nav { display: flex; gap: 6px; }
.top nav a {
  padding: 8px 18px; border-radius: 999px; text-decoration: none; color: var(--rose-dark);
  font-weight: 600; border: 1.5px solid transparent;
}
.top nav a:hover { background: rgba(255,255,255,.6); }
.top nav a[aria-current="page"] { background: var(--cream); border-color: var(--petal); color: var(--rose); }
.lace {
  height: 12px;
  background: radial-gradient(circle at 10px 0, var(--blush) 9px, transparent 9.5px) 0 0 / 20px 12px repeat-x;
}

main { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 80px; }

/* ---------- panels ---------- */
.panel {
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 3px 0 var(--blush);
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.ribbon { display: grid; grid-template-columns: repeat(4, 1fr); padding: 22px 8px; }
.ribbon .fig { padding: 4px 20px; border-left: 3px dotted var(--petal); }
.ribbon .fig:first-child { border-left: 0; }
.ribbon .num-big { font-family: var(--serif); font-style: italic; font-size: 1.9rem; line-height: 1.2; display: block; }
.ribbon .lbl { color: var(--mauve); font-size: .9rem; }
.ribbon .fig.profit .num-big { color: var(--rose); font-size: 2.3rem; }

.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1.5px dashed var(--line); }
.mini li:last-child { border-bottom: 0; }
.mini small { display: block; color: var(--mauve); }
.mini a { color: inherit; text-decoration: none; font-weight: 600; }
.mini a:hover { color: var(--rose); }
.soft-msg { color: var(--mauve); margin: 4px 0; }

/* ---------- toolbar, inputs, buttons ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.toolbar input[type="search"] { flex: 1 1 240px; }

input, select, textarea {
  font: inherit; color: var(--cocoa); background: #fff;
  border: 1.5px solid var(--petal); border-radius: 12px; padding: 10px 12px; width: 100%;
}
select { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--rose); outline-offset: 1px; }
input::placeholder { color: #B79AA3; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 20px; border-radius: 999px;
  border: 1.5px solid var(--petal); background: var(--cream); color: var(--rose-dark);
}
.btn:hover { background: var(--blush); }
.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.primary:hover { background: var(--rose-dark); border-color: var(--rose-dark); }
.btn.danger { background: #A93252; border-color: #A93252; color: #fff; }
.btn.danger:hover { background: #8C2442; }
.btn.small { padding: 5px 14px; font-size: .9rem; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
.tablewrap { padding: 8px 20px; }
th { text-align: left; font-weight: 600; font-size: .85rem; color: var(--mauve); padding: 10px 8px; }
td { padding: 12px 8px; border-top: 1.5px dashed var(--line); vertical-align: middle; }
.num { text-align: right; white-space: nowrap; }
td small { display: block; color: var(--mauve); }
td.main strong { font-weight: 600; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 260px; }
.good { color: var(--ok); font-weight: 600; }

.pill { display: inline-block; padding: 2px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.low { background: var(--low-bg); color: var(--low); }
.pill.out { background: var(--out-bg); color: var(--out); }

select.status { padding: 4px 28px 4px 12px; border-radius: 999px; font-weight: 600; font-size: .9rem; border-width: 0; cursor: pointer; }
select.status.pending   { background-color: var(--low-bg);  color: var(--low); }
select.status.paid      { background-color: var(--out-bg);  color: var(--out); }
select.status.shipped   { background-color: var(--ship-bg); color: var(--ship); }
select.status.completed { background-color: var(--ok-bg);   color: var(--ok); }
select.status.cancelled { background-color: var(--grey-bg); color: var(--grey); cursor: not-allowed; }

.empty { text-align: center; padding: 36px 12px; color: var(--mauve); }
.empty p { margin: 0 0 14px; }

/* ---------- dialogs ---------- */
dialog {
  border: 1.5px solid var(--petal); border-radius: 24px; padding: 0;
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  background: var(--cream); color: var(--cocoa);
  box-shadow: 0 18px 50px rgba(190, 68, 104, .22);
}
dialog.wide { width: min(700px, calc(100vw - 24px)); }
dialog.small { width: min(400px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(120, 60, 80, .28); backdrop-filter: blur(2px); }
dialog form { padding: 24px; display: grid; gap: 14px; }
dialog form h2 { font-size: 1.5rem; margin: 0; }
dialog p { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; align-content: start; }
.field input, .field select, .field textarea { font-weight: 400; }
.field select { width: 100%; }
.opt { font-weight: 400; color: var(--mauve); }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-error { background: var(--out-bg); color: var(--out); padding: 10px 14px; border-radius: 12px; font-weight: 600; }

.items { border: 1.5px dashed var(--petal); border-radius: 16px; padding: 12px 14px 14px; margin: 0; min-width: 0; }
.items legend, .items .legend { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 1.05rem; padding: 0 6px; }
.items .legend { padding: 0 0 6px; }
.line { display: grid; grid-template-columns: 1fr 76px 104px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.line.head { font-size: .8rem; color: var(--mauve); margin-bottom: 4px; }
.line select { width: 100%; }
.line .x { border: 0; background: transparent; color: var(--rose); font-size: 1.4rem; line-height: 1; cursor: pointer; border-radius: 50%; width: 36px; height: 36px; }
.line .x:hover { background: var(--blush); }

table.plain td { border-top: 1.5px dashed var(--line); padding: 8px 4px; }
table.plain tr:first-child td { border-top: 0; }

.totals { display: flex; gap: 10px; flex-wrap: wrap; }
.totals div { flex: 1 1 100px; background: var(--blush); border-radius: 14px; padding: 10px 14px; }
.totals span { display: block; font-size: .85rem; color: var(--mauve); }
.totals strong { font-family: var(--serif); font-style: italic; font-size: 1.3rem; }
.totals .profit { background: var(--rose); }
.totals .profit span, .totals .profit strong { color: #fff; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px);
  background: var(--cocoa); color: #fff; padding: 10px 22px; border-radius: 999px;
  font-weight: 600; opacity: 0; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #A93252; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- small screens ---------- */
@media (max-width: 800px) {
  .cols { grid-template-columns: 1fr; }
  .ribbon { grid-template-columns: 1fr 1fr; row-gap: 14px; }
  .ribbon .fig:nth-child(3) { border-left: 0; }
}

@media (max-width: 760px) {
  h1 { font-size: 1.7rem; }
  .tablewrap { background: none; border: 0; box-shadow: none; padding: 0; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack tr { background: var(--cream); border: 1.5px solid var(--line); border-radius: 18px;
    padding: 10px 16px; margin-bottom: 12px; box-shadow: 0 3px 0 var(--blush); }
  table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 14px;
    border: 0; padding: 5px 0; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--mauve); font-size: .85rem; text-align: left; flex: none; }
  table.stack td.main { display: block; text-align: left; padding-top: 2px; }
  table.stack td.main::before, table.stack td.actions::before { display: none; }
  table.stack td.actions { justify-content: flex-end; padding-top: 10px; border-top: 1.5px dashed var(--line); margin-top: 6px; }
  .clamp { max-width: none; text-align: right; }
  .grid2 { grid-template-columns: 1fr; }
  .line { grid-template-columns: 1fr 64px 88px 32px; gap: 6px; }
  .line .x { width: 32px; }
  dialog form { padding: 18px; }
}

/* ======================= v2 additions ======================= */
.titlebar { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 18px; }
.titlebar h1 { margin: 0; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--mauve); font-weight: 600; }

.ribbon.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; padding: 16px 8px; }
.ribbon.three .num-big { font-size: 1.5rem; }
.ribbon.three .fig.profit .num-big { font-size: 1.5rem; color: var(--cocoa); }
.ribbon .num-big { overflow-wrap: anywhere; }
.ribbon .fig.profit .num-big { font-size: 2rem; }
.cols .wide { grid-column: 1 / -1; }
.mini-ribbon { padding: 12px 8px; margin-bottom: 16px; }
.mini-ribbon .num-big { font-size: 1.25rem; }
.mini-ribbon .fig.profit .num-big { font-size: 1.25rem; }
.mini-ribbon .lbl { font-size: .82rem; }

/* filters */
.filters { margin: -4px 0 16px; }
.filters > summary {
  display: inline-block; cursor: pointer; list-style: none; user-select: none;
  padding: 7px 18px; border-radius: 999px; border: 1.5px solid var(--petal);
  background: var(--cream); color: var(--rose-dark); font-weight: 600;
}
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary::before { content: "▸ "; }
.filters[open] > summary::before { content: "▾ "; }
.filters > summary:hover { background: var(--blush); }
.filters[data-active]:not([data-active="0"]) > summary { background: var(--rose); border-color: var(--rose); color: #fff; }
.filter-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px;
  background: var(--cream); border: 1.5px solid var(--line); border-radius: 18px;
  padding: 16px; margin-top: 10px; box-shadow: 0 3px 0 var(--blush);
}
.filter-grid .field select { width: 100%; }
.field.wide2 { grid-column: span 2; }
.datetrio { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 8px; }
.datetrio select { width: 100%; font-weight: 400; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.toolbar select { flex: 0 0 auto; max-width: 100%; }

/* product photos */
.thumb { width: 52px; height: 52px; border-radius: 14px; flex: none; object-fit: cover; border: 1.5px solid var(--line); background: var(--blush); }
.thumb.ph { display: inline-grid; place-items: center; color: var(--rose); font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 1.4rem; }
.prod { display: flex; align-items: center; gap: 12px; text-align: left; }
.prod strong { display: block; font-weight: 600; }
.prod small { display: block; color: var(--mauve); }
.photo { display: flex; align-items: center; gap: 16px; }
.photo-preview {
  width: 96px; height: 96px; border-radius: 20px; flex: none; background: var(--blush) center / cover no-repeat;
  border: 1.5px dashed var(--ribbon); display: grid; place-items: center; color: var(--rose); font-size: .85rem; text-align: center;
}
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo-actions .hint { flex-basis: 100%; margin: 2px 0 0; }
label.btn { display: inline-block; }

.mh { font-weight: 600; font-size: .85rem; color: var(--rose); min-height: 1.3em; }
.addr { color: var(--mauve); font-size: .85rem; }


/* receipt: hidden on screen, the only thing shown when printing */
#receipt { display: none; }
@media print {
  body { background: #fff; }
  body > *:not(#receipt) { display: none !important; }
  dialog { display: none !important; }
  #receipt { display: block !important; color: #000; font-family: var(--sans); max-width: 420px; margin: 0 auto; padding: 12px; }
  #receipt h1 { font-size: 1.6rem; text-align: center; margin: 0; color: #000; }
  #receipt .c { text-align: center; margin: 2px 0; }
  #receipt hr { border: 0; border-top: 1px dashed #000; margin: 10px 0; }
  #receipt table { width: 100%; border-collapse: collapse; }
  #receipt td { border: 0; padding: 3px 0; vertical-align: top; }
  #receipt td.num { text-align: right; }
  #receipt .tot td { font-weight: 700; font-size: 1.1rem; border-top: 1px dashed #000; padding-top: 8px; }
}

@media (max-width: 800px) {
  .ribbon.three { grid-template-columns: 1fr; row-gap: 10px; }
  .ribbon.three .fig { border-left: 0; border-top: 3px dotted var(--petal); padding-top: 10px; }
  .ribbon.three .fig:first-child { border-top: 0; padding-top: 4px; }
  .field.wide2 { grid-column: auto; }
  .mini-ribbon { grid-template-columns: 1fr 1fr; row-gap: 10px; }
}
@media (max-width: 760px) {
  .prod { text-align: left; }
  table.stack td.main .prod { justify-content: flex-start; }
  .toolbar select { flex: 1 1 140px; }
  .photo { flex-direction: column; align-items: flex-start; }
}

.datetrio select { min-width: 0; }
td.num > span small { display: block; }
@media (max-width: 760px) { table.stack td.num > span { text-align: right; } }

/* language switch */
.top-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.lang { display: inline-flex; border: 1.5px solid var(--petal); border-radius: 999px; background: var(--cream); padding: 2px; }
.lang button {
  font: inherit; font-size: .85rem; font-weight: 700; letter-spacing: .02em; cursor: pointer;
  border: 0; background: transparent; color: var(--rose-dark); padding: 5px 13px; border-radius: 999px;
}
.lang button:hover { background: var(--blush); }
.lang button[aria-pressed="true"] { background: var(--rose); color: #fff; }

/* ======================= v3 additions ======================= */
/* bigger product pictures, with arrows when there are several */
.thumb { width: 96px; height: 96px; border-radius: 18px; }
.thumb.ph { font-size: 2rem; }
.gal { position: relative; width: 96px; height: 96px; flex: none; }
.gal .thumb { width: 100%; height: 100%; cursor: zoom-in; display: block; }
.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; padding: 0 0 2px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .88); color: var(--rose-dark); font-size: 1.2rem; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 4px rgba(91, 58, 69, .25);
}
.gal-nav:hover { background: #fff; color: var(--rose); }
.gal-nav.prev { left: 4px; }
.gal-nav.next { right: 4px; }
.gal-count {
  position: absolute; right: 5px; bottom: 5px; font-size: .72rem; font-weight: 700; line-height: 1;
  background: rgba(91, 58, 69, .75); color: #fff; padding: 3px 7px; border-radius: 999px; pointer-events: none;
}
.prod small.desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 300px; margin-top: 2px; }
td.actions { white-space: normal; }
td.actions .btn { margin: 2px 0 2px 6px; }
table td.actions { min-width: 120px; }
.track { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }

/* photo viewer */
dialog.viewer { width: min(780px, calc(100vw - 24px)); overflow: hidden; }
.vwrap { position: relative; padding: 14px; display: grid; gap: 12px; }
.vclose {
  position: absolute; top: 22px; right: 22px; z-index: 2; width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .9); color: var(--rose-dark); font-size: 1.6rem; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 6px rgba(91, 58, 69, .25);
}
.vstage { position: relative; height: min(66vh, 560px); background: var(--blush); border-radius: 18px; overflow: hidden; display: grid; place-items: center; }
.vstage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.vstage .gal-nav { width: 46px; height: 46px; font-size: 2rem; padding-bottom: 4px; }
.vstage .gal-nav.prev { left: 12px; }
.vstage .gal-nav.next { right: 12px; }
.vstage .gal-count { right: 14px; bottom: 14px; font-size: .85rem; padding: 4px 10px; }
.vstrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px; }
.vt { flex: none; width: 60px; height: 60px; padding: 0; border: 2px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; background: var(--blush); opacity: .75; }
.vt.on { border-color: var(--rose); opacity: 1; }
.vt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vinfo { display: grid; gap: 2px; padding: 0 6px 6px; }
.vinfo strong { font-family: var(--serif); font-style: italic; font-size: 1.3rem; }
.vinfo small { color: var(--mauve); }
.vprice { color: var(--rose); font-weight: 700; }
.vinfo p { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* photo uploader in the product form */
.photos { display: grid; gap: 8px; }
.photos .hint { margin: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.ptile { position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden; border: 1.5px solid var(--line); background: var(--blush); }
.ptile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ptile.cover { border-color: var(--ribbon); }
.ptile .px {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border: 0; border-radius: 50%; padding: 0 0 2px;
  background: rgba(255, 255, 255, .92); color: var(--rose-dark); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.ptile .px:hover { background: #fff; color: var(--rose); }
.pbadge, .pcover {
  position: absolute; left: 5px; bottom: 5px; font: inherit; font-size: .72rem; font-weight: 700; line-height: 1;
  padding: 4px 9px; border-radius: 999px; border: 0;
}
.pbadge { background: var(--rose); color: #fff; }
.pcover { background: rgba(255, 255, 255, .92); color: var(--rose-dark); cursor: pointer; }
.pcover:hover { background: #fff; }
.ptile.add { display: grid; place-content: center; text-align: center; gap: 0; border: 1.5px dashed var(--ribbon); background: var(--cream); color: var(--rose); cursor: pointer; }
.ptile.add:hover { background: var(--blush); }
.ptile.add span { font-size: 1.8rem; line-height: 1.1; }
.ptile.add small { font-weight: 600; font-size: .8rem; }
.photos-head { display: flex; align-items: baseline; gap: 8px; }
.sku-hint { font-weight: 400; color: var(--mauve); }

/* customer picker */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  max-height: 252px; overflow-y: auto; background: #fff; border: 1.5px solid var(--petal); border-radius: 14px;
  box-shadow: 0 10px 28px rgba(190, 68, 104, .2);
}
.combo-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-weight: 400; }
.combo-list li:hover, .combo-list li.on { background: var(--blush); }
.combo-list strong { font-weight: 600; }
.combo-list .ph { color: var(--mauve); }
.combo-list small { display: block; color: var(--mauve); font-size: .82rem; }
.combo-list em { font-style: normal; color: var(--rose); font-size: .8rem; font-weight: 600; white-space: nowrap; }

/* categories dialog */
dialog .dform { padding: 24px; display: grid; gap: 14px; }
dialog .dform h2 { font-size: 1.5rem; margin: 0; }
.cat-list { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; padding: 2px; }
.cat-row { display: grid; grid-template-columns: 1fr 110px auto auto auto; gap: 8px; align-items: center; }
.cat-row.new { grid-template-columns: 1fr 110px auto; padding-top: 10px; border-top: 1.5px dashed var(--line); }
.cat-row input { padding: 7px 10px; }
.cat-n { color: var(--mauve); font-size: .82rem; white-space: nowrap; }

/* invoice extras */
#receipt .r-logo { text-align: center; line-height: 0; }
#receipt .ship { text-align: center; margin: 4px 0 0; }
#receipt .since { font-weight: 700; letter-spacing: .03em; margin-top: 6px; }
@media print { #receipt { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

@media (max-width: 760px) {
  .thumb, .gal { width: 84px; height: 84px; }
  .cat-row { grid-template-columns: 1fr 90px; }
  .cat-row .cat-n { grid-column: 1 / -1; }
  .cat-row.new { grid-template-columns: 1fr 90px auto; }
  .vstage { height: 52vh; }
  dialog .dform { padding: 18px; }
}

@media (max-width: 560px) {
  .top nav { flex-wrap: wrap; }
  .top nav a { padding: 6px 12px; }
  .top-right { max-width: 100%; }
}
.btn { white-space: nowrap; }

/* ======================= v4: sales page + admin sign-in ======================= */
.hero { text-align: center; padding: 8px 0 22px; }
.hero h1 { margin-bottom: 6px; font-size: 2.3rem; }
.hero p { margin: 0 auto; max-width: 560px; color: var(--mauve); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 18px; }
.chip {
  font: inherit; font-weight: 600; cursor: pointer; padding: 6px 16px; border-radius: 999px;
  border: 1.5px solid var(--petal); background: var(--cream); color: var(--rose-dark);
}
.chip:hover { background: var(--blush); }
.chip[aria-pressed="true"] { background: var(--rose); border-color: var(--rose); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { display: flex; flex-direction: column; background: var(--cream); border: 1.5px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 3px 0 var(--blush); }
.card .pic { position: relative; aspect-ratio: 1; background: var(--blush); cursor: zoom-in; overflow: hidden; display: grid; place-items: center; }
.card .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .gal-nav { width: 30px; height: 30px; font-size: 1.4rem; }
.card.soldout .pic img { filter: grayscale(.7); opacity: .65; }
.phold { display: grid; place-items: center; color: var(--rose); font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 3rem; }
.vstage .phold { font-size: 6rem; }
.flag { position: absolute; left: 10px; top: 10px; font-size: .78rem; font-weight: 700; padding: 3px 11px; border-radius: 999px; }
.flag.low { background: var(--low-bg); color: var(--low); }
.flag.out { background: var(--out-bg); color: var(--out); }
.card .body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; flex: 1; }
.card .cat { color: var(--mauve); font-size: .8rem; }
.card h3 { margin: 0; font-size: 1.02rem; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.card .price { color: var(--rose); font-weight: 700; font-size: 1.05rem; }
.card .desc { margin: 0; color: var(--mauve); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .btn { margin-top: 8px; width: 100%; }
.card .cardbuy { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }   /* buttons sit on the same line on every card */
.card .cardbuy .btn { margin-top: 0; width: auto; flex: 1; }
.card .cardbuy .btn.iconbtn { flex: 0 0 46px; }
.iconbtn { display: inline-grid; place-items: center; padding: 0 !important; width: 46px; min-height: 42px; }
.iconbtn:hover { background: var(--petal); }
.buyrow .iconbtn { flex: 0 0 46px; }
.card .btn:disabled, #pAdd:disabled, #pBuy:disabled { opacity: .55; cursor: not-allowed; }

.foot { text-align: center; color: var(--mauve); padding: 8px 16px 40px; font-family: var(--serif); font-style: italic; }

.cartbtn { display: inline-flex; align-items: center; gap: 8px; }
.cartcount { background: var(--rose); color: #fff; border-radius: 999px; min-width: 22px; padding: 0 7px; font-size: .8rem; line-height: 22px; text-align: center; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--petal); border-radius: 999px; background: #fff; }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--rose-dark); font-size: 1.2rem; cursor: pointer; border-radius: 50%; }
.stepper button:hover:not(:disabled) { background: var(--blush); }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper output { min-width: 28px; text-align: center; font-weight: 700; }
.buyrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
#pHint { margin: 4px 0 0; }

.cline { display: grid; grid-template-columns: 56px 1fr auto auto 34px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1.5px dashed var(--line); }
.cline img, .cline .cph { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--blush); border: 1.5px solid var(--line); }
.cline .cph { display: grid; place-items: center; color: var(--rose); font-family: var(--serif); font-style: italic; font-weight: 700; }
.cline small { display: block; color: var(--mauve); }
.cline .lt { font-weight: 700; min-width: 96px; text-align: right; }
.cline .x { border: 0; background: transparent; color: var(--rose); font-size: 1.4rem; cursor: pointer; border-radius: 50%; width: 34px; height: 34px; }
.cline .x:hover { background: var(--blush); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.1rem; }
.cart-total strong { font-family: var(--serif); font-style: italic; font-size: 1.5rem; color: var(--rose); }
#whoBox .hint { margin: 0 0 10px; }
#whoBox .field + .field, #whoBox .grid2 + .field, #whoBox .grid2 + .grid2, #whoBox .field + .grid2 { margin-top: 10px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* admin extras */
.navbadge { display: inline-block; margin-left: 6px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--rose); color: #fff; font-size: .75rem; line-height: 20px; text-align: center; }
.alert-link { display: block; margin: 0 0 14px; padding: 12px 18px; border-radius: 16px; background: var(--low-bg); color: var(--low); font-weight: 700; text-decoration: none; border: 1.5px solid #F1D9A0; }
.alert-link:hover { background: #FFE8B0; }
.shoplink { text-decoration: none; display: inline-block; }
.pill.online { background: var(--ship-bg); color: var(--ship); margin-top: 4px; font-size: .75rem; }
select.status.accepted { background-color: #DDEBF7; color: #2F5B80; }

@media (max-width: 560px) {
  .hero h1 { font-size: 1.8rem; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card .body { padding: 10px; }
  .cline { grid-template-columns: 48px 1fr auto 30px; }
  .cline img, .cline .cph { width: 48px; height: 48px; }
  .cline .lt { grid-column: 2 / 4; text-align: left; min-width: 0; }
  .top .btn.small { padding: 5px 10px; }
}
#whoBox .grid2 .field + .field { margin-top: 0; }

/* sales page cards: the button always sits at the bottom, so every card in a row lines up */
.card .body { display: flex; flex-direction: column; gap: 4px; }
.card .body .btn { margin-top: auto; }
.card .body .price + .btn, .card .body .desc + .btn { margin-top: auto; }
.card .body > :nth-last-child(2) { margin-bottom: 8px; }
.muted { color: var(--mauve); }

/* v5 */
.chartpanel { margin-bottom: 18px; }
.chartpanel .titlebar { margin-bottom: 8px; }
.chartpanel h2 { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.cgrid { stroke: var(--line); stroke-dasharray: 3 4; }
.ctext { fill: var(--mauve); font-size: 11px; }
.bar-s { fill: var(--ribbon); }
.bar-p { fill: var(--rose-dark); }
.chart g:hover .bar-s { fill: var(--rose); }
.chart-sum { display: flex; gap: 8px 24px; flex-wrap: wrap; color: var(--mauve); font-size: .92rem; margin-bottom: 4px; }
.chart-sum strong { color: var(--cocoa); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.sw.s { background: var(--ribbon); } .sw.p { background: var(--rose-dark); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--rose); flex: none; padding: 0; }
.check small { display: block; font-weight: 400; color: var(--mauve); }
.pill.hidden { background: var(--grey-bg); color: var(--grey); margin-top: 4px; font-size: .75rem; }
.contact { margin-bottom: 6px; font-style: normal; font-family: var(--sans); }
.contact a { color: var(--rose-dark); font-weight: 600; text-decoration: none; }
.contact a:hover { text-decoration: underline; }
.track-result { background: var(--blush); border-radius: 16px; padding: 14px 16px; }
.track-result .hint { margin: 4px 0 8px; }
.tstatus { display: inline-block; padding: 4px 14px; border-radius: 999px; font-weight: 700; background: var(--low-bg); color: var(--low); }
.tstatus.s-accepted { background: #DDEBF7; color: #2F5B80; }
.tstatus.s-paid { background: var(--out-bg); color: var(--out); }
.tstatus.s-shipped { background: var(--ship-bg); color: var(--ship); }
.tstatus.s-completed { background: var(--ok-bg); color: var(--ok); }
.tstatus.s-cancelled { background: var(--grey-bg); color: var(--grey); }
.track-result .ship { margin: 8px 0 0; }

/* order queue page */
.qhead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.qstats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.qchip { background: var(--cream, #fff7f9); border: 1px solid var(--line, #f3d3dc); border-radius: 14px; padding: 8px 16px; display: flex; flex-direction: column; min-width: 110px; }
.qchip strong { font-size: .8rem; color: var(--mauve); font-weight: 600; }
.qchip span { font-size: 1.3rem; font-weight: 700; }

/* bank transfer */
.radio { display: flex; align-items: center; gap: 10px; padding: 8px 2px; cursor: pointer; }
.radio input { accent-color: var(--rose); width: 18px; height: 18px; }
.paybox { text-align: center; margin: 10px 0; }
.paybox .qr { max-width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--petal); background: #fff; }
.paybox .mini { text-align: left; margin-top: 8px; }
.paid { color: var(--ok); font-weight: 700; }
.payinfo { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 10px 0 0; }
.payinfo dt { color: var(--mauve); }
.payinfo dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
