/* XRoad Store POS — one stylesheet, phone first, tablet from 760px.
   Sections: tokens · base · controls · top bar & tabs · shared blocks ·
   sell · cart · items & lists · reports · dialogs · sale done · lock · toast */

/* ---- Tokens ---------------------------------------------------------------- */
:root {
  --green: #1f7a4d;
  --green-dark: #165c3a;
  --green-soft: #e7f3ec;
  --yellow: #f6c445;
  --bg: #f6f4ee;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #5f6a64;
  --line: #e2ded3;
  --low: #c2410c;        /* low stock, owes, warnings */
  --low-bg: #fff1e6;
  --low-line: #f3c7a6;
  --amber: #7a5b00;      /* needs a price */
  --amber-bg: #fff8e1;
  --amber-line: #f0d98a;
  --danger: #b91c1c;
  --blue: #1d5fbf;       /* services, GCash */
  --blue-bg: #e6efff;
  --blue-line: #c9d8f2;
  --purple: #6b3fb5;     /* kits */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px rgb(0 0 0 / 0.18);
  --tabs-h: 64px;
  --bar-h: 64px;
  color-scheme: light;
}

/* ---- Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 18px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h2 { font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
a { color: var(--blue); }
main { padding: 12px 16px; max-width: 1200px; margin: 0 auto; }
.muted { color: var(--muted); font-size: 16px; }
.small { font-size: 14px; }
.center { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; list-style: none; }
.empty button { margin-top: 12px; }

/* ---- Controls -------------------------------------------------------------- */
button, input, select { font: inherit; color: inherit; }
button, .button-like {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:active:not(:disabled), .button-like:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, .button-like:focus-within, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: 2px; }
button.primary, .button-like.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.primary:active:not(:disabled) { background: var(--green-dark); }
button.danger { color: var(--danger); border-color: #f1c4c4; }
button.ghost { background: transparent; }
button.big { min-height: 60px; width: 100%; font-size: 20px; }
a.button-like { text-decoration: none; color: var(--text); }
.small-btn { min-height: 40px; padding: 0 10px; font-size: 15px; flex-shrink: 0; }

input, select {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
input:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--green) 35%, transparent); border-color: var(--green); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 16px; color: var(--muted); }
.field input, .field select { color: var(--text); font-size: 20px; }
.field small { font-size: 14px; }
.check { display: flex; align-items: flex-start; gap: 12px; font-size: 17px; cursor: pointer; }
.check input { width: 26px; height: 26px; min-height: 0; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--green); }
.check span { display: flex; flex-direction: column; gap: 2px; }
.check small { font-size: 14px; color: var(--muted); }
.input-row { display: flex; gap: 8px; }
.input-row > :first-child { flex: 1; min-width: 0; }
.input-row button { flex-shrink: 0; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { border: 0; border-radius: 0; padding: 0 4px; font-weight: 600; font-size: 16px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--green); color: #fff; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip { flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 99px; font-size: 16px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.chip .count { font-weight: 700; }
.chip-sep { flex-shrink: 0; width: 1px; margin: 6px 2px; background: var(--line); }
.chip.warn { background: var(--low-bg); border-color: var(--low-line); color: var(--low); font-weight: 600; }
.chip.amber { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); font-weight: 600; }
.chip.warn[aria-pressed="true"], .chip.amber[aria-pressed="true"] { color: #fff; }
.chip.warn[aria-pressed="true"] { background: var(--low); border-color: var(--low); }
.chip.amber[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); }
.money-chip { background: var(--blue-bg); border-color: var(--blue-line); color: var(--blue); font-weight: 600; }
.money-chip svg { width: 18px; height: 18px; }

.badge { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 99px; background: var(--low); color: #fff; font-size: 13px; font-weight: 600; vertical-align: 1px; }
.badge.amber { background: var(--amber); }
.pill { display: inline-block; padding: 0 8px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--green-soft); color: var(--green); }
.pill.gcash { background: var(--blue-bg); color: var(--blue); }
.pill.utang { background: var(--low-bg); color: var(--low); }

svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Top bar & tabs ------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 8px 16px;
  background: var(--green); color: #fff;
  border-bottom: 4px solid var(--yellow);
}
.topbar h1 { margin: 0 auto 0 0; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offline { font-size: 14px; background: var(--yellow); color: var(--text); padding: 4px 10px; border-radius: 99px; font-weight: 600; }
.sync-badge {
  min-height: 36px; padding: 0 12px; flex-shrink: 0;
  font-size: 14px; font-weight: 600; border: 0; border-radius: 99px;
  background: rgb(255 255 255 / 0.18); color: #fff;
}
.sync-badge.error { background: var(--yellow); color: var(--text); }
.lock-btn { background: var(--yellow); color: var(--text); }
body.locked .lock-btn { display: none !important; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgb(0 0 0 / 0.04);
}
.tabs button {
  border: 0; border-radius: 0; height: var(--tabs-h); padding: 0 2px;
  flex-direction: column; gap: 3px;
  font-size: 13px; font-weight: 600; color: var(--muted); background: transparent;
}
.tabs svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--green); box-shadow: inset 0 3px 0 var(--green); }
.tabs button[aria-current="page"] svg { stroke-width: 2.4; }
.tabs button.locked-tab { opacity: 0.4; }

/* ---- Shared blocks ------------------------------------------------------------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar .search { flex: 1; min-width: 0; }
.toolbar button { flex-shrink: 0; padding: 0 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions > * { flex: 1 1 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 8px; }
.card form { display: flex; flex-direction: column; gap: 12px; }

/* Settings sections that fold open */
details.fold { padding: 0; }
details.fold > summary {
  list-style: none; cursor: pointer; padding: 14px; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; font-size: 18px; }
