/* Boss Carton งานผลิต — มือถือเป็นหลัก ใช้งานหน้าลานโหลดของ */

@font-face {
  font-family: "Plex Thai";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-thai-thai-400-normal.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Plex Thai";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-thai-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plex Thai";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-thai-thai-600-normal.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Plex Thai";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-thai-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ⭐ 28/10/2026 หน้าตาใหม่ (แอดมินสั่ง): โทนน้ำเงินแบบ ERP · พื้นเทาอมฟ้า · ข้อมูลอยู่ในการ์ดขาวมุมมน · โลโก้ Boss Carton
   ใช้งานหน้าลานโหลดของ: ปุ่มใหญ่ ตัวหนังสือเข้ม สีสถานะต่างกันชัด (เขียว / เหลือง / น้ำเงิน / แดง) */
:root {
  --ink: #1e293b;         /* ตัวหนังสือหลัก */
  --paper: #f1f5f9;       /* พื้นหลังแอป */
  --sheet: #fff;          /* การ์ด */
  --brand: #b45309;       /* ⭐ ชุดซ้อม staging: ส้ม (แอปจริง = น้ำเงิน #1c3faa) */
  --brand-deep: #92400e;
  --brand-soft: #fef3c7;
  --muted: #64748b;
  --line: #e2e8f0;
  --edge: #cbd5e1;        /* ขอบปุ่ม / ช่องกรอก */
  --go: #15803d;          /* ขึ้นรถแล้ว / ยืนยัน */
  --go-soft: #dcfce7;
  --stop: #c81e1e;        /* มีปัญหา */
  --stop-soft: #fee2e2;
  --lock: #1e40af;        /* ออกใบส่งสินค้าแล้ว */
  --lock-soft: #dbeafe;
  --wait: #a16207;        /* รอขึ้นรถ */
  --wait-soft: #fef3c7;
  --shadow: 0 2px 10px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .05);
  --radius-s: 8px;
  --radius-m: 12px;
  --tap: 52px;
  font-family: "Plex Thai", "Thonburi", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-size: 17px;
  line-height: 1.55;
  background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* แถบหัวสีน้ำเงิน + โลโก้ */
.band {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .18);
  display: flex;
  align-items: center;
  gap: 12px;
}
.band__home {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.01em;
}
.band__logo { flex: none; width: 34px; height: 34px; border-radius: 8px; }
.band__title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.band__who { flex: 0 1 auto; min-width: 0; max-width: 46%; font-size: .9rem; text-align: right; line-height: 1.25; }
.band__name, .band__who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.band__who small { color: #c7d2fe; }
.band__out {
  flex: none;
  white-space: nowrap;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: var(--radius-s);
  background: rgba(255, 255, 255, .12);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
}

/* มือถือ: หัวแอปบรรทัดเดียว ไม่ตัดคำกลางชื่อ */
@media (max-width: 480px) {
  .band { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .band__home { gap: 8px; }
  .band__long { display: none; }
  .band__who { font-size: .8rem; max-width: 44%; }
  .band__out { min-height: 36px; padding: 0 10px; font-size: .82rem; }
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  outline: none;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 600; margin-top: 28px; margin-bottom: 10px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

a { color: var(--brand); text-underline-offset: 3px; }

:focus-visible { outline: 3px solid #3b82f6; outline-offset: 2px; }
/* พื้นที่เนื้อหารับโฟกัสตอนเปลี่ยนหน้า (ให้โปรแกรมอ่านหน้าจออ่านต่อได้) แต่ไม่ต้องมีกรอบสีน้ำเงิน */
main:focus, main:focus-visible { outline: none; }

/* ปุ่ม */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  line-height: 1.3;
  text-align: center;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--go { background: var(--go); border-color: var(--go); color: #fff; }
.btn--stop { color: var(--stop); border-color: #f5a3a3; }
.btn--ink { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(28, 63, 170, .25); }
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.btn-row > .btn:only-child { grid-column: 1 / -1; }
.stack { display: grid; gap: 10px; margin-top: 16px; }

/* หน้าเข้าสู่ระบบ: การ์ดกลางจอ + โลโก้ */
.login {
  margin-top: 8vh;
  background: var(--sheet);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 20px 24px;
  text-align: center;
}
.login::before {
  content: "";
  display: block;
  width: 64px;
  height: 92px;
  margin: 0 auto 14px;
  background: url("/icons/logo-symbol.png") center / contain no-repeat;
}
.login h1 { font-size: 1.8rem; }
.login .btn { margin-top: 24px; }
.alert {
  border-left: 5px solid var(--stop);
  background: var(--stop-soft);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  margin-top: 18px;
  text-align: left;
}

/* รายการ tag / ใบสั่งผลิต = การ์ด */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rows > li { background: var(--sheet); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.row-link {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 12px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
}
.row-link strong { font-size: 1.1rem; }
.row-link .meta { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; }
.count {
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 2px 10px;
}
.bar { grid-column: 1 / -1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--go); border-radius: 999px; }

/* หน้างาน: เลข JB ใหญ่ */
.jb {
  font-size: clamp(2.1rem, 9vw, 3rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.05;
  margin: 4px 0 6px;
  word-break: break-all;
  color: var(--ink);
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 12px 0 0;
  background: var(--sheet);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* รายการขึ้นรถ: การ์ด + แถบสีซ้าย + ป้ายสถานะ */
.line {
  background: var(--sheet);
  border-left: 5px solid var(--wait);
  padding: 14px 14px 16px;
  margin-top: 12px;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}
.line--loaded { border-left-color: var(--go); }
.line--locked { border-left-color: var(--lock); }
.line--issue { border-left-color: var(--stop); }
.line__head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.line__no { font-size: 1.25rem; font-weight: 600; }
.line__qty { font-weight: 600; white-space: nowrap; }
.status {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
}
.status .small { font-weight: 400; }
.status--wait { color: var(--wait); background: var(--wait-soft); }
.status--loaded { color: var(--go); background: var(--go-soft); }
.status--locked { color: var(--lock); background: var(--lock-soft); }
.issue-note { margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-s); color: var(--stop); background: var(--stop-soft); font-weight: 600; }

/* เอกสาร และ ประวัติ */
.docs, .log { list-style: none; margin: 0; background: var(--sheet); border-radius: var(--radius-m); box-shadow: var(--shadow); padding: 2px 16px; }
.docs li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.docs .btn { width: auto; min-height: 44px; }
.log { font-size: .95rem; }
.log li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.docs li:last-child, .log li:last-child { border-bottom: none; }
.log time { color: var(--muted); display: block; font-size: .85rem; }

/* สแกน */
#reader { width: 100%; max-width: 480px; margin: 12px auto 0; background: #0f172a; border-radius: var(--radius-m); overflow: hidden; min-height: 260px; box-shadow: var(--shadow); }

/* จัดการบัญชี */
.form { display: grid; gap: 10px; background: var(--sheet); padding: 16px; border-radius: var(--radius-m); box-shadow: var(--shadow); margin-top: 10px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
input, select, textarea {
  font: inherit;
  font-size: 17px;        /* ต่ำกว่า 16px แล้ว iPhone จะซูมหน้าตอนพิมพ์และค้างซูม */
  font-weight: 400;
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid rgba(28, 63, 170, .18); outline-offset: 0; }
textarea { min-height: 96px; resize: vertical; }
.person { background: var(--sheet); padding: 12px 16px; margin-top: 10px; border-radius: var(--radius-m); box-shadow: var(--shadow); }
.person--off { opacity: .6; }
.person__top { display: flex; justify-content: space-between; gap: 10px; }
.person__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.person__actions .btn { min-height: 44px; font-size: .95rem; }

/* หน้าต่างยืนยัน */
dialog {
  border: none;
  border-radius: 16px;
  padding: 20px 18px 18px;
  width: min(92vw, 460px);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .35);
}
dialog::backdrop { background: rgba(15, 23, 42, .5); }
dialog h2 { margin-top: 0; }

/* แจ้งผล */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%);
  max-width: 92vw;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-m);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 20;
}
.toast--show { opacity: 1; }
.toast--bad { background: var(--stop); }

.loading { padding: 40px 0; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* คลังวัตถุดิบ (งาน 06 · 28/10/2026) */
.zones { display: flex; flex-wrap: wrap; gap: 8px; }
.zone { min-width: 60px; min-height: 52px; padding: 0 14px; font: inherit; font-size: 1.3rem; font-weight: 700; border: 2px solid var(--edge); border-radius: var(--radius-s); background: #fff; color: var(--ink); cursor: pointer; }
.zone--on { background: var(--brand); border-color: var(--brand); color: #fff; }
.lbl { font-weight: 600; font-size: .95rem; }
.psize { font-size: 2.1rem; font-weight: 800; line-height: 1.15; margin: 8px 0 4px; }
.psize small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.psize--none { font-size: 1.2rem; color: var(--muted); }
.pstate { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 999px; font-weight: 700; background: var(--line); }
.pstate--in_stock { background: var(--go-soft); color: var(--go); }
.pstate--empty { background: #fef3c7; color: #92400e; }
.pstate--void { background: var(--stop-soft); color: var(--stop); }
.pline { margin-top: 8px; }
.count-line { font-weight: 600; margin: 10px 0 4px; }
.line--alt { border-left-color: #f59e0b; }
.diff--ok { color: var(--go); font-weight: 700; }
.diff--short { color: #b45309; font-weight: 700; }
.struck { text-decoration: line-through; }
.log li.undone { opacity: .6; }
.btn--sm { min-height: 38px; padding: 4px 14px; font-size: .92rem; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--edge); background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; }
.chip--on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pogroup { margin-top: 18px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; margin: 4px 0; }
/* ⭐ 28/10/2026 แอดมินแจ้ง: หัวข้อย่อยชิดปุ่ม/การ์ด · ปุ่มรับคืนตัดบรรทัดชิดขอบ */
h3 { font-size: 1rem; font-weight: 600; margin-top: 24px; margin-bottom: 10px; }
.btn--two { flex-direction: column; gap: 2px; padding: 12px 10px; line-height: 1.4; }
.btn--two small { font-size: .82rem; font-weight: 500; color: var(--muted); }

/* ห้องราคา + Dashboard ผู้บริหาร (งาน 07 ขั้น 3 · 29/10/2026) */
.tbl-wrap { overflow-x: auto; background: var(--sheet); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .tbl-sum td { font-weight: 700; border-top: 2px solid var(--edge); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.tile { background: var(--sheet); border-radius: var(--radius-m); box-shadow: var(--shadow); padding: 10px 12px; min-width: 0; }
.tile__label { display: block; color: var(--muted); font-size: .85rem; }
.tile__value { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile__unit { color: var(--muted); font-size: .8rem; }
.due--late { color: var(--stop); font-weight: 600; }
.price-warn { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--radius-s); background: var(--wait-soft); color: #92400e; font-weight: 600; font-size: .9rem; }
.price-warn[hidden] { display: none; }
@media (max-width: 480px) {
  .tiles { grid-template-columns: 1fr; }
  .tbl { font-size: .88rem; }
  .tbl th, .tbl td { padding: 8px 7px; }
  .tile { display: flex; align-items: baseline; gap: 8px; }
  .tile__label { flex: 1 1 auto; }
}

/* หน้าสรุปความคืบหน้า + กราฟวงกลมราย Tag (งาน 07 · SQL ชุดที่ 10 · 29/10/2026)
   วงแหวนแบนมีเงา มองตรงจากด้านบน (ชิ้นใหญ่เท่าจำนวนจริง) · สีตามสถานะในแอป · ตรวจสีคนตาบอดสีผ่าน (ออกใบ ↔ ขึ้นรถ ↔ รอ) */
:root { --pie-noted: #1d4ed8; --pie-loaded: #15803d; --pie-wait: #f59e0b; }
button.chip { font: inherit; cursor: pointer; }
.pie__card { display: flex; align-items: center; gap: 18px; background: var(--sheet); border-radius: var(--radius-m);
  box-shadow: var(--shadow); padding: 16px; }
.pie__svg { flex: 0 0 auto; width: 190px; height: 190px; overflow: visible; }
.pie__ring { filter: drop-shadow(0 4px 5px rgba(15, 23, 42, .22)) drop-shadow(0 1px 1px rgba(15, 23, 42, .18)); }
.pie__track { fill: none; stroke: var(--line); }
.pie__arc { fill: none; }
.pie__arc.pie--noted { stroke: var(--pie-noted); }
.pie__arc.pie--loaded { stroke: var(--pie-loaded); }
.pie__arc.pie--wait { stroke: var(--pie-wait); }
.pie__tag { text-anchor: middle; font-size: 26px; font-weight: 600; fill: var(--ink); }
.pie__total { text-anchor: middle; font-size: 14px; fill: var(--muted); }
.pie__side { flex: 1 1 auto; min-width: 0; }
.pie__legend { list-style: none; margin: 0; padding: 0; }
.pie__legend li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.pie__legend li:last-child { border-bottom: none; }
.pie__key { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 4px; }
.pie__key.pie--noted { background: var(--pie-noted); }
.pie__key.pie--loaded { background: var(--pie-loaded); }
.pie__key.pie--wait { background: var(--pie-wait); }
.pie__label { flex: 1 1 auto; min-width: 0; }
.pie__num { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pie__unit { margin: 10px 0 0; }
.pie__unit .chip { padding: 6px 12px; font-size: .9rem; }
@media (max-width: 480px) {
  .pie__card { flex-direction: column; align-items: stretch; padding: 14px 12px; }
  .pie__svg { align-self: center; width: 180px; height: 180px; }
}

/* สแกนมัดขึ้นรถ (งาน 02 ขั้น B · 29/10/2026): แถบผลสแกนสีเต็มแถบ อ่านได้จากระยะแขน · เขียว / เหลือง / แดง / เทา */
.scanbar { margin-top: 12px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--sheet); box-shadow: var(--shadow); color: var(--ink); font-weight: 600; }
.scanbar[hidden] { display: none; }
.scanbar__big { display: block; font-size: 1.35rem; line-height: 1.35; overflow-wrap: anywhere; }
.scanbar small { display: block; margin-top: 4px; font-size: .95rem; font-weight: 500; }
.scanbar--go { background: var(--go); color: #fff; }
.scanbar--warn { background: #facc15; color: #3f2a00; }
.scanbar--stop { background: var(--stop); color: #fff; }
.scanbar--wait { background: #475569; color: #fff; }
#reader { margin-top: 12px; border-radius: var(--radius-m); overflow: hidden; }
.bundle-big { margin-top: 6px; font-size: 1.6rem; font-weight: 700; }
.bundle-big span { font-size: 1.15rem; font-weight: 600; color: var(--muted); }
.status--stop { color: var(--stop); background: var(--stop-soft); }
.rowbtn { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-m); }
.tbl tr.tap { cursor: pointer; }
.tbl tr.tap:active { background: var(--brand-soft); }
.recent { border-left: 4px solid var(--line); padding-left: 10px !important; }
.recent--go { border-left-color: var(--go); }
.recent--warn { border-left-color: #facc15; }
.recent--stop { border-left-color: var(--stop); }
.recent--wait { border-left-color: #475569; }
.pdfref { overflow-wrap: anywhere; }
