@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700;800&display=swap");

:root {
  --paper: #fbf6ec;
  --surface: #fffdf8;
  --ink: #271f19;
  --muted: #756a5f;
  --line: #e7dac9;
  --coffee: #704028;
  --coffee-dark: #351f15;
  --leaf: #2f705f;
  --mint: #dcebe4;
  --coral: #d66d45;
  --sky: #346b8d;
  --gold: #bf8f35;
  --shadow: 0 18px 45px rgba(61, 39, 23, .12);
  --shadow-lift: 0 10px 28px rgba(61, 39, 23, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --tab-height: 72px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(47, 112, 95, .10), transparent 34%),
    linear-gradient(315deg, rgba(214, 109, 69, .10), transparent 28%),
    var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin-top: 0; }

h1 { margin-bottom: 2px; color: var(--coffee-dark); font-size: 17px; line-height: 1.2; font-weight: 800; letter-spacing: -0.005em; }
h2 { margin-bottom: 4px; color: var(--coffee-dark); font-size: clamp(24px, 7vw, 34px); line-height: 1.12; font-weight: 800; letter-spacing: -0.015em; }
h3 { margin-bottom: 10px; color: var(--coffee-dark); font-size: 16px; line-height: 1.28; }
h4 { margin-bottom: 8px; color: var(--coffee-dark); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; font-weight: 800; }
p  { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

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

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: var(--tab-height);
  overflow-x: hidden;
}

/* ------------------------------------------------------------- */
/* Sidebar                                                       */
/* ------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid rgba(112, 64, 40, .14);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px 8px;
}

.brand-text { min-width: 0; line-height: 1.1; }
.brand p, .brand-tagline { font-size: 11px; color: var(--muted); margin-top: 1px; }
.brand-tagline { display: none; }

.brand-mark {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, var(--surface) 0 17%, transparent 18%),
    conic-gradient(from 20deg, var(--coffee), var(--coral), var(--leaf), var(--coffee));
  box-shadow: inset 0 0 0 3px rgba(255, 253, 248, .88);
}

/* Bottom tabs (mobile) */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--tab-height);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  border-top: 1px solid rgba(112, 64, 40, .15);
  box-shadow: 0 -16px 34px rgba(55, 36, 20, .08);
  backdrop-filter: blur(18px);
}

.tab-button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-width: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}

.tab-button span:first-child { font-size: 18px; line-height: 1; }

.tab-button.active {
  transform: translateY(-2px);
  background: var(--coffee);
  color: var(--surface);
}

.source-card { display: none; }

main { min-width: 0; padding: 0 16px 16px; }

.screen {
  display: none;
  min-width: 0;
  animation: enter .22s ease both;
}
.screen.active { display: block; }

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------- */
/* Order screen                                                   */
/* ------------------------------------------------------------- */
.inline-field > span,
.inline-field > label {
  display: inline;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
}

/* Chip-pill UI used in place of native <select> in webviews that block
   the native picker (LINE / Messenger / Facebook in-app browsers). */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.pill-row .pill {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--coffee-dark);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.1;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.pill-row .pill.active {
  background: var(--coffee);
  color: var(--surface);
  border-color: var(--coffee);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(112, 64, 40, .22);
}

@media (hover: hover) {
  .pill-row .pill:hover:not(.active) {
    border-color: rgba(112, 64, 40, .35);
    color: var(--coffee);
  }
}

.pill-row .pill-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

/* Category pill row sits below the search input — give it breathing room. */
.cat-pill-row {
  margin: -4px 0 14px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
          mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
}
.cat-pill-row::-webkit-scrollbar { display: none; }
.cat-pill-row .pill { flex: 0 0 auto; }

