:root {
  --bg: #f7f6f3;
  --card: #ffffff;
  --ink: #1f1d1a;
  --muted: #6f6a62;
  --line: #e7e3dc;
  --gold: #b29c78;
  --gold-ink: #6e5a36;
  --ok: #2f7a4f;
  --warn: #b26a00;
  --bad: #b3261e;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Kanit", system-ui, sans-serif; font-weight: 300; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.35rem; font-weight: 500; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; font-weight: 500; margin: .2rem 0; }
.muted { color: var(--muted); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; letter-spacing: .02em; }
.brand span { color: var(--gold); font-weight: 400; }
.who { font-size: .85rem; color: var(--muted); text-align: right; }
.who button { margin-left: 8px; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.center { text-align: center; }
input, textarea, select { width: 100%; font: inherit; font-size: 1rem; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; margin-top: 6px; }
label { display: block; margin: 10px 0; font-size: .95rem; }
.btn { font: inherit; font-size: 1rem; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); min-height: 48px; cursor: pointer; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #fff; font-weight: 500; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.msg { min-height: 1.2em; font-size: .95rem; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
.progress { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.progress span { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .9rem; }
.lead-head { display: flex; justify-content: space-between; gap: 12px; }
.tag { display: inline-block; font-size: .8rem; color: var(--gold-ink); background: #f3eee4; border-radius: 999px; padding: 2px 10px; margin-bottom: 6px; }
.hot { color: var(--warn); font-size: 1.1rem; white-space: nowrap; }
.phone { display: block; margin: 14px 0; padding: 14px; text-align: center; font-size: 1.5rem; font-weight: 500;
  color: #fff; background: var(--ok); border-radius: 12px; text-decoration: none; }
.phone.none { background: var(--line); color: var(--muted); pointer-events: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.history { margin-top: 10px; font-size: .9rem; }
.history ul { padding-left: 18px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 500; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { font: inherit; padding: 10px 14px; min-height: 44px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.sticky { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); display: flex; gap: 8px; background: var(--card); padding-top: 8px; }
.grow { flex: 1; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs button { flex: 1; font: inherit; padding: 14px 4px; border: 0; background: none; color: var(--muted); min-height: 60px; }
.tabs button.active { color: var(--ink); font-weight: 500; box-shadow: inset 0 3px 0 var(--gold); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.list li.overdue { border-color: var(--bad); }
.list li .meta { color: var(--muted); font-size: .9rem; }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.row label { flex: 1; min-width: 130px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 12px 0; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stats b { display: block; font-size: 1.4rem; font-weight: 500; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.kpis label { margin: 0; font-size: .85rem; }
.kpis input.low { border-color: var(--warn); background: #fff8ec; }
.checks { padding-left: 18px; font-size: .9rem; }
.checks .bad { color: var(--bad); }
.checks .good { color: var(--ok); }
#cally-preview { width: 100%; max-height: 360px; object-fit: contain; border-radius: 10px; margin-top: 8px; background: #faf9f6; }
.file input { padding: 10px; }
.badge { display: inline-block; font-size: .78rem; border-radius: 999px; padding: 1px 9px; background: #efece6; color: var(--muted); white-space: nowrap; }
.badge.st0 { background: #efece6; } .badge.st1 { background: #e8f0fb; color: #2b5797; } .badge.st2 { background: #e9f6ee; color: var(--ok); }
.badge.st3 { background: #fff3df; color: var(--warn); } .badge.st4 { background: #f3eee4; color: var(--gold-ink); }
.badge.st5, .badge.st6 { background: #2f7a4f; color: #fff; } .badge.st7 { background: var(--gold); color: #fff; }
.badge.st-1 { background: #fbe9e7; color: var(--bad); }
#cdp-list li { cursor: pointer; }
.tl li { padding: 10px 12px; }
details.card > summary { cursor: pointer; font-weight: 500; }
#cdp-profile .kpis label { font-size: .85rem; }
#cdp-profile textarea { font: inherit; }
.um-hits { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button { font-size: .92rem; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; }
label.check input { width: auto; margin-top: 3px; }
#imp-preview .stats div { font-size: .85rem; }
