/* ธีมระบบบริหารความสัมพันธ์ลูกค้า — เขียวหยก (teal) + เทาอุ่น · sidebar ซ้าย · อ่านง่ายทั้งจอคอมและมือถือ */
:root {
  --brand: #0f766e; --brand-2: #0b5f59; --brand-3: #14958b; --brand-soft: #e2f3f0; --brand-ink: #0a4f4a;
  --side: #0f2e2c; --side-2: #0b2423; --side-txt: #c9dedb; --side-on: #7fdccf;
  --bg: #f3f6f6; --card: #ffffff; --ink: #172626; --muted: #62787a; --line: #dfe7e7; --line-2: #eef2f2;
  --green: #1a7f4b; --green-bg: #e2f4e9; --red: #c2402f; --red-bg: #fbe7e4; --amber: #b7791f; --amber-bg: #fdf1dc; --amber-ink: #8a5a12;
  --blue: #2563a8; --blue-bg: #e5eefb; --purple: #6b4fbb; --purple-bg: #eee9fb; --grey-bg: #edf1f1; --grey-ink: #55696b;
  --lineapp: #06c755; --lineapp-bg: #e6f8ec;
  --radius: 12px; --shadow: 0 1px 2px rgba(18, 40, 38, .05), 0 3px 12px rgba(18, 40, 38, .05);
  --side-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "IBM Plex Sans Thai", "Noto Sans Thai", "Sukhumvit Set", "Leelawadee UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.55; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; line-height: 1.3; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 14.5px; margin: 16px 0 6px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.lede { color: var(--muted); margin-top: 2px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.num.b, b.num { font-weight: 700; }
.b { font-weight: 700; }
.hide-sm { display: inline; }
.ic { vertical-align: -3px; flex: none; }

/* ---------- โครงแอป ---------- */
.app { display: flex; min-height: 100vh; }
.side { width: var(--side-w); flex: none; background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%); color: var(--side-txt); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; color: #fff; font-weight: 700; font-size: 13.5px; line-height: 1.3; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--brand-3); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .5px; padding: 4px 8px; border-radius: 7px; }
.nav { padding: 10px 10px 20px; flex: 1; }
.nav .grp { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7f9d99; padding: 14px 10px 4px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-txt); padding: 8px 10px; border-radius: 9px; font-size: 14px; margin-bottom: 1px; }
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(127, 220, 207, .16); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--side-on); }
.nav a .cnt { margin-left: auto; background: #e9642b; color: #fff; font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 999px; line-height: 18px; }
.side-foot { padding: 12px 16px; font-size: 11.5px; color: #7f9d99; border-top: 1px solid rgba(255, 255, 255, .08); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 18px; height: 56px; }
.hamb { display: none; cursor: pointer; color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; background: var(--grey-bg); border: 1.5px solid transparent; border-radius: 10px; padding: 0 12px; height: 38px; width: 100%; max-width: 460px; color: var(--muted); }
.search:focus-within { border-color: var(--brand); background: #fff; }
.search input { border: 0; background: transparent; outline: 0; font: inherit; width: 100%; color: var(--ink); padding: 0; }
.spacer { flex: 1; }
.iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; color: var(--muted); cursor: pointer; list-style: none; }
.iconbtn:hover { background: var(--grey-bg); color: var(--ink); }
.iconbtn .dot { position: absolute; top: 3px; right: 2px; background: #e9642b; color: #fff; font-size: 10.5px; font-weight: 700; font-style: normal; border-radius: 999px; min-width: 17px; height: 17px; line-height: 17px; text-align: center; padding: 0 4px; }
.who { display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none; padding: 4px 8px 4px 4px; border-radius: 10px; }
.who:hover { background: var(--grey-bg); }
.who-t { display: flex; flex-direction: column; line-height: 1.2; }
.who-t b { font-size: 13px; }
.who-t small { color: var(--muted); font-size: 11.5px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 13px; flex: none; }
.avatar-lg { width: 48px; height: 48px; font-size: 20px; }
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
details.dd { position: relative; }
details.dd summary { list-style: none; }
details.dd summary::-webkit-details-marker { display: none; }
details.dd .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(18, 40, 38, .14); min-width: 220px; padding: 6px; z-index: 50; }
details.dd .menu a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); font-size: 13.5px; }
details.dd .menu a:hover { background: var(--grey-bg); text-decoration: none; }
details.dd .menu-h { font-size: 11.5px; color: var(--muted); padding: 6px 12px 4px; }
.menu.roles { min-width: 300px; }
.menu.roles a { display: flex; flex-direction: column; gap: 1px; }
.menu.roles a span { font-size: 12px; color: var(--muted); }
.menu.roles a.on { background: var(--brand-soft); }
.menu.notes { min-width: 340px; max-height: 70vh; overflow-y: auto; }
.menu .note { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 8px; border-left: 3px solid var(--amber); margin: 3px 0; font-size: 13px; }
.menu .note.red { border-left-color: var(--red); }
.menu .note.blue { border-left-color: var(--blue); }
.menu .note.green { border-left-color: var(--green); }
.menu .note span { color: var(--muted); font-size: 12.5px; }
.content { padding: 22px 24px 70px; max-width: 1240px; width: 100%; margin: 0 auto; }
.content.wide { max-width: 1560px; }
.navtoggle, .scrim { display: none; }
@media (max-width: 960px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
  .navtoggle:checked ~ .app .side { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 55; }
  .navtoggle:checked ~ .scrim { display: block; }
  .hamb { display: inline-flex; }
  .hide-sm { display: none; }
  .content { padding: 16px 14px 60px; }
  .top { padding: 0 12px; gap: 6px; }
}

