/* Coffee POS — espresso & cream. Mobile-first; rail layout from 768px. */
:root {
  --bg: #F7F1E8;
  --surface: #FFFDF9;
  --surface-2: #F1E8DB;
  --tint: #EEDFCB;
  --line: #E0D2BF;
  --line-strong: #CDBBA4;
  --text: #2A1D15;
  --muted: #6A5647;
  --primary: #5B3A29;
  --primary-hover: #462C1E;
  --primary-ink: #FFFFFF;
  --crema: #C8873F;
  --success: #1D7A4B;
  --success-bg: #E3F3E9;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --warn-bg: #FFF2D6;
  --warn-ink: #6B4500;
  --focus: #1F5FBF;
  --out-bg: #E9E4DE;
  --out-ink: #554B43;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(42, 29, 21, .06), 0 4px 14px rgba(42, 29, 21, .06);
  --shadow-lg: 0 10px 40px rgba(42, 29, 21, .25);
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Thonburi", "Leelawadee UI", "Noto Sans Thai", "Sukhumvit Set", sans-serif;
  --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);
  --nav-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a, label, input, select, .tile { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.noscript { padding: 24px; text-align: center; }

/* ============ app shell ============ */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "main" "nav";
}
.main { grid-area: main; min-height: 0; min-width: 0; position: relative; overflow: hidden; }
.view { height: 100%; }
.view[hidden] { display: none; }

.nav {
  grid-area: nav;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 0 var(--sar) var(--sab) var(--sal);
  z-index: 5;
}
.nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}
.nav-link svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link[aria-current="page"] { color: var(--primary); font-weight: 700; }
.nav-link[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}

@media (min-width: 768px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "nav main"; }
  .nav {
    display: flex; flex-direction: column; gap: 6px;
    border-top: 0; border-right: 1px solid var(--line);
    padding: calc(12px + var(--sat)) 6px calc(12px + var(--sab)) calc(6px + var(--sal));
  }
  .nav-link { min-height: 68px; border-radius: 14px; font-size: 14px; }
  .nav-link[aria-current="page"] { background: var(--tint); }
  .nav-link[aria-current="page"]::before { top: 18px; bottom: 18px; left: -6px; right: auto; width: 4px; height: auto; border-radius: 0 4px 4px 0; }
  .nav-link:hover { background: var(--surface-2); }
}

