/* Theme: replace these with the shop's colours. */
:root {
  /* ข้าวด้งทะเลดอง: black and red, like the shop's menu and sign */
  --brand: #e3262b;        /* main red (active tab, primary buttons) */
  --brand-ink: #ffffff;
  --accent: #e3262b;       /* price badges */
  --bg: #0b0b0b;
  --card: #1a1a1a;
  --ink: #f5f1ec;
  --muted: #a39a92;
  --line: #2c2c2c;
  --chip: #2a2a2a;         /* secondary buttons, steppers */
  --chip-press: #3a3a3a;
  --pic-bg: #151515;
  --tabs-bg: rgba(18,18,18,.94);
  --danger-bg: #3a1214;
  --good: #3ccf6e;
  --bad: #ff5a5f;
  --radius: 18px;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Thonburi", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
input, select, textarea { font: inherit; font-size: 18px; } /* >=16px: no iOS zoom */
[hidden] { display: none !important; }

/* ---------- header / banner ---------- */
.top { position: relative; background: #000; color: #fff; padding-top: env(safe-area-inset-top); }
/* Always show the whole banner (never crop): full width on phones, centred on wider screens. */
.banner { display: block; width: 100%; max-width: 900px; height: auto; aspect-ratio: 3 / 1; object-fit: contain; margin: 0 auto; }
.top-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px 8px; border-bottom: 3px solid var(--brand); }
.top-bar h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; font-size: 22px; color: #fff; }
.icon-btn:active { background: rgba(255,255,255,.2); }
.sync { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(0,0,0,.25); }

main { padding: 14px 14px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); max-width: 720px; margin: 0 auto; }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--tabs-bg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.tabs .ti { font-size: 24px; filter: grayscale(1); opacity: .6; }
.tabs button.on { color: var(--brand); }
.tabs button.on .ti { filter: none; opacity: 1; }

/* ---------- summary strip ---------- */
.strip { display: flex; align-items: baseline; gap: 10px; background: var(--card); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.strip .big { font-size: 28px; font-weight: 800; }
.strip .lbl { color: var(--muted); font-weight: 600; }
.strip .right { margin-left: auto; color: var(--muted); }

h2 { font-size: 18px; margin: 22px 4px 10px; }
.hint { color: var(--muted); font-size: 14px; margin: -4px 4px 10px; }

/* ---------- big picture buttons ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid.small { grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } .grid.small { grid-template-columns: repeat(4, 1fr); } }

.tile {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,.5);
  text-align: left; transition: transform .08s ease;
}
.tile:active { transform: scale(.96); }
.tile .pic { aspect-ratio: 4 / 3; width: 100%; display: grid; place-items: center; font-size: 64px; background: var(--pic-bg); overflow: hidden; }
.grid.small .tile .pic { font-size: 40px; aspect-ratio: 1; }
.tile .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .name { padding: 8px 10px 10px; font-weight: 700; font-size: 17px; line-height: 1.2; }
.tile.has-more .name { padding-right: 52px; }
.tile .name .unit { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.grid.small .tile .name { font-size: 14px; padding: 6px 8px 8px; }
.tile .price { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-weight: 800; font-size: 18px; padding: 3px 10px; border-radius: 99px; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.grid.small .tile .price { font-size: 13px; padding: 2px 7px; top: 6px; left: 6px; }
.grid.small .tile .count { min-width: 28px; height: 28px; top: 6px; right: 6px; font-size: 14px; }
.tile .count { position: absolute; top: 8px; right: 8px; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 99px; background: #fff; color: #111; font-weight: 800; display: grid; place-items: center; }
.tile .more { position: absolute; right: 6px; bottom: 6px; width: 40px; height: 40px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.tile.flash { animation: flash .35s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--brand); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* ---------- lists ---------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 60px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .em { font-size: 26px; width: 36px; text-align: center; flex: none; }
.row .em img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; display: block; }
.row .main { flex: 1; min-width: 0; text-align: left; }
.row .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .main small { color: var(--muted); }
.row .amt { font-weight: 800; white-space: nowrap; }
.row .amt.neg { color: var(--bad); }
.empty { padding: 18px; text-align: center; color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; background: var(--chip); font-size: 24px; font-weight: 800; }
.stepper button:active { background: var(--chip-press); }
.stepper .q { min-width: 32px; text-align: center; font-weight: 800; font-size: 18px; }
.del { width: 44px; height: 44px; border-radius: 12px; color: var(--bad); font-size: 20px; flex: none; }
.del:active { background: var(--danger-bg); }

/* ---------- overview ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--chip); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { padding: 10px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.nav { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.nav button.arrow { width: 48px; height: 48px; border-radius: 14px; background: var(--card); font-size: 24px; font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.nav .lbl { flex: 1; text-align: center; font-weight: 800; font-size: 17px; }
.nav .lbl small { display: block; font-weight: 600; color: var(--brand); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card .k { color: var(--muted); font-weight: 600; font-size: 14px; }
.card .v { font-size: 24px; font-weight: 800; margin-top: 2px; }
.card .s { color: var(--muted); font-size: 13px; }
.card.profit { grid-column: 1 / -1; }
.card.profit .v { font-size: 34px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* ---------- buttons ---------- */
.btn { display: block; width: 100%; padding: 15px; border-radius: 14px; font-weight: 800; font-size: 18px; background: var(--brand); color: var(--brand-ink); text-align: center; }
.btn:active { filter: brightness(.92); }
.btn.ghost { background: var(--chip); color: var(--ink); }
.btn.danger { background: var(--danger-bg); color: var(--bad); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.add-btn { margin-top: 12px; }

/* ---------- bottom sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .22s ease; max-width: 720px; margin: 0 auto;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: #444; margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 12px; font-size: 21px; display: flex; align-items: center; gap: 10px; }
.sheet h3 .em { font-size: 32px; }
.sheet h3 .em img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; display: block; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.field { margin: 12px 0; }
.field label { display: block; font-weight: 700; color: var(--muted); font-size: 14px; margin: 0 4px 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.field input.money { font-size: 34px; font-weight: 800; text-align: center; padding: 10px; }
.field .stepper { justify-content: center; gap: 14px; }
.field .stepper button { width: 64px; height: 64px; font-size: 30px; border-radius: 18px; }
.field .stepper .q { font-size: 34px; min-width: 70px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.quick button { padding: 8px 14px; border-radius: 99px; background: var(--chip); font-weight: 700; }
.total-line { text-align: center; font-size: 18px; color: var(--muted); margin: 6px 0; }
.total-line b { color: var(--ink); font-size: 24px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; z-index: 40; max-width: 560px; margin: 0 auto;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px;
  background: #f5f1ec; color: #111; border-radius: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.3); animation: fade .15s;
}
.toast .msg { flex: 1; font-weight: 600; }
.toast button { padding: 10px 16px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.login .box { padding: 24px 20px; max-width: 420px; width: 100%; margin: 0 auto; }
.login p { color: var(--muted); }
.login .err { color: var(--bad); font-weight: 700; }

/* ---------- settings: item editor ---------- */
.item-edit { display: grid; grid-template-columns: 36px 1fr 96px 44px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.item-edit input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; background: var(--card); }
.item-edit .em { font-size: 24px; text-align: center; }
.item-edit input[type=checkbox] { width: 26px; height: 26px; }