/* ---------- แท็บย่อย ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -6px 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 13px; color: var(--muted); font-size: 13.5px; white-space: nowrap; border-bottom: 2.5px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand-ink); font-weight: 700; border-bottom-color: var(--brand); }
.tabs .cnt { background: var(--amber-bg); color: var(--amber-ink); font-size: 11px; padding: 0 6px; border-radius: 999px; }

/* ---------- หัวหน้า / การ์ด / กริด ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.dh-l { display: flex; gap: 14px; align-items: center; }
.dh-kicker { font-size: 12.5px; color: var(--muted); }
.dh-kicker a { color: var(--muted); }
.dh-meta { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.dh-r { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dh-r form { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-tight { padding: 12px 14px; }
.card h2 { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h2 .h-r { font-size: 12.5px; font-weight: 500; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.split-eq { grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-4, .split { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
/* มือถือ: การ์ดในกริดต้องไม่ดันหน้าให้กว้างเกินจอ — กราฟ/ตารางที่กว้างกว่าการ์ดเลื่อนซ้ายขวาในการ์ดแทน (15 พ.ย. 2569) */
.grid > *, .split > * { min-width: 0; }
.split.split-inbox { grid-template-columns: minmax(260px, 1fr) minmax(0, 2.2fr) minmax(250px, 1fr); }
@media (max-width: 1000px) { .split.split-inbox { grid-template-columns: minmax(0, 1fr); } }
/* เอกสาร A4 เปิดบนมือถือ: หัวเอกสารขึ้นบรรทัดใหม่ได้ + ตารางเลื่อนในกรอบ (ตอนพิมพ์ไม่กระทบ) */
@media screen and (max-width: 700px) { .doc { padding: 18px 14px; overflow-x: auto; } .doc-head { flex-wrap: wrap; } .doc-head > div { min-width: 0 !important; } }
@media (max-width: 1000px) { .card { overflow-x: auto; } }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--ink); }
a.kpi:hover { text-decoration: none; border-color: var(--brand-3); }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--brand-ink); line-height: 1.2; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-good .kpi-value { color: var(--green); }
.kpi-warn .kpi-value { color: var(--amber); }
.kpi-bad .kpi-value { color: var(--red); }

