/* =====================================================================
   Vendored: normalize.css v8.0.1 (below, verbatim) — MIT License
   Copyright (c) Nicolas Gallagher and Jonathan Neal
   https://github.com/necolas/normalize.css — a small, reputable CSS
   normalize used so form controls and text sizing behave the same on
   iPhone Safari, Android Chrome and iPad. App styles follow after it.
   ===================================================================== */
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */

/* Document
   ========================================================================== */

/**
 * 1. Correct the line height in all browsers.
 * 2. Prevent adjustments of font size after orientation changes in iOS.
 */

html {
  line-height: 1.15; /* 1 */
  -webkit-text-size-adjust: 100%; /* 2 */
}

/* Sections
   ========================================================================== */

/**
 * Remove the margin in all browsers.
 */

body {
  margin: 0;
}

/**
 * Render the `main` element consistently in IE.
 */

main {
  display: block;
}

/**
 * Correct the font size and margin on `h1` elements within `section` and
 * `article` contexts in Chrome, Firefox, and Safari.
 */

h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

/* Grouping content
   ========================================================================== */

/**
 * 1. Add the correct box sizing in Firefox.
 * 2. Show the overflow in Edge and IE.
 */

hr {
  box-sizing: content-box; /* 1 */
  height: 0; /* 1 */
  overflow: visible; /* 2 */
}

/**
 * 1. Correct the inheritance and scaling of font size in all browsers.
 * 2. Correct the odd `em` font sizing in all browsers.
 */

pre {
  font-family: monospace, monospace; /* 1 */
  font-size: 1em; /* 2 */
}

/* Text-level semantics
   ========================================================================== */

/**
 * Remove the gray background on active links in IE 10.
 */

a {
  background-color: transparent;
}

/**
 * 1. Remove the bottom border in Chrome 57-
 * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
 */

abbr[title] {
  border-bottom: none; /* 1 */
  text-decoration: underline; /* 2 */
  text-decoration: underline dotted; /* 2 */
}

/**
 * Add the correct font weight in Chrome, Edge, and Safari.
 */

b,
strong {
  font-weight: bolder;
}

/**
 * 1. Correct the inheritance and scaling of font size in all browsers.
 * 2. Correct the odd `em` font sizing in all browsers.
 */

code,
kbd,
samp {
  font-family: monospace, monospace; /* 1 */
  font-size: 1em; /* 2 */
}

/**
 * Add the correct font size in all browsers.
 */

small {
  font-size: 80%;
}

/**
 * Prevent `sub` and `sup` elements from affecting the line height in
 * all browsers.
 */

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

/* Embedded content
   ========================================================================== */

/**
 * Remove the border on images inside links in IE 10.
 */

img {
  border-style: none;
}

/* Forms
   ========================================================================== */

/**
 * 1. Change the font styles in all browsers.
 * 2. Remove the margin in Firefox and Safari.
 */

button,
input,
optgroup,
select,
textarea {
  font-family: inherit; /* 1 */
  font-size: 100%; /* 1 */
  line-height: 1.15; /* 1 */
  margin: 0; /* 2 */
}

/**
 * Show the overflow in IE.
 * 1. Show the overflow in Edge.
 */

button,
input { /* 1 */
  overflow: visible;
}

/**
 * Remove the inheritance of text transform in Edge, Firefox, and IE.
 * 1. Remove the inheritance of text transform in Firefox.
 */

button,
select { /* 1 */
  text-transform: none;
}

/**
 * Correct the inability to style clickable types in iOS and Safari.
 */

button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}

/**
 * Remove the inner border and padding in Firefox.
 */

button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

/**
 * Restore the focus styles unset by the previous rule.
 */

button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
  outline: 1px dotted ButtonText;
}

/**
 * Correct the padding in Firefox.
 */

fieldset {
  padding: 0.35em 0.75em 0.625em;
}

/**
 * 1. Correct the text wrapping in Edge and IE.
 * 2. Correct the color inheritance from `fieldset` elements in IE.
 * 3. Remove the padding so developers are not caught out when they zero out
 *    `fieldset` elements in all browsers.
 */

legend {
  box-sizing: border-box; /* 1 */
  color: inherit; /* 2 */
  display: table; /* 1 */
  max-width: 100%; /* 1 */
  padding: 0; /* 3 */
  white-space: normal; /* 1 */
}

/**
 * Add the correct vertical alignment in Chrome, Firefox, and Opera.
 */

progress {
  vertical-align: baseline;
}

/**
 * Remove the default vertical scrollbar in IE 10+.
 */

textarea {
  overflow: auto;
}

/**
 * 1. Add the correct box sizing in IE 10.
 * 2. Remove the padding in IE 10.
 */

[type="checkbox"],
[type="radio"] {
  box-sizing: border-box; /* 1 */
  padding: 0; /* 2 */
}

