/* ฟอนต์ Mali (Cadson Demak) ใบอนุญาต SIL OFL 1.1 ดู fonts/OFL.txt เก็บไว้ในแอป ใช้ได้ตอนไม่มีเน็ต */
@font-face { font-family: 'Mali'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/mali-400-thai.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Mali'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/mali-400-latin.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: 'Mali'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/mali-600-thai.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Mali'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/mali-600-latin.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: 'Mali'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/mali-700-thai.woff2) format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Mali'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/mali-700-latin.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; }
/* ร้านมะลิ: กระจกฝ้าโทนครีมขาว ฟ้ายามเช้าสีพาสเทล ประกายทอง แบบนิทานเจ้าหญิง (ไม่มีตัวการ์ตูน)
   การ์ดในรายการยาวใช้ขาวโปร่งเฉยๆ ไม่เบลอ ให้มือถือเลื่อนลื่น ส่วนที่เบลอจริงมีแค่แถบล่าง หน้าต่าง และการ์ดหัวหน้า */
:root {
  --cream: #FBF5EC;
  --ink: #4A3A4F;
  --ink-2: #8E7C8B;
  --rose: #D98FA2;
  --rose-deep: #B86A82;
  --lilac: #B7A2DA;
  --gold: #C29A45;
  --gold-soft: #F4E6C2;
  --mint: #CDEBDD;
  --mint-ink: #3F7E62;
  --red: #C2546B;
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .82);
  --glass-line: rgba(255, 255, 255, .92);
  --soft-line: rgba(183, 150, 170, .22);
  --field: rgba(250, 243, 236, .9);
  --shadow: 0 12px 30px -14px rgba(122, 78, 112, .32), 0 2px 6px -2px rgba(122, 78, 112, .08);
  --grad: linear-gradient(135deg, #E9A9B7 0%, #CF93BC 55%, #B59BD8 100%);
  --grad-gold: linear-gradient(135deg, #E9C878 0%, #C29A45 100%);
  --radius: 24px;
  --font: "Mali", "Noto Sans Thai", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--cream); }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }

/* ฉากหลัง: ท้องฟ้าพาสเทล มีแสงฟุ้งกับประกายดาวจางๆ อยู่นิ่งไม่เลื่อนตาม */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 40% at 8% 4%, rgba(246, 205, 216, .85), transparent 70%),
    radial-gradient(55% 40% at 100% 12%, rgba(218, 205, 244, .8), transparent 70%),
    radial-gradient(70% 45% at 50% 105%, rgba(250, 226, 190, .75), transparent 70%),
    radial-gradient(40% 30% at 85% 70%, rgba(246, 214, 226, .55), transparent 70%),
    var(--cream);
}
.sky::before, .sky::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 34% 9%, #fff 50%, transparent 51%),
    radial-gradient(1.8px 1.8px at 72% 22%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 88% 48%, #fff 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 22% 62%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 58% 80%, #fff 50%, transparent 51%),
    radial-gradient(1.8px 1.8px at 8% 88%, #fff 50%, transparent 51%);
  animation: twinkle 5s ease-in-out infinite;
}
.sky::after {
  background-image:
    radial-gradient(1.4px 1.4px at 46% 34%, rgba(232, 200, 120, .9) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 80% 8%, rgba(232, 200, 120, .9) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 92% 86%, rgba(232, 200, 120, .9) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 18% 40%, rgba(232, 200, 120, .9) 50%, transparent 51%);
  animation-delay: -2.5s;
}
@keyframes twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }
#view { padding: 0 16px; }
body.has-tabbar #view { padding-bottom: 176px; }

