/*
 * หน้าตาชุดเดียวกับเว็บหลัก vingroupphone.com (VIN PHONE · รีแบรนด์จาก Promp Phone 29 ต.ค. 2569) — ฟอนต์ LINE Seed
 * ปุ่มหลักเขียว #00b84a · ลิงก์/จุดเน้นน้ำเงินรอยัล #2a4fd9 · ไล่สีเขียว→ฟ้าตามคำว่า VIN ในโลโก้ · พื้นเทาอ่อนเรียบ
 * ค่าสียกมาจาก src/app/globals.css ของเว็บหลัก (ชุดฟ้า Promp Phone เดิมอยู่ใน git history)
 */
@font-face { font-family: lineSeedTh; src: url(fonts/LINESeedSansTH_W_Rg.woff2) format('woff2'); font-weight: 400; font-display: swap }
@font-face { font-family: lineSeedTh; src: url(fonts/LINESeedSansTH_W_Bd.woff2) format('woff2'); font-weight: 700; font-display: swap }
@font-face { font-family: lineSeedEn; src: url(fonts/LINESeedSans_W_Rg.woff2) format('woff2'); font-weight: 400; font-display: swap }
@font-face { font-family: lineSeedEn; src: url(fonts/LINESeedSans_W_Bd.woff2) format('woff2'); font-weight: 700; font-display: swap }

:root {
  /* ห้ามใช้ --brand เป็นสีตัวหนังสือบนพื้นขาว (เขียวบนขาวแค่ 2.6:1) — ตัวหนังสือเน้นใช้ --navy */
  --brand: #00b84a; --brand-dark: #00a040; --navy: #2a4fd9; --navy-dark: #1f3db3;
  /* --tint/--pale คู่กับตัวหนังสือ --navy · --aqua = ตัวหนังสือเล็กบนพื้น --grad */
  --tint: #eaf5fd; --pale: #bfe3f8; --aqua: #d9f7e6;
  --ink: #111111; --body: #444444; --muted: #6b6b6b; --faint: #9a9a9a;
  --line: #e5e5e5; --line-strong: #d6d6d6; --soft: #f7f7f7; --sunk: #efefef;
  --night: #0f1f2e; --night-text: #a9b8c4;
  --ok: #067a3a; --ok-bg: #eaf9ef; --line-green: #06c755;
  --red: #d93a4a; --red-bg: #fdeef0; --amber: #a15c07; --amber-bg: #fdf3e1;
  /* เขียว→ฟ้าแบบคำว่า VIN แต่หรี่ลงให้ตัวหนังสือขาวบนพื้นอ่านออก (ชุด --ci-money ของเว็บหลัก) */
  --grad: linear-gradient(135deg, #009a3e 0%, #00897b 50%, #0077c8 100%);
  --side-bg: #ffffff; --side-fg: #111111; --side-active: var(--navy);
  /* วงกลมสถานะการผ่อนชำระ */
  --mark-ok: #16a34a; --mark-late: #f5b400; --mark-over: #dc2626; --mark-none: #c9d1db;
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 24px;
  --shadow: 0 1px 2px rgba(31, 41, 55, .04), 0 10px 30px -18px rgba(31, 41, 55, .18);
  --shadow-brand: 0 12px 26px -14px rgba(0, 184, 74, .6);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --top-h: 72px; --side-w: 236px;
}
* { box-sizing: border-box }
html, body { height: 100% }
body {
  margin: 0; background: var(--soft); color: var(--ink);
  font: 400 15px/1.55 lineSeedEn, lineSeedTh, Tahoma, "Leelawadee UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.25 }
a { color: var(--navy); text-decoration: none }
b, strong { font-weight: 700 }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em }
[hidden] { display: none !important }
.logo { height: 24px; width: auto; display: block }
:focus-visible { outline: 3px solid rgba(0, 184, 74, .45); outline-offset: 2px }

/* ── ล็อกอิน ─────────────────────────────────────────── */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(600px 400px at 85% 10%, rgba(0, 200, 83, .2), transparent 70%),
    radial-gradient(500px 360px at 10% 95%, rgba(10, 140, 227, .16), transparent 70%),
    linear-gradient(180deg, #f7fdf9, #eef7fd);
}
.login-card {
  width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow); padding: 36px 32px 32px;
}
.login-card .logo { height: 32px; margin: 0 auto 22px }
.login-card h1 { font-size: 24px; text-align: center }
.login-card .sub { margin: 6px 0 24px; text-align: center; color: var(--muted); font-size: 14px }
.login-form { display: grid; gap: 14px }
.login-form label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 700 }
.login-form input {
  height: 48px; padding: 0 18px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.login-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0, 184, 74, .2) }
.login-form button {
  margin-block-start: 6px; height: 50px; border: 0; border-radius: 999px; background: var(--brand); color: #fff;
  font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: var(--shadow-brand); transition: background .15s, opacity .15s;
}
.login-form button:hover { background: var(--brand-dark) }
.login-form button:not(.ready) { opacity: .6; box-shadow: none }
.login-foot { margin: 22px 0 0; text-align: center; color: var(--faint); font-size: 12.5px }
.err { color: var(--red); font-size: 13.5px; margin: 0 }