/* ---------- ตาราง ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; background: #f8fafa; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #f7fafa; }
.tbl th.num, .tbl td.num, .tbl .r { text-align: right; }
.tbl-sm { font-size: 12.8px; }
.tbl tr.dim td { color: var(--muted); }
.tbl tr.hl td { background: var(--amber-bg); }
.empty { color: var(--muted); padding: 26px; text-align: center; background: #f8fafa; border-radius: 10px; border: 1px dashed var(--line); }
.sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---------- badge / chip / due ---------- */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; vertical-align: 1px; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber-ink); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.b-grey { background: var(--grey-bg); color: var(--grey-ink); }
.b-line { background: var(--lineapp-bg); color: #0b8a3d; }
.chip { display: inline-block; background: var(--grey-bg); color: var(--grey-ink); border-radius: 7px; padding: 1px 8px; font-size: 12px; margin: 1px 2px 1px 0; }
.chip.teal { background: var(--brand-soft); color: var(--brand-ink); }
.due { display: inline-flex; flex-direction: column; line-height: 1.25; }
.due .due-date { font-size: 12px; color: var(--muted); }
.due b { font-size: 12.5px; }
.due-ok b { color: var(--green); }
.due-soon b { color: var(--amber); }
.due-late b { color: var(--red); }

/* ---------- ปุ่ม / ฟอร์ม ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--brand); color: #fff; border: 1.5px solid var(--brand); cursor: pointer; padding: 7px 14px; border-radius: 9px; font-size: 13.5px; font-family: inherit; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.btn:hover { background: var(--brand-2); border-color: var(--brand-2); text-decoration: none; }
.btn-line { background: #fff; color: var(--brand-ink); border-color: var(--line); }
.btn-line:hover { background: var(--brand-soft); border-color: var(--brand-3); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--grey-bg); color: var(--ink); border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-red { background: var(--red); border-color: var(--red); }
.btn-red:hover { background: #a3331f; border-color: #a3331f; }
.btn-green { background: var(--green); border-color: var(--green); }
.btn-green:hover { background: #14653b; border-color: #14653b; }
.btn-amber { background: var(--amber); border-color: var(--amber); }
.btn-amber:hover { background: #955f13; border-color: #955f13; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
form { margin: 0; }
input, select, textarea { font-family: inherit; font-size: 13.5px; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); max-width: 100%; width: 100%; }
input[type="checkbox"], input[type="radio"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 118, 110, .25); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 3px; font-weight: 500; }
.f { min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-grid .span2 { grid-column: span 2; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.form-row > div { min-width: 140px; flex: 1; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { width: auto; }
details.box { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 16px; box-shadow: var(--shadow); }
details.box summary { padding: 12px 18px; cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--brand-ink); }
details.box summary::-webkit-details-marker { display: none; }
details.box summary::before { content: "+"; display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 6px; background: var(--brand-soft); font-weight: 700; }
details.box[open] summary::before { content: "–"; }
details.box .box-b { padding: 4px 18px 18px; }

/* ---------- แถบแจ้ง ---------- */
.err { background: var(--red-bg); color: var(--red); border: 1px solid #f0c9c3; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 600; }
.ok-note { background: var(--green-bg); color: var(--green); border: 1px solid #bfe4cc; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 600; }
.info-note { background: var(--blue-bg); color: var(--blue); border: 1px solid #c8d9f2; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; }
.warn-note { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid #f0d9a8; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; }
.alert-strip { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.alert-strip .a-item { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 9px; padding: 8px 13px; font-size: 13px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.alert-strip .a-item.sev-red { border-left-color: var(--red); }
.alert-strip .a-item.sev-blue { border-left-color: var(--blue); }
.alert-strip .a-item.sev-green { border-left-color: var(--green); }
.alert-strip .a-item b { white-space: nowrap; }
.alert-strip .a-item .a-go { margin-left: auto; font-size: 12.5px; }
.section-note { font-size: 12.5px; color: var(--muted); background: #f5f8f8; border-radius: 9px; padding: 9px 13px; margin-top: 10px; }

/* ---------- meter / stack / chart ---------- */
.meter { position: relative; background: #e6ecec; border-radius: 999px; height: 20px; min-width: 110px; overflow: hidden; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand-3); border-radius: 999px; }
.meter span { position: relative; z-index: 1; font-size: 11.5px; font-weight: 700; color: var(--ink); padding-left: 9px; line-height: 20px; white-space: nowrap; }
.meter-green i { background: var(--green); }
.meter-amber i { background: var(--amber); }
.meter-red i { background: var(--red); }
.stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #e6ecec; }
.stack i { display: block; height: 100%; }
.c-teal { background: var(--brand-3); } .c-green { background: var(--green); } .c-amber { background: #e2a33a; } .c-red { background: var(--red); } .c-blue { background: var(--blue); } .c-grey { background: #b6c3c3; } .c-purple { background: var(--purple); } .c-line { background: var(--lineapp); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 6px 2px 0; }
.chart .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 18px; height: 100%; }
.chart .bar i { width: 100%; background: var(--brand-3); border-radius: 5px 5px 0 0; min-height: 2px; }
.chart .bar.hl i { background: #e2a33a; }
.chart .bar span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart .bar b { font-size: 11px; color: var(--ink); white-space: nowrap; }
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel .fr { display: grid; grid-template-columns: 150px 1fr 120px; gap: 10px; align-items: center; font-size: 13px; }
.funnel .fr i { display: block; height: 26px; border-radius: 6px; background: var(--brand-3); min-width: 6px; }
.funnel .fr .v { text-align: right; font-variant-numeric: tabular-nums; }
svg.line { width: 100%; height: auto; display: block; }

/* ---------- กระดานดีล (kanban) ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol { flex: 1; min-width: 232px; max-width: 300px; background: #eaf0ef; border-radius: var(--radius); padding: 10px; border: 2px solid transparent; }
.kcol.over { border-color: var(--brand-3); background: var(--brand-soft); }
.kcol-h { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 8px; font-size: 13px; }
.kcol-h b { font-size: 13.5px; }
.kcol-h .sum { color: var(--muted); font-size: 12px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); display: block; color: var(--ink); }
.kcard:hover { border-color: var(--brand-3); text-decoration: none; }
.kcard.dragging { opacity: .5; }
.kcard .kc-t { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.kcard .kc-a { font-size: 12.5px; color: var(--muted); }
.kcard .kc-v { font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; font-size: 13.5px; color: var(--brand-ink); }
.kcard .kc-f { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.kcard.stale { border-left: 3px solid var(--red); }
.kcard.hot { border-left: 3px solid #e2a33a; }

/* ---------- stepper ---------- */
.stepper { display: flex; list-style: none; margin: 0 0 14px; padding: 0; gap: 4px; overflow-x: auto; }
.stepper li { flex: 1; min-width: 100px; text-align: center; font-size: 12.5px; padding: 7px 8px; background: var(--grey-bg); color: var(--muted); border-radius: 8px; position: relative; white-space: nowrap; }
.stepper li.done { background: var(--brand-soft); color: var(--brand-ink); }
.stepper li.cur { background: var(--brand); color: #fff; font-weight: 700; }
.stepper.red li.cur { background: var(--red); }

/* ---------- ไทม์ไลน์ / kv / อื่น ๆ ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6.5px; top: 5px; width: 11px; height: 11px; border-radius: 50%; background: var(--brand-3); border: 2px solid #fff; }
.timeline li.red::before { background: var(--red); }
.timeline li.amber::before { background: #e2a33a; }
.timeline li.grey::before { background: #b6c3c3; }
.timeline li.line::before { background: var(--lineapp); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .tl-t { font-size: 12px; color: var(--muted); }
.timeline .tl-b { font-size: 13.5px; }
.timeline .tl-d { color: var(--muted); font-size: 13px; margin-top: 1px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.pill { background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12.8px; color: var(--grey-ink); }
.pill.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pill:hover { text-decoration: none; border-color: var(--brand-3); }
.mini-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.mini-cards .mc { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; background: #fbfdfd; }
.mini-cards .mc b { display: block; }
.score { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 700; font-size: 13px; border: 3px solid var(--line); color: var(--ink); background: #fff; }
.score.hot { border-color: #e2a33a; color: var(--amber-ink); }
.score.warm { border-color: var(--brand-3); color: var(--brand-ink); }
.score.cold { border-color: #b6c3c3; color: var(--muted); }
.tag-line { display: inline-flex; align-items: center; gap: 4px; }
.tag-line i { width: 8px; height: 8px; border-radius: 50%; background: var(--lineapp); display: inline-block; }

/* ---------- แชท (กล่องข้อความ) ---------- */
.threads { display: flex; flex-direction: column; gap: 4px; }
.thread { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); align-items: flex-start; }
.thread:hover { text-decoration: none; border-color: var(--brand-3); }
.thread.on { border-color: var(--brand); background: var(--brand-soft); }
.thread .th-b { flex: 1; min-width: 0; }
.thread .th-n { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.thread .th-n b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .th-n span { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.thread .th-p { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat { display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; max-height: 480px; overflow-y: auto; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; position: relative; }
.bubble.in { background: var(--grey-bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.sys { background: transparent; color: var(--muted); font-size: 12px; align-self: center; text-align: center; }
.bubble .bt { display: block; font-size: 10.5px; opacity: .7; margin-top: 3px; }
.reply-box { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.reply-box textarea { min-height: 44px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.quick button { background: #fff; border: 1.5px solid var(--line); border-radius: 999px; font: inherit; font-size: 12.5px; padding: 3px 11px; cursor: pointer; color: var(--grey-ink); }
.quick button:hover { border-color: var(--brand-3); color: var(--brand-ink); }

/* ---------- ปฏิทินสัปดาห์ ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week .day { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 120px; }
.week .day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.week .day .dh { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.week .ev { display: block; font-size: 12px; padding: 4px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-ink); margin-bottom: 4px; line-height: 1.3; }
.week .ev.visit { background: var(--amber-bg); color: var(--amber-ink); }
.week .ev.task { background: var(--blue-bg); color: var(--blue); }
.week .ev.done { opacity: .55; text-decoration: line-through; }
@media (max-width: 900px) { .week { grid-template-columns: 1fr 1fr; } }

/* ---------- แผนที่จำลอง ---------- */
.map { position: relative; background: linear-gradient(135deg, #e6efe9 0%, #dbe8e3 40%, #e9f0ee 100%); border-radius: 10px; height: 200px; overflow: hidden; border: 1px solid var(--line); }
.map::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px); background-size: 28px 28px; }
.map .pin { position: absolute; transform: translate(-50%, -100%); color: var(--red); font-size: 12px; text-align: center; }
.map .pin b { display: block; background: #fff; border-radius: 6px; padding: 1px 6px; font-size: 11px; color: var(--ink); box-shadow: var(--shadow); white-space: nowrap; }

/* ---------- เอกสารพิมพ์ A4 ---------- */
body.bare { background: #e9eeee; }
.doc { background: #fff; max-width: 800px; margin: 20px auto; padding: 36px 44px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 16px; }
.doc h1 { font-size: 21px; color: var(--brand-ink); }
.doc .co { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.doc .co b { color: var(--ink); }
.doc table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.doc th { border: 1px solid #c9d6d4; background: #f0f5f4; padding: 6px 9px; text-align: left; font-size: 12px; }
.doc td { border: 1px solid #c9d6d4; padding: 6px 9px; vertical-align: top; }
.doc .tot td { border: 0; padding: 3px 9px; }
.doc .tot tr.grand td { font-weight: 700; font-size: 14px; border-top: 2px solid var(--ink); }
.doc-sign { display: flex; gap: 30px; margin-top: 44px; }
.doc-sign div { flex: 1; border-top: 1px solid #999; text-align: center; padding-top: 6px; font-size: 12.5px; color: var(--muted); }
.doc .stamp { display: inline-block; border: 2px solid var(--green); color: var(--green); border-radius: 6px; padding: 2px 10px; font-weight: 700; font-size: 12px; transform: rotate(-4deg); }
.doc .qrbox { width: 92px; height: 92px; border: 2px solid var(--ink); border-radius: 6px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 5px; }
.doc .qrbox i { background: var(--ink); border-radius: 1px; }
.doc .qrbox i.o { background: transparent; }
.print-bar { text-align: center; margin: 14px auto 30px; display: flex; gap: 8px; justify-content: center; }
@media print {
  body, body.bare { background: #fff; }
  .side, .top, .no-print, .page-head-right, .print-bar, .tabs, .scrim { display: none !important; }
  .content { margin: 0; max-width: none; padding: 0; }
  .doc { border: none; margin: 0; max-width: none; padding: 0; }
  .card { box-shadow: none; border-color: #ccc; }
}
