/* REMAX Island · Follow-up — สีแบรนด์ REMAX (น้ำเงิน + แดงเล็กน้อย), พื้นเทาอ่อน การ์ดขาว, ธีมสว่าง/มืด */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f2f5fb;
  --field: #f4f6fb;
  --tint: #f7f9fe;
  --tint-line: #dfe6f3;
  --line: #e7ebf3;
  --line-2: #d3dae8;
  --ink: #0e1a35;
  --ink-2: #3b4763;
  --muted: #7a859e;
  --accent: #0046be;
  --accent-ink: #002f7f;
  --accent-soft: #e8effc;
  --primary: #003da5;
  --primary-ink: #ffffff;
  --primary-glow: rgba(0, 61, 165, .28);
  --brand-red: #dc1c2e;
  --brand-red-soft: #fdecee;
  --track: #e8edf5;
  --crit: #dc2626; --crit-soft: #fef2f2;
  --warn: #c2410c; --warn-soft: #fff7ed;
  --ok: #059669;
  --age-y: #a16207; --age-y-soft: #fef9c3; --age-o: #c2410c; --age-o-soft: #ffedd5; --age-r: #dc2626; --age-r-soft: #fee2e2;
  --overlay: rgba(14, 26, 53, .32);
  --shadow: 0 1px 2px rgba(14, 26, 53, .04), 0 8px 24px rgba(14, 26, 53, .05);
  --shadow-lg: 0 24px 56px rgba(14, 26, 53, .16), 0 2px 8px rgba(14, 26, 53, .06);
  --radius: 18px;
  --side-w: 232px;
  --content-w: 1440px;
  --font: "Poppins", "Kanit", "Leelawadee UI", "Noto Sans Thai", Tahoma, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #121a2b; --surface-2: #1a2438; --field: #172135; --tint: #121c30; --tint-line: #24324c; --line: #232f47; --line-2: #34435f;
    --ink: #edf2fb; --ink-2: #c3cde0; --muted: #8592ab; --accent: #6fa0ff; --accent-ink: #a9c6ff; --accent-soft: #16264a;
    --primary: #3b7bff; --primary-ink: #ffffff; --primary-glow: rgba(59, 123, 255, .35); --brand-red: #ff5a67; --brand-red-soft: #3a1820; --track: #232f47;
    --crit: #f87171; --crit-soft: #2c1517; --warn: #fb923c; --warn-soft: #2b1c10; --ok: #34d399;
    --age-y: #facc15; --age-y-soft: #2a2508; --age-o: #fb923c; --age-o-soft: #2f1a0b; --age-r: #f87171; --age-r-soft: #331416;
    --overlay: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #121a2b; --surface-2: #1a2438; --field: #172135; --tint: #121c30; --tint-line: #24324c; --line: #232f47; --line-2: #34435f;
    --ink: #edf2fb; --ink-2: #c3cde0; --muted: #8592ab; --accent: #6fa0ff; --accent-ink: #a9c6ff; --accent-soft: #16264a;
    --primary: #3b7bff; --primary-ink: #ffffff; --primary-glow: rgba(59, 123, 255, .35); --brand-red: #ff5a67; --brand-red-soft: #3a1820; --track: #232f47;
    --crit: #f87171; --crit-soft: #2c1517; --warn: #fb923c; --warn-soft: #2b1c10; --ok: #34d399;
    --age-y: #facc15; --age-y-soft: #2a2508; --age-o: #fb923c; --age-o-soft: #2f1a0b; --age-r: #f87171; --age-r-soft: #331416;
    --overlay: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 500; }
.code, .codelink { font-size: 12px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.dotc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .15s, opacity .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 8px 18px -8px var(--primary-glow); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface); box-shadow: var(--shadow); }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.block { width: 100%; height: 44px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ic { width: 17px; height: 17px; }
.linkbtn { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px 2px; color: var(--accent); cursor: pointer; font-weight: 500; font-size: 13px; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.linkbtn .ic { width: 14px; height: 14px; }
.danger-txt { color: var(--crit); }
.iconbtn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 0; background: none;
  color: var(--muted); cursor: pointer; flex: none; transition: background-color .15s, color .15s; }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }

/* fields */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
input, select, textarea { width: 100%; height: 42px; padding: 0 14px; border: 1px solid transparent; border-radius: 12px; background: var(--field);
  min-width: 0; transition: border-color .15s, box-shadow .15s, background-color .15s; }
textarea { height: auto; padding: 9px 12px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input[type=checkbox], input[type=radio] { width: auto; height: auto; }
.help { font-size: 12px; color: var(--muted); font-style: normal; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.switch input { appearance: none; -webkit-appearance: none; position: relative; width: 32px; height: 18px; border-radius: 99px; border: 0;
  background: var(--line-2); cursor: pointer; transition: background-color .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(14px); background: var(--primary-ink); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
.form-err { color: var(--crit); min-height: 1em; font-size: 13px; }
.form-err:empty { display: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* radio chips (สถานะย่อย) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; min-height: 34px; padding: 5px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; color: var(--ink-2); transition: background-color .12s, border-color .12s, color .12s; }
.chip:hover span { border-color: var(--line-2); }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented toggle (ภาษา) */
.controls { display: flex; align-items: center; gap: 6px; }
.seg-toggle { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--surface-2); flex: none; }
.seg-toggle button { border: 0; background: none; padding: 4px 9px; border-radius: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; font-weight: 500; }
.seg-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }

/* logo */
.logo { position: relative; overflow: hidden; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--primary); color: #fff; font: 600 12px/1 var(--font); letter-spacing: .04em; box-shadow: 0 8px 16px -8px var(--primary-glow); }
.logo::after { content: ""; position: absolute; right: 6px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-red); box-shadow: 0 0 0 2px var(--primary); }
.logo.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 15px; }
.logo.lg::after { width: 8px; height: 8px; right: 8px; top: 8px; }

/* login */
.login-wrap { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 72px 16px 32px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--brand-red) 8%, transparent), transparent 60%), var(--bg); }
.login-top { position: absolute; top: 16px; right: 16px; }
.login { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { font-size: 24px; letter-spacing: -.02em; }
.login-card { background: var(--surface); border-radius: 22px; padding: 26px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-lg); }
.demo-pick { display: flex; flex-direction: column; gap: 10px; }
.demo-pick p { font-size: 13px; color: var(--muted); }
.demo-roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* demo bar */
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 14px 28px 0; padding: 8px 14px; border-radius: 12px; font-size: 12.5px;
  background: var(--warn-soft); color: var(--ink-2); }
.demo-tag { font-weight: 600; color: var(--warn); }
.demo-bar select { width: auto; height: 30px; font-size: 12.5px; padding: 0 28px 0 10px; background-color: var(--surface); }

/* โครงหน้า: แถบเมนูซ้าย (คอม) · แถบบน · แถบเมนูล่าง (มือถือ) */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; width: var(--side-w); flex: none; display: flex; flex-direction: column; gap: 6px; overflow-y: auto;
  padding: 22px 16px 18px; background: var(--surface); border-right: 1px solid var(--line); }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 18px; }