/* Contact channel chips — phone/FB/IG/Line/web (used by the contacts sheet) */
.contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(108, 75, 50, .22);
  background: #fff;
  color: var(--coffee, #6c4b32);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.contact-chip:focus-visible {
  background: var(--coffee, #6c4b32);
  border-color: var(--coffee, #6c4b32);
  color: #fff;
  outline: none;
}
@media (hover: hover) {
  .contact-chip:hover {
    background: var(--coffee, #6c4b32);
    border-color: var(--coffee, #6c4b32);
    color: #fff;
  }
}
.contact-chip .chip-ico { font-size: 14px; line-height: 1; }
.contact-chip.muted {
  color: #6b6b6b;
  border-style: dashed;
  background: #fafafa;
  cursor: default;
}
@media (hover: hover) {
  .contact-chip.muted:hover { background: #fafafa; color: #6b6b6b; }
}

/* Search row */
.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 14px;
}

.input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  font-size: 16px; /* prevent iOS Safari zoom on focus + override label 13px inheritance */
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.input:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(47, 112, 95, .14); }

.input.compact { min-height: 44px; padding: 8px 12px; font-size: 16px; }

.search-input-wrap {
  position: relative;
  display: block;
}
.search-input-wrap::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  background-color: var(--muted);
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-size: contain;
          mask-size: contain;
  pointer-events: none;
  opacity: .7;
}
.search-input {
  border-radius: var(--radius-pill);
  padding-left: 40px;
}

.cat-select {
  border-radius: var(--radius-pill);
  min-width: 140px;
  padding-right: 32px;
}

/* Menu grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.fineprint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(112, 64, 40, .12);
  border-radius: var(--radius-pill);
  background: #efe7d9;
  color: var(--coffee);
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 800;
}

.badge.medium { background: #fff1dc; color: #85511d; }
.badge.partial { background: #e6f0f4; color: var(--sky); }

/* Recent strip */
.recent-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.recent-strip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.recent-strip-head h3 {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.recent-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--coffee);
  background: #efe7d9;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}

.recent-list { display: grid; gap: 8px; }

.recent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 13px;
  border: 1px solid transparent;
  transition: border-color .15s ease;
}
@media (hover: hover) {
  .recent-item:hover { border-color: var(--line); }
}

.recent-item .who { color: var(--coffee-dark); font-weight: 800; }
.recent-item .what { color: var(--muted); font-size: 12px; margin-top: 1px; }
.recent-item .options { color: var(--muted); font-size: 11px; }

.recent-empty {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

.recent-empty strong { color: var(--coffee-dark); display: block; margin-bottom: 4px; }

/* ------------------------------------------------------------- */
/* Bottom sheet                                                   */
/* ------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 6, .5);
  z-index: 70;
  opacity: 0;
  transition: opacity .2s ease;
}

.sheet-backdrop[hidden] { display: none; }
.sheet-backdrop.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -20px 60px rgba(20, 12, 6, .25);
  transform: translateY(100%);
  transition: transform .25s ease;
}

.sheet[hidden] { display: none; }
.sheet.show { transform: translateY(0); }

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(112, 64, 40, .25);
  margin: 12px auto 0;
}

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 20px 6px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 { font-size: 20px; }

.sheet-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--coffee);
  font-size: 22px;
  font-weight: 900;
  display: inline-grid;
  place-items: center;
}

.sheet-body {
  overflow-y: auto;
  padding: 14px 20px;
  flex: 1 1 auto;
}

.sheet-section { margin: 14px 0; }
.sheet-section:first-child { margin-top: 4px; }

.sheet-section h4 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.sheet-section h4 .opt-hint {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-row button {
  min-height: 42px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--coffee-dark);
  font-weight: 700;
  font-size: 14px;
  transition: all .12s ease;
}

.chip-row button.active {
  border-color: var(--coffee);
  background: var(--coffee);
  color: var(--surface);
}

.sheet-foot {
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.primary, .secondary {
  min-height: 48px;
  border-radius: var(--radius-sm);
  font-weight: 900;
}

.primary {
  background: var(--coffee);
  color: var(--surface);
  box-shadow: 0 14px 28px rgba(112, 64, 40, .20);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

@media (hover: hover) {
  .primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(112, 64, 40, .26);
  }
}

.primary:disabled { cursor: not-allowed; opacity: .56; box-shadow: none; }

.secondary {
  background: #efe7d9;
  color: var(--coffee);
}

.sheet-submit { width: 100%; min-height: 54px; font-size: 16px; }

.textarea {
  min-height: 82px;
  resize: vertical;
}

/* ------------------------------------------------------------- */
/* Summary screen                                                 */
/* ------------------------------------------------------------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin: 6px 0 14px;
}

.page-head p { font-size: 13px; }

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.ghost {
  background: var(--paper);
  color: var(--coffee);
  font-weight: 800;
  min-height: 40px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  font-size: 14px;
}
@media (hover: hover) {
  .ghost:hover { background: var(--surface); }
}

.metrics {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.metric-hero {
  display: grid;
  align-content: end;
  gap: 2px;
  min-height: 124px;
  border-radius: var(--radius);
  background: var(--coffee-dark);
  color: var(--surface);
  padding: 14px 18px 16px;
  box-shadow: var(--shadow);
}
.metric-hero .metric-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .68;
}
.metric-hero strong {
  font-size: 46px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--surface);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.metric-hero .metric-unit {
  font-size: 12px;
  font-weight: 700;
  opacity: .7;
  letter-spacing: .04em;
}

.metric-side {
  display: grid;
  gap: 10px;
}
.metric-mini {
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
}
.metric-mini strong {
  color: var(--coffee-dark);
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.metric-mini span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 4px;
}

.metric-needs-price {
  display: none;
  grid-column: 1 / -1;
  align-content: center;
  border: 1px solid rgba(214, 109, 69, .35);
  border-radius: var(--radius);
  background: #fdf1ea;
  padding: 10px 14px;
}
.metric-needs-price.visible { display: grid; }
.metric-needs-price strong { color: var(--coral); font-size: 20px; line-height: 1; font-weight: 800; }
.metric-needs-price span { color: var(--coral); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; margin-top: 3px; }

.metric-surcharge {
  display: none;
  grid-column: 1 / -1;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 14px;
}
.metric-surcharge.visible { display: grid; }
.metric-surcharge strong { color: var(--coffee-dark); font-size: 20px; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric-surcharge span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; margin-top: 3px; }

.needs-price {
  color: var(--coral);
  font-style: normal;
  font-weight: 800;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.summary-grid, .rounds-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.summary-list { display: grid; gap: 8px; }

.line-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-bottom: 1px dashed var(--line);
  padding: 10px 0;
}

.line-item:last-child { border-bottom: 0; }
.line-item strong { color: var(--coffee-dark); }
.line-item small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.45; font-size: 12px; }

.line-box { min-height: 210px; }

.action-row {
  display: grid;
  gap: 9px;
}

/* ------------------------------------------------------------- */
/* Rounds screen                                                 */
/* ------------------------------------------------------------- */
.round-list { display: grid; gap: 10px; }

.round-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
}

.round-row header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.round-row strong { color: var(--coffee-dark); }
.round-row small { font-size: 12px; color: var(--muted); }

.toggle {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 36px;
  min-width: 44px;
  border-radius: var(--radius-pill);
  background: #d6c7b7;
  transition: background .18s ease;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .16);
  transition: transform .18s ease;
}