/* ── โครงหน้า ─────────────────────────────────────────── */
.app { height: 100dvh; display: grid; grid-template: var(--top-h) 1fr / var(--side-w) 1fr }
.top {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 28px 0 24px; background: rgba(255, 255, 255, .94); border-block-end: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(8px); position: relative; z-index: 5;
}
.top-right { display: flex; align-items: center; gap: 12px; font-size: 14px }
.welcome { display: flex; align-items: center; gap: 8px; color: var(--muted) }
.welcome b { color: var(--ink) }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 14px;
}
.lang { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: #fff }
.lang button {
  border: 0; background: none; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.lang button.on { background: var(--night); color: #fff }
.lang button:disabled { cursor: not-allowed; opacity: .55 }
.logout {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 999px;
  border: 0; background: var(--night); color: #fff; font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.logout:hover { background: #000 }
.logout svg { width: 15px; height: 15px }
/* กระดิ่งสลิปรอตรวจ — มีสลิปค้างเป็นสีแดงและสั่นเบา ๆ */
.bell {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
}
.bell:hover { background: var(--tint) }
.bell svg { width: 19px; height: 19px }
.bell.has { color: var(--red); border-color: #f3c2c8; background: var(--red-bg) }
.bell.has svg { animation: bell-ring 2.4s var(--ease) infinite; transform-origin: 50% 8% }
.bell-n, .menu-n {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 11.5px; font-weight: 700; line-height: 19px; text-align: center;
}
.bell-n { position: absolute; top: -5px; right: -6px; box-shadow: 0 0 0 2px #fff }
.menu-n { display: inline-block; margin-inline-start: 6px }
@keyframes bell-ring { 0%, 60%, 100% { transform: rotate(0) } 8%, 24% { transform: rotate(14deg) } 16%, 32% { transform: rotate(-12deg) } 40% { transform: rotate(5deg) } }
@media (prefers-reduced-motion: reduce) { .bell.has svg { animation: none } }
.sound-gate {
  height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid #f3c2c8;
  background: var(--red-bg); color: var(--red); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  animation: gate-pulse 1.6s var(--ease) infinite;
}
.sound-gate[hidden] { display: none }
@keyframes gate-pulse { 50% { box-shadow: 0 0 0 5px rgba(220, 38, 38, .14) } }
@media (prefers-reduced-motion: reduce) { .sound-gate { animation: none } }
/* รูปสลิปในตารางและในกล่องรับชำระ */
.slip-thumb { display: block; width: 44px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--sunk) }
.slip-big { display: block; max-width: 100%; max-height: 62vh; margin: 0 auto; border-radius: var(--r-sm); border: 1px solid var(--line) }
.slip-check { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 18px; align-items: start }
.slip-check .slip-big { max-height: 70vh }
@media (max-width: 900px) { .slip-check { grid-template-columns: 1fr } }

.side {
  background: var(--side-bg); color: var(--side-fg); overflow-y: auto; padding: 16px 12px 36px;
  border-inline-end: 1px solid var(--line);
  /* ทุกสีในเมนูผสมจากสีที่ตั้งในหน้า "ตั้งค่าสี" — พื้นเข้มหรืออ่อนก็อ่านออก */
  --side-dim: color-mix(in srgb, var(--side-fg) 68%, transparent);
  --side-faint: color-mix(in srgb, var(--side-fg) 48%, transparent);
  --side-hover: color-mix(in srgb, var(--side-fg) 6%, transparent);
  --side-on: color-mix(in srgb, var(--side-active) 11%, transparent);
  --side-rule: color-mix(in srgb, var(--side-fg) 10%, transparent);
}
.side::-webkit-scrollbar { width: 8px } .side::-webkit-scrollbar-thumb { background: var(--side-rule); border-radius: 4px }

/* ช่องค้นหาเมนู */
.menu-find {
  position: sticky; top: -16px; z-index: 1; display: flex; align-items: center; gap: 8px;
  margin: -16px -12px 10px; padding: 16px 12px 10px; background: var(--side-bg);
}
.menu-find svg { position: absolute; inset-inline-start: 24px; width: 16px; height: 16px; color: var(--side-faint); pointer-events: none }
.menu-find input {
  width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 12px; font-size: 13.5px;
  border: 1px solid var(--side-rule); background: var(--side-hover); color: var(--side-fg);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.menu-find input::placeholder { color: var(--side-faint) }
.menu-find input:focus { outline: none; border-color: var(--brand); background: var(--side-bg); box-shadow: 0 0 0 3px rgba(0, 184, 74, .2) }
.menu-none { margin: 10px 12px; font-size: 13px; color: var(--side-faint) }

/* รายการเมนู — ไอคอน + ชื่อ · หน้าที่เปิดอยู่เป็นแถบสีพร้อมขีดซ้าย */
.side a {
  position: relative; display: flex; align-items: center; gap: 11px; color: var(--side-dim);
  min-height: 40px; padding: 8px 12px; margin: 1px 0; border-radius: 11px; font-size: 14px; line-height: 1.3;
  transition: background .15s, color .15s;
}
.side a .mi { flex: none; display: grid; place-items: center; width: 20px; height: 20px; color: var(--side-faint); transition: color .15s }
.side a .mi svg { width: 19px; height: 19px }
.side a .ml { flex: 1; min-width: 0 }
.side a:hover { background: var(--side-hover); color: var(--side-fg) }
.side a:hover .mi { color: var(--side-fg) }
.side a.on { background: var(--side-on); color: var(--side-active); font-weight: 700; box-shadow: inset 3px 0 0 var(--side-active) }
.side a.on .mi { color: var(--side-active) }
.side .menu-n { margin-inline-start: auto }

/* หัวข้อกลุ่ม — กดพับ/กางได้ ลูกศรหมุนตาม */
.side .grp { margin-block-start: 14px; padding-block-start: 12px; border-block-start: 1px solid var(--side-rule) }
.side .sec {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  margin: 0 0 4px; padding: 6px 12px; border: 0; border-radius: 9px; background: none; cursor: pointer;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--side-faint); text-align: start;
}
.side .sec:hover { background: var(--side-hover); color: var(--side-fg) }
.side .sec svg { width: 15px; height: 15px; transition: transform .2s var(--ease) }
.side .grp.folded .sec svg { transform: rotate(-90deg) }
.side .grp-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .22s var(--ease) }
.side .grp.folded .grp-body { grid-template-rows: 0fr }
.side .group { display: grid; overflow: hidden; min-height: 0 }
/* กำลังค้นหา — กางทุกกลุ่มที่มีผล ไม่สนว่าพับไว้ */
.side .finding .grp.folded .grp-body { grid-template-rows: 1fr }
.side .finding .grp.folded .sec svg { transform: none }
@media (prefers-reduced-motion: reduce) { .side .grp-body, .side .sec svg { transition: none } }

.main { overflow: auto; padding: 28px 32px 56px; min-width: 0 }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin: 0 0 18px }
.page-head h1 { font-size: 26px; letter-spacing: -.01em }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap }
.loading { color: var(--faint); padding: 30px 0 }

/* ── ปุ่ม (ทรงแคปซูลแบบเว็บหลัก) ─────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 20px;
  border: 0; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 700; white-space: nowrap; color: #fff;
  transition: background .15s, box-shadow .15s, transform .15s var(--ease);
}
.btn:active { transform: translateY(1px) }
.btn svg { width: 15px; height: 15px; flex: none }
.btn-add, .btn-primary, .btn-green { background: var(--brand); box-shadow: var(--shadow-brand) }
.btn-add:hover, .btn-primary:hover, .btn-green:hover { background: var(--brand-dark) }
.btn-green { min-width: 150px }
.btn-ghost, .btn-outline, .btn-warn { background: #fff; color: var(--ink); border: 1px solid var(--line-strong) }
.btn-ghost:hover, .btn-outline:hover, .btn-warn:hover { background: var(--soft) }
.btn-outline { width: 100% }
.btn-danger { background: var(--red) }
.btn-danger:hover { background: #c02f3e }
.btn-cyan { background: var(--navy) }
.btn-cyan:hover { background: var(--navy-dark) }
.btn-excel { background: #fff; color: var(--ink); border: 1px solid var(--line-strong) }
.btn-excel svg { color: #1d7044 }
.btn-excel:hover { background: var(--soft) }
.btn-excel.sm { height: 32px; padding: 0 14px; font-size: 12.5px }
.btn:disabled { opacity: .5; cursor: not-allowed }
.btn-search {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-brand);
}
.btn-search:hover { background: var(--brand-dark) }
.btn-search svg { width: 15px; height: 15px }
.ic {
  width: 32px; height: 32px; border: 0; border-radius: 10px; display: inline-grid; place-items: center;
  cursor: pointer; vertical-align: middle; margin: 0 2px; background: var(--tint); color: var(--navy); transition: filter .15s;
}
.ic:hover { filter: brightness(.95) }
.ic svg { width: 15px; height: 15px }
.ic.del, .ic.lock { background: var(--red-bg); color: var(--red) }
.ic.ok { background: var(--ok-bg); color: var(--ok) }
.ic:disabled { opacity: .4; cursor: not-allowed }

/* ── ช่องกรอก ─────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 18px }
.filters .row { display: flex; gap: 8px; width: 100%; flex-wrap: wrap; align-items: center }
.inp, .sel, .area {
  height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 14.5px; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
.inp::placeholder, .area::placeholder { color: var(--faint) }
/* ตัวกรองทรงแคปซูลแบบช่องค้นหาของเว็บหลัก */
.filters .inp, .filters .sel, .drange > .inp { width: 176px; border-radius: 999px; padding-inline: 18px }
.filters .inp.w-sm, .filters .sel.w-sm { width: 118px }
.sel {
  appearance: none; padding-inline-end: 38px; cursor: pointer;
  background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1.5l5 5 5-5" fill="none" stroke="%231f2937" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat right 16px center;
}
.filters .sel { padding-inline-end: 38px }
.area { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; width: 100% }
input[type=number].inp { text-align: end }
/* ช่องตัวเลขไม่มีลูกศรขึ้น/ลง (เจ้าของร้านไม่ต้องการ) — พิมพ์ตัวเลขเองอย่างเดียว */
input[type=number] { appearance: textfield; -moz-appearance: textfield }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0 }
.inp:focus, .sel:focus, .area:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0, 184, 74, .2) }
.inp:disabled, .sel:disabled, .area:disabled { background: var(--soft); color: var(--muted) }