/**
 * Correct the cursor style of increment and decrement buttons in Chrome.
 */

[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

/**
 * 1. Correct the odd appearance in Chrome and Safari.
 * 2. Correct the outline style in Safari.
 */

[type="search"] {
  -webkit-appearance: textfield; /* 1 */
  outline-offset: -2px; /* 2 */
}

/**
 * Remove the inner padding in Chrome and Safari on macOS.
 */

[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

/**
 * 1. Correct the inability to style clickable types in iOS and Safari.
 * 2. Change font properties to `inherit` in Safari.
 */

::-webkit-file-upload-button {
  -webkit-appearance: button; /* 1 */
  font: inherit; /* 2 */
}

/* Interactive
   ========================================================================== */

/*
 * Add the correct display in Edge, IE 10+, and Firefox.
 */

details {
  display: block;
}

/*
 * Add the correct display in all browsers.
 */

summary {
  display: list-item;
}

/* Misc
   ========================================================================== */

/**
 * Add the correct display in IE 10+.
 */

template {
  display: none;
}

/**
 * Add the correct display in IE 10.
 */

[hidden] {
  display: none;
}

/* =====================================================================
   KK Bobabite POS — app styles (normalize.css above is vendored,
   MIT License, github.com/necolas/normalize.css — see top of file).

   Themes: the saved per-account preference is White / Black /
   Brown / Auto (Auto follows the device light/dark setting and
   resolves to White or Black only — Brown is a manual choice);
   <html data-theme> always holds the EFFECTIVE theme
   ("white"|"black"|"brown") resolved by app.js. All colours go
   through the variables below so every effective theme covers
   every view.

   Layout: iPad landscape = menu + cart side by side. Phones = stacked,
   one-hand use, >=48px touch targets, no sideways page scroll.
   ===================================================================== */

:root {
  /* safe-area insets (iPhone notch / home indicator, Android gesture bar) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  /* White theme (light) */
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #e7e5e4;
  --text: #1f2937;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #b91c1c;
  --accent-bg: #b91c1c;
  --on-accent: #ffffff;
  --gold: #b91c1c;
  --accent-soft-bg: #fef2f2;
  --accent-soft-border: #fecaca;
  --danger: #dc2626;
  --danger-bg: #dc2626;
  --danger-soft-bg: #fef2f2;
  --danger-soft-border: #fecaca;
  --success: #15803d;
  --success-bg: #16a34a;
  --success-soft-bg: #f0fdf4;
  --cart-bg: #fffbeb;
  --cart-border: #fde68a;
  --closing-bg: linear-gradient(135deg, #fef2f2, #fffbeb);
  --closing-border: #fecaca;
  --chip-blue-bg: #eff6ff;
  --chip-blue-text: #1d4ed8;
  --chip-blue-border: #bfdbfe;
  --warn-bg: #f59e0b;
  --warn-text: #111827;
  --info-bg: #1d4ed8;
  --overlay: rgba(17, 24, 39, .55);
  --shadow: 0 8px 30px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .25);
  --track-off: #d1d5db;
  --grab-bg: #dcfce7;
  --grab-text: #166534;
  --panda-bg: #fce7f3;
  --panda-text: #9d174d;
  --tag-bg: #e5e7eb;
  --owner-tag-bg: #fef3c7;
  --owner-tag-text: #92400e;
  --input-bg: #ffffff;
  --toast-bg: #111827;
  --toast-text: #ffffff;
  --badge-bg: #111827;
  --badge-text: #ffffff;
  --failed-bg: #fef2f2;
  --failed-border: #fecaca;
  --failed-text: #991b1b;
}

html[data-theme="black"] {
  /* Black theme (dark) */
  --bg: #0b0f14;
  --surface: #161c24;
  --surface-2: #1d242e;
  --surface-3: #232b36;
  --text: #f3f4f6;
  --text-2: #d1d5db;
  --muted: #9ca3af;
  --faint: #6b7280;
  --border: #2b3442;
  --border-strong: #3a4556;
  --accent: #f87171;
  --accent-bg: #b91c1c;
  --on-accent: #ffffff;
  --gold: #f87171;
  --accent-soft-bg: #2a1618;
  --accent-soft-border: #5b2326;
  --danger: #f87171;
  --danger-bg: #dc2626;
  --danger-soft-bg: #2a1618;
  --danger-soft-border: #5b2326;
  --success: #4ade80;
  --success-bg: #22c55e;
  --success-soft-bg: #12271a;
  --cart-bg: #26200f;
  --cart-border: #57481a;
  --closing-bg: linear-gradient(135deg, #2a1618, #26200f);
  --closing-border: #5b2326;
  --chip-blue-bg: #12233f;
  --chip-blue-text: #93c5fd;
  --chip-blue-border: #1e3a5f;
  --warn-bg: #f59e0b;
  --warn-text: #111827;
  --info-bg: #2563eb;
  --overlay: rgba(0, 0, 0, .7);
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .6);
  --track-off: #3a4556;
  --grab-bg: #14532d;
  --grab-text: #bbf7d0;
  --panda-bg: #500f2e;
  --panda-text: #fbcfe8;
  --tag-bg: #2b3442;
  --owner-tag-bg: #451a03;
  --owner-tag-text: #fcd34d;
  --input-bg: #1d242e;
  --toast-bg: #f3f4f6;
  --toast-text: #111827;
  --badge-bg: #f3f4f6;
  --badge-text: #111827;
  --failed-bg: #2a1618;
  --failed-border: #5b2326;
  --failed-text: #fca5a5;
}

html[data-theme="brown"] {
  /* Brown theme (dark, warm) — the owner's screenshot palette: deep
     espresso-brown background, lighter brown cards, warm borders, a
     vivid orange accent, golden-amber prices and primary buttons,
     cream text with tan muted text. A FOURTH, manual-only theme:
     Auto never resolves to it, and the Black theme above is
     untouched. Every text/background pair here keeps >= 4.5:1
     contrast (verified in the layout probe). Receipts are NOT
     themed — they stay white paper in every theme. */
  --bg: #20140D;
  --surface: #2C1B10;
  --surface-2: #36220E;
  --surface-3: #402A12;
  --text: #F5EDE4;
  --text-2: #E3D5C2;
  --muted: #B8A48E;
  --faint: #9C8468;
  --border: #4A3220;
  --border-strong: #6B4A2C;
  --accent: #F2762E;
  --accent-bg: #E8A33D;
  --on-accent: #20140D;
  --gold: #E8A33D;
  --accent-soft-bg: #3A2110;
  --accent-soft-border: #6B4A2C;
  --danger: #F87171;
  --danger-bg: #DC2626;
  --danger-soft-bg: #2E1710;
  --danger-soft-border: #63351F;
  --success: #4ADE80;
  --success-bg: #22C55E;
  --success-soft-bg: #12271A;
  --cart-bg: #33200F;
  --cart-border: #6B4A2C;
  --closing-bg: linear-gradient(135deg, #3A2110, #33200F);
  --closing-border: #6B4A2C;
  --chip-blue-bg: #38250F;
  --chip-blue-text: #E8A33D;
  --chip-blue-border: #6B4A2C;
  --warn-bg: #F59E0B;
  --warn-text: #20140D;
  --info-bg: #7C4A21;
  --overlay: rgba(20, 10, 4, .7);
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .6);
  --track-off: #4A3220;
  --grab-bg: #14532D;
  --grab-text: #BBF7D0;
  --panda-bg: #500F2E;
  --panda-text: #FBCFE8;
  --tag-bg: #38250F;
  --owner-tag-bg: #451A03;
  --owner-tag-text: #FCD34D;
  --input-bg: #26180E;
  --toast-bg: #F5EDE4;
  --toast-text: #20140D;
  --badge-bg: #F5EDE4;
  --badge-text: #20140D;
  --failed-bg: #2E1710;
  --failed-border: #63351F;
  --failed-text: #FCA5A5;
}
/* Brown only: the selected channel/payment segment takes the
   picture's brighter amber (the primary buttons and the cart bar
   keep the deeper checkout gold of --accent-bg). */
html[data-theme="brown"] .segmented button.active {
  background: #F6A21E; border-color: #F6A21E; color: #20140D;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  /* a stray pull-to-refresh mid-sale would lose the in-memory cart */
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0; }
button { font: inherit; cursor: pointer; touch-action: manipulation; color: inherit; }
input, select {
  font: inherit; font-size: 16px; /* >=16px stops iOS Safari auto-zoom on focus */
  padding: 10px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--input-bg); color: var(--text); min-height: 48px;
}
label { display: block; margin: 10px 0; }
label.inline, .inline-form label { display: inline-block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 10px 18px; min-height: 48px; font-weight: 600;
}
.btn.primary { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--on-accent); }
.btn.danger { background: var(--danger-bg); border-color: var(--danger-bg); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.big { width: 100%; font-size: 1.1rem; padding: 14px; }
.btn.small { min-height: 48px; padding: 8px 12px; }

/* banners */
.offline-banner { background: var(--warn-bg); color: var(--warn-text); padding: calc(10px + var(--sat)) 14px 10px; font-weight: 600; text-align: center; }
.queue-banner { background: var(--info-bg); color: #fff; padding: 8px 14px; text-align: center; font-weight: 600; }

/* auth */
.auth-screen { position: relative; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(20px + var(--sat)) max(20px, var(--sar)) calc(20px + var(--sab)) max(20px, var(--sal)); }
.auth-card { background: var(--surface); border-radius: 20px; padding: 28px; max-width: 430px; width: 100%; box-shadow: var(--shadow); text-align: center; }
.auth-logo { height: 116px; max-width: 92%; object-fit: contain; background: #fff; border-radius: 14px; padding: 6px; }
.auth-card h1 { margin: 8px 0 0; color: var(--accent); letter-spacing: .04em; }
.auth-sub { margin: 2px 0 18px; color: var(--muted); }
.auth-card label { text-align: left; }
.auth-card input { width: 100%; }
.login-users { display: grid; gap: 10px; margin: 14px 0; }
.login-user-btn {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 16px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface);
  font-size: 1.05rem; font-weight: 600; min-height: 56px; color: var(--text);
}
/* Coloured initial-avatar circle on each login account button; the
   colours are painted inline by app.js from its AVATAR_COLORS
   palette (name-derived, every pair >= 4.5:1). */
.login-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 800;
}
.login-user-btn .role { font-size: .8rem; color: var(--muted); font-weight: 500; margin-left: auto; }
.pin-for { font-weight: 700; font-size: 1.05rem; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 10px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--faint); }
.pin-dots span.filled { background: var(--accent-bg); border-color: var(--accent-bg); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 260px; margin: 12px auto; }
.pin-pad button { min-height: 56px; font-size: 1.3rem; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; }
.pin-pad button.small { font-size: .9rem; }