.toggle.on { background: var(--leaf); }
.toggle.on::after { transform: translateX(28px); }
.toggle:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

label {
  display: grid;
  gap: 6px;
  color: var(--coffee-dark);
  font-size: 13px;
  font-weight: 800;
}

/* generic field wrapper — used when <label for=""> is a sibling of the
   control (selects esp.) instead of wrapping it, to avoid iOS Safari
   swallowing taps on labels that wrap <select>. */
.field {
  display: grid;
  gap: 6px;
  color: var(--coffee-dark);
  font-size: 13px;
  font-weight: 800;
}

.field-hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
  margin-left: 4px;
}

/* Multi-select pill row uses a square check indicator instead of the
   single-select pill shape, so users immediately see this isn't a
   one-of-many control. */
.multi-pill-row .pill {
  position: relative;
  padding-left: 34px;
}

.multi-pill-row .pill::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  transition: background .15s ease, border-color .15s ease;
}

.multi-pill-row .pill.active::before {
  background: var(--surface);
  border-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 38%, var(--coffee) 38% 62%, transparent 62%),
                    linear-gradient(-45deg, transparent 32%, var(--coffee) 32% 50%, transparent 50%);
  background-position: 2px 4px, 1px 7px;
  background-size: 12px 8px, 8px 6px;
  background-repeat: no-repeat;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
  background: rgba(255, 253, 248, .64);
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------- */
/* Toast                                                          */
/* ------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tab-height) + 14px);
  z-index: 90;
  display: none;
  border-radius: var(--radius);
  background: var(--coffee-dark);
  color: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 800;
  text-align: center;
}

.toast[data-type="success"] { background: var(--leaf); }
.toast[data-type="error"] { background: var(--coral); }
.toast[data-type="warn"] { background: var(--gold); color: var(--coffee-dark); }

.toast.show {
  display: block;
  animation: enter .18s ease both;
}

/* ------------------------------------------------------------- */
/* Mobile-only refinements (≤599px)                              */
/* ------------------------------------------------------------- */
@media (max-width: 599px) {
  /* Hide the empty sticky brand bar — tabs already live at the bottom */
  .sidebar {
    position: static;
    background: transparent;
    border: 0;
  }
  .brand { display: none; }

  /* Search row stacks: search input full width, category select below */
  .search-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .cat-select { width: 100%; }

  /* Page heads on summary/rounds: actions wrap below title */
  .page-head { flex-wrap: wrap; }
  .page-head-actions { width: 100%; }

  /* Lift toast above the FAB so they don't overlap */
  .toast {
    bottom: calc(var(--tab-height) + 72px + env(safe-area-inset-bottom));
  }
}

