:root {
  --ink: #172c26; --muted: #5b6e66; --bg: #f3f7f4; --card: #fff; --line: #dce8e0;
  --brand: #147657; --brand-dark: #124c3c; --danger: #a33434; --warn-bg: #fff6e0; --err-bg: #fff1ee; --ok-bg: #e7f4ec;
  --tap: 44px; --bottom-nav: 64px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); }
img, svg { max-width: 100%; }

/* ---------- Header ---------- */
header.top { background: var(--brand-dark); color: #fff; padding: 10px max(calc((100% - 1080px) / 2), 16px);
  padding-top: max(10px, env(safe-area-inset-top)); display: flex; gap: 12px; justify-content: space-between; align-items: center; }
header.top a { color: #fff; text-decoration: none; }
header.top .brand { font-weight: 700; white-space: nowrap; }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
header.top nav.main a { padding: 10px 0; }
header.top nav.main a.active { text-decoration: underline; text-underline-offset: 6px; }
header.top .brand { flex: 0 0 auto; }
header.top .tools { display: flex; gap: 10px; align-items: center; justify-content: flex-end; min-width: 0; flex: 1 1 auto; }
header.top .tools form { min-width: 0; margin: 0; }
header.top .tools form:first-child { flex: 0 1 auto; }
header.top select { background: #ffffff1a; color: #fff; border: 1px solid #ffffff55; border-radius: 8px;
  padding: 8px 10px; width: 100%; max-width: 260px; min-width: 0; min-height: 40px; text-overflow: ellipsis; }
header.top select option { color: var(--ink); }
button.link { background: none; color: #fff; padding: 8px 4px; font-weight: 500; min-height: 40px; }

/* ---------- Bottom navigation (phones) ---------- */
.bottom-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff;
  border-top: 1px solid var(--line); box-shadow: 0 -4px 16px #123b2a14;
  grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottom-nav); color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600; }
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--brand); }

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 28px auto; padding: 0 16px; }
h1 { font-size: clamp(1.5rem, 4vw, 2.4rem); letter-spacing: -.02em; margin: 2px 0 12px; line-height: 1.2; overflow-wrap: anywhere; }
h2 { margin-top: 0; font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { color: var(--muted); margin: 0; font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 16px 0; box-shadow: 0 6px 22px #123b2a0a; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--ok-bg); margin: 0 0 12px; }
.notice.error { background: var(--err-bg); }
.notice.warn { background: var(--warn-bg); }
.flash-toast { position: fixed; z-index: 90; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: min(520px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px;
  background: #11633f; color: #fff; border-radius: 14px; box-shadow: 0 10px 30px #0b2b2155;
  animation: toast-in .25s ease-out; transition: opacity .3s, transform .3s; }
.flash-toast + .flash-toast { top: calc(84px + env(safe-area-inset-top)); }
.flash-toast.hide { opacity: 0; transform: translate(-50%, -12px); }
.flash-icon { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; background: #fff; color: #11633f;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; }
.flash-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.flash-text strong { font-size: 1rem; }
.flash-close { flex: 0 0 auto; background: none; color: #fff; font-size: 1.5rem; width: 44px; min-height: 44px; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .flash-toast { animation: none; transition: none; } }
.invite-box { display: grid; gap: 10px; border: 1px solid #b9dcc6; }
.invite-box input { font-size: 14px; }
header.top .store-name, header.top .admin-link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
header.top .admin-link { padding: 0 4px; font-weight: 600; }
header.top .brand, header.top .admin-link { display: inline-flex; align-items: center; min-height: 44px; }
.status { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.status.trial { background: var(--warn-bg); color: #8a5a00; }
.status.active { background: #dff3e6; color: #11633f; }
.status.suspended, .status.expired { background: var(--err-bg); color: var(--danger); }

/* ---------- Forms ---------- */
form.stack { display: grid; gap: 14px; }
label { font-weight: 600; display: grid; gap: 6px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: var(--tap); }
label.check input { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; accent-color: var(--brand); }
/* 16px text stops iOS from zooming into fields on focus. */
input, textarea, select { width: 100%; border: 1px solid #cad9d0; border-radius: 10px; padding: 10px 12px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink); min-height: var(--tap); }
textarea { min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; display: flex; gap: 4px 20px; flex-wrap: wrap; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.hint { color: var(--muted); font-size: .875rem; margin: -6px 0 0; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff;
  border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  min-height: var(--tap); touch-action: manipulation; }
.button.secondary, button.secondary { background: #e4efe8; color: var(--ink); }
button.danger, .button.danger { background: #fbeaea; color: var(--danger); }
button:active, .button:active { transform: translateY(1px); }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline-flex; margin: 0; }
.actions > a:not(.button) { padding: 10px 4px; }

/* ---------- Page toolbar & filters ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; justify-content: space-between; }
.toolbar > div { min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 160px; flex: 1 1 160px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 10px 8px; border-bottom: 1px solid #e5eee8; vertical-align: top; overflow-wrap: anywhere; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.inactive td { opacity: .55; }
td.row-actions { width: 1%; white-space: nowrap; overflow-wrap: normal; }
td.row-actions .actions { flex-wrap: nowrap; justify-content: flex-end; }

.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: #e4efe8; color: var(--ink); text-decoration: none; vertical-align: middle; }
.badge.warn { background: var(--warn-bg); color: #8a5a00; }
.badge.service { background: #e8eefc; color: #2a4a9a; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .badge { font-size: .875rem; padding: 6px 14px; min-height: 40px; display: inline-flex; align-items: center; }
.chips .badge.on { background: var(--brand); color: #fff; }
.split { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
tfoot td { border-top: 2px solid var(--line); }
.period-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 12px; }
.period-form input { min-width: 0; width: 100%; }
@media (max-width: 720px) { .period-form { grid-template-columns: 1fr 1fr; } .period-form button { grid-column: 1 / -1; } }
.commission-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.commission-form input[name=commission_percent] { width: 5.5em; min-width: 0; text-align: right; }
.commission-form button { min-height: 40px; padding: 6px 12px; }
.commission-form label.check { flex: 1 0 100%; min-height: 32px; font-weight: 400; justify-content: inherit; }
a.wa-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-weight: 600; }
a.wa-link::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #25d366; flex: 0 0 auto; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: inherit; }
.stat strong { display: block; font-size: 1.9rem; line-height: 1.2; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.pager { display: flex; gap: 12px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.pager a { padding: 10px 4px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid #e5eee8; }
.list-plain li:last-child { border-bottom: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex: 1 1 260px; min-width: 0; margin: 0; }
.inline-form input { flex: 1 1 auto; min-width: 0; }
.inline-form button { flex: 0 0 auto; }
details summary { cursor: pointer; padding: 8px 0; }
.store-plan + .store-plan { border-top: 1px solid #e5eee8; margin-top: 12px; }
.category-list { list-style: none; margin: 0; padding: 0; }
.category-list li { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid #e5eee8; }
.category-list li:last-child { border-bottom: 0; }
.category-meta { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.category-meta a { white-space: nowrap; padding: 10px 0; }
.category-meta form { margin: 0; }
.list-plain li.split { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.list-plain li.split > :last-child { white-space: nowrap; }

/* ---------- POS (cashier) ---------- */
body.no-scroll { overflow: hidden; }
.pos-top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.pos-search { display: flex; gap: 8px; align-items: center; }
.pos-search input { flex: 1 1 auto; min-width: 0; }
.pos-search .button, .pos-search button { flex: 0 0 auto; }
.pos-cats { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.pos-cats::-webkit-scrollbar { display: none; }
.chip { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 99px; padding: 8px 14px;
  min-height: 40px; font-weight: 600; white-space: nowrap; flex: 0 0 auto; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.pos-card { position: relative; display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 2px;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 8px; font-weight: 400; }
.pos-card.empty { opacity: .5; }
.pos-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: #eef4f0; }
.placeholder { display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: var(--brand);
  background: #e4efe8; }
.pos-name { font-weight: 600; line-height: 1.25; margin-top: 4px; overflow-wrap: anywhere; }
.pos-price { font-weight: 700; color: var(--brand-dark); }
.pos-stock { font-size: .8rem; color: var(--muted); }
.pos-qty { position: absolute; top: 4px; right: 4px; background: var(--brand); color: #fff; border-radius: 99px;
  min-width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-weight: 700; padding: 0 6px; }
.pos-links { text-align: center; margin: 16px 0 90px; }
.cart-bar { position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 25; display: flex; justify-content: space-between;
  align-items: center; gap: 10px; padding: 14px 18px; border-radius: 14px; box-shadow: 0 8px 24px #0b2b2140; min-height: 56px;
  max-width: 1056px; margin: 0 auto; }
.cart-total { font-size: 1.15rem; font-weight: 800; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 150px; z-index: 60; background: #172c26ee; color: #fff;
  padding: 10px 16px; border-radius: 99px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: #0b1f1a80; display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
.sheet-full { height: 100%; max-height: 100%; border-radius: 0; padding-bottom: 0; }
@media (min-width: 720px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } .sheet-full { height: auto; max-height: 92vh; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -18px; background: #fff;
  margin: -18px -16px 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); z-index: 2; }
.sheet-head h2 { margin: 0; }
.sheet-close { position: absolute; top: 8px; right: 8px; background: #eef4f0; color: var(--ink); width: 44px; height: 44px;
  border-radius: 50%; font-size: 1.5rem; padding: 0; }
.sheet-head .sheet-close { position: static; }
.ps-image { display: flex; justify-content: center; margin-bottom: 8px; }
.ps-img { width: min(240px, 70vw); aspect-ratio: 1; object-fit: cover; border-radius: 14px; }
.ps-price { font-size: 1.6rem; font-weight: 800; color: var(--brand-dark); margin: 4px 0; }
.stepper { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.stepper button { width: 48px; font-size: 1.4rem; padding: 0; }
.stepper input { width: 80px; text-align: center; font-size: 1.2rem; }
.stepper.small { margin: 0; gap: 4px; }
.stepper.small button { width: 40px; min-height: 40px; }
.stepper.small span { min-width: 24px; text-align: center; font-weight: 700; }
.sheet-actions { display: grid; gap: 8px; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); }
.sticky-actions button { min-height: 52px; font-size: 1.1rem; }
.co-block { padding: 12px 0; border-bottom: 1px solid #eef3ef; }
.co-block h3 { margin: 0 0 8px; font-size: 1rem; }
.co-items { list-style: none; margin: 0; padding: 0; }
.co-items li { display: grid; grid-template-columns: 44px 1fr auto; grid-template-areas: "img main step" "img main line";
  gap: 2px 10px; align-items: center; padding: 8px 0; }
.co-img { grid-area: img; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; font-size: 1.1rem; }
.co-item-main { grid-area: main; display: grid; min-width: 0; overflow-wrap: anywhere; }
.co-items .stepper { grid-area: step; justify-self: end; }
.co-line { grid-area: line; justify-self: end; font-weight: 700; }
.co-results { list-style: none; margin: 6px 0 0; padding: 0; }
.co-results li { border-bottom: 1px solid #eef3ef; }
.link-btn { background: none; color: var(--brand); padding: 10px 0; font-weight: 600; text-align: left; width: 100%; }
.co-picked { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--ok-bg); padding: 8px 12px; border-radius: 10px; }
.small-btn { min-height: 40px; padding: 6px 12px; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: 0 0 auto; }
.segmented button { background: #fff; color: var(--ink); border-radius: 0; font-weight: 600; padding: 10px 14px; }
.segmented button.on { background: var(--brand); color: #fff; }
.segmented.wide { display: grid; grid-template-columns: repeat(2, 1fr); }
.segmented.wide button { border-bottom: 1px solid var(--line); }
.co-change { font-size: 1.1rem; margin: 8px 0 0; }
.co-change .bad { color: var(--danger); }
#co-quick { margin-top: 8px; }
.co-summary { padding: 12px 0; }
.co-summary p { display: flex; justify-content: space-between; margin: 4px 0; }
.co-grand { font-size: 1.3rem; font-weight: 800; }

.scanner { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 16px; }
.scanner-frame { position: relative; width: min(92vw, 480px); aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; background: #111; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #3ee08a; box-shadow: 0 0 12px #3ee08a; }
.scanner-msg { color: #fff; text-align: center; max-width: 420px; margin: 0; }
.scanner-msg.error { color: #ffd0c8; }
.scanner-close { min-width: 160px; }

/* ---------- Sales & invoice ---------- */
.sale-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid #e5eee8;
  color: inherit; text-decoration: none; }
.sale-row:last-child { border-bottom: 0; }
.sale-row .amount { font-weight: 700; text-align: right; }
.sale-row.void .amount { text-decoration: line-through; color: var(--muted); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.summary-grid div { background: #f6faf7; border-radius: 10px; padding: 10px; min-width: 0; }
.summary-grid strong { display: block; font-size: clamp(.95rem, 4vw, 1.25rem); white-space: nowrap; }
.receipt-lines { list-style: none; margin: 0; padding: 0; }
.receipt-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed #d5e2da; }
.receipt-lines li > span:last-child { white-space: nowrap; font-weight: 600; }
.totals p { display: flex; justify-content: space-between; margin: 4px 0; }
.totals .grand { font-size: 1.3rem; font-weight: 800; }
.big-actions { display: grid; gap: 10px; }
.big-actions .button, .big-actions button { min-height: 52px; font-size: 1.05rem; width: 100%; }
.button.wa { background: #1f9e55; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 2px;
  padding: 10px 12px; background: #f6faf7; border-radius: 10px; }
.switch { flex: 0 0 auto; position: relative; width: 56px; min-height: 32px; height: 32px; padding: 0; border-radius: 99px;
  background: #c9d6ce; transition: background .2s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px #0003; transition: left .2s; }
.switch.on { background: var(--brand); }
.switch.on .knob { left: 27px; }
.switch:focus-visible { outline: 3px solid #9fd3b6; outline-offset: 2px; }
.logo-header { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: #fff; padding: 2px; flex: 0 0 auto; }
.logo-title { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 4px; flex: 0 0 auto; }
.store-title { display: flex; gap: 12px; align-items: center; }
.store-title h1 { margin-bottom: 8px; }
.logo-preview { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; display: block; margin: 4px 0; }
.logo-receipt { display: block; max-width: 120px; max-height: 72px; object-fit: contain; margin: 0 auto 8px; }
.receipt-head { text-align: center; }
.action-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.action-pair form { margin: 0; display: flex; }
.action-pair .button, .action-pair button { width: 100%; min-height: 52px; font-size: 1.05rem; }
.button.warn-btn { background: #fff3dc; color: #7a4d00; border: 1px solid #f0d49a; }
button.danger { border: 1px solid #f1c9c9; }
.sale-item { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #e5eee8; }
.sale-item:last-child { border-bottom: 0; }
.sale-item .sale-row { flex: 1 1 auto; border-bottom: 0; min-width: 0; }
.sale-item .row-btn { flex: 0 0 auto; min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.sale-row strong { white-space: nowrap; }
@media (max-width: 719px) {
  .sale-item .sale-row { grid-template-columns: 1fr; }
  .sale-item .sale-row .amount { text-align: left; grid-row: 2; }
}
.product-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; float: left; margin-right: 10px; }
.image-preview { width: 120px; height: 120px; border-radius: 12px; object-fit: cover; display: block; margin: 4px 0; }
.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1 1 auto; min-width: 0; }

/* ---------- Phones ---------- */
@media (max-width: 719px) {
  header.top nav.main { display: none; }
  header.top { gap: 8px; }
  .cart-bar { bottom: calc(var(--bottom-nav) + 10px + env(safe-area-inset-bottom)); }
  .pos-grid { grid-template-columns: repeat(2, 1fr); }
  .toast { bottom: calc(var(--bottom-nav) + 84px); }
  header.top .brand-long { display: none; }
  .bottom-nav { display: grid; }
  main { margin: 16px auto; padding-bottom: calc(var(--bottom-nav) + 24px + env(safe-area-inset-bottom)); }
  .card { padding: 14px; border-radius: 12px; margin: 12px 0; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat strong { font-size: 1.6rem; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .quick-actions .button { padding: 10px 6px; font-size: .95rem; }
  .toolbar { align-items: stretch; }
  .toolbar > .actions { width: 100%; }
  .toolbar > .actions > .button, .toolbar > .button { flex: 1; }
  .filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .filters input, .filters select, .filters button { min-width: 0; width: 100%; padding-left: 10px; padding-right: 10px; }
  .filters input[type=search] { grid-column: 1 / 4; }
  .filters button { grid-column: 4; grid-row: 1; }
  .filters select:first-of-type { grid-column: 1 / 3; }
  .filters select:nth-of-type(2) { grid-column: 3 / 5; }
  .filters select:only-of-type, .filters .full-row { grid-column: 1 / 5; }
  .form-actions > button, .form-actions > .button { flex: 1 1 100%; }
  .form-actions > a { width: 100%; text-align: center; }

  /* Tables turn into stacked cards: each cell shows its column name from data-label. */
  .table-wrap { overflow: visible; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  table.cards td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; white-space: normal; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; flex: 0 0 auto; }
  table.cards td.primary { display: block; text-align: left; font-size: 1.05rem; padding-bottom: 6px; }
  table.cards td.primary::before, table.cards td.row-actions::before { content: none; }
  table.cards td.row-actions { width: 100%; white-space: normal; justify-content: flex-start; padding-top: 8px; margin-top: 4px; border-top: 1px solid #eef3ef; }
  table.cards td.row-actions .actions { width: 100%; flex-wrap: wrap; justify-content: stretch; }
  table.cards td.row-actions .actions > * { flex: 1; }
  table.cards td.row-actions .actions > a { text-align: center; border-radius: 10px; background: #e4efe8; color: var(--ink); font-weight: 700; text-decoration: none; }
  table.cards td.row-actions .actions button { width: 100%; }
  table.cards td.hide-mobile { display: none; }
  table.cards tfoot { display: block; }
  table.cards tfoot tr { background: #f6faf7; }
  table.cards td:empty { display: none; }
  table.cards td .commission-form { width: 100%; justify-content: flex-end; }
}

/* ---------- Printing (kept last so it beats the phone rules: A4's printable width is < 720px) ---------- */
@page { size: auto; margin: 10mm; }
@media print {
  html, body, :root { background: #fff !important; min-height: 0 !important; height: auto !important; }
  header.top, .bottom-nav, .cart-bar, .no-print, .notice, .toast, .sheet-backdrop, .scanner { display: none !important; }
  main, .invoice { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .card { border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
  .receipt { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