/* header + nav */
/* The header is deliberately NOT sticky/fixed (owner's call): it
   scrolls away with the page, so it can never hover over and hide
   menu items underneath it — on iPad, iPhone and Android alike. */
.app-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: calc(10px + var(--sat)) max(16px, var(--sar)) 10px max(16px, var(--sal)); background: var(--surface); border-bottom: 1px solid var(--border); }
.header-logo { height: 44px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.header-title { display: flex; flex-direction: column; min-width: 0; }
.header-title strong { color: var(--accent); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { background: var(--accent-soft-bg); color: var(--accent); border: 1px solid var(--accent-soft-border); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.sync-chip { background: var(--chip-blue-bg); color: var(--chip-blue-text); border: 1px solid var(--chip-blue-border); padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.main-nav { display: flex; gap: 6px; padding: 10px 16px 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.nav-btn { flex: 1 0 auto; min-height: 48px; border: none; border-radius: 12px 12px 0 0; background: var(--surface-3); color: var(--text); font-weight: 700; padding: 10px 14px; white-space: nowrap; }
.nav-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 -2px 8px rgba(0,0,0,.05); }
main { padding: 16px max(16px, var(--sar)) 10px max(16px, var(--sal)); max-width: 1400px; margin: 0 auto; }
.view { background: var(--surface); border-radius: 0 14px 14px 14px; padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }

/* sell */
.sell-layout { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
/* min-width:0 is load-bearing on phones: the menu column must never
   size itself to its content. The old category strip was a
   horizontal scroller whose full (scrolled) content width became
   the column's minimum — the phone browser then expanded the whole
   layout viewport to fit it and the page rendered at desktop
   width, zoomed out. iPad never noticed; iPhone/Android did. The
   category selector is a wrapping tile grid now (below), but the
   discipline stays: a grid child with min-width:auto could still
   force the column wide. */
.sell-menu { min-width: 0; }
/* Category selector: a wrapping TILE GRID, not a scrolling strip —
   the owner wants every category visible at once on the Sell
   screen, neatly arranged, with no sideways swiping on any device.
   Phones get 3 columns × 3 rows of equal tiles (long names like
   "Special Series" wrap to two lines inside their tile); wide
   screens flow into 5 columns / 2 rows (see the min-width media
   query with the other breakpoints). The 1fr tracks + min-width:0
   tiles mean the grid itself can never overflow horizontally. */
.category-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
/* Each tile carries its category colour (--cat / --cat-fill /
   --cat-on, painted inline by app.js from its CATEGORY_COLORS
   map): a coloured dot + a soft 12% tint of the colour over the
   theme surface, with a half-strength coloured border. Unselected
   tiles stay quiet — colour as identity, not a rainbow wall. The
   SELECTED tile fills with the category colour itself; its text
   colour (--cat-on) is chosen per category so contrast stays
   >= 4.5:1 in both themes (bright gold takes near-black text, the
   deep hues take white). color-mix over var(--surface) keeps the
   tint right in the White and Black themes alike. */
.category-tabs button {
  min-width: 0; min-height: 52px; padding: 8px 6px; border-radius: 14px;
  border: 2px solid color-mix(in srgb, var(--cat, #b91c1c) 50%, var(--border));
  background: color-mix(in srgb, var(--cat, #b91c1c) 12%, var(--surface));
  color: var(--text);
  font-weight: 700; font-size: .95rem; line-height: 1.2; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 7px; overflow-wrap: anywhere;
}
.category-tabs button .cat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat, var(--accent)); flex: 0 0 auto; }
/* The category icon stays SMALL on purpose (the owner's explicit
   call): a ~17px emoji inline with the dot + label — identity at a
   glance, never big artwork; the tile keeps its compact shape. */
.category-tabs button .cat-icon { font-size: 17px; line-height: 1; flex: 0 0 auto; }
.category-tabs button.active {
  background: var(--cat-fill, var(--accent-bg)); border-color: var(--cat-fill, var(--accent-bg));
  color: var(--cat-on, var(--on-accent));
}
.category-tabs button.active .cat-dot { background: var(--cat-on, var(--on-accent)); }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item-btn {
  position: relative; border: 2px solid var(--border); background: var(--surface); color: var(--text); border-radius: 14px;
  padding: 14px 10px; min-height: 96px; display: flex; flex-direction: column; gap: 6px;
  align-items: flex-start; text-align: left; font-weight: 600; overflow-wrap: anywhere;
}
.item-btn .price { color: var(--gold); font-weight: 800; }
.item-btn .price-not-set { color: var(--faint); font-weight: 600; font-size: .9rem; }
.item-btn.sold-out { opacity: .45; }
.badge-soldout { position: absolute; top: 8px; right: 8px; background: var(--badge-bg); color: var(--badge-text); font-size: .68rem; padding: 3px 8px; border-radius: 999px; letter-spacing: .05em; }

/* Desktop side panel: sticky within its own grid column (it never
   overlaps the menu), with a plain 16px offset — the old 76px top
   assumed the once-sticky header, which no longer exists. On phones
   the panel is position:static (see the phone media query). */
.cart-panel { background: var(--cart-bg); border: 1px solid var(--cart-border); border-radius: 14px; padding: 16px; position: sticky; top: 16px; min-width: 0; }
.cart-panel h2 { margin-top: 0; }
.cart-items { display: grid; gap: 8px; }
.cart-line { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.cart-line .cl-top { display: flex; justify-content: space-between; gap: 8px; }
.cart-line .cl-name { font-weight: 700; overflow-wrap: anywhere; }
.cart-line .cl-opts { color: var(--muted); font-size: .85rem; }
.cart-line .cl-controls { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.qty-stepper { display: inline-flex; align-items: center; gap: 10px; }
.qty-stepper button { width: 48px; height: 48px; min-height: 48px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 1.3rem; font-weight: 700; }
.cl-remove { margin-left: auto; color: var(--accent); background: none; border: none; font-weight: 700; min-height: 48px; padding: 6px 8px; }
/* manual platform pricing — only rendered on Grab/foodpanda channels */
.cl-price-edit {
  min-height: 48px; padding: 6px 12px; border-radius: 10px; font-weight: 700;
  background: var(--accent-soft-bg); color: var(--accent);
  border: 1px dashed var(--accent-soft-border); white-space: nowrap;
}
.platform-badge {
  background: var(--chip-blue-bg); color: var(--chip-blue-text);
  border: 1px solid var(--chip-blue-border); font-size: .72rem; font-weight: 800;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.price-hint { color: var(--muted); font-size: .9rem; margin: -6px 0 10px; }
#price-modal label input { width: 100%; }
.field { margin: 14px 0; }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; }
.segmented { display: flex; gap: 6px; }
.segmented button { flex: 1; min-height: 48px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; padding: 8px 4px; }
.segmented button.active { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--on-accent); }
/* Compact variant — used ONLY by the Settings → Appearance theme
   selector: a rarely-touched settings control, so it is deliberately
   smaller than the selling-screen segmented controls (which stay at
   the full 48px). Reduced height/padding, smaller text, narrower
   group; still a comfortable 40px tap target. */
.segmented.compact { gap: 4px; max-width: 340px; }
.segmented.compact button { min-height: 40px; padding: 4px 8px; font-size: .85rem; font-weight: 600; border-width: 1px; border-radius: 8px; }
/* Colour-coded checkout buttons (owner's picks — ONLY these three;
   every other channel/payment button keeps the accent styling):
   Cash = white, KBZPay = KBZ blue, foodpanda = its brand pink
   #D70F64 (the owner corrected an earlier plain red to the real
   foodpanda colour). Keyed by the buttons' data-v values under
   their segment ids, so the colours live in exactly this one
   place and win over the generic active rule (and Brown's amber
   segment override) in every theme. Unselected buttons carry a
   soft tint of their colour so staff spot them at a glance; the
   selected state fills with the colour itself. Selected-text
   contrast: white on the blue 6.4:1, white on the pink 5.1:1,
   near-black on white 14.7:1 — all >= 4.5:1. Cash's white fill
   keeps a strong border so the button never disappears against
   the White theme's light surfaces. */
#payment-seg button[data-v="Cash"] {
  background: color-mix(in srgb, #ffffff 16%, var(--surface));
  border-color: var(--border-strong);
}
#payment-seg button[data-v="Cash"].active {
  background: #ffffff; border-color: var(--border-strong); color: #1f2937;
}
#payment-seg button[data-v="KBZPay"] {
  background: color-mix(in srgb, #005eb8 14%, var(--surface));
  border-color: color-mix(in srgb, #005eb8 55%, var(--border));
}
#payment-seg button[data-v="KBZPay"].active {
  background: #005eb8; border-color: #005eb8; color: #ffffff;
}
#channel-seg button[data-v="foodpanda"] {
  background: color-mix(in srgb, #d70f64 12%, var(--surface));
  border-color: color-mix(in srgb, #d70f64 55%, var(--border));
}
#channel-seg button[data-v="foodpanda"].active {
  background: #d70f64; border-color: #d70f64; color: #ffffff;
}
.totals { border-top: 2px dashed var(--border); padding-top: 10px; display: grid; gap: 8px; }
.totals .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.totals .row input { width: 130px; text-align: right; }
.totals .row.total { font-size: 1.2rem; }
.totals .row.total strong { color: var(--accent); }
.cart-bar {
  position: fixed; left: max(12px, var(--sal)); right: max(12px, var(--sar)); bottom: calc(12px + var(--sab)); z-index: 30;
  background: var(--accent-bg); color: var(--on-accent); border: none; border-radius: 14px;
  min-height: 56px; padding: 12px 18px; font-weight: 800; font-size: 1.05rem;
  display: none; justify-content: space-between; align-items: center; gap: 10px; box-shadow: var(--shadow-lg);
}
.cart-bar span { min-width: 0; overflow-wrap: anywhere; }

/* today / closing */
.closing-card { background: var(--closing-bg); border: 2px solid var(--closing-border); border-radius: 16px; padding: 18px; margin-bottom: 22px; }
.closing-card h2 { margin-top: 0; }
.closing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.closing-main { background: var(--surface); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.closing-main span { color: var(--muted); font-weight: 600; }
.closing-main strong { font-size: 1.5rem; }
.closing-main.profit strong { color: var(--success); }
.closing-splits { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.closing-splits h3 { margin: 0 0 8px; font-size: .95rem; color: var(--muted); }
.split-row { display: flex; justify-content: space-between; gap: 10px; background: var(--surface); border-radius: 8px; padding: 7px 10px; margin-bottom: 5px; }
.split-row span { min-width: 0; overflow-wrap: anywhere; }
.mini-summary { background: var(--surface-2); border-radius: 10px; padding: 12px; margin: 10px 0; }

/* orders */
.orders-list { display: grid; gap: 10px; }
.order-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.order-card .oc-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.order-card .oc-no { font-weight: 800; }
.order-card .oc-total { margin-left: auto; font-weight: 800; color: var(--accent); }
.order-card .oc-items { color: var(--text-2); margin-top: 6px; overflow-wrap: anywhere; }
.order-card .oc-meta { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.channel-badge { font-size: .75rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--tag-bg); }
.channel-badge.grab { background: var(--grab-bg); color: var(--grab-text); }
.channel-badge.foodpanda { background: var(--panda-bg); color: var(--panda-text); }
.delete-btn { color: var(--danger); background: var(--danger-soft-bg); border: 1px solid var(--danger-soft-border); border-radius: 10px; min-height: 48px; padding: 8px 14px; font-weight: 700; margin-top: 8px; }
/* Receipt button on order cards — rendered for Walk-in orders only
   (Grab/foodpanda orders never get a receipt). */
.receipt-btn { color: var(--accent); background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); border-radius: 10px; min-height: 48px; padding: 8px 14px; font-weight: 700; margin-top: 8px; margin-right: 8px; }

/* history */
.days-list { display: grid; gap: 8px; }
/* Last-7-days sales chart (History): a single inline SVG drawn by
   app.js — bar fill and label colours ride the theme tokens, so it
   reads correctly in White, Black and Brown. Capped width so the
   bars stay proportionate on wide screens. */
.chart-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; background: var(--surface); }
.chart-card h3 { margin: 0 0 6px; font-size: .95rem; color: var(--muted); }
.history-chart svg { width: 100%; max-width: 520px; height: auto; display: block; }
.chart-bar { fill: var(--gold); }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-val { fill: var(--text-2); font-size: 11px; font-weight: 700; }
.chart-lab { fill: var(--muted); font-size: 11px; }
.day-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; width: 100%; text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px; min-height: 56px; font-weight: 600; }
.day-row .profit { color: var(--success); font-weight: 800; }

/* collapsible groups — Stock and Settings → Menu prices (by
   category) and Today's orders (by channel). The owner dislikes
   long scrolling lists, so these lists open with every group
   collapsed behind its header (except the first) and expand on tap. */
.cat-group { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; overflow: hidden; background: var(--surface); }
.cat-group-header {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 10px 14px; background: var(--surface-2); border: none; text-align: left;
  font-weight: 700; color: var(--text);
}
.cat-group-header .cg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat, var(--accent)); flex: 0 0 auto; }
.cat-group-header .cg-icon { font-size: 15px; line-height: 1; flex: 0 0 auto; }
.cat-group-header .cg-name { color: var(--accent); overflow-wrap: anywhere; }
.cat-group-header .cg-meta { margin-left: auto; color: var(--muted); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.cat-group-header .cg-chevron { color: var(--muted); flex: 0 0 auto; }
.cat-group-body { padding: 8px 10px 4px; }
.cat-group-body .stock-row:last-child, .cat-group-body .price-row:last-child, .cat-group-body .order-card:last-child { margin-bottom: 4px; }
/* Today's orders reuse the group shell: order cards carry no margin of
   their own (the flat lists space them with grid gap), so inside a
   group body they need the same rhythm as stock/price rows. The Today
   list itself is a grid with a 10px gap, so the groups' own bottom
   margin is dropped there to avoid double spacing. */
.cat-group-body .order-card { margin-bottom: 8px; }
#today-orders .cat-group { margin-bottom: 0; }

/* stock */
.stock-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; background: var(--surface); }
.stock-row .sr-name { font-weight: 600; overflow-wrap: anywhere; }
.stock-row .sr-price { color: var(--muted); white-space: nowrap; }
.stock-row .toggle-wrap { margin-left: auto; display: flex; align-items: center; gap: 8px; min-height: 48px; }
/* Compact switch (owner: the old one was too big). The LABEL keeps
   the full 76x48px tap target — the invisible checkbox covers all of
   it, and the row around it is padded too — but the VISIBLE switch is
   drawn smaller inside it: a 56x34px track (~3/4 size) with a 26px
   knob, centred in the label. The Available/Sold Out text shrinks to
   match (.toggle-label). */
.toggle { position: relative; width: 76px; height: 48px; flex: 0 0 auto; margin: 0; }
.toggle input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 7px 10px; background: var(--track-off); border-radius: 999px; transition: .15s; pointer-events: none; }
.toggle .track::after { content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%; background: #fff; top: 4px; left: 4px; transition: .15s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.toggle input:checked + .track { background: var(--success-bg); }
.toggle input:checked + .track::after { left: 26px; }
.toggle-label { font-size: .85rem; }

/* money */
.money-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.money-card { background: var(--surface-2); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.money-card strong { font-size: 1.4rem; }
.money-card.profit { background: var(--success-soft-bg); }
.money-card.profit strong { color: var(--success); }
.expense-form { display: flex; flex-wrap: wrap; gap: 8px; }
.expense-form input, .expense-form select { flex: 1 1 160px; }
/* Expense quick-add preset chips (Money): full 48px tap targets in
   a wrapping row above the form — compact, never a long list. */
.expense-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.preset-chip {
  min-height: 48px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-weight: 600;
}
.preset-chip:active { background: var(--accent-soft-bg); border-color: var(--accent-soft-border); }
.expenses-list { display: grid; gap: 8px; }
.expense-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.expense-row .amount { font-weight: 800; }
.expense-row .delete-btn { margin-left: auto; margin-top: 0; }

/* settings */
.settings-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 16px; background: var(--surface); }
.settings-card h3 { margin-top: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form input { flex: 1 1 150px; }
.user-row, .price-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.user-row .u-name { font-weight: 700; }
.user-row .spacer, .price-row .spacer { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.price-row input { width: 130px; }
.role-tag { font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--tag-bg); }
.role-tag.owner { background: var(--owner-tag-bg); color: var(--owner-tag-text); }
.off-tag { color: var(--faint); font-weight: 700; }
/* Telegram summary card (Settings): full-width fields, and the
   composed-summary fallback text in a readable pre block. Anchor
   "buttons" (the share links) need the button layout explicitly. */
#telegram-card label input { width: 100%; }
.summary-text {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: ui-monospace, Menlo, monospace; font-size: .9rem; color: var(--text);
  max-height: 320px; overflow-y: auto;
}
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* failed queue */
.failed-queue { background: var(--failed-bg); border: 1px solid var(--failed-border); color: var(--failed-text); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 600; }

/* footer — the ONLY place the address appears (plus receipts).
   Kept CLOSE under the content: main's bottom padding (10px) plus
   this top padding (10px) is the whole gap, so the address shows up
   right below the menu instead of after a long scroll. On phones the
   bottom padding grows (see the phone media query) — that space sits
   BELOW the address and exists only so the fixed cart bar can never
   cover the footer when the page is scrolled to the very end. */
.app-footer { padding: 10px max(16px, var(--sar)) calc(24px + var(--sab)) max(16px, var(--sal)); text-align: center; color: var(--muted); font-size: .9rem; }
.app-footer a { color: var(--accent); display: inline-block; min-height: 48px; line-height: 48px; padding: 0 4px; }

/* modals — centred dialog on wide screens, bottom sheet on phones */
.modal { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: max(16px, var(--sat)) max(16px, var(--sar)) max(16px, var(--sab)) max(16px, var(--sal)); z-index: 50; }
.modal-card { background: var(--surface); color: var(--text); border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
/* Keyboard open (phones): the price-editor sheet must live INSIDE
   the visual viewport — its bottom edge resting on the keyboard's
   top edge — instead of at the bottom of the full-height layout
   viewport, where the keyboard covers it and the price being typed
   is invisible. --vvh/--vvo are maintained from window.visualViewport
   by initKeyboardKeeper() in app.js, and html.kb-open is only set
   while a keyboard is actually up, so with no keyboard (desktop,
   iPad, or keyboard closed) the sheet is exactly as before. The
   card's max-height follows the same box so it can never poke out
   above the visible band either. */
html.kb-open #price-modal { top: var(--vvo, 0px); bottom: auto; height: var(--vvh, 100dvh); }
html.kb-open #price-modal .modal-card { max-height: calc(var(--vvh, 100dvh) - 16px); }
/* While the keyboard is up, give the page extra scroll room at the
   end so a focused in-flow checkout input (platform order no.,
   discount) can always be scrolled clear of the keyboard — app.js
   scrolls it into the visible band on every viewport change. */
html.kb-open main { padding-bottom: calc(10px + var(--kbh, 0px)); }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.topping-list { display: grid; gap: 8px; }
.topping-option { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 48px; font-weight: 600; margin: 0; }
.topping-option input { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; }
.topping-option .t-price { margin-left: auto; color: var(--gold); font-weight: 800; white-space: nowrap; }

/* receipt — always paper colours, whatever the app theme is */
.receipt { text-align: center; font-family: ui-monospace, Menlo, monospace; background: #fff; color: #111827; border-radius: 12px; padding: 16px; }
.receipt img { height: 64px; object-fit: contain; }
.receipt h3 { margin: 6px 0; }
.receipt .r-items { text-align: left; margin: 10px 0; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 10px; }
.receipt .r-opts { color: #6b7280; font-size: .85em; text-align: left; }
.receipt hr { border: none; border-top: 1px dashed #9ca3af; }
.receipt .r-total { font-size: 1.15rem; font-weight: 800; }
#receipt-sheet { display: none; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + var(--sab)); z-index: 60;
  background: var(--toast-bg); color: var(--toast-text); padding: 12px 20px; border-radius: 12px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow-lg);
}

/* phones (Android Chrome / iPhone Safari) */
@media (max-width: 820px) {
  main { padding: 10px max(10px, var(--sar)) 10px max(10px, var(--sal)); }
  /* The fixed cart bar is 56px tall and floats 12px above the screen
     edge, so its top edge sits 68px up. The footer's bottom padding
     (76px + safe area) is exactly the clearance that keeps the whole
     footer visible above the bar when scrolled to the end — the old
     design instead put 88px of padding between the content and the
     footer, which pushed the address far down the page. */
  .app-footer { padding-bottom: calc(76px + var(--sab)); }
  .view { padding: 12px; }
  .sell-layout { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .cart-bar { display: flex; }
  .cart-bar.hidden { display: none !important; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .header-title span { display: none; }
  .toast { bottom: calc(84px + var(--sab)); } /* float above the cart bar */
  /* dialogs become bottom sheets: full width, thumb-reachable, scroll inside */
  .modal { align-items: flex-end; padding: 0; }
  .modal-card {
    max-width: none; border-radius: 20px 20px 0 0;
    max-height: 92dvh; padding-bottom: calc(22px + var(--sab));
  }
}
@media (max-width: 520px) {
  .app-header { gap: 8px; }
  .header-logo { height: 36px; }
  .header-title strong { font-size: .95rem; }
  .user-chip { max-width: 128px; overflow: hidden; text-overflow: ellipsis; }
  .sync-chip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  #logout-btn { padding: 8px 10px; }
  .nav-btn { padding: 10px 11px; }
  .auth-card { padding: 22px 18px; }
}
@media (max-width: 480px) {
  .item-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .segmented button { font-size: .88rem; padding: 8px 2px; }
  .totals .row input { width: 110px; }
  .price-row input { width: 110px; }
  .closing-main strong { font-size: 1.3rem; }
}

/* wide screens (desktop / landscape tablet, where the cart panel
   sits beside a broad menu column): the category tiles flow into
   5 columns — two rows for the 9 categories — still no scrolling */
@media (min-width: 1100px) {
  .category-tabs { grid-template-columns: repeat(5, 1fr); }
}

/* receipt printing: print ONLY the receipt sheet */
@media print {
  body * { visibility: hidden; }
  #receipt-sheet, #receipt-sheet * { visibility: visible; }
  #receipt-sheet { display: block; position: absolute; inset: 0 auto auto 0; width: 100%; }
  #receipt-sheet .receipt { background: #fff; color: #111827; }
}
