:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef5f1;
  --text: #1f2a2a;
  --muted: #67736f;
  --line: #dce4df;
  --primary: #1f7a72;
  --primary-dark: #155d57;
  --danger: #d95745;
  --shadow: 0 12px 30px rgba(31, 42, 42, 0.08);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.customer-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.customer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 8px;
  background: #203b3a;
  color: #fff;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

.brand-block h1 {
  font-size: 26px;
  line-height: 1.15;
}

.brand-block p,
.cart-head p,
.sync-status,
.menu-meta,
.line-sub,
.note-field span,
.search-field span,
.table-box span {
  color: var(--muted);
}

.table-box {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.table-box span,
.search-field span,
.note-field span {
  font-size: 14px;
  font-weight: 800;
}

.table-box input,
.search-field input,
.note-field input,
.line-note {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  outline-color: var(--primary);
}

.table-box input {
  min-height: 58px;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}

.menu-panel,
.cart-panel,
.menu-card,
.cart-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.menu-panel {
  padding: 14px;
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.search-field,
.note-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sync-status {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #d4ded8;
  border-radius: 8px;
  background: #f7fbf9;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.sync-status.online {
  border-color: #b9dec9;
  background: #edf8f1;
  color: #20743d;
}

.sync-status.error {
  border-color: #efc9c3;
  background: #fff3f1;
  color: #9f3326;
}

.menu-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.menu-card {
  display: grid;
  gap: 10px;
  min-height: 156px;
  padding: 12px;
  box-shadow: none;
}

.menu-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.menu-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #304441;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.price {
  color: var(--primary-dark);
  font-weight: 900;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.add-button,
.qty-button,
.remove-button,
.submit-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
}

.add-button {
  flex: 1 1 100px;
  background: #f2fbf8;
  border-color: #b8ddd4;
  color: var(--primary-dark);
  padding: 0 12px;
  font-weight: 900;
}

.cart-panel {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.cart-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.cart-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 360px);
  overflow: auto;
  padding-right: 2px;
}

.cart-line {
  display: grid;
  gap: 10px;
  padding: 12px;
  box-shadow: none;
}

.line-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.line-title {
  font-weight: 900;
}

.line-sub {
  margin-top: 3px;
  font-size: 13px;
}

.line-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.qty-button {
  width: 44px;
  background: #fff;
  font-size: 20px;
  font-weight: 900;
}

.qty-value {
  min-width: 34px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.remove-button {
  background: #fff3f1;
  border-color: #efc9c3;
  color: #9f3326;
  padding: 0 12px;
  font-weight: 900;
}

.cart-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 20px;
}

.cart-total strong {
  color: var(--primary-dark);
  font-size: 26px;
}

.submit-button {
  min-height: 56px;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.submit-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed #c8d3cd;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translateX(-50%) translateY(80px);
  min-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  background: #203b3a;
  color: #fff;
  padding: 14px 16px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 960px) {
  .customer-grid {
    grid-template-columns: 1fr;
  }

  .cart-panel {
    position: static;
  }

  .cart-list {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .customer-shell {
    padding: 10px;
  }

  .customer-topbar,
  .toolbar,
  .line-main,
  .line-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .customer-topbar,
  .line-main,
  .line-actions {
    display: flex;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .table-box {
    min-width: 0;
  }

  .menu-list {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Cafe Baan Yo Shop v2 — แถบแจ้งปิดรับออเดอร์ และท้ายหน้า
   ============================================================ */

[hidden] {
  display: none !important;
}

.closed-banner {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: rgba(217, 87, 69, 0.08);
  border: 1px solid rgba(217, 87, 69, 0.3);
  color: #96311f;
  line-height: 1.5;
}

.closed-banner strong {
  font-size: 15px;
}

.closed-banner span {
  font-size: 14px;
}

.submit-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.customer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.staff-link {
  color: var(--muted);
  text-decoration: none;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.staff-link:hover {
  color: var(--primary-dark);
  border-color: var(--primary);
}

.staff-link:focus-visible,
.submit-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   v3.0.0 — การ์ดหมวดมีรูป กางทีละหมวด และแถบตะกร้าติดขอบล่าง
   ============================================================ */

.menu-panel {
  padding-bottom: 96px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
  gap: 12px;
}

.category-tile {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.category-tile:hover {
  border-color: var(--primary);
}

.cover {
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
}

.cover.tall {
  aspect-ratio: 16 / 7;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ยังไม่ได้ใส่รูป ใช้พื้นสีอ่อนกับชื่อหมวดแทน จะได้ไม่เห็นกรอบว่างเปล่า */
.cover-empty {
  display: grid;
  place-items: center;
  padding: 10px;
  background: rgba(31, 122, 114, 0.08);
  color: var(--primary-dark);
  text-align: center;
}

.cover-empty span {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.75;
}

.category-name {
  display: block;
  padding: 9px 12px 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.category-count {
  display: block;
  padding: 2px 12px 11px;
  font-size: 12px;
  color: var(--muted);
}

.category-open {
  grid-column: 1 / -1;
  border: 1px solid var(--primary);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}

.category-open-head {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  /* หัวหมวดติดขอบบนตอนเลื่อน หมวดใหญ่ 16 เมนูจะได้กดหุบกลับโดยไม่ต้องเลื่อนขึ้นสุด */
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

.category-open-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.category-open-bar .category-name,
.category-open-bar .category-count {
  padding: 0;
  flex: 0 0 auto;
}

.category-open-bar .category-name {
  flex: 1 1 auto;
  min-width: 0;
}

.category-chevron {
  color: var(--muted);
  font-size: 12px;
}

.category-open .menu-list {
  padding: 8px 14px 14px;
}

.menu-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.menu-card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.menu-from {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.search-results .menu-list {
  padding: 0;
}

/* ---------------------------------------------- ตะกร้า */

.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(31, 42, 42, 0.09);
}

.cart-bar-summary {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 1px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cart-bar-count {
  font-size: 12px;
  color: var(--muted);
}

.cart-bar-total {
  font-size: 18px;
  font-weight: 700;
}

.cart-bar-cta {
  flex: 0 0 auto;
  padding: 11px 22px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

.cart-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.cart-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 42, 42, 0.42);
}

.cart-sheet .cart-panel {
  position: relative;
  max-height: 82vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.cart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cart-close-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

body.cart-locked {
  overflow: hidden;
}

@media (min-width: 900px) {
  .cart-sheet {
    justify-content: center;
    align-items: center;
  }

  .cart-sheet .cart-panel {
    width: min(460px, 92vw);
    border-radius: 18px;
    max-height: 80vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
