/* ============================================================
   TEMPLE GOLD — Putisi Cashier's visual system, aligned to the
   Temple Gold reference (reverse-engineered from the HK Gala 2026
   check-in admin, now the shared default theme). Fonts load from
   Google Fonts per the reference rather than being self-hosted.
   Four typefaces, four jobs, never mixed within a job:
     --font-tc      primary voice — headings, nav labels, item/receipt
                    prose, any text a customer or staff member reads
     --font-sans    form inputs only (the Latin workhorse)
     --font-mono    system chrome — buttons, pills, table headers,
                    sortable-column labels, field labels
     --font-display reserved for exactly one hero number per screen
                    (the cart running total, the receipt total)
   ============================================================ */

:root {
  /* paper / surface — warm parchment ground */
  --paper: #F3EAD8;
  --paper-2: #EADFC8;
  --paper-3: #E2D4B8;
  --card: #FBF6EC;
  --card-2: #F6EEDD;

  /* ink (text) */
  --ink: #3B2A18;
  --ink-2: #5C4630;
  --ink-soft: #8A7355;
  --ink-faint: #A8916F;

  /* gold — primary accent */
  --gold: #B58A3C;
  --gold-deep: #94702C;
  --gold-pale: #D8BE86;

  /* cinnabar — seal & alert accent */
  --cinnabar: #9E2B23;
  --cinnabar-deep: #7E211B;

  /* jade — quiet tertiary (category identity, not status) */
  --jade: #6E8C7B;
  --jade-pale: #A9C2B2;

  --line: #D7C6A6;
  --line-soft: #E3D6BB;
  --line-strong: #C2AC83;

  /* status pill system — shared by every pill in the app */
  --ok: #5E7E5A; --ok-bg: #E7EDDD; --ok-text: #3f5a3b; --ok-border: #c4d3b4;
  --hold: #B07C2E; --hold-bg: #F3E6CB; --hold-text: #7c5618; --hold-border: #e0c891;
  --pend: #8A7355; --pend-bg: #EAE0CB; --pend-text: #6b573a; --pend-border: #d6c4a0;
  --no: #9E5A4E; --no-bg: #F0DFD6; --no-text: #7c4338; --no-border: #dcc0b6;
  --amber-bg: #f4e2c0; --amber-text: #8c5b14; --amber-border: #d9b877; --amber-dot: #8c5b14;

  --bloom-1: rgba(255, 250, 236, .95);
  --bloom-2: rgba(216, 190, 134, .30);

  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-sm: 0 2px 8px rgba(93, 66, 33, .08);
  --shadow: 0 12px 34px rgba(93, 66, 33, .14);
  --shadow-lg: 0 24px 60px rgba(80, 54, 22, .20);

  --measure: 46rem;

  --font-tc: "Noto Serif TC", "Cormorant Garamond", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Noto Serif TC", ui-monospace, monospace;
  --font-display: "Cormorant Garamond", Georgia, serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #211A12;
    --paper-2: #1A140D;
    --paper-3: #150F09;
    --card: #2A2117;
    --card-2: #241C13;
    --ink: #ECE1CE;
    --ink-2: #CDBFA5;
    --ink-soft: #A08A6C;
    --ink-faint: #7C6A50;
    --gold: #C9A44A;
    --gold-deep: #B8954A;
    --gold-pale: #6B5A34;
    --cinnabar: #D2776A;
    --cinnabar-deep: #A8463A;
    --jade: #8FB09E;
    --jade-pale: #3E5548;
    --line: #4A3D2A;
    --line-soft: #382D1F;
    --line-strong: #5C4B32;
    --ok: #8FB08A; --ok-bg: #2C3628; --ok-text: #B9D3B2; --ok-border: #445238;
    --hold: #D3A85E; --hold-bg: #3A2E17; --hold-text: #E4C083; --hold-border: #5A461F;
    --pend: #B4A17E; --pend-bg: #332B1C; --pend-text: #D3C29E; --pend-border: #4C3F28;
    --no: #D08A7C; --no-bg: #3A231E; --no-text: #E3AA9C; --no-border: #5A362E;
    --amber-bg: #3D2E11; --amber-text: #E0B45E; --amber-border: #5C441C; --amber-dot: #E0B45E;
    --bloom-1: transparent;
    --bloom-2: transparent;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --shadow: 0 12px 34px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #211A12;
  --paper-2: #1A140D;
  --paper-3: #150F09;
  --card: #2A2117;
  --card-2: #241C13;
  --ink: #ECE1CE;
  --ink-2: #CDBFA5;
  --ink-soft: #A08A6C;
  --ink-faint: #7C6A50;
  --gold: #C9A44A;
  --gold-deep: #B8954A;
  --gold-pale: #6B5A34;
  --cinnabar: #D2776A;
  --cinnabar-deep: #A8463A;
  --jade: #8FB09E;
  --jade-pale: #3E5548;
  --line: #4A3D2A;
  --line-soft: #382D1F;
  --line-strong: #5C4B32;
  --ok: #8FB08A; --ok-bg: #2C3628; --ok-text: #B9D3B2; --ok-border: #445238;
  --hold: #D3A85E; --hold-bg: #3A2E17; --hold-text: #E4C083; --hold-border: #5A461F;
  --pend: #B4A17E; --pend-bg: #332B1C; --pend-text: #D3C29E; --pend-border: #4C3F28;
  --no: #D08A7C; --no-bg: #3A231E; --no-text: #E3AA9C; --no-border: #5A362E;
  --amber-bg: #3D2E11; --amber-text: #E0B45E; --amber-border: #5C441C; --amber-dot: #E0B45E;
  --bloom-1: transparent;
  --bloom-2: transparent;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  --shadow: 0 12px 34px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background:
    radial-gradient(120% 90% at 92% 4%, var(--bloom-1), transparent 46%),
    radial-gradient(80% 70% at 88% 30%, var(--bloom-2), transparent 55%),
    linear-gradient(150deg, var(--paper) 0%, var(--paper-2) 60%, var(--paper-3) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-tc), var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img { max-width: 100%; }

h1, h2, h3 { line-height: 1.15; color: var(--ink); font-family: var(--font-tc); }
h1 {
  font-weight: 700;
  letter-spacing: -.01em;
  font-size: clamp(1.9rem, 3.2vw, 2.6rem);
  margin: .2em 0 .5em;
}
h2 {
  font-weight: 700;
  font-size: 1.4rem;
  margin: 2rem 0 .3rem;
}
h2::after {
  content: "";
  display: block;
  width: 3rem;
  height: 2px;
  background: var(--gold);
  margin-top: .4rem;
}
h3 {
  font-weight: 500;
  font-size: 1.15rem;
  color: var(--ink-2);
  margin: 1.4rem 0 .2rem;
}

a { color: var(--gold-deep); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link { position: absolute; left: -9999px; z-index: 10; }
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--card);
  padding: .5rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* ---- header / nav ----
   Mobile-first: collapsed to a hamburger toggle by default. At >=720px the
   toggle disappears and the menu sits inline with the brand. */
nav {
  background: var(--paper-2);
  border-bottom: 1px solid var(--gold-pale);
  padding: .85rem 1.25rem;
  display: flex;
  flex-direction: column;
}
.nav__bar {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.nav__toggle {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .5rem .9rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}
.nav__toggle:hover { border-color: var(--gold); color: var(--ink); }
.nav__toggle-icon { font-size: 1rem; line-height: 1; }
.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
}
.nav__logo {
  display: block;
  flex: none;
  height: 26px;
  width: calc(26px * 4.04);
  background: var(--ink);
  -webkit-mask: url("/images/logo-lockup.png") no-repeat left center / contain;
  mask: url("/images/logo-lockup.png") no-repeat left center / contain;
}
.nav__name {
  font-family: var(--font-tc);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  white-space: nowrap;
}
.nav__menu {
  display: flex;
  flex-direction: column;
  margin-top: .9rem;
  padding: .3rem 1rem .9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.nav__menu[hidden] { display: none; }
.nav__menu a {
  color: var(--ink-2);
  text-decoration: none;
  font-family: var(--font-tc);
  font-size: .95rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.nav__menu a:hover { color: var(--ink); }
.nav__account {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .6rem;
  margin-top: .9rem;
  font-family: var(--font-tc);
  font-size: .85rem;
  color: var(--ink-soft);
}

@media (min-width: 720px) {
  nav { flex-direction: row; align-items: center; gap: 1.25rem; }
  .nav__bar { display: contents; }
  .nav__toggle { display: none; }
  .nav__menu[hidden] { display: flex; }
  .nav__menu {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }
  .nav__menu a {
    padding: 0;
    border-bottom: 1px solid transparent;
    letter-spacing: .01em;
  }
  .nav__menu a:hover { border-bottom-color: var(--gold); }
  .nav__account {
    flex-direction: row;
    align-items: center;
    gap: .6rem;
    margin-top: 0;
    margin-left: auto;
  }
}

/* ---- layout ---- */
main { max-width: var(--measure); margin: 0 auto; padding: 2rem 1.25rem 4rem; }

.admin-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 2rem 1.25rem 4rem;
}
.admin-layout main {
  max-width: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 0;
}
.admin-sidebar {
  flex: none;
  width: 10.5rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  position: sticky;
  top: 1.5rem;
}
.admin-sidebar__link {
  padding: .55rem .7rem;
  border-radius: var(--r);
  border: 1px solid transparent;
  color: var(--ink-2);
  font-family: var(--font-tc);
  font-size: .92rem;
  text-decoration: none;
}
.admin-sidebar__link:hover { background: var(--card-2); color: var(--ink); }
.admin-sidebar__link--active {
  background: var(--card);
  border-color: var(--gold);
  color: var(--ink);
  font-weight: 600;
}
.auth-page {
  max-width: 22rem;
  margin: 4.5rem auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
}
.auth-page h1 { text-align: center; margin-bottom: 1.25rem; }

/* ---- forms ---- */
label {
  display: block;
  margin-bottom: 1.1rem;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
input, select, textarea {
  width: 100%;
  padding: .6rem .8rem;
  margin-top: .4rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); background: #fffef9; box-shadow: 0 0 0 2px rgba(181,138,60,.18); }
textarea { min-height: 5rem; resize: vertical; }

/* Pill buttons with a gold gradient. Every button label is JetBrains Mono,
   even CJK ones — falls back to the serif stack automatically for glyphs
   it doesn't have. */
button {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .06em;
  padding: .7rem 1.6rem;
  cursor: pointer;
  background: linear-gradient(150deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #fff;
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: filter .15s;
}
button:hover { filter: brightness(1.06); }
.nav__account button {
  background: transparent;
  color: var(--ink-2);
  border: 1.5px solid var(--line-strong);
  box-shadow: none;
  filter: none;
}
.nav__account button:hover { color: var(--ink); border-color: var(--gold-deep); background: transparent; filter: none; }

/* ---- tables ---- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; background: var(--card); border-radius: var(--r); overflow: hidden; }
th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold-deep);
  text-align: left;
  padding: .6rem .8rem;
  border-bottom: 2px solid var(--gold-pale);
}
td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line-soft); font-family: var(--font-tc); }
tfoot td { font-weight: 700; font-family: var(--font-mono); border-bottom: none; border-top: 2px solid var(--gold-pale); }
tr:last-child td { border-bottom: none; }

/* ---- messages ---- */
.error { color: var(--cinnabar-deep); font-family: var(--font-tc); font-size: .92rem; }
.success { color: var(--ok-text); font-family: var(--font-tc); font-size: .92rem; }

/* ---- primary call-to-action buttons (admin section links) ---- */
.dashboard-actions { display: flex; flex-wrap: wrap; gap: .85rem; margin: 1.5rem 0; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 12rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .06em;
  padding: .9rem 1.6rem;
  cursor: pointer;
  background: linear-gradient(150deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #fff;
  border: 1px solid var(--gold-deep);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.06); color: #fff; }

/* ---- status pills — the shared 5-state system ----
   ok (cleared / active), hold (deprecated alias, kept for gradient
   continuity), pending (cheque pending), no (voided / inactive / declined),
   amber (caution — low stock). Category-identity pills below are a
   separate, non-semantic set. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .03em;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--gold-deep);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--gold-deep); }
.pill--ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.pill--ok::before { background: var(--ok); }
.pill--warn { background: var(--no-bg); color: var(--no-text); border-color: var(--no-border); }
.pill--warn::before { background: var(--no); }
.pill--pending { background: var(--pend-bg); color: var(--pend-text); border-color: var(--pend-border); }
.pill--pending::before { background: var(--pend); }
.pill--amber { background: var(--amber-bg); color: var(--amber-text); border-color: var(--amber-border); }
.pill--amber::before { background: var(--amber-dot); }
.pill--neutral { color: var(--ink); background: var(--paper-2); border-color: var(--line); }
.pill--neutral::before { background: var(--ink-soft); }

/* Category identity pills (admin Items table) — decorative, not status;
   assigned by a category's position (0-3) among the temple's categories,
   not by name, since the catalog is admin-editable. A 5th+ category falls
   back to .pill--neutral rather than inventing a 5th hue. Slot 1 ties
   directly to the jade token now that Temple Gold introduces it as this
   app's quiet tertiary. */
.pill--cat-0 { color: var(--ink); background: #F3E3D2; border-color: #C67A3E; }
.pill--cat-0::before { background: #C67A3E; }
.pill--cat-1 { color: var(--ink); background: var(--jade-pale); border-color: var(--jade); }
.pill--cat-1::before { background: var(--jade); }
.pill--cat-2 { color: var(--ink); background: #E3E0F0; border-color: #5B4FA8; }
.pill--cat-2::before { background: #5B4FA8; }
.pill--cat-3 { color: var(--ink); background: #F3DDE7; border-color: #C24A82; }
.pill--cat-3::before { background: #C24A82; }

/* ---- sortable table headers (admin Items) ---- */
th.sortable a {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  color: inherit;
  text-decoration: none;
}
th.sortable a:hover { color: var(--ink); }
th.sortable .sort-arrow { font-size: .7em; opacity: .7; }

/* ---- counter / sale screen ---- */
.sale-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: none;
  padding: 1.5rem 1.25rem 6rem;
}
.sale-catalog { flex: 1; min-width: 0; }

.category-tabs {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}
.category-tab {
  flex: none;
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .02em;
  padding: .5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}
.category-tab:hover { border-color: var(--gold); color: var(--ink); }
.category-tab--active {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: #fff;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 1rem;
}
@media (max-width: 480px) {
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .65rem; }
}
.item-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
@media (max-width: 480px) {
  .item-tile { padding: .8rem; }
  .item-tile button { min-height: 2.6rem; }
}
.item-tile--disabled { opacity: .55; }
.item-tile__name-en { font-family: var(--font-tc); font-size: 1.05rem; color: var(--ink); }
.item-tile__name-zh { font-family: var(--font-tc); font-size: .9rem; color: var(--ink-soft); }
.item-tile__price { font-family: var(--font-mono); font-size: .95rem; color: var(--gold-deep); }
.item-tile form { margin-top: auto; }
.item-tile__amount-form { display: flex; gap: .4rem; }
.item-tile__amount-form input { padding: .5rem .6rem; margin-top: 0; }
.item-tile button { width: 100%; padding: .5rem; }

/* Desktop-only sidebar cart — hidden on mobile, where the compact
   .cart-fab icon + a dedicated /sale/cart page replace it entirely. */
.cart-panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.cart-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  font-family: var(--font-mono);
  font-weight: 600;
  border-bottom: 1px solid var(--line-soft);
}
.cart-panel__total { color: var(--gold-deep); font-weight: 700; }
.cart-body { padding: 1.1rem 1.25rem 1.35rem; }

/* ---- mobile cart icon (floating, links to /sale/cart) ---- */
.cart-fab {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  background: linear-gradient(150deg, var(--gold) 0%, var(--gold-deep) 100%);
  border: 1px solid var(--gold-deep);
  box-shadow: var(--shadow);
  color: #fff;
}
.cart-fab__icon { width: 1.5rem; height: 1.5rem; }
.cart-fab__badge {
  position: absolute;
  top: -.3rem;
  right: -.3rem;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 .3rem;
  border-radius: 999px;
  background: var(--cinnabar);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--paper);
}

/* ---- dedicated mobile cart page (/sale/cart) ---- */
.cart-page { max-width: 32rem; }
.cart-page__header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .3rem;
  margin-bottom: .5rem;
}
.cart-page__back { font-family: var(--font-tc); font-size: .85rem; color: var(--ink-soft); text-decoration: none; }
.cart-page__back:hover { color: var(--ink); }
.cart-page h1 { margin: 0; }

.cart-empty { text-align: center; padding: 1.75rem 1rem 1rem; color: var(--ink-soft); }
.cart-empty p { margin: 0 0 .3rem; }
.cart-empty__hint { font-size: .85rem; }

.cart-lines { list-style: none; padding: 0; margin: 0; }
.cart-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem .75rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.cart-line:last-child { border-bottom: none; }

.cart-line__info { flex: 1 1 100%; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.cart-line__name {
  font-family: var(--font-tc);
  font-size: 1.02rem;
  line-height: 1.25;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: normal;
}
.cart-line__unit { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-soft); letter-spacing: .01em; }
.cart-line__total { font-family: var(--font-mono); font-weight: 600; font-size: .92rem; color: var(--ink-2); white-space: nowrap; flex: none; margin-left: auto; }

.cart-line__qty { display: flex; align-items: center; gap: .4rem; flex: none; }
.cart-line__qty form { display: contents; }
.cart-line__qty-form { display: contents; }
.cart-line__step {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  cursor: pointer;
  flex: none;
}
.cart-line__step:hover { border-color: var(--gold); color: var(--ink); background: var(--paper-2); filter: none; }
.cart-line__step--minus:hover { border-color: var(--cinnabar); color: var(--cinnabar-deep); }
.cart-line__step:disabled {
  opacity: .3;
  cursor: not-allowed;
  pointer-events: none;
}
.cart-line__qty-num {
  width: 2.4rem;
  height: 1.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .88rem;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .4rem;
  padding: 0;
  flex: none;
  -moz-appearance: textfield;
}
.cart-line__qty-num:focus { outline: none; border-color: var(--gold); }
.cart-line__qty-num::-webkit-outer-spin-button,
.cart-line__qty-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cart-summary-block { margin-top: .5rem; padding-top: 1rem; border-top: 1px solid var(--gold-pale); }
.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
}
.cart-total__label { font-family: var(--font-mono); font-weight: 600; font-size: .78rem; letter-spacing: .04em; color: var(--ink-2); }
.cart-total__amount { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--gold-deep); white-space: nowrap; }
.cart-panel .btn-primary { display: block; width: 100%; text-align: center; }

@media (min-width: 900px) {
  .sale-layout { flex-direction: row; align-items: flex-start; padding-bottom: 2rem; }
  .cart-panel {
    display: block;
    position: sticky;
    top: 1.5rem;
    flex: none;
    width: 21.5rem;
    border-radius: var(--r-lg);
  }
  .cart-fab { display: none; }
}

/* ---- checkout ---- */
.checkout-page { max-width: 32rem; }
.payment-tiles { display: flex; flex-wrap: wrap; gap: .85rem; margin: 1.25rem 0; }
.payment-tile {
  position: relative;
  flex: 1 1 9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  font-family: var(--font-tc);
  font-size: .95rem;
  cursor: pointer;
}
.payment-tile input { position: absolute; opacity: 0; pointer-events: none; }
.payment-tile:has(input:checked) {
  border-color: var(--gold-deep);
  background: var(--gold-pale);
  color: var(--ink);
}
.checkout-cash-note { font-family: var(--font-tc); font-size: .9rem; color: var(--ink-soft); margin: 0 0 1rem; }
.cart-page__back.checkout-back { display: inline-block; margin-bottom: .75rem; }

/* ---- confirmation / receipt ----
   Deliberately narrower and bounded than the rest of the site: this is the
   one screen that doubles as a printed paper slip, so it reads as a ticket
   with an edge rather than a webpage section. One dominant number (the
   total, in the display face); everything else — letterhead, ids,
   metadata — stays quiet and compact so it doesn't compete. */
.confirmation-page { max-width: 30rem; }
.receipt-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 1.85rem 1.6rem 1.6rem;
  max-width: 23rem;
  margin: 0 auto;
}

.receipt-letterhead { text-align: center; margin-bottom: 1.25rem; }
.receipt-logo { height: 32px; width: auto; margin-bottom: .55rem; }
.receipt-org { font-family: var(--font-tc); font-weight: 600; font-size: 1.15rem; letter-spacing: .02em; color: var(--ink); margin: 0 0 .3rem; }
.receipt-address { font-family: var(--font-tc); font-size: .72rem; color: var(--ink-soft); margin: 0; line-height: 1.5; }

.receipt-void-banner {
  background: var(--no-bg);
  border: 1px solid var(--no-border);
  border-radius: var(--r);
  padding: .8rem .95rem;
  margin-bottom: 1.15rem;
}
.receipt-void-banner__title { margin: 0 0 .25rem; font-family: var(--font-mono); font-weight: 700; letter-spacing: .03em; font-size: .8rem; text-transform: uppercase; color: var(--no-text); }
.receipt-void-banner__detail { margin: 0; font-family: var(--font-tc); font-size: .8rem; color: var(--ink-2); line-height: 1.5; }

.receipt-id { text-align: center; margin: 0 0 1rem; }
.receipt-number { font-family: var(--font-mono); font-weight: 700; font-size: 1.02rem; letter-spacing: .01em; color: var(--gold-deep); }

.receipt-meta { margin: 0 0 1.1rem; }
.receipt-meta__row { display: flex; justify-content: space-between; gap: 1rem; padding: .22rem 0; }
.receipt-meta__row dt { font-family: var(--font-tc); font-size: .8rem; color: var(--ink-soft); margin: 0; }
.receipt-meta__row dd { font-family: var(--font-tc); font-size: .8rem; color: var(--ink); margin: 0; text-align: right; }

.receipt-divider { border: none; border-top: 1px solid var(--line-soft); margin: 1rem 0; }
.receipt-divider--dashed { border-top-style: dashed; border-top-color: var(--gold-pale); }

.receipt-items { list-style: none; margin: 0; padding: 0; }
.receipt-item { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--line-soft); }
.receipt-item:last-child { border-bottom: none; }
.receipt-item__desc { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.receipt-item__name { font-family: var(--font-tc); font-size: 1rem; color: var(--ink); }
.receipt-item__name-zh { font-family: var(--font-tc); font-size: .78rem; color: var(--ink-soft); }
.receipt-item__amount { font-family: var(--font-mono); font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; flex: none; }

.receipt-total { display: flex; justify-content: space-between; align-items: baseline; }
.receipt-total__label { font-family: var(--font-mono); font-weight: 600; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.receipt-total__amount { font-family: var(--font-display); font-weight: 700; font-size: 2rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--gold-deep); }
.receipt-rounded-note { margin: .3rem 0 0; text-align: right; font-family: var(--font-tc); font-style: italic; font-size: .76rem; color: var(--ink-soft); }

.receipt-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem auto 0; max-width: 23rem; }
.receipt-actions button, .receipt-actions .btn-primary { flex: 1 1 9rem; margin: 0; }
.receipt-void-link { text-align: center; margin: .9rem auto 0; max-width: 23rem; font-family: var(--font-tc); font-size: .85rem; }

/* ---- print ---- */
@media print {
  nav, .skip-link, .print-hide {
    display: none !important;
  }
  body { background: none; }
  main.confirmation-page { padding: 0; max-width: 100%; }
  .receipt-card { box-shadow: none; border: none; border-radius: 0; max-width: 100%; padding: 0; margin: 0; }
  .card { box-shadow: none; }
  .table-scroll { overflow-x: visible; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  main.reports-page { max-width: 100%; padding: .5rem .75rem; font-size: .82rem; }
  .reports-page .card { padding: .6rem .8rem; margin-top: .6rem; }
  .report-item-block { break-inside: avoid; }
  .reports-page h1 { font-size: 1.3rem; margin: 0 0 .1rem; }
  .reports-page h2 { font-size: 1rem; margin: 0 0 .3rem; }
  .reports-page h2::after { display: none; }
  .reports-page h3 { font-size: .82rem; font-style: normal; margin: .5rem 0 0; }
  .reports-page table { margin-top: .2rem; }
  .reports-page th, .reports-page td { padding: .2rem .4rem; font-size: .74rem; }
  .reports-page tfoot td { font-weight: 700; border-top: 1.5px solid var(--ink-soft); }
  .report-category-subtotal { margin-top: .4rem; font-weight: 700; }
}

/* ---- void ---- */
.sale-void-action { margin-top: 1.5rem; }
.sale-void-action summary {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-tc);
  font-size: .88rem;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
}
.sale-void-action summary:hover { color: var(--cinnabar-deep); }
.sale-void-action summary::-webkit-details-marker { display: none; }
.sale-void-action summary::before {
  content: "▸";
  font-size: .75em;
  color: var(--ink-soft);
}
.sale-void-action[open] summary::before { content: "▾"; }
.sale-void-action form { margin-top: .75rem; }

/* ---- card component ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin-top: 0; }

.stock-delta--up { color: var(--ok-text); font-weight: 600; font-family: var(--font-mono); }
.stock-delta--down { color: var(--cinnabar-deep); font-weight: 600; font-family: var(--font-mono); }

.report-date-label { font-family: var(--font-mono); font-size: .85rem; color: var(--ink-soft); margin: 0 0 1rem; }
.report-item-name-zh { font-family: var(--font-tc); font-size: .85rem; color: var(--ink-soft); font-weight: 400; }
.report-category-subtotal { margin-top: .75rem; padding-top: .5rem; border-top: 1px solid var(--gold-pale); font-family: var(--font-mono); font-weight: 700; text-align: right; }