details.fold > summary .summary-note { margin-left: auto; font-size: 14px; color: var(--muted); text-align: right; }
details.fold > summary::after { content: '›'; font-size: 26px; color: var(--muted); transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold > .fold-body { padding: 0 14px 14px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-4 { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.stat span { font-size: 14px; color: var(--muted); }
.stat strong { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { font-size: 13px; color: var(--muted); }
.stat.low, .stat.owes { background: var(--low-bg); border-color: var(--low-line); }
.stat.low strong, .stat.owes strong { color: var(--low); }
.stats.compact .stat strong { font-size: 19px; }
@media (max-width: 420px) { .stats-3 .stat strong { font-size: 18px; } }

.sum-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; }
.sum-row span { min-width: 0; }
.sum-row strong { white-space: nowrap; }
.sum-row.total strong { font-size: 28px; }
.sum-row.strong-row { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.sum-row.strong-row strong { font-size: 22px; color: var(--green); }
.sum-row.change strong { font-size: 26px; color: var(--green); }
.sum-row.change strong.warn { color: var(--low); font-size: 20px; }

.back { padding-left: 4px; margin-bottom: 4px; color: var(--green); font-weight: 600; }
.detail-title { font-size: 24px; margin: 4px 0; overflow-wrap: anywhere; }
.low-banner {
  width: 100%; margin-bottom: 12px; justify-content: flex-start; text-align: left;
  background: var(--low-bg); border-color: var(--low-line); color: var(--low); font-weight: 600;
}
.price-banner { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.no-price { color: var(--amber); font-size: 15px; font-weight: 600; }

/* ---- Sell ---------------------------------------------------------------------- */
.catalog { min-width: 0; } /* lets the category row scroll instead of widening the page */
.grid-note, .list-note { margin: 0 0 8px; font-size: 14px; list-style: none; color: var(--muted); }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid .empty { grid-column: 1 / -1; }
.tile {
  position: relative;
  flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 2px;
  min-height: 100px; padding: 10px 12px; text-align: left;
}
.tile-name {
  font-weight: 600; font-size: 17px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.tile-price { font-size: 19px; font-weight: 700; color: var(--green); }
.tile-stock { font-size: 13px; color: var(--muted); }
.tile-qty {
  position: absolute; top: -8px; right: -8px;
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 99px;
  display: grid; place-items: center;
  background: var(--yellow); font-weight: 700; font-size: 15px; box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
/* States: shown in the small stock line, not by repainting the whole tile */
.tile.low .tile-stock, .tile.expiring .tile-stock { color: var(--low); font-weight: 600; }
.tile.expired { border-color: var(--low-line); }
.tile.expired .tile-stock { color: var(--danger); font-weight: 700; }
.tile.service .tile-stock { color: var(--blue); font-weight: 600; }
.tile.kit .tile-stock { color: var(--purple); font-weight: 600; }
.tile.group { border: 2px solid #b7d3c4; box-shadow: 4px 4px 0 -1px var(--line); }
.tile.no-price-tile { border-style: dashed; background: #fffdf5; }
.tile.no-price-tile .tile-price { color: var(--muted); }
.tile.no-price-tile .tile-stock { color: var(--amber); font-weight: 600; }

/* First run */
.welcome { grid-column: 1 / -1; text-align: center; padding: 28px 18px; }
.welcome h2 { margin: 0 0 6px; font-size: 22px; }
.welcome p { margin: 0 auto 16px; max-width: 420px; }
.welcome .actions { flex-direction: column; max-width: 360px; margin: 0 auto; }

/* Group flavor picker, barcode link list */
.picker { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.pick-row { display: flex; align-items: center; gap: 8px; }
.pick { flex: 1; min-width: 0; min-height: 56px; flex-direction: column; align-items: flex-start; text-align: left; padding: 8px 12px; gap: 0; }
.pick-name { font-weight: 600; overflow-wrap: anywhere; }
.pick-sub { font-size: 14px; color: var(--muted); }
.pick-qty { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 99px; display: grid; place-items: center; background: var(--yellow); font-weight: 700; }
.pick-minus { width: 48px; padding: 0; font-size: 24px; flex-shrink: 0; }

/* ---- Cart ---------------------------------------------------------------------- */
.cart { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cart > * { flex-shrink: 0; } /* scroll the cart instead of squashing its parts */
.cart-head { display: flex; align-items: center; gap: 8px; }
.cart-head h2 { margin: 0 auto 0 0; }
.cart-lines { list-style: none; margin: 0; padding: 0; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.line-name { font-weight: 600; overflow-wrap: anywhere; }
.line-sub { font-size: 15px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 48px; padding: 0; font-size: 24px; }
.stepper .qty { min-width: 28px; text-align: center; font-weight: 700; }
.stepper button.qty { width: auto; min-width: 52px; padding: 0 8px; font-size: 18px; background: var(--bg); }
.quick-cash { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.quick-cash:empty { display: none; }
.quick-cash button { padding: 0 6px; }
.pay { display: flex; flex-direction: column; gap: 10px; }
.qr-img { display: block; width: 100%; max-width: 320px; max-height: 60vh; object-fit: contain; margin: 0 auto; border-radius: 12px; background: #fff; }

.cart-bar {
  position: fixed; left: 12px; right: 12px; z-index: 15;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  height: var(--bar-h);
  justify-content: space-between; gap: 8px;
  background: var(--green); color: #fff; border: 0; font-size: 18px;
  box-shadow: var(--shadow);
}
.cart-bar strong { font-size: 22px; }

/* Phone: cart opens as a full-screen panel */
@media (max-width: 759px) {
  #view-sell { padding-bottom: calc(var(--bar-h) + 20px); }
  .cart {
    display: none;
    position: fixed; inset: 0 0 calc(var(--tabs-h) + env(safe-area-inset-bottom)) 0; z-index: 25;
    border-radius: 0; border: 0; overflow-y: auto;
  }
  .cart.open { display: flex; }
}

/* ---- Items, customers & other lists ---------------------------------------------- */
.prod-list, .sales-list, .moves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prod-row {
  width: 100%; min-height: 64px; padding: 10px 14px;
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name price" "stock stock";
  gap: 2px 12px; text-align: left; justify-content: stretch;
}
.prod-name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
.prod-price { grid-area: price; font-weight: 700; color: var(--green); white-space: nowrap; }
.prod-stock { grid-area: stock; font-size: 15px; color: var(--muted); }
.prod-row.low .prod-stock { color: var(--low); }
.prod-row.owes { border-color: var(--low-line); }
.prod-row.owes .prod-price { color: var(--low); }

.moves li { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.moves li.empty { background: none; border: 0; justify-content: center; }
.moves li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.moves small { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.move-qty { font-weight: 700; white-space: nowrap; }
.move-qty.pos { color: var(--green); }
.move-qty.neg { color: var(--low); }
.voided { opacity: 0.55; }
.voided strong { text-decoration: line-through; }

.import-card { margin-top: 16px; }
.import-card h3 { margin: 0 0 6px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; }
.import-card .muted { margin: 0; }
.import-summary { margin: 0; padding-left: 20px; }
.import-summary .warn { color: var(--low); }
.import-errors { margin: 0; padding: 8px 8px 8px 24px; max-height: 30vh; overflow-y: auto; background: var(--low-bg); border-radius: 10px; font-size: 14px; color: var(--low); }
.catalog-list { display: flex; flex-direction: column; gap: 12px; max-height: 50vh; overflow-y: auto; padding: 2px; }

/* Set prices sheet */
.sheet { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.sheet-head, .sheet-row { display: grid; grid-template-columns: 1fr 76px 60px 64px; gap: 6px; align-items: center; }
.sheet-head { font-size: 13px; color: var(--muted); position: sticky; top: 0; background: var(--card); padding-bottom: 4px; z-index: 1; }
.sheet-name { font-size: 15px; overflow-wrap: anywhere; }
.sheet-row input { min-height: 44px; padding: 0 8px; font-size: 17px; }
.sheet-row.focus-row { background: var(--amber-bg); border-radius: 8px; }

/* ---- Reports ------------------------------------------------------------------- */
.period-seg { margin-bottom: 10px; }
.date-nav { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; margin-bottom: 8px; }
.date-nav button { font-size: 26px; padding: 0; }
.sales-date { margin: 4px 0 12px; font-size: 18px; color: var(--muted); }
.top { margin: 0; padding: 0 0 0 24px; }
.top li { padding: 4px 0; }
.top li span:last-child { float: right; color: var(--muted); font-size: 16px; }
.sale { width: 100%; padding: 10px 14px; text-align: left; flex-direction: column; align-items: stretch; gap: 2px; }
.sale-head { display: flex; justify-content: space-between; gap: 8px; }
.sale-items { color: var(--muted); font-size: 16px; overflow-wrap: anywhere; }
.sale-detail .sum-row span { font-size: 16px; }

/* ---- Tablet and wider -------------------------------------------------------- */
@media (min-width: 760px) {
  .phone-only { display: none !important; }
  /* minmax(0, 1fr): a long category row must not push the cart off screen */
  .sell-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
  .cart { position: sticky; top: 12px; max-height: calc(100vh - var(--tabs-h) - 24px); overflow-y: auto; }
  .stats-4 { grid-template-columns: repeat(4, 1fr); }
  .prod-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prod-list > .list-note, .prod-list > .empty { grid-column: 1 / -1; }
}

/* ---- Dialogs ------------------------------------------------------------------- */
dialog {
  width: min(480px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  border: 0; border-radius: 18px; padding: 18px;
  background: var(--card); color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin: 0 0 4px; }
#form-dialog form { display: flex; flex-direction: column; gap: 12px; }
#form-dialog .muted { margin: 0; }
.form-error { margin: 0; color: var(--danger); min-height: 1.2em; font-size: 16px; }
.form-error:empty { min-height: 0; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: -18px; background: var(--card); padding: 8px 0 0; }
.dlg-actions .spacer { flex: 1; }
.dlg-actions button { padding: 0 12px; }

.scan-dialog { padding: 12px; display: none; flex-direction: column; gap: 10px; background: #111; color: #fff; }
.scan-dialog[open] { display: flex; }
.scan-view { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 65vh; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 22% 12%; border: 3px solid var(--yellow); border-radius: 12px; box-shadow: 0 0 0 999px rgb(0 0 0 / 0.35); }
.scan-msg { margin: 0; min-height: 2.6em; text-align: center; }

/* ---- Sale done screen ------------------------------------------------------------ */
.done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; }
.done-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); margin-bottom: 6px; }
.done-icon svg { width: 34px; height: 34px; stroke-width: 3; }
.done-label { font-size: 16px; color: var(--muted); margin-top: 6px; }
.done-amount { font-size: 48px; font-weight: 800; color: var(--green); line-height: 1.1; }
.done-amount.small-amount { font-size: 32px; }
.done-sub { font-size: 16px; color: var(--muted); }

/* ---- Lock screen ----------------------------------------------------------------- */
.login { max-width: 440px; margin: 32px auto; padding: 0 16px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login h2 { margin: 0; font-size: 24px; }
.login .muted { margin: 0; }
body.locked main, body.locked .tabs, body.locked #sync-badge { display: none !important; }
body.locked { padding-bottom: 0; }

/* ---- Toast ----------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; z-index: 40;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 90px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  button:active:not(:disabled) { transform: none; }
}
details.fold > summary .summary-note.due { color: var(--low); font-weight: 600; }

/* ---- Final touches ---------------------------------------------------------- */
.sync-badge svg, .lock-btn svg { width: 18px; height: 18px; }
.button-like svg, .actions button svg { width: 20px; height: 20px; flex-shrink: 0; }
.login-icon { width: 64px; height: 64px; border-radius: 16px; align-self: center; margin-bottom: 4px; }
.login h2 { text-align: center; }
.login form > .muted:first-of-type { text-align: center; }

/* ---- Sign-up, plan, admin ----------------------------------------------------- */
#login-form[data-mode="signin"] .signup-only, #login-form[data-mode="signup"] .signin-only { display: none; }
#login-form .ghost { color: var(--green); font-weight: 600; }
.expired-card { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.expired-card h2 { margin: 0; }
.expired-card .muted { margin: 0; }
.expired-card .actions { flex-direction: column; }
.renew-contact { margin: 0; padding: 12px; border-radius: var(--radius-sm); background: var(--amber-bg); color: var(--amber); font-weight: 600; }
.renew-contact a { color: inherit; text-decoration: underline; }
.nowrap { white-space: nowrap; }
.plan-bar {
  display: flex; width: 100%; min-height: 40px; border: 0; border-radius: 0;
  justify-content: center; font-size: 15px; font-weight: 600;
  background: var(--amber-bg); color: var(--amber); border-bottom: 1px solid var(--amber-line);
}
body.locked .plan-bar { display: none !important; }
.admin-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.admin-store { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.admin-store small { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.admin-store .actions { margin: 6px 0 0; }

/* ---- Fill prices with markup ----------------------------------------------- */
.markup-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.markup-row .field input, .markup-row .field select { font-size: 18px; min-height: 48px; }
.markup-row button { min-height: 48px; }
.sheet-row input[data-auto] { background: var(--green-soft); }

/* ---- Admin: many stores ------------------------------------------------------ */
.admin-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.admin-totals .stat { padding: 8px 10px; }
.admin-totals .stat strong { font-size: 20px; }
.admin-search { width: 100%; font-size: 18px; min-height: 48px; margin-bottom: 8px; }
.admin-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.admin-bar .muted { flex: 1; font-size: 14px; }
.admin-sort { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--muted); }
.admin-sort select { min-height: 40px; font-size: 16px; }
.admin-more { width: 100%; margin-top: 10px; }
.admin-table-wrap { overflow-x: auto; margin-top: 10px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.admin-table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table { min-width: 900px; }
.admin-table td { white-space: nowrap; }
.admin-table td:first-child { white-space: normal; min-width: 140px; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-actions { white-space: nowrap; }
.admin-actions .small-btn + .small-btn { margin-left: 6px; }
.admin-page { background: var(--bg); }
.admin-top { display: flex; justify-content: space-between; align-items: baseline; max-width: 1200px; margin: 0 auto; padding: 16px 16px 0; }
.admin-top h1 { margin: 0; font-size: 26px; }
.admin-main { max-width: 1200px; margin: 12px auto; }
@media (max-width: 480px) { .admin-totals { grid-template-columns: repeat(2, 1fr); } }

/* ---- Old address: "the app has moved" ----------------------------------------- */
.moved-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; min-height: 48px; border: 0; border-radius: 0; padding: 8px 14px; background: var(--blue); color: #fff; font-size: 16px; font-weight: 700; }
body.moved { padding-top: 48px; }