/* ช่วงวันที่ */
.drange { position: relative; display: inline-block }
.drange > .inp { cursor: pointer }
.drange-pop {
  position: absolute; z-index: 30; top: 46px; left: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 18px 40px -16px rgba(31, 41, 55, .3); padding: 14px; display: grid; gap: 10px; width: 300px;
}
.drange-pop .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.drange-pop label { font-size: 12px; color: var(--muted); display: grid; gap: 3px }
.drange-pop .inp { width: 100%; font-size: 13px; padding: 0 8px; border-radius: 10px }
.drange-pop .quick { display: flex; flex-wrap: wrap; gap: 6px }
.drange-pop .quick button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12.5px; cursor: pointer;
}
.drange-pop .quick button:hover { background: var(--tint); border-color: var(--pale) }
.drange-pop .foot { display: flex; justify-content: space-between }
.drange-pop .btn { height: 34px; padding: 0 16px }

/* สวิตช์เปิด/ปิด */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; cursor: pointer }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--sunk); transition: background .2s var(--ease) }
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(31, 41, 55, .25); transition: left .2s var(--ease);
}
.switch input:checked + span { background: var(--brand) }
.switch input:checked + span::after { left: 21px }
.switch input:focus-visible + span { outline: 3px solid rgba(0, 184, 74, .45) }

/* ฟอร์มหน้าตั้งค่า */
.form { display: grid; gap: 14px; max-width: 580px }
.form.narrow { max-width: 340px }
.fld { display: grid; gap: 6px; min-width: 0 }
.fld > span { font-weight: 700; font-size: 13.5px }
.fld .hint { font-weight: 400; color: var(--muted); font-size: 12px }
.fld .hint.warn { color: var(--amber) }
.fld .inp, .fld .sel { width: 100% }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px }
.form .btn-green { justify-self: start; margin-block-start: 8px }
.suffix { position: relative } .suffix .inp { padding-inline-end: 32px }
.suffix.wide .inp { padding-inline-end: 52px }
.suffix::after { content: attr(data-suffix); position: absolute; inset-inline-end: 14px; top: 50%; translate: 0 -50%; font-size: 14px; color: var(--muted) }
/* หน้าตั้งค่าเป็นการ์ดขาวบนพื้นฟ้าอ่อน */
/* .bare = ฟอร์มที่มีการ์ดของตัวเองอยู่ข้างในแล้ว ไม่ต้องครอบซ้ำ */
.main > div > .form:not(.bare), .main > div > form:not(.filters):not(.app-form):not(.bare) {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow);
}

