/* ===== Zeek Design — ระบบใบรับงานลูกค้า : สไตล์หลัก ===== */
:root {
  /* ===== ธีมสว่าง (Light theme) — โทนสีกลางทั้งระบบกำหนดที่นี่ที่เดียว ===== */
  color-scheme: light;
  --brand: #FFCC00;
  --brand-dark: #dbaf00;
  --brand-soft: #fff6d6;
  --brand-ink: #8a6a00;       /* สีแบรนด์เข้ม อ่านง่ายบนพื้นขาว */
  --on-brand: #1f2530;        /* สีตัวอักษรบนพื้นสีแบรนด์ */
  --on-brand-soft: rgba(31, 37, 48, .72);
  --on-brand-chip: rgba(0, 0, 0, .10);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --field: #ffffff;          /* พื้นช่องกรอก */
  --text: #1f2530;
  --muted: #6b7280;
  --faint: #9aa3af;
  --border: #e6e8ec;
  --sidebar-bg: #0f1722;
  --sidebar-bg-2: #0b121b;
  --sidebar-text: #aeb6c2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 28px -18px rgba(16, 24, 40, .35);
  --shadow-lg: 0 24px 60px -24px rgba(16, 24, 40, .45);
  --ok: #16a34a; --warn: #d97706; --err: #dc2626; --info: #2563eb;
  --font: 'Sarabun', 'Leelawadee UI', 'Tahoma', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- โครงหน้า ---------- */
#root { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px; flex: 0 0 252px;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-ink-soft, var(--sidebar-text));
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px; border-bottom: 1px solid var(--sidebar-line, rgba(255, 255, 255, .07));
}
.sidebar .brand .logo {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--logo-bg, var(--brand)); color: var(--logo-ink, #fff); font-weight: 800; font-size: 22px;
}
.sidebar .brand .logo img { width: 100%; height: 100%; object-fit: contain; background: transparent; padding: 3px; }
.sidebar .brand .name { font-weight: 800; color: var(--sidebar-ink, #fff); font-size: 16px; letter-spacing: .2px; }
.sidebar .brand .sub { font-size: 11.5px; color: var(--sidebar-ink-faint, var(--faint)); }

.nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--sidebar-ink-faint, #5b6675); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; color: var(--sidebar-ink-soft, var(--sidebar-text));
  font-weight: 500; transition: background .12s, color .12s;
}
.nav a .ic { width: 19px; height: 19px; flex: none; opacity: .9; }
.nav a:hover { background: var(--sidebar-hover-bg, rgba(255, 255, 255, .06)); color: var(--sidebar-ink, #fff); }
.nav a.active { background: var(--brand); color: var(--on-brand); box-shadow: 0 8px 18px -10px var(--brand); }
.nav a.active .ic { opacity: 1; }
.sidebar .foot { padding: 14px 18px; font-size: 11.5px; color: var(--sidebar-ink-faint, #5b6675); border-top: 1px solid var(--sidebar-line, rgba(255, 255, 255, .07)); }

main#view { flex: 1; min-width: 0; padding: 26px 30px 60px; }

/* ---------- หัวข้อหน้า ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; color: var(--content-ink, var(--text)); }
.page-head .sub { color: var(--content-ink-soft, var(--muted)); font-size: 13.5px; margin-top: 3px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  transition: all .12s; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); border-color: #d3d7de; }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: var(--on-brand); }
.btn-danger { background: #fff; border-color: #f2c4c4; color: var(--err); }
.btn-danger:hover { background: #fdeaea; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(15, 23, 34, .06); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- การ์ด ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 16px; }
.card-head .sub { font-size: 12.5px; color: var(--section-head-ink-soft, var(--muted)); }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, 1fr); } .cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* ---------- การ์ดสถิติ Dashboard ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 27px; font-weight: 800; margin-top: 7px; letter-spacing: -.5px; }
.stat .meta { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.stat .corner { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.stat.accent { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); border-color: transparent; color: var(--on-brand); }
.stat.accent .label, .stat.accent .meta { color: var(--on-brand-soft); }
.stat.accent .value { color: var(--on-brand); }
.stat.accent .corner { background: var(--on-brand-chip); color: var(--on-brand); }

/* ---------- ฟอร์ม ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.req { color: var(--err); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input[readonly] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 92px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.span-2 { grid-column: 1 / -1; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

/* ตัวเลือกแบบการ์ด (ประเภทงาน / แผนก) */
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 11px; background: #fff;
  font-weight: 600; transition: all .12s; user-select: none;
}
.choice:hover { border-color: #cfd3da; }
.choice input { accent-color: var(--brand); width: 17px; height: 17px; }
.choice.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- ตาราง ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
table.table tbody tr:hover { background: var(--surface-2); }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.linkish { color: var(--brand-ink); cursor: pointer; font-weight: 700; }
.linkish:hover { text-decoration: underline; }

/* ---------- ป้ายสถานะ / แท็ก ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 7px; background: #eef1f5; color: #475063; font-size: 12px; font-weight: 600; margin: 2px 3px 2px 0; }

/* ---------- แถบเครื่องมือ / ฟิลเตอร์ ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.seg { display: inline-flex; background: #eceef2; border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 8px 16px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.search input { padding-left: 36px; }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 34, .5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 80; padding: 20px; }
.modal { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal .modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal .modal-body { padding: 22px; }
.modal .modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- ไฟล์แนบ ---------- */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.attach {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; position: relative;
}
.attach .thumb { height: 96px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.attach .thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach .thumb .file-ic { color: var(--faint); }
.attach .cap { padding: 7px 9px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach .rm { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(15, 23, 34, .65); color: #fff; cursor: pointer; display: grid; place-items: center; }
.attach .rm:hover { background: var(--err); }
.dropzone { border: 2px dashed #d3d7de; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: all .12s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- charts ---------- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--brand); transition: opacity .12s; }
.chart .bar:hover { opacity: .8; }
.chart .axis { stroke: var(--border); }
.chart .glabel { fill: var(--faint); font-size: 11px; }
.chart .vlabel { fill: var(--muted); font-size: 10.5px; }

/* ---------- เบ็ดเตล็ด ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; }
.between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.kpi-bar { height: 8px; border-radius: 999px; background: #eef1f5; overflow: hidden; }
.kpi-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: #1f2530; color: #fff; padding: 12px 16px; border-radius: 11px; box-shadow: var(--shadow-lg);
  font-weight: 600; max-width: 360px; animation: toast-in .18s ease; display: flex; align-items: center; gap: 10px;
}
.toast.ok { background: #14803f; } .toast.err { background: #c0322b; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- โหลด ---------- */
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- มือถือ ---------- */
.menu-btn { display: none; }
@media (max-width: 880px) {
  #root { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 60; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar .nav { position: absolute; top: 100%; left: 0; right: 0; background: var(--sidebar-bg); flex-direction: column; display: none; }
  .sidebar.open .nav { display: flex; }
  .sidebar .foot { display: none; }
  .menu-btn { display: inline-grid; place-items: center; background: transparent; border: none; color: var(--sidebar-ink, #fff); padding: 14px; cursor: pointer; }
  main#view { padding: 18px 16px 50px; }
}

/* =====================================================================
   ใบรับงาน (Receipt) — แสดงบนจอ + พิมพ์
   ===================================================================== */
.receipt-toolbar { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.sheet {
  background: #fff; max-width: 800px; margin: 0 auto; padding: 40px 44px;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  color: #14181f;
}
.sheet .r-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--brand); padding-bottom: 18px; }
.sheet .r-head .co { display: flex; gap: 14px; align-items: center; }
.sheet .r-head .logo { width: 60px; height: 60px; border-radius: 12px; background: var(--logo-bg, var(--brand)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 30px; overflow: hidden; flex: none; }
.sheet .r-head .logo img { width: 100%; height: 100%; object-fit: contain; }
.sheet .r-head .co-name { font-size: 21px; font-weight: 800; }
.sheet .r-head .co-info { font-size: 12px; color: #5b6675; line-height: 1.5; margin-top: 3px; }
.sheet .r-head .doc { text-align: right; }
.sheet .r-head .doc .title { font-size: 20px; font-weight: 800; color: var(--brand-ink); }
.sheet .r-head .doc .code { font-size: 14px; font-weight: 700; margin-top: 4px; }
.sheet .r-head .doc .date { font-size: 12px; color: #5b6675; margin-top: 2px; }

.sheet .r-section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--brand-ink); margin: 22px 0 10px; border-bottom: 1px solid #eceef2; padding-bottom: 5px; }
.r-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px; }
.r-info .row { display: flex; gap: 10px; font-size: 13.5px; padding: 3px 0; }
.r-info .row .k { color: #5b6675; min-width: 96px; flex: none; }
.r-info .row .v { font-weight: 600; }
.r-detail { background: #fafbfc; border: 1px solid #eceef2; border-radius: 9px; padding: 13px 15px; font-size: 13.5px; white-space: pre-wrap; min-height: 46px; }
.r-quote { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.r-quote .box { border: 1px solid #eceef2; border-radius: 9px; padding: 12px 14px; }
.r-quote .box .k { font-size: 11.5px; color: #5b6675; }
.r-quote .box .v { font-size: 16px; font-weight: 800; margin-top: 3px; }
.r-quote .box.total { background: var(--brand-soft); border-color: var(--brand); }
.r-quote .box.total .v { color: var(--brand-ink); }
.r-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.r-photos .ph { border: 1px solid #eceef2; border-radius: 9px; overflow: hidden; height: 150px; }
.r-photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.r-files { font-size: 13px; }
.r-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin-top: 46px; }
.r-sign .line { border-top: 1px dotted #9aa3af; padding-top: 8px; text-align: center; font-size: 13px; color: #5b6675; }
.sheet .r-foot { margin-top: 30px; border-top: 1px solid #eceef2; padding-top: 12px; font-size: 11px; color: #9aa3af; text-align: center; }

/* ===================== เมนูคำนวณราคา ===================== */
.calc-table th, .calc-table td { padding: 8px 8px; vertical-align: middle; }
.calc-table .num-in { max-width: 92px; text-align: right; padding: 8px 9px; }
.calc-table select.select { padding: 8px 9px; }
.calc-summary { max-width: 440px; margin-left: auto; }
.cs-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; color: var(--muted); gap: 12px; }
.cs-row .lbl { font-weight: 600; }
.cs-row .v { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cs-row.grand { border-top: 2px solid var(--brand); margin-top: 6px; padding-top: 12px; }
.cs-row.grand .lbl { font-size: 16px; font-weight: 800; color: var(--text); }
.cs-row.grand .v { font-size: 22px; font-weight: 800; color: var(--brand-ink); }
.price-matrix th, .price-matrix td { padding: 6px 8px; vertical-align: middle; white-space: nowrap; }
.price-matrix input.input { padding: 7px 8px; }
.price-matrix .num-in { max-width: 110px; text-align: right; }
.price-matrix thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }

/* ===================== โหมดพิมพ์ ===================== */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .toast-wrap, .receipt-toolbar, .menu-btn, .no-print { display: none !important; }
  #root { display: block; }
  main#view { padding: 0; }
  .sheet { box-shadow: none; border: none; border-radius: 0; max-width: none; margin: 0; padding: 0; }
  .sheet .r-head { padding-bottom: 12px; }
  .r-photos .ph { height: 130px; }
  .r-section-title { margin-top: 16px; }
  a { color: inherit; }
}

/* ===================== ผู้ใช้ในแถบข้าง ===================== */
.sidebar .foot { display: flex; flex-direction: column; gap: 10px; }
.user-row { display: flex; align-items: center; gap: 10px; }
.u-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.u-info { min-width: 0; }
.u-info .u-name { color: var(--sidebar-ink, #fff); font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-info .u-role { font-size: 11.5px; color: var(--sidebar-ink-faint, #6b7686); }
.u-actions { display: flex; flex-direction: column; gap: 6px; }
.u-actions .btn { width: 100%; justify-content: flex-start; background: var(--sidebar-hover-bg, rgba(255, 255, 255, .06)); border-color: transparent; color: var(--sidebar-ink-soft, var(--sidebar-text)); }
.u-actions .btn:hover { background: var(--sidebar-hover-bg2, rgba(255, 255, 255, .13)); color: var(--sidebar-ink, #fff); }

/* ===================== หน้าเข้าสู่ระบบ ===================== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1100px 560px at 50% -10%, #1b2738, #0d141d); }
.login-card { width: 100%; max-width: 384px; background: #fff; border-radius: 18px; padding: 32px 30px; box-shadow: var(--shadow-lg); }
.login-logo { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto; background: var(--logo-bg, var(--brand)); display: grid; place-items: center; overflow: hidden; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; padding: 7px; }
.login-title { text-align: center; margin-top: 14px; font-size: 22px; letter-spacing: .3px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-top: 2px; }
.login-hint { text-align: center; color: var(--faint); font-size: 12px; margin-top: 14px; line-height: 1.5; }
.login-card .btn-block { margin-top: 4px; }

/* ===================== สรุปยอดในฟอร์ม ===================== */
.quote-summary { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); max-width: 360px; margin-left: auto; }
.qs-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); font-size: 14px; }
.qs-row.strong { color: var(--text); font-weight: 800; font-size: 16px; border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 8px; }

/* ===================== ยอดเงินในใบรับงาน ===================== */
.r-amounts { margin-top: 12px; max-width: 340px; margin-left: auto; }
.amt-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; color: #475063; }
.amt-row.grand { border-top: 2px solid var(--brand); margin-top: 4px; padding-top: 8px; font-weight: 800; font-size: 16px; color: #14181f; }
.amt-row.remain { font-weight: 800; color: var(--brand-ink); }
.r-items { width: 100%; border-collapse: collapse; margin: 10px 0 6px; font-size: 13px; }
.r-items th, .r-items td { padding: 7px 8px; border-bottom: 1px solid #eceef2; text-align: left; vertical-align: top; }
.r-items th { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: #5b6675; background: #fafbfc; }
.r-items td.num, .r-items th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* =====================================================================
   ปรับแต่ง UI เพิ่มเติม (พาเลทสีจากภาพตัวอย่าง)
   ===================================================================== */
:root {
  --pal-1: #5FA486; --pal-1-bg: rgba(95, 164, 134, .12);   /* เขียว */
  --pal-2: #8FBEB0; --pal-2-bg: rgba(143, 190, 176, .18);  /* ฟ้าอมเขียว */
  --pal-3: #E7CE6B; --pal-3-bg: rgba(231, 206, 107, .20);  /* เหลืองอ่อน/ครีม */
  --pal-4: #FFC94C; --pal-4-bg: rgba(255, 201, 76, .20);   /* เหลือง */
  --pal-5: #F7941E; --pal-5-bg: rgba(247, 148, 30, .13);   /* ส้ม */
  --pal-red: #E5544B; --pal-red-bg: rgba(229, 84, 75, .12);/* แดง (หมวดลบ/ยกเลิก) */
}

/* (ข้อ 2) ปุ่ม "สร้างใบรับงานใหม่" ในแถบข้าง: ตัวอักษรดำ พื้นเหลือง, hover พื้นเทาอ่อน */
/* ผูกกับสีแบรนด์กลาง (--brand) — เปลี่ยนสีแบรนด์ในหน้าตั้งค่าธีมสีแล้วจุดนี้เปลี่ยนตามทันที */
.nav a.btn-newjob { background: var(--brand); color: var(--on-brand); border: 1px solid var(--brand); font-weight: 700; box-shadow: 0 8px 18px -10px var(--brand); }
.nav a.btn-newjob .ic { opacity: 1; color: var(--on-brand); }
.nav a.btn-newjob:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: var(--on-brand); }
.nav a.btn-newjob.active { background: var(--brand); color: var(--on-brand); }

/* (ข้อ 7) แถบสีหัวข้อ section (card-head) ทั่วทั้งระบบ — วนสีตามลำดับการ์ดใน grid */
.card-head {
  background: var(--sec-bg, var(--brand-soft));
  border-bottom: 2px solid var(--sec, var(--brand));
  border-radius: var(--radius) var(--radius) 0 0;
}
.grid > .card:nth-child(5n+1) { --sec: var(--pal-1); --sec-bg: var(--pal-1-bg); }
.grid > .card:nth-child(5n+2) { --sec: var(--pal-2); --sec-bg: var(--pal-2-bg); }
.grid > .card:nth-child(5n+3) { --sec: var(--pal-3); --sec-bg: var(--pal-3-bg); }
.grid > .card:nth-child(5n+4) { --sec: var(--pal-4); --sec-bg: var(--pal-4-bg); }
.grid > .card:nth-child(5n+5) { --sec: var(--pal-5); --sec-bg: var(--pal-5-bg); }

/* (ข้อ 1) การ์ดสรุปในแดชบอร์ด — โทนสีต่างกันตามพาเลท (ตัวอักษรยังเป็นสีเข้ม อ่านง่าย) */
.stat.tone-green { background: var(--pal-1-bg); border-color: rgba(95, 164, 134, .4); }
.stat.tone-green .corner { background: rgba(95, 164, 134, .22); color: #3f7a60; }
.stat.tone-mint { background: var(--pal-2-bg); border-color: rgba(143, 190, 176, .6); }
.stat.tone-mint .corner { background: rgba(143, 190, 176, .32); color: #3c766a; }
.stat.tone-orange { background: var(--pal-5-bg); border-color: rgba(247, 148, 30, .4); }
.stat.tone-orange .corner { background: rgba(247, 148, 30, .22); color: #b96f10; }
.stat.tone-slate { background: rgba(100, 116, 139, .12); border-color: rgba(100, 116, 139, .42); }
.stat.tone-slate .corner { background: rgba(100, 116, 139, .2); color: #475569; }
.stat.tone-purple { background: rgba(124, 58, 237, .1); border-color: rgba(124, 58, 237, .38); }
.stat.tone-purple .corner { background: rgba(124, 58, 237, .18); color: #6d28d9; }

/* ใบรับงาน (Receipt) คงเป็น "กระดาษขาว" เสมอ (เพื่อความเป็นเอกสาร + การพิมพ์) */
.sheet {
  color-scheme: light;
  --surface: #ffffff; --surface-2: #fafbfc; --field: #ffffff;
  --text: #14181f; --muted: #5b6675; --faint: #9aa3af; --border: #eceef2;
  --brand-soft: #fff6d6; --brand-ink: #8a6a00; --on-brand: #1f2530;
  background: #ffffff; color: #14181f;
}
.sheet .input, .sheet .select, .sheet .textarea { background: #fff; color: #14181f; }

/* การ์ดสรุป Dashboard: ไล่เฉด (gradient) คนละสีชัดเจน
   ตัวอักษรปรับ ดำ/ขาว อัตโนมัติตามความสว่างของเฉดที่ owner เลือก (ค่า fallback = ขาว แบบเดิม) */
.stat[class*="tone-"], .stat.accent { border-color: transparent; color: var(--ink, #fff); border-radius: 16px; box-shadow: 0 16px 36px -16px rgba(0, 0, 0, .55); }
.stat[class*="tone-"] .label, .stat[class*="tone-"] .meta, .stat.accent .label, .stat.accent .meta { color: var(--ink-soft, rgba(255, 255, 255, .92)); text-shadow: var(--tshadow, 0 1px 2px rgba(0, 0, 0, .32)); }
.stat[class*="tone-"] .value, .stat.accent .value { color: var(--ink, #fff); text-shadow: var(--tshadow, 0 1px 3px rgba(0, 0, 0, .36)); }
.stat[class*="tone-"] .corner, .stat.accent .corner { background: var(--corner, rgba(255, 255, 255, .18)); color: var(--ink, #fff); }
/* map ตัวแปรสีการ์ดแต่ละใบ → ตัวแปร ink กลางที่ blanket rule ด้านบนใช้ */
.stat.tone-mint   { --ink: var(--card-newJobs-ink, #fff); --ink-soft: var(--card-newJobs-ink-soft, rgba(255,255,255,.92)); --corner: var(--card-newJobs-corner, rgba(255,255,255,.18)); --tshadow: var(--card-newJobs-shadow, 0 1px 3px rgba(0,0,0,.36)); }
.stat.tone-slate  { --ink: var(--card-open-ink, #fff); --ink-soft: var(--card-open-ink-soft, rgba(255,255,255,.92)); --corner: var(--card-open-corner, rgba(255,255,255,.18)); --tshadow: var(--card-open-shadow, 0 1px 3px rgba(0,0,0,.36)); }
.stat.tone-green  { --ink: var(--card-won-ink, #fff); --ink-soft: var(--card-won-ink-soft, rgba(255,255,255,.92)); --corner: var(--card-won-corner, rgba(255,255,255,.18)); --tshadow: var(--card-won-shadow, 0 1px 3px rgba(0,0,0,.36)); }
.stat.tone-purple { --ink: var(--card-deposit-ink, #fff); --ink-soft: var(--card-deposit-ink-soft, rgba(255,255,255,.92)); --corner: var(--card-deposit-corner, rgba(255,255,255,.18)); --tshadow: var(--card-deposit-shadow, 0 1px 3px rgba(0,0,0,.36)); }
.stat.tone-orange { --ink: var(--card-pipeline-ink, #fff); --ink-soft: var(--card-pipeline-ink-soft, rgba(255,255,255,.92)); --corner: var(--card-pipeline-corner, rgba(255,255,255,.18)); --tshadow: var(--card-pipeline-shadow, 0 1px 3px rgba(0,0,0,.36)); }
.stat.accent      { --ink: var(--card-sales-ink, #fff); --ink-soft: var(--card-sales-ink-soft, rgba(255,255,255,.92)); --corner: var(--card-sales-corner, rgba(255,255,255,.18)); --tshadow: var(--card-sales-shadow, 0 1px 3px rgba(0,0,0,.36)); }
/* สีการ์ดปรับได้จากหน้า "ตั้งค่าธีมสี" — ค่าใน var() คือค่าเริ่มต้นเดิม (ถ้ายังไม่ตั้งจะใช้ค่านี้) */
.stat.tone-mint   { background: linear-gradient(135deg, var(--card-newJobs-from, #3a2fd0), var(--card-newJobs-to, #7c7bff)); }   /* งานรับเข้าใหม่ */
.stat.tone-slate  { background: linear-gradient(135deg, var(--card-open-from, #0b64ca), var(--card-open-to, #35b8f5)); }         /* เปิดงาน/รอเสนอราคา */
.stat.tone-green  { background: linear-gradient(135deg, var(--card-won-from, #04794a), var(--card-won-to, #23e394)); }           /* งานที่ปิดได้ */
.stat.tone-purple { background: linear-gradient(135deg, var(--card-deposit-from, #7d18de), var(--card-deposit-to, #c072ff)); }   /* รอมัดจำ */
.stat.tone-orange { background: linear-gradient(135deg, var(--card-pipeline-from, #dc1a54), var(--card-pipeline-to, #ff8460)); } /* รอปิดการขาย */
.stat.accent      { background: linear-gradient(135deg, var(--card-sales-from, #9c6004), var(--card-sales-to, #f5b825)); }       /* ยอดปิดการขาย */

/* =====================================================================
   หัวข้อ section + หัวตาราง "ทุกจุดทั่วระบบ" ผูกกับตัวแปรกลางชุดเดียว
   (ปรับจากหน้าตั้งค่าธีมสีครั้งเดียว มีผลทุกหน้า)
   --section-head-bg = แถบหัวข้อ/หัวตาราง · --section-body-bg = พื้นที่เนื้อหาในการ์ด
   ===================================================================== */
.card-head { background: var(--section-head-bg, var(--surface-2)); color: var(--section-head-ink, var(--text)); }
table.table th { background: var(--section-head-bg, var(--surface-2)); color: var(--section-head-ink-soft, var(--muted)); }
.price-matrix thead th { background: var(--section-head-bg, var(--surface-2)); color: var(--section-head-ink-soft, var(--muted)); }
.card-pad { background: var(--section-body-bg, transparent); color: var(--section-body-ink, var(--text)); }
.card > .card-pad:last-child { border-radius: 0 0 var(--radius) var(--radius); }
/* ใบเสนอราคาเป็นกระดาษขาว — ไม่ให้สีธีมมาทับ */
.sheet .card-head, .sheet table.table th, .sheet .card-pad { background: revert; }

/* =====================================================================
   ตารางคำนวณราคา — จัด เครื่องพิมพ์/วัสดุ (แถวบน) + เคลือบ/ติดบน (แถวล่าง)
   ไว้ในช่องเดียว เพื่อให้ช่องตัวเลขกว้างพอแสดงค่าครบ
   ===================================================================== */
.calc-table .spec-cell { min-width: 330px; }
.calc-spec { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 10px; }
.calc-spec label { display: block; min-width: 0; }
.calc-spec label > span { display: block; font-size: 11px; color: var(--faint); margin-bottom: 3px; }
.calc-spec select.select { width: 100%; }
.calc-table .num-in { max-width: 118px; }
.calc-table td, .calc-table th { white-space: nowrap; }
.calc-table td.num, .calc-table th.num { min-width: 96px; }

/* ===================== TABDA — เพิ่มเติม ===================== */
/* การ์ดสรุปแดชบอร์ด (4 ใบ) — ใช้ตัวแปรธีมสมาชิก + auto-contrast */
.stat.tone-pending, .stat.tone-active, .stat.tone-expiring, .stat.tone-expired {
  border-color: transparent; border-radius: 16px;
  box-shadow: 0 16px 36px -16px rgba(0, 0, 0, .3);
}
.stat.tone-pending  { background: linear-gradient(135deg, var(--card-pending-from, #9c6004), var(--card-pending-to, #f5b825)); color: var(--card-pending-ink, #fff); }
.stat.tone-active   { background: linear-gradient(135deg, var(--card-active-from, #04794a), var(--card-active-to, #23e394)); color: var(--card-active-ink, #fff); }
.stat.tone-expiring { background: linear-gradient(135deg, var(--card-expiring-from, #b45309), var(--card-expiring-to, #fb923c)); color: var(--card-expiring-ink, #fff); }
.stat.tone-expired  { background: linear-gradient(135deg, var(--card-expired-from, #b91c1c), var(--card-expired-to, #f87171)); color: var(--card-expired-ink, #fff); }
.stat.tone-pending  .value, .stat.tone-active .value, .stat.tone-expiring .value, .stat.tone-expired .value { color: inherit; text-shadow: 0 1px 3px rgba(0,0,0,.3); }
.stat.tone-pending  .label, .stat.tone-active .label, .stat.tone-expiring .label, .stat.tone-expired .label,
.stat.tone-pending  .meta,  .stat.tone-active .meta,  .stat.tone-expiring .meta,  .stat.tone-expired .meta {
  color: var(--card-pending-ink-soft, rgba(255,255,255,.92)); text-shadow: 0 1px 2px rgba(0,0,0,.28);
}
.stat.tone-active .label,   .stat.tone-active .meta   { color: var(--card-active-ink-soft, rgba(255,255,255,.92)); }
.stat.tone-expiring .label, .stat.tone-expiring .meta { color: var(--card-expiring-ink-soft, rgba(255,255,255,.92)); }
.stat.tone-expired .label,  .stat.tone-expired .meta  { color: var(--card-expired-ink-soft, rgba(255,255,255,.92)); }

/* checkbox แบบ inline */
.check-inline { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check-inline input { width: 17px; height: 17px; }

/* ===== หน้าสาธารณะ (ฟอร์มสมัคร / เช็คสถานะ) ===== */
.public-wrap { min-height: 100vh; width: 100%; background: var(--bg); padding: 26px 16px 40px; }
.public-inner { max-width: 720px; margin: 0 auto; }
.public-head { text-align: center; margin-bottom: 20px; }
.public-head h1 { font-size: 26px; }
.public-foot { max-width: 720px; margin: 22px auto 0; text-align: center; }
.public-foot a { color: var(--brand-ink); font-weight: 600; }

/* ===== ใบข้อมูลสมาชิก (memberDetail sheet) ===== */
.sheet-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.sheet-hr { border: none; border-top: 3px solid var(--brand); margin: 14px 0 4px; }
.sheet-section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--brand-ink); margin: 16px 0 6px; border-bottom: 1px solid #eceef2; padding-bottom: 5px; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.sheet-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed #eef1f5; }
.sheet-foot { margin-top: 26px; border-top: 1px solid #eceef2; padding-top: 12px; font-size: 11px; text-align: center; }
@media (max-width: 640px) { .sheet-grid { grid-template-columns: 1fr; } }

/* ===== ตัวเลือกที่อยู่ไทย (address picker) ===== */
.addr-picker .field { margin-bottom: 10px; }
.addr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.addr-picker.is-disabled { opacity: .6; }
.addr-mirror { background: var(--surface-2, #f6f8fa); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; color: var(--muted); min-height: 20px; margin-bottom: 4px; }
@media (max-width: 640px) { .addr-grid { grid-template-columns: 1fr; } }

/* ===== สิทธิประโยชน์สมาชิก ===== */
.benefit-list { margin: 0; padding-left: 20px; }
.benefit-list li { padding: 4px 0; }
.benefit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.benefit-row .input { flex: 1; }
