/* โทนสี: Navy / Dark Blue + Orange (ใช้ธีมเดียว ไม่สลับตามโหมดมืด/สว่างของเครื่อง)
   ส้มใช้เป็นสี accent และปุ่มหลักเท่านั้น ไม่ใช้ทั้งระบบ */
:root {
  --bg: #0F172A;          /* พื้น — Navy เข้ม */
  --surface: #1E293B;     /* Card */
  --surface-2: #273449;   /* ช่องกรอก/ปุ่มรอง (ระหว่าง card กับเส้นขอบ) */
  --border: #334155;      /* เส้น/ขอบ */
  --text: #F8FAFC;        /* ตัวอักษรหลัก */
  --muted: #94A3B8;       /* ตัวอักษรรอง */
  --primary: #F59E0B;     /* Accent / ปุ่มหลัก — Orange */
  --primary-hover: #D97706;
  --primary-ink: #0F172A; /* ตัวอักษรบนปุ่มส้ม (navy อ่านชัดกว่าขาวบนส้ม) */
  --primary-soft: rgba(245, 158, 11, 0.14);
  --pos: #34D399;
  --neg: #F87171;
  --danger: #F87171;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums; /* ตัวเลขกว้างเท่ากัน หลักตรงกัน ไม่กระโดดตอนพิมพ์ */
  -webkit-tap-highlight-color: transparent;
}
/* พื้นหลัง 2 ชั้น (DESIGN 2.1): Navy → ลายเส้นแบบงาน (blueprint grid) + แสงส้มจาง ๆ → Card
   ชั้นตกแต่งจางมาก (3–8%) อยู่หลังทุกอย่าง ไม่รับการแตะ และไม่ใช้รูปภาพ */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px) 0 0 / 120px 120px,
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px) 0 0 / 120px 120px;
  /* ลายชัดด้านบน แล้วจางลงด้านล่าง ไม่รบกวนเนื้อหา */
  -webkit-mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 0%, transparent 80%);
  mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 0%, transparent 80%);
}
/* ลายน้ำแบบบ้าน (ไฟล์เดียวทั้งระบบ) อยู่เหนือเมนูล่าง + แสงส้มจาง ๆ ด้านหลัง + แสงส้มมุมขวาบน
   อยู่หลังการ์ดเสมอ หน้าไหนเนื้อหาเต็มจอก็ถูกบังไปเอง ไม่ต้องฝืนให้เห็น */
body::after {
  background:
    url("../icons/blueprint.svg") no-repeat center bottom calc(var(--nav-h) + 24px) / min(420px, 88vw) auto,
    radial-gradient(circle at 50% calc(100% - var(--nav-h) - 110px), rgba(245, 158, 11, 0.055), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(245, 158, 11, 0.08), transparent 35%);
}
@media print {
  body::before, body::after { display: none; }
}

h1, h2, h3 { line-height: 1.3; margin: 0; }
a { color: inherit; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.splash { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- ปุ่ม ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 48px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled), .fab:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-income { background: var(--pos); color: var(--primary-ink); }
.btn-expense { background: var(--neg); color: #fff; }
.btn-ghost-danger { background: transparent; color: var(--danger); margin-right: auto; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
.btn-block { width: 100%; }
.icon-btn {
  font: inherit; background: none; border: 0; color: var(--muted);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--surface-2); }
.link { font: inherit; background: none; border: 0; color: var(--primary); cursor: pointer; padding: 4px; font-weight: 600; }
/* Text link: action ที่ไม่สำคัญ เช่น ออกจากระบบ (DESIGN 4) */
.text-link {
  font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer;
  color: var(--muted); min-height: 44px; padding: 8px 16px;
}
.text-link:hover, .text-link:active { color: var(--danger); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- โครงหน้า ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
main { max-width: 720px; margin: 0 auto; padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
.page { padding: 16px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.section-title { font-size: 18px; font-weight: 600; margin: 24px 0 8px; }
.back { display: inline-block; text-decoration: none; color: var(--muted); margin-bottom: 8px; padding: 4px 0; }
/* ปุ่มกลับทุกหน้า: ไม่มีกรอบ — ไอคอน ‹ + ชื่อหน้า / ไม่ใช้สีส้ม (สงวนไว้ปุ่มหลัก) / พื้นที่กด ≥ 44px / hover-focus = พื้นจาง
   ขยับซ้าย 8px ให้ไอคอนตรงกับขอบเนื้อหา (padding ใช้เป็นพื้นที่กด / พื้นจางตอน hover) */
.back.back-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px 0 8px; margin-left: -8px;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--text); font-size: 16px; font-weight: 600; line-height: 1;
  transition: background-color 0.15s;
}
.back.back-btn:hover { background: var(--surface-2); }
.back.back-btn:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; background: var(--surface-2); }
.back-arrow { flex: 0 0 auto; width: 20px; height: 20px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; gap: 4px;
}
.bottomnav svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }
/* แถบบนขวาของหน้าบัญชี: กระดิ่ง + รูปโปรไฟล์ (ตาม Reference — แสดงอย่างเดียว ยังไม่มี action) */
.topbar-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; flex: 0 0 auto; }
.topbar .warn-chip + .topbar-actions { margin-left: 10px; }
/* สถานะระบบในแถบบน ก่อน Avatar (Online-first SCOPE 3.7) — ออนไลน์ = ป้ายเขียวนิ่ง
   ไม่มีอินเทอร์เน็ต = ป้ายเตือนแดง เฟดช้า ๆ ชัด → จาง → ชัด (รอบละ 2.4 วิ) เปลี่ยนแค่ opacity → ขนาด/layout ไม่ขยับ
   จางสุด 0.5 ข้อความยังอ่านได้ตลอด / ผู้ใช้ตั้ง Reduce Motion → ไม่เคลื่อนไหว */