/* ── หน้าฟอร์ม: การ์ดฟอร์ม + คอลัมน์อธิบายข้าง (lib.js formLayout/formCard) ── */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 22px; align-items: start; max-width: 1240px }
.form-layout.solo { grid-template-columns: minmax(0, 1fr); max-width: 900px }
.form-layout.solo.wide { max-width: 1240px }
.form-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; min-width: 0 }
.fc-head { display: flex; gap: 14px; align-items: flex-start; padding: 22px 26px 18px; border-block-end: 1px solid var(--line) }
.fc-ic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--tint); color: var(--navy) }
.fc-ic svg { width: 22px; height: 22px }
.fc-head h2 { font-size: 17px; margin-block-start: 1px }
.fc-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5 }
.fc-body { display: grid; gap: 16px; padding: 22px 26px 24px }
.fc-sec { display: grid; gap: 12px }
.fc-sec + .fc-sec { padding-block-start: 20px; border-block-start: 1px dashed var(--line) }
.fc-sec > h3 { font-size: 14.5px; color: var(--ink) }
.fc-sec > h3 small { font-weight: 400; color: var(--faint); font-size: 12.5px; margin-inline-start: 4px }
.fc-actions {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 16px 26px; background: var(--soft); border-block-start: 1px solid var(--line);
}
.fc-actions .btn svg { width: 16px; height: 16px }
.fc-actions .hint { color: var(--faint); font-size: 13px }
.form-aside { display: grid; gap: 16px; position: sticky; top: 0; min-width: 0 }
.aside-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px;
  font-size: 13.5px; line-height: 1.6; color: var(--body);
}
.aside-card.tint { background: var(--tint); border-color: var(--pale) }
.aside-card h3 { display: flex; align-items: center; gap: 8px; font-size: 14.5px; margin: 0 0 10px; color: var(--ink) }
.aside-card h3 svg { flex: none; width: 18px; height: 18px; color: var(--navy) }
.aside-card p { margin: 0 0 8px } .aside-card p:last-child { margin: 0 }
.aside-card ol, .aside-card ul { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px }
.aside-card dl { margin: 0 }
.aside-card dt { font-weight: 700; color: var(--ink) }
.aside-card dd { margin: 1px 0 12px; color: var(--muted) } .aside-card dd:last-child { margin-block-end: 0 }
.chips { display: flex; flex-wrap: wrap; gap: 6px }
.chips span { padding: 3px 10px; border-radius: 999px; background: var(--sunk); color: var(--muted); font-size: 12.5px }
/* หน้าเงินดาวน์ — การ์ดละประเภทเรียงเป็นตาราง */
.down-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px }
.down-card { padding: 16px 16px 18px; display: grid; gap: 8px; align-content: start }
.down-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-block-start: 16px }
/* ช่องเลือกสีหน้าตั้งค่าสี + ชุดสีสำเร็จรูป */
.color-inp { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer }
.color-inp::-webkit-color-swatch-wrapper { padding: 0 }
.color-inp::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 8px }
.color-inp::-moz-color-swatch { border: 1px solid var(--line); border-radius: 8px }
.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px }
.swatches button {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; font-size: 13px; text-align: start;
}
.swatches button:hover { border-color: var(--brand); background: var(--tint) }
.swatches span { flex: none; display: grid; place-items: center; width: 30px; height: 26px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; font-weight: 700 }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 10px }
@media (max-width: 1280px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
@media (max-width: 1100px) {
  .form-layout { grid-template-columns: minmax(0, 1fr) }
  .form-aside { position: static }
}
@media (max-width: 560px) {
  .fc-head, .fc-body, .fc-actions { padding-inline: 18px }
}

/* ปุ่มเลือกรูป */
.imgs { display: flex; gap: 10px; flex-wrap: wrap }
.img-pick { display: grid; gap: 6px; font-weight: 700; font-size: 13.5px }
.img-box {
  position: relative; width: 104px; height: 80px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); display: grid;
  place-items: center; cursor: pointer; overflow: hidden; background: var(--soft); color: var(--muted);
}
.img-box:hover { border-color: var(--brand); color: var(--navy) }
.img-box img { width: 100%; height: 100%; object-fit: contain; background: #fff }
.img-box svg { width: 20px; height: 20px }
.img-box input { display: none }
.img-x {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  background: var(--red); color: #fff; font-size: 13px; line-height: 17px; cursor: pointer; padding: 0;
}
.img-wrap { position: relative; width: max-content }
.copy { position: relative } .copy .inp { padding-inline-end: 44px }
.copy button {
  position: absolute; inset-inline-end: 6px; top: 5px; width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: var(--tint); color: var(--navy); cursor: pointer; display: grid; place-items: center;
}
.copy svg { width: 15px; height: 15px }

/* ── ตาราง (การ์ดขาว หัวตารางฟ้าอ่อน แบบตารางงวดผ่อนของเว็บหลัก) ── */
.tbl-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; margin: 0 0 10px; font-size: 14px; color: var(--muted) }
.tbl-wrap {
  overflow-x: auto; margin: 0 0 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.tbl-wrap::-webkit-scrollbar { height: 10px } .tbl-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px }
/* หัวตาราง — แบ่งเป็นช่องให้เห็นชัดว่าคอลัมน์ไหนคู่กับข้อมูลไหน
   เดิมพื้นอ่อนเกินและไม่มีเส้นคั่น อ่านยากเวลาคอลัมน์เยอะ */