/* ------------------------------------------------------------- */
/* Desktop                                                        */
/* ------------------------------------------------------------- */
@media (min-width: 600px) {
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
  .toast {
    left: auto;
    right: 28px;
    bottom: 28px;
    width: 360px;
  }
}

@media (min-width: 760px) {
  .app-shell {
    display: grid;
    grid-template-columns: 276px 1fr;
    gap: 22px;
    padding: 22px;
  }

  .sidebar {
    top: 22px;
    align-self: start;
    min-height: calc(100vh - 44px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .brand {
    align-items: center;
    padding: 18px;
  }

  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .brand h1 { font-size: 16px; }
  .sidebar {
    background: color-mix(in oklch, var(--paper) 90%, transparent);
    backdrop-filter: blur(18px);
  }

  .tabs {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
    padding: 0 18px 18px;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .tab-button {
    grid-template-columns: 26px 1fr;
    justify-items: start;
    min-height: 46px;
    padding: 0 12px;
    font-size: 14px;
  }

  /* source-card retained for debug, kept hidden by default (toggle via [hidden] attr) */

  main { padding: 0; }

  .app-shell { padding-bottom: 22px; }

  .menu-grid { grid-template-columns: repeat(3, 1fr); }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .wide { grid-column: 1 / -1; }

  .action-row { grid-template-columns: 1fr 1fr; }

  .rounds-grid {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }

  /* On desktop, the sheet feels better as a centered modal */
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, calc(-50% + 20px));
    width: min(520px, calc(100vw - 40px));
    max-height: 84vh;
    max-height: 84dvh;
    border-radius: var(--radius);
  }
  .sheet.show {
    transform: translate(-50%, -50%);
  }
  .sheet-handle { display: none; }
}

@media (min-width: 1024px) {
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
}

#sheetCustomerName {
  font-weight: 600;
}

/* ------------------------------------------------------------- */
/* Cart                                                          */
/* ------------------------------------------------------------- */
.cart-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.cart-row .cart-row-main { min-width: 0; }
.cart-row .cart-row-main strong { display: block; color: var(--coffee-dark); }
.cart-row .cart-row-main small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.cart-row .cart-row-price { font-weight: 700; color: var(--coffee-dark); }

.cart-row .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (hover: hover) {
  .cart-row .icon-btn:hover { background: rgba(112,64,40,.08); color: var(--coffee-dark); }
  .cart-row .icon-btn.danger:hover { background: rgba(214,109,69,.12); color: var(--coral); }
}

.cart-foot { display: flex; flex-direction: column; gap: 10px; }
.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  color: var(--muted);
}
.cart-total-row strong { font-size: 20px; color: var(--coffee-dark); }

.cart-round-warn {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(191,143,53,.15);
  color: var(--coffee-dark);
  font-size: 13px;
  border: 1px solid rgba(191,143,53,.4);
}