.page { padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: 32px; animation: rise .3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.press { transition: transform .14s ease, background-color .15s ease, color .15s ease, box-shadow .15s ease; }
.press:active:not(:disabled) { transform: scale(.96); }

/* ---------- หัวหน้า ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.page-head h1 {
  margin: 0; font-size: 30px; font-weight: 700; line-height: 1.25; letter-spacing: -.2px;
  background: linear-gradient(120deg, #B86A82 0%, #9C78C4 60%, #C29A45 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.page-head h1::after { content: " ✦"; font-size: 18px; color: var(--gold); -webkit-text-fill-color: var(--gold); vertical-align: 6px; }
.page-head .sub { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.head-right { display: flex; gap: 8px; }

.top-bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; min-height: 48px; }
.top-bar h1 { flex: 1; margin: 0; font-size: 21px; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 16px; display: inline-grid; place-items: center; flex: none;
  background: var(--glass-strong); color: var(--ink); border: 1px solid var(--glass-line); box-shadow: var(--shadow);
}
.icon-btn .ic { width: 21px; height: 21px; }
.icon-btn.small { width: 36px; height: 36px; border-radius: 12px; box-shadow: none; }
.icon-btn.small .ic { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: .35; }

/* ---------- การ์ดกระจก ---------- */
.card {
  background: var(--glass); border-radius: var(--radius); border: 1px solid var(--glass-line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.glass, .dlg, .tabbar, .save-bar {
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
}
.glass { background: rgba(255, 255, 255, .5); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 999px;
  background: rgba(244, 230, 194, .7); color: #8A6A2B; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip-strong { background: var(--grad); color: #fff; font-size: 14px; padding: 5px 13px; }
.chip-soft { background: rgba(183, 162, 218, .22); color: #6F5A9A; }
.st-chip.st-booked { background: rgba(183, 162, 218, .25); color: #6F5A9A; }
.st-chip.st-making { background: rgba(217, 143, 162, .22); color: var(--rose-deep); }
.st-chip.st-shipped { background: var(--mint); color: var(--mint-ink); }
.st-chip.st-cancelled { background: rgba(142, 124, 139, .16); color: var(--ink-2); }

.tag { display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; flex: none; }
.tag .ic { width: 13px; height: 13px; stroke-width: 3; }
.tag-owe { background: rgba(194, 84, 107, .1); color: var(--red); }
.tag-paid { background: var(--mint); color: var(--mint-ink); }
.tag-muted { background: rgba(142, 124, 139, .14); color: var(--ink-2); }

.warn { color: var(--red) !important; font-weight: 700; }
.muted { color: var(--ink-2); }
.pos { color: var(--mint-ink); }
.neg, .owe { color: var(--red); }
.hint { margin: 8px 4px 0; font-size: 13px; color: var(--ink-2); }
.hint:empty { display: none; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 18px; font-weight: 700; font-size: 16px;
}
.btn .ic { width: 20px; height: 20px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 22px -10px rgba(184, 106, 130, .8), inset 0 1px 0 rgba(255, 255, 255, .45); text-shadow: 0 1px 1px rgba(120, 60, 90, .25); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 10px 22px -10px rgba(194, 84, 107, .8); }
.btn-ghost { background: var(--glass-strong); color: var(--ink); border: 1px solid var(--glass-line); }
.btn-text { background: none; color: var(--ink-2); min-height: 44px; font-weight: 600; }
.btn-danger-text { color: var(--red); width: 100%; margin-top: 4px; }
.btn-big { min-height: 56px; font-size: 17px; border-radius: 20px; width: 100%; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 13px; }
.btn-dashed {
  width: 100%; min-height: 52px; border: 1.5px dashed rgba(184, 106, 130, .45); color: var(--rose-deep);
  background: rgba(255, 255, 255, .35); border-radius: 20px; margin: 10px 0 6px;
}
.btn.wide { width: 100%; }
.btn:disabled { background: rgba(142, 124, 139, .18); color: var(--ink-2); box-shadow: none; text-shadow: none; }

/* ---------- ตัวเลขสรุป ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.stat {
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px; box-shadow: var(--shadow);
  padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; min-width: 0;
}
.stat b { font-size: 30px; font-weight: 700; line-height: 1.2; color: var(--rose-deep); }
.stat b.stat-money { font-size: 19px; line-height: 1.9; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.stat-hot b { color: var(--red); }

/* ---------- แถบเตือน ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; margin-bottom: 12px;
  background: rgba(244, 230, 194, .75); color: #7A5B22; border-radius: 20px; border: 1px solid var(--glass-line);
}
.banner > .ic { width: 24px; height: 24px; color: var(--gold); }
.banner div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.banner b { font-size: 15px; }
.banner span { font-size: 13px; }
.banner-plain { background: rgba(255, 255, 255, .45); border: 1px dashed rgba(194, 154, 69, .45); color: var(--ink-2); }
.banner-plain b { color: var(--ink); }

/* ---------- รายการ ---------- */
.sec-title { font-size: 17px; font-weight: 700; margin: 24px 4px 10px; display: flex; align-items: baseline; gap: 8px; }
.sec-title span { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 10px; }

.order-card { display: flex; align-items: center; gap: 12px; padding: 12px; }
.oc-num {
  width: 54px; height: 58px; border-radius: 18px; flex: none; line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, rgba(255, 255, 255, .95), rgba(246, 222, 230, .9)); color: var(--rose-deep);
  border: 1px solid var(--glass-line); box-shadow: inset 0 -2px 0 rgba(217, 143, 162, .25);
}
.oc-num small { font-size: 12px; font-weight: 700; opacity: .7; }
.oc-num b { font-size: 22px; font-weight: 700; }
.order-card.st-booked .oc-num { background: linear-gradient(160deg, #fff, rgba(225, 214, 246, .95)); color: #6F5A9A; }
.order-card.st-shipped .oc-num { background: linear-gradient(160deg, #fff, var(--mint)); color: var(--mint-ink); }
.order-card.st-cancelled { opacity: .6; }
.oc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.oc-top { display: flex; align-items: center; gap: 6px; min-width: 0; justify-content: space-between; }
.oc-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-lines { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--ink-2); }
.oc-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.oc-meta .ic { width: 14px; height: 14px; }
.oc-arrow { color: var(--ink-2); width: 18px; height: 18px; }

/* แถบความคืบหน้า: สีอ่อน = ทำแล้ว สีเข้ม = ส่งแล้ว */
.pbar { position: relative; height: 7px; border-radius: 999px; background: rgba(183, 150, 170, .18); overflow: hidden; margin: 3px 0 1px; }
.pbar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width .4s ease; }
.pbar-made { background: linear-gradient(90deg, #F2C6D1, #E3BDE0); }
.pbar-ship { background: var(--grad); }

.empty { text-align: center; padding: 28px 20px; margin-top: 8px; }
.empty h2 { margin: 10px 0 4px; font-size: 20px; }
.empty p { margin: 0 0 16px; color: var(--ink-2); }
.empty-icon {
  width: 76px; height: 76px; border-radius: 28px; display: inline-grid; place-items: center;
  background: var(--grad); color: #fff; box-shadow: 0 14px 30px -12px rgba(184, 106, 130, .7);
}
.empty-icon .ic { width: 38px; height: 38px; }
.empty-mini {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px; color: var(--ink-2);
  border: 1.5px dashed var(--soft-line); border-radius: 20px; font-size: 14px; text-align: center; background: rgba(255, 255, 255, .3);
}
.empty-mini.flat { border: 0; background: none; padding: 12px; }
.all-link { margin-top: 18px; }

/* ---------- แถบล่าง + ปุ่มลอย ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 448px; height: 68px; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px;
  background: rgba(255, 255, 255, .7); border-radius: 26px; border: 1px solid var(--glass-line);
  box-shadow: 0 18px 40px -16px rgba(122, 78, 112, .45);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: var(--ink-2); font-size: 12px; font-weight: 600; border-radius: 20px; transition: background-color .2s, color .2s;
}
.tab .ic { width: 22px; height: 22px; }
.tab.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(184, 106, 130, .8); }
.tab:active { transform: scale(.95); }

.fab {
  position: fixed; z-index: 21; right: max(16px, calc(50% - 224px));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 82px);
  display: inline-flex; align-items: center; gap: 8px; height: 58px; padding: 0 22px 0 18px; border-radius: 22px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 17px; text-shadow: 0 1px 1px rgba(120, 60, 90, .25);
  box-shadow: 0 14px 28px -10px rgba(184, 106, 130, .85), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.fab .ic { width: 24px; height: 24px; stroke-width: 2.5; }

/* ---------- เปลี่ยนเดือน ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-title { font-size: 18px; font-weight: 700; }
.to-now { margin: 8px auto 0; display: flex; }

/* ---------- ตารางงาน ---------- */
.gantt { padding: 12px 12px 14px; }
.g-head { display: grid; gap: 1px; margin-top: 12px; }
.g-day {
  height: 22px; border-radius: 5px; font-size: 10px; font-weight: 700; display: grid; place-items: center; color: var(--ink-2);
  overflow: visible; white-space: nowrap;
}
.g-day.free { background: var(--mint); color: var(--mint-ink); }
.g-day.busy { background: rgba(217, 143, 162, .28); }
.g-day.busy2 { background: rgba(184, 106, 130, .55); color: #fff; }
.g-day.today { outline: 2px solid var(--gold); outline-offset: -1px; color: var(--ink); }
.g-day.sun:not(.today) { box-shadow: inset 0 -2px 0 rgba(194, 84, 107, .35); }
.g-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 2px 4px; font-size: 12px; color: var(--ink-2); }
.g-legend span { display: inline-flex; align-items: center; gap: 4px; }
.g-legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.lg-free { background: var(--mint); }
.lg-busy { background: rgba(217, 143, 162, .28); }
.lg-busy2 { background: rgba(184, 106, 130, .55); }
.g-rows { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.g-row { display: flex; flex-direction: column; gap: 3px; padding: 6px 2px; border-top: 1px solid var(--soft-line); }
.g-label { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.g-label b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-label small { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { display: grid; gap: 1px; height: 16px; }
.g-today { grid-row: 1; background: rgba(194, 154, 69, .22); border-radius: 4px; }
.g-bar { grid-row: 1; border-radius: 999px; background: var(--grad); box-shadow: 0 4px 10px -5px rgba(184, 106, 130, .8); }
.g-bar.st-booked { background: linear-gradient(90deg, #CDBEEA, #B7A2DA); }
.g-bar.st-shipped { background: var(--mint); box-shadow: none; }
.g-bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.g-bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.free-list { padding: 6px 14px; }
.free-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.free-item + .free-item { border-top: 1px solid var(--soft-line); }
.free-item .ic { color: var(--gold); }
.free-item b { flex: 1; font-size: 15px; }
.free-item span { font-size: 13px; font-weight: 700; color: var(--mint-ink); background: var(--mint); padding: 2px 10px; border-radius: 999px; }
.free-item.none span { background: rgba(194, 84, 107, .1); color: var(--red); }

/* ---------- หน้าเงิน ---------- */
.money-card { padding: 12px 12px 16px; text-align: center; }
.money-left { display: flex; flex-direction: column; align-items: center; margin-top: 8px; }
.money-left small { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.money-left b {
  font-size: 40px; font-weight: 700; line-height: 1.25;
  background: var(--grad-gold); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.money-left b.neg { background: none; color: var(--red); }
.money-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.money-split div { background: rgba(255, 255, 255, .55); border-radius: 18px; padding: 8px; display: flex; flex-direction: column; border: 1px solid var(--glass-line); }
.money-split small { display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.money-split small .ic { width: 15px; height: 15px; }
.money-split b { font-size: 20px; }

.entry { display: flex; align-items: center; gap: 12px; padding: 11px 12px; text-align: left; width: 100%; }
.entry-icon, .row-icon { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.k-in { background: var(--mint); color: var(--mint-ink); }
.k-out { background: rgba(194, 84, 107, .12); color: var(--red); }
.k-ship { background: rgba(183, 162, 218, .25); color: #6F5A9A; }
.entry-text, .row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.entry-text b, .row-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-text small, .row-text small { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.entry-text small .ic { width: 13px; height: 13px; }
.entry-amt { font-size: 16px; white-space: nowrap; }

/* ---------- หน้าต้นทุน ---------- */
.size-card { display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left; width: 100%; }
.size-badge { width: 46px; height: 46px; border-radius: 16px; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; }
.size-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.size-text b { font-size: 18px; }
.size-text small { font-size: 13px; color: var(--ink-2); }
.size-cost { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.size-cost small { font-size: 12px; color: var(--ink-2); }
.size-cost b { font-size: 15px; }

.menu { padding: 4px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 10px; border-radius: 18px; color: var(--ink-2); }
.menu-item:active { background: rgba(255, 255, 255, .6); }
.menu-item:disabled { cursor: default; }
.menu-item:disabled .menu-text b { color: var(--ink-2); }
.menu-item + .menu-item { border-top: 1px solid var(--soft-line); border-radius: 0 0 18px 18px; }
.menu-icon { width: 44px; height: 44px; border-radius: 15px; background: rgba(244, 230, 194, .8); color: #8A6A2B; display: grid; place-items: center; flex: none; }
.menu-text { flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.menu-text b { color: var(--ink); font-size: 16px; }
.menu-text small { font-size: 13px; }
.foot-note { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--ink-2); font-size: 13px; margin-top: 28px; }

/* ---------- ค้นหา ---------- */
.search-box {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 56px; color: var(--ink-2);
  background: var(--glass-strong); border: 1px solid var(--glass-line); border-radius: 20px; box-shadow: var(--shadow);
}
.search-box:focus-within { border-color: var(--rose); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; color: var(--ink); }

/* ---------- ฟอร์ม ---------- */
.page-form { padding-bottom: 120px; }
.fcard { padding: 14px; margin-bottom: 14px; }
.fcard-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.fcard-title .ic { color: var(--rose-deep); }
.fcard-title.outside { margin: 6px 4px 10px; }
.field { display: block; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.field-label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 0 0 4px 4px; }
.field-label em { font-style: normal; color: var(--rose-deep); }
.input-wrap {
  display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 14px; border-radius: 16px;
  background: var(--field); color: var(--ink-2); border: 1.5px solid transparent; transition: border-color .15s, background-color .15s;
}
.input-wrap:focus-within { border-color: var(--rose); background: #fff; }
.input-wrap input { flex: 1; width: 100%; min-width: 0; border: 0; outline: 0; background: none; font-size: 17px; color: var(--ink); }
.input-wrap > span { font-weight: 600; flex: none; }
.input-wrap.small { height: 46px; padding: 0 12px; border-radius: 14px; }
.input-wrap.small input { font-size: 16px; }
.input-wrap.big-num { height: 64px; }
.input-wrap.big-num input { font-size: 28px; font-weight: 700; }
.money-in input { font-weight: 700; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: .8; }
.plain-area {
  width: 100%; border-radius: 16px; background: var(--field); border: 1.5px solid transparent; padding: 12px 14px;
  font-size: 16px; color: var(--ink); outline: 0; resize: vertical; line-height: 1.5;
}
.plain-area:focus { border-color: var(--rose); background: #fff; }
.field.error .input-wrap, .field.error .plain-area, .date-tile.error, .item-card.error, .extra-card.error, .input-wrap.error { border-color: var(--red) !important; }

.suggest { display: flex; flex-direction: column; gap: 6px; }
.suggest:not(:empty) { margin-top: 8px; }
.suggest-item {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 16px;
  background: rgba(246, 222, 230, .7); animation: rise .2s ease-out;
}
.avatar { width: 36px; height: 36px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.s-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.s-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-text small { font-size: 13px; color: var(--ink-2); }
.suggest-item .chip { background: rgba(255, 255, 255, .8); }

.addr-pick:not(:empty) { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.addr-chip {
  display: flex; align-items: flex-start; gap: 8px; text-align: left; padding: 9px 12px; border-radius: 14px;
  background: rgba(244, 230, 194, .55); font-size: 14px; line-height: 1.4;
}
.addr-chip .ic { width: 16px; height: 16px; color: var(--gold); margin-top: 2px; }

.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.date-tile {
  position: relative; display: flex; flex-direction: column; padding: 10px 14px; border-radius: 16px;
  background: var(--field); border: 1.5px solid transparent; min-height: 68px; justify-content: center; overflow: hidden;
}
.date-tile .field-label { margin: 0; }
.date-tile b { font-size: 17px; font-weight: 700; }
.date-tile input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; cursor: pointer; }
.dlg .date-tile { margin-bottom: 4px; }

.quick-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quick-row:empty { display: none; }
.chip-btn {
  padding: 6px 13px; border-radius: 999px; background: rgba(255, 255, 255, .75); color: var(--ink);
  font-size: 14px; font-weight: 600; border: 1px solid var(--soft-line);
}
.chip-btn.on { background: var(--grad); color: #fff; border-color: transparent; }
.field .quick-row + .input-wrap { margin-top: 8px; }

.item-card { padding: 12px 14px 14px; margin-bottom: 10px; animation: rise .22s ease-out; border: 1.5px solid var(--glass-line); }
.item-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 6px; }
.item-no { font-weight: 700; font-size: 15px; }
.size-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.type-chip {
  min-width: 52px; height: 42px; padding: 0 14px; border-radius: 14px; font-size: 15px; font-weight: 700;
  background: rgba(255, 255, 255, .8); color: var(--ink); border: 1px solid var(--soft-line);
}
.type-chip.on { background: var(--grad); color: #fff; border-color: transparent; }
.line-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 4px; }
.line-fields > label { min-width: 0; }
.line-sub { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.line-sub b { font-size: 17px; color: var(--ink); }
.extra-card { display: grid; grid-template-columns: minmax(0, 1fr) 112px 36px; gap: 6px; align-items: center; padding: 8px; margin-bottom: 8px; border: 1.5px solid var(--glass-line); }
.add-extra { width: 100%; font-size: 14px; margin-bottom: 8px; }

.save-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .78); border-top: 1px solid var(--glass-line); box-shadow: 0 -10px 30px -18px rgba(122, 78, 112, .4);
}
.save-total { display: flex; flex-direction: column; line-height: 1.15; flex: none; }
.save-total small { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.save-total b { font-size: 22px; font-weight: 700; }
.save-bar .btn { flex: 1; width: auto; }

/* ---------- หน้ารายละเอียดออร์เดอร์ ---------- */
.hero { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hero-top h2 { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.3; word-break: break-word; }
.hero-links { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phone-link { display: inline-flex; align-items: center; gap: 6px; color: var(--rose-deep); font-weight: 700; }
.phone-link .ic { width: 16px; height: 16px; }
.addr-box { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; padding: 10px 10px 10px 12px; border-radius: 16px; background: rgba(255, 255, 255, .6); font-size: 14px; }
.addr-box > .ic { width: 16px; height: 16px; color: var(--gold); margin-top: 3px; }
.addr-box span { flex: 1; white-space: pre-line; }

.progress-card { padding: 14px; margin-top: 12px; }
.pc-nums { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-bottom: 8px; }
.pc-nums div { display: flex; flex-direction: column; }
.pc-nums small { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.pc-nums b { font-size: 20px; }
.progress-card .pbar { height: 10px; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; flex-wrap: wrap; font-size: 14px; }
.pc-foot > span { display: inline-flex; align-items: center; gap: 5px; }
.pc-foot .ic { width: 16px; height: 16px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 14px; margin-top: 12px; }
.info-grid div { display: flex; flex-direction: column; min-width: 0; }
.info-grid small { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.info-grid b { font-size: 16px; }

.items-view { padding: 4px 14px; }
.iv-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--soft-line); }
.iv-text { flex: 1; min-width: 0; word-break: break-word; }
.iv-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; font-weight: 700; }
.iv-total b { font-size: 22px; color: var(--rose-deep); }

.money-box { padding: 12px; }
.mb-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.mb-nums div { display: flex; flex-direction: column; background: rgba(255, 255, 255, .55); border-radius: 16px; padding: 8px 12px; }
.mb-nums small { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.mb-nums b { font-size: 20px; }
.rows { display: flex; flex-direction: column; margin-bottom: 10px; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 10px 4px; text-align: left; width: 100%; border-bottom: 1px solid var(--soft-line); }
.row-cost { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.row-thumbs { display: flex; gap: 4px; align-items: center; color: var(--ink-2); font-size: 13px; }
.row-thumbs .ic { width: 15px; height: 15px; }
.mini-ph { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; display: block; border: 1px solid var(--glass-line); }
.mini-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-box { display: flex; gap: 10px; padding: 14px; margin-top: 14px; font-size: 15px; white-space: pre-line; }
.note-box .ic { color: var(--gold); margin-top: 2px; }
.sec-title + .card { margin-top: 0; }
#toggle-cancel { margin-top: 18px; }

/* ---------- สูตรต้นทุนในหน้าต่าง ---------- */
.yield-line { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--soft-line); }
.yield-line > span:first-child { display: flex; flex-direction: column; font-weight: 600; font-size: 15px; line-height: 1.3; }
.yield-line small { font-size: 12px; color: var(--ink-2); font-weight: 400; }
.cost-preview:not(:empty) { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.cost-preview div { background: rgba(244, 230, 194, .55); border-radius: 16px; padding: 8px 12px; display: flex; flex-direction: column; text-align: left; }
.cost-preview div:last-child { grid-column: 1 / -1; }
.cost-preview small { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.cost-preview b { font-size: 18px; }

/* ---------- หน้าต่าง ---------- */
.dlg-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(90, 64, 96, .28);
  display: grid; place-items: center; padding: 16px; animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dlg {
  width: 100%; max-width: 400px; background: rgba(255, 252, 248, .9); border-radius: 28px; padding: 22px 18px 16px;
  text-align: center; border: 1px solid var(--glass-line); box-shadow: 0 30px 60px -20px rgba(90, 50, 80, .45);
  animation: pop .3s cubic-bezier(.2, 1.3, .4, 1); max-height: calc(100dvh - 32px); overflow-y: auto;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dlg-icon { width: 56px; height: 56px; border-radius: 20px; background: var(--grad); color: #fff; display: inline-grid; place-items: center; }
.dlg-icon.small { width: 40px; height: 40px; border-radius: 14px; }
.dlg-icon.small .ic { width: 20px; height: 20px; }
.dlg-icon.danger { background: rgba(194, 84, 107, .12); color: var(--red); }
.dlg-icon .ic { width: 28px; height: 28px; }
.dlg h2 { margin: 12px 0 6px; font-size: 20px; }
.dlg p { margin: 0 0 4px; color: var(--ink-2); font-size: 15px; }
.dlg p b { color: var(--ink); }
.dlg-form { text-align: left; }
.dlg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.dlg-head h2 { margin: 0; font-size: 19px; }
.dlg-body .field:first-child { margin-top: 0; }
.dlg-actions { display: flex; gap: 10px; margin-top: 18px; }
.dlg-actions .btn { flex: 1; padding: 0 10px; }
.dlg .btn-danger-text { margin-top: 6px; }

/* ---------- ข้อความแจ้งสั้น ---------- */
.toast {
  position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); z-index: 60; transform: translate(-50%, -20px);
  max-width: calc(100% - 48px); padding: 12px 18px; border-radius: 18px; background: rgba(74, 58, 79, .92); color: #fff;
  font-weight: 600; font-size: 15px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- รูปสลิป / บิล ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.ph { position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: rgba(255, 255, 255, .7); border: 1px solid var(--glass-line); display: block; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-x { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; border-radius: 999px; background: rgba(74, 58, 79, .85); color: #fff; display: grid; place-items: center; }
.ph-x .ic { width: 15px; height: 15px; stroke-width: 2.6; }
.photo-row { display: flex; align-items: center; gap: 6px; }
.photo-count { flex: 1; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.photo-count .ic { width: 16px; height: 16px; }
.photo-row .btn { cursor: pointer; gap: 5px; padding: 0 12px; }
.photo-row .btn .ic { width: 17px; height: 17px; }
.photo-full { font-size: 13px; color: var(--ink-2); font-weight: 600; padding: 0 4px; }

.viewer { position: fixed; inset: 0; z-index: 55; background: #241A26; display: grid; place-items: center; animation: fade .18s ease-out; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .icon-btn { position: absolute; background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .25); box-shadow: none; }
.viewer-close { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.viewer-prev { left: 10px; top: 50%; margin-top: -22px; }
.viewer-next { right: 10px; top: 50%; margin-top: -22px; }
.viewer-count {
  position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .15); color: #fff; font-weight: 600; font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
