/* เว็บสั่งซื้อผ่านไลน์ DPS Box — ออกแบบให้มือถือเป็นหลัก (ทดสอบที่ 360–430px)
   สีหลักใช้เขียวไลน์ เพราะลูกค้ามาจากแชทไลน์ ปุ่มจะได้ดูเป็นเรื่องเดียวกัน */

:root {
  --line: #06c755;
  --line-d: #05a948;
  --navy: #0f2a5c;
  --ink: #10141d;
  --mute: #5b6473;
  --line-c: #e3e8f0;
  --bg: #f4f6fb;
  --card: #fff;
  --warn: #b42318;
  --gold: #b5751a;
  --r: 14px;
  --bar-h: 76px;
  color-scheme: light;   /* หน้านี้ออกแบบไว้โทนสว่างอย่างเดียว กันเบราว์เซอร์ในแอปไลน์กลับสีเอง */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Sarabun", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { font-family: "Prompt", "Segoe UI", Tahoma, sans-serif; margin: 0; line-height: 1.35; }

a { color: var(--navy); }

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

/* ---------- แถบบน ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: #fff; border-bottom: 1px solid var(--line-c);
}
.topbar .wrap { display: flex; align-items: center; gap: 10px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--navy); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand span { font-family: "Prompt", sans-serif; font-size: 15px; line-height: 1.15; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--mute); }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mute); }
.who img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--bg); }
.who b { color: var(--ink); font-weight: 600; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.announce { background: #fff7e6; color: var(--gold); text-align: center; padding: 8px 14px; font-size: 13.5px; font-weight: 600; }

/* ---------- ขั้นตอน ---------- */
.steps { display: flex; gap: 6px; padding: 12px 0 4px; }
.steps div {
  flex: 1; text-align: center; font-size: 12px; color: var(--mute);
  padding: 7px 4px; border-radius: 9px; background: #e8edf6; font-weight: 600;
}
.steps div.on { background: var(--navy); color: #fff; }
.steps div.done { background: #d8f3e2; color: var(--line-d); }

/* ---------- ทั่วไป ---------- */
main { padding-bottom: calc(var(--bar-h) + 20px); }

.card {
  background: var(--card); border: 1px solid var(--line-c); border-radius: var(--r);
  padding: 14px; margin: 12px 0;
}
.card > h2 { font-size: 16px; margin-bottom: 4px; }
.card > p.sub { margin: 0 0 12px; color: var(--mute); font-size: 13.5px; }

.sec-title { font-size: 15px; margin: 18px 0 8px; color: var(--navy); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border: 0; border-radius: 11px;
  font-family: "Prompt", sans-serif; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: filter .15s, background .15s;
}
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-line { background: var(--line); color: #fff; }
.btn-p { background: var(--navy); color: #fff; }
.btn-o { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1.6px var(--navy); }
.btn-g { background: #eef1f7; color: var(--mute); }
.btn-w { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { min-height: 52px; font-size: 16.5px; }

.muted { color: var(--mute); }
.small { font-size: 13px; }
.center { text-align: center; }
.err-box { background: #fff1f0; color: var(--warn); border: 1px solid #ffd7d3; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: 10px 0; }
.ok-box { background: #eaf9f0; color: var(--line-d); border: 1px solid #c4ecd4; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: 10px 0; }

/* ---------- ค้นหา + หมวด ---------- */
.search { position: relative; margin: 12px 0 10px; }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 40px;
  border: 1px solid var(--line-c); border-radius: 11px; background: #fff;
  font-size: 16px; font-family: inherit;   /* 16px กัน iPhone ซูมเองตอนแตะ */
}
.search svg { position: absolute; left: 13px; top: 13px; width: 19px; height: 19px; stroke: var(--mute); fill: none; stroke-width: 2; }

.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-c);
  background: #fff; color: var(--mute); font-size: 13.5px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.chips button.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }

/* ---------- รายการสินค้า ---------- */
.plist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.prow {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--line-c); border-radius: 12px; padding: 10px 12px;
}
.prow.picked { border-color: var(--line); background: #f6fdf8; }
.prow .nm { font-weight: 600; font-size: 14.5px; }
.prow .meta { font-size: 12.5px; color: var(--mute); }
.prow .pz { font-size: 13.5px; color: var(--navy); font-weight: 600; }
.prow .pz s { color: var(--mute); font-weight: 400; margin-left: 5px; font-size: 12px; }
.prow .ask { font-size: 12.5px; color: var(--gold); font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-c);
  background: #fff; color: var(--navy); font-size: 19px; line-height: 1; cursor: pointer; font-family: inherit;
}
.stepper button:active { background: #eef1f7; }
.stepper .add { width: auto; padding: 0 14px; height: 36px; background: var(--navy); color: #fff; border-color: var(--navy); font-size: 14px; font-weight: 600; }
.stepper input {
  width: 58px; height: 34px; text-align: center; font-size: 16px; font-family: inherit;
  border: 1px solid var(--line-c); border-radius: 9px; background: #fff; color: var(--ink);
}

.empty { text-align: center; color: var(--mute); padding: 40px 10px; }

/* ---------- แถบเรทราคา ---------- */
.meter { background: #fff; border: 1px solid var(--line-c); border-radius: 12px; padding: 11px 13px; margin: 12px 0; }
.meter .top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 7px; }
.meter .top b { color: var(--navy); }
.meter .bar { height: 7px; border-radius: 99px; background: #e8edf6; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--line), var(--line-d)); border-radius: 99px; }
.meter .hint { font-size: 12.5px; color: var(--mute); margin-top: 7px; }
.meter .save { color: var(--line-d); font-weight: 600; }

/* ---------- แถบล่างติดจอ ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line-c);
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 18px rgba(16, 24, 40, .07);
}
.bottombar .wrap { display: flex; align-items: center; gap: 12px; }
.bottombar .sum { flex: 1; min-width: 0; }
.bottombar .sum .t { font-size: 12px; color: var(--mute); }
.bottombar .sum .v { font-family: "Prompt", sans-serif; font-size: 20px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.bottombar .btn { flex: none; }

/* ---------- ฟอร์ม ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.field label b { color: var(--warn); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line-c); border-radius: 10px; background: #fff; color: var(--ink);
  font-size: 16px; font-family: inherit;   /* 16px กัน iPhone ซูมเอง */
}
.field textarea { min-height: 78px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #b9cdf5; outline-offset: 1px; border-color: var(--navy); }
.field .hint { display: block; font-size: 12px; color: var(--mute); margin-top: 4px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .f2 { grid-template-columns: 1fr; gap: 0; } }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line-c); border-radius: 11px; background: #fff; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--navy); }
.check .tx { font-size: 14px; }
.check .tx small { display: block; color: var(--mute); font-size: 12.5px; }

/* ---------- สรุปยอด ---------- */
.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.lines th { text-align: left; font-size: 12.5px; color: var(--mute); font-weight: 600; padding: 0 0 7px; }
.lines th:last-child, .lines td:last-child { text-align: right; }
.lines td { padding: 8px 0; border-top: 1px solid #f0f3f8; vertical-align: top; }
.lines .nm { font-weight: 600; }
.lines .meta { font-size: 12px; color: var(--mute); }

.totals { margin-top: 12px; border-top: 1px solid var(--line-c); padding-top: 10px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.totals .free { color: var(--line-d); font-weight: 600; }
.totals .cut { color: var(--line-d); }
.totals .grand {
  border-top: 1px solid var(--line-c); margin-top: 8px; padding-top: 10px;
  font-family: "Prompt", sans-serif; font-size: 19px; font-weight: 700; color: var(--navy);
}

/* ---------- หน้าเสร็จสิ้น ---------- */
.done-hero { text-align: center; padding: 8px 0 4px; }
.done-hero .tick {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 50%;
  background: #eaf9f0; display: grid; place-items: center;
}
.done-hero .tick svg { width: 32px; height: 32px; stroke: var(--line-d); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done-hero h2 { font-size: 19px; }
.done-hero .no { font-size: 13.5px; color: var(--mute); margin-top: 3px; }

.linkbox {
  display: flex; gap: 8px; align-items: center; background: #f7f9fd;
  border: 1px dashed var(--navy); border-radius: 11px; padding: 11px 12px; margin: 12px 0;
}
.linkbox code { flex: 1; min-width: 0; font-size: 13px; word-break: break-all; color: var(--navy); font-family: ui-monospace, Menlo, Consolas, monospace; }

.howto { counter-reset: s; margin: 14px 0 0; padding: 0; list-style: none; }
.howto li { counter-increment: s; position: relative; padding: 0 0 12px 34px; font-size: 14px; }
.howto li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 23px; height: 23px; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: 12.5px; font-weight: 700; display: grid; place-items: center;
}

/* ---------- สถานะออเดอร์ ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.b-new { background: #fff4e5; color: var(--gold); }
.b-confirmed { background: #e7f0ff; color: var(--navy); }
.b-done { background: #eaf9f0; color: var(--line-d); }
.b-cancelled { background: #f1f2f5; color: var(--mute); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 11px;
  font-size: 14px; max-width: 90vw; text-align: center; z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--warn); }

/* ---------- หลังร้าน ---------- */
.adm-wrap { max-width: 940px; margin: 0 auto; padding: 0 14px; }
.otable { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
.otable th { text-align: left; background: #f5f7fa; padding: 9px 10px; font-size: 12.5px; color: var(--mute); white-space: nowrap; }
.otable td { padding: 10px; border-top: 1px solid #eef1f6; vertical-align: top; }
.otable tr { cursor: pointer; }
.otable tr:hover td { background: #fafbfe; }
@media (max-width: 720px) {
  .otable, .otable tbody, .otable tr, .otable td { display: block; width: 100%; }
  .otable thead { display: none; }
  .otable tr { background: #fff; border: 1px solid var(--line-c); border-radius: 12px; margin-bottom: 9px; padding: 4px 2px; }
  .otable td { border: 0; padding: 3px 11px; }
}

.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(12, 18, 32, .5);
  display: grid; place-items: end center; padding: 0;
}
.modal .box {
  background: #fff; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .modal { place-items: center; padding: 20px; }
  .modal .box { border-radius: 16px; }
}
.modal .x { float: right; border: 0; background: #eef1f7; width: 32px; height: 32px; border-radius: 50%; font-size: 17px; cursor: pointer; color: var(--mute); }

/* ---------- ชวนล็อกอินบนหน้าแรก ---------- */
.loginpitch {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #f0fdf4; border: 1px solid #c4ecd4; border-radius: var(--r);
  padding: 12px 14px; margin: 12px 0 0;
}
.loginpitch > div { flex: 1; min-width: 170px; }
.loginpitch b { font-size: 14.5px; }
.loginpitch small { display: block; color: var(--mute); font-size: 12.5px; line-height: 1.5; }

/* ---------- การ์ดให้เลือก (ที่อยู่ / ใบกำกับภาษี) ---------- */
.picklist { display: flex; flex-direction: column; gap: 8px; }

.pickcard {
  display: flex; align-items: flex-start; gap: 10px; position: relative;
  border: 1.6px solid var(--line-c); border-radius: 12px; padding: 12px 12px 12px 11px;
  background: #fff; cursor: pointer;
}
.pickcard.on { border-color: var(--line); background: #f6fdf8; }
.pickcard input[type="radio"] { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--line-d); }
.pc-body { flex: 1; min-width: 0; padding-right: 44px; }
.pc-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pc-body .small { line-height: 1.55; }
.pc-edit {
  position: absolute; right: 10px; top: 10px;
  font-size: 12.5px; color: var(--navy); text-decoration: none; font-weight: 600;
  padding: 4px 9px; border-radius: 7px; background: #eef1f7;
}

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  background: #eef1f7; color: var(--mute); font-size: 11.5px; font-weight: 600;
}
.tag-d { background: #d8f3e2; color: var(--line-d); }

/* ---------- หลังร้าน: ตารางราคาต่อเรท ---------- */
.pricegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (min-width: 640px) { .pricegrid { grid-template-columns: 1fr 1fr 1fr; } }

.ratebox { border-top: 1px solid #f0f3f8; padding-top: 12px; margin-top: 12px; }
.ratebox:first-of-type { border-top: 0; padding-top: 0; }
.ratebox code { font-size: 12px; background: #f5f7fa; padding: 1px 6px; border-radius: 5px; }

/* ---------- หน้าเข้าสู่ระบบ (หน้าแรกของคนที่ยังไม่ล็อกอิน) ---------- */
.welcome { text-align: center; padding: 34px 4px 20px; }
.welcome .wm {
  width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 22px;
  background: #fff; border: 1px solid var(--line-c); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .06);
}
.welcome .wm svg { width: 52px; height: 52px; }
.welcome h1 { font-size: 25px; line-height: 1.3; color: var(--navy); margin-bottom: 12px; }
.welcome .lead { color: var(--mute); font-size: 14.5px; line-height: 1.75; margin: 0 0 24px; }
.welcome .lead b { color: var(--ink); }
