/* ระบบสั่งทอง — ธีมครีม/แดง/ทอง เดียวกับป้ายราคาทอง (mobile-first) */
:root {
  --bg: #FFF8E1;
  --red: #C62828;
  --red-dark: #B71C1C;
  --gold: #F0B429;
  --gold-soft: #FFD75E;
  --brown: #6D4C00;
  --cream-line: #F0DFA8;
  --text: #3E2C00;
  --muted: #9A845A;
  --white: #FFFFFF;
  --ok: #1B7A2E;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* date input บน iOS/LINE webview มีความกว้าง-สูงขั้นต่ำของตัวเอง ไม่ยอมหดตามคอลัมน์ → บังคับให้
   ทำตัวเหมือน text input ปกติ ไม่งั้นช่องล้นไปเกยช่องข้าง ๆ ในฟอร์ม 2 คอลัมน์ */
input[type=date] {
  -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 100%; min-height: 44px; text-align: left;
}
input[type=date]::-webkit-date-and-time-value { text-align: left; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 16px;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--red);
  color: var(--gold-soft);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.topbar a.back { color: var(--gold-soft); text-decoration: none; font-size: 22px; line-height: 1; padding: 4px 6px 4px 0; }
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .who { font-size: 12px; opacity: .9; text-align: right; line-height: 1.2; }

.wrap { padding: 14px; max-width: 760px; margin: 0 auto; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 600;
  padding: 12px 18px; text-decoration: none; text-align: center;
  background: var(--red); color: #fff;
}
.btn:active { transform: scale(.98); }
.btn.gold { background: var(--gold); color: var(--red-dark); }
.btn.ghost { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn.small { font-size: 14px; padding: 8px 12px; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ---------- home menu ---------- */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.menu-btn {
  background: var(--white); border: 2px solid var(--gold); border-radius: 16px;
  padding: 20px 10px; text-align: center; text-decoration: none; color: var(--red-dark);
  font-weight: 700; font-size: 17px;
  box-shadow: 0 2px 8px rgba(198,40,40,.08);
}
.menu-btn .ic { font-size: 34px; display: block; margin-bottom: 8px; }
.menu-btn:active { background: var(--bg); }
.stat-row { display: flex; gap: 10px; margin-top: 16px; }
.stat {
  flex: 1; background: var(--white); border-radius: 12px; padding: 10px 6px;
  text-align: center; border: 1px solid var(--cream-line);
}
.stat b { display: block; font-size: 22px; color: var(--red-dark); }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- gallery ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbar input[type=search] {
  flex: 1; border: 1.5px solid var(--cream-line); border-radius: 12px;
  padding: 10px 14px; font-family: inherit; font-size: 16px; background: var(--white);
}
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.filters select {
  border: 1.5px solid var(--cream-line); border-radius: 10px; background: var(--white);
  font-family: inherit; font-size: 14px; padding: 7px 10px; color: var(--text);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card {
  background: var(--white); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--cream-line); text-decoration: none; color: var(--text);
  display: flex; flex-direction: column;
}
.card .ph {
  aspect-ratio: 1; background: var(--bg) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 30px;
}
.card .nm { padding: 8px 10px 2px; font-weight: 700; font-size: 15px; color: var(--red-dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { padding: 0 10px 8px; font-size: 12px; color: var(--muted); }
.card.inactive { opacity: .5; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 30px; border: 0;
  box-shadow: 0 4px 14px rgba(183,28,28,.4); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- sheet / modal ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-bg.open { display: flex; }
.sheet {
  background: var(--white); border-radius: 18px 18px 0 0; width: 100%; max-width: 760px;
  max-height: 88dvh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 12px; font-size: 18px; color: var(--red-dark); }
.sheet .row { margin-bottom: 12px; }
/* แถวที่แบ่งซ้าย-ขวา (เช่น ช่วงวันที่) — ให้ลูกหดได้ ไม่งั้น min-width:auto ทำให้ช่องเกยกัน */
.sheet .row > div { min-width: 0; }
.sheet label { display: block; font-size: 13px; font-weight: 600; color: var(--brown); margin-bottom: 4px; }
.sheet input[type=text], .sheet input[type=number], .sheet input[type=date],
.sheet select, .sheet textarea {
  width: 100%; min-width: 0; border: 1.5px solid var(--cream-line); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 16px; background: var(--bg);
}
.sheet textarea { min-height: 64px; resize: vertical; }

/* ---------- list (settings) ---------- */
.list { background: var(--white); border-radius: 12px; border: 1px solid var(--cream-line); overflow: hidden; }
.list .item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border-bottom: 1px solid var(--cream-line); font-size: 15px;
}
.list .item:last-child { border-bottom: 0; }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .sub { font-size: 12px; color: var(--muted); }
.list .item.off .grow { opacity: .45; text-decoration: line-through; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button {
  border: 1.5px solid var(--red); background: transparent; color: var(--red);
  border-radius: 999px; padding: 7px 14px; font-family: inherit; font-size: 14px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.tabs button.on { background: var(--red); color: #fff; }

/* ---------- misc ---------- */
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--cream-line);
  border-radius: 999px; font-size: 12px; padding: 3px 10px; color: var(--brown); margin: 2px 4px 2px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .ic { font-size: 44px; display: block; margin-bottom: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(62,44,0,.92); color: #fff; border-radius: 999px; padding: 10px 20px;
  font-size: 14px; z-index: 60; opacity: 0; transition: opacity .25s; pointer-events: none;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }
#authGate {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center;
}
#authGate .logo { width: 64px; height: 64px; border-radius: 50%; background: var(--gold-soft);
  color: var(--red-dark); font-weight: 800; font-size: 26px; display: flex; align-items: center; justify-content: center; }
#authGate p { color: var(--brown); margin: 0; }
#authGate.hide { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs .th {
  width: 84px; height: 84px; border-radius: 10px; background: var(--bg) center/cover; position: relative;
  border: 2px solid var(--cream-line);
}
.thumbs .th.primary { border-color: var(--gold); }
.thumbs .th .star {
  position: absolute; top: -6px; right: -6px; background: var(--gold); color: var(--red-dark);
  border-radius: 50%; width: 22px; height: 22px; font-size: 13px;
  display: flex; align-items: center; justify-content: center; border: 0; cursor: pointer;
}