.tbl th {
  background: var(--sunk); color: var(--ink); font-weight: 700; font-size: 13.5px; padding: 15px 16px;
  white-space: nowrap; text-align: center;
  border-block-end: 2px solid var(--line-strong);
  border-inline-end: 1px solid var(--line-strong);
}
.tbl th:last-child { border-inline-end: 0 }
/* เส้นคั่นจาง ๆ ในตัวข้อมูล พอให้กวาดตาตามคอลัมน์ได้ ไม่ตีกรอบจนลาย */
.tbl td { border-inline-end: 1px solid var(--line) }
.tbl td:last-child { border-inline-end: 0 }
.tbl td { padding: 14px 16px; text-align: center; white-space: nowrap; border-block-end: 1px solid var(--line); color: var(--body) }
.tbl tbody tr:last-child td { border-block-end: 0 }
.tbl td.l, .tbl th.l { text-align: start } .tbl td.r, .tbl th.r { text-align: end }
.tbl td.wrap { white-space: normal; min-width: 180px }
.tbl tr.click { cursor: pointer } .tbl tbody tr:hover td { background: var(--soft) }
/* แถวเงินดาวน์ในตารางผ่อน — แยกจากงวดผ่อนให้เห็นว่าเป็นเงินก้อนแรกตอนทำสัญญา */
.tbl tr.row-down td { background: var(--tint) }
.tbl tfoot td { font-weight: 700; background: var(--soft) }
.tbl .empty { color: var(--faint); padding: 34px; text-align: center }
.pager { display: flex; gap: 6px; justify-content: flex-end }
.pager button {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink);
  cursor: pointer; display: grid; place-items: center;
}
.pager button:hover:not(:disabled) { background: var(--tint); border-color: var(--pale) }
.pager button:disabled { color: var(--line-strong); cursor: default }
.pager svg { width: 11px; height: 11px }
/* ตารางในการ์ด/กล่อง ไม่ต้องมีกรอบซ้อน */
.panel .tbl-wrap, .modal-card .tbl-wrap { box-shadow: none; border-radius: var(--r) }

.tag {
  display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--sunk); color: var(--muted); white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok) } .tag.warn { background: var(--amber-bg); color: var(--amber) }
.tag.bad { background: var(--red-bg); color: var(--red) } .tag.info { background: var(--tint); color: var(--navy) }
.tag.dark { background: var(--night); color: #fff }

/* ── การ์ด ────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 22px 24px; min-width: 0;
}
.card .lbl { font-size: 14px; color: var(--muted) }
.card .val { font-size: 26px; font-weight: 700; margin-block-start: 6px; font-variant-numeric: tabular-nums; color: var(--ink); letter-spacing: -.01em }
/* การ์ดคาดการณ์แถวบนใช้พื้นไล่สีแบบแบนเนอร์ของเว็บหลัก */
.card.blue { background: var(--grad); border-color: transparent; box-shadow: 0 16px 34px -20px rgba(0, 137, 123, .55) }
.card.blue .lbl { color: var(--aqua) } .card.blue .val { color: #fff }
.card.violet { background: var(--tint); border-color: var(--pale) } .card.violet .val { color: var(--navy) }
.card .split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-block-start: 8px }
.card .split small { display: block; font-size: 12.5px; color: var(--muted) }
.card .split b { font-size: 22px }
.cards.sm .card { padding: 18px 22px } .cards.sm .val { font-size: 22px }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0;
}
.panel > h3 { font-size: 17px; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 0 0 16px }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 14px }
.kv dt { color: var(--muted) } .kv dd { margin: 0; overflow-wrap: anywhere }
.map { display: block; width: 100%; height: 260px; margin: 8px 0 0; border: 1px solid var(--line); border-radius: 12px; background: var(--soft) }
.note {
  background: var(--amber-bg); color: var(--amber); border-radius: var(--r); padding: 11px 16px; font-size: 13.5px; margin: 0 0 14px;
}
.note.bad { background: var(--red-bg); color: var(--red) } .note.info { background: var(--tint); color: var(--navy) }
/* สถานะระบบ MDM บนแดชบอร์ด */
.health { margin: 0 0 16px }
.health .note { margin: 0 0 10px }
.health .note ul { margin: 6px 0 0; padding-inline-start: 20px }
.health-ok { margin: 4px 0 0; font-size: 13px; color: var(--muted) }

/* ── กราฟ ─────────────────────────────────────────────── */
.chart {
  display: grid; grid-template-columns: 1fr 220px; gap: 12px; align-items: end; margin: 0 0 18px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 22px 24px 16px;
}
.chart svg { width: 100%; height: auto; max-height: 360px; overflow: visible }
.chart .axis text { font-size: 12px; fill: var(--muted) }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: flex-start; font-size: 13.5px; padding-block-end: 30px }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--body) }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block }

/* ── ตัวแก้ข้อความ (ตั้งค่าสัญญา) ────────────────────────── */
.rte { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px; border-block-end: 1px solid var(--line); background: var(--soft); align-items: center }
.rte-bar button, .rte-bar select { border: 0; background: none; height: 30px; min-width: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; padding: 0 8px }
.rte-bar button:hover { background: var(--sunk) } .rte-bar .sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 6px }
.rte-body { min-height: 420px; max-height: 65vh; overflow: auto; padding: 14px 18px; outline: none; font-size: 14.5px; line-height: 1.75 }
.rte-code { width: 100%; min-height: 420px; border: 0; padding: 14px; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical }

/* ── modal ────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; overflow-y: auto }
.modal-scrim { position: fixed; inset: 0; background: rgba(31, 41, 55, .42); backdrop-filter: blur(2px) }
.modal-card {
  position: relative; width: 100%; max-width: 540px; background: #fff; border-radius: var(--r-xl); padding: 26px 28px;
  box-shadow: 0 30px 70px -20px rgba(31, 41, 55, .45); display: grid; gap: 16px;
}
.modal-card.wide { max-width: 780px }
.modal-card h3 { font-size: 20px }
.modal-card .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px }
.modal-card .fields .full { grid-column: 1 / -1 }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-block-start: 4px }
.modal-foot .btn-green { min-width: 120px }
.modal-x {
  position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--soft); font-size: 15px; cursor: pointer; color: var(--muted);
}
.modal-x:hover { background: var(--sunk) }
/* รูปเครื่องจริง (รุ่น + สี) มุมขวาบนของหน้าเครื่อง ใต้ปุ่มปิด — แถวบน ๆ ค่าสั้น ไม่ทับกัน */
.dev-photo { position: absolute; top: 64px; right: 28px; width: 140px; height: auto; pointer-events: none }
@media (max-width: 640px) { .dev-photo { position: static; display: block; width: 120px; margin: 0 auto } }
/* แทร็กของ grid ต้องหดได้ ไม่งั้นของที่ตัดบรรทัดไม่ได้ (ปุ่มยาว) ดันการ์ดให้กว้างเกินจอมือถือ */
.modal { grid-template-columns: minmax(0, 1fr) }
@media (max-width: 560px) {
  .modal { padding: 12px }
  .modal-card { padding: 22px 18px }
  /* หัวข้ออยู่เหนือค่า — คอลัมน์หัวข้อ 130px กินที่จนปุ่มกับแผนที่ล้น */
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0 }
  .kv dt { margin-block-start: 10px; font-size: 13px }
  .kv dt:first-child { margin-block-start: 0 }
  .kv .btn { white-space: normal; height: auto; min-height: 40px; padding-block: 8px }
}