.sheet-secondary-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.sheet-secondary-row .danger-link {
  background: transparent;
  color: var(--coral);
  font-weight: 600;
  padding: 6px 10px;
  font-size: 13px;
}
@media (hover: hover) {
  .sheet-secondary-row .danger-link:hover { text-decoration: underline; }
}

/* ------------------------------------------------------------- */
/* Compact header (Task 4 of list-view redesign)                  */
/* ------------------------------------------------------------- */
.compact-header {
  position: sticky;
  top: 0;
  z-index: 9;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.compact-header-pin { font-size: 18px; }
.compact-header-text { flex: 1; min-width: 0; line-height: 1.1; }
.compact-header-text strong {
  display: block;
  font-size: 14px;
  color: var(--coffee-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compact-header-text small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.compact-header-btn {
  background: transparent;
  color: var(--coffee);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  min-height: 36px;
  cursor: pointer;
}
.compact-header-btn:active { background: var(--mint); }

/* ------------------------------------------------------------- */
/* Picker sheet (Task 5)                                          */
/* ------------------------------------------------------------- */
.picker-sheet .chip-row button { font-size: 13px; }
.picker-sheet .pill-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
}

/* ------------------------------------------------------------- */
/* Contacts sheet (Task 6)                                        */
/* ------------------------------------------------------------- */
.contacts-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.contacts-body .contact-meta {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
.contacts-body .empty {
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0;
}

/* ------------------------------------------------------------- */
/* Cart bottom bar (Task 7)                                       */
/* ------------------------------------------------------------- */
.cart-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  /* Sit ABOVE the bottom tab bar so สรุป/จัดการรอบ tabs stay tappable when
     the cart has items. Both used to anchor to bottom:0 with the cart bar's
     higher z-index covering the tabs entirely — that broke tab navigation
     whenever any item was in the cart. */
  bottom: var(--tab-height);
  z-index: 60;
  background: var(--coffee);
  color: var(--surface);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 -2px 8px rgba(0,0,0,.12);
}
.cart-bar-expand {
  flex: 1;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 4px 0;
  border: 0;
}
.cart-bar-expand strong { display: block; font-size: 14px; }
.cart-bar-expand small { display: block; font-size: 11px; opacity: .85; }
.cart-bar-send {
  background: var(--leaf);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 800;
  min-height: 40px;
  border: 0;
  cursor: pointer;
}
.cart-bar-send:disabled { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------- */
/* Menu list rows (Task 8 — replaces .menu-card cards)            */
/* ------------------------------------------------------------- */
.menu-grid {
  display: block;
  margin-bottom: 22px;
}
.menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 0;
  border-bottom: 1px solid #f5ede0;
  background: var(--surface);
  text-align: left;
  min-height: 44px;
  cursor: pointer;
}
.menu-row:last-child { border-bottom: 0; }
.menu-row:active { background: #fbf6ec; }
.menu-row-emoji { font-size: 18px; }
.menu-row-text { flex: 1; min-width: 0; line-height: 1.25; }
.menu-row-text strong { display: block; font-size: 13.5px; color: var(--ink); font-weight: 600; }
.menu-row-text small { display: block; font-size: 10.5px; color: var(--muted); }
.menu-row-price { font-size: 12.5px; font-weight: 700; color: var(--leaf); white-space: nowrap; }
.menu-row-add {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--coffee); color: #fff;
  font-size: 16px; font-weight: 900;
  display: inline-grid; place-items: center;
}

.sheet-advanced { margin: 12px 20px; }
.sheet-advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 0;
  font-size: 13px;
  color: var(--coffee);
  border-bottom: 1px solid var(--line);
}
.sheet-advanced > summary::-webkit-details-marker { display: none; }
.sheet-advanced[open] > summary { border-bottom-color: transparent; }

.dual-foot {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}
.dual-foot .sheet-secondary-row { grid-column: 1 / -1; }
.dual-foot .sheet-secondary-row[hidden] { display: none; }

/* Bean chip suffix labels (+10฿, หมด) — Task: bean stock + surcharge */
.chip-row button .chip-suffix {
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  opacity: .7;
}
.chip-row button[disabled] {
  opacity: .4;
  cursor: not-allowed;
  text-decoration: line-through;
}
.chip-row button[disabled] .chip-suffix {
  text-decoration: none;
}