/* หน้าตา: ป้ายแบน (ไม่มีขอบ / gradient / เงา) จุดสถานะ 6px + ข้อความ — ขนาดไม่เกินป้ายเดิม (98×26 / มือถือแคบ 86×23) */
.net-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 600; white-space: nowrap; padding: 4px 6px; border-radius: 999px;
  color: #6EE7B7; background: rgba(52, 211, 153, .08);
}
.net-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #34D399; flex: 0 0 auto; }
.net-status.offline { color: #FECACA; background: rgba(248, 113, 113, .16); animation: net-pulse 2.4s ease-in-out infinite; }
.net-status.offline::before { background: #F87171; }
@keyframes net-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .net-status.offline { animation: none; } }
/* มือถือ/แท็บเล็ต (< 1024px ไม่มี .topnav): แถบบนแถวแรก = โลโก้ | สถานะ + Avatar
   ป้าย "เหลือ X วัน · ต่ออายุ" ลงไปแถวที่สองของแถบบน → ชื่อระบบไม่ถูกบีบ ไม่ล้นจอ */
@media (max-width: 1023px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .warn-chip { order: 3; flex: 1 0 100%; text-align: center; }
  .topbar .warn-chip + .topbar-actions { margin-left: auto; }
  .topbar-actions { gap: 10px; }
}
/* จอแคบมาก (≤ 380px): ป้ายสถานะ/ระยะห่างกะทัดรัดขึ้น ให้หน้าตั้งค่า (มีกระดิ่ง) ยังอยู่แถวเดียว */
@media (max-width: 380px) {
  .topbar-actions { gap: 6px; }
  .net-status { font-size: .67rem; padding: 3px 4px; gap: 3px; }
}
.topbar-bell { display: grid; place-items: center; color: var(--text); }
.topbar-bell svg { width: 24px; height: 24px; }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; padding: 0;
  display: grid; place-items: center; border: 0; cursor: pointer; /* ไม่มีกรอบส้ม (เอาออก 27 พ.ย. 2569) */
  background: var(--primary-soft); color: var(--primary); font: inherit; font-weight: 700; font-size: 15px;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* เมนู Avatar (SCOPE 11.9): บัญชีผู้ใช้ — ชื่อ / อีเมล / ออกจากระบบ */
.avatar-menu { position: relative; display: flex; }
.avatar-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  width: min(280px, calc(100vw - 32px)); padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.avatar-panel[hidden] { display: none; }
.avatar-panel-user { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.avatar-panel-name { font-size: 15px; overflow-wrap: anywhere; }
.avatar-panel-email { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.avatar-panel-logout {
  display: block; width: 100%; margin-top: 10px; min-height: 44px; padding: 8px 12px;
  border: 0; border-radius: 10px; background: transparent; color: var(--danger);
  font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.avatar-panel-logout:hover, .avatar-panel-logout:focus-visible { background: rgba(248, 113, 113, 0.12); }
.avatar-panel-logout:disabled { opacity: 0.6; cursor: default; }

.fab {
  position: fixed; z-index: 11;
  right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  font: inherit; font-weight: 700;
  border: 0; border-radius: 999px; padding: 14px 20px;
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3); cursor: pointer;
}
@media (min-width: 760px) { .fab { right: calc(50% - 344px); } }

/* ---------- การ์ด / รายการ ---------- */
.summary, .stats { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat span { display: block; font-size: 0.8rem; color: var(--muted); }
.stat b { font-size: 1.15rem; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.chip {
  font: inherit; font-size: 0.875rem; white-space: nowrap; cursor: pointer;
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px;
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title { font-size: 1.05rem; }
.card p { margin: 2px 0 0; }
.card-nums { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 0.875rem; color: var(--muted); flex-wrap: wrap; }
.card-nums b { color: var(--text); }
.card-nums b.pos { color: var(--pos); }
.card-nums b.neg { color: var(--neg); }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.badge-quote { background: rgba(96, 165, 250, 0.15); color: #93C5FD; }
.badge-active { background: var(--primary-soft); color: var(--primary); }
.badge-paused { background: var(--surface-2); color: var(--muted); }
.badge-done { background: rgba(52, 211, 153, 0.15); color: var(--pos); }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--pos); border-radius: inherit; }

.empty { text-align: center; padding: 40px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- หน้าโครงการ ---------- */
.project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.project-head h1 { font-size: 1.4rem; }
.project-head p { margin: 2px 0 0; }
.tel { display: inline-block; margin-top: 4px; color: var(--primary); text-decoration: none; font-weight: 600; }
.meta { display: flex; align-items: center; gap: 8px; margin: 10px 0 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 16px; }
.actions .btn { padding: 10px 6px; }

.tx {
  font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.tx-main, .tx-side { display: flex; flex-direction: column; min-width: 0; }
.tx-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-side { align-items: flex-end; flex-shrink: 0; }
.tx-side small { color: var(--muted); }

/* ---------- ทีมช่าง ---------- */
.worker { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700;
  background: var(--primary-soft); color: var(--primary);
}
.worker-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.worker-main a { color: var(--primary); text-decoration: none; }
.worker-rate { font-weight: 700; white-space: nowrap; }
.worker-rate small { color: var(--muted); font-weight: 400; }

/* ---------- ฟอร์ม ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 500; }
.field small { color: var(--muted); font-size: 12px; }
.req { color: var(--neg); }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px กัน iOS ซูมอัตโนมัติ */
  width: 100%; padding: 10px 12px; min-height: 48px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
}
::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
/* Checkbox / radio: no box after tap or click (27 พ.ย. 2569) — keyboard (Tab) still shows the outline */
input:is([type="checkbox"], [type="radio"]):focus:not(:focus-visible) { outline: none; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.15s ease-out;
}
.modal {
  width: 100%; max-width: 520px; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0;
  animation: up 0.2s ease-out;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px 6px 18px; }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: 8px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.modal-foot .btn-primary { min-width: 120px; }
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .modal-backdrop, .modal { animation: none; } }

.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--nav-h) + 80px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 0.9rem; max-width: calc(100% - 32px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- หน้าล็อกอิน ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px 20px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin-top: 8px; }
.auth-card > p.muted { margin: 4px 0 24px; }
.auth-logo { border-radius: 18px; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; min-height: 52px; gap: 10px; }
.btn-google:hover { background: #f8f9fa; }
.error { color: var(--danger); min-height: 1.5em; margin: 12px 0 0; font-size: 0.9rem; }

/* Free: จำนวนงานร่างใต้ปุ่มสร้างงาน / ครบเพดาน → ปุ่มปิด (SCOPE 2.0.2 — Round 2) */
/* จำนวนงานร่างในปุ่มสร้างงานใหม่ "(ร่าง 2/3)" — ตัวเล็ก/จางกว่าข้อความหลัก */
.draft-quota { margin-left: 8px; font-size: 0.8em; font-weight: 600; opacity: 0.75; }
.draft-quota[hidden] { display: none; }

/* หมวดงานใน Calculator (SCOPE 3.2.1): หัวข้อ "รายการ" → หมวด (ชื่อพิมพ์เอง) → การ์ด วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น เดิม */
/* การ์ด "รายการ": หัว Section แบบการ์ดอื่น / หมวดทั้งหมด + ปุ่มเพิ่มหมวดอยู่ใน body */
.calc-items-card .calc-items-body { padding: 16px 12px 20px; }
.calc-items-body > .calc-category:first-child { margin-top: 0; }
/* มือถือ: ขอบการ์ดชิดขึ้น ให้แถวรายการกว้างใกล้เดิม (ช่องกรอก / ป้ายไม่ถูกตัด) */
@media (max-width: 479px) { .calc-items-card .calc-items-body { padding: 14px 4px 18px; } .calc-items-card .calc-category { padding-left: 6px; } }
html[data-theme="light"] .calc-items-card .calc-cat-hint { color: var(--muted); }
.calc-category { margin-top: 12px; padding-left: 10px; border-left: 3px solid var(--accent-line, var(--primary)); }
.calc-category + .calc-category { margin-top: 24px; }
/* Category Color System: หมวดคี่ = ชุดสี A / หมวดคู่ = ชุดสี B — ทั้งพื้นหมวด หัวหมวด Card หัว Card พื้นที่รายการ และช่องกรอก
   สีกำหนดเฉพาะใน .calc-category (ตัวแปรภายในหมวด) แต่ละระดับต่างกันเป็นลำดับชั้น / เปลี่ยนเฉพาะสีพื้น ไม่แตะเส้น ตัวอักษร ปุ่ม layout
   padding ให้พื้นหมวดโผล่รอบการ์ด (ซ้ายคงค่าเดิม) */
.calc-items-body > .calc-category { padding: 8px 10px 12px;
  --cat-bg: #0B1728; --cat-head: #18263B; --cat-label: #1D3A5B; --cat-card: #17263A; --cat-card-head: #1D3A5B; --cat-input: #202D40; --cat-item: #111B2A; }
.calc-items-body > .calc-category:nth-child(even) {
  --cat-bg: #1E4165; --cat-head: #2E5680; --cat-label: #37658F; --cat-card: #2B527B; --cat-card-head: #37658F; --cat-input: #3A5D80; --cat-item: #243F5C; }
html[data-theme="light"] .calc-items-body > .calc-category {
  --cat-bg: #FFFFFF; --cat-head: #FFFFFF; --cat-label: #DCEBFA; --cat-card: #FFFFFF; --cat-card-head: #DCEBFA; --cat-input: #FFFFFF; --cat-item: #F7FAFD; }
html[data-theme="light"] .calc-items-body > .calc-category:nth-child(even) {
  --cat-bg: #D5E7F8; --cat-head: #C4DCF2; --cat-label: #B3D1EE; --cat-card: #E7F2FC; --cat-card-head: #C4DCF2; --cat-input: #FFFFFF; --cat-item: #DCE9F5; }
html[data-theme="dark"] .calc-items-body > .calc-category {
  --cat-bg: #080D14; --cat-head: #111A27; --cat-label: #142B45; --cat-card: #111A27; --cat-card-head: #142B45; --cat-input: #182332; --cat-item: #0D141F; }
html[data-theme="dark"] .calc-items-body > .calc-category:nth-child(even) {
  --cat-bg: #1C334D; --cat-head: #234766; --cat-label: #285377; --cat-card: #203D5A; --cat-card-head: #285377; --cat-input: #263F59; --cat-item: #182D43; }
@media (max-width: 479px) { .calc-items-body > .calc-category { padding: 8px 8px 10px 6px; } }
.calc-items-body > .calc-category { background: var(--cat-bg); }
.calc-items-body > .calc-category .calc-cat-head { background: var(--cat-head); }
.calc-items-body > .calc-category .calc-cat-label { background: var(--cat-label); }
.calc-items-body > .calc-category .calc-group { background: var(--cat-card); }
.calc-items-body > .calc-category .calc-type-head { background: var(--cat-card-head); }
.calc-items-body > .calc-category .calc-rows { background: var(--cat-item); }
.calc-items-body > .calc-category :is(.calc-name, .calc-qty, .calc-unit, .calc-price, .calc-sell) { background: var(--cat-input); }
.calc-cat-name { font-weight: 700; font-size: 17px; min-height: 44px; }
/* แถวชื่อหมวด: [ หมวด | ช่องชื่อหมวด ] — ป้าย "หมวด" ใช้พื้นหัว Section (--surface-head ตาม Theme) */
.calc-cat-head { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.calc-cat-head:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.calc-cat-label { position: relative; flex: 0 0 auto; white-space: nowrap; display: flex; align-items: center; padding: 0 14px 0 18px; background: var(--surface-head); color: var(--text); font-size: 16px; font-weight: 700; border-right: 1px solid var(--border); }
/* แถบเหลืองด้านซ้าย แบบเดียวกับหัว Section (.calc-group-head::before) */
.calc-cat-label::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-line); }
.calc-cat-head .calc-cat-name { flex: 1 1 auto; min-width: 0; border: 0; border-radius: 0; background: transparent; outline: none; }
/* Light: หัว Section ในการ์ดเป็นฟ้าอ่อน (token ระดับการ์ด) → ป้าย "หมวด" ใช้สีเดียวกัน */
html[data-theme="light"] .calc-cat-label { background: linear-gradient(180deg, #E6F0FC 0%, #C8DFFA 100%); color: #0F172A; }
html[data-theme="light"] .calc-cat-label::before { background: #F59E0B; }
.calc-category .calc-cat-body > .calc-group { margin-top: 10px; }
.calc-cat-hint { margin: 6px 2px 0; color: #CBD5E1; }
/* ปุ่ม "＋ เพิ่มหมวดงาน (n)" (Primary) และ "＋ เพิ่มงานย่อย (n.m)" (Secondary): ทรงแคปซูลชุดเดียวกัน
   ขนาด / ความสูง / padding / ตัวอักษร / เงา เท่ากัน — ต่างกันที่สีและระดับความสำคัญเท่านั้น (สีส้มตาม SCOPE 3.7) */
.calc-pill { display: flex; align-items: center; justify-content: center; gap: 4px; width: 260px; max-width: 100%; min-height: 48px; margin: 20px auto 0; padding: 10px 20px; border: 2px solid transparent; border-radius: 999px; font-size: 16px; font-weight: 700; line-height: 1.3; text-align: center; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22); transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease; }
/* จอ 320–360px: ขยายเต็มพื้นที่ (ข้อความไม่ล้น) — ปุ่มหมวดกว้าง/ตรงแนวเดียวกับเนื้อหาในหมวด (เส้นเหลือง 3px + ระยะ 6px) ให้สองปุ่มกว้างเท่ากัน */
@media (max-width: 360px) { .calc-pill { width: 100%; } .calc-items-body > .calc-category ~ .calc-add-cat { width: calc(100% - 9px); margin-left: 9px; margin-right: 0; } }
.calc-pill:active:not(:disabled) { transform: scale(0.97); }
.calc-pill:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .calc-pill { transition: none; } .calc-pill:active:not(:disabled) { transform: none; } }
.calc-pill[hidden] { display: none; }
/* Primary: พื้นส้ม #F59E0B / ตัวอักษร Navy (ทุก Theme) */
.calc-add-cat { background: #F59E0B; border-color: #F59E0B; color: #0F172A; }
.calc-add-cat:hover:not(:disabled), .calc-add-cat:active:not(:disabled) { background: #D97706; border-color: #D97706; }
.calc-items-body > .calc-add-cat:first-child { margin-top: 0; }
/* Secondary: พื้นโปร่ง / กรอบส้ม / ตัวอักษรสีหลักของพื้นที่ (ขาวบน Navy-Dark) / เลข (n.m) สีส้ม */
.calc-add-sub { margin-top: 14px; background: transparent; border-color: var(--primary); color: var(--text); }
.calc-add-sub .calc-pill-no { color: var(--primary); }
/* ปุ่มงานย่อยอยู่ในหมวด (เส้นส้ม 3px + ระยะซ้าย) → เลื่อนซ้ายครึ่งหนึ่ง ให้กึ่งกลางตรงกับปุ่ม "เพิ่มหมวดงาน" (22 พ.ย. 2569)
   จอ ≤ 360px สองปุ่มกว้างเต็มและตรงแนวกันอยู่แล้ว → ไม่เลื่อน */
.calc-category .calc-add-sub { position: relative; left: -6.5px; }
@media (max-width: 479px) { .calc-items-card .calc-category .calc-add-sub { left: -4.5px; } }
@media (max-width: 360px) { .calc-items-card .calc-category .calc-add-sub { left: 0; } }
.calc-add-sub:hover:not(:disabled), .calc-add-sub:active:not(:disabled) { background: var(--primary-soft); }
/* ยังไม่มีชื่องาน: ข้อความแนะนำแทนปุ่ม "＋ เพิ่มหมวดงาน" — สูงเท่าปุ่ม (ไม่กระโดด) / สีข้อความรอง ไม่ใช่ error */
.calc-add-cat-hint { margin: 20px 0 0; min-height: 48px; padding: 10px 14px; display: flex; align-items: center; justify-content: center; text-align: center; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: 15px; line-height: 1.4; }
.calc-items-body > .calc-add-cat-hint:nth-child(2) { margin-top: 0; }
@media (max-width: 359px) { .calc-add-cat-hint { padding: 10px 6px; font-size: 14px; } } /* จอ 320px: ข้อความแนะนำบรรทัดเดียว สูงเท่าปุ่ม (ไม่กระโดด) */
.calc-add-cat-hint[hidden] { display: none; }
/* งานย่อย (SCOPE 3.2.3 แบบละเอียด): หัวงานย่อยใช้รูปแบบเดียวกับหัวหมวด (ป้าย "งาน 1.1" + ช่องชื่อ) */
.calc-subtask { margin-top: 14px; }
/* เยื้องเฉพาะหัวงานย่อย ("งาน 1.1") ให้เห็นว่าอยู่ใต้หมวด — วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น ด้านล่างไม่เยื้อง (ใช้แนวซ้ายเดิม) */
.calc-sub-head { margin-left: 14px; }
@media (min-width: 640px) { .calc-sub-head { margin-left: 24px; } }
.calc-category .calc-sub-body > .calc-group,
.calc-category .calc-legacy > .calc-group { margin-top: 10px; }
/* รายการเดิม (legacy): รายการของงานแบบละเอียดที่สร้างก่อนมีงานย่อย — แสดงแยกจากงานย่อย */
.calc-legacy { margin-top: 12px; }
.calc-legacy-title { font-size: 15px; font-weight: 700; margin: 0 2px; color: var(--text); }
/* รูปแบบรายการ (SCOPE 3.2.2): การ์ดเล็กเหนือ "รายละเอียดงาน" — Radio แบบง่าย / แบบละเอียด */
.item-mode .calc-card-body { padding: 12px 16px 14px; }
.item-mode-options { display: grid; gap: 6px; }
.item-mode-option { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 1.45; color: var(--text); cursor: pointer; }
.item-mode-option input { flex: 0 0 auto; width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--primary); }
.item-mode-option span { min-width: 0; }
.calc-new.is-disabled { opacity: 0.45; pointer-events: none; cursor: not-allowed; }

/* Guest (ยังไม่ล็อกอิน — SCOPE 2.0.1 / 11.9 ข้อ 5): หน้าแรกมีปุ่ม "เริ่ม/คำนวณต่อโดยไม่เข้าสู่ระบบ" / หน้าคำนวณ + ตั้งค่า มีเมนู งาน · ตั้งค่า / แถบบนมีปุ่มเข้าสู่ระบบ */
/* หน้าแรก (Welcome): ปุ่มหลัก Guest (ส้ม) → "หรือ" → Google (ขาว) → จุดเด่น 3 อย่าง — ปุ่มแคปซูล ข้อความ 2 บรรทัดกึ่งกลาง (21 พ.ย. 2569) */
.auth-welcome { max-width: 400px; padding: 32px 24px 24px; }
.auth-welcome .auth-tagline { margin: 4px 0 24px; }
.auth-cta {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; min-height: 58px; padding: 9px 20px; border-radius: 999px;
  font: inherit; text-align: center; text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.auth-cta-title { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.auth-cta-sub { font-size: 0.8125rem; font-weight: 500; line-height: 1.3; opacity: 0.85; }
.auth-cta-row { display: inline-flex; align-items: center; gap: 10px; }
.auth-cta:disabled { opacity: 0.6; cursor: default; }
/* ปุ่มหลัก Guest: ส้ม #F59E0B ตัวอักษร Navy ทุกธีม / เงาเล็กน้อย */
.auth-guest { background: #F59E0B; color: #0F172A; box-shadow: 0 6px 16px rgba(245, 158, 11, 0.28); }
.auth-guest:hover { background: #FBBF24; }
.auth-guest .auth-cta-sub { opacity: 0.8; }
/* ตัวคั่น "หรือ" */
.auth-or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 0.875rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
/* ปุ่ม Google: พื้นขาว น้ำหนักรองจาก Guest */
.auth-welcome .btn-google { background: #fff; color: #1F1F1F; border-color: #DADCE0; }
.auth-welcome .btn-google:hover:not(:disabled) { background: #F8F9FA; }
.auth-welcome .btn-google .auth-cta-sub { color: #5F6368; opacity: 1; }
.auth-welcome .error:empty { display: none; }
/* เข้าสู่ระบบจากเบราว์เซอร์ในแอป (LINE / Facebook ฯลฯ) → คำแนะนำให้เปิดใน Chrome / Safari */
.auth-inapp { margin: 12px 0 0; padding: 14px 16px; border: 1px solid var(--accent-line, #F59E0B); border-radius: 12px; background: var(--surface); text-align: left; font-size: 0.9375rem; line-height: 1.55; }
.auth-inapp[hidden], .auth-inapp-url[hidden] { display: none; }
.auth-inapp p { margin: 0 0 8px; }
.auth-inapp-title { font-weight: 700; font-size: 1rem; }
.auth-inapp-how { color: var(--muted); }
.auth-inapp-note { color: var(--danger); font-size: 0.875rem; }
.auth-inapp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.auth-inapp-actions .btn { flex: 1 1 160px; min-height: 44px; text-decoration: none; }
.auth-inapp-url { width: 100%; min-height: 44px; padding: 8px 12px; margin: 0 0 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg, transparent); color: var(--text); font: inherit; }
.auth-inapp-msg:empty { display: none; }
.auth-inapp-msg { color: var(--muted); font-size: 0.875rem; }
.auth-inapp-guest { color: var(--muted); font-size: 0.875rem; margin-bottom: 0 !important; }
.auth-welcome .error { margin: 10px 0 0; }
/* จุดเด่นด้านล่าง: ไอคอนเล็ก + ข้อความสั้น 3 ช่อง คั่นด้วยเส้นบาง */
.auth-feats { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); }
.auth-feats li { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 4px; color: var(--muted); font-size: 0.8125rem; font-weight: 500; line-height: 1.3; }
.auth-feats li + li { border-left: 1px solid var(--border); }
.auth-feat-icon { width: 22px; height: 22px; color: #F59E0B; }
html[data-theme="light"] .auth-feat-icon { color: #B45309; } /* ส้มเข้มบนการ์ดขาว อ่านชัด */
/* ลิงก์ข้อกำหนดการใช้งาน (terms.html) · นโยบายความเป็นส่วนตัว (privacy.html) ท้ายการ์ดหน้าแรก / ท้ายหน้าตั้งค่า — ตัวเล็ก สีรอง พื้นที่แตะสูง 44px */
.auth-legal { margin: 12px 0 -8px; text-align: center; font-size: 0.8125rem; }
.auth-legal a { display: inline-block; min-height: 44px; padding: 12px 8px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.auth-legal a:hover { color: var(--text); }
.auth-legal-sep { color: var(--muted); margin: 0 2px; }
.account-legal { margin: 20px 0 0; } /* ท้ายหน้าตั้งค่า (ทุกแท็บ) — ทางเข้าหลัง Login */
/* จอแคบ (≤ 360px): ลดขอบการ์ด / ปุ่ม ให้ข้อความรองอยู่บรรทัดเดียว ปุ่มไม่สูงเกิน */
@media (max-width: 360px) {
  .auth-welcome { padding: 28px 14px 20px; }
  .auth-cta { padding: 9px 12px; }
  .auth-cta-sub { font-size: 0.75rem; white-space: nowrap; }
  .auth-feats li { font-size: 0.75rem; }
}
.topbar-login { min-height: 36px; padding: 6px 14px; font-size: 14px; color: var(--text); text-decoration: none; white-space: nowrap; }

/* ---------- ชำระเงิน / บัญชี ---------- */
.center { text-align: center; }
.btn-lg { min-height: 48px; font-size: 1.05rem; }
.paywall .price { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 8px 0 4px; }
.paywall .price b { font-size: 2.5rem; color: var(--primary); line-height: 1; }
.paywall .price span { color: var(--muted); }
.features { list-style: none; padding: 0; margin: 16px 0 20px; text-align: left; }
.features li { padding: 6px 0 6px 28px; position: relative; }
.features li::before { content: "✓"; position: absolute; left: 4px; color: var(--pos); font-weight: 700; }
.signed-in { margin: 20px 0 0; }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.qr-box p { margin: 0; }
.qr { width: 240px; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--border); }
.qr-amount { font-size: 1.5rem; font-weight: 700; }
.pay-status { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 8px 0 !important; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pay-success { padding: 16px 0; }
.big-check { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--pos); color: #fff; font-size: 2rem; }

.warn-chip {
  font-size: 0.8rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
}
/* หน้าบัญชี (DESIGN: ผลรีวิวหน้าบัญชี รอบ 2) */
.profile { display: flex; align-items: center; gap: 12px; min-height: 72px; }
.profile-photo, .profile-initial { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.profile-initial { display: grid; place-items: center; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.profile-text { display: flex; flex-direction: column; min-width: 0; }
.profile-name { font-weight: 600; }
.profile-email { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-status { display: flex; flex-direction: column; }
.sub-label { font-size: 14px; color: var(--muted); }
.sub-date { font-size: 20px; font-weight: 700; line-height: 1.3; }
.sub-left { font-size: 14px; }
.sub-status.warn .sub-date, .sub-status.warn .sub-left { color: var(--neg); }
.renew-note { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.logout { display: block; margin: 16px auto 0; }

/* หน้าตั้งค่า: เมนู 2 รายการ (SCOPE 11.9) แบบ capsule / รายการที่เลือกพื้นส้ม
   ขนาดกระชับแบบ navigation (สูงรวม ~48px) ไอคอน + ข้อความบรรทัดเดียว / ปุ่มแต่ละอันสูง 40px ยังแตะง่ายบนมือถือ */
.account-tabs {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; /* 3 รายการ (SCOPE 11.10) */
  padding: 3px; margin-bottom: 16px;
  background: rgba(30, 41, 59, 0.85); border: 1px solid var(--border); border-radius: 12px;
}
.account-tab {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 6px 10px; border-radius: 9px; min-width: 0;
  text-decoration: none; color: #CBD5E1; font-size: 14px; font-weight: 500; text-align: center; white-space: nowrap;
}
.account-tab span { overflow: hidden; text-overflow: ellipsis; }
.account-tab svg { width: 18px; height: 18px; flex: 0 0 auto; }
.account-tab:hover { background: var(--surface-2); color: var(--text); }
.account-tab.active { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.account-tabs + .biz-section { margin-top: 0; }
@media (max-width: 380px) {
  .account-tab { gap: 6px; font-size: 13px; padding: 6px 6px; }
  .account-tab svg { width: 16px; height: 16px; }
}
/* มือถือ (< 600px): 3 รายการแคบเกินแถวเดียว → ไอคอนบน ข้อความล่าง ตัดคำได้ อ่านครบไม่ถูกตัด "…" */
@media (max-width: 599px) {
  .account-tab { flex-direction: column; gap: 3px; min-height: 52px; padding: 6px 4px; font-size: 12px; line-height: 1.25; white-space: normal; }
  .account-tab span { overflow: visible; text-overflow: clip; }
  .account-tab svg { width: 18px; height: 18px; }
}

/* ตั้งค่า → รูปแบบการแสดงผล: Theme เป็นการ์ดตัวเลือก (radio) เห็นชัด ไม่ใช่ dropdown (SCOPE 11.10) */
.theme-card { padding: 20px; }
.theme-title { font-size: 18px; font-weight: 700; margin: 0; }
.theme-note { margin: 4px 0 16px; }
.theme-options { display: grid; gap: 10px; }
@media (min-width: 768px) { .theme-options { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.theme-option {
  position: relative; display: flex; align-items: center; gap: 14px; cursor: pointer;
  padding: 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2);
}
@media (min-width: 768px) { .theme-option { flex-direction: column; align-items: flex-start; } }
.theme-option:hover { border-color: var(--muted); }
.theme-option.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.theme-option input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.theme-option:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.theme-swatch {
  flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 4px;
  width: 64px; height: 48px; padding: 6px; border-radius: 8px; border: 1px solid rgba(148, 163, 184, 0.45);
}
@media (min-width: 768px) { .theme-swatch { width: calc(100% - 34px); height: 64px; } }
.theme-swatch i { border-radius: 4px; }
.theme-swatch i:first-child { grid-column: 1 / -1; }
.theme-swatch i:last-child { width: 60%; justify-self: end; background: #F59E0B; }
.theme-swatch-navy { background: #0F172A; } .theme-swatch-navy i:not(:last-child) { background: #1E293B; }
.theme-swatch-light { background: #0F172A; } .theme-swatch-light i:not(:last-child) { background: #FFFFFF; } /* พื้น Navy + การ์ดขาว */
.theme-swatch-light i:last-child { background: #2563EB; }
.theme-swatch-dark { background: #07090E; } .theme-swatch-dark i:not(:last-child) { background: #121821; }
.theme-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.theme-name { font-size: 16px; font-weight: 700; color: var(--text); }
.theme-tag { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.theme-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }
.theme-check {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted);
  display: grid; place-items: center;
}
@media (min-width: 768px) { .theme-check { position: absolute; top: 12px; right: 12px; } }
.theme-option.is-selected .theme-check { border-color: var(--primary); background: var(--primary); }
.theme-option.is-selected .theme-check::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid var(--primary-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}

/* พื้นหลังเฉพาะหน้าตั้งค่า: ทับลาย Blueprint ให้จางลงอีกชั้น (หน้าอื่นไม่เปลี่ยน) ให้การ์ดและตัวเลขอ่านง่ายขึ้น */
.account-page::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: rgba(15, 23, 42, 0.62);
}

/* แพ็กเกจและเครดิต: การ์ดเดียว — แพ็กเกจปัจจุบัน → ใช้งานได้ถึง → เหลือกี่วัน → ต่ออายุ */
.plan-card { padding: 20px; }
.plan-head { display: flex; flex-direction: column; gap: 4px; }
.plan-label { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.plan-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.plan-name { font-size: 22px; line-height: 1.3; color: var(--text); }
.plan-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--pos); background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.35);
}
.plan-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.plan-badge.is-off { color: var(--neg); background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.35); }
.plan-status { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: rgba(15, 23, 42, 0.55); border: 1px solid var(--border); }
.plan-status .sub-status { gap: 2px; }
.plan-status .sub-date { font-size: 18px; }
.plan-status .sub-left { color: var(--primary); font-weight: 600; }
.plan-status .sub-status.warn .sub-left { color: var(--neg); }
.plan-renew { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.plan-renew .renew-note { margin-bottom: 10px; }
/* ปุ่มต่ออายุ: ยังเด่นและแตะง่าย แต่ไม่ใหญ่เท่าแบนเนอร์ (ข้อความ / การทำงานของ paymentBox เดิม) */
.plan-renew .btn-lg { min-height: 46px; font-size: 1rem; }
@media (min-width: 768px) {
  .plan-renew .btn-block { width: auto; min-width: 280px; padding-left: 24px; padding-right: 24px; }
}

/* ข้อมูลกิจการ (หน้าบัญชี) — ตามแบบ: การ์ดฟอร์ม 2 คอลัมน์ + การ์ดตัวอย่างหัวใบเสนอราคา */
.biz-section { margin-top: 24px; }
.biz-card .req { color: var(--primary); }
.biz-card .field > span { font-weight: 600; }
@media (min-width: 768px) {
  .biz-card input, .biz-card textarea { font-size: 15px; min-height: 44px; padding: 8px 12px; }
  .biz-card .biz-icon-input input { font-size: 14px; padding-left: 36px; padding-right: 8px; }
  .biz-card .biz-icon-input svg { left: 11px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .biz-card .biz-row2 { grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr); gap: 0 10px; }
  .biz-card .biz-icon-input input { font-size: 13px; padding-left: 32px; padding-right: 6px; }
  .biz-card .biz-icon-input svg { left: 9px; width: 16px; height: 16px; }
}
.biz-card, .biz-preview-card { padding: 20px; }
.biz-preview-card { margin-top: 16px; }
.biz-head { display: flex; gap: 14px; align-items: center; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.biz-head-icon { color: var(--primary); flex: 0 0 auto; }
.biz-head-icon svg { width: 40px; height: 40px; display: block; }
.biz-title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.biz-title span { font-weight: 400; }
.biz-form input, .biz-form input[inputmode] { text-align: left; }
/* Guest (SCOPE 11.9 ข้อ 5): ช่อง / ปุ่ม disabled ไม่รับการแตะ → ให้การแตะไปถึงฟอร์ม แล้วเปิด Modal ชวนเข้าสู่ระบบ */
.biz-form-ro :disabled { pointer-events: none; }
.biz-form-ro .field, .biz-form-ro .biz-logo-edit, .biz-form-ro .biz-save { cursor: pointer; }
.biz-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 24px; }
.biz-col-side { border-left: 1px solid var(--border); padding-left: 24px; min-width: 0; }
.biz-col-main { min-width: 0; }
.biz-row2 { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 0 14px; }
.biz-icon-input { position: relative; display: block; }
.biz-icon-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.biz-icon-input input { width: 100%; padding-left: 40px; }
.biz-logo-edit { display: flex; align-items: flex-start; gap: 16px; }
.biz-logo { flex: 0 0 auto; width: 140px; height: 140px; display: grid; place-items: center; background: #fff; border-radius: 12px; overflow: hidden; padding: 10px; }
.biz-logo img { width: 100%; height: 100%; object-fit: contain; }
.biz-logo-empty { background: transparent; border: 1px dashed var(--border); color: var(--primary); }
.biz-logo-empty svg { width: 36px; height: 36px; }
.biz-logo-actions { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.biz-logo-actions .btn { gap: 8px; justify-content: center; white-space: nowrap; padding-left: 12px; padding-right: 12px; }
.biz-logo-actions .btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.biz-logo-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.biz-note-field { border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 0; }
.biz-label-note { font-weight: 400; color: #CBD5E1; font-size: 13px; }
.biz-save { margin-top: 18px; }
.field-error { color: var(--neg) !important; }
/* ตัวอย่างหัวใบ: กระดาษขาว ขอบล่างแบบฉีก */
.biz-preview-title { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.biz-preview-title svg { width: 28px; height: 28px; flex: 0 0 auto; }
.biz-paper {
  background: #fff; color: #0F172A; border-radius: 10px 10px 0 0; padding: 20px 24px 28px; margin: 0 8px; /* คอม: โค้งมุมบนซ้าย-ขวา / มือถือ: บนซ้ายมุมเดียว (26 พ.ย. 2569) */
  /* ขอบล่างเป็นคลื่นแบบกระดาษฉีก */
  --tear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 12' preserveAspectRatio='none'%3E%3Cpath d='M0 0H40V6Q35 12 30 6T20 6T10 6T0 6Z'/%3E%3C/svg%3E");
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 11px) no-repeat, var(--tear) bottom left / 40px 12px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 11px) no-repeat, var(--tear) bottom left / 40px 12px repeat-x;
}
.biz-paper-head { display: flex; align-items: center; gap: 22px; }
.biz-paper-logo { flex: 0 0 auto; width: 120px; height: 120px; display: grid; place-items: center; } /* ไม่มีเส้นคั่น — เหมือนใบจริง (26 พ.ย. 2569) */
.biz-paper-logo img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.biz-paper-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.biz-name { font-size: 22px; line-height: 1.35; font-weight: 700; }
.biz-sep { margin: 0 8px; color: #94A3B8; }
.biz-nowrap { white-space: nowrap; } /* เบอร์โทร / เลขผู้เสียภาษีไม่ตัดกลางคำ */
.biz-paper-line { height: 0; margin-top: 14px; border-top: 2px solid #0F172A; } /* เส้นคั่นใต้หัวใบ แบบเดียวกับใบจริง (ไม่มีกรอบขีดลง) */
.biz-paper-empty { margin: 0; color: #64748B; font-size: 14px; }
@media (max-width: 760px) {
  .biz-cols { grid-template-columns: minmax(0, 1fr); }
  .biz-col-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
}
@media (max-width: 480px) {
  .biz-card, .biz-preview-card { padding: 16px; }
  .biz-head-icon svg { width: 32px; height: 32px; }
  .biz-title { font-size: 18px; }
  .biz-row2 { grid-template-columns: minmax(0, 1fr); }
  .biz-logo { width: 120px; height: 120px; }
  .biz-paper { padding: 16px 16px 24px; margin: 0; border-radius: 10px 0 0 0; }
  /* มือถือ: โลโก้อยู่ซ้ายข้อความ (แบบเดียวกับใบจริง — ปรับ 26 พ.ย. 2569 เดิมเรียงลงล่าง) */
  .biz-paper-head { gap: 12px; }
  .biz-paper-logo { width: 72px; height: 72px; }
  .biz-paper-text { font-size: 13px; line-height: 1.45; }
  .biz-name { font-size: 17px; }
}

/* ---------- หน้าคำนวณงาน ---------- */
/* ท้ายหน้า: ใช้ระยะเว้นเมนูล่างของ main อย่างเดียว (ดูหมายเหตุที่ .calc-total) */
.calc-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.calc-head .page-title { margin-bottom:2px; }
/* หัวข้อหน้าคำนวณ: แถบสีด้านซ้าย (สีเดียวกับหัว Section --accent-line) */
.calc-head .page-title { position: relative; padding-left: 16px; font-size: 24px; line-height: 1.3; }
.calc-head .page-title::before { content: ""; position: absolute; left: 0; top: 0.2em; bottom: 0.2em; width: 5px; border-radius: 3px; background: var(--accent-line); }
.calc-guest-new { flex: 0 0 auto; white-space: nowrap; order: 3; } /* Guest "เริ่มงานใหม่" (SCOPE 2.0.1) ไม่ตัดบรรทัดบนจอแคบ */
/* รูปแบบรายการ (SCOPE 3.2.2) อยู่ในแถวหัวหน้า: จอกว้าง = ขวาของหัวข้อ / จอแคบ = บรรทัดใหม่ใต้หัวข้อ เต็มความกว้าง */
.calc-head { flex-wrap: wrap; }
.calc-head > div:first-child { flex: 1 1 0; min-width: 0; }
.calc-head .item-mode { order: 2; flex: 0 1 auto; max-width: 420px; margin: 0; }
/* จอแคบ: ย่อเป็นปุ่มสลับ 2 ช่อง ขวาของหัวข้อ (ซ่อนคำอธิบาย / radio จริงยังอยู่ — กดได้ด้วยคีย์บอร์ด) */
@media (max-width: 639px) {
  .calc-head { column-gap: 8px; }
  .calc-head > div:first-child { flex: 1 0 auto; } /* หัวข้อไม่ตัดบรรทัด — ที่ไม่พอ → ปุ่มสลับลงบรรทัดใหม่แทน */
  .calc-head .page-title { font-size: 22px; white-space: nowrap; }
  .calc-page .calc-head .item-mode.calc-card { order: 2; flex: 0 0 auto; align-self: flex-end; max-width: none; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; }
  /* Guest: "เริ่มงานใหม่" ขึ้นไปอยู่ขวาของแถวลิงก์กลับ → ปุ่มสลับอยู่ขวาของหัวข้อเหมือนบัญชีที่ล็อกอิน (ปรับ 26 พ.ย. 2569) */
  .calc-head:has(.calc-guest-new) { position: relative; }
  .calc-head .calc-guest-new { position: absolute; top: 2px; right: 0; min-height: 38px; }
  .calc-head:has(.calc-guest-new) .page-title { margin-top: 10px; } /* เว้นให้ปุ่มสลับ (ชิดล่าง) ไม่ชนปุ่มเริ่มงานใหม่ */
  .calc-head .item-mode .calc-card-body { padding: 0; }
  .calc-head .item-mode-options { display: flex; gap: 0; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  .calc-head .item-mode-option { position: relative; align-items: center; min-height: 40px; padding: 0 10px; border-radius: 9px; font-size: 13px; white-space: nowrap; }
  .calc-head .item-mode-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
  /* ช่องที่เลือก = พื้นสีหลักของธีม + ✓ / ช่องที่ไม่เลือก = ตัวหนังสือเทาจาง ไม่มีพื้น (27 พ.ย. 2569 — เดิมพื้นขาวทั้งคู่ดูเด่นพอกัน งงว่าเลือกอันไหน) */
  .calc-head .item-mode-option { color: var(--muted); }
  .calc-head .item-mode-option b { font-weight: 600; }
  .calc-head .item-mode-option:has(input:checked) { background: var(--primary); color: var(--primary-ink); }
  .calc-head .item-mode-option:has(input:checked) b { font-weight: 700; }
  .calc-head .item-mode-option:has(input:checked) b::before { content: "✓ "; }
  .calc-head .item-mode-option:has(input:focus-visible) { outline: 2px solid var(--muted); outline-offset: 1px; }
  .calc-head .item-mode-desc { display: none; }
}
.calc-card, .calc-group, .calc-summary { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); margin-top:12px; padding:14px; }
.calc-card .field { margin-bottom:12px; }.calc-card .field:last-child { margin-bottom:0; }
.calc-group { padding:0; overflow:hidden; }.calc-group-head { display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--border); }.calc-group-head h2 { font-size:1rem; }
.calc-rows { padding:8px; }.calc-row { padding:10px 6px 12px; border-bottom:1px solid var(--border); }.calc-row:last-child { border-bottom:0; }
.calc-row-top { display:flex; gap:6px; align-items:center; }.calc-row-top input { font-weight:600; }.calc-remove { flex:0 0 40px; color:var(--muted); }
.calc-inputs { display:grid; grid-template-columns:1fr .75fr 1.2fr; gap:6px; margin-top:6px; }.calc-inputs input { min-width:0; }
.calc-line { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:5px; padding:0 2px; }.calc-line b { white-space:nowrap; }.calc-empty { padding:8px 6px; margin:0; }.calc-add { margin-top:12px; }
.calc-summary { padding:0; overflow:hidden; }.calc-total { display:flex; justify-content:space-between; align-items:center; padding:14px; font-size:1.05rem; }.calc-total b { font-size:1.25rem; }
.profit-line { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 14px; border-top:1px solid var(--border); }.profit-buttons { display:flex; gap:5px; flex-wrap:wrap; justify-content:flex-end; }
.profit-btn { border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:999px; min-height:36px; padding:5px 11px; font:inherit; font-weight:600; cursor:pointer; }.profit-btn.active { background:var(--text); color:var(--bg); border-color:var(--text); }
.profit-input { width:64px !important; min-height:36px !important; padding:6px 8px !important; }.sell-field { padding:12px 14px 4px; margin:0; border-top:1px solid var(--border); }.sell-field input { font-size:1.15rem; font-weight:700; }
.calc-kpi { display:flex; align-items:baseline; gap:8px; padding:14px; background:var(--primary-soft); }.calc-kpi b { font-size:1.5rem; color:var(--pos); }.calc-kpi small { color:var(--muted); margin-left:auto; }.calc-kpi.loss { background:color-mix(in srgb, var(--neg) 9%, var(--surface)); }.calc-kpi.loss b { color:var(--neg); }
.calc-quote { margin-top:12px; min-height:54px; font-size:1.05rem; }.calc-note { text-align:center; margin:8px 0 0; }
.page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:12px; }.page-head .btn { white-space:nowrap; }
@media (max-width:420px) { .calc-inputs { grid-template-columns:.9fr .65fr 1.15fr; }.profit-line { align-items:flex-start; flex-direction:column; }.profit-buttons { width:100%; justify-content:flex-start; }.calc-kpi { flex-wrap:wrap; }.calc-kpi small { margin-left:0; width:100%; } }

/* ---------- ปรับเพิ่ม: รายการงาน / ปุ่มเพิ่มรายการต่อหมวด ---------- */
.calc-new { margin-bottom: 8px; }
.calc-add-row { border-radius: 0; border-width: 1px 0 0; min-height: 48px; color: var(--primary); }
.badge-draft { background: var(--surface-2); color: var(--muted); }
.badge-issued { background: rgba(52, 211, 153, 0.15); color: var(--pos); }

/* ---------- หน้าคำนวณ: สรุปราคา + แถบสรุปด้านล่างจอ (แก้จากรีวิวหน้าจริง) ---------- */
/* ท้ายหน้าคำนวณ: เว้นที่เมนูล่างมาจาก main แล้ว (ไม่ซ้อนเพิ่ม — ปรับ 25 พ.ย. 2569) / แถบสรุป + ปุ่มลอยซ่อนตอนเห็นการ์ดสรุป จึงไม่บังของท้ายหน้า */
.calc-total { padding: 12px 16px; font-size: 16px; }
.calc-total b { font-size: 20px; font-weight: 700; }            /* Number-L */
.profit-line { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 16px; }
.profit-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.profit-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; width: 100%; }
.profit-btn { background: transparent; border-color: var(--border); color: var(--text); min-height: 40px; padding: 6px 14px; }
.profit-btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.profit-custom { display: flex; align-items: center; gap: 8px; }
.profit-custom[hidden] { display: none; }
.profit-custom input { max-width: 140px; font-weight: 600; }
.profit-custom span { color: var(--muted); }
.sell-field { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; margin: 0; border-top: 1px solid var(--border); }
.sell-field > span { font-size: 14px; font-weight: 500; color: var(--muted); }
.money-input { position: relative; display: block; }
.money-input > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; font-weight: 700; pointer-events: none; }
.money-input input { padding-left: 34px; font-size: 20px; font-weight: 700; }
.calc-kpi { flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 12px 16px 14px; background: transparent; border-top: 1px solid var(--border); }
.calc-kpi > span { font-size: 16px; font-weight: 500; }
.calc-kpi b { font-size: 28px; font-weight: 700; line-height: 1.2; color: var(--pos); }   /* Number-XL */
.calc-kpi small { width: 100%; margin-left: 0; color: var(--muted); font-size: 14px; }
.calc-kpi.loss { background: rgba(248, 113, 113, 0.08); }
.calc-kpi.loss b, .calc-kpi.loss > span { color: var(--neg); }

.calc-sticky {
  position: fixed; z-index: 9; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  width: min(720px, 100%) ; max-width: calc(100% - 16px);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 8px 12px; border-radius: 14px; cursor: pointer;
  font: inherit; color: var(--text); text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.6);
  transition: opacity 0.15s, transform 0.15s;
}
.calc-sticky span { display: flex; flex-direction: column; min-width: 0; }
.calc-sticky small { font-size: 12px; color: var(--muted); }
.calc-sticky b { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calc-sticky.is-hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 8px); }
@media (prefers-reduced-motion: reduce) { .calc-sticky { transition: none; } }

/* แถวรายการ: ชื่อรายการขึ้นบรรทัดเองเมื่อยาว / ช่องหน่วยกว้างพอไม่ตัดคำ */
.calc-name {
  font: inherit; font-size: 16px; font-weight: 600; line-height: 1.4;
  resize: none; overflow: hidden; min-height: 48px; padding: 12px;
}
.calc-inputs,
.calc-row .calc-inputs { grid-template-columns: minmax(0, 0.9fr) minmax(84px, 0.9fr) minmax(0, 1.3fr); }
@media (max-width: 420px) {
  .calc-inputs { grid-template-columns: minmax(0, 0.9fr) minmax(84px, 0.9fr) minmax(0, 1.3fr); }
}
.calc-unit { padding-left: 10px; padding-right: 10px; }
.calc-unit[readonly] { cursor: pointer; caret-color: transparent; }
/* แผ่นเลือกหน่วย (จอสัมผัส) — ขึ้นจากด้านล่างแบบ popup อื่นของแอป */
.unit-sheet .modal-body { padding: 8px 18px max(18px, env(safe-area-inset-bottom)); }
.unit-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.unit-chip, .unit-custom {
  min-height: 48px; padding: 6px 4px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
}
/* ปุ่มหน่วย: ไม้โทของ "ต้น" ที่ 17px หนา 600 เล็กจนดูเป็น "ตัน" บนจอความละเอียดต่ำ → ตัวบางลง + ใหญ่ขึ้น (ความสูงปุ่มเท่าเดิม) */
.unit-chip { font-size: 19px; font-weight: 500; line-height: 1.5; }
.unit-chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.unit-custom { width: 100%; margin-top: 12px; background: transparent; border-style: dashed; color: var(--muted); font-weight: 500; }
@media (max-width: 340px) { .unit-chips { grid-template-columns: repeat(3, 1fr); } }
/* กล่องเลือกหน่วยใต้ช่อง (จอคอม) */
.unit-pop {
  position: fixed; z-index: 45; width: 300px; max-width: calc(100vw - 16px);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); animation: fade 0.12s ease-out;
}
.unit-pop[hidden] { display: none; }
.unit-pop .unit-chip { min-height: 38px; font-size: 17px; border-radius: 10px; }
.unit-pop .unit-chip:hover, .unit-pop .unit-chip.hi { border-color: var(--primary); }
.unit-pop .unit-chip.hi { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .unit-pop { animation: none; } }

/* ---------- ตัวเลขชิดขวาทั้งระบบ (DESIGN 3) ---------- */
/* ช่องกรอกตัวเลข */
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"] { text-align: right; }
/* ช่องตัวเลข (เช่น ราคาต่อหน่วย): ไม่แสดงปุ่มขึ้น-ลงของเบราว์เซอร์ — พิมพ์ตัวเลขเอง (21 พ.ย. 2569) */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* กล่องกำไร: ป้ายซ้าย ตัวเลขขวา */
.calc-kpi { display: grid; grid-template-columns: auto 1fr; align-items: baseline; }
.calc-kpi b { justify-self: end; text-align: right; }
.calc-kpi small { grid-column: 1 / -1; text-align: right; }

/* แถบสรุปด้านล่างจอ */
.calc-sticky span { align-items: flex-end; text-align: right; }

/* การ์ดรายการงาน: ป้ายเหนือตัวเลข ชิดขวาทุกช่อง */
.job-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.job-nums span { display: flex; flex-direction: column; align-items: flex-end; text-align: right; min-width: 0; }
.job-nums small { font-size: 12px; color: var(--muted); }
.job-nums b { font-size: 16px; font-weight: 600; white-space: nowrap; }

/* ---------- หน้าคำนวณ: Visual Hierarchy ของหัวข้อหมวด / label / ค่าที่กรอก ---------- */
/* ระยะห่างระหว่าง section ให้ชัด */
.calc-card, .calc-group, .calc-summary { margin-top: 20px; }
.calc-card { padding: 0; overflow: hidden; }
.calc-card-body { padding: 12px 16px 16px; }

/* 1. หัวข้อหมวด: รายละเอียดงาน / วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น / สรุป */
.calc-group-head { padding: 14px 16px 12px; }
.calc-group-head h2 { font-size: 18px; font-weight: 700; line-height: 1.3; color: #F1F5F9; letter-spacing: 0.01em; }
/* หัวข้อใต้งานย่อย: "(ชื่องานย่อย)" ตัวจางต่อท้าย (SCOPE 3.2.3 ข้อ 21) */
.calc-group-of { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; overflow-wrap: anywhere; }
.calc-group-of[hidden] { display: none; }

/* 2. Label ของข้อมูล: ชื่องาน / ลูกค้า */
.calc-card .field > span { font-size: 14px; font-weight: 600; color: #CBD5E1; }

/* 3. ค่าที่ผู้ใช้กรอก: 16px สีขาว ไม่หนาเกินไป */
.calc-card input, .calc-name, .calc-inputs input { font-size: 16px; font-weight: 500; color: var(--text); }

/* ---------- Micro-interaction: ตัวเลขในกล่องสรุปตอบสนองเมื่อค่าเปลี่ยนจริง ----------
   class ใส่ชั่วคราวจาก JS (changePop ใน ui.js) แล้วถอดออกเมื่อจบ / ใช้ transform จึงไม่ดันตำแหน่งองค์ประกอบอื่น */
@keyframes price-pop {
  0%   { transform: scale(1);    opacity: 0.85; }
  40%  { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
@keyframes profit-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.price-pop  { animation: price-pop 260ms ease-out; }
.profit-pop { animation: profit-pop 320ms ease-out; transform-origin: right center; }
@media (prefers-reduced-motion: reduce) {
  .price-pop, .profit-pop { animation: none; }
}

/* ---------- ราคาที่เสนอรายรายการ ---------- */
.row-sell { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.row-sell-label { font-size: 14px; font-weight: 500; color: #CBD5E1; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag-manual {
  font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px;
  color: var(--primary); background: var(--primary-soft); border: 1px solid rgba(245, 158, 11, 0.35);
}
.tag-manual[hidden] { display: none; }
.money-sm { flex: 0 0 46%; }
.money-sm > span { font-size: 16px; font-weight: 600; left: 10px; }
.money-sm input { padding-left: 28px; font-size: 16px; font-weight: 600; }
.sell-total { border-top: 1px solid var(--border); }
.sell-total b { font-size: 20px; font-weight: 700; }   /* Number-L */

/* ยอดของแต่ละรายการ: "ราคาในใบเสนอ" + ตัวเลข / บรรทัดเล็ก "ทุน ฿x" ด้านล่าง */
.line-label { font-size: 14px; font-weight: 500; color: #CBD5E1; }
.line-cost { margin-top: 2px; padding: 0 2px; }

/* ป้าย "ราคาที่เสนอ/หน่วย [ปรับเอง]" และกำไรของรายการอยู่ใต้ป้าย */
.row-sell-label { flex-direction: column; align-items: flex-start; gap: 2px; }
.row-sell-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-sell-pct { font-size: 12px; font-weight: 500; color: var(--muted); }
.row-sell-pct:empty { display: none; }
.row-sell-pct.neg { color: var(--neg); }

/* ป้าย "ปรับเอง ✕" กับ % กำไรของรายการอยู่บรรทัดเดียวกัน (% ต่อท้ายป้าย) ทุกขนาดจอ — ปรับ 21 พ.ย. 2569 */
.row-sell-label { flex-direction: row; align-items: center; gap: 6px; }
.row-sell-badge { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
.row-sell-badge > * { white-space: nowrap; } /* จอแคบมากจนไม่พอ → % ลงบรรทัดใต้ป้ายทั้งก้อน ไม่ตัดกลางคำ ไม่บีบช่องราคา */

/* "ทุน x" ชิดขวาใต้ราคาในใบเสนอ (ตัวเลขชิดขวาทั้งระบบ) */
.line-cost { text-align: right; }

/* ช่องราคาที่เสนอ/หน่วย ไม่มี ฿ นำหน้าแล้ว */
.money-sm input { padding-left: 12px; }

/* กล่องกำไร: % อยู่ต่อจากคำว่า กำไร / บรรทัดหมายเหตุแสดงเฉพาะตอนขาดทุน */
.calc-kpi small:empty { display: none; }

/* ---------- Modal ยืนยัน (แทน confirm ของเบราว์เซอร์) ---------- */
/* กลางจอทุกขนาด มุมโค้งครบ เว้นขอบข้างละ 16px (คำเตือนเด่น ไม่ดูเป็นส่วนหนึ่งของหน้า) */
.modal-backdrop-center { align-items: center; padding: 16px; }
:is(.modal-confirm, .mode-pick) { max-width: 400px; border-radius: 20px; animation: pop 0.18s ease-out; }
:is(.modal-confirm, .mode-pick) .modal-body { padding: 20px 20px 8px; }
:is(.modal-confirm, .mode-pick) h2 { font-size: 18px; font-weight: 700; }
:is(.modal-confirm, .mode-pick) p { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.modal-confirm .modal-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 0; padding: 16px 20px 20px; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .modal-confirm, .mode-pick { animation: none; } }
.modal-confirm .modal-foot .btn { min-width: 0; }
.modal-confirm .modal-foot .btn:only-child { grid-column: 1 / -1; } /* กล่องแจ้งเตือนปุ่มเดียว → เต็มความกว้าง */
/* งานใหม่: เลือกรูปแบบรายการ (แตะการ์ด = เลือก) — ทุกขนาดจอ */
.mode-pick .modal-body { padding-bottom: 20px; }
.mode-pick-options { display: grid; gap: 10px; margin-top: 16px; text-align: left; }
.mode-pick-opt {
  display: grid; gap: 2px; width: 100%; min-height: 44px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.mode-pick-opt b { font-size: 17px; font-weight: 700; }
.mode-pick-opt small { font-size: 13px; color: var(--muted); }
/* โครงสร้างเป็นกล่องขั้น / "งานย่อย" = กล่องสีส้ม (จุดต่างของ 2 แบบ) */
.mode-pick-opt { padding-left: 14px; padding-right: 14px; }
.mp-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 6px 0 4px; }
.mp-step { font-style: normal; font-size: 14px; font-weight: 600; line-height: 1.3; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); white-space: nowrap; }
.mp-step-hi { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
/* สีประจำขั้น: หมวดงาน = ฟ้า / รายการ = เขียว (พื้นจาง) / งานย่อย = ส้มทึบ (เด่นสุด) */
.mp-step-cat { background: rgba(59, 130, 246, 0.2); border-color: rgba(96, 165, 250, 0.7); color: #BFDBFE; }
.mp-step-item { background: rgba(52, 211, 153, 0.16); border-color: rgba(52, 211, 153, 0.65); color: #A7F3D0; }
html[data-theme="light"] .mp-step-cat { background: #DBEAFE; border-color: #93C5FD; color: #1D4ED8; }
html[data-theme="light"] .mp-step-item { background: #D1FAE5; border-color: #6EE7B7; color: #047857; }
.mp-arrow { font-style: normal; color: var(--muted); font-size: 14px; }
.mode-pick:focus { outline: none; }
.mode-pick-opt.current { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.mode-pick-opt:hover, .mode-pick-opt:active { border-color: var(--primary); }
.mode-pick-opt:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
/* modal ยืนยัน (23 พ.ย. 2569): หัวข้ออยู่กลาง / กล่องเด่นจากหน้าหลัก — ฉากหลังมืดขึ้น + เบลอ, พื้นกล่องยกขึ้น, ขอบทองบาง + เงา */
.modal-backdrop-center { background: rgba(2, 6, 14, 0.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
:is(.modal-confirm, .mode-pick) { background: var(--surface-2); border: 1px solid rgba(245, 160, 0, 0.45); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6); }
:is(.modal-confirm, .mode-pick) .modal-body { text-align: center; }
html[data-theme="light"] .modal-backdrop-center { background: rgba(15, 23, 42, 0.5); }
html[data-theme="light"] :is(.modal-confirm, .mode-pick) { background: #FFFFFF; border-color: rgba(217, 119, 6, 0.5); box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35); }
.btn-danger { background: var(--danger); color: var(--primary-ink); }
.btn-danger:hover { background: #EF4444; }

/* ช่อง จำนวน / หน่วย / ทุน/หน่วย: ป้ายเล็กเหนือช่อง ช่องเตี้ยลง ตัวอักษรในช่องยังเป็น 16px */
.mini-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-field > span { font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 2px; }
.mini-field.num > span { text-align: right; }   /* ป้ายของช่องตัวเลขชิดขวาตามตัวเลข */
.calc-inputs .mini-field input { min-height: 40px; padding: 6px 10px; font-size: 16px; }

/* ช่องหน่วย: ป้ายและข้อความชิดขวาเหมือนช่องอื่นในแถว */
.calc-inputs .mini-field > span { text-align: right; }
.calc-inputs .calc-unit { text-align: right; }

/* ---------- พื้นหลังภาพเครื่องมือช่าง: เฉพาะหน้าล็อกอิน / ชำระเงิน (DESIGN 2.1) ----------
   ชั้นบน = Navy ทับ 72% ให้การ์ดอ่านง่าย / หน้าทำงาน (งาน, คำนวณ, บัญชี) ไม่ใช้ภาพนี้ */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.72)),
    url("../img/bg-tools-sm.webp?v=2") center / cover no-repeat,
    var(--bg);
}
/* จอคอม/แท็บเล็ต: ภาพแนวตั้ง (3:4) วางเต็มความสูงกลางจอ ไม่ยืดไม่แตก
   ขอบซ้ายขวาของภาพไล่จางกลืนกับพื้น Navy */
@media (min-width: 768px) {
  .auth {
    background:
      linear-gradient(rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.72)),
      linear-gradient(90deg, var(--bg) 0, rgba(15, 23, 42, 0) 18%, rgba(15, 23, 42, 0) 82%, var(--bg) 100%)
        center top / calc(100vh * 0.75) 100vh no-repeat,
      url("../img/bg-tools.webp?v=2") center top / calc(100vh * 0.75) 100vh no-repeat,
      var(--bg);
  }
}

/* ---------- พื้นหลังภาพเครื่องมือช่าง: ใช้ทุกหน้า (เจ้าของงานเลือก 17 พ.ย. 2569) ----------
   แทนลายตาราง CSS + ลายน้ำบ้าน (ในภาพมีลายแบบงานและรูปบ้านอยู่แล้ว)
   ใช้ position: fixed ของ ::before (ไม่ใช้ background-attachment: fixed ซึ่ง iPhone ไม่รองรับ) ภาพจึงอยู่กับที่ตอนเลื่อนจอ */
body::before {
  background:
    linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.75)),
    url("../img/bg-tools-sm.webp?v=2") center / cover no-repeat,
    var(--bg);
  -webkit-mask-image: none;
  mask-image: none;
}
body::after { display: none; }
.auth { background: transparent; }   /* หน้าล็อกอิน/ชำระเงินใช้พื้นหลังเดียวกับทุกหน้า */
@media (min-width: 768px) {
  body::before {
    background:
      linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.75)),
      linear-gradient(90deg, var(--bg) 0, rgba(15, 23, 42, 0) 18%, rgba(15, 23, 42, 0) 82%, var(--bg) 100%)
        center top / calc(100vh * 0.75) 100vh no-repeat,
      url("../img/bg-tools.webp?v=2") center top / calc(100vh * 0.75) 100vh no-repeat,
      var(--bg);
  }
}

/* แถบไล่สีเข้มด้านบนจอ: หัวข้อหน้า / ลิงก์กลับ / คำโปรย อยู่บนภาพโดยตรง จึงต้องเข้มขึ้นให้อ่านชัด
   (เข้ม 92% ที่ขอบบน แล้วจางหายภายใน 300px ส่วนล่างยังเห็นภาพเหมือนเดิม) */
body::before {
  background:
    linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
    linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.75)),
    url("../img/bg-tools-sm.webp?v=2") center / cover no-repeat,
    var(--bg);
}
@media (min-width: 768px) {
  body::before {
    background:
      linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
      linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.75)),
      linear-gradient(90deg, var(--bg) 0, rgba(15, 23, 42, 0) 18%, rgba(15, 23, 42, 0) 82%, var(--bg) 100%)
        center top / calc(100vh * 0.75) 100vh no-repeat,
      url("../img/bg-tools.webp?v=2") center top / calc(100vh * 0.75) 100vh no-repeat,
      var(--bg);
  }
}

/* =====================================================================
   Desktop / PC (≥1024px) — Web App layout
   มือถือ (<768px) และแท็บเล็ต (768–1023px) ไม่ถูกแตะ ทุกกฎด้านล่างอยู่ใน min-width: 1024px
   ยกเว้น .topnav ที่ซ่อนไว้นอกช่วงนี้ (เป็น element ใหม่ ไม่มีผลกับ layout มือถือ)
   ===================================================================== */
.topnav { display: none; }

@media (min-width: 1024px) {
  :root { --content-w: 1100px; }

  /* แถบบน: สูง 64px โลโก้ซ้าย เมนูขวา ขอบตรงกับเนื้อหา */
  .topbar {
    min-height: 64px;
    padding: 8px max(24px, calc((100% - var(--content-w)) / 2));
  }
  .topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
  .topnav a {
    display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px;
    border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 500;
  }
  .topnav a svg { width: 20px; height: 20px; }
  .topnav a:hover { background: var(--surface-2); color: var(--text); }
  .topnav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
  .topbar .warn-chip { margin-left: 12px; }
  .topbar-actions { margin-left: 16px; }

  /* ไม่มีเมนูล่างแบบมือถือบนจอคอม */
  .bottomnav { display: none; }

  /* เนื้อหา: กว้างสูงสุด 1100px กลางจอ อยู่ในแผงเดียว */
  main {
    max-width: none;
    width: min(100% - 48px, var(--content-w));
    padding-bottom: 48px;
  }
  main > .page {
    margin-top: 24px;
    padding: 24px 32px 32px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border);
    border-radius: 20px;
  }
  .calc-page { padding-bottom: 32px; }

  /* แถวรายการ: ช่องตัวเลขขนาดพอดี จัดชิดขวา (ไม่ยืดเต็มความกว้าง 1000px) */
  .calc-inputs,
  .calc-row .calc-inputs { grid-template-columns: repeat(3, minmax(0, 200px)); justify-content: end; }
  .money-sm { flex: 0 0 200px; }

  /* แถบสรุป: กว้างเท่าเนื้อหา ติดขอบล่างของจอเฉพาะช่วงที่อยู่ในหน้า (sticky ไม่ลอยออกนอกเนื้อหา) */
  .calc-sticky {
    position: sticky;
    left: auto;
    bottom: 16px;
    transform: none;
    width: 100%;
    max-width: none;
    margin-top: 16px;
  }
  .calc-sticky.is-hidden { transform: translateY(8px); }
  /* จอคอม: แถบสรุป / ปุ่มลอยอยู่ในเนื้อหา (sticky) → ตอนซ่อน (เห็นการ์ดสรุปแล้ว) ไม่กินพื้นที่ท้ายหน้า */
  .calc-sticky.is-hidden, .calc-fab.is-hidden { display: none; }

  /* พื้นหลัง: ภาพจางลง (ชั้นทับ 85%) เนื้อหาเป็นจุดเด่น */
  body::before {
    background:
      linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
      linear-gradient(rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.85)),
      linear-gradient(90deg, var(--bg) 0, rgba(15, 23, 42, 0) 18%, rgba(15, 23, 42, 0) 82%, var(--bg) 100%)
        center top / calc(100vh * 0.75) 100vh no-repeat,
      url("../img/bg-tools.webp?v=2") center top / calc(100vh * 0.75) 100vh no-repeat,
      var(--bg);
  }
}

/* จอกว้าง (≥768px): ใช้ช่วงกลางของภาพ ขยายเต็มความกว้างจอ (cover) แทนการวางภาพเต็มความสูงกลางจอ
   ส่วนบน/ล่างของภาพจะถูกตัดออก — เจ้าของงานเลือก 17 พ.ย. 2569 */
@media (min-width: 768px) {
  body::before {
    background:
      linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
      linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.75)),
      url("../img/bg-tools.webp?v=2") center / cover no-repeat,
      var(--bg);
  }
}
@media (min-width: 1024px) {
  body::before {
    background:
      linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
      linear-gradient(rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.85)),
      url("../img/bg-tools.webp?v=2") center / cover no-repeat,
      var(--bg);
  }
}

/* หัวการ์ดหมวด (รายละเอียดงาน / วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น / สรุป): พื้นอ่อนกว่าตัวการ์ด แยกส่วนให้ชัด
   ใช้สีระหว่างการ์ด (#1E293B) กับช่องกรอก (#273449) เพื่อไม่ให้หัวการ์ดดูเหมือนช่องกรอก */
:root { --surface-head: #2A3850; }
.calc-group-head { background: var(--surface-head); }

/* หัวการ์ดหมวด: เปลี่ยนเป็น "เข้มกว่าตัวการ์ด" ไม่ใช้โทนใกล้ช่องกรอก (เดิม #2A3850 ใกล้ #273449 จนลายตา)
   ลำดับความเข้ม: หัวการ์ด #141D2E (เข้มสุด) → ตัวการ์ด #1E293B → ช่องกรอก #273449 (อ่อนสุด) */
:root { --surface-head: #141D2E; }
.calc-group-head { background: var(--surface-head); border-bottom-color: var(--border); }

/* แถบลายเฉียงงานก่อสร้าง (hazard stripe) บาง 6px ที่ขอบบนของหัวการ์ดหมวด
   ใช้ส้มของแอปสลับ Navy (ไม่ใช่เหลือง-ดำเต็มแถบ เพื่อไม่ให้ลายตา/แย่งสายตาจากตัวเลข) */
.calc-group-head { position: relative; padding-top: 20px; }
.calc-group-head::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: repeating-linear-gradient(-45deg, var(--primary) 0 8px, #0F172A 8px 16px);
}

/* ป้าย "ปรับเอง ✕" กดได้: ยกเลิกราคาที่ปรับเอง */
button.tag-manual { font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 24px; }
button.tag-manual:hover { background: rgba(245, 158, 11, 0.25); }
button.tag-manual[hidden] { display: none; }

/* แถบปุ่ม "＋ เพิ่ม..." ท้ายการ์ดหมวด: พื้นส้มจาง (เป็นปุ่มกดได้) ไม่ซ้ำกับโทนเทา-น้ำเงินของหัวการ์ด/ตัวการ์ด/ช่องกรอก */
.calc-add-row {
  background: rgba(245, 158, 11, 0.08);
  border-top-color: rgba(245, 158, 11, 0.25);
  font-weight: 600;
}
.calc-add-row:hover { background: rgba(245, 158, 11, 0.15); }
.calc-add-row:active { background: rgba(245, 158, 11, 0.2); }

/* แยกการ์ดหมวดให้ชัดจากพื้นหลัง:
   - หัวการ์ดใช้สีเดียวกับตัวการ์ด (เดิม #141D2E เข้มใกล้พื้นหลังจนกลืน) แยกด้วยแถบลายเฉียง + ตัวหนา + เส้นคั่นแทน
   - ขอบการ์ดสว่างขึ้น #475569 ให้เห็นกรอบชัดบนพื้นเข้ม
   ลำดับ: พื้นหลัง (เข้มสุด) → การ์ด #1E293B + ขอบชัด → ช่องกรอก #273449 (อ่อนสุด) */
:root { --surface-head: var(--surface); --card-edge: #475569; }
.calc-card, .calc-group, .calc-summary { border-color: var(--card-edge); }
.calc-group-head { background: var(--surface-head); border-bottom: 1px solid var(--border); }

/* แถบลายเฉียงหัวการ์ด: ลดความเด่นลง ~25% ให้เป็น accent รอง ไม่แย่งสายตาจากหัวข้อและตัวเลข
   - บางลง 6px → 4px (padding ของหัวการ์ดคงเดิม ความสูงการ์ดไม่เปลี่ยน)
   - ส้ม/เหลืองลดความสด (ทึบ 72%) / ช่องเข้มใช้สีเดียวกับการ์ดให้กลืนกับพื้น
   - ยังเป็นลายเฉียงสลับสองสีเหมือนเดิม */
.calc-group-head::before {
  height: 4px;
  background: repeating-linear-gradient(-45deg, rgba(245, 158, 11, 0.72) 0 7px, var(--surface) 7px 14px);
}

/* =====================================================================
   Professional Contractor SaaS: เลิกใช้ลายเหลือง–ดำ (hazard stripe) ทุก Section
   เหลือง = accent เฉพาะจุด / น้ำเงินเข้ม = ตัวตนหลัก / Blueprint = พื้นหลัง (17 พ.ย. 2569)
   ===================================================================== */
:root {
  --accent-line: #F5A000;     /* เส้น accent ทอง-เหลือง */
  --surface-head: #3E5677;    /* หัว Section: ฟ้าเทา สว่างกว่าตัวการ์ด (#1E293B) ชัด ตามภาพตัวอย่าง (19 พ.ย. 2569) */
}

/* หัว Section: ไม่มีลายเฉียง → พื้น navy เข้ม + เส้นทองบาง 3px ด้านซ้าย */
.calc-group-head {
  position: relative;
  padding: 14px 16px 12px 20px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border);
}
.calc-group-head::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  height: auto;
  border-radius: 0 3px 3px 0;
  background: var(--accent-line);
}
.calc-group-head h2 { color: var(--text); }

/* Card: กรอบฟ้าเทาเข้มบาง + เงาบาง ๆ (ไม่มี decoration เพิ่ม) */
.calc-card, .calc-group, .calc-summary {
  border-color: #3A4A63;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.18);
}

/* ภาพพื้นหลัง Blueprint: จางลง ให้ข้อมูลอ่านง่ายเป็นอันดับแรก (ชั้นทับ 75% → 82% มือถือ / 85% → 88% คอม) */
body::before {
  background:
    linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
    linear-gradient(rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.82)),
    url("../img/bg-tools-sm.webp?v=2") center / cover no-repeat,
    var(--bg);
}
@media (min-width: 768px) {
  body::before {
    background:
      linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
      linear-gradient(rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.82)),
      url("../img/bg-tools.webp?v=2") center / cover no-repeat,
      var(--bg);
  }
}
@media (min-width: 1024px) {
  body::before {
    background:
      linear-gradient(to bottom, rgba(15, 23, 42, 0.92) 0, rgba(15, 23, 42, 0.6) 160px, rgba(15, 23, 42, 0) 300px),
      linear-gradient(rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.88)),
      url("../img/bg-tools.webp?v=2") center / cover no-repeat,
      var(--bg);
  }
}

/* ป้ายช่อง "ทุน/หน่วย · ราคาตลาด" ยาวขึ้น: ไม่ให้ขึ้นบรรทัดใหม่ ถ้าแคบมากให้ตัดด้วย … */
.mini-field > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* แถบสรุปด้านล่างจอ: ต้องเห็นชัด แยกจากการ์ดที่เลื่อนอยู่ด้านหลัง
   (ไม่ใช้พื้นเหลืองทั้งแถบ — ส้ม/เหลืองทึบสงวนไว้ให้ปุ่ม "ออกใบเสนอราคา" และกำไรสีเขียวต้องอ่านออก) */
.calc-sticky {
  background: #0B1220;
  border: 1px solid rgba(245, 160, 0, 0.55);
  border-top: 3px solid var(--accent-line);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.4);
  padding: 10px 14px;
}
.calc-sticky small { color: #CBD5E1; font-weight: 500; }
.calc-sticky b { font-size: 18px; font-weight: 700; }

/* กล่อง "สรุป": สไตล์เดียวกับแถบสรุปด้านล่างจอ (พื้นเข้ม + กรอบทอง + เส้นทองด้านบน)
   ให้เห็นว่าเป็นตัวเลขชุดเดียวกัน และแยกจากการ์ดกรอกข้อมูลอื่นชัดเจน */
.calc-summary {
  background: #0B1220;
  border: 1px solid rgba(245, 160, 0, 0.55);
  border-top: 3px solid var(--accent-line);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.calc-summary .calc-group-head { background: #0B1220; border-bottom-color: rgba(245, 160, 0, 0.25); }
/* หัว "สรุป": แถบเหลืองด้านซ้ายเหมือนหัว Section อื่น (ใช้ ::before / padding เดิมของ .calc-group-head — ปรับ 19 พ.ย. 2569) */
.calc-summary .calc-total,
.calc-summary .profit-line,
.calc-summary .calc-kpi { border-color: rgba(148, 163, 184, 0.18); }

/* ---------- Summary: "ราคาที่เสนอรวม" = ผลลัพธ์หลัก ----------
   แถวพื้นน้ำเงินตัดกับพื้น Summary เล็กน้อย + เส้นส้มบางด้านซ้าย / ตัวเลขใหญ่ที่สุดในกล่อง
   กำไรยังเป็นสีเขียวเด่น แต่ตัวเลขเล็กกว่าราคาที่เสนอรวม / รูปแบบเงินเหมือนทั้งระบบ (ไม่มี ฿) */
.calc-summary .sell-total {
  position: relative;
  background: #16223A;
  border-top-color: rgba(148, 163, 184, 0.18);
  padding: 16px 16px 16px 20px;
}
.calc-summary .sell-total::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-line);
}
.calc-summary .sell-total span { font-size: 16px; font-weight: 600; color: var(--text); }
.calc-summary .sell-total b { font-size: 30px; font-weight: 700; line-height: 1.2; color: var(--text); }
.calc-summary .calc-kpi b { font-size: 22px; }

/* ---------- กำไรที่ต้องการ: ปุ่มลัด 30% + "กำหนดเอง" + ช่องกรอก % อยู่บรรทัดเดียวกัน (SCOPE 3.2 ปรับ 21 พ.ย. 2569) ----------
   grid 2 ช่อง: "กำหนดเอง" กว้างกว่าปุ่ม % 1.6 เท่า / ไม่ขึ้นบรรทัดใหม่ ไม่ scroll */
.profit-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.profit-buttons,
.profit-line .profit-buttons {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 6px;
  flex: 0 1 200px;
  width: auto;
  min-width: 0;
  flex-wrap: nowrap;
}
.profit-btn {
  min-width: 0;
  padding: 6px 4px;
  white-space: nowrap;
  text-align: center;
  font-size: 15px;
}

/* ช่องกรอก % (กำหนดเอง): ต่อท้ายปุ่ม "กำหนดเอง" ในบรรทัดเดียวกัน */
.profit-custom { flex: 0 1 auto; min-width: 0; gap: 6px; }
.profit-custom input { width: 80px; min-width: 0; max-width: 100%; text-align: right; }

/* "ราคาที่เสนอรวม" แก้ได้: ช่องกรอกตัวใหญ่ในแถวเน้นของกล่องสรุป */
.calc-summary .sell-total { cursor: text; gap: 12px; }
.total-input {
  flex: 0 1 220px;
  min-width: 0;
  text-align: right;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  min-height: 52px;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid #3A4A63;
  color: var(--text);
}
.total-input:focus { border-color: var(--accent-line); outline: 2px solid var(--accent-line); outline-offset: 0; }
.total-note {
  margin: 0;
  padding: 8px 16px 10px 20px;
  font-size: 14px;
  color: #FBBF24;
  background: #16223A;
}
.total-note[hidden] { display: none; }

/* ลิงก์ "↺ กลับเป็นราคาเดิม (…)" ใต้ราคาที่เสนอรวม: text link ชิดขวา แสดงเฉพาะหลังแก้ยอดรวม */
.total-undo-row { display: flex; justify-content: flex-end; background: #16223A; }
.total-undo {
  font: inherit; font-size: 14px; font-weight: 500;
  background: none; border: 0; cursor: pointer;
  color: var(--primary); padding: 4px 16px 10px; min-height: 36px;
}
.total-undo:hover { text-decoration: underline; }
.total-undo[hidden] { display: none; }
.total-undo-row:has(.total-undo[hidden]) { display: none; }

/* ลดระยะห่าง: ช่องยอดรวม ↔ ลิงก์ "↺ กลับเป็นราคาเดิม" ↔ แถวกำไร
   และไม่ให้ป้าย "ราคาที่เสนอรวม" ตัดเป็น 2 บรรทัด */
.calc-summary .sell-total { padding-top: 12px; padding-bottom: 12px; }
.calc-summary .sell-total > span { white-space: nowrap; }
.calc-summary .total-input { flex: 0 1 200px; }
.calc-summary:has(.total-undo:not([hidden])) .sell-total { padding-bottom: 2px; }
.total-undo { min-height: 28px; padding: 2px 16px 8px; line-height: 1.3; }

/* ป้ายที่มาของราคา: สีกลาง ๆ ไม่ใช้แดง/เขียว (ไม่ได้หมายถึงผิดหรือถูก)
   - 🔒 ปรับเอง  = ผู้ใช้กำหนดเอง ระบบไม่แตะ (ส้ม = accent, กดเพื่อยกเลิก)
   - ระบบปรับ    = ระบบปรับให้ตามยอดรวม (เทาอมฟ้า แสดงข้อมูลอย่างเดียว) */
.tag-lock { width: 12px; height: 12px; flex-shrink: 0; }
.tag-system {
  display: inline-flex; align-items: center; min-height: 24px;
  font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 999px;
  color: #CBD5E1; background: rgba(148, 163, 184, 0.14); border: 1px solid rgba(148, 163, 184, 0.3);
  white-space: nowrap;
}
.tag-system[hidden] { display: none; }

/* toast ที่มีปุ่ม "เลิกทำ": กดได้ (toast ปกติไม่รับการแตะ) */
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; border-radius: 14px; padding: 6px 10px 6px 16px; width: max-content; }
.toast-msg { min-width: 0; }
.toast-action {
  flex-shrink: 0; white-space: nowrap;
  font: inherit; font-weight: 700; color: var(--primary-hover);
  background: none; border: 0; cursor: pointer; padding: 6px 4px; min-height: 32px;
  text-decoration: underline; text-underline-offset: 3px;
}

/* รายการงานแบบตาราง (SCOPE 11.11) — การ์ด → ตาราง เปลี่ยนเฉพาะการนำเสนอ
   ตัวกรอง (chip เดิม) + ช่องค้นหา / ทั้งแถวกดเปิดงาน (ลิงก์ชื่องานยืดคลุมแถว) / ปุ่มลบอยู่เหนือลิงก์ */
.jobs-tools { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.jobs-tools .jobs-filter { padding: 4px 0; }
.jobs-search { min-height: 44px; }
.jobs-scope { margin: 0 2px 8px; }
.jobs-table { padding: 0; overflow: hidden; }
.jobs-head { display: none; }
.job-row { position: relative; display: grid; align-items: center; column-gap: 12px; padding: 10px 12px; border-top: 1px solid var(--border); }
.jobs-head + .job-row, .jobs-table > .job-row:first-child { border-top: 0; }
.job-row:hover { background: var(--primary-soft); }
.job-link { min-width: 0; color: inherit; text-decoration: none; }
.job-link::after { content: ""; position: absolute; inset: 0; }
.job-link:focus-visible { outline: none; }
.job-row:has(.job-link:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }
.job-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.job-cust, .job-date, .job-qno { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.job-sell { font-weight: 600; white-space: nowrap; text-align: right; }
.job-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.job-delete { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; }
.job-delete:hover, .job-delete:focus-visible { color: var(--neg); background: rgba(248, 113, 113, 0.12); }
/* มือถือ (< 600px): แถวกะทัดรัด 2 บรรทัด — [ชื่องาน | สถานะ | ลบ] / [ลูกค้า · แก้ไขล่าสุด · เลขที่ใบ | ราคาที่เสนอ] ไม่เลื่อนแนวนอน */
@media (max-width: 599px) {
  .job-row { grid-template-columns: minmax(0, 1fr) 36px; grid-template-areas: "l1 act" "l2 act"; row-gap: 4px; padding: 10px 6px 10px 12px; }
  .job-l1, .job-l2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .job-l1 { grid-area: l1; }
  .job-l2 { grid-area: l2; align-items: flex-end; }
  .job-link { flex: 1 1 auto; }
  .job-status { flex: 0 0 auto; }
  .job-sell { flex: 0 0 auto; margin-left: auto; font-size: 15px; }
  .job-actions { grid-area: act; }
  /* ลูกค้า / แก้ไขล่าสุด / เลขที่ใบ: ชื่อลูกค้าหดก่อน (ตัดด้วย …) / แคบจนลูกค้าเหลือ < ~6 ตัวอักษร → ขึ้นบรรทัดใหม่ ไม่ซ่อนข้อมูล */
  .job-meta { flex: 1 1 auto; display: flex; flex-wrap: wrap; min-width: 0; gap: 2px 10px; }
  .job-meta > span { flex: 0 0 auto; max-width: 100%; }
  .job-meta > .job-cust { flex: 1 1 6em; min-width: 0; }
  .job-meta > .job-qno { font-weight: 600; }
  .job-meta > .job-qno.muted { display: none; }
  .job-actions { width: 36px; } /* ทุกแถวเว้นที่ปุ่มลบเท่ากัน → ราคาที่เสนอตรงแนวเดียวกัน */
}
/* ตาราง (≥ 600px): หัวคอลัมน์ + 7 คอลัมน์ / พื้นที่ไม่พอ (600–679px) เลื่อนแนวนอนภายในตาราง
   คอลัมน์สุดท้าย = ปุ่มถังขยะ (งานร่าง) / เปิดงานด้วยการกดที่แถว */
@media (min-width: 600px) {
  .jobs-table { overflow-x: auto; }
  .jobs-head, .job-row { grid-template-columns: minmax(100px, 2fr) minmax(72px, 1.4fr) 128px 92px 80px 72px 40px; column-gap: 10px; min-width: 668px; }
  .job-l1, .job-l2 { display: contents; }
  .jobs-head { display: grid; align-items: center; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
  .jobs-head .num { text-align: right; }
  .job-meta { display: contents; }
  .job-link { grid-column: 1; grid-row: 1; }
  .job-cust { grid-column: 2; grid-row: 1; }
  .job-status { grid-column: 3; grid-row: 1; }
  .job-sell { grid-column: 4; grid-row: 1; }
  .job-date { grid-column: 5; grid-row: 1; }
  .job-qno { grid-column: 6; grid-row: 1; }
  .job-actions { grid-column: 7; grid-row: 1; }
  .jobs-tools { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .jobs-tools .jobs-search { flex: 0 1 300px; }
}
/* Tablet / Desktop (≥ 680px — SCOPE 11.11 ปรับ 23 พ.ย. 2569): Header แบบ SaaS List Page
   [รายการงาน ......... ＋ สร้างงานใหม่] ปุ่มพอดีข้อความ ชิดขวาของหัวข้อ / ส่วนอื่นเต็มแถวตามลำดับเดิม
   < 680px ไม่มีกฎในกลุ่มนี้ → ปุ่มเต็มความกว้างด้านบนเหมือนเดิม */
@media (min-width: 680px) {
  .jobs-page { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: center; }
  .jobs-page > * { grid-column: 1 / -1; min-width: 0; }
  .jobs-page > .section-title { grid-column: 1; grid-row: 1; margin: 0; }
  .jobs-page > .calc-new { grid-column: 2; grid-row: 1; width: auto; min-height: 44px; margin: 0; padding: 8px 20px; font-size: 1rem; white-space: nowrap; }
  .jobs-page > .jobs-tools, .jobs-page > .list:nth-child(3) { margin-top: 16px; }
}
/* Light: Badge ร่าง ในการ์ดขาวต้องเห็นเป็นป้าย (พื้นเทาอ่อน) แยกจาก ออกใบเสนอราคาแล้ว (เขียว) */
html[data-theme="light"] .jobs-table .badge-draft { background: #E2E8F0; color: #334155; }
@media (min-width: 1024px) {
  .jobs-head, .job-row { grid-template-columns: minmax(140px, 2fr) minmax(110px, 1.4fr) 136px 108px 96px 84px 40px; column-gap: 12px; }
}

/* รายการงาน: ปุ่มโหลดเพิ่ม (อ่านทีละหน้า SCOPE 8) */
.jobs-more { margin-top: 12px; }
.jobs-more[hidden] { display: none; } /* .btn ตั้ง display ทับ [hidden] → ไม่มีงานเหลือแล้วต้องซ่อนจริง */

/* =========================================================================
   ใบเสนอราคา: ร่าง (Draft) / ตัวอย่าง (Preview) / ใบที่ออกแล้ว (ISSUED) / พิมพ์ A4
   ========================================================================= */
/* หัวข้อหน้าข้อมูลในใบเสนอราคา: แถบสีด้านซ้าย แบบเดียวกับหัวข้อหน้าคำนวณ */
.quote-page > .page-title { position: relative; padding-left: 16px; font-size: 24px; line-height: 1.3; }
.quote-page > .page-title::before { content: ""; position: absolute; left: 0; top: 0.2em; bottom: 0.2em; width: 5px; border-radius: 3px; background: var(--accent-line); }
@media (max-width: 639px) { .quote-page > .page-title { font-size: 22px; } }
.quote-form { display: contents; }
.quote-warn { color: var(--neg); margin: 0 0 10px; font-weight: 600; }
.quote-check { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; min-height: 44px; cursor: pointer; }
.quote-check input { width: 22px; height: 22px; accent-color: var(--primary); flex: 0 0 auto; }
.quote-page .calc-card input, .quote-page .calc-card input[inputmode] { text-align: left; }
.quote-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 16px; }
.quote-line b { text-align: right; white-space: nowrap; }
.quote-internal .calc-group-head h2 small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.quote-internal .pos { color: var(--pos); }
.quote-internal .neg { color: var(--neg); }
.quote-problems { margin: 16px 0 0; padding: 12px 16px 12px 32px; border: 1px solid var(--neg); border-radius: var(--radius); color: var(--neg); font-size: 14px; }
.quote-next { margin-top: 16px; }
.quote-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.quote-toolbar .back { margin: 0; }
.quote-actions { margin-top: 16px; }
.quote-actions .quote-problems { margin: 0 0 12px; }
/* Launch Period (SCOPE 2.L): ใช้สิทธิ์ครบในรอบแล้ว — ข้อความหลัก + ข้อความรอง เหนือปุ่มยืนยัน (ปุ่มปิด) */
.quote-limit { display: flex; flex-direction: column; gap: 2px; margin: 0 0 12px; padding: 12px 16px; border: 1px solid var(--primary); border-radius: var(--radius); background: var(--primary-soft); font-size: 14px; align-items: center; text-align: center; } /* จัดกลาง (28 พ.ย. 2569) */
.quote-limit span { color: var(--muted); }
.quote-limit[hidden] { display: none; }
.quote-paper { overflow-x: auto; border-radius: 10px; }

/* ---------- เอกสาร (พื้นขาวแบบกระดาษ) ---------- */
.quote-doc {
  position: relative; overflow: hidden;
  background: #fff; color: #0F172A; border-radius: 10px; padding: 20px 16px;
  font-size: 13px; line-height: 1.55; min-width: 320px;
}
.quote-doc .nw { white-space: nowrap; }
/* ลายน้ำร่าง: คลุมทั้งแผ่น ข้อความ 3 ที่ (บน / กลาง / ล่าง — 27 พ.ย. 2569) */
.qd-watermark {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-around; align-items: center;
  overflow: hidden; pointer-events: none; z-index: 1;
}
.qd-watermark span { transform: rotate(-28deg); font-size: 30px; font-weight: 700; color: rgba(220, 38, 38, 0.13); white-space: nowrap; }
/* หัวใบ (ปรับ 26 พ.ย. 2569): ร้าน (กว้างกว่า ไม่ตัดบรรทัดมาก) | ใบเสนอราคา — สูงเท่ากัน: ฝั่งขวาหัวข้อชิดบน รายละเอียดชิดล่าง / จอแคบ → ซ้อนกัน */
.qd-head { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: stretch; gap: 12px 24px; border-bottom: 2px solid #0F172A; padding-bottom: 12px; }
.qd-seller { display: flex; gap: 12px; align-items: stretch; min-width: 0; overflow-wrap: anywhere; }
/* ข้อความร้านกระจายเต็มความสูงหัวใบ → บรรทัดแรก / บรรทัดสุดท้ายตรงกับฝั่ง "ใบเสนอราคา" (ปรับ 26 พ.ย. 2569) */
.qd-seller > div { display: flex; flex-direction: column; justify-content: flex-start; min-width: 0; }
/* ข้อมูลร้านน้อยบรรทัด (เช่น ชื่อ + โทร) → เรียงชิดกัน / ตั้งแต่ 3 บรรทัด → กระจายให้ล่างตรงกับฝั่งใบเสนอราคา (ปรับ 26 พ.ย. 2569) */
.qd-seller > div:has(> :nth-child(3)) { justify-content: space-between; }
.qd-seller > .qd-logo { align-self: flex-start; }
.qd-logo { width: 64px; height: 64px; object-fit: contain; flex: 0 0 auto; }
.qd-seller-name { font-size: 16px; display: block; word-break: keep-all; overflow-wrap: anywhere; } /* ชื่อยาว: ขึ้นบรรทัดใหม่ตรงเว้นวรรค ไม่ตัดกลางคำ (26 พ.ย. 2569) */
.qd-title { min-width: 0; display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; } /* เลขที่ / วันที่ อยู่ชิดใต้หัว "ใบเสนอราคา" (ปรับ 26 พ.ย. 2569 — เดิมดันไปชิดล่าง) */
/* หัวใบบรรทัดชิด (ปรับ 26 พ.ย. 2569 — ไม่กินพื้นที่) */
.qd-head { line-height: 1.35; }
.qd-title h2 { font-size: 22px; font-weight: 700; line-height: 1.2; margin: 0; }
.qd-title dl { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; margin: 0; }
.qd-title dt { color: #475569; }
.qd-title dd { margin: 0; font-weight: 600; }
.qd-title small { font-weight: 400; color: #475569; }
.qd-pending { color: #94A3B8; font-weight: 400; }
.qd-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 20px; padding: 8px 0; line-height: 1.35; overflow-wrap: anywhere; }
.qd-parties h3, .qd-notes h3 { font-size: 12px; font-weight: 700; color: #475569; margin: 0 0 2px; }
/* ลูกค้า / งาน: หัวข้อกับชื่ออยู่บรรทัดเดียวกัน (ที่อยู่ / โทร / รายละเอียด ยังขึ้นบรรทัดถัดไป) */
.qd-parties h3 { display: inline; margin: 0 8px 0 0; }
.qd-parties h3::after { content: " :"; } /* ลูกค้า : ชื่อ / งาน : ชื่องาน (แบบเดียวกับใบสรุป) */
.qd-table { width: 100%; border-collapse: collapse; }
/* ตารางรายการแถวชิด (ปรับ 26 พ.ย. 2569 — รายการเยอะไม่ล้นหลายหน้า / ตัวอักษรเท่าเดิม) */
.qd-table { line-height: 1.35; }
.qd-table th { background: #F1F5F9; font-weight: 600; text-align: left; padding: 4px 6px; border-bottom: 1px solid #CBD5E1; }
.qd-table td { padding: 3px 6px; border-bottom: 1px solid #E2E8F0; vertical-align: top; }
.qd-table .qd-group td { background: #F8FAFC; font-weight: 700; color: #334155; }
/* หมวดงานในใบ (ปรับ 26 พ.ย. 2569) — แนวเดียวกับเอกสารสรุป: หัวหมวดฟ้าอ่อน / รายการเยื้อง / รวมหมวด */
.qd-table .qd-cat td { background: #DCE8F7; color: #0F172A; font-weight: 700; border-top: 1px solid #A9C6EC; }
.qd-table .qd-cat .qd-no { color: #0F172A; }
.qd-table:has(.qd-cat) tr:not(.qd-cat):not(.qd-cattotal) .qd-name { padding-left: 14px; }
.qd-dashed { display: flex; gap: 6px; }
.qd-dash { flex: none; color: #94A3B8; }
.qd-table .qd-cattotal td { background: #F1F5F9; font-weight: 700; border-top: 1.5px solid #64748B; }
.qd-no { width: 28px; color: #64748B; }
.qd-name { overflow-wrap: anywhere; }
.qd-qty { white-space: nowrap; text-align: right !important; } /* จำนวนชิดขวา / หน่วยแยกคอลัมน์ (ปรับ 26 พ.ย. 2569) */
.qd-unit { white-space: nowrap; }
.qd-num { text-align: right !important; white-space: nowrap; }
.qd-bottom { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; margin-top: 12px; }
.qd-notes { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.qd-notes p { margin: 0 0 8px; }
.qd-seller-note { color: #475569; }
.qd-totals { border-collapse: collapse; flex: 0 1 260px; margin-left: auto; }
.qd-totals { line-height: 1.35; }
.qd-totals th { text-align: left; font-weight: 400; padding: 2px 12px 2px 0; color: #334155; }
.qd-totals td { text-align: right; padding: 2px 0; white-space: nowrap; }
.qd-grand th, .qd-grand td { font-weight: 700; font-size: 15px; color: #0F172A; border-top: 2px solid #0F172A; padding-top: 6px; }
@media (max-width: 420px) {
  .quote-doc { font-size: 12px; padding: 16px 12px; min-width: 0; }
  .qd-watermark span { font-size: 20px; }
  .qd-table th, .qd-table td { padding: 3px 4px; }
}
/* หน้า Preview / ใบที่ออกแล้ว: บนจอแสดงเป็นกระดาษ A4 (210 × 297 มม. ขอบใน 12 มม. ตัวอักษร 10.5pt เท่ากับตอนพิมพ์)
   จอแคบกว่า A4 → fitPaper() ใน js/views/quote.js ย่อทั้งแผ่น (zoom) ให้พอดีความกว้าง / รายการยาวเกิน 1 หน้า → แผ่นยืดลง (ตัดหน้าตอนพิมพ์) */
@media screen {
  .quote-view .quote-paper { overflow: hidden; border-radius: 0; padding: 2px 0 6px; }
  .quote-view .quote-doc { width: 210mm; min-width: 0; min-height: 297mm; padding: 12mm; box-sizing: border-box; margin: 0 auto; font-size: 10.5pt; border-radius: 2px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); }
  .quote-view .qd-watermark span { font-size: 40pt; }
  /* แผ่น A4 แยกหน้า (paginateDoc ใน quote.js — 26 พ.ย. 2569) */
  .quote-view .qd-sheets { display: flex; flex-direction: column; gap: 18px; }
  .quote-view .quote-doc.qd-sheet { height: 297mm; }
  .quote-view .quote-doc.qd-sheet::after { top: 5mm; right: 12mm; }
  .quote-view .qd-table th { padding: 4px 6px; }
  .quote-view .qd-table td { padding: 3px 6px; }
}

/* =====================================================================
   Theme (SCOPE 11.10): <html data-theme="navy|light|dark"> ตั้งจาก js/shell.js (localStorage)
   Navy = ค่าทั้งหมดด้านบน (ไม่มีกฎในส่วนนี้) / Light และ Dark = เปลี่ยน token สี + จุดที่ฝังสี navy ไว้ตรง ๆ
   เอกสารใบเสนอราคา / ตัวอย่างหัวใบ (พื้นขาว) และการพิมพ์ ไม่เปลี่ยนตาม Theme
   ===================================================================== */

/* ---------- Dark: เข้มกว่า Navy (ไม่ใช่ดำสนิท 3.7) ---------- */
html[data-theme="dark"] {
  --bg: #07090E;
  --surface: #121821;
  --surface-2: #1A2230;
  --surface-head: linear-gradient(180deg, #203D5F 0%, #152D4B 55%, #152C49 100%); /* หัว Section: Navy เข้มไล่เฉด ตามภาพตัวอย่าง */
  --border: #263040;
  --card-edge: #2E3A4D;
  --text: #F1F5F9;
  --muted: #94A3B8;
  --primary-ink: #07090E;
  color-scheme: dark;
}
html[data-theme="dark"] body::before {
  background:
    linear-gradient(to bottom, rgba(7, 9, 14, 0.95) 0, rgba(7, 9, 14, 0.7) 160px, rgba(7, 9, 14, 0) 300px),
    linear-gradient(rgba(7, 9, 14, 0.9), rgba(7, 9, 14, 0.9)),
    url("../img/bg-tools-sm.webp?v=2") center / cover no-repeat,
    var(--bg);
}
@media (min-width: 768px) {
  html[data-theme="dark"] body::before {
    background:
      linear-gradient(to bottom, rgba(7, 9, 14, 0.95) 0, rgba(7, 9, 14, 0.7) 160px, rgba(7, 9, 14, 0) 300px),
      linear-gradient(rgba(7, 9, 14, 0.92), rgba(7, 9, 14, 0.92)),
      url("../img/bg-tools.webp?v=2") center / cover no-repeat,
      var(--bg);
  }
}
html[data-theme="dark"] .account-tabs { background: rgba(18, 24, 33, 0.92); }
html[data-theme="dark"] .account-page::before { background: rgba(7, 9, 14, 0.6); }
html[data-theme="dark"] .plan-status,
html[data-theme="dark"] .total-input { background: rgba(7, 9, 14, 0.6); }
html[data-theme="dark"] .calc-card,
html[data-theme="dark"] .calc-group,
html[data-theme="dark"] .calc-summary,
html[data-theme="dark"] .total-input { border-color: var(--card-edge); }
html[data-theme="dark"] .calc-sticky,
html[data-theme="dark"] .calc-summary,
html[data-theme="dark"] .calc-summary .calc-group-head { background: #05070B; }
html[data-theme="dark"] .calc-summary .sell-total,
html[data-theme="dark"] .total-note,
html[data-theme="dark"] .total-undo-row { background: #0F1520; }

/* ---------- Light (SCOPE 11.10 ปรับ 19 พ.ย. 2569) = Navy BG + พื้นที่ทำงานสว่าง ----------
   ลำดับชั้น: พื้นหลัง / Header / เมนู Navy เดิม → Card ขาว → กลุ่มข้อมูลฟ้าอ่อน → ช่องกรอกขาว
   ระดับหน้าใช้ token Navy เดิมทั้งหมด (ไม่ override) / เปลี่ยน token เป็นโทนสว่างเฉพาะภายในพื้นที่ทำงาน
   ส้ม = accent / เพิ่มรายการ / ไฮไลต์ · เหลืองอ่อน = ราคาที่เสนอ · น้ำเงินสด = ปุ่ม action หลัก (.btn-primary) */
html[data-theme="light"] {
  --data-bg: #EEF4FA;   /* กลุ่มข้อมูลภายใน Card */
  --sell-bg: #FFF8DB;   /* ราคาที่เสนอ */
  --action: #2563EB;    /* ปุ่ม action หลัก */
  --action-hover: #1D4ED8;
}
/* พื้นที่ทำงาน (Card / ฟอร์ม / popup / สรุปตัวเลข): --surface-2 (พื้นช่องกรอก) = ขาว */
html[data-theme="light"] :is(.card, .calc-card, .calc-group, .calc-summary, .calc-sticky, .modal, .unit-pop, .empty, .auth-card, .stat, .tx) {
  --surface: #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-head: linear-gradient(180deg, #E6F0FC 0%, #C8DFFA 100%); /* หัว Section: ฟ้าอ่อนไล่เฉด ตามภาพตัวอย่าง */
  --border: #C7D5E5;
  --card-edge: #D6E1EE;
  --text: #0F172A;
  --muted: #475569;
  --primary: #B45309;          /* ส้มเข้ม: ตัวอักษรส้มบนพื้นขาว contrast ≥ 4.5 */
  --primary-hover: #92400E;
  --primary-ink: #FFFFFF;
  --primary-soft: rgba(217, 119, 6, 0.12);
  --accent-line: #F59E0B;
  --pos: #047857;
  --neg: #DC2626;
  --danger: #DC2626;
  color: var(--text);
  color-scheme: light;
}

/* Card ขาว ขอบฟ้าเทาอ่อน เงาแยกจากพื้น Navy */
html[data-theme="light"] :is(.card, .calc-card, .calc-group, .calc-summary, .auth-card, .modal, .empty, .stat, .tx) {
  border-color: var(--card-edge); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.18);
}
html[data-theme="light"] .calc-group-head h2 { color: var(--text); }

/* กลุ่มข้อมูลภายใน Card = ฟ้าอ่อน (ช่องกรอกในกลุ่มยังเป็นขาว) */
html[data-theme="light"] .calc-row { background: var(--data-bg); border: 0; border-radius: 12px; margin-bottom: 8px; padding: 10px; }
html[data-theme="light"] .calc-row:last-child { margin-bottom: 0; }
html[data-theme="light"] .calc-kpi,
html[data-theme="light"] .job-nums,
html[data-theme="light"] .plan-status { background: var(--data-bg); }
html[data-theme="light"] .job-nums { border-radius: 10px; padding: 8px 10px; }
html[data-theme="light"] .plan-status { border-color: var(--card-edge); }

/* ราคาที่เสนอ = เหลืองอ่อน */
html[data-theme="light"] .row-sell { background: var(--sell-bg); border-radius: 10px; padding: 6px 8px; }
html[data-theme="light"] .calc-summary .sell-total,
html[data-theme="light"] .total-note,
html[data-theme="light"] .total-undo-row { background: var(--sell-bg); }
html[data-theme="light"] .total-note { color: #92400E; }
html[data-theme="light"] .total-input { background: #FFFFFF; border-color: var(--border); }

/* ตัวอักษรที่ฝังสีอ่อน (โทน Navy) ภายในพื้นที่ทำงาน → Navy / Slate ที่อ่านง่าย */
html[data-theme="light"] .biz-label-note,
html[data-theme="light"] .calc-card .field > span,
html[data-theme="light"] .row-sell-label,
html[data-theme="light"] .line-label,
html[data-theme="light"] .calc-sticky small { color: #334155; }

/* แถบสรุปติดล่าง / การ์ดสรุป: ขาว ขอบส้ม */
html[data-theme="light"] .calc-sticky { background: var(--surface); border-color: rgba(245, 158, 11, 0.7); box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45); }
html[data-theme="light"] .calc-summary { background: var(--surface); border-color: rgba(245, 158, 11, 0.7); }
html[data-theme="light"] .calc-summary .calc-group-head { background: var(--surface-head); border-bottom-color: rgba(217, 119, 6, 0.3); }
html[data-theme="light"] .calc-summary .calc-kpi { border-color: var(--card-edge); }

/* ปุ่ม action หลัก = น้ำเงินสด (ตัวอักษรขาว contrast 5.2) */
html[data-theme="light"] .btn-primary { background: var(--action); color: #FFFFFF; }
html[data-theme="light"] .btn-primary:hover:not(:disabled) { background: var(--action-hover); }

/* ป้าย / สถานะ */
html[data-theme="light"] .tag-system { color: #334155; background: #F1F5F9; border-color: var(--border); }
html[data-theme="light"] .badge-quote { background: rgba(37, 99, 235, 0.1); color: #1D4ED8; }
html[data-theme="light"] .badge-done,
html[data-theme="light"] .badge-issued { background: rgba(4, 120, 87, 0.1); }
html[data-theme="light"] .biz-paper,
html[data-theme="light"] .quote-doc { box-shadow: 0 0 0 1px var(--border); }
html[data-theme="light"] .theme-option { background: var(--data-bg); border-color: var(--card-edge); }
html[data-theme="light"] .theme-option.is-selected { background: var(--primary-soft); border-color: var(--primary); }

@media (min-width: 1024px) {
  html[data-theme="dark"] main > .page { background: rgba(7, 9, 14, 0.55); }
}

/* แถบหัวข้อ Section (ไม่รวมหัวการ์ด "สรุป" ของ Navy / Dark): เส้นไฮไลต์ด้านบน + เส้นคั่นล่าง ตามภาพตัวอย่าง
   ใช้ inset shadow + สีเส้นเดิม → ขนาด / padding / ความสูงไม่เปลี่ยน */
html[data-theme="navy"] .calc-group-head:not(.calc-summary .calc-group-head) { box-shadow: inset 0 1px 0 #6682A4; border-bottom-color: #496482; }
html[data-theme="dark"] .calc-group-head:not(.calc-summary .calc-group-head) { box-shadow: inset 0 1px 0 rgba(163, 176, 196, 0.55); border-bottom-color: #0D2443; }
html[data-theme="light"] .calc-group-head:not(.calc-summary .calc-group-head) { box-shadow: inset 0 1px 0 #F5FAFD; border-bottom-color: #B9D3F2; }
/* หัวการ์ด "สรุป": ใช้สีชุดเดียวกับแถบหัวข้อ Section ของแต่ละธีม (เฉพาะสีพื้น / ไฮไลต์ / เส้นคั่น — ขนาด ระยะ และเส้นส้มคงเดิม) */
html[data-theme="navy"] .calc-summary .calc-group-head { background: var(--surface-head); box-shadow: inset 0 1px 0 #6682A4; border-bottom-color: #496482; }
html[data-theme="dark"] .calc-summary .calc-group-head { background: var(--surface-head); box-shadow: inset 0 1px 0 rgba(163, 176, 196, 0.55); border-bottom-color: #0D2443; }
html[data-theme="light"] .calc-summary .calc-group-head { background: var(--surface-head); box-shadow: inset 0 1px 0 #F5FAFD; border-bottom-color: #B9D3F2; }

/* ---------- ดูภาพสรุป (SCOPE 3.2.4): เอกสารภายใน A4 — A4 เป็นต้นฉบับเดียว ----------
   แผ่นกระดาษขนาดจริง 210 × 297 มม. / ตัวอักษรเป็น pt (ขนาดจริงบนกระดาษ ข้อ 19: ไม่ต่ำกว่า 10pt)
   Preview = ย่อทั้งแผ่นด้วย zoom ให้พอดีจอ (JS) ไม่มี layout มือถือแยก / Print = แผ่นเดียวกันขนาดจริง */
/* ปุ่ม "ดูสรุปรายการ" มุมขวาของหัวการ์ด "สรุป" (ไอคอนเอกสาร + ข้อความ) */
.calc-doc-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border: 2px solid #F59E0B; border-radius: 8px; background: rgba(245, 158, 11, 0.2); color: #F8FAFC; font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2; white-space: nowrap; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.calc-doc-btn:hover { background: rgba(245, 158, 11, 0.34); }
.calc-doc-btn .calc-doc-icon { color: #FBBF24; }
/* Light: ปุ่มพื้นขาว กรอบส้มเข้ม ตัดกับหัวการ์ดสีฟ้าอ่อน */
html[data-theme="light"] .calc-doc-btn { background: #FFFFFF; border-color: #B45309; color: #0F172A; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15); }
html[data-theme="light"] .calc-doc-btn:hover { background: #FEF3C7; }
html[data-theme="light"] .calc-doc-btn .calc-doc-icon { color: #B45309; }
.calc-doc-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.calc-doc-icon { width: 18px; height: 18px; flex: none; color: var(--primary); }
/* ปุ่มลอย "สรุป" (SCOPE 3.2.4 ข้อ 12): มุมล่างขวา เหนือแถบตัวเลขลอย — สีเดียวกับปุ่มในหัวการ์ด (ไม่ใช้ส้มทึบ) */
.calc-fab {
  position: fixed; z-index: 9;
  right: max(8px, calc((100% - 720px) / 2));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px + var(--sticky-h, 68px));
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  background: #1E293B; /* ทึบ: ไม่ให้เนื้อหาด้านหลังทะลุ */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: opacity 0.15s, transform 0.15s;
}
.calc-fab:hover { background: #33302A; }
html[data-theme="light"] .calc-fab { background: #FFFFFF; box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22); }
html[data-theme="light"] .calc-fab:hover { background: #FEF3C7; }
.calc-fab.is-hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
@media (prefers-reduced-motion: reduce) { .calc-fab { transition: none; } }
@media (min-width: 1024px) {
  /* Desktop: แถบสรุปเป็น sticky ในเนื้อหา → ปุ่มลอยติดอยู่เหนือแถบ ชิดขวาของเนื้อหา */
  .calc-fab { position: sticky; right: auto; bottom: calc(16px + var(--sticky-h, 68px) + 10px); display: flex; width: fit-content; margin: 16px 0 0 auto; }
}
@media print { .calc-fab { display: none; } }
.sd-overlay { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: #3F4246; }
.sd-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); }
.sd-bar-title { font-size: 16px; color: var(--text); }
.sd-scroll { position: relative; flex: 1 1 auto; overflow: auto; padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.sd-sheets { width: max-content; margin: 0 auto; }
.sd-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }
.sd-page {
  page: sd-a4;
  width: 210mm; height: 297mm; padding: 8mm 14mm 14mm; box-sizing: border-box; overflow: hidden;
  background: #fff; color: #111827; margin: 0 0 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  font-family: "Noto Sans Thai", system-ui, sans-serif; font-size: 11pt; line-height: 1.4;
}
.sd-measure .sd-page { margin: 0; }
.sd-doc-head { margin-bottom: 3.5mm; }
.sd-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 6mm; padding-bottom: 3mm; border-bottom: 2px solid #0F2547; margin-bottom: 2.5mm; }
.sd-title { margin: 0; font-size: 18pt; font-weight: 700; line-height: 1.35; color: #0F2547; display: flex; align-items: center; gap: 3mm; }
.sd-hat { flex: none; width: 13mm; height: auto; opacity: 0.35; }
.sd-notice { margin: 0 0 1mm; padding: 1mm 3mm; border: 1.5px solid #B45309; border-radius: 1.5mm; color: #92400E; font-size: 10.5pt; font-weight: 700; line-height: 1.35; white-space: nowrap; }
.sd-head { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8mm; }
.sd-head > .sd-meta + .sd-meta { padding-left: 8mm; border-left: 1px solid #CBD5E1; }
.sd-meta { margin: 0; display: grid; gap: 1.5mm; }
.sd-meta > div { display: grid; grid-template-columns: 30mm 1fr; gap: 2mm; align-items: baseline; }
.sd-meta dt { color: #374151; font-size: 11pt; }
.sd-meta dt::after { content: " :"; float: right; }
.sd-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: #111827; font-size: 11pt; }
.sd-meta .sd-job { font-size: 13pt; font-weight: 700; }
.sd-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; border: 1px solid #CBD5E1; border-radius: 2.5mm; }
/* มุมโค้ง (22 พ.ย. 2569): ช่องที่มุมโค้งตามกรอบ ให้พื้นหัวตาราง / แถวสุดท้ายไม่ล้นมุม (เส้นในตารางมีแค่บน + ซ้าย → separate ไม่เกิดเส้นซ้อน) */
.sd-table thead th:first-child { border-top-left-radius: calc(2.5mm - 1px); }
.sd-table thead th:last-child { border-top-right-radius: calc(2.5mm - 1px); }
.sd-table tbody tr:last-child td:first-child { border-bottom-left-radius: calc(2.5mm - 1px); }
.sd-table tbody tr:last-child td:last-child { border-bottom-right-radius: calc(2.5mm - 1px); }
.sd-c-no { width: 10.5mm; } /* พอดีหัว "ลำดับ" 11pt และเลข n.mm (ข้อ 19 / 26) — พื้นที่ที่เหลือให้คอลัมน์รายการงาน */
.sd-c-num { width: 27mm; } /* ตัวเลข 7 หลัก (9,999,999.00) ของแถวรายการ / รวมหมวดอยู่ในช่องพอดี ชิดขวาแนวเดียวกัน */
/* จำนวน / หน่วย / ราคา/หน่วย เป็นคอลัมน์ (ข้อ 3 ปรับ 21 พ.ย. 2569): จำนวนถึง 12,000.00 / ราคาต่อหน่วย 7 หลัก (งานเหมา) พอดีช่อง */
.sd-c-qty { width: 20mm; }
.sd-c-unit { width: 15mm; }
.sd-c-unitcost { width: 26mm; }
.sd-table th { background: #0F2547; color: #fff; font-size: 11pt; font-weight: 700; line-height: 1.35; padding: 1.2mm 1.5mm; text-align: center; border-left: 1px solid #2B4470; }
.sd-table th:first-child { border-left: 0; padding-left: 0.5mm; padding-right: 0.5mm; }
.sd-table td { padding: 1.6mm 2mm; border-top: 1px solid #E5E7EB; vertical-align: top; font-size: 11pt; line-height: 1.4; }
.sd-table td + td { border-left: 1px solid #E5E7EB; }
.sd-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 1.2mm; padding-right: 1.2mm; }
.sd-table .sd-no { white-space: nowrap; text-align: center; padding-left: 0.5mm; padding-right: 0.5mm; }
.sd-cat td { background: #DCE8F7; font-size: 11.5pt; font-weight: 700; border-top: 1px solid #A9C6EC; padding-top: 0.9mm; padding-bottom: 0.9mm; line-height: 1.35; }
.sd-sub td { background: #FDF3D7; font-size: 11pt; font-weight: 700; padding-top: 0.9mm; padding-bottom: 0.9mm; line-height: 1.35; }
.sd-sub .sd-name { padding-left: 4mm; }
.sd-legacy td { background: #F3F4F6; color: #374151; font-size: 11pt; font-weight: 700; padding-left: 4mm; }
.sd-item .sd-name { padding-left: 7mm; color: #111827; }
.sd-item-name { overflow-wrap: anywhere; }
.sd-table .sd-unit { text-align: center; padding-left: 1mm; padding-right: 1mm; overflow-wrap: anywhere; }
.sd-empty td { color: #6B7280; font-style: italic; padding-left: 7mm; }
/* บรรทัดปิดหมวด "รวมหมวด n" (ข้อ 27): หนากว่ารายการ / เส้นบนชัด / พื้นอ่อน — ไม่เด่นเท่ากล่องสรุปยอดรวม */
.sd-cattotal td { background: #F1F5F9; font-size: 11.5pt; font-weight: 700; border-top: 1.5px solid #64748B; }
/* ช่องเดียวคลุมรายการงาน + ต้นทุน: ขอบขวาเท่าช่องตัวเลข (1.2mm) → ต้นทุนรวม / ราคาที่เสนอ ชิดขวาแนวเดียวกับคอลัมน์ต้นทุน */
.sd-cattotal .sd-name { padding-left: 4mm; padding-right: 1.2mm; }
.sd-cattotal-line { display: flex; justify-content: space-between; align-items: baseline; gap: 4mm; }
.sd-table .sd-cattotal-cost .num { white-space: nowrap; font-variant-numeric: tabular-nums; padding: 0; }
.sd-cattotal-cost { display: flex; align-items: baseline; gap: 2.5mm; white-space: nowrap; }
.sd-cattotal-cost > span { font-size: 11pt; font-weight: 400; color: #374151; } /* ป้าย "ต้นทุน" แบบเดียวกับ "กำไร" / "ราคาที่เสนอ" */
/* บรรทัดล่างของ "รวมหมวด": กำไร … ราคาที่เสนอ … ชิดขวาสุดของตาราง */
.sd-catsum { display: flex; justify-content: flex-end; align-items: baseline; flex-wrap: wrap; gap: 0 2.5mm; margin-top: 0.6mm; font-size: 11pt; white-space: nowrap; }
.sd-catsum > span { font-weight: 400; color: #374151; }
.sd-catsum > b { font-weight: 700; font-variant-numeric: tabular-nums; }
.sd-catsum > b + span { margin-left: 4mm; }
.sd-profit { color: #15803D; }
.sd-totals { margin-top: 6mm; margin-left: auto; width: 100mm; border: 1px solid #CBD5E1; border-radius: 2.5mm; overflow: hidden; }
.sd-totals h2 { margin: 0; padding: 1.2mm 4mm; background: #0F2547; color: #fff; font-size: 11.5pt; font-weight: 700; line-height: 1.35; }
.sd-total { display: grid; grid-template-columns: 1fr auto 10mm; align-items: baseline; gap: 3mm; padding: 1.2mm 4mm; border-top: 1px solid #E5E7EB; font-size: 11pt; line-height: 1.4; }
.sd-total b { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.sd-grand { background: #FCE7A8; font-size: 13pt; font-weight: 700; }
@page sd-a4 { size: A4; margin: 0; }
@media print {
  html:has(body.sd-open) { color-scheme: light; } /* ขอบกระดาษไม่ตามธีมมืด */
  body.sd-open > :not(.sd-overlay) { display: none !important; }
  body.sd-open .sd-overlay { position: static; display: block; background: #fff; }
  body.sd-open .sd-scroll { overflow: visible; padding: 0; }
  body.sd-open .sd-sheets { zoom: 1 !important; width: auto; margin: 0; }
  .sd-page { margin: 0; box-shadow: none; break-after: page; }
  .sd-page:last-child { break-after: auto; }
  .sd-page, .sd-page * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- พิมพ์ / บันทึก PDF (A4) ---------- */
@page { size: A4; margin: 12mm; }
@page qdsheet { size: A4; margin: 6mm 12mm 12mm; }
@media print {
  html, body { background: #fff !important; color: #000; }
  /* ขอบกระดาษ (margin ของ @page) ไม่ตามธีมมืด — เปิด "กราฟิกพื้นหลัง" แล้วขอบเคยเป็นสีดำ (แบบเดียวกับใบสรุป) */
  html { color-scheme: light !important; }
  .topbar, .bottomnav, .no-print, .toast, .warn-chip, .modal-backdrop { display: none !important; }
  main { max-width: none; padding: 0 !important; margin: 0; }
  .page { padding: 0 !important; }
  .quote-paper { overflow: visible; border-radius: 0; }
  .quote-doc { border-radius: 0; padding: 0; font-size: 10.5pt; min-width: 0; overflow: visible; zoom: 1 !important; }
  .qd-sheets { zoom: 1 !important; display: block !important; }
  /* แผ่นหลายหน้า: หน้ากระดาษแบบ qdsheet (ขอบบน 6 มม.) + เว้นบนในแผ่น 6 มม. = เนื้อหาเริ่มที่ 12 มม. เท่าเดิม / แผ่นสูงเต็มหน้า → เลขหน้าอยู่มุมขวาบนของหน้าตัวเอง */
  .quote-doc.qd-sheet { page: qdsheet; height: 279mm !important; padding-top: 6mm !important; box-sizing: border-box; overflow: hidden !important; break-after: page; }
  .quote-doc.qd-sheet::after { top: 0; right: 0; }
  .quote-doc.qd-sheet:last-child { break-after: auto; }
  .quote-doc.qd-sheet + .quote-doc.qd-sheet .qd-watermark { display: none; } /* ลายน้ำ position: fixed ซ้ำทุกหน้าอยู่แล้ว */
  .qd-watermark { position: fixed; inset: 0; }
  .qd-watermark span { font-size: 40pt; }
  .qd-table thead { display: table-header-group; }
  .qd-table tr, .qd-totals, .qd-notes { break-inside: avoid; }
  .qd-table th, .qd-group td, .qd-cat td, .qd-cattotal td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- หน้าแรก (Welcome): สีตามภาพตัวอย่าง (21 พ.ย. 2569) — ใช้ทุกธีม เพราะหน้าแรกอยู่บนพื้น Blueprint น้ำเงินเข้มเสมอ ----------
   วางท้ายไฟล์ให้ชนะกติกาการ์ดขาวของธีม Light (ความเจาะจงเท่ากัน ลำดับหลังชนะ) */
html .auth-card.auth-welcome {
  --text: #F8FAFC;
  --muted: #A9B8D6;
  --border: rgba(122, 152, 210, 0.32);
  background: linear-gradient(180deg, rgba(22, 36, 72, 0.94) 0%, rgba(12, 22, 48, 0.94) 100%);
  border: 1px solid rgba(122, 152, 210, 0.38);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--text);
}
html .auth-welcome h1 { color: #FFFFFF; }
html .auth-welcome .auth-tagline { color: #B7C6E2; }
/* ปุ่ม Guest: ส้มไล่เฉดเล็กน้อย (บนอ่อน → ล่างเข้ม) เงาส้ม */
html .auth-welcome .auth-guest { background: linear-gradient(180deg, #FBBF24 0%, #F59E0B 100%); color: #0F172A; box-shadow: 0 8px 20px rgba(245, 158, 11, 0.32); }
html .auth-welcome .auth-guest:hover { background: linear-gradient(180deg, #FCD34D 0%, #FBBF24 100%); }
/* ไอคอนจุดเด่น: กล่องน้ำเงินมุมมน ไอคอนฟ้าอ่อน / ข้อความขาวนวล */
html .auth-welcome .auth-feats li { color: #E2E8F0; }
html .auth-welcome .auth-feat-icon {
  box-sizing: content-box; width: 22px; height: 22px; padding: 9px; border-radius: 11px;
  color: #D6E4FF; background: linear-gradient(180deg, #23417C 0%, #1A3266 100%); border: 1px solid rgba(122, 160, 230, 0.4);
}

/* ================= หน้าคำนวณ: ปรับลำดับชั้น + Summary (22 พ.ย. 2569 — UI เท่านั้น ไม่แตะ Logic) =================
   หมวด (เด่นสุด) → งานย่อย (รองลงมา เยื้อง) → วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น (การ์ดของงานย่อย เยื้องตามบนจอกว้าง)
   Orange = Action / ตัวเลือกที่เลือกอยู่ — "ราคาที่เสนอรวม" ตัวเลขเด่นที่สุดของ Summary */

/* 1) หมวด: ป้ายและชื่อใหญ่ / หนักกว่างานย่อย */
.calc-category > .calc-cat-head { min-height: 50px; }
.calc-category > .calc-cat-head .calc-cat-label { font-size: 17px; font-weight: 800; padding-right: 16px; }
.calc-category > .calc-cat-head .calc-cat-name { font-size: 18px; font-weight: 800; }

/* 2) งานย่อย: ระดับรอง — ป้ายเล็กลง พื้นอ่อนกว่า ชื่อน้ำหนักกลาง */
.calc-sub-head { min-height: 44px; }
.calc-sub-head .calc-cat-label { font-size: 15px; font-weight: 700; padding: 0 12px 0 16px; } /* พื้นป้ายสีเดียวกับป้าย "หมวด" ตามเดิม (ไม่เปลี่ยนสี) — ต่างกันที่ขนาดเท่านั้น */
.calc-sub-head .calc-cat-name { font-size: 16px; font-weight: 600; min-height: 42px; }

/* 3) วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น ของงานย่อย: เยื้องตามหัวงานย่อยบนจอกว้าง (มือถือคงแนวเดิม ให้ช่องกรอกกว้างพอ) */
@media (min-width: 640px) {
  .calc-category .calc-sub-body,
  .calc-category .calc-sub-hint { margin-left: 24px; }
}

/* 4) ระยะ: [รายการ] → เพิ่มงานย่อย → (เว้นมากขึ้น) → เพิ่มหมวดงาน → สรุป (ไม่ห่างเกินจำเป็น) */
.calc-items-body > .calc-category ~ .calc-add-cat { margin-top: 32px; }
.calc-items-card .calc-items-body { padding-bottom: 16px; }

/* 5) "ดูสรุปรายการ": Secondary — กรอบบาง พื้นโปร่ง ไม่แย่งความสนใจจากตัวเลข */
.calc-doc-btn { border-width: 1.5px; background: transparent; box-shadow: none; }
.calc-doc-btn:hover { background: rgba(245, 158, 11, 0.14); }
html[data-theme="light"] .calc-doc-btn { background: transparent; box-shadow: none; }
/* ปุ่มลอย "สรุป" (ใช้ .calc-doc-btn ร่วมกัน) คงพื้นทึบ + เงาเดิม — ลอยทับเนื้อหา ต้องไม่โปร่ง (22 พ.ย. 2569) */
.calc-doc-btn.calc-fab { background: #1E293B; border-width: 2px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.calc-doc-btn.calc-fab:hover { background: #33302A; }
html[data-theme="light"] .calc-doc-btn.calc-fab { background: #FFFFFF; box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22); }
html[data-theme="light"] .calc-doc-btn.calc-fab:hover { background: #FEF3C7; }

/* 6) กำไรที่ต้องการ: ตัวที่เลือกอยู่ = ส้มทึบ (Accent) / ที่ไม่ได้เลือก = กรอบ */
.profit-btn.active,
html[data-theme="light"] .profit-btn.active { background: #F59E0B; border-color: #F59E0B; color: #0F172A; font-weight: 700; }

/* 7) ราคาที่เสนอรวม: ป้ายและตัวเลขเด่นที่สุดของ Summary (ยังเป็นช่องแก้ได้ตามเดิม — ไม่ใช่ปุ่ม) */
.calc-summary .sell-total > span { font-size: 17px; font-weight: 700; }
.calc-summary .total-input { font-size: 32px; }
@media (max-width: 360px) { .calc-summary .total-input { font-size: 28px; } }
@media (max-width: 340px) { .calc-summary .total-input { font-size: 23px; padding-left: 8px; padding-right: 8px; } } /* 320px: ยอด 7 หลัก (2,013,779) อยู่ในช่องพอดี (เดิมล้น) */

/* ================= หน้าคำนวณ ชุดที่ 2: Layout ตามภาพ Reference (22 พ.ย. 2569 — SCOPE 3.2.3 ข้อ 22) =================
   หัว Cost Section: ไอคอน + ชื่อ (ชื่องานย่อย/หมวด) / สถานะ / ＋ เพิ่ม… / ▾ — มือถือ < 480px เป็น 2 บรรทัด
   แถวปุ่ม งานย่อย + หมวดงาน: จอ ≥ 600px แถวเดียว / Summary: ต้นทุนรวม | กำไรที่ต้องการ 2 คอลัมน์บนจอ ≥ 600px */

/* ไอคอนเส้นบาง (มีข้อความกำกับเสมอ) */
.calc-icon { width: 20px; height: 20px; flex: 0 0 auto; color: #CBD5E1; }
html[data-theme="light"] .calc-icon { color: #334155; }

/* หัว Cost Section */
.calc-type-head { display: flex; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; min-height: 56px; }
.calc-type-head h2 { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.calc-type-head h2 .calc-group-of { flex: 0 1 auto; }
.calc-group-status { flex: 0 0 auto; font-size: 14px; color: var(--muted); white-space: nowrap; }
/* จำนวนรายการบนหัวการ์ด ("n รายการ"): อ่านง่ายขึ้น — สว่างกว่า --muted เล็กน้อย + หนาขึ้น (ไม่ใช้สีเหลือง / ขนาด-ตำแหน่งเดิม) */
.calc-group-status { color: #CBD5E1; font-weight: 600; }
html[data-theme="light"] .calc-group-status { color: #334155; } /* Light: หัวการ์ดพื้นสว่าง → เทาเข้มแทน */
/* มีรายการแล้ว → ป้ายเม็ดยาพื้นส้มอ่อน ตัวเลขส้มหนาใหญ่ (ปรับ 29 พ.ย. 2569) / "ยังไม่มีรายการ" คงแบบจาง */
.calc-group-status.has-items { display: inline-flex; align-items: baseline; gap: 4px; padding: 3px 12px; border-radius: 999px; background: rgba(245, 158, 11, 0.16); border: 1px solid rgba(245, 158, 11, 0.45); color: #F1F5F9; }
.calc-group-status.has-items b { font-size: 17px; font-weight: 800; color: #FBBF24; }
html[data-theme="light"] .calc-group-status.has-items { background: #FEF3C7; border-color: #FCD34D; color: #1F2937; }
html[data-theme="light"] .calc-group-status.has-items b { color: #B45309; }
.calc-head-add {
  flex: 0 0 auto; min-height: 36px; padding: 6px 14px; border: 1.5px solid #F59E0B; border-radius: 999px;
  background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s ease;
}
.calc-head-add:hover, .calc-head-add:active { background: rgba(245, 158, 11, 0.16); }
.calc-head-add:focus-visible, .calc-group-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
html[data-theme="light"] .calc-head-add { border-color: #B45309; color: #0F172A; }
.calc-group-toggle {
  flex: 0 0 auto; width: 36px; height: 36px; min-height: 0; padding: 0; margin-right: -6px; border: 0; border-radius: 8px;
  display: grid; place-items: center; background: transparent; color: var(--text); cursor: pointer;
}
.calc-group-toggle:hover { background: rgba(148, 163, 184, 0.16); }
.calc-chevron { width: 22px; height: 22px; transition: transform 0.2s ease; }
.calc-group.is-collapsed .calc-chevron { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .calc-chevron { transition: none; } }
/* พับอยู่ / ส่วนว่าง (ไม่มีเนื้อหาใต้หัว) → ไม่มีเส้นคั่นใต้หัว */
.calc-group.is-collapsed > .calc-type-head,
.calc-type-head:has(+ .calc-group-body:empty) { border-bottom: 0; }
.calc-group-body[hidden] { display: none; }
@media (max-width: 479px) {
  .calc-type-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "title title toggle" "status add add"; gap: 8px 8px; }
  .calc-type-head h2 { grid-area: title; }
  .calc-type-head .calc-group-toggle { grid-area: toggle; justify-self: end; }
  .calc-type-head .calc-group-status { grid-area: status; align-self: center; }
  .calc-type-head .calc-head-add { grid-area: add; justify-self: end; }
  .calc-legacy .calc-type-head { grid-template-areas: "title title toggle" "status status status"; }
}

/* แถวปุ่ม: [＋ เพิ่มงานย่อย (หมวดสุดท้าย)] [＋ เพิ่มหมวดงาน] */
.calc-pill-row { margin-top: 20px; }
.calc-items-body > .calc-pill-row:first-child { margin-top: 0; }
.calc-pill-row > .calc-pill, .calc-pill-row > .calc-add-cat-hint { margin-top: 0; }
.calc-pill-row > .calc-add-sub { left: 0; }
.calc-pill-row > .calc-add-sub:not([hidden]) ~ .calc-add-cat,
.calc-pill-row > .calc-add-sub:not([hidden]) ~ .calc-add-cat-hint { margin-top: 32px; } /* มือถือ: บน–ล่าง เว้นระยะไม่ให้ดูเป็นปุ่มเดียวกัน */
@media (min-width: 600px) {
  .calc-pill-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 16px; }
  .calc-pill-row > .calc-pill { flex: 0 1 260px; margin: 0; }
  .calc-pill-row > .calc-add-sub:not([hidden]) ~ .calc-add-cat,
  .calc-pill-row > .calc-add-sub:not([hidden]) ~ .calc-add-cat-hint { margin-top: 0; }
  .calc-pill-row > .calc-add-cat-hint { flex: 1 1 260px; }
}

/* Summary */
.calc-summary > .calc-group-head h2 { display: flex; align-items: center; gap: 8px; }
.calc-summary > .calc-group-head .calc-icon { color: var(--accent-line); }
.calc-summary .sell-total > span { display: inline-flex; align-items: center; gap: 8px; }
.calc-summary .sell-total .calc-icon { width: 22px; height: 22px; color: var(--accent-line); }
.calc-summary .total-input { flex: 1 1 200px; max-width: 420px; }
/* ส่วนบนของสรุป (ทุกความกว้าง): ต้นทุนรวม → กำไรที่ต้องการ เรียงลงตามสูตร (SCOPE 3.2) ตัวเลข/ปุ่มชิดขวาแนวเดียวกับราคาที่เสนอรวม
   ป้าย "กำไรที่ต้องการ" กับปุ่มอยู่บรรทัดเดียวกัน — ที่ไม่พอ (จอแคบ / เปิด "กำหนดเอง") ปุ่มตกลงไปบรรทัดใต้ป้าย */
.calc-sum-top > .calc-total { padding-bottom: 6px; }
.calc-sum-top > .profit-line { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; border-top: 0; padding-top: 6px; }
.calc-sum-top > .profit-line .profit-row { margin-left: auto; flex-wrap: nowrap; justify-content: flex-end; max-width: 100%; } /* ปุ่ม + ช่อง % บรรทัดเดียวกันเสมอ (3.2) — ที่ไม่พอ ทั้งแถวลงไปใต้ป้าย */
.calc-sum-top > .profit-line .profit-buttons { width: auto; justify-content: flex-end; }
.calc-sum-top > .profit-line .profit-label { font-size: 16px; font-weight: 400; color: var(--text); } /* ป้ายแบบเดียวกับ "ต้นทุนรวม" */
.calc-type-name { white-space: nowrap; }
/* จอ < 600px: "ราคาที่เสนอรวม" ป้ายอยู่บน ช่องตัวเลขเต็มความกว้างด้านล่าง (ยอด 7 หลักไม่ล้น / ยังเป็นช่องแก้ได้) */
@media (max-width: 599px) {
  .calc-summary .sell-total { flex-wrap: wrap; row-gap: 8px; }
  .calc-summary .sell-total > span { flex: 1 1 100%; }
  .calc-summary .total-input { flex: 1 1 100%; max-width: none; }
}
/* "ราคาในใบเสนอ" แก้ได้ (SCOPE 3.2 เพิ่ม 23 พ.ย. 2569): ช่องกรอกที่หน้าตาเหมือนตัวเลขเดิม (ฟอนต์ / ขนาด / ตำแหน่งตาม <b> เดิม)
   ข้อความซ่อน (.line-total-size) = ตัวเลขชุดเดียวกัน กำหนดความกว้างเท่าเดิมพอดี / ช่องกรอกวางทับ → คอลัมน์ / ความสูงแถวไม่ขยับ
   เส้นประใต้ตัวเลข = แตะแก้ได้ (ไม่กินพื้นที่) */
.calc-row .line-total { position: relative; display: inline-block; min-width: 0; }
.calc-row .line-total-size { visibility: hidden; white-space: pre; }
.calc-row .calc-line-total {
  position: absolute; inset: 0; width: 100%; height: 100%;
  font: inherit; color: inherit; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: inherit;
  min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 4px; box-shadow: none;
  background: transparent linear-gradient(to right, var(--accent-line) 55%, transparent 0) 0 100% / 5px 1px repeat-x;
  cursor: text;
}
.calc-row .calc-line-total:focus { outline: 2px solid var(--accent-line); outline-offset: 2px; background: var(--surface); box-shadow: none; }
.calc-row .calc-line-total[readonly] { background: transparent; cursor: default; }
.calc-row .calc-line-total[readonly]:focus { outline: 0; }
/* แถบ "＋ เพิ่ม…" ท้ายรายการ (23 พ.ย. 2569): กดได้เฉพาะก้อนรอบตัวหนังสือ (สูงเต็มแถบ) — ขอบซ้าย / ขวาของแถบกดไม่ได้ กันนิ้วพลาด
   ปกติหน้าตาเหมือนเดิม (ตัวหนังสือส้มกลางแถบ ไม่มีกรอบ) / ชี้หรือแตะ → พื้นส้มจางขอบมนเฉพาะรอบตัวหนังสือ (แทนการไฮไลต์ทั้งแถบ) */
.calc-group .calc-group-body > .calc-add-row { pointer-events: none; background: transparent; padding-top: 0; padding-bottom: 0; align-items: stretch; }
.calc-group .calc-group-body > .calc-add-row:hover, .calc-group .calc-group-body > .calc-add-row:active,
html[data-theme] .calc-group .calc-group-body > .calc-add-row:hover, html[data-theme] .calc-group .calc-group-body > .calc-add-row:active { background: transparent; }
.calc-group-body > .calc-add-row .calc-add-hit {
  pointer-events: auto; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0 20px; border-radius: 999px; transition: background-color 0.15s ease;
}
.calc-group-body > .calc-add-row .calc-add-hit:hover { background: rgba(245, 158, 11, 0.12); }
.calc-group-body > .calc-add-row .calc-add-hit:active { background: rgba(245, 158, 11, 0.2); }
.calc-icon-worker { stroke-width: 1.4; } /* ไอคอนค่าแรงรายละเอียดมาก → เส้นบางกว่าไอคอนอื่น ให้อ่านออกที่ 20px */

/* ================= แถวรายการต้นทุน: Desktop 2 บรรทัด (22 พ.ย. 2569 — UI เท่านั้น / มือถือ < 600px คงเดิม) =================
   บรรทัด 1: [ชื่อรายการ (กว้างสุด ~45–50%)] [จำนวน] [หน่วย] [ราคาต่อหน่วย] [✕]
   บรรทัด 2: [ราคาที่เสนอ/หน่วย + กำไร % + ช่องราคา]            [ราคาในใบเสนอ / ทุน]
   ใช้ grid บนแถวเดิม (display: contents กับกล่องย่อย) — ไม่เปลี่ยน HTML / ช่องกรอก / ลำดับ Tab */
@media (min-width: 600px) {
  .calc-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(72px, 12%) minmax(60px, 13%) minmax(96px, 20%) 36px;
    grid-template-areas:
      "name qty  unit price remove"
      "sell sell line line  line"
      "sell sell cost cost  cost";
    column-gap: 8px;
    row-gap: 6px;
    align-items: end;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .calc-row > .calc-row-top,
  .calc-row > .calc-inputs { display: contents; }
  .calc-row .calc-name { grid-area: name; min-height: 40px; padding: 8px 12px; }
  .calc-row .calc-remove { grid-area: remove; justify-self: center; width: 36px; height: 40px; min-height: 0; }
  .calc-row .calc-inputs > :nth-child(1) { grid-area: qty; }
  .calc-row .calc-inputs > :nth-child(2) { grid-area: unit; }
  .calc-row .calc-inputs > :nth-child(3) { grid-area: price; }
  .calc-row .row-sell { grid-area: sell; margin-top: 2px; align-self: start; min-width: 0; }
  .calc-row .row-sell .money-sm { flex: 0 1 180px; min-width: 120px; }
  .calc-row .calc-line { grid-area: line; margin-top: 2px; justify-content: flex-end; gap: 10px; align-self: start; min-width: 0; }
  .calc-row .calc-line .line-label { white-space: nowrap; }
  .calc-row .line-cost { grid-area: cost; margin-top: 0; align-self: start; }
  .calc-row .line-cost:empty { display: none; }
}

/* ================= แถวรายการต้นทุน: แถวเดียว (22 พ.ย. 2569 — UI เท่านั้น) =================
   # | ชื่อรายการ | จำนวน | หน่วย | ราคาต่อหน่วย | ราคาที่เสนอ/หน่วย (+%) | ราคาในใบเสนอ | ทุน | ×
   - ใช้เมื่อ "พื้นที่ของรายการ" กว้างพอ (container ≥ 800px ≈ จอ ≥ 1000px) — แคบกว่านั้น: 2 บรรทัด (≥ 600px) / มือถือ (< 600px) เดิม
   - หัวตารางครั้งเดียวต่อส่วน (ไม่มีป้ายซ้ำทุกแถว) / คอลัมน์ตรงกันทุกแถวด้วย subgrid / ตัวเลขยาวขยายคอลัมน์เอง
   - ไม่เปลี่ยน HTML ของช่องกรอก / สูตร / บันทึกอัตโนมัติ — ป้ายของช่องยังอยู่สำหรับโปรแกรมอ่านหน้าจอ (ซ่อนแบบ visually-hidden) */
.row-no, .line-cost-num, .row-sell-pct-short, .calc-rows-head { display: none; }
.calc-group-body { container: rows / inline-size; }
@container rows (min-width: 800px) {
  .calc-rows {
    display: grid;
    grid-template-columns:
      [no] 22px [name] minmax(150px, 1fr) [qty] 60px [unit] 60px [cost] 80px
      [sell] minmax(132px, max-content) [total] minmax(80px, max-content) [costc] minmax(64px, max-content) [rm] 28px;
    column-gap: 6px;
    padding: 4px 10px 6px;
  }
  .calc-rows-head, .calc-rows > .calc-row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; grid-template-areas: none; }
  /* หัวตาราง */
  .calc-rows-head { align-items: end; padding: 6px 0 6px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--muted); }
  .calc-rows-head > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .calc-rows-head > :nth-child(1), .calc-rows-head > :nth-child(n + 3) { text-align: right; }
  .calc-rows-head > :nth-child(4) { text-align: center; }
  .calc-rows-head > :nth-child(6) { text-align: left; }
  /* แถว: ไม่เป็นการ์ด / เส้นคั่นบาง / เตี้ย */
  .calc-rows > .calc-row { align-items: center; row-gap: 0; padding: 4px 0; margin: 0; border: 0; border-bottom: 1px solid rgba(148, 163, 184, 0.1); border-radius: 0; background: transparent; }
  .calc-rows > .calc-row:last-child { border-bottom: 0; }
  .calc-row > .calc-row-top, .calc-row > .calc-inputs, .calc-row > .calc-line { display: contents; }
  /* ทุกช่องอยู่แถวเดียว (กำหนดแถวตรง ๆ — ไม่ให้ลำดับใน HTML ดันช่องลงบรรทัดถัดไป) */
  .calc-rows > .calc-row > *, .calc-row > .calc-row-top > *, .calc-row > .calc-inputs > *, .calc-row > .calc-line > * { grid-row: 1; }
  .calc-row .row-no { display: block; grid-column: no; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .calc-row .calc-name { grid-area: 1 / name; min-height: 36px; padding: 6px 10px; font-size: 15px; font-weight: 600; border-radius: 8px; }
  .calc-row .calc-inputs > :nth-child(1) { grid-area: 1 / qty; }
  .calc-row .calc-inputs > :nth-child(2) { grid-area: 1 / unit; }
  .calc-row .calc-inputs > :nth-child(3) { grid-area: 1 / cost; }
  .calc-row .calc-inputs .mini-field input { min-height: 36px; height: 36px; padding: 4px 6px; font-size: 15px; font-weight: 400; border-radius: 8px; }
  .calc-row .calc-inputs .calc-unit { text-align: center; }
  /* ป้ายของช่อง: ซ่อนจากสายตา (ยังอ่านได้ด้วยโปรแกรมอ่านหน้าจอ) */
  .calc-row .mini-field > span, .calc-row .row-sell-title, .calc-row .line-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  /* ราคาที่เสนอ/หน่วย: [ช่องราคา] (+30%) [ปรับเอง ✕ / ระบบปรับ] */
  .calc-row .row-sell { grid-area: 1 / sell; align-self: center; display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 6px; margin: 0; padding: 0; background: transparent; border-radius: 0; min-width: 0; }
  .calc-row .row-sell .money-sm { flex: 0 0 84px; min-width: 0; }
  .calc-row .row-sell .money-sm input { min-height: 36px; height: 36px; padding: 4px 6px; font-size: 15px; font-weight: 700; border-radius: 8px; }
  .calc-row .row-sell-label { flex: 0 0 auto; gap: 4px; }
  .calc-row .row-sell-badge { flex-wrap: nowrap; gap: 4px; }
  .calc-row .row-sell-pct { display: none; }
  .calc-row .row-sell-pct-short { display: inline; order: -1; font-size: 12px; font-weight: 500; line-height: 1; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; padding: 0; background: none; border: 0; }
  .calc-row .row-sell-pct-short:empty { display: none; }
  .calc-row .row-sell-pct-short.neg { color: var(--neg); }
  /* ป้าย "ปรับเอง ✕" แบบกระชับ: เหลือรูปกุญแจ + ✕ (ข้อความยังอยู่ใน aria-label) */
  .calc-row button.tag-manual { font-size: 0; gap: 2px; padding: 2px 6px; min-height: 22px; }
  .calc-row button.tag-manual > span { font-size: 12px; }
  .calc-row .tag-system { font-size: 11px; padding: 1px 6px; }
  /* ราคาในใบเสนอ (เด่น) / ทุน (รอง) */
  .calc-row .line-total { grid-area: 1 / total; text-align: right; font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .calc-row .line-cost { display: none; }
  .calc-row .line-cost-num { display: block; grid-area: 1 / costc; text-align: right; font-size: 13px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .calc-row .calc-remove { grid-area: 1 / rm; width: 28px; min-width: 0; height: 32px; padding: 0; justify-self: center; }
}
/* Light: แถวไม่เป็นการ์ดฟ้าแยก (เฉพาะแถวเดียว) */
@container rows (min-width: 800px) {
  html[data-theme="light"] .calc-rows > .calc-row { background: transparent; border-radius: 0; margin: 0; padding: 4px 0; border-bottom: 1px solid rgba(15, 23, 42, 0.07); }
  html[data-theme="light"] .calc-rows > .calc-row:last-child { border-bottom: 0; }
  html[data-theme="light"] .calc-row .row-sell { background: transparent; padding: 0; }
}

/* ================= ตารางต้นทุน (แถวเดียว): ปุ่มเพิ่ม / ความกระชับ (22 พ.ย. 2569 — Desktop เท่านั้น) =================
   ใช้เกณฑ์เดียวกับแถวเดียว (กว้าง ≥ 800px) — มือถือ / 2 บรรทัด ไม่เปลี่ยน */
.calc-group { container: section / inline-size; }
@container section (min-width: 800px) {
  /* ปุ่ม "＋ เพิ่ม…" บนหัวการ์ด: กระชับ กึ่งกลางแนวตั้ง */
  .calc-type-head .calc-head-add { align-self: center; height: 36px; min-height: 36px; padding: 0 15px; font-size: 15px; border-radius: 18px; }
}
@container rows (min-width: 800px) {
  /* ปุ่ม "＋ เพิ่ม…" ท้ายตาราง: แถว Add Row เบา ๆ (ไม่ใช่แถบทึบ) — ทำงานเหมือนเดิม */
  .calc-group-body > .calc-add-row {
    height: 42px; min-height: 42px; margin: 0; padding: 0 12px;
    background: transparent; border: 0; border-top: 1px solid rgba(148, 163, 184, 0.12); border-radius: 0; box-shadow: none;
    font-size: 15px; font-weight: 600; color: var(--primary); cursor: pointer;
    transition: color 0.15s ease; /* ไม่ transition พื้นหลัง: ตอนเปลี่ยนผัง (2 บรรทัด → แถวเดียว) พื้นเดิมต้องไม่ค้าง */
  }
  .calc-group-body > .calc-add-row:hover { background: rgba(245, 158, 11, 0.06); color: #FBBF24; }
  .calc-group-body > .calc-add-row:active { background: rgba(245, 158, 11, 0.1); }
  html[data-theme="light"] .calc-group-body > .calc-add-row { background: transparent; border-top-color: rgba(15, 23, 42, 0.07); color: #B45309; }
  html[data-theme="light"] .calc-group-body > .calc-add-row:hover { background: rgba(245, 158, 11, 0.08); color: #92400E; }
  /* แถวกระชับขึ้นเล็กน้อย (ช่องกรอกยังสูง 36px กดง่าย) */
  .calc-rows > .calc-row, html[data-theme="light"] .calc-rows > .calc-row { padding-top: 3px; padding-bottom: 3px; }
  .calc-rows { padding-bottom: 4px; }
}

/* ================= รายการต้นทุน: มือถือ (< 600px) กระชับขึ้น (22 พ.ย. 2569 — Mobile เท่านั้น / Desktop ไม่เปลี่ยน) =================
   Card เดิม: ชื่อ ✕ / จำนวน · หน่วย · ราคาต่อหน่วย / ราคาที่เสนอ (+กำไร) บรรทัดเดียว / ราคาในใบเสนอ / ทุน — เป้าหมาย ~180–210px ต่อรายการ */
@media (max-width: 599px) {
  /* หัว Section: กระชับ / ปุ่มเพิ่ม 34px */
  .calc-type-head { padding-top: 8px; padding-bottom: 8px; min-height: 0; gap: 6px 8px; }
  .calc-type-head .calc-head-add { height: 34px; min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 17px; }
  .calc-type-head .calc-group-toggle { width: 34px; height: 34px; }
  /* Card รายการ: ระยะในและระหว่างบรรทัดน้อยลง */
  .calc-rows { padding: 4px 6px; }
  .calc-rows > .calc-row { padding: 6px 4px; }
  html[data-theme="light"] .calc-rows > .calc-row { padding: 6px; margin-bottom: 6px; }
  /* ชื่อรายการ: เต็มความกว้าง / สูง 40px */
  .calc-row .calc-name { min-height: 40px; padding: 8px 10px; font-size: 16px; }
  .calc-row .calc-remove { flex: 0 0 36px; width: 36px; height: 40px; }
  /* จำนวน · หน่วย · ราคาต่อหน่วย = 25 / 25 / 50 บรรทัดเดียว */
  .calc-row .calc-inputs,
  .calc-inputs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); gap: 6px; margin-top: 4px; }
  .calc-row .calc-inputs .mini-field input { min-height: 40px; height: 40px; padding: 6px; font-size: 16px; }
  .calc-row .mini-field { gap: 1px; }
  .calc-row .mini-field > span { font-size: 11px; line-height: 1.2; }
  /* ราคาที่เสนอ/หน่วย  กำไร 30%  [ ราคา ] — บรรทัดเดียว */
  .calc-row .row-sell { flex-wrap: nowrap; gap: 6px; margin-top: 4px; }
  .calc-row .row-sell-label { flex: 0 1 auto; min-width: 0; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0 6px; }
  /* ปกติอยู่บรรทัดเดียว / จอแคบมาก + ป้าย "ปรับเอง" ไม่พอ → "กำไร x%" ลงใต้ป้าย (ไม่ทับ ไม่ล้น) */
  .calc-row .row-sell-title { flex: 0 0 auto; white-space: nowrap; font-size: 13px; }
  .calc-row .row-sell-badge { flex-wrap: nowrap; gap: 4px; }
  .calc-row .row-sell-pct { font-size: 12px; white-space: nowrap; }
  .calc-row .row-sell .money-sm { flex: 1 0 96px; min-width: 96px; max-width: 46%; margin-left: auto; }
  .calc-row .row-sell .money-sm input { min-height: 40px; height: 40px; padding: 6px 10px; font-size: 16px; font-weight: 700; }
  html[data-theme="light"] .calc-row .row-sell { padding: 2px 6px; }
  /* ป้าย "ปรับเอง ✕" แบบกระชับ (กุญแจ + ✕) ให้ทั้งแถวอยู่บรรทัดเดียว — ข้อความยังอยู่ใน aria-label */
  .calc-row button.tag-manual { font-size: 0; gap: 2px; padding: 2px 6px; min-height: 22px; }
  .calc-row button.tag-manual > span { font-size: 12px; }
  .calc-row .tag-system { font-size: 11px; padding: 1px 6px; white-space: nowrap; }
  /* ราคาในใบเสนอ (เด่น) / ทุน (รอง): ป้ายซ้าย ตัวเลขขวา */
  .calc-row .calc-line { margin-top: 4px; min-height: 24px; padding: 0 2px; }
  .calc-row .calc-line .line-label { font-size: 13px; }
  .calc-row .calc-line b { font-size: 16px; }
  .calc-row .line-cost:not(.is-hint) { display: none; }
  .calc-row:not(:has(.line-cost.is-hint)) .line-cost-num { display: flex; justify-content: space-between; align-items: baseline; min-height: 20px; padding: 0 2px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .calc-row .line-cost-num::before { content: "ทุน"; }
  /* ปุ่ม "＋ เพิ่ม…" ท้ายรายการ: แถว Add Row เบา ๆ (ไม่ใช่แถบสูง) */
  .calc-group-body > .calc-add-row {
    height: 42px; min-height: 42px; margin: 0; padding: 0 12px;
    background: transparent; border: 0; border-top: 1px solid rgba(148, 163, 184, 0.12); border-radius: 0; box-shadow: none;
    font-size: 15px; font-weight: 600; color: var(--primary); transition: color 0.15s ease;
  }
  .calc-group-body > .calc-add-row:active { background: rgba(245, 158, 11, 0.1); }
  html[data-theme="light"] .calc-group-body > .calc-add-row { background: transparent; border-top-color: rgba(15, 23, 42, 0.07); color: #B45309; }
}
/* จอแคบมาก (< 360px): ช่องตัวเลขเว้นขอบน้อยลง ให้ "12000" / "ตร.ม." พอดีช่อง */
@media (max-width: 359px) { .calc-row .calc-inputs .mini-field input { padding-left: 4px; padding-right: 4px; } }

/* ================= สถานะราคาของรายการ: ข้อความเล็กในช่องเดียวกับกำไร % (SCOPE 3.2 ปรับ 22 พ.ย. 2569) =================
   +30% / ปรับเอง / ระบบปรับ — DOM เดิม / ช่องกว้างคงที่ → คอลัมน์และความสูงแถวไม่ขยับเมื่อสถานะเปลี่ยน
   ไม่มี badge / กรอบ / พื้นหลัง / กุญแจ / ✕ — แตะ "ปรับเอง" = กลับไปใช้ราคาจาก % (ปุ่มเดิม data-reset-sell) */
.calc-row .row-sell-badge { flex: 0 0 auto; width: 76px; min-width: 76px; max-width: 76px; overflow: hidden; flex-wrap: nowrap; }
.calc-row button.tag-manual,
.calc-row .tag-system {
  display: inline; min-height: 0; height: auto; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
  font: inherit; font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--muted); white-space: nowrap;
}
.calc-row button.tag-manual { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.calc-row button.tag-manual:hover, .calc-row button.tag-manual:focus-visible { color: var(--text); background: none; }
.calc-row button.tag-manual[hidden], .calc-row .tag-system[hidden] { display: none; }
.calc-row button.tag-manual .tag-lock, .calc-row button.tag-manual > span { display: none; }
html[data-theme="light"] .calc-row .tag-system, html[data-theme="light"] .calc-row button.tag-manual { background: none; border: 0; color: var(--muted); }
/* ราคาที่ปรับ (เอง / ระบบ) → แสดงสถานะแทน % ในช่องเดียวกัน */
.calc-row .row-sell-badge:has(> .tag-manual:not([hidden]), > .tag-system:not([hidden])) > .row-sell-pct,
.calc-row .row-sell-badge:has(> .tag-manual:not([hidden]), > .tag-system:not([hidden])) > .row-sell-pct-short { display: none; }
/* แถวเดียว (Desktop): ช่องสถานะแคบ ชิดราคา */
@container rows (min-width: 800px) {
  .calc-row .row-sell-badge { width: 54px; min-width: 54px; max-width: 54px; }
}
/* ปรับเอง → กำไรจริงเป็น % สีส้ม + เส้นประใต้ แทนคำว่า "ปรับเอง" (SCOPE 3.2 ปรับ 23 พ.ย. 2569) — ปุ่ม / ช่องเดิม กว้างเท่าเดิม
   มือถือ / 2 บรรทัด: "กำไร 33.3%" / แถวเดียว: "+33.3%" / ขาดทุน: สีแดง / ทุน 0: ไม่มี has-pct → "ปรับเอง" เดิม */
.calc-row button.tag-manual.has-pct { font-size: 0; text-decoration: none; }
.calc-row button.tag-manual.has-pct::after {
  content: attr(data-pct-long); font-size: 12px; font-weight: 600; color: var(--accent-line); font-variant-numeric: tabular-nums;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.calc-row button.tag-manual.has-pct.neg::after { color: var(--neg); }
.calc-row button.tag-manual.has-pct:hover::after, .calc-row button.tag-manual.has-pct:focus-visible::after { text-decoration-style: solid; }
html[data-theme="light"] .calc-row button.tag-manual.has-pct:not(.neg)::after { color: #B45309; }
@container rows (min-width: 800px) {
  .calc-row button.tag-manual.has-pct::after { content: attr(data-pct-short); }
}

/* ข้อมูลในใบเสนอราคา: ผู้เสนอราคา (ตั้งค่าแล้ว) = แถบเดียว — ชื่อกิจการยาวตัด … / ปุ่มแก้ไขกดง่าย (44px) */
.quote-seller { display: flex; align-items: stretch; gap: 0; padding: 0; overflow: hidden; }
/* ป้าย "ผู้เสนอราคา" = พื้นหัว Section + แถบเหลืองด้านซ้าย (แบบป้าย "หมวด" ในหน้าคำนวณ) */
.quote-seller-label::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-line); }
.quote-seller-label { position: relative; flex: 0 0 auto; display: flex; align-items: center; padding: 0 14px 0 18px; background: var(--surface-head); border-right: 1px solid var(--border); font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }
.quote-seller-name { flex: 1 1 auto; align-self: center; min-width: 0; padding-left: 12px; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-seller-edit { flex: 0 0 auto; align-self: center; margin-right: 4px; display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--text); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.quote-seller-edit:hover { background: var(--surface-2); }
/* งาน: แถบเดียวแบบผู้เสนอราคา — ช่องชื่องานอยู่ในแถบ */
.quote-job { margin-top: 12px; }
.quote-job .quote-seller-label { cursor: pointer; }
.quote-job-input { flex: 1 1 auto; min-width: 0; align-self: center; margin: 6px; min-height: 44px; }
/* modal รายการในใบ: แยกหมวด → งานย่อย / ชื่อ + จำนวน หน่วย (ไม่มีราคา) */
.quote-view-items { border: 0; background: none; cursor: pointer; font: inherit; }
.items-sheet .modal-body { padding-bottom: 16px; }
.qi-group + .qi-group { margin-top: 16px; }
.qi-cat { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; padding: 8px 12px; border-radius: 10px; background: var(--surface-head); border-left: 3px solid var(--accent-line); font-size: 16px; font-weight: 700; color: var(--text); }
.qi-sub { display: flex; align-items: center; gap: 6px; margin: 10px 0 2px 6px; font-size: 14px; font-weight: 700; color: var(--primary); }
.qi-no { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--muted); }
.qi-cat .qi-no { color: var(--muted); }
.qi-list { list-style: none; margin: 0; padding: 0 0 0 6px; }
.qi-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.qi-row:last-child { border-bottom: 0; }
.qi-name { min-width: 0; overflow-wrap: anywhere; }
.qi-qty { flex: 0 0 auto; color: var(--muted); white-space: nowrap; }
.qi-empty { margin: 4px 0 0 12px; }
/* ส่วนลด / VAT / ยืนราคา (ข้อมูลในใบเสนอราคา): พับได้ — แตะทั้งแถบหัว / ▾ พับอยู่ · ▴ เปิด */
.quote-terms-head { cursor: pointer; min-height: 44px; }
.quote-terms .calc-chevron { transform: rotate(180deg); }
.quote-terms.is-collapsed .calc-chevron { transform: rotate(0deg); }
.quote-terms.is-collapsed .quote-terms-head { border-bottom: 0; }
.quote-terms .calc-card-body[hidden] { display: none; }
/* ยอดที่เสนอ (ข้อมูลในใบเสนอราคา): แถบเดียว — ตัวเลขชิดขวา สีส้มแบบยอดสุทธิเดิม */
.quote-total-bar { min-height: 52px; }
.quote-total-num { flex: 1 1 auto; align-self: center; padding: 0 16px 0 12px; text-align: right; font-size: 1.15rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* ภาพสรุป A4: ปุ่มกลับแบบเดียวกับทุกหน้า (เป็น <button>) */
.sd-back { font-family: inherit; cursor: pointer; margin: 0; }
/* รายการงาน: ค้นเจอจากในงาน (รายการ / หมวด / งานย่อย) → บรรทัดเล็กใต้แถว บอกที่มา */
.job-hit { grid-column: 1; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
@media (min-width: 600px) { .job-hit { grid-column: 1 / 7; grid-row: 2; margin-top: 2px; } }

/* งานร่างครบเพดาน → เลือกงานร่างที่จะลบ (jobs.js openDraftPicker — SCOPE 2.L) */
.draft-pick .dp-msg { margin: 0 0 10px; }
.dp-list { display: flex; flex-direction: column; gap: 8px; }
.dp-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; min-height: 44px; }
.dp-item input { flex: 0 0 auto; width: 20px; height: 20px; accent-color: var(--danger); margin: 0; }
.dp-item.is-picked { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.dp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dp-name { overflow-wrap: anywhere; }
.dp-meta { font-size: 13px; }
.dp-sell { flex: 0 0 auto; font-weight: 700; }
.draft-pick .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* จำนวนงานบนตัวกรอง (ทั้งหมด / ร่าง / ออกใบเสนอราคาแล้ว) */
.chip-count { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: color-mix(in srgb, currentColor 16%, transparent); font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.draft-pick .dp-note { padding: 10px 12px; border-radius: 10px; background: var(--surface-head); border-left: 3px solid var(--accent-line); }

/* ยืนราคาขัดกัน (ข้อความที่พิมพ์เอง ≠ ระยะยืนราคาของใบ) — เตือนเท่านั้น */
.quote-conflict { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; border-left: 3px solid #F59E0B; background: rgba(245, 158, 11, 0.12); color: var(--text); font-size: 14px; line-height: 1.5; }
.quote-conflict a { color: var(--primary); font-weight: 600; }
.biz-note-hint { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.biz-preview-dirty { margin-left: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(245, 158, 11, 0.16); color: #F59E0B; font-size: 12px; font-weight: 600; vertical-align: middle; }
html[data-theme="light"] .biz-preview-dirty { color: #B45309; }
/* ไม่แสดงโลโก้ในใบ (ค่าเริ่มต้นติ๊ก — 26 พ.ย. 2569) */
.biz-logo-toggle { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 14px; cursor: pointer; }
.biz-logo-toggle input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
/* ยืนราคาเริ่มต้น: ช่องตัวเลขสั้น */
.biz-num-field input { max-width: 140px; }
/* มัดจำ: ช่องตัวเลข + เช็กบ็อกซ์ แสดงท้ายใบ บรรทัดเดียวกัน */
.biz-inline { display: flex; align-items: center; gap: 12px; }
.biz-inline input[data-digits] { max-width: 110px; }
.biz-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.biz-check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.biz-num-field > label[for] { font-size: 14px; font-weight: 600; }
.qd-notes .qd-term { margin: 0 0 2px; }

/* ตัดรูปโลโก้ (logo-crop.js — 26 พ.ย. 2569) */
.logo-crop .modal-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lc-shapes { display: flex; gap: 8px; }
.lc-stage { position: relative; width: min(78vw, 300px); aspect-ratio: 1; overflow: hidden; background: #fff; touch-action: none; cursor: grab; user-select: none; }
.lc-stage.lc-png { background: repeating-conic-gradient(#E2E8F0 0 25%, #fff 0 50%) 0 0 / 16px 16px; } /* PNG โปร่งใส → ลายตาราง */
.lc-stage:active { cursor: grabbing; }
.lc-stage img { position: absolute; left: 0; top: 0; max-width: none; pointer-events: none; }
.lc-mask { position: absolute; inset: 0; pointer-events: none; outline: 2px solid var(--primary); outline-offset: -2px; }
.lc-stage.is-circle .lc-mask { border-radius: 50%; box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55); outline: 2px solid var(--primary); }
.lc-zoom { display: flex; align-items: center; gap: 10px; width: min(78vw, 300px); font-size: 14px; }
.lc-zoom input { flex: 1; accent-color: var(--primary); }
.lc-hint { margin: 0; text-align: center; }
/* ป้าย "ยังไม่บันทึก" ไม่ตัดคำ — จอแคบขึ้นบรรทัดใหม่ทั้งป้าย */
.biz-preview-title { flex-wrap: wrap; row-gap: 6px; }
.biz-preview-title .biz-preview-dirty { white-space: nowrap; margin-left: 0; }

/* เลขหน้าบนแผ่น A4 มุมขวาบน (เฉพาะใบที่มีหลายหน้า — ปรับ 26 พ.ย. 2569) */
.quote-doc.qd-sheet { position: relative; }
.quote-doc.qd-sheet::after { content: "หน้า " attr(data-page); position: absolute; font-size: 9pt; color: #64748B; }
/* ส่วนลด + ปุ่มปัดเศษ (26 พ.ย. 2569) */
.quote-discount { display: flex; align-items: flex-end; gap: 8px; }
.quote-discount .field { flex: 1; margin-bottom: 0; }
.quote-discount [data-round] { min-height: 44px; white-space: nowrap; }
.quote-round-hint { display: block; margin: 4px 0 12px; min-height: 1em; }

/* แบบละเอียด: หัวงานย่อยในใบ (3.3.1 — 26 พ.ย. 2569) */
.qd-table .qd-subhead td { font-weight: 700; color: #1E3A5F; padding-top: 5px; }
.qd-table .qd-subhead td:nth-child(2) { padding-left: 14px; }
.qd-sub-no { display: inline-block; min-width: 2.4em; color: #475569; }
.qd-table:has(.qd-subhead) tr:not(.qd-cat):not(.qd-cattotal):not(.qd-subhead) .qd-name { padding-left: 30px; }
.qd-parties b, .qd-parties strong, .qd-parties dd { word-break: keep-all; overflow-wrap: anywhere; }
/* ชื่อยาว: แต่ละคำเป็นก้อน → ขึ้นบรรทัดใหม่ตรงเว้นวรรค (quote-doc.js words()) */
.quote-doc .qd-word { display: inline-block; max-width: 100%; }

/* แก้ไขใบที่ออกแล้ว — ออกใบใหม่เลขเดิม (SCOPE 3.3 ปรับ 26 พ.ย. 2569) */
.badge-revising { background: rgba(245, 158, 11, 0.16); color: #F59E0B; }
html[data-theme="light"] .badge-revising { color: #B45309; }
.revising-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; border-left: 4px solid #F59E0B; background: rgba(245, 158, 11, 0.12); color: var(--text); font-size: 14px; line-height: 1.5; }
.quote-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.quote-versions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.quote-old-note { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; background: rgba(245, 158, 11, 0.12); color: var(--text); font-size: 14px; }
/* ยืนราคา / มัดจำ + แสดงท้ายใบ ในหน้าข้อมูลในใบเสนอราคา (ย้ายจากข้อมูลกิจการ 27 พ.ย. 2569) — จอแคบเรียงลงเป็นสองบรรทัด */
.quote-terms-row { display: flex; flex-wrap: wrap; gap: 0 28px; }
.quote-num-field > label[for] { font-size: 14px; font-weight: 600; }
.quote-num-field input[inputmode] { max-width: 110px; }
/* การ์ดลูกค้า (หน้าข้อมูลในใบเสนอราคา) กระชับ — 27 พ.ย. 2569 */
.quote-customer .field { margin-bottom: 10px; }
.quote-customer textarea { resize: none; overflow: hidden; min-height: 48px; }
@media (min-width: 640px) {
  .quote-customer { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: start; }
}
/* กำไร % คิดจากต้นทุน (markup) — บอกให้ชัด 27 พ.ย. 2569 / ข้อความเล็ก ไม่เปลี่ยน layout */
.profit-basis { font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
/* ส่วนลด | VAT / ยืนราคา | มัดจำ — จอกว้าง 2 คอลัมน์ มีเส้นคั่น (27 พ.ย. 2569) / จอแคบเรียงลงตามเดิม */
.qt-cell { min-width: 0; }
@media (min-width: 640px) {
  .qt-pair, .quote-terms-row.qt-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0; align-items: start; }
  .qt-pair:first-child { margin-bottom: 14px; }
  .qt-pair > :nth-child(2) { border-left: 1px solid var(--border); padding-left: 28px; margin-left: 28px; }
  .qt-vat { padding-top: 26px; } /* ตรงกับช่องส่วนลด (ใต้ป้าย) */
  .qt-vat .quote-check { margin: 0; min-height: 48px; }
}
.quote-round-hint:empty { display: none; } /* ยังไม่กดปัดเศษ → ไม่เว้นที่ว่าง (27 พ.ย. 2569) */
/* มือถือ (จอแคบกว่า 640 — 27 พ.ย. 2569): 2 คอลัมน์ เส้นคั่นแนวตั้งระหว่างคอลัมน์ + เส้นแนวนอนระหว่างแถว / ช่องตัวเลขยืดเต็มคอลัมน์ / ป้าย "ท้ายใบ" (ตัด "แสดง") */
@media (max-width: 639px) {
  .qt-pair, .quote-terms-row.qt-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0; align-items: end; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
  .qt-pair > :nth-child(2) { border-left: 1px solid var(--border); padding-left: 12px; margin-left: 12px; }
  .qt-pair .field { margin-bottom: 0; }
  .qt-vat { align-self: stretch; display: flex; align-items: flex-end; }
  .qt-vat .quote-check { margin: 0; min-height: 48px; }
  .qt-pair .biz-inline { gap: 8px; }
  .qt-pair input[inputmode], .qt-pair .quote-discount input[name="discount"] { max-width: none; width: 100%; min-width: 0; flex: 1 1 auto; padding-left: 10px; padding-right: 8px; }
  .qt-pair .biz-check { gap: 5px; }
  .qt-show { display: none; }
}
/* ช่องส่วนลด: กว้างพอตัวเลขหลักล้าน ไม่ยืดเต็มคอลัมน์ (27 พ.ย. 2569 — เอาปุ่มปัดเศษออก) */
.quote-discount input[name="discount"] { max-width: 110px; } /* เท่าช่องยืนราคา / มัดจำ */
/* ลูกค้า: แถบเดียวแบบ "งาน" + "เพิ่มเติม ▾" ท้ายแถบ / ช่องเพิ่มเติมกางใต้แถบ (27 พ.ย. 2569) */
.quote-cust { flex-wrap: wrap; }
.quote-cust > .quote-job-input { flex: 1 1 0; width: auto; } /* ไม่ยืด 100% (กันแถบแตกบรรทัด) */
.quote-cust-more-btn { flex: 0 0 auto; align-self: center; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-right: 4px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.quote-cust-more-btn:hover { background: var(--surface-2); color: var(--text); }
.quote-cust .calc-chevron { transform: rotate(180deg); }
.quote-cust.is-collapsed .calc-chevron { transform: rotate(0deg); }
.quote-cust > .quote-cust-body { flex: 0 0 100%; border-top: 1px solid var(--border); }
.quote-cust > .quote-cust-body[hidden] { display: none; }
/* ล้างข้อมูลกิจการ (27 พ.ย. 2569): ปุ่มรองใต้ปุ่มบันทึก สีแดง ไม่เด่นเท่าปุ่มบันทึก */
.biz-clear { display: block; margin: 12px auto 0; min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--neg); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
/* หน้าข้อมูลในใบเสนอราคา: แถบ / หัวการ์ด ขนาดเท่ากันทุกส่วน (27 พ.ย. 2569) — สูง 60px · ป้าย 15px ตัวหนา */
.quote-page .quote-seller { min-height: 60px; }
.quote-page .quote-terms-head, .quote-page .quote-internal .calc-group-head { min-height: 60px; padding-top: 8px; padding-bottom: 8px; }
.quote-page .quote-terms-head h2, .quote-page .quote-internal .calc-group-head h2 { font-size: 15px; line-height: 1.35; }
.quote-page .quote-form > .calc-card, .quote-page > .calc-card, .quote-page > .calc-summary { margin-top: 0; margin-bottom: 12px; } /* ระยะห่างระหว่างส่วนเท่ากัน 12px */
.quote-page .quote-form { margin: 0; }
.quote-page .quote-next { margin-top: 0; }

/* ===== มาตรฐานเดียวทุกหน้า (27 พ.ย. 2569) =====
   ชื่อหน้า 22px (มือถือ) / 24px · หัวการ์ด สูง 60px ตัว 15px · ระยะห่างการ์ด 12px · ช่องกรอก 16px ทุกขนาดจอ */
.page-title, .jobs-page > .section-title { font-size: 24px; line-height: 1.3; }
@media (max-width: 639px) { .page-title, .jobs-page > .section-title { font-size: 22px; } }
/* หัวการ์ด (หน้าคิดราคางาน: รายละเอียดงาน / รายการ / สรุป) — ไม่รวมหัวกลุ่มวัสดุ / ค่าแรง / อื่น ในหมวด */
.calc-card > .calc-group-head:not(.calc-type-head), .calc-summary > .calc-group-head { min-height: 60px; padding-top: 8px; padding-bottom: 8px; }
.calc-card > .calc-group-head:not(.calc-type-head) h2, .calc-summary > .calc-group-head h2 { font-size: 15px; line-height: 1.35; }
/* ข้อมูลกิจการ: หัวการ์ด + หัวตัวอย่างหัวใบ */
.biz-head { min-height: 60px; padding-bottom: 10px; margin-bottom: 14px; }
.biz-head-icon svg { width: 32px; height: 32px; }
.biz-title, .biz-preview-title { font-size: 15px; }
@media (max-width: 767px) { .biz-title { font-size: 15px; } }
.biz-preview-title svg { width: 22px; height: 22px; }
.biz-section { margin-top: 12px; }
.biz-section > .card + .card, .biz-preview-card { margin-top: 12px; }
@media (min-width: 768px) {
  .biz-card input, .biz-card textarea, .biz-card .biz-icon-input input { font-size: 16px; }
}
/* หน้าใบที่ออกแล้ว: ปุ่มใต้ใบ / ปุ่มกลับบรรทัดเดียว */
.quote-toolbar .back { white-space: nowrap; }
.quote-issued-actions { display: grid; gap: 10px; margin-top: 12px; }
.calc-page > .calc-card:not(.item-mode), .calc-page > .calc-summary { margin-top: 12px; } /* ระยะห่างการ์ดหลักหน้าคิดราคางาน 12px (ไม่รวมกลุ่มวัสดุ / ค่าแรงในหมวด) */
.calc-page .calc-items-card { margin-top: 12px; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } /* กันเบราว์เซอร์มือถือขยายตัวอักษรเอง (หน้าใบที่มีแผ่น A4 กว้าง — 27 พ.ย. 2569) */
/* หน้าคิดราคางาน: แถบ งาน / ลูกค้า แบบหน้าข้อมูลในใบ (27 พ.ย. 2569) */
.calc-page .quote-seller { min-height: 60px; }
.calc-page .calc-job-bar, .calc-page .calc-cust-bar { margin-top: 12px; }
.calc-page .calc-job-bar > .quote-job-input, .calc-page .calc-cust-bar > .quote-job-input { width: auto; flex: 1 1 0; }
/* ===== ปรับต่อ (27 พ.ย. 2569) ===== */
/* 1. แถบส้มหน้าชื่อหน้า ทุกหน้า (เดิมมีเฉพาะ คิดราคางาน / ข้อมูลในใบ) */
.page-title, .jobs-page > .section-title { position: relative; padding-left: 16px; }
.page-title::before, .jobs-page > .section-title::before { content: ""; position: absolute; left: 0; top: 0.2em; bottom: 0.2em; width: 5px; border-radius: 3px; background: var(--accent-line); }
/* 2. หัวกลุ่ม วัสดุ / ค่าแรง / ค่าใช้จ่ายอื่น ในหมวด: ตัว 15px · จอคอมสูง 60px (มือถือ 2 แถวตามเดิม — ชื่อ / ปุ่มเพิ่ม) */
.calc-type-head h2 { font-size: 15px; }
@media (min-width: 640px) { .calc-type-head { min-height: 60px; } }
/* 3. ข้อมูลกิจการ: หัวการ์ดเป็นแถบสีแบบหัวการ์ดหน้าอื่น (เต็มความกว้างการ์ด) */
.biz-card, .biz-preview-card { overflow: hidden; }
.biz-card > .biz-head.calc-group-head, .biz-preview-card > .biz-preview-title.calc-group-head { margin: -12px -16px 16px; padding: 8px 16px; min-height: 60px; display: flex; align-items: center; gap: 10px; justify-content: flex-start; }
.biz-card > .biz-head .biz-head-icon svg, .biz-preview-card > .biz-preview-title svg { width: 22px; height: 22px; }
.biz-card > .biz-head .biz-title { font-size: 15px; }
/* 4. ช่องเบอร์โทร / อีเมล (มีไอคอน) ไม่หนา — เดิมสืบทอดตัวหนาจากป้ายช่อง */
.biz-card .field > .biz-icon-input { font-weight: 400; }
/* ปุ่มส่งผ่าน LINE (27 พ.ย. 2569): สีเขียว LINE + ไอคอน */
.btn-line { background: #06C755; border-color: #06C755; color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-line:hover { background: #05B34C; border-color: #05B34C; }
.btn-line:disabled { opacity: 0.7; }
.btn-line-icon { width: 22px; height: 22px; flex: 0 0 auto; }
/* ลายน้ำร่าง: ปูทั้งแผ่น 2 × 6 (27 พ.ย. 2569) — ทับตัวเลขราคา / ยอดเงินด้วย ลบจากภาพแคปยาก / ยังจางพออ่านตัวเลขตรวจได้ */
.qd-watermark { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(6, 1fr); place-items: center; }
.qd-watermark span { font-size: 15px; color: rgba(220, 38, 38, 0.14); }
@media (max-width: 420px) { .qd-watermark span { font-size: 11px; } }
@media screen { .quote-view .qd-watermark span { font-size: 22pt; } }
@media print { .qd-watermark span { font-size: 22pt; } }

/* ===== รายการงานแบบการ์ด (27 พ.ย. 2569 — แทนตาราง) =====
   Navy: การ์ดขาวบนพื้นน้ำเงิน / Light: การ์ดขาวมีขอบ + เงาบาง / Dark: การ์ดเข้ม
   แถบซ้าย + ไอคอน + กล่องราคา: ร่าง = ส้ม · ออกใบแล้ว = เขียว · กำลังแก้ไข = เหลือง */
.jobs-cards { display: grid; gap: 12px; }
.jobs-cards .job-card {
  --jc-bg: #FFFFFF; --jc-text: #0F172A; --jc-muted: #64748B; --jc-line: #E2E8F0;
  --jc-accent: #F59E0B; --jc-tint: #FEF3C7; --jc-tint-text: #78350F;
  position: relative; display: flex; align-items: center; gap: 14px; min-width: 0;
  padding: 14px 14px 14px 20px; border: 0; border-radius: 16px; overflow: hidden;
  background: var(--jc-bg); color: var(--jc-text); box-shadow: 0 4px 14px rgba(2, 6, 23, 0.28);
}
.jobs-cards .job-card--issued { --jc-accent: #22C55E; --jc-tint: #DCFCE7; --jc-tint-text: #14532D; }
.jobs-cards .job-card--revising { --jc-accent: #EAB308; --jc-tint: #FEF9C3; --jc-tint-text: #713F12; }
.jobs-cards .job-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--jc-accent); }
.jobs-cards .job-card:hover { background: var(--jc-bg); box-shadow: 0 6px 18px rgba(2, 6, 23, 0.34); }
.jobs-cards .job-ico { flex: 0 0 auto; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--jc-tint); color: var(--jc-accent); }
.jobs-cards .job-ico svg { width: 28px; height: 28px; }
.jobs-cards .job-card--draft .job-ico { color: #D97706; }
.jobs-cards .job-card--issued .job-ico { color: #16A34A; }
.jobs-cards .job-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.jobs-cards .job-l1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.jobs-cards .job-link { flex: 0 1 auto; min-width: 0; }
.jobs-cards .job-name { font-size: 17px; font-weight: 800; color: var(--jc-text); }
.jobs-cards .job-status { flex: 0 0 auto; }
/* ป้ายสถานะอยู่คอลัมน์ขวาแถวบน คู่กับปุ่มถังขยะ (งานร่าง) — ปรับ 29 พ.ย. 2569 */
.jobs-cards .job-side-top { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.jobs-cards .badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; border: 0; }
.jobs-cards .badge-draft { background: #94A3B8; color: #FFFFFF; }
.jobs-cards .badge-issued { background: #16A34A; color: #FFFFFF; }
.jobs-cards .badge-revising { background: #F59E0B; color: #1F2937; }
.jobs-cards .job-badge-ico { width: 14px; height: 14px; stroke-width: 3; }
.jobs-cards .job-cust { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--jc-text); }
.jobs-cards .job-cust.muted { color: var(--jc-muted); }
.jobs-cards .job-cust > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs-cards .job-foot { display: flex; align-items: center; gap: 10px; min-width: 0; margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--jc-line); font-size: 14px; color: var(--jc-muted); }
.jobs-cards .job-qno, .jobs-cards .job-date { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 14px; }
.jobs-cards .job-qno { color: var(--jc-text); font-weight: 600; }
.jobs-cards .job-qno[hidden] { display: none; }
.jobs-cards .job-sep { width: 1px; height: 16px; background: var(--jc-line); }
.jobs-cards .job-mi { width: 16px; height: 16px; flex: 0 0 auto; color: var(--jc-muted); }
.jobs-cards .job-hit { font-size: 13px; color: var(--jc-muted); }
.jobs-cards .job-side { flex: 0 0 auto; align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; padding-left: 14px; border-left: 1px solid var(--jc-line); }
.jobs-cards .job-price { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 12px; background: var(--jc-tint); color: var(--jc-tint-text); }
.jobs-cards .job-sell { font-size: 20px; font-weight: 800; color: inherit; text-align: right; }
.jobs-cards .job-chev { width: 20px; height: 20px; stroke-width: 2.5; }
.jobs-cards .job-delete { position: relative; z-index: 1; width: 36px; height: 36px; color: var(--jc-muted); }
.jobs-cards .job-delete:hover, .jobs-cards .job-delete:focus-visible { color: #DC2626; background: #FEE2E2; }
@media (max-width: 479px) {
  .jobs-cards .job-card { gap: 10px; padding: 12px 10px 12px 16px; }
  .jobs-cards .job-ico { width: 44px; height: 44px; border-radius: 12px; }
  .jobs-cards .job-ico svg { width: 24px; height: 24px; }
  .jobs-cards .job-name { font-size: 16px; }
  .jobs-cards .badge { padding: 2px 8px; font-size: 12px; }
  .jobs-cards .job-side { padding-left: 10px; }
  .jobs-cards .job-price { padding: 8px 10px; }
  .jobs-cards .job-sell { font-size: 16px; }
  .jobs-cards .job-chev { width: 16px; height: 16px; }
}
/* Light: การ์ดขาวบนพื้นสว่าง → ขอบบาง + เงาเบา */
html[data-theme="light"] .jobs-cards .job-card { box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 4px 12px rgba(15, 23, 42, 0.06); outline: 1px solid #E2E8F0; }
/* Dark: การ์ดเข้ม / สีอ่อนลงให้อ่านบนพื้นมืด */
html[data-theme="dark"] .jobs-cards .job-card { --jc-bg: #1A2230; --jc-text: #F1F5F9; --jc-muted: #94A3B8; --jc-line: #2E3A4E; --jc-tint: rgba(245, 158, 11, 0.16); --jc-tint-text: #FCD34D; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
html[data-theme="dark"] .jobs-cards .job-card--issued { --jc-tint: rgba(34, 197, 94, 0.16); --jc-tint-text: #86EFAC; }
html[data-theme="dark"] .jobs-cards .job-card--revising { --jc-tint: rgba(234, 179, 8, 0.16); --jc-tint-text: #FDE68A; }
html[data-theme="dark"] .jobs-cards .job-card--draft .job-ico { color: #FBBF24; }
html[data-theme="dark"] .jobs-cards .job-card--issued .job-ico { color: #4ADE80; }
html[data-theme="dark"] .jobs-cards .job-delete:hover { background: rgba(248, 113, 113, 0.15); color: #F87171; }
/* การ์ดรายการงาน: ชื่องานยาวขึ้นบรรทัดใหม่ (สูงสุด 2 บรรทัด) แทนการตัด / แถวเลขที่ใบ + เวลา ตกบรรทัดได้ */
.jobs-cards .job-l1 { align-items: flex-start; }
.jobs-cards .job-name { white-space: normal; overflow: hidden; text-overflow: clip; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.jobs-cards .job-foot { flex-wrap: wrap; row-gap: 2px; }
/* Light: ป้ายในการ์ดสีเข้มชัด (กฎป้ายเดิมของธีมสว่างทำให้จาง) */
html[data-theme="light"] .jobs-cards .badge-draft { background: #94A3B8; color: #FFFFFF; }
html[data-theme="light"] .jobs-cards .badge-issued { background: #16A34A; color: #FFFFFF; }
html[data-theme="light"] .jobs-cards .badge-revising { background: #F59E0B; color: #1F2937; }
/* มือถือ (< 480px): ป้ายสถานะอยู่เหนือชื่องาน (ชื่อได้เต็มความกว้าง) / ไม่ตัดกลางคำ / แถวเลขที่ใบ + เวลา ไม่มีไอคอน (พอดีบรรทัดเดียว) */
@media (max-width: 479px) {
  .jobs-cards .job-l1 { flex-direction: column; align-items: flex-start; gap: 4px; }
  .jobs-cards .job-name { overflow-wrap: normal; word-break: normal; }
  .jobs-cards .job-foot { gap: 8px; font-size: 13px; }
  .jobs-cards .job-foot .job-mi { display: none; }
  .jobs-cards .job-qno, .jobs-cards .job-date { font-size: 13px; }
}
/* มือถือ: วันที่ + เวลา "25 พ.ย. 68 17:33" ยาวขึ้น (27 พ.ย. 2569) — ที่ไม่พอ → วันที่ลงบรรทัดใต้เลขที่ใบ / ไม่มีเส้นคั่นค้างท้ายบรรทัด */
@media (max-width: 479px) {
  .jobs-cards .job-foot { column-gap: 12px; }
  .jobs-cards .job-foot .job-sep { display: none; }
}
/* เมนูล่าง: เมนูที่เลือกอยู่มีพื้นส้มจางมุมโค้ง (แบบเดียวกับเมนูบนจอคอม — 27 พ.ย. 2569) / ความสูงแถบเท่าเดิม (แถบสรุปหน้าคำนวณวางต่อจาก --nav-h) */
.bottomnav a { margin: 6px 5px; border-radius: 14px; transition: background-color 0.15s; }
.bottomnav a.active { background: var(--primary-soft); }
@media (prefers-reduced-motion: reduce) { .bottomnav a { transition: none; } }