.side-brand > div strong { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.side-label { padding: 12px 12px 4px; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: .03em; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
/* เส้นกั้นกลุ่มเมนู (Main Menu | Report Menu | ผู้ดูแลระบบ) — แสดงแม้แถบซ้ายเหลือแต่ไอคอน */
.side-sep { align-self: stretch; height: 0; margin: 10px 8px 0; border: 0; border-top: 1px solid var(--line); }
.side-nav button { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: none;
  color: var(--ink-2); font-weight: 500; cursor: pointer; text-align: left; transition: background-color .15s, color .15s; }
.side-nav button .ic { width: 19px; height: 19px; color: var(--muted); transition: color .15s; }
.side-nav button:hover { background: var(--surface-2); color: var(--ink); }
.side-nav button[aria-current="page"] { background: var(--primary); color: var(--primary-ink); box-shadow: 0 10px 20px -10px var(--primary-glow); }
.side-nav button[aria-current="page"] .ic { color: var(--primary-ink); }
.side-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.side-foot b { display: block; color: var(--ink-2); font-weight: 500; font-size: 12.5px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* คอลัมน์เนื้อหา: กว้างไม่เกิน --content-w และอยู่กลางพื้นที่ที่เหลือจากแถบซ้าย */
.content-in { width: 100%; max-width: var(--content-w); margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 28px; padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px); }
.top-brand { display: none; }
.greet { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.greet strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.greet span { font-size: 12.5px; color: var(--muted); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-right .seg-toggle { background: var(--surface); box-shadow: var(--shadow); }
.top-right .iconbtn { background: var(--surface); box-shadow: var(--shadow); }
/* เมนูย่อย (Followup: งาน / ความเคลื่อนไหว · รายงาน: Leads / ดีล) */
.subnav { display: flex; gap: 4px; width: fit-content; max-width: calc(100% - 56px); margin: 4px 28px 0; padding: 4px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav button { border: 0; background: none; padding: 7px 16px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: .15s; }
.subnav button:hover { color: var(--ink); }
.subnav button[aria-current="page"] { color: var(--primary-ink); background: var(--primary); }
.bottom-nav { display: none; }
.usermenu { position: relative; margin-left: 4px; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 14px; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink);
  font-weight: 600; font-size: 13px; flex: none; }
.who { display: flex; flex-direction: column; line-height: 1.25; }
.who strong { font-size: 13px; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 11.5px; color: var(--muted); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; z-index: 30; animation: pop .15s ease-out; }
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu button { display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.menu button .ic { width: 16px; height: 16px; color: var(--muted); }
.menu button:hover { background: var(--surface-2); }
.role-pill { display: inline-flex; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.role-pill.r-ceo { background: var(--primary); color: var(--primary-ink); }
.role-pill.r-admin { background: var(--accent-soft); color: var(--accent); }

/* main */
.main { width: 100%; padding: 22px 28px 72px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; }

/* การ์ดตัวเลขสรุป (กดเพื่อกรอง) · ปุ่ม "สรุป" เปิด / ซ่อน (ซ่อน = แถวตัวเลขย่อบรรทัดเดียว) */
.stats-wrap { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.stats-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stats-wrap[data-open="true"] .stats-bar { justify-content: flex-end; }
.stats-tg { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.stats-tg:hover { border-color: var(--primary); color: var(--primary); }
.stats-tg .ic { width: 16px; height: 16px; }
.stats-tg .ic:last-child { transition: transform .15s; }
.stats-wrap[data-open="true"] .stats-tg .ic:last-child { transform: rotate(180deg); }
.stats-mini { display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.stats-mini::-webkit-scrollbar { display: none; }
.stats-wrap[data-open="true"] .stats-mini, .stats-wrap[data-open="false"] .stats { display: none; }
.sm-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font: inherit; font-size: 12.5px; white-space: nowrap; }
.sm-chip b { color: var(--ink); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
button.sm-chip { cursor: pointer; }
button.sm-chip.on { border-color: var(--primary); color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stats-foot { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.stats-foot .ic { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.stat { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 18px; border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: inherit; text-align: left; font: inherit; overflow: hidden; min-width: 0; }
button.stat { cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
button.stat:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -12px rgba(14, 26, 53, .18); }
button.stat.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.st-ic { width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); }
.st-ic .ic { width: 21px; height: 21px; stroke-width: 2; }
.st-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.st-label { font-size: 12.5px; color: var(--muted); font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.st-val { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; color: var(--ink); font-variant-numeric: tabular-nums; }
.st-note { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.st-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 26px; flex: none; }   /* แถวเดียวกับตัวเลข (ชิดขวา) · ไม่ทับชื่อการ์ดหรือข้อความรอง */
.spark i { display: block; width: 5px; border-radius: 3px; background: color-mix(in srgb, var(--tone) 30%, transparent); }
.spark i:last-child { background: var(--tone); }
.tone-blue { --tone: var(--primary); --tone-soft: var(--accent-soft); }
.tone-teal { --tone: #0d9488; --tone-soft: color-mix(in srgb, #0d9488 13%, var(--surface)); }
.tone-amber { --tone: #d97706; --tone-soft: color-mix(in srgb, #d97706 14%, var(--surface)); }
.tone-red { --tone: var(--brand-red); --tone-soft: var(--brand-red-soft); }
.tone-green { --tone: #16a34a; --tone-soft: color-mix(in srgb, #16a34a 13%, var(--surface)); }
.tone-violet { --tone: #6d4bd8; --tone-soft: color-mix(in srgb, #6d4bd8 13%, var(--surface)); }

/* รูปย่อชื่อลูกค้า (อักษรย่อ + สีตามชื่อ) */
.who-cell { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.who-txt { display: flex; flex-direction: column; min-width: 0; }
.av { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  font-family: "Poppins", "Noto Sans Thai Looped", "Leelawadee UI", Tahoma, sans-serif;
  background: var(--av-bg); color: var(--av-ink); }
.av.lg { width: 52px; height: 52px; border-radius: 16px; font-size: 18px; }
.av-0 { --av-bg: #e6edfb; --av-ink: #003da5; }
.av-1 { --av-bg: #fde8ea; --av-ink: #b4182a; }
.av-2 { --av-bg: #dff5ef; --av-ink: #0f766e; }
.av-3 { --av-bg: #fdf0d9; --av-ink: #a35a00; }
.av-4 { --av-bg: #ece7fb; --av-ink: #5b3cc4; }
.av-5 { --av-bg: #e3f2fd; --av-ink: #0369a1; }
:root[data-theme="dark"] .av { background: color-mix(in srgb, var(--av-ink) 26%, var(--surface)); color: color-mix(in srgb, var(--av-ink) 35%, #fff); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .av { background: color-mix(in srgb, var(--av-ink) 26%, var(--surface)); color: color-mix(in srgb, var(--av-ink) 35%, #fff); } }
.hero-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hero-row h2 { min-width: 0; }

/* stage filter pills */

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 360px; }
.search .ic { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.filters select { width: auto; }
.toolbar input, .toolbar select, .dash-panel select { background-color: var(--surface); box-shadow: var(--shadow); }
.drawer input, .drawer select, .drawer textarea { background-color: var(--surface); border-color: var(--line); }
.price-q { display: inline-flex; align-items: center; gap: 6px; }
.price-q input { width: 250px; }
.price-note { margin: 10px 0 0; }

/* tables */
.table-wrap { background: var(--surface); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }   /* จอแคบ: เลื่อนซ้าย-ขวาในกรอบ ไม่ตัดคอลัมน์ท้าย */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 15px 18px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; letter-spacing: .02em; }
td { padding: 15px 18px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; }
table.deals tbody tr { cursor: pointer; transition: background-color .12s; }
table.deals tbody tr:hover, table.deals tbody tr:focus-visible { background: var(--tint); outline: none; }
tr.closed td { opacity: .5; }
td strong { display: block; font-weight: 600; }
td .small { display: block; }
.meta { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.meta .code { font-size: 11.5px; }
td.client, td.seller, td.agent { color: var(--ink-2); }
td.agent { white-space: nowrap; }
td.next { max-width: 260px; font-size: 13px; color: var(--ink-2); }
.next-txt { display: block; }
.due { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.due.late { color: var(--crit); font-weight: 500; }
.due.today { color: var(--warn); font-weight: 500; }
.meta.next-meta { margin-top: 4px; }
td.upd { white-space: nowrap; font-size: 12.5px; color: var(--muted); }
td.upd.stale { color: var(--warn); font-weight: 500; }
td.actions { white-space: nowrap; }
td.actions .linkbtn + .linkbtn { margin-left: 12px; }
.state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.state.on { color: var(--ink-2); }
.state.on .dot { background: var(--ok); }

.status { display: flex; flex-direction: column; gap: 2px; }
.st-main { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; }
.st-sub { font-size: 12.5px; color: var(--muted); padding-left: 15px; }
.empty { padding: 56px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface); }

/* drawer: รายละเอียดงาน */
.drawer-back { position: fixed; inset: 0; background: var(--overlay); z-index: 40; animation: fade .2s ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 41; background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); animation: slide-in .24s cubic-bezier(.2, .8, .2, 1); }
.dr-bar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.dr-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--c); }
.dr-ids { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.id-chip { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-2); padding: 3px 8px; border-radius: 6px; }
.dr-body { flex: 1; overflow-y: auto; padding: 22px 22px calc(40px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }

.dr-hero { display: flex; flex-direction: column; gap: 8px; padding-bottom: 2px; }
.dr-hero h2 { font-size: 24px; line-height: 1.2; letter-spacing: -.02em; overflow-wrap: anywhere; }
.dr-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13.5px; }
.dr-facts span { display: inline-flex; align-items: center; gap: 6px; }
.dr-facts .ic { width: 16px; height: 16px; }
.dr-price { font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* การ์ดสถานะ */
.status-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 24%, var(--line)); }
.sc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.sc-step { font-weight: 600; color: color-mix(in srgb, var(--c) 70%, var(--ink)); }
.sc-days { color: var(--muted); }
.sc-badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: color-mix(in srgb, var(--c) 70%, var(--ink)); }
.sc-badge .ic { width: 15px; height: 15px; stroke-width: 2.4; }
.sc-stage { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.sc-stage .dot { width: 10px; height: 10px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.sc-sub { color: var(--ink-2); padding-left: 20px; }
.sc-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.sc-steps li { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.sc-steps i { display: block; width: 100%; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 9%, transparent); }
.sc-steps span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sc-steps .done i { background: color-mix(in srgb, var(--c) 50%, transparent); }
.sc-steps .now i { background: var(--c); }
.sc-steps .now span { color: var(--ink); font-weight: 700; }
.status-card.branch .sc-steps { opacity: .45; }

/* การ์ดขั้นต่อไป */
.next-card { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.date-tile { width: 54px; height: 58px; flex: none; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface-2); line-height: 1.1; }
.date-tile b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.date-tile span { font-size: 12px; color: var(--muted); }
.date-tile.empty { color: var(--muted); }
.next-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.next-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.next-when { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.due-chip { font-weight: 600; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.due-chip.late { background: var(--crit); color: #fff; }
.next-card.late { border-color: color-mix(in srgb, var(--crit) 35%, var(--line)); background: var(--crit-soft); }
.next-card.late .date-tile { background: var(--crit); color: #fff; }
.next-card.late .date-tile span { color: rgba(255, 255, 255, .85); }

/* ฟอร์มอัปเดต และหัวข้อ */
.panel { border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); }
.panel-head, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 26px; }
.panel h3, .section h3 { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.panel h3 .ic { width: 16px; height: 16px; color: var(--muted); }
.section { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.tag { font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 2px 9px; border-radius: 99px; }

/* ผู้เกี่ยวข้อง */
.tiles { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.tile { display: flex; gap: 14px; align-items: center; padding: 14px 16px; min-width: 0; }
.tile + .tile { border-top: 1px solid var(--line); }
.tile-ic { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.tile-ic .ic { width: 17px; height: 17px; }
.tile-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 600; font-size: 14px; }
.tile-ic:has(.tile-avatar) { background: none; }
.tile-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-body strong { font-weight: 600; overflow-wrap: anywhere; }
.tile-sub { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.tile-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--accent); text-decoration: none; margin-top: 2px; overflow-wrap: anywhere; }
.tile-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.tile-link .ic { width: 13px; height: 13px; }
.notes-box { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); color: var(--ink-2); }
.notes-box > .ic { color: var(--muted); margin-top: 2px; }
.notes-box p { margin-top: 2px; overflow-wrap: anywhere; }

.kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ประวัติ */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 18px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 4px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-avatar { position: relative; width: 31px; height: 31px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.tl-avatar::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 2px solid var(--bg); }
.tl-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-top: 5px; }
.tl-main { font-size: 13.5px; }
.chg-list { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; overflow-wrap: anywhere; }
.chg-list s { color: var(--muted); }
.tl-note { font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: 7px 11px;
  white-space: pre-wrap; color: var(--ink-2); width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-meta strong { font-weight: 500; color: var(--ink-2); }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }

/* วันสำคัญ + ค่าคอมมิชชั่น */
.dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.date-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.date-tile.sm { width: 44px; height: 48px; border-radius: 10px; }
.date-tile.sm b { font-size: 17px; }
.date-tile.sm span { font-size: 11px; }
.comm-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.comm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.comm-rows { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.comm-rows div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.comm-rows dt { color: var(--muted); font-size: 13px; }
.comm-rows dd { margin: 0; font-weight: 500; }
.comm-rows .total { padding-top: 8px; margin-top: 2px; border-top: 1px dashed var(--line-2); }
.comm-rows .total dt { color: var(--ink); font-weight: 600; }
.comm-rows .total dd { font-weight: 700; font-size: 15px; }
.comm-preview:empty { display: none; }
.comm-preview { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.form-sec { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.modal-head + .form-sec { margin-top: 0; padding-top: 0; border-top: 0; }
input[data-money] { font-variant-numeric: tabular-nums; }

.comm-note { margin: 8px 0 0; font-size: 13.5px; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }

/* เลือก Agent: แถวละคน */
.agent-rows { display: flex; flex-direction: column; gap: 8px; }
.agent-row { display: flex; align-items: center; gap: 6px; }
.agent-row input { flex: 1; }
.add-agent { align-self: flex-start; margin-top: 2px; }
.add-agent .ic { width: 15px; height: 15px; }

/* ช่องติ๊ก (ค่าคอม / ประเภทสัญญา) */
.ticks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tick { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-size: 13.5px; color: var(--ink-2); transition: border-color .12s, background-color .12s; min-width: 0; }
.tick:hover { border-color: var(--line-2); }
.tick input[type=checkbox] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--primary); cursor: pointer; }
.tick:has(input[type=checkbox]:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); color: var(--ink); }
.tick.other { grid-column: 1 / -1; }
.tick.other span { flex: none; }
.tick.other input[type=text] { flex: 1; height: 30px; min-width: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag.strong { color: var(--ink); background: var(--surface-2); font-weight: 500; padding: 3px 10px; }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.feed-item { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.feed-prop { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.codelink { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
.codelink:hover { text-decoration: underline; text-underline-offset: 3px; }

/* สรุปรวม (CEO + Admin) */
.dash-panel { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.fnote { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.fchip { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 12.5px; }
.pillbars { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.pillbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pillbar > .lbl { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.pill { display: inline-flex; align-items: center; justify-content: center; height: 38px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.pill:hover { border-color: var(--line-2); color: var(--ink); }
.pill.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
select.pill-select { width: auto; min-width: 150px; height: 38px; font-size: 13.5px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding: 18px 18px 16px 22px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.kpi::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(180deg, var(--c1), var(--c2)); }
.kpi > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi > b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi > small { font-size: 12px; color: var(--muted); }

.dash-sec { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.sec-head { display: flex; align-items: flex-start; gap: 14px; }
.sec-num { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 600; font-size: 15px; box-shadow: 0 8px 16px -8px var(--primary-glow); }
.sec-head h2 { font-size: 20px; }
.sec-head p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.chart-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 28px; align-items: start; }
.donut-wrap { display: flex; flex-direction: column; gap: 18px; }
.donut { display: block; width: 100%; max-width: 260px; margin: 6px auto 0; }
.donut path, .donut circle { fill: none; stroke-width: 30; }
.dn-big { font: 700 19px var(--font); fill: var(--ink); }
.dn-sub { font: 600 10px var(--font); fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.legend li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 58px; align-items: center; gap: 10px; padding: 5px 6px; font-size: 13.5px; }
.legend .sw { width: 13px; height: 13px; border-radius: 3px; background: var(--c2); }
.legend .nm { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.legend .pc { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars-title { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.bars { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 18px; }
.bars .nm { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .nm small { color: var(--muted); font-size: 12px; }
.bars .val { text-align: right; font-weight: 700; font-size: 14.5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.bars .track { height: 9px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bars .fill { display: block; height: 100%; min-width: 7px; border-radius: 99px; background: linear-gradient(90deg, var(--c1), var(--c2)); }
.bars .meta { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dash-empty { padding: 36px 12px; text-align: center; color: var(--muted); }

/* modal */
.modal-back { position: fixed; inset: 0; background: var(--overlay); z-index: 60; display: grid; place-items: center; padding: 16px; overflow-y: auto; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 620px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 24px; animation: pop .18s ease-out; }
.modal form { display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: -4px -6px 2px 0; }
.modal-head h2 { font-size: 19px; }
.modal .kv dd { font-size: 13px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: 14px; font-weight: 500; font-size: 13.5px; z-index: 80;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--crit); color: #fff; }
.toast.has-act { display: flex; align-items: center; gap: 14px; width: max-content; }
.toast.has-act.show { pointer-events: auto; }
.toast-act { flex: none; background: none; border: 1px solid currentColor; color: inherit; font: inherit; font-weight: 600; border-radius: 10px; padding: 5px 12px; cursor: pointer; }
.toast-act:hover { background: color-mix(in srgb, currentColor 14%, transparent); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } }

/* Track: รายการ lead */
.pill-n { margin-left: 8px; font-weight: 600; opacity: .65; font-variant-numeric: tabular-nums; }
table.leads tbody tr { cursor: pointer; transition: background-color .12s; }
table.leads tbody tr:hover, table.leads tbody tr:focus-visible { background: var(--tint); outline: none; }
table.leads tr.done td { opacity: .62; }
table.deals td.prop { min-width: 210px; }
/* ลิงก์ทรัพย์ */
.links-row { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 5px; }
.ext-link { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 24px; padding: 0 9px; border-radius: 8px; font-size: 12px; font-weight: 500;
  color: var(--accent); background: var(--accent-soft); text-decoration: none; overflow: hidden; }
.ext-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext-link .ic { width: 13px; height: 13px; flex: none; }
.ext-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.kv.wide { grid-column: 1 / -1; }
table.leads td.want { max-width: 300px; font-size: 13px; color: var(--ink-2); }
table.leads td.agent, table.leads td.src { font-size: 13px; color: var(--ink-2); }
table.leads td.agent { white-space: nowrap; }
table.leads td.st .meta { margin-top: 3px; }
td.age-cell { white-space: nowrap; }
.age { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-2); }
.age-y { color: var(--age-y); background: var(--age-y-soft); }
.age-o { color: var(--age-o); background: var(--age-o-soft); }
.age-r { color: var(--age-r); background: var(--age-r-soft); }
.age-owner { color: var(--primary); background: var(--accent-soft); }
/* CRM: ที่มาของลูกค้า (migration 029) */
.age-lead { color: #0e7490; background: color-mix(in srgb, #0891b2 14%, transparent); }
.age-deal { color: #6d28d9; background: color-mix(in srgb, #7c3aed 14%, transparent); }
/* CRM: ทั้งสองฝั่ง (ผู้ซื้อ / ผู้เช่า + เจ้าของทรัพย์) · New 2026-10-16 */
.age-both { color: #b45309; background: color-mix(in srgb, #f59e0b 18%, transparent); }
.id-chip.both { color: #b45309; background: color-mix(in srgb, #f59e0b 18%, transparent); }
.pill-note { margin-left: 4px; }
.side-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 -4px; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; }
.side-title svg { width: 16px; height: 16px; }
.side-none { margin: 6px 0 0; }
.link-n { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.link-n .ic { width: 13px; height: 13px; }
.age-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; background: var(--muted); }
.age-dot.age-y { background: var(--age-y); } .age-dot.age-o { background: var(--age-o); } .age-dot.age-r { background: var(--age-r); }
.lstatus { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.lstatus .dot { background: var(--c, var(--muted)); }
.ls-new { --c: #0ea5e9; } .ls-assigned { --c: #6366f1; } .ls-in_progress { --c: #f59e0b; } .ls-viewing { --c: #ea580c; } .ls-reserved { --c: #16a34a; } .ls-closed { --c: #0f766e; } .ls-lost { --c: #94a3b8; }
/* ทรัพย์ฝาก (migration 013) */
.lst-available { --c: #16a34a; } .lst-reserved { --c: #6366f1; } .lst-sold { --c: #0d9488; } .lst-rented { --c: #0ea5e9; } .lst-withdrawn { --c: #94a3b8; } .lst-not_listed { --c: #94a3b8; }
table.listings tbody tr { cursor: pointer; transition: background-color .12s; }
table.listings tbody tr:hover, table.listings tbody tr:focus-visible { background: var(--tint); outline: none; }
table.listings tr.done td { opacity: .55; }
table.listings td.prop { min-width: 210px; }
table.listings td.lprice { white-space: nowrap; font-weight: 500; font-variant-numeric: tabular-nums; }
table.listings td.seller, table.listings td.agent { font-size: 13px; }
table.listings td.st .meta { margin-top: 3px; }
/* ขั้นตอนรับทรัพย์ (migration 015) */
.tag.lprog { color: var(--accent-ink); background: var(--accent-soft); white-space: nowrap; }
.tag.lprog.done { color: var(--muted); background: var(--surface-2); }
.lprog-bar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 2px 0; }
.lprog-bar i { height: 6px; border-radius: 99px; background: var(--surface-2); }
.lprog-bar i.on { background: var(--accent); }
/* Agent Recruitment (migration 018): แถบ 6 ขั้น · ไม่ผ่าน / ถอนตัว = สีเทา */
.lprog-bar.r5 { grid-template-columns: repeat(5, 1fr); }
.lprog-bar.off i.on { background: var(--muted); }
.tag.rclosed { color: var(--muted); background: var(--surface-2); text-decoration: none; }
.tag.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
/* กดเลือกขั้น 1–5 (New 2026-10-18): ขั้นที่ทำแล้วมีเครื่องหมายถูก · ขั้นถัดไปขอบสีหลัก */
.rstep-pick { margin-top: 8px; }
.rsteps { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.rstep { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 5px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; transition: border-color .12s, background-color .12s; }
.rstep:hover { border-color: var(--line-2); }
.rstep:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rstep.on { color: var(--ink-2); font-weight: 500; }
.rstep.next { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.rstep svg { width: 14px; height: 14px; color: var(--ok); }
.step-no { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; border-radius: 99px; font-size: 12px; background: var(--accent-soft); color: var(--accent-ink); }
.mini.rround, .mini-list > div.mini { cursor: default; }
.mini-acts { margin-left: auto; display: inline-flex; gap: 12px; }
/* Agent Recruitment: คอร์สอบรม = พิมพ์ชื่อ + วันที่ + บันทึก ในแถวเดียว */
.course-add { display: grid; grid-template-columns: minmax(0, 1fr) 170px auto; gap: 8px; align-items: end; margin-bottom: 10px; }
.course-add .btn { white-space: nowrap; }
/* Kick Start Training (2026-10-21): ปุ่มชื่อคอร์สสำเร็จรูป + 11 หัวข้อใต้คอร์สที่บันทึกแล้ว */
.rc-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -2px 0 12px; }
.rc-quick .qbtn { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.rc-quick .qbtn:hover { border-color: var(--primary); color: var(--primary); }
.rc-quick .qbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ks-topics { margin-top: 8px; }
.ks-list { margin: 0 0 10px; padding-left: 22px; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.list-row.lang-row { grid-template-columns: 90px 1fr auto; }
table.recruits tbody tr { cursor: pointer; transition: background-color .12s; }
table.recruits tbody tr:hover, table.recruits tbody tr:focus-visible { background: var(--tint); outline: none; }
table.recruits tr.done td { opacity: .55; }
table.recruits td.cust { min-width: 220px; }
table.recruits td.contact { font-size: 13px; color: var(--ink-2); }
table.recruits td.contact .line { display: block; overflow-wrap: anywhere; }
table.recruits td.st { min-width: 170px; }
table.recruits td.st .lprog-bar { margin-top: 6px; max-width: 180px; }
table.recruits td.src { font-size: 13px; }
table.recruits td.src .meta { display: block; }
.meta.warn-txt, .warn-txt { color: var(--warn); font-weight: 500; }
.tag.warn { color: var(--warn); background: var(--warn-soft); }

/* Track: ฟอร์ม */
.chips.big .chip span { min-height: 38px; padding: 6px 18px; font-size: 14px; font-weight: 600; }
.form-block { display: flex; flex-direction: column; gap: 14px; }
.more { border: 1px dashed var(--line-2); border-radius: 12px; padding: 0 12px; }
.more summary { cursor: pointer; padding: 10px 0; font-size: 13px; color: var(--accent); font-weight: 500; }
.more[open] { padding-bottom: 12px; }
.dup { border: 1px solid var(--age-y); background: var(--age-y-soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.dup.picked { border-color: var(--accent); background: var(--accent-soft); }
.dup-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.dup-head .ic { width: 16px; height: 16px; }
.dup-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent); }
.dup-head + .dup-item { border-top: 0; padding-top: 0; }
.dup-who { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.dup-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.dup-ok { padding-top: 8px; border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent); white-space: normal; font-weight: 600; color: var(--ink); }
/* ช่องเลือกที่พิมพ์ค้นหาได้ (combobox) */
.combo { position: relative; flex: 1; min-width: 0; }
.combo-in { padding-right: 38px; }
.combo-btn { position: absolute; right: 2px; top: 2px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted);
  cursor: pointer; display: grid; place-items: center; border-radius: 10px; }
.combo-btn:hover { color: var(--ink); }
.combo-btn .ic { width: 16px; height: 16px; }
.combo-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow: auto; margin: 0; padding: 4px;
  list-style: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-lg); }
.combo-list li { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; line-height: 1.35; }
.combo-list li small { color: var(--muted); font-size: 12px; }
.combo-list li.on, .combo-list li[data-combo-pick]:hover { background: var(--accent-soft); }
.combo-list li[aria-selected="true"] > span { font-weight: 600; color: var(--accent-ink); }
.combo-list .combo-empty { color: var(--muted); cursor: default; font-size: 12.5px; }
.missing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  border: 1px dashed var(--age-o); background: var(--age-o-soft); color: var(--ink); }
.missing .ic { width: 16px; height: 16px; color: var(--age-o); }
.load-err { margin: 0 0 14px; }

/* ยืนยันการลบ */
.danger-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--crit); background: var(--crit-soft); color: var(--ink); }
.danger-box > .ic { color: var(--crit); width: 18px; height: 18px; margin-top: 2px; }
.danger-box > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 13px; }
.danger-box strong { overflow-wrap: anywhere; }
.danger-box p { color: var(--ink-2); }
.del-list { margin: 4px 0; padding-left: 18px; }
.confirm-del input { border-color: var(--crit); }
.msg-box { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font: 13px/1.6 var(--font);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; }
.list-ed { display: flex; flex-direction: column; gap: 6px; }
.list-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }

/* Track: รายละเอียด lead */
.cbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
a.cbtn:hover { border-color: var(--accent); color: var(--accent); }
.cbtn .ic { width: 15px; height: 15px; }
.cbtn.wa { border-color: #25d366; color: #128c4b; }
.cbtn.line { border-color: #06c755; color: #05893b; }
.cbtn.plain { color: var(--ink-2); }
/* ส่งข้อความให้ Agent: WhatsApp · LINE · Messenger · คัดลอก (migration 029) */
.share-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.btn.share { justify-content: center; text-decoration: none; }
.btn.share.wa { border-color: #25d366; color: #128c4b; }
.btn.share.line { border-color: #06c755; color: #05893b; }
.btn.share.fb { border-color: #0866ff; color: #0866ff; }
@media (max-width: 520px) { .share-row { grid-template-columns: 1fr 1fr; } }
.lead-state { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.lead-state-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.lead-state-top .lstatus { font-size: 15px; font-weight: 600; }
.lead-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.facts:empty { display: none; }
.application-answers .kv { min-width: 0; }
.application-answers dd { overflow-wrap: anywhere; }
.note-add { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* CRM: รายชื่อลูกค้า */
table.customers tbody tr { cursor: pointer; transition: background-color .12s; }
table.customers tbody tr:hover, table.customers tbody tr:focus-visible { background: var(--tint); outline: none; }
table.customers td.cust .age { height: 20px; font-size: 11px; }
.tags-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tags-row:empty { display: none; }
table.customers td.contact { font-size: 13px; color: var(--ink-2); }
table.customers td.contact .line { display: block; overflow-wrap: anywhere; }
table.customers td.lds .meta { margin-top: 3px; }
table.customers td.agent { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
table.customers td.bud { font-size: 13px; white-space: nowrap; }

/* CRM: หน้าลูกค้า */
.mini-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.mini { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 12px 14px; background: none; border: 0; cursor: pointer; color: inherit; }
.mini + .mini { border-top: 1px solid var(--line); }
.mini:hover { background: var(--surface-2); }
.mini-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.mini-sub { font-size: 13px; color: var(--ink-2); }
.mini-sub.muted { color: var(--muted); font-size: 12.5px; }
.mini .status { flex-direction: row; flex-wrap: wrap; gap: 4px 8px; }
.mini .st-sub { padding-left: 0; }
.history { border-style: solid; border-color: var(--line); background: var(--surface); }
.history .timeline { margin-top: 4px; }
.mg-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow: auto; }
.mg-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.mg-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mg-item input { margin-top: 3px; accent-color: var(--primary); }
.mg-item > span { display: flex; flex-direction: column; min-width: 0; }

/* รายงาน Leads */
.rep-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.rep-table th, .rep-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rep-table th { font-size: 12px; }
.rep-table td.num { font-variant-numeric: tabular-nums; color: var(--ink); }
.rep-table tfoot td { color: var(--ink-2); background: var(--surface-2); }
.rep-table tfoot tr.sum td { font-weight: 600; color: var(--ink); }
.rep-table td.bar-cell { min-width: 170px; }
.bar-cell, .rep-bars li { display: flex; align-items: center; gap: 8px; }
.rbar { flex: 1; min-width: 60px; height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.rbar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.rnum { min-width: 46px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.rep-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rep-bars .nm { flex: 0 0 40%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rep-bars .pc { min-width: 48px; text-align: right; font-size: 12px; color: var(--muted); }
.age-stack { display: flex; gap: 2px; height: 14px; border-radius: 99px; overflow: hidden; background: var(--track); }
.age-stack .seg { display: block; min-width: 4px; background: var(--muted); }
.age-stack .seg.age-n { background: var(--line-2); }
.age-stack .seg.age-y { background: var(--age-y); } .age-stack .seg.age-o { background: var(--age-o); } .age-stack .seg.age-r { background: var(--age-r); }
.age-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; }
.age-legend li { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.age-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.age-legend .pc { min-width: 48px; text-align: right; font-size: 12px; color: var(--muted); }
.age-dot.age-n { background: var(--line-2); }
.facts.plain { border: 0; padding: 0; background: none; }

/* การ์ดในลิ้นชักรายละเอียด: พื้นขาว เงาบาง แทนเส้นขอบ */
.panel, .tiles, .facts, .mini-list, .lead-state, .next-card, .date-row, .comm-card, .feed, .history { border-color: transparent; box-shadow: var(--shadow); }
.facts.plain { box-shadow: none; }
.dr-bar { border-bottom-color: transparent; box-shadow: 0 1px 0 var(--line); }

/* นำเข้า CSV */
.row-start { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.imp-cols { overflow-wrap: anywhere; margin-bottom: 6px; }
.imp-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; }
.imp-sum strong { overflow-wrap: anywhere; }
.ok-txt { color: var(--ok); font-weight: 600; }
.imp-list { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow: auto; margin-top: 10px; }
.imp-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.imp-row.bad { border-color: var(--age-r); background: var(--age-r-soft); cursor: default; }
.imp-row input { margin-top: 3px; accent-color: var(--primary); }
.imp-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 13px; }
.imp-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.imp-dup { color: var(--accent); font-size: 12.5px; }
.imp-err { color: var(--age-r); font-size: 12.5px; font-weight: 500; }
.imp-warn { color: var(--age-y); font-size: 12.5px; }

/* ตารางสมส่วน (คอม / แท็บเล็ต) */
@media (min-width: 761px) {
  table.deals, table.leads, table.customers, table.listings, table.recruits { table-layout: fixed; }
  table.deals { min-width: 1020px; } table.customers, table.listings { min-width: 940px; } table.leads { min-width: 860px; } table.recruits { min-width: 820px; }
  th.c-upd { width: 100px; } table.leads th.c-upd { width: 78px; }
  table.deals th.c-person { width: 11.5%; } table.deals th.c-st { width: 15%; } table.deals th.c-next { width: 16%; }
  /* ช่องทางที่มา 15%: คำยาว เช่น Facebook Marketplace ไม่ถูกตัดกลางคำบนจอ 1024px · ตัดคำเฉพาะคำที่ยาวเกินช่อง (break-word) */
  th.c-person { width: 14%; } th.c-src { width: 15%; } th.c-price { width: 13%; } th.c-bud { width: 14%; }
  th.c-st { width: 17%; } th.c-next { width: 17%; } th.c-want { width: 20%; } th.c-lds { width: 15%; }
  th.c-contact { width: 21%; } th.c-step { width: 22%; }
  table.listings th.c-st { width: 24%; } table.listings th.c-price { width: 12%; }
  /* CRM แยกฝั่ง: เหลือที่ให้ชื่อลูกค้า */
  table.customers.side-buyer th.c-contact { width: 16%; } table.customers.side-buyer th.c-bud { width: 12%; } table.customers.side-buyer th.c-want { width: 16%; }
  table.customers.side-buyer th.c-lds { width: 13%; } table.customers.side-buyer th.c-person { width: 11%; }
  table.customers.side-owner th.c-contact { width: 17%; } table.customers.side-owner th.c-want { width: 18%; } table.customers.side-owner th.c-price { width: 12%; }
  table.customers.side-owner th.c-st { width: 12%; } table.customers.side-owner th.c-person { width: 12%; }
  table.customers td.price { font-size: 13px; white-space: nowrap; } table.customers td.want .meta { margin-top: 3px; }
  /* ชื่อคน · สิ่งที่ต้องทำต่อ · ความต้องการ: ไม่เกิน 2 บรรทัด (เต็มอยู่ในหน้ารายละเอียด) */
  :is(table.deals, table.leads, table.customers, table.listings, table.recruits) td { overflow-wrap: break-word; }
  td.agent, table.leads td.agent, table.customers td.agent { white-space: normal; }
  .clamp2, td.next .next-txt, table.leads td.want > span:first-child { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  /* Buyer Leads กระชับ (CEO 2026-10-12): นัดหมายในช่องสถานะ 1 บรรทัด · วันที่ไม่ตัดบรรทัด */
  table.leads td.st .next-meta .next-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  table.leads td.st .next-meta .due { white-space: nowrap; }
  table.leads td { padding-top: 10px; padding-bottom: 10px; }
  td .meta { overflow-wrap: break-word; }
  td.st .st-main { white-space: normal; align-items: baseline; }
  td.st .st-main .dot { flex: none; transform: translateY(-1px); }
  td.upd, td.age-cell { white-space: nowrap; }
}

/* แท็บเล็ต */
@media (max-width: 1023px) and (min-width: 761px) {
  :root { --side-w: 76px; }
  .side { padding: 22px 12px 18px; align-items: center; }
  .side-brand { padding: 0 0 18px; }
  .side-brand > div, .side-label, .side-foot { display: none; }
  .side-nav button { width: 48px; height: 48px; padding: 0; justify-content: center; }
  .side-nav button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar, .main { padding-left: 22px; padding-right: 22px; }
  .demo-bar, .subnav { margin-left: 22px; margin-right: 22px; }
}

/* mobile */
@media (max-width: 760px) {
  .side { display: none; }
  .topbar { gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .top-brand { display: flex; }
  .greet strong { font-size: 14px; }
  .greet span { font-size: 11.5px; }
  .who { display: none; }
  .usermenu summary { padding: 4px; }
  .top-right .seg-toggle button { padding: 4px 7px; }
  .subnav { margin: 2px 16px 0; max-width: calc(100% - 32px); }
  .main { padding: 14px 16px calc(104px + env(safe-area-inset-bottom, 0px)); gap: 14px; }
  .main.solo { padding-bottom: 56px; }
  .page-title { font-size: 23px; }
  .bottom-nav { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 35;
    padding: 6px; gap: 4px; border-radius: 20px; background: var(--surface); box-shadow: 0 12px 32px rgba(14, 26, 53, .18), 0 0 0 1px var(--line); }
  .bottom-nav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 7px; border: 0; border-radius: 14px;
    background: none; color: var(--muted); font-size: 11px; font-weight: 500; cursor: pointer; }
  .bottom-nav button .ic { width: 21px; height: 21px; }
  /* line-height 1.35: วรรณยุกต์ไทยด้านบน (เช่น วันนี้) ไม่ถูกตัด */
  .bottom-nav button span { max-width: 100%; overflow: hidden; text-align: center; line-height: 1.35;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: normal; }
  .bn-sep { flex: none; width: 1px; margin: 10px 1px; background: var(--line); }
  /* 6 เมนู (CEO / Admin): ชิดขึ้นเล็กน้อยให้ชื่อยาว เช่น Deal Tracking ไม่ถูกตัด */
  .bottom-nav:has(.bn-sep + button + .bn-sep) { gap: 2px; padding: 6px 4px; }
  .bottom-nav:has(.bn-sep + button + .bn-sep) button { padding: 8px 1px 7px; font-size: 10.5px; }
  .bottom-nav button[aria-current="page"] { color: var(--primary); background: var(--accent-soft); }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  /* มือถือ: การ์ด 2 คอลัมน์แบบเตี้ย (ไอคอนเล็กข้างตัวเลข · ไม่มีกราฟ) · ใบสุดท้ายที่เหลือเดี่ยวเต็มแถว */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .st-ic { width: 32px; height: 32px; border-radius: 10px; }
  .st-ic .ic { width: 17px; height: 17px; }
  .st-label { font-size: 11.5px; }
  .st-val { font-size: 19px; line-height: 1.2; }
  .st-note { font-size: 11px; }
  .spark { display: none; }
  button.stat:hover { transform: none; }
  .stats-tg { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .sm-chip { height: 32px; padding: 0 10px; }
  .av { width: 34px; height: 34px; border-radius: 11px; font-size: 12.5px; }
  .head-actions .btn.ghost span { display: none; }
  .head-actions .btn.ghost { width: 36px; padding: 0; }
  .search { max-width: none; flex-basis: 100%; }
  .filters { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filters select { width: 100%; min-width: 0; }
  .filters > :last-child:nth-child(odd), .filters > select:only-of-type { grid-column: 1 / -1; }
  .price-q { grid-column: 1 / -1; min-width: 0; }
  .price-q input { flex: 1; width: auto; min-width: 0; }
  .price-q select { flex: 0 0 auto; width: auto; max-width: 45%; }
  .filters .switch { grid-column: 1 / -1; }
  table.users td.actions .linkbtn + .linkbtn { margin-left: 0; }
  .grid2, .grid3, .ticks { grid-template-columns: 1fr; }
  .demo-bar { margin: 10px 16px 0; }
  .dash-panel { padding: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 12px 12px; }
  .kpi > b { font-size: 20px; }
  .chart-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .donut { max-width: 220px; }
  .sec-head h2 { font-size: 18px; }
  .pillbars { gap: 10px; }
  .pill { padding: 0 13px; }
  select.pill-select { min-width: 0; flex: 1 1 140px; }
  .bars .meta { white-space: normal; }

  /* table → cards */
  .table-wrap { background: none; border: 0; border-radius: 0; overflow: visible; box-shadow: none; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody { display: flex; flex-direction: column; gap: 10px; }
  tbody tr { background: var(--surface); border: 0; border-radius: var(--radius); padding: 15px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; box-shadow: var(--shadow); }
  td { padding: 0; border: 0; }
  table.deals tbody tr { grid-template-areas: "prop upd" "st st" "next next" "client seller"; }
  table.deals.with-agent tbody tr { grid-template-areas: "prop upd" "st st" "next next" "client seller" "agent agent"; }
  table.deals td.prop { grid-area: prop; min-width: 0; }
  table.deals td.upd { grid-area: upd; }
  table.deals td.st { grid-area: st; }
  table.deals td.next { grid-area: next; max-width: none; }
  table.deals td.next:empty { display: none; }
  table.deals td.client { grid-area: client; font-size: 13px; }
  table.deals td.seller { grid-area: seller; font-size: 13px; text-align: right; min-width: 0; }
  table.deals td.agent { grid-area: agent; font-size: 13px; }
  table.deals td.client::before, table.deals td.seller::before, table.deals td.agent::before { content: attr(data-l) " · "; color: var(--muted); font-size: 12px; }
  table.leads tbody tr { grid-template-areas: "cust age" "want want" "st agent" "src src"; }
  table.leads td.cust { grid-area: cust; min-width: 0; }
  table.leads td.age-cell { grid-area: age; }
  table.leads td.want { grid-area: want; max-width: none; }
  table.leads td.st { grid-area: st; }
  table.leads td.agent { grid-area: agent; text-align: right; white-space: normal; min-width: 0; }
  table.leads td.src { grid-area: src; }
  table.leads td.src::before { content: attr(data-l) " · "; color: var(--muted); font-size: 12px; }
  table.listings tbody tr { grid-template-areas: "prop upd" "st price" "seller seller"; }
  table.listings.with-agent tbody tr { grid-template-areas: "prop upd" "st price" "seller agent"; }
  table.listings td.prop { grid-area: prop; min-width: 0; }
  table.listings td.upd { grid-area: upd; }
  table.listings td.st { grid-area: st; }
  table.listings td.lprice { grid-area: price; text-align: right; }
  table.listings td.seller { grid-area: seller; min-width: 0; }
  table.listings td.agent { grid-area: agent; text-align: right; white-space: normal; min-width: 0; }
  table.listings td.seller::before, table.listings td.agent::before { content: attr(data-l) " · "; color: var(--muted); font-size: 12px; }
  table.recruits tbody tr { grid-template-areas: "cust upd" "st st" "contact src"; }
  table.recruits td.cust { grid-area: cust; min-width: 0; }
  table.recruits td.upd { grid-area: upd; }
  table.recruits td.st { grid-area: st; min-width: 0; }
  table.recruits td.contact { grid-area: contact; min-width: 0; }
  table.recruits td.src { grid-area: src; text-align: right; min-width: 0; }
  .course-add { grid-template-columns: minmax(0, 1fr) auto; }
  .course-add .fld:first-child { grid-column: 1 / -1; }
  table.customers tbody tr { grid-template-areas: "cust upd" "contact bud" "lds agent"; }
  table.customers td.bud { grid-area: bud; text-align: right; white-space: normal; min-width: 0; }
  table.customers td.cust { grid-area: cust; min-width: 0; }
  table.customers td.upd { grid-area: upd; }
  table.customers td.contact { grid-area: contact; }
  table.customers td.lds { grid-area: lds; }
  table.customers td.agent { grid-area: agent; text-align: right; white-space: normal; min-width: 0; }
  /* แท็บผู้ซื้อ / ผู้เช่า: เพิ่มแถว "ต้องการ" · แท็บเจ้าของทรัพย์: ทรัพย์ + ราคา · สถานะ + Agent */
  table.customers.side-buyer tbody tr { grid-template-areas: "cust upd" "contact bud" "want want" "lds agent"; }
  table.customers.side-buyer td.want { grid-area: want; min-width: 0; font-size: 13px; color: var(--ink-2); }
  table.customers.side-owner tbody tr { grid-template-areas: "cust upd" "contact price" "want want" "st agent"; }
  table.customers.side-owner td.want { grid-area: want; min-width: 0; }
  table.customers.side-owner td.price { grid-area: price; text-align: right; white-space: normal; min-width: 0; }
  table.customers.side-owner td.st { grid-area: st; min-width: 0; }
  .facts { grid-template-columns: 1fr; }
  .list-row { grid-template-columns: 1fr 1fr 36px; }
  /* ตารางรายงานคงเป็นตาราง (เลื่อนซ้าย-ขวาในกรอบของตัวเอง) ไม่แปลงเป็นการ์ด */
  table.rep-table { display: table; }
  table.rep-table thead { display: table-header-group; }
  table.rep-table tbody { display: table-row-group; }
  table.rep-table tfoot { display: table-footer-group; }
  table.rep-table tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; }
  table.rep-table th, table.rep-table td { display: table-cell; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .rep-table td.bar-cell { min-width: 120px; }
  .rep-table tbody td:first-child, .rep-table tfoot td:first-child { white-space: normal; min-width: 110px; max-width: 150px; }
  .rep-bars .nm { flex-basis: 34%; }
  table.users td { grid-column: 1 / -1; }
  table.users td::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); }
  table.users td.actions { text-align: left; display: flex; gap: 12px; }
  table.users td.actions::before { display: none; }

  .drawer { border-left: 0; }
  .dr-bar { padding-left: 16px; }
  .dr-body { padding-left: 16px; padding-right: 16px; }
  .dr-hero h2 { font-size: 22px; }
  .modal-back { place-items: end center; padding: 0; }
  .modal { max-height: 94vh; max-height: 94dvh; overflow-y: auto; border-radius: 22px 22px 0 0; border-bottom: 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); animation: sheet .22s cubic-bezier(.2, .8, .2, 1); }
  .login-top { top: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* โอนย้ายงาน (migration 035) */
.tw-items { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.tw-group { border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 10px; margin: 0; min-width: 0; }
.tw-group legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.tw-group .check { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; overflow-wrap: anywhere; }

/* Record forms share section titles and action placement across menus. */
.form-sub { font-size: 13px; font-weight: 600; margin: 0; color: var(--muted); }

@media (max-width: 760px) {
  #stats-track .stat:first-child { grid-column: 1 / -1; }
}

/* ---------- วันนี้ · ค้นหาได้จากทุกหน้า · เส้นทางงาน (2026-10-15) ---------- */
.top-search { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.top-search:hover { color: var(--ink); border-color: var(--line-2); }
.top-search .ic { width: 16px; height: 16px; }
.top-search kbd { font: 11px/1 inherit; padding: 3px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-top: 14px; align-items: start; }
.today-sec { scroll-margin-top: 80px; }
.today-done { margin-top: 14px; }
.today-done > p { margin: -4px 0 10px; }
.tag.k-lead { color: var(--accent-ink); background: var(--accent-soft); }
.tag.k-listing { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.tag.k-deal { color: var(--warn); background: var(--warn-soft); }
.due-inline { font-variant-numeric: tabular-nums; color: var(--muted); }
.due-inline.late { color: var(--crit); font-weight: 500; }
.due-inline.today { color: var(--warn); font-weight: 500; }
.gsearch .gs-box { max-width: none; margin-bottom: 12px; }
.gsearch .gs-box input { font-size: 16px; }
.gs-results { display: flex; flex-direction: column; gap: 12px; max-height: min(60vh, 520px); overflow-y: auto; }
.gs-head { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px 4px; }
.gs-group { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.gs-group .gs-head { margin: 0; padding: 8px 12px; background: var(--surface-2); }
.gs-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 0; border-top: 1px solid var(--line); background: none;
  text-align: left; font: inherit; color: inherit; cursor: pointer; }
.gs-item:hover, .gs-item.on { background: var(--accent-soft); }
.gs-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.gs-sub { font-size: 12.5px; color: var(--muted); }
.journey { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 14px; }
.journey-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.j-step { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); color: inherit; font: inherit; font-size: 12.5px; }
button.j-step { cursor: pointer; }
button.j-step:hover { border-color: var(--primary); }
.j-step.cur { border-color: var(--primary); background: var(--accent-soft); }
.j-step.off { color: var(--muted); }
.j-kind { font-weight: 600; }
.j-extra { color: var(--muted); }
.j-arrow { color: var(--muted); }
@media (max-width: 760px) {
  .top-search { width: 38px; padding: 0; justify-content: center; }
  .top-search span, .top-search kbd { display: none; }
  .today-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- ปฏิทิน · ปุ่มทำเร็ว · จับคู่ · ค่าคอมได้รับจริง · LINE (2026-10-15) ---------- */
.today-row { display: flex; flex-direction: row; align-items: center; gap: 10px; cursor: default; }
.today-row:hover { background: none; }
.today-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.today-open:hover strong { color: var(--primary); }
.today-acts { display: inline-flex; gap: 6px; flex: none; }
.today-acts .btn .ic { width: 14px; height: 14px; }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.cal-bar .iconbtn { font-size: 24px; line-height: 1; border: 1px solid var(--line); }
.cal-title { font-size: 18px; font-weight: 600; margin: 0 4px; min-width: 150px; text-align: center; }
.cal-legend { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.cal-legend i, .cal-dots i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-lead { background: var(--primary); }
.dot-listing { background: var(--ok); }
.dot-deal { background: var(--warn); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-wd { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-day { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-height: 92px; padding: 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; overflow: hidden; }
.cal-day:hover { border-color: var(--line-2); }
.cal-day.is-today .cal-n { background: var(--primary); color: #fff; }
.cal-day.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-n { align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 600; }
.cal-dots { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.cal-dots b { margin-left: 2px; font-weight: 600; }
.cal-peek { display: flex; flex-direction: column; gap: 2px; font-size: 11px; line-height: 1.3; }
.cal-peek span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-list { margin-top: 14px; }
.match-sec h3 .ic { width: 15px; height: 15px; }
.comm-row.void strong { text-decoration: line-through; color: var(--muted); }
.comm-add { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; padding: 12px; border: 1px dashed var(--line-2); border-radius: 14px; }
.comm-add .comm-note, .comm-add .btn { grid-column: 1 / -1; }
.comm-shares { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.comm-share { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; }
.comm-share .pct { display: inline-flex; align-items: center; gap: 4px; }
.comm-share .pct input { width: 84px; text-align: right; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.line-code { margin-top: 12px; }
/* วันนัด + เวลา (migration 049) · เชื่อมปฏิทินมือถือ */
/* เวลาต้องเห็นครบ HH:MM + ไอคอนนาฬิกา: ช่องแคบ (กล่องอัปเดตใน drawer) เวลาขึ้นบรรทัดใหม่แทนการถูกตัด */
.dt-pair { display: flex; flex-wrap: wrap; gap: 8px; }
.dt-pair input { padding: 0 10px; }
.dt-pair input[type=date] { flex: 1.6 1 10rem; min-width: 0; }
/* 8rem = "02:30 PM" + ไอคอน (เครื่องที่ตั้งเวลา 12 ชม.) · 24 ชม. ใช้แค่ ~6rem */
.dt-pair input[type=time] { flex: 1 0 8rem; min-width: 8rem; font-variant-numeric: tabular-nums; }
/* เปิดจากลิงก์ในข้อความส่งให้ Agent: ไฮไลต์ฟอร์มอัปเดตสั้น ๆ */
.panel.update.flash { outline: 2px solid var(--primary); outline-offset: 2px; transition: outline-color .3s; }
@media (prefers-reduced-motion: reduce) { .panel.update.flash { transition: none; } }
.cal-peek b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-feed-add { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.cal-feed-add .btn { flex: 1 1 180px; justify-content: center; }
.cal-feed-seen { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.cal-feed-seen svg { width: 16px; height: 16px; color: var(--ok, currentColor); }
.line-code .code-big { font-size: 30px; font-weight: 700; letter-spacing: 4px; text-align: center; padding: 12px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .today-row { flex-direction: column; align-items: stretch; }
  .today-acts { justify-content: flex-end; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 52px; padding: 4px; border-radius: 10px; align-items: center; }
  .cal-n { align-self: center; font-size: 12px; min-width: 22px; height: 22px; padding: 0 4px; }
  .cal-peek { display: none; }
  .cal-dots b { display: none; }
  .cal-legend { margin-left: 0; width: 100%; }
  .cal-title { min-width: 0; font-size: 16px; }
  .comm-add { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- ลูกค้าเดิม · ใครออนไลน์ · การเข้าใช้งาน (migration 045) ---------- */
.tag.repeat { color: var(--accent-ink); background: var(--accent-soft); font-size: 11px; padding: 1px 8px; white-space: nowrap; vertical-align: middle; }
.tag.overlap { color: var(--warn); background: var(--warn-soft); font-size: 11px; padding: 1px 8px; white-space: nowrap; vertical-align: middle; }
.pill.warn-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); }
.pill.warn-pill .ic { width: 14px; height: 14px; }
.pill.warn-pill.on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.other-work .linkbtn { margin-top: 8px; }
.other-work .missing { margin-bottom: 10px; }
.today-overlap { margin-top: 14px; }
.today-overlap > p { margin: -4px 0 10px; }
.today-overlap h3 .ic { width: 16px; height: 16px; color: var(--warn); vertical-align: -3px; margin-right: 6px; }
.online-chip { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; white-space: nowrap; }
button.online-chip { cursor: pointer; }
button.online-chip:hover { border-color: var(--line-2); color: var(--ink); }
.online-chip .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.online-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.online-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.online-list .avatar.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }
.ol-who { display: grid; flex: 1; min-width: 0; }
.use-date input { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
.use-table td .muted { display: block; }
.use-grid { border-collapse: separate; border-spacing: 2px; font-size: 11px; }
.use-grid th { font-weight: 500; color: var(--muted); text-align: center; padding: 0 1px; min-width: 18px; }
.use-grid th.on { color: var(--ink); }
.use-grid tbody th { text-align: left; color: var(--ink-2); white-space: nowrap; padding-right: 8px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.use-grid td { padding: 0; }
.use-cell { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 0; padding: 0; background: var(--surface-2); cursor: pointer; vertical-align: middle; }
.use-cell.l1 { background: color-mix(in srgb, var(--ok) 25%, var(--surface-2)); }
.use-cell.l2 { background: color-mix(in srgb, var(--ok) 50%, var(--surface-2)); }
.use-cell.l3 { background: color-mix(in srgb, var(--ok) 75%, var(--surface-2)); }
.use-cell.l4 { background: var(--ok); }
.use-cell.on { outline: 2px solid var(--primary); outline-offset: 1px; }
.use-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.use-legend .use-cell { cursor: default; margin-right: 4px; }
@media (max-width: 760px) {
  .online-chip { padding: 0 10px; }
  .online-chip span { display: none; }
  .online-chip::after { content: attr(data-n); }
}
/* โทรศัพท์จอแคบ: ปุ่มด้านขวาเต็มแถบ คำทักทายถูกบีบเหลือ "สวั..." → ซ่อนไป (หน้าวันนี้มีวันที่อยู่แล้ว) */
@media (max-width: 480px) {
  .topbar .greet { display: none; }
  .topbar .top-right { margin-left: auto; }
}
.who-txt .tag.repeat, .who-txt .tag.overlap { align-self: flex-start; margin-top: 2px; }
.who-txt .tag.repeat + .tag.overlap { margin-top: 3px; }
@media (max-width: 760px) {
  table.use-table td { grid-column: 1 / -1; }
  table.use-table td[data-l]::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); }
  table.use-table td:not([data-l]):empty { display: none; }
  table.use-grid { display: table; }
  table.use-grid thead { display: table-header-group; }
  table.use-grid tbody { display: table-row-group; }
  table.use-grid tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; box-shadow: none; }
  table.use-grid th, table.use-grid td { display: table-cell; }
  table.use-grid tbody th { max-width: 110px; }
}
.use-grid tbody th, .use-grid thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }

/* ---------- ลูกค้าของฉัน (Agent) ---------- */
.myc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 14px; margin-top: 14px; align-items: start; }
.myc-card { display: grid; gap: 10px; min-width: 0; }
.myc-card.done { opacity: .78; }
.myc-card .cbtns { margin: 0; }

/* ---------- กระชับขึ้น (New 2026-10-18: "อยากให้กระชับ จะได้ไม่ต้องเลื่อนเยอะ ทั้งมือถือและคอม") ----------
   การ์ดสรุป · รายการหน้าวันนี้ · รายการในมือถือ · ลิ้นชักรายละเอียด: ระยะห่าง / ตัวอักษรเล็กลง ข้อมูลเท่าเดิม */
.main { padding-top: 16px; gap: 14px; }
.page-title { font-size: 24px; }
/* การ์ดสรุป: เตี้ยลง ไอคอนอยู่ข้างตัวเลข · คอมพิวเตอร์วางได้ 5–7 ใบต่อแถว */
.stats-wrap { gap: 8px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat { align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; }
.st-ic { width: 34px; height: 34px; border-radius: 10px; }
.st-ic .ic { width: 17px; height: 17px; }
.st-label { font-size: 12px; -webkit-line-clamp: 1; }
.st-val { font-size: 20px; line-height: 1.2; }
.st-note { font-size: 11.5px; -webkit-line-clamp: 1; }
.spark { height: 18px; gap: 2px; }
.spark i { width: 4px; }
.stats-tg, .sm-chip { height: 30px; }
/* ตาราง (คอมพิวเตอร์): แถวเตี้ยลง · มือถือเป็นการ์ด (ระยะของการ์ดอยู่ด้านล่าง) */
@media (min-width: 761px) {
  th { padding: 11px 14px 9px; }
  td { padding: 10px 14px; }
}
/* หน้าวันนี้: ปุ่ม เสร็จแล้ว / พรุ่งนี้ ไม่บีบข้อความ (ขึ้นบรรทัดล่างเมื่อกล่องแคบ) · ชื่อยาวตัดด้วย … */
.today-grid { gap: 10px; margin-top: 10px; }
.mini { padding: 9px 12px; gap: 2px; }
.mini-sub { font-size: 12.5px; }
.mini-top strong { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-row { flex-wrap: wrap; gap: 6px 10px; }
.today-open { flex: 1 1 220px; gap: 2px; }
.today-acts { margin-left: auto; }
.today-acts .btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.today-sec .section-head { min-height: 22px; }
/* ลิ้นชักรายละเอียด */
.dr-bar { padding: 8px 12px 8px 18px; }
.dr-body { padding-top: 14px; gap: 12px; }
.dr-hero { gap: 6px; }
.dr-hero h2 { font-size: 20px; }
.dr-facts { font-size: 13px; gap: 4px 14px; }
.dr-price { font-size: 19px; }
.status-card { padding: 12px 14px; gap: 4px; }
.sc-stage { font-size: 17px; }
.sc-steps { margin-top: 6px; }
.next-card { padding: 10px 12px; gap: 12px; }
.date-tile { width: 46px; height: 50px; }
.date-tile b { font-size: 19px; }
.panel { padding: 14px; gap: 10px; border-radius: 14px; }
.section { gap: 8px; margin-top: 2px; }
.tile { padding: 10px 14px; gap: 12px; }
.tile-ic, .tile-avatar { width: 30px; height: 30px; }
.facts { padding: 10px 14px; gap: 8px 14px; }
.notes-box { padding: 10px 12px; gap: 10px; }
.date-row { padding: 8px 12px; gap: 10px; }
.date-tile.sm { width: 40px; height: 44px; }
.comm-card { padding: 12px 14px; gap: 8px; }
.timeline li { padding-bottom: 12px; }
.journey { padding: 8px 10px; }
@media (max-width: 760px) {
  .main { padding-top: 10px; gap: 10px; }
  .page-title { font-size: 21px; }
  /* การ์ดสรุป 2 คอลัมน์แบบเตี้ย · ข้อความรองบรรทัดเดียว */
  .stats { gap: 6px; }
  .stat { padding: 8px 10px; gap: 8px; border-radius: 12px; }
  .st-ic { width: 28px; height: 28px; border-radius: 9px; }
  .st-ic .ic { width: 15px; height: 15px; }
  .st-label { font-size: 11px; }
  .st-val { font-size: 17px; }
  .st-note { font-size: 10.5px; }
  /* รายการที่เป็นการ์ด (Buyer / Owner / Deal / CRM / ผู้สมัคร) */
  tbody { gap: 8px; }
  tbody tr { padding: 11px 12px; gap: 4px 10px; border-radius: 14px; }
  .meta { margin-top: 1px; }
  /* ลิ้นชัก */
  .dr-body { padding-left: 12px; padding-right: 12px; gap: 10px; }
  .panel { padding: 12px; }
}
@media (max-width: 760px) {
  /* หน้าวันนี้: ข้อความเต็มความกว้าง ปุ่มอยู่ขวาบรรทัดล่าง (เดิมเรียงแนวตั้งทำให้กล่องสูงมาก) */
  .today-row { flex-direction: row; align-items: center; }
  /* การ์ดรายการ: "อัปเดตล่าสุด / วัน" มุมขวาบน · ข้อมูลคู่กันแบ่งครึ่ง บรรทัดเดียว (ยาวเกินตัดด้วย …) */
  :is(table.deals, table.leads, table.listings, table.recruits, table.customers) tbody tr { position: relative; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  :is(table.deals, table.leads, table.listings, table.recruits, table.customers) tbody tr > :is(td.upd, td.age-cell) { position: absolute; top: 11px; right: 12px; font-size: 11.5px; }
  :is(table.deals, table.leads, table.listings, table.recruits, table.customers) :is(td.prop, td.cust) { padding-right: 72px; }
  td.client, td.seller, td.agent, td.src, td.contact, td.bud, td.lprice, td.price { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  table.deals tbody tr { grid-template-areas: "prop prop" "st st" "next next" "client seller"; }
  table.deals.with-agent tbody tr { grid-template-areas: "prop prop" "st st" "next next" "client seller" "agent agent"; }
  table.leads tbody tr { grid-template-areas: "cust cust" "want want" "st agent" "src src"; }
  table.listings tbody tr { grid-template-areas: "prop prop" "st st" "seller price"; }
  table.listings.with-agent tbody tr { grid-template-areas: "prop prop" "st st" "seller price" "agent agent"; }
  table.listings td.agent { text-align: left; }
  table.recruits tbody tr { grid-template-areas: "cust cust" "st st" "contact src"; }
  table.customers tbody tr { grid-template-areas: "cust cust" "contact bud" "lds agent"; }
  table.customers.side-buyer tbody tr { grid-template-areas: "cust cust" "contact bud" "want want" "lds agent"; }
  table.customers.side-owner tbody tr { grid-template-areas: "cust cust" "contact price" "want want" "st agent"; }
}
@media (max-width: 760px) {
  /* ป้าย "ลูกค้า · ชื่อ" อยู่บรรทัดเดียวกัน · สถานะ + สถานะย่อย บรรทัดเดียว · สิ่งที่ต้องทำต่อ · วันนัด ต่อกัน */
  td.client .clamp2, td.seller .clamp2, td.agent .clamp2, td.src .clamp2, td.contact .clamp2, td.bud .clamp2 { display: inline; }
  tbody td .status { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
  tbody td .st-sub { padding-left: 0; }
  td.next .next-txt, td.next .due, .meta.next-meta .next-txt, .meta.next-meta .due { display: inline; margin-top: 0; }
  td.next .next-txt + .due::before, .meta.next-meta .next-txt + .due::before { content: " · "; color: var(--muted); }
  .meta.next-meta { margin-top: 2px; }
}

/* รายงาน → Leads → ทั้งหมด: Lead ของแต่ละ Agent เป็นแถว (2026-10-21) · แท่ง 2 สี Buyer (น้ำเงิน) / Owner (เขียวอมฟ้า) */
:root { --ag-buyer: var(--accent); --ag-owner: #0d9488; --ag-owner-soft: #e6f6f4; --ag-owner-ink: #0f766e; --ag-deal: #7c3aed; --ag-deal-soft: #f1ebfe; --ag-deal-ink: #6d28d9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ag-owner: #2dd4bf; --ag-owner-soft: #10302d; --ag-owner-ink: #5eead4; --ag-deal: #a78bfa; --ag-deal-soft: #2a1f45; --ag-deal-ink: #c4b5fd; } }
:root[data-theme="dark"] { --ag-owner: #2dd4bf; --ag-owner-soft: #10302d; --ag-owner-ink: #5eead4; --ag-deal: #a78bfa; --ag-deal-soft: #2a1f45; --ag-deal-ink: #c4b5fd; }
.ag-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-2); }
.ag-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.ag-legend i.buyer, .ag-bar i.buyer { background: var(--ag-buyer); }
.ag-legend i.owner, .ag-bar i.owner { background: var(--ag-owner); }
.ag-legend i.deal, .ag-bar i.deal { background: var(--ag-deal); }
.ag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ag-row { display: grid; grid-template-columns: minmax(180px, 240px) 1fr 64px; grid-template-areas: "who bar total" "who detail total"; gap: 6px 16px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.ag-row:last-child { border-bottom: 0; }
.ag-row.none { margin-top: 6px; border-top: 1px dashed var(--line-2); border-bottom: 0; }
.ag-who { grid-area: who; display: flex; align-items: center; gap: 10px; min-width: 0; }
.ag-who > div { min-width: 0; display: flex; flex-direction: column; }
.ag-who b { font-weight: 600; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-who small { font-size: 12px; color: var(--muted); }
.av.ag-none { background: var(--surface-2); color: var(--muted); }
.ag-bar { grid-area: bar; display: flex; height: 12px; border-radius: 99px; background: var(--track); overflow: hidden; }
.ag-bar i { display: block; height: 100%; }
.ag-total { grid-area: total; text-align: right; line-height: 1.1; }
.ag-total b { display: block; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.ag-total small { font-size: 11.5px; color: var(--muted); }
.ag-detail { grid-area: detail; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; }
.ag-gap { flex: 0 0 6px; }
.ag-n, .ag-st { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; border: 0; font: inherit; font-size: 12.5px; line-height: 1.4; }
.ag-n b, .ag-st b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ag-n.buyer { background: var(--accent-soft); color: var(--accent-ink); }
.ag-n.owner { background: var(--ag-owner-soft); color: var(--ag-owner-ink); }
.ag-n.deal { background: var(--ag-deal-soft); color: var(--ag-deal-ink); }
button.ag-n { cursor: pointer; }
button.ag-n:hover { box-shadow: inset 0 0 0 1px currentColor; }
button.ag-n:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ag-st { background: var(--surface-2); color: var(--ink-2); }
.ag-st.won { color: var(--ok); }
.ag-n.zero, .ag-st.zero { opacity: .5; }
@media (max-width: 760px) {
  .ag-row { grid-template-columns: 1fr auto; grid-template-areas: "who total" "bar bar" "detail detail"; gap: 8px 10px; padding: 10px 2px; }
  .ag-who .av { width: 32px; height: 32px; border-radius: 10px; font-size: 12px; }
  .ag-gap { flex-basis: 100%; height: 0; }
}

/* Kick Start Training paid on its own (migration 060): one line under step 4 of the applicant file */
.ks-pay { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.ks-pay .facts { flex: 1; grid-template-columns: 1fr; padding: 10px 14px; }
.ks-note { color: var(--ink); font-weight: 500; }
/* Save comes first in the page (Enter = Save); Remove still sits on the left */
.row-end .ks-remove { order: 3; margin-right: auto; }
.row-end:has(.ks-remove) > .btn.primary { order: 5; }
.row-end:has(.ks-remove) > .btn.ghost { order: 4; }