/* ============ buttons & controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1.5px solid transparent; border-radius: 12px;
  font-size: 16px; font-weight: 600; line-height: 1.2;
  text-decoration: none; text-align: center;
  background: transparent; color: var(--primary);
  user-select: none; -webkit-user-select: none;
  transition: background-color .15s, transform .08s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--primary); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { border-color: var(--danger); color: var(--danger); background: var(--surface); }
.btn-danger-text { color: var(--danger); }
.btn-sm { min-height: 48px; padding: 0 14px; font-size: 15px; }
.btn-lg { min-height: 56px; font-size: 18px; padding: 0 22px; }
.btn-xl { min-height: 60px; font-size: 20px; width: 100%; border-radius: 14px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; min-height: 48px; padding: 0 8px;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  font-size: 18px; font-weight: 600;
}
.btn-icon:hover:not(:disabled) { background: var(--surface-2); }
.btn-icon:disabled { opacity: .35; }
.link-btn { color: var(--primary); text-decoration: underline; font-weight: 500; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.file-btn { position: relative; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 16px;
  border: 1.5px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 16px; font-weight: 600; white-space: nowrap;
  user-select: none; -webkit-user-select: none;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-lg { min-height: 56px; font-size: 18px; border-radius: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.input:focus { border-color: var(--primary); outline: 3px solid rgba(31, 95, 191, .35); outline-offset: 0; }
.input[aria-invalid="true"] { border-color: var(--danger); background: #FFF8F7; }
.input-lg { min-height: 56px; font-size: 20px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%235B3A29' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center / 20px; }
.input-affix { position: relative; display: block; }
.input-affix .input { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.input-affix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field { display: grid; gap: 6px; margin: 0 0 16px; }
.field > span:first-child { font-weight: 600; font-size: 16px; }
.field-money { max-width: 220px; }
.field-row { display: grid; gap: 0 12px; }
@media (min-width: 600px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field-error, .form-error { color: var(--danger); font-weight: 600; margin: -6px 0 12px; }
.form-error { margin: 0 0 14px; padding: 10px 14px; background: var(--danger-bg); border-radius: 10px; }
.warn-text { color: var(--danger); margin-top: 10px; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }

/* segmented options (radio / checkbox cards) */
.opt-group { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
.opt-group > legend, .opt-label { font-weight: 700; font-size: 16px; margin-bottom: 8px; padding: 0; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.seg-wrap { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.seg-opt { position: relative; display: block; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt > span, .seg-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 56px; padding: 6px 10px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface);
  font-weight: 600; font-size: 17px; text-align: center; line-height: 1.25;
  user-select: none; -webkit-user-select: none;
}
.seg-opt small { font-weight: 500; font-size: 15px; color: var(--muted); }
.seg-opt input:checked + span, .seg-btn[aria-pressed="true"] { border-color: var(--primary); background: var(--tint); color: var(--primary); }
.seg-opt input:checked + span::before, .seg-btn[aria-pressed="true"]::before { content: "✓ "; font-weight: 700; }
.seg-opt input:checked + span small { color: var(--primary); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg-btn { width: 100%; color: var(--text); }
.seg[role="group"] { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }

/* stepper */
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.step { width: 52px; height: 52px; border: 0; border-radius: 10px; background: var(--surface); color: var(--primary); font-size: 26px; font-weight: 600; line-height: 1; box-shadow: var(--shadow); }
.step:active { transform: scale(.94); }
.step-val { min-width: 44px; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper-sm .step { width: 48px; height: 48px; font-size: 22px; }
.stepper-sm .step-val { min-width: 34px; font-size: 18px; }
.opt-qty { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt-qty .opt-label { margin: 0; }

/* switches */
.switch-track { position: relative; flex: none; width: 52px; height: 30px; border-radius: 999px; background: #BDAE9C; transition: background-color .15s; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; min-width: 120px; padding: 0 8px; border: 0; background: none; font-weight: 600; font-size: 15px; color: var(--text); }
.switch-btn[aria-checked="true"] .switch-track { background: var(--success); }
.switch-btn[aria-checked="true"] .switch-knob { transform: translateX(22px); }
.switch-btn[aria-checked="false"] .switch-text { color: var(--danger); }
.switch-row { position: relative; display: flex; align-items: center; gap: 14px; min-height: 56px; margin: 0 0 14px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; width: 52px; height: 30px; margin: 0; cursor: pointer; }
.switch-row input:checked + .switch-track { background: var(--success); }
.switch-row input:checked + .switch-track .switch-knob { transform: translateX(22px); }
.switch-row input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-row small { display: block; color: var(--muted); font-size: 15px; }

/* ============ banners & cards ============ */
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 14px; border-radius: 12px; margin: 0 0 12px; border: 1px solid var(--line); }
.banner p { flex: 1 1 240px; }
.banner-info { background: var(--tint); border-color: #DCC7AC; }
.banner-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #F0D49A; }
.banner-danger { background: var(--danger-bg); color: var(--danger); border-color: #F5C2BC; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 18px; margin: 0 0 12px; }
.card-danger { border-color: #EDB5AE; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty-title { font-size: 20px; font-weight: 700; color: var(--text); }
.tag { display: inline-block; font-size: 13px; font-weight: 600; padding: 0 8px; border-radius: 999px; background: var(--tint); color: var(--primary); vertical-align: middle; }

/* ============ sell ============ */
.view-sell { display: flex; flex-direction: column; }
.sell { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.products { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 0 calc(12px + var(--sar)) 0 calc(12px + var(--sal)); }
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: calc(10px + var(--sat)) 4px 8px; }
.topbar-title { font-size: 20px; font-weight: 700; color: var(--primary); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.topbar-meta { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.cats {
  display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain;
  padding: 2px 4px 10px; margin: 0 -4px; scrollbar-width: none; flex: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats[hidden] { display: none; }
.cat {
  flex: none; min-height: 48px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap;
}
.cat[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.search-wrap { padding: 0 0 10px; flex: none; }
.search-wrap[hidden] { display: none; }
.grid {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start;
  padding: 2px 2px 16px;
}
@media (min-width: 480px) and (max-width: 767.98px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); } }
.grid > .empty { grid-column: 1 / -1; }

.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 112px; padding: 12px 12px 10px;
  border: 1px solid rgba(42, 29, 21, .08); border-radius: 16px;
  background: var(--tile, var(--surface-2)); color: var(--text);
  text-align: left;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s ease-out, box-shadow .15s;
  box-shadow: 0 1px 0 rgba(42, 29, 21, .06);
}
.tile:active:not(.is-out) { transform: scale(.96); }
.tile-emoji { font-size: 28px; line-height: 1.1; margin-bottom: 2px; flex-shrink: 0; }
.tile-name { font-size: 17px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex-shrink: 0; }
.tile-price { margin-top: auto; padding-top: 4px; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-badge {
  position: absolute; top: 8px; right: 8px; min-width: 30px; height: 30px; padding: 0 8px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 0 0 2px var(--surface);
  z-index: 1;
}
.tile-badge.pop { animation: pop .28s ease-out; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.tile-tag { position: absolute; right: 8px; top: 10px; font-size: 13px; font-weight: 600; color: var(--muted); background: rgba(255,255,255,.65); padding: 0 6px; border-radius: 6px; }
.tile.is-out { background: var(--out-bg); color: var(--out-ink); cursor: not-allowed; box-shadow: none; border-style: dashed; border-color: #BFB4A8; }
.tile.is-out .tile-emoji { filter: grayscale(1); opacity: .55; }
.tile.is-out .tile-name { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.tile-out { display: inline-block; background: var(--out-ink); color: #fff; border-radius: 8px; padding: 0 10px; font-size: 16px; }

/* cart */
.cart { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.cart-head { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--sat)) 12px 8px 16px; border-bottom: 1px solid var(--line); }
.cart-head h2 { flex: 1; font-size: 20px; }
.cart-lines { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 0 16px; }
.cart-empty { color: var(--muted); text-align: center; padding: 40px 12px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main total" "step x"; align-items: center; gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line-main { grid-area: main; display: flex; flex-direction: column; align-items: flex-start; min-height: 48px; justify-content: center; padding: 2px 4px; border: 0; background: none; text-align: left; border-radius: 8px; }
.line-main:hover { background: var(--surface-2); }
.line-name { font-weight: 600; font-size: 17px; line-height: 1.3; }
.line-opt { color: var(--muted); font-size: 15px; line-height: 1.35; }
.line-total { grid-area: total; font-weight: 700; font-size: 18px; text-align: right; }
.line .stepper { grid-area: step; justify-self: start; }
.line-x { grid-area: x; justify-self: end; }
.cart-foot { padding: 10px 16px calc(12px + var(--sab)); border-top: 1px solid var(--line); display: grid; gap: 8px; background: var(--surface); }
.cart-discount { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 12px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: none; font-weight: 600; color: var(--primary); }
.cart-discount:disabled { opacity: .5; }
.cart-discount small { color: var(--muted); }
.cart-total { display: flex; align-items: baseline; justify-content: space-between; }
.cart-total span { font-size: 18px; font-weight: 600; }
.cart-total strong { font-size: 32px; font-weight: 700; color: var(--text); }
.cart-close { display: none; }

/* phone cart bar + sheet */
.cartbar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px calc(12px + var(--sar)) 8px calc(12px + var(--sal));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgba(42, 29, 21, .06);
}
.cartbar-open { flex: 1; min-width: 0; min-height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--surface); font-size: 17px; font-weight: 600; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cartbar-open:disabled { color: var(--muted); }
.cartbar .btn { min-height: 56px; font-size: 18px; padding: 0 22px; border-radius: 14px; }
.cart-scrim { position: fixed; inset: 0; background: rgba(30, 20, 12, .45); z-index: 20; }
.cart-scrim[hidden] { display: none; }

@media (max-width: 767.98px) {
  .cart {
    position: fixed; z-index: 21; left: 0; right: 0; bottom: 0;
    height: calc(100dvh - 48px - var(--sat)); max-height: 100%;
    border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
    transform: translateY(105%); visibility: hidden;
    transition: transform .25s ease-out, visibility 0s linear .25s;
    padding-left: var(--sal); padding-right: var(--sar);
  }
  .cart-head { padding-top: 12px; }
  .cart-open .cart { transform: none; visibility: visible; transition: transform .25s ease-out; }
  .cart-close { display: inline-flex; }
}
@media (min-width: 768px) {
  .sell { grid-template-columns: minmax(0, 1fr) 300px; }
  .products { padding: 0 16px; }
  .cart { border-left: 1px solid var(--line); padding-right: var(--sar); }
  .cartbar { display: none; }
}
@media (min-width: 1024px) { .sell { grid-template-columns: minmax(0, 1fr) 360px; } }

/* ============ pages: menu / sales / settings ============ */
.view-page { overflow-y: auto; overscroll-behavior: contain; padding: 0 calc(16px + var(--sar)) calc(24px + var(--sab)) calc(16px + var(--sal)); }
@media (max-width: 767.98px) { .view-page { padding-bottom: 24px; } }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: calc(12px + var(--sat)) 0 12px; max-width: 980px; margin: 0 auto; }
.page-head h2 { font-size: 24px; color: var(--primary); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-body { max-width: 980px; margin: 0 auto; }

.menu-cat { margin: 0 0 20px; }
.menu-cat h3 { font-size: 18px; margin: 0 0 8px; }
.menu-cat-empty { padding: 4px 0 8px; }
.menu-items { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.menu-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-bottom: 1px solid var(--line); }
.menu-row:last-child { border-bottom: 0; }
.menu-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 6px; border: 0; background: none; text-align: left; border-radius: 12px; }
.menu-row-main:hover { background: var(--surface-2); }
.swatch { flex: none; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 12px; background: var(--tile); font-size: 26px; border: 1px solid rgba(42,29,21,.08); }
.menu-row-text { display: grid; min-width: 0; }
.menu-row-name { font-size: 17px; font-weight: 600; }
.menu-row-price { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.menu-row.is-out .swatch { filter: grayscale(1); opacity: .6; }
.menu-row.is-out .menu-row-name { color: var(--out-ink); text-decoration: line-through; }

.date-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.date-pick .input { width: auto; min-width: 170px; }
.sales-day { font-size: 18px; margin: 0 0 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 10px; }
@media (min-width: 900px) { .stats { grid-template-columns: 1.2fr 1fr 1fr 1.4fr; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; display: grid; align-content: start; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: 15px; }
.stat strong { font-size: 28px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat small { color: var(--danger); font-size: 14px; }
.stat-main { background: var(--primary); border-color: var(--primary); }
.stat-main span { color: #F1E3D3; }
.stat-main strong { color: #fff; font-size: 32px; }
.stat-split { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 900px) { .stat-split { grid-column: auto; } }
.stat-split strong { font-size: 22px; }
.stat-split > div { display: grid; }
.sales-cols { display: grid; gap: 0 16px; margin-top: 14px; }
@media (min-width: 900px) { .sales-cols { grid-template-columns: 1fr 1.5fr; align-items: start; } }
.top-list { counter-reset: t; }
.top-list li { counter-increment: t; display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.top-list li:last-child { border-bottom: 0; }
.top-list li > span:first-child::before { content: counter(t) ". "; color: var(--muted); font-weight: 600; }
.order-list li + li { border-top: 1px solid var(--line); }
.order-row {
  width: 100%; display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "no time method total" "items items items items";
  gap: 0 10px; align-items: baseline; padding: 10px 4px; min-height: 56px; border: 0; background: none; text-align: left; border-radius: 8px;
}
.order-row:hover { background: var(--surface-2); }
.order-no { grid-area: no; font-weight: 700; font-variant-numeric: tabular-nums; }
.order-time { grid-area: time; color: var(--muted); font-variant-numeric: tabular-nums; }
.order-method { grid-area: method; color: var(--muted); font-size: 15px; }
.order-total { grid-area: total; font-weight: 700; font-size: 17px; text-align: right; }
.order-items { grid-area: items; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-row.is-void .order-no, .order-row.is-void .order-items { text-decoration: line-through; color: var(--out-ink); }
.order-row.is-void .order-total s { color: var(--out-ink); font-weight: 500; }
.void-tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 0 8px; border-radius: 999px; background: var(--danger-bg); color: var(--danger); text-decoration: none; }

.settings .card { max-width: 720px; }
.settings p + .row-gap { margin-top: 10px; }
.qr-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.qr-thumb { width: 120px; height: 120px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.qr-none { display: grid; place-items: center; color: var(--muted); font-size: 15px; background: var(--surface-2); }
.steps { list-style: none; display: grid; gap: 8px; margin: 0 0 12px; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.danger-row:first-of-type { border-top: 0; }
.app-ver { text-align: center; margin: 8px 0 0; }
#s-storage { margin-top: 10px; }

/* item form */
.rows { display: grid; gap: 8px; margin-bottom: 10px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 118px 48px; gap: 8px; align-items: center; }
.cat-add { grid-template-columns: minmax(0, 1fr) auto; margin-top: 12px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.emoji-opt, .color-opt { position: relative; display: block; }
.emoji-opt input, .color-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.emoji-opt > span:not(.sr-only) { display: grid; place-items: center; min-height: 52px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 24px; }
.emoji-opt:first-child > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.emoji-opt input:checked + span { border-color: var(--primary); background: var(--tint); box-shadow: inset 0 0 0 1px var(--primary); }
.emoji-opt input:focus-visible + span, .color-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.color-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.color-opt > span { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--tile); border: 2px solid rgba(42,29,21,.15); }
.color-opt input:checked + span { border: 3px solid var(--primary); }
.color-opt input:checked + span::after { content: "✓"; font-weight: 700; color: var(--primary); font-size: 20px; }
.preview-wrap { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.tile-preview { width: 150px; cursor: default; }
.cat-rows { display: grid; gap: 8px; }
.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto; gap: 4px; align-items: center; }
.cat-count { font-size: 14px; white-space: nowrap; padding: 0 4px; }
.preview-list { display: grid; gap: 4px; margin: 0 0 6px; }

/* ============ dialogs ============ */
.dlg {
  padding: 0; border: 0; border-radius: var(--radius-lg);
  width: min(560px, calc(100vw - 32px));
  max-height: min(92dvh, 920px);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg::backdrop { background: rgba(30, 20, 12, .5); }
.dlg-small { width: min(460px, calc(100vw - 32px)); }
@media (min-width: 768px) { #dlg-pay { width: min(680px, calc(100vw - 32px)); } }
.dlg-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0; }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 8px 20px; border-bottom: 1px solid var(--line); }
.dlg-title { flex: 1; font-size: 21px; font-weight: 700; line-height: 1.3; }
.dlg-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; }
.dlg-foot { padding: 12px 20px calc(14px + var(--sab)); border-top: 1px solid var(--line); background: var(--surface); }
.dlg-foot-2 { display: flex; justify-content: space-between; gap: 10px; }
.dlg-foot-2 .btn { min-height: 56px; flex: 0 1 auto; }
.dlg-foot-2 .btn[type="submit"], .dlg-foot-2 .btn-primary { flex: 1 1 auto; max-width: 320px; margin-left: auto; }
#dlg-confirm .dlg-body { padding: 20px; }
#dlg-confirm .dlg-title { margin-bottom: 10px; }
.confirm-msg { margin-bottom: 14px; }
.confirm-msg p + p { margin-top: 8px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dlg-actions .btn { min-height: 52px; }

@media (max-width: 767.98px) {
  .dlg:not(.dlg-small) {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    margin: 0; border-radius: 0;
    padding: var(--sat) var(--sar) 0 var(--sal);
  }
  .dlg-small { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding-bottom: var(--sab); }
  .dlg-actions { flex-direction: column-reverse; align-items: stretch; }
}

/* payment */
.pay-total { text-align: center; padding: 4px 0 12px; }
.pay-total span { display: block; color: var(--muted); font-size: 16px; }
.pay-total strong { font-size: 40px; font-weight: 700; line-height: 1.2; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 14px; margin-bottom: 14px; }
.tab { min-height: 52px; border: 0; border-radius: 10px; background: transparent; font-size: 18px; font-weight: 600; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); font-weight: 700; }
.pane[hidden] { display: none; }
.pay-cash { display: grid; gap: 12px; }
.pay-left { display: grid; gap: 10px; align-content: start; }
.pay-recv { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 14px; border: 2px solid var(--line-strong); border-radius: 14px; background: #fff; }
.pay-recv span { font-weight: 600; }
.pay-recv output { font-size: 32px; font-weight: 700; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick .chip { padding: 0 6px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { min-height: 58px; border: 0; border-radius: 12px; background: var(--surface-2); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none; }
.key:active { background: var(--tint); transform: scale(.96); }
.key-fn { font-size: 18px; color: var(--muted); }
.pay-change { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-height: 64px; padding: 8px 16px; border-radius: 14px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.pay-change strong { font-size: 34px; font-weight: 700; }
.pay-change.is-ok { background: var(--success-bg); color: var(--success); }
.pay-change.is-short { background: var(--danger-bg); color: var(--danger); }
@media (min-width: 680px) {
  .pay-cash { grid-template-columns: 1fr 1fr; gap: 16px; }
  .quick { grid-template-columns: 1fr 1fr; }
}
.pay-transfer { display: grid; gap: 12px; justify-items: center; text-align: center; }
.qr-img { width: min(280px, 70vw); aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.qr-empty { padding: 28px 16px; border: 2px dashed var(--line-strong); border-radius: 14px; width: 100%; color: var(--muted); }
.qr-empty a { display: inline-flex; min-height: 48px; align-items: center; font-weight: 600; }
.pay-note { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 14px; text-align: left; }
#pay-err { margin: 12px 0 0; }

/* done */
.done { text-align: center; display: grid; gap: 8px; justify-items: center; }
.done-check { width: 76px; height: 76px; border-radius: 50%; background: var(--success); display: grid; place-items: center; animation: pop .35s ease-out; }
.done-check svg { width: 44px; height: 44px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done-no { font-size: 18px; }
.done-no strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.done-change { width: 100%; display: flex; justify-content: space-between; align-items: baseline; padding: 10px 18px; border-radius: 14px; background: var(--success-bg); color: var(--success); font-weight: 600; font-size: 18px; }
.done-change strong { font-size: 40px; font-weight: 700; }
.done-sum { width: 100%; display: grid; gap: 2px; }
.done-sum > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.done-sum dt { color: var(--muted); }
.done-sum dd { font-weight: 700; }
.done-sum .sum-total dd { font-size: 22px; }
.done-items { width: 100%; text-align: left; border-top: 1px solid var(--line); margin-top: 4px; }
.done-items li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.done-items small { display: block; color: var(--muted); font-size: 15px; }
.done-items.is-void { text-decoration: line-through; color: var(--out-ink); }
.done-foot { display: grid; gap: 8px; position: relative; }
.done-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.done-more .btn { min-height: 52px; }
.done-timer { position: absolute; top: -1px; left: 0; right: 0; height: 4px; background: transparent; overflow: hidden; }
.done-timer span { display: block; height: 100%; background: var(--crema); transform-origin: left; animation: shrink linear forwards; }
.done-timer.stopped { display: none; }
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.disc-preview { margin-top: 14px; font-size: 18px; }

/* welcome */
.welcome { text-align: center; display: grid; gap: 10px; justify-items: center; padding-top: 24px; }
.welcome .field { width: 100%; text-align: left; margin-top: 8px; }
.welcome-logo { border-radius: 16px; }
.welcome-foot { display: grid; gap: 8px; }

/* ============ toasts ============ */
.toasts {
  position: fixed; top: auto; right: auto; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 84px + var(--sab));
  margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: inherit;
  width: min(480px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  z-index: 100; pointer-events: none;
}
.toasts[popover]:not(:popover-open) { display: none; }
body:not([data-view="sell"]) .toasts { bottom: calc(var(--nav-h) + 16px + var(--sab)); }
@media (min-width: 768px) { .toasts, body:not([data-view="sell"]) .toasts { bottom: calc(24px + var(--sab)); } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  min-height: 52px; padding: 6px 8px 6px 16px;
  background: #2A1D15; color: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  font-weight: 500; animation: toast-in .18s ease-out;
}
.toast-error { background: var(--danger); }
.toast-btn { min-height: 48px; padding: 0 14px; border: 0; border-radius: 10px; background: rgba(255,255,255,.14); color: #FFD9A8; font-weight: 700; font-size: 16px; }
.toast.out { opacity: 0; transition: opacity .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.print-area { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .done-timer { display: none; }
}

@media (hover: hover) {
  .tile:not(.is-out):hover { box-shadow: 0 0 0 2px var(--primary) inset; }
}

/* ============ receipt print (80mm, also fine on 58mm) ============ */
@media print {
  @page { size: 80mm auto; margin: 3mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  body > *:not(.print-area) { display: none !important; }
  dialog { display: none !important; }
  .print-area { display: block !important; color: #000; font-family: var(--font); font-size: 12px; line-height: 1.35; }
  .rc { width: 100%; max-width: 74mm; margin: 0 auto; }
  .rc-shop { text-align: center; font-size: 16px; font-weight: 700; }
  .rc-meta { text-align: center; margin-bottom: 4px; }
  .rc-void { text-align: center; font-weight: 700; margin: 4px 0; }
  .rc table { width: 100%; border-collapse: collapse; }
  .rc td { padding: 2px 0; vertical-align: top; }
  .rc .r { text-align: right; white-space: nowrap; padding-left: 6px; }
  .rc-lines { border-top: 1px dashed #000; border-bottom: 1px dashed #000; margin: 4px 0; }
  .rc-opt { font-size: 11px; }
  .rc-total td { font-weight: 700; font-size: 15px; }
  .rc-foot { text-align: center; margin-top: 8px; }
}

/* phone: keep the payment sheet within one screen */
@media (max-width: 767.98px) {
  .pay-total { padding: 0 0 8px; }
  .pay-total strong { font-size: 34px; }
  .tabs { margin-bottom: 10px; }
  .tab { min-height: 48px; }
  .pay-cash { gap: 8px; }
  .pay-left { gap: 8px; }
  .pay-recv output { font-size: 28px; }
  .quick .chip-lg { min-height: 48px; font-size: 17px; }
  .pay-change { min-height: 56px; }
  .pay-change strong { font-size: 30px; }
  .key { min-height: 52px; font-size: 24px; }
  #dlg-pay .dlg-scroll { padding-top: 10px; padding-bottom: 10px; }
  .banner { padding: 8px 12px; }
  .banner .hide-sm { display: none; }
}