/* ── toast ────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 22px; right: 22px; display: grid; gap: 8px; z-index: 80 }
.toast {
  background: #fff; border: 1px solid var(--line); border-inline-start: 4px solid var(--brand); padding: 12px 16px; border-radius: var(--r);
  box-shadow: 0 16px 36px -16px rgba(31, 41, 55, .35); font-size: 14px; max-width: 380px;
}
.toast.bad { border-inline-start-color: var(--red) } .toast.ok { border-inline-start-color: var(--line-green) }

/* ── รายละเอียดสัญญา ─────────────────────────────────── */
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px }
.sum-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 14px; color: var(--muted) }
.sum-row b { font-weight: 700; color: var(--ink) }
.quote { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px }
.quote div { background: var(--soft); border-radius: var(--r); padding: 12px 14px }
.quote small { display: block; color: var(--muted); font-size: 12.5px } .quote b { font-size: 18px }
.quote .hl { background: var(--grad) } .quote .hl small { color: var(--aqua) } .quote .hl b { color: #fff }
.cmd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px }
.cmd-grid button {
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; cursor: pointer; text-align: start; font-weight: 700; font-size: 13.5px;
}
.cmd-grid button:hover { background: var(--tint); border-color: var(--pale) }
.cmd-grid button.is-danger { border-color: #f3c2c8; color: var(--red) }
.cmd-grid button.is-danger:hover { background: var(--red-bg) }
.cmd-grid button .tag { display: block; width: max-content; margin-block-start: 6px; font-size: 11px }
.cmd-grid button:disabled { opacity: .45; cursor: not-allowed }

/* ── สถานะการผ่อนชำระ (ลูกค้าแถวละคน งวดละวงกลม) ──────── */
.inst-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 0 0 14px; font-size: 13.5px; color: var(--body) }
.inst-legend span { display: inline-flex; align-items: center; gap: 7px }
.inst-legend .hint { margin-inline-start: auto; color: var(--muted) }
.mdot { width: 16px; height: 16px; border-radius: 50%; flex: none; display: inline-block; background: var(--mark-none) }
.mdot.ring { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--navy) }
.inst-list { display: grid; gap: 12px; margin: 0 0 12px }
.inst-row {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px 18px;
}
.inst-who {
  display: grid; gap: 3px; align-content: center; min-height: 96px; padding: 14px 16px; border-radius: var(--r);
  background: var(--navy); color: #fff; text-align: center; transition: background .15s;
}
.inst-who:hover { background: var(--navy-dark) }
.inst-who b { font-size: 16px; overflow-wrap: anywhere }
.inst-who small { font-size: 12px; color: #c7d4f4; overflow-wrap: anywhere }
.inst-who small.due { color: #fff; font-weight: 700 }
.inst-dots { display: flex; flex-wrap: wrap; gap: 12px 2px }
.inst-cell { width: 98px; display: grid; justify-items: center; align-content: start; gap: 5px; text-align: center }
.inst-due { font-size: 12.5px; color: var(--body); font-variant-numeric: tabular-nums }
.inst-dot {
  width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: var(--mark-none); color: var(--body); font-weight: 700; font-size: 15px;
  transition: transform .15s var(--ease), box-shadow .15s;
}
button.inst-dot { cursor: pointer }
button.inst-dot:hover { transform: scale(1.07) }
.inst-dot.m-on_time, .mdot.m-on_time { background: var(--mark-ok); color: #fff }
.inst-dot.m-late, .mdot.m-late { background: var(--mark-late); color: #4a3300 }
.inst-dot.m-overdue, .mdot.m-overdue { background: var(--mark-over); color: #fff }
.inst-cell.next .inst-dot { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--navy) }
.inst-cell.next .inst-due { color: var(--navy); font-weight: 700 }
.inst-st { font-size: 12px; line-height: 1.35; color: var(--faint) }
.inst-st.m-on_time { color: var(--ok); font-weight: 700 }
.inst-st.m-late { color: var(--amber); font-weight: 700 }
.inst-st.m-overdue { color: var(--red); font-weight: 700 }
.inst-empty {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 34px; text-align: center; color: var(--faint); margin: 0 0 12px;
}
/* z-index เหนือ .modal (50) — หน้าปฏิทินเปิดเมนูนี้จากในกล่องรายชื่อของวัน */
.mark-pop {
  position: fixed; z-index: 60; width: 250px; display: grid; gap: 2px; padding: 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px -16px rgba(31, 41, 55, .3);
}
.mark-pop .t { padding: 6px 10px 8px; font-size: 12.5px; color: var(--muted) }
.mark-pop button {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px;
  background: none; text-align: start; font-size: 14px; cursor: pointer;
}
.mark-pop button:hover, .mark-pop button.on { background: var(--soft) }
.mark-pop button.on { font-weight: 700 }
.mark-pop button.clear { color: var(--muted); margin-block-start: 4px; border-block-start: 1px solid var(--line); border-radius: 0 0 10px 10px }
.mark-pop button:disabled { opacity: .5; cursor: wait }

/* ── Dashboard: ปุ่มสลับ รายชื่อ / ปฏิทิน ──────────────── */
.mode-switch { display: inline-flex; gap: 2px; padding: 4px; background: #fff; border: 1px solid var(--line-strong); border-radius: 999px }
.mode-switch a {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 16px; border-radius: 999px;
  font-size: 14px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s;
}
.mode-switch a:hover { background: var(--soft); color: var(--ink) }
.mode-switch a.on { background: var(--navy); color: #fff }
.mode-switch svg { width: 16px; height: 16px; flex: none }

/* ── Dashboard แบบปฏิทิน (ช่องวันละไม่เกิน 3 ชื่อ) ─────── */
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; margin: 0 0 12px }
.cal-nav { display: flex; align-items: center; gap: 8px }
.cal-nav h2 { min-width: 170px; margin: 0; font-size: 20px; text-align: center }
.cal-arrow {
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink);
  cursor: pointer; display: grid; place-items: center;
}
.cal-arrow:hover { background: var(--tint); border-color: var(--pale) }
.cal-arrow svg { width: 12px; height: 12px }
.cal-nav .btn { height: 36px; padding: 0 16px; font-size: 13px }
.cal-sum { font-size: 13.5px; color: var(--muted) }
.cal {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  overflow: hidden; margin: 0 0 12px;
}
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) }
.cal-head span {
  padding: 12px 6px; background: var(--sunk); color: var(--ink); font-size: 13.5px; text-align: center;
  border-block-end: 2px solid var(--line-strong);
}
.cal-head .short { display: none }
/* เส้นล่างของแถวสุดท้ายซ่อนใต้ขอบการ์ด ไม่ซ้อนเป็นสองเส้น */
.cal-grid { margin-block-end: -1px }
.cal-day {
  min-width: 0; min-height: 132px; display: flex; flex-direction: column; gap: 5px; padding: 8px;
  border: 0; border-inline-end: 1px solid var(--line); border-block-end: 1px solid var(--line);
  background: #fff; color: inherit; font: inherit; text-align: start;
}
.cal-day:nth-child(7n) { border-inline-end: 0 }
.cal-day.out { background: var(--soft) }
button.cal-day { cursor: pointer; transition: background .15s }
button.cal-day:hover { background: var(--soft) }
button.cal-day:focus-visible { outline: 2px solid var(--navy); outline-offset: -2px }
.cal-n {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%;
  font-size: 13.5px; font-weight: 700; color: var(--body); font-variant-numeric: tabular-nums;
}
.cal-day.today .cal-n { background: var(--navy); color: #fff }
.cal-who { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px }
.cal-who .mdot { width: 12px; height: 12px }
.cal-who > span {
  min-width: 0; padding: 3px 10px; border-radius: 999px; background: var(--tint); color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-who.owe > span { background: var(--red-bg); color: var(--red); font-weight: 700 }
.cal-who.paid > span { background: var(--soft); color: var(--faint) }
.cal-who.paid > span::before { content: '✓ '; color: var(--ok); font-weight: 700 }
.cal-more { padding-inline-start: 18px; font-size: 12.5px; font-weight: 700; color: var(--navy) }
/* กล่องรายชื่อของวัน — คอลัมน์ของการ์ดต้องหดได้ จอแคบตารางจะเลื่อนข้างในแทนดันการ์ดล้นจอ · หัวข้อยาวไม่ทับปุ่มปิด */
.modal-card:has(.cal-tbl) { grid-template-columns: minmax(0, 1fr) }
.modal-card:has(.cal-tbl) h3 { padding-inline-end: 40px }
.inst-dot.sm { width: 36px; height: 36px; font-size: 13px }
.cal-seq { display: grid; justify-items: center; gap: 3px }
.cal-seq small { font-size: 11.5px; color: var(--faint) }
.cal-sub { display: block; margin-block-start: 2px; font-size: 12.5px; color: var(--muted) }
@media (max-width: 700px) {
  .cal-nav h2 { min-width: 0; font-size: 18px }
  .cal-head span { padding: 10px 2px; font-size: 12.5px }
  .cal-head .full { display: none }
  .cal-head .short { display: inline }
  /* จอแคบเหลือแค่จุดสี (ชื่อดูในกล่องตอนกดวัน) */
  .cal-day { min-height: 84px; padding: 6px 2px; align-items: center; gap: 4px }
  .cal-n { width: 24px; height: 24px; font-size: 12.5px }
  .cal-day .cal-who > span { display: none }
  .cal-more { padding: 0; font-size: 11px }
}

@media (max-width: 900px) {
  :root { --side-w: 0px; --top-h: 62px }
  .app { grid-template: var(--top-h) auto 1fr / 1fr }
  .top { padding: 0 14px }
  .side { max-height: 240px; padding: 8px 10px; border-inline-end: 0; border-block-end: 1px solid var(--line) }
  .menu-find { top: -8px; margin: -8px -10px 6px; padding: 8px 10px 6px }
  .menu-find svg { inset-inline-start: 22px }
  .welcome b, .logout span { display: none }
  .main { padding: 18px 16px 48px }
  .cards { grid-template-columns: 1fr 1fr }
  .chart { grid-template-columns: 1fr }
  .grid2, .grid3, .grid4, .modal-card .fields { grid-template-columns: 1fr }
  .filters .inp, .filters .sel, .drange > .inp { width: 100% }
  .filters .drange { width: 100% }
  .inst-row { grid-template-columns: 1fr; gap: 14px; padding: 14px }
  .inst-who { min-height: 0 }
  .inst-dots { justify-content: center }
  .inst-legend .hint { margin-inline-start: 0 }
}

/* ── รายชื่อแอปในเครื่อง (ลิ้นชักรายละเอียดเครื่อง) ──────────────── */
.app-list { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden }
.app-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; font-size: 13.5px; border-block-end: 1px solid var(--line);
}
.app-row:last-child { border-block-end: 0 }
.app-row:nth-child(even) { background: var(--soft) }
/* bundle id กดคัดลอกได้ ทำให้ดูกดได้จริง */
.app-row code {
  font-size: 12px; color: var(--muted); cursor: pointer;
  padding: 2px 7px; border-radius: 6px; background: var(--sunk); white-space: nowrap;
}
.app-row code:hover { background: var(--pale); color: var(--ink) }

/* สถานะคำสั่งภาพพื้นหลัง (.note.bad/.info มีอยู่แล้วด้านบน) */
.note.ok { background: var(--ok-bg); color: var(--ok) }

/* ── แท็บในลิ้นชักรายละเอียดเครื่อง ─────────────────────────────── */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin: 18px 0 14px; border-block-end: 2px solid var(--line);
}
.tabs .tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 9px 16px; font-size: 14px; font-weight: 600; color: var(--muted);
  border-block-end: 3px solid transparent; margin-block-end: -2px;
  border-start-start-radius: 10px; border-start-end-radius: 10px;
}
.tabs .tab:hover { background: var(--soft); color: var(--ink) }
.tabs .tab.on { color: var(--navy); border-block-end-color: var(--navy) }
.tab-panel { display: none }
.tab-panel.on { display: block }

/* แท็บหมวดเครื่องหน้า "เครื่องในระบบ MDM" — ตัวเลขบอกจำนวนเครื่องในหมวด */
.dev-tabs, .list-tabs { margin-block-start: 0 }
.tabs .tab .n {
  display: inline-block; min-width: 22px; padding: 1px 7px; margin-inline-start: 4px; border-radius: 999px;
  background: var(--sunk); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center;
}
.tabs .tab.on .n { background: var(--navy); color: #fff }

/* ตารางเครื่อง — ช่องสัญญา/สถานะตัดบรรทัดได้ แท็กเรียงต่อกันแล้วขึ้นบรรทัดใหม่ ให้ทั้งตารางพอดีจอ */
.tbl.dev-tbl th, .tbl.dev-tbl td { padding-inline: 12px }
.tbl.dev-tbl td.wrap { min-width: 140px }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center }

/* ฟอร์มคำขอสินเชื่อแบบเป็นขั้น (ลูกค้า · เครื่อง · สินเชื่อ · อัพโหลด) */
.steps { display: flex; max-width: 520px; margin: 0 0 18px }
.steps button {
  flex: 1; position: relative; display: grid; justify-items: center; gap: 6px; padding: 0;
  border: 0; background: none; font: inherit; font-size: 13.5px; color: var(--muted); cursor: pointer;
}
/* เส้นเชื่อมจากกลางวงก่อนหน้ามากลางวงนี้ */
.steps button + button::before {
  content: ''; position: absolute; top: 18px; inset-inline-end: 50%; width: 100%; height: 4px; background: var(--sunk);
}
.steps b {
  /* z-index: เส้นของปุ่มถัดไปอยู่หลังวงกลม ไม่ทับตัวเลข */
  position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--sunk); color: var(--body); font-size: 15px; transition: background .2s var(--ease);
}
.steps .done b, .steps .done::before, .steps .on::before { background: var(--brand); color: #fff }
.steps .on b { background: var(--navy); color: #fff; box-shadow: 0 0 0 4px var(--tint) }
.steps .on span { color: var(--ink); font-weight: 700 }
.step-panel { display: none } .step-panel.on { display: block }
.panel.stack { display: grid; gap: 14px; margin: 0 0 16px } .panel.stack > h3 { margin: 0 }
.panel .hint { color: var(--muted); font-size: 13px; font-weight: 400 }
.wizard-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-block-start: 12px }
[data-found]:empty { display: none }

/* ช่องรูปบัตรประชาชน/เอกสาร */
.docs { display: flex; gap: 14px; flex-wrap: wrap }
.doc { position: relative; display: grid; gap: 6px; width: 132px; font-size: 12.5px; font-weight: 400; color: var(--muted); text-align: center; text-decoration: none }
.doc > span:empty { display: none }
.doc-box {
  position: relative; width: 132px; height: 100px; border: 1.5px dashed var(--line-strong); border-radius: var(--r);
  display: grid; place-content: center; justify-items: center; gap: 4px; overflow: hidden;
  background: var(--soft); color: var(--muted); font-size: 13px; cursor: pointer;
}
.doc-box:hover { border-color: var(--brand); color: var(--navy) }
.doc-box svg { width: 22px; height: 22px }
.doc-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff }
.doc-box input { display: none }
.doc .img-x { z-index: 1 }

/* ช่องกรอกที่มีปุ่มอยู่ท้ายช่อง (ดึงข้อมูลจากเลขบัตร) */
.inp-act { position: relative } .inp-act .inp { padding-inline-end: 96px }
.inp-act button {
  position: absolute; inset-inline-end: 6px; top: 5px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px;
  background: var(--tint); color: var(--navy); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.inp-act button:hover { background: var(--pale) }
.inp-act button:disabled { opacity: .6; cursor: wait }
[data-found] .note:last-child { margin: 0 }
.inp-act button svg { width: 16px; height: 16px; display: block }
/* ช่องที่ระบบคิดให้ (เงินดาวน์จาก %) — สีจางแบบระบบเดิม */
.app-form .inp[readonly] { background: var(--soft); color: var(--body) }
.grid2 > .full, .grid3 > .full { grid-column: 1 / -1 }

/* คำนวณสินเชื่อ */
.calc { max-width: 720px }
.calc [data-out] { margin-top: 10px }
