:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e6e5e0;
  --border: #e0dfda;
  --border-strong: #c9c8c1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #85847e;
  --accent: #2a78d6;
  --accent-soft: #e3eefb;
  --accent-text: #1c5cab;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-soft: #fbe7e7;
  --warning-soft: #fff4dc;
  --good-soft: #e3f5e3;
  --bubble-in: #ffffff;
  --bubble-out: #dcebfd;
  --line: #06c755;
  --facebook: #0866ff;
  --instagram: #e1306c;
  --whatsapp: #25d366;
  --manual: #85847e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --radius: 10px;
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2d2d2a;
    --border: #2f2f2c; --border-strong: #45453f; --text: #f0efec; --text-2: #c3c2b7; --text-3: #8d8c84;
    --accent: #3987e5; --accent-soft: #1d2d42; --accent-text: #86b6ef;
    --critical-soft: #3a1f1f; --warning-soft: #3a3120; --good-soft: #1d3320;
    --bubble-in: #232321; --bubble-out: #1d3352;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2d2d2a;
  --border: #2f2f2c; --border-strong: #45453f; --text: #f0efec; --text-2: #c3c2b7; --text-3: #8d8c84;
  --accent: #3987e5; --accent-soft: #1d2d42; --accent-text: #86b6ef;
  --critical-soft: #3a1f1f; --warning-soft: #3a3120; --good-soft: #1d3320;
  --bubble-in: #232321; --bubble-out: #1d3352;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* Text size: the phone / browser setting (100%) × the in-app choice (--ts, ขนาดตัวอักษร). Every font size is in rem. */
html { font-size: calc(100% * var(--ts, 1)); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 0.875rem/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.25rem; font-weight: 600; }
h2 { font-size: 1rem; font-weight: 600; }
h3 { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 0.75rem; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.hidden { display: none !important; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; min-height: 34px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 3px 8px; min-height: 28px; font-size: 0.75rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 10px; min-height: 34px; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--text-2); font-weight: 500; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; background: var(--surface-2);
  color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.chip.good { background: var(--good-soft); color: var(--text); border-color: transparent; }
.chip.share-chip { background: var(--good-soft); color: var(--good); border-color: transparent; font-weight: 600; flex: none; }
.chip.warn { background: var(--warning-soft); color: var(--text); border-color: transparent; }
.chip.crit { background: var(--critical-soft); color: var(--critical); border-color: transparent; font-weight: 600; }
.chip .dot, .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; border-radius: 4px; font-size: 0.6875rem; font-weight: 600; color: #fff; line-height: 1.6; }

.ch { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; color: #fff; font-size: 0.625rem; font-weight: 700; flex: none; }
.ch.line { background: var(--line); } .ch.facebook { background: var(--facebook); } .ch.instagram { background: var(--instagram); }
.ch.whatsapp { background: var(--whatsapp); } .ch.manual { background: var(--manual); }

.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; color: var(--text-2);
  position: relative; flex: none; overflow: visible; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .ch { position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; font-size: 0.5625rem; border: 2px solid var(--surface); box-sizing: content-box; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card.pad { padding: 16px; }
.section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.empty { padding: 40px 16px; text-align: center; color: var(--text-3); }

/* status pills: icon + label, never color alone */
.st { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 500; white-space: nowrap; }
.st::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--text-3); }
.st.new::before { background: var(--text-3); }
.st.ongoing::before { background: var(--accent); }
.st.call::before { background: #1f8fbf; border-radius: 50%; }
.st.first_room::before { background: #6a5acd; border-radius: 2px; }
.st.visit::before { background: #6250d6; }
.st.reserve::before { background: var(--warning); }
.st.won::before { background: var(--good); border-radius: 50%; }
.st.lost::before { background: var(--critical); }

.timer { font-variant-numeric: tabular-nums; font-size: 0.75rem; font-weight: 600; padding: 0 6px; border-radius: 4px; white-space: nowrap; }
.timer.ok { color: var(--text-2); background: var(--surface-2); }
.timer.warn { color: var(--text); background: var(--warning-soft); }
.timer.warn::before { content: '⏱ '; }
.timer.crit { color: #fff; background: var(--critical); }
.timer.crit::before { content: '⚠ '; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 64px 1fr; height: 100vh; height: 100dvh; }
.rail { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; }
.rail .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 10px; }
.rail a { width: 52px; padding: 7px 0 5px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-2);
  text-decoration: none; font-size: 0.625rem; position: relative; }
.rail a svg { width: 20px; height: 20px; }
.rail a:hover { background: var(--surface-2); color: var(--text); }
.rail a.active { background: var(--accent-soft); color: var(--accent-text); }
.rail .badge { position: absolute; top: 2px; right: 6px; background: var(--critical); color: #fff; border-radius: 999px; font-size: 0.625rem; padding: 0 5px; line-height: 1.6; font-weight: 700; }
.rail .spacer { flex: 1; }
.rail .me { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; cursor: pointer; position: relative; border: 0; }
.rail .me .on { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface); background: var(--text-3); }
.rail .me .on.yes { background: var(--good); }
main.page { overflow: auto; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; flex-wrap: wrap; }
.page-body { padding: 0 20px 24px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr 58px; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 4px; border-right: 0; border-top: 1px solid var(--border); overflow-x: auto; }
  .rail .logo, .rail .spacer { display: none; }
  .rail a { width: auto; min-width: 48px; padding: 4px 6px; }
  .page-head, .page-body { padding-left: 16px; padding-right: 16px; }
}

/* ---------- inbox */
.inbox { display: grid; grid-template-columns: 340px 1fr 340px; height: 100%; min-height: 0; }
.inbox > * { min-height: 0; min-width: 0; }
.list-pane { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; }
.list-head { padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.scopes { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.scopes button { border: 0; background: var(--surface-2); color: var(--text-2); padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; cursor: pointer; white-space: nowrap; }
.scopes button.on { background: var(--text); color: var(--surface); }
.scopes button .n { font-weight: 700; margin-left: 2px; }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
.conv.unread .name { font-weight: 700; }
.conv.unread::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.conv .name { font-weight: 500; }
.conv .preview { color: var(--text-2); font-size: 0.8125rem; }
.conv .meta { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.conv .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.unread-n { background: var(--critical); color: #fff; font-size: 0.6875rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; }

.chat-pane { display: flex; flex-direction: column; background: var(--bg); }
.chat-head { padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; min-height: 60px; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; font-size: 0.6875rem; color: var(--text-3); background: var(--surface-2); padding: 1px 10px; border-radius: 999px; margin: 8px 0; }
.msg { max-width: min(560px, 78%); display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.system { align-self: center; max-width: 90%; }
.msg.system .bubble { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-2); font-size: 0.75rem; }
.bubble { padding: 7px 11px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, .04); }
.msg.in .bubble { background: var(--bubble-in); border-top-left-radius: 4px; border: 1px solid var(--border); }
.msg.out .bubble { background: var(--bubble-out); border-top-right-radius: 4px; }
.msg.comment .bubble { border-left: 3px solid var(--facebook); }
.msg.hidden-c .bubble { opacity: .5; }
.bubble img { max-width: 260px; max-height: 260px; border-radius: 8px; display: block; }
.msg .info { font-size: 0.6875rem; color: var(--text-3); margin: 2px 4px 6px; display: flex; gap: 6px; align-items: center; }
.msg .info .fail { color: var(--critical); font-weight: 600; }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 8px 12px; position: relative; }
.composer textarea { border: 0; resize: none; min-height: 44px; max-height: 180px; padding: 6px 2px; background: transparent; }
.composer textarea:focus { outline: none; }
.composer .tools { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.composer .warnline { font-size: 0.75rem; color: var(--text); background: var(--warning-soft); padding: 4px 8px; border-radius: 6px; margin-bottom: 6px; }
.composer .warnline.crit { background: var(--critical-soft); }
.composer .modes { display: flex; gap: 4px; margin-bottom: 4px; }
.composer .modes button { border: 0; background: transparent; color: var(--text-2); font-size: 0.75rem; padding: 3px 8px; border-radius: 6px; cursor: pointer; }
.composer .modes button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.composer .modes button:disabled { opacity: .4; cursor: not-allowed; }
.composer textarea.note-mode { background: var(--warning-soft); border-radius: 8px; padding: 6px 8px; }
.msg.note { align-self: center; max-width: min(620px, 92%); }
.msg.note .bubble { background: var(--warning-soft); border: 1px dashed var(--warning, #c98a00); color: var(--text); font-size: 0.8125rem; }
.msg.note.sys .bubble { background: transparent; border-style: dotted; color: var(--text-2); font-size: 0.75rem; }
.msg.note .info { justify-content: center; }
.msg .mention { color: var(--accent); }
.chat-head .presence { font-size: 0.75rem; color: var(--accent); min-height: 0; }
.chat-head .presence:empty { display: none; }
.chat-head .presence .typing { font-weight: 600; }
.list-head .bulk { background: var(--surface-2); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.conv .pick { flex: none; width: 18px; height: 18px; margin: 0 2px 0 0; }
.popup { position: absolute; bottom: 100%; left: 12px; right: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto; z-index: 20; }
.popup .item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.popup .item:hover, .popup .item.sel { background: var(--accent-soft); }

.side-pane { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.tabs { display: flex; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px 6px; cursor: pointer; color: var(--text-2); font-size: 0.8125rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 0.8125rem; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.policy { font-size: 0.75rem; padding: 8px 10px; border-radius: 8px; display: flex; gap: 6px; }
.policy.warn { background: var(--warning-soft); }
.policy.crit { background: var(--critical-soft); }
.policy.good { background: var(--good-soft); }
.policy.info { background: var(--accent-soft); }

@media (max-width: 1200px) {
  .inbox { grid-template-columns: 300px 1fr; }
  .inbox .side-pane { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 100vw); z-index: 30; box-shadow: var(--shadow); transform: translateX(100%); transition: transform .2s; }
  .inbox.show-side .side-pane { transform: none; }
}
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox .chat-pane { display: none; }
  .inbox.has-chat .list-pane { display: none; }
  .inbox.has-chat .chat-pane { display: flex; }
}

/* ---------- tables */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.t { border-collapse: collapse; width: 100%; font-size: 0.8125rem; }
table.t th, table.t td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.t th { background: var(--surface-2); font-weight: 600; color: var(--text-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; font-size: 0.75rem; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.wrap-cell { min-width: 200px; max-width: 320px; white-space: pre-wrap; }
table.t td.miss { color: var(--critical); font-size: 0.75rem; }
table.sheet td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: 0.75rem; color: var(--text-2); }
.kpi .value { font-size: 1.625rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.kpi .sub { font-size: 0.75rem; color: var(--text-3); }
.kpi.crit .value { color: var(--critical); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
@media (max-width: 760px) { .dash-grid { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 12px 14px; overflow: auto; max-height: 420px; }
.panel-body.flush { padding: 0; }
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 0.75rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap;
  transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; }
.chart .tip.on { opacity: 1; }
.rank { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 0.75rem; background: var(--surface-2); }
.rank.r1 { background: var(--accent); color: #fff; }

/* ---------- misc */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); box-shadow: var(--shadow); border-radius: 10px; padding: 10px 12px; cursor: pointer; animation: tin .2s; }
.toast.crit { border-left-color: var(--critical); }
.toast.good { border-left-color: var(--good); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal .mh { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal .mb { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 40; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface); z-index: 41; overflow-y: auto; box-shadow: var(--shadow); }
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.settings-nav button { border: 1px solid var(--border); background: var(--surface); padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--text-2); }
.settings-nav button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.setting-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; max-width: 900px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: 0.75rem; }
.ok-badge { color: var(--good); font-weight: 600; }
.ok-badge::before { content: '● '; }
.no-badge { color: var(--text-3); }
.no-badge::before { content: '○ '; }
.result { font-size: 0.75rem; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; }
.result.ok { background: var(--good-soft); }
.result.err { background: var(--critical-soft); }
.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px 12px; font-size: 0.8125rem; }
kbd { font-family: ui-monospace, Menlo, monospace; font-size: 0.6875rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface-2); }

/* back button only on phones; the side panel close button only when it floats */
.chat-head .back-myday { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px 4px 4px; font-size: 0.75rem; color: var(--text-2); }
@media (max-width: 760px) { .chat-head .back-myday .hide-sm { display: none; } }
@media (min-width: 1201px) { .inbox .side-pane [data-close] { display: none; } }

/* Shown while the account still uses a published default password; sits bottom-left so it never covers headers */
.sysbar { position: fixed; left: 76px; bottom: 12px; z-index: 60; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: calc(100vw - 92px); pointer-events: none; }
.sysbar > * { pointer-events: auto; max-width: 100%; }
.sysbar [data-power]:empty { display: none; }
.weak-pw { display: flex; align-items: center; gap: 8px; background: var(--critical-soft); color: var(--text); border: 1px solid var(--critical); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 0.8125rem; box-shadow: 0 2px 8px rgb(0 0 0 / .12); max-width: 100%; }
.weak-pw.power { background: var(--warning-soft); border-color: var(--warning); border-radius: 12px; padding: 6px 14px; line-height: 1.4; }
.weak-pw.power.low { background: var(--critical-soft); border-color: var(--critical); }
.weak-pw a { color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weak-pw button { border: 0; background: transparent; cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 6px; color: var(--text-2); }
@media (max-width: 760px) {
  .sysbar { left: 8px; right: 8px; bottom: 64px; max-width: none; }
  /* Never cover the composer while a chat is open */
  .shell:has(.inbox.has-chat) ~ .sysbar { display: none; }
  /* Bottom nav: every item shares the width so the account button stays fully visible at 375px */
  .rail a { flex: 1 1 0; min-width: 0; padding: 4px 2px; }
  .rail a span { font-size: 0.625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .rail .me { flex: 0 0 32px; width: 32px; height: 32px; margin: 0 4px; }
  /* Composer stays on one row: the quick-reply picker shrinks instead of pushing Send down */
  .composer .tools { flex-wrap: nowrap; }
  .composer .tools select { flex: 1 1 auto; min-width: 0; max-width: none !important; }
  .composer .tools .grow { display: none; }
}

/* Pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 10px; padding: 0 20px 20px; overflow-x: auto; align-items: start; height: calc(100% - 110px); }
.kcol { background: var(--surface-2); border-radius: 12px; display: flex; flex-direction: column; max-height: 100%; min-height: 120px; border: 2px solid transparent; }
.kcol.over { border-color: var(--accent); }
.kcol.closed { opacity: .85; }
.kcol header { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px; }
.kcards { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px 10px; overflow-y: auto; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; cursor: grab; }
.kcard:hover { border-color: var(--border-strong); }
.kcard.dragging { opacity: .4; }
@media (max-width: 760px) { .board { padding: 0 16px 16px; grid-auto-columns: 82vw; height: auto; } }

/* Live team board */
.live td.num b.bad { color: var(--critical); }
.live .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 6px; vertical-align: middle; }
.live .dot.on { background: var(--good); }
.page-head select, .page-head input[type=search] { width: auto; max-width: 220px; }

/* Stage replies above the composer */
.stage-chips { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; overflow-x: auto; scrollbar-width: none; }
.stage-chips > * { flex: none; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 0.8125rem; cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Dashboard trends */
.chart.mini { margin-top: 2px; }
.heat-key { display: inline-block; width: 80px; height: 10px; border-radius: 3px; background: linear-gradient(to right, color-mix(in srgb, var(--accent) 12%, transparent), var(--accent)); }
.up { color: var(--good); font-weight: 600; }
.down { color: var(--critical); font-weight: 600; }
.qrow { border-bottom: 1px solid var(--border); }

/* WhatsApp leads answered in Business Suite */
.bs-panel { border: 1px solid var(--border); border-left: 3px solid #25d366; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.btn.good { border-color: var(--good); color: var(--good); }
.btn.wa { border-color: #25d366; color: #128c4b; }
.bs-panel a.btn { text-decoration: none; align-self: flex-start; }

/* Guide */
.guide { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.guide-toc { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 8px; }
.guide-toc a { padding: 8px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 0.875rem; }
.guide-toc a:hover { background: var(--surface-2); }
.guide-toc a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.guide-steps { padding-left: 22px; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; }
.guide-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.page-head .help-link { margin-left: 4px; }
@media (max-width: 760px) {
  .guide { grid-template-columns: 1fr; }
  .guide-toc { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .guide-toc a { white-space: nowrap; flex: none; border: 1px solid var(--border); }
}

/* Team: stations and performance */
.pref-grid select { width: auto; min-width: 120px; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.warn-card { background: var(--warning-soft); }
.queue-box { background: var(--warning-soft); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; display: grid; gap: 6px; }
.queue-box select { width: auto; max-width: 200px; }
.auto-info { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.auto-info .chip { font-size: 0.6875rem; }
.chip.auto { border-style: dashed; }
.auto-info { cursor: pointer; }
.chip.miss { color: var(--text-3); background: transparent; border: 1px dashed var(--border); }
.crit-line { font-size: 0.6875rem; color: var(--text-2); margin-top: 1px; white-space: normal; overflow-wrap: anywhere; }
/* One-click sale-stage question in the chat header */
.stage-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); border: 1px solid var(--accent); font-size: 0.8125rem; }
.stage-ask .grow { min-width: 200px; }
.btn.on { background: var(--accent-soft); }
.tally-add { padding: 0 4px; min-height: 0; font-size: 0.75rem; opacity: .55; } .tally-add:hover { opacity: 1; }

/* Backup mode: the site can't reach its server, or WhatsApp is disconnected — where to answer meanwhile */
[data-backup]:empty { display: none; }
.backup-mode { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 80; width: min(760px, calc(100vw - 16px)); display: flex; flex-direction: column; gap: 6px; background: var(--warning-soft); color: var(--text); border: 1px solid var(--warning); border-radius: 12px; padding: 10px 14px; font-size: 0.875rem; box-shadow: 0 4px 16px rgb(0 0 0 / .18); }
.backup-mode.crit { background: var(--critical-soft); border-color: var(--critical); }
.backup-mode .btn { text-decoration: none; }

/* Sales page */
.field.compact { min-width: 150px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.kpi { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--text); text-decoration: none; }
.kpi b { font-size: 1.375rem; font-variant-numeric: tabular-nums; }
a.kpi:hover { border-color: var(--accent); }
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 96px 1fr 48px 48px; align-items: center; gap: 8px; font-size: 0.8125rem; }
.funnel-row .fbar { display: block; height: 18px; border-radius: 0 4px 4px 0; background: var(--surface-2, transparent); }
.funnel-row .fbar span { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--accent); }
.funnel-row .fbar:hover span { opacity: .8; }
.funnel-row .fv { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .funnel-row { grid-template-columns: 76px 1fr 40px 40px; } }
/* Lead slots planner */
.day-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.day-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 84px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.day-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.howto { padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); }
.plan-t .cond-row td { border-top: 0; padding-top: 0; }
.cond { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.cond .field { min-width: 260px; flex: 1; }
.cond textarea { width: 100%; resize: vertical; }
.zone-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.queue-rule { margin-top: 4px; padding: 6px 8px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; white-space: pre-wrap; }

/* The customer's 5 criteria: one-colour icons (Noto Emoji), everything else keeps its colours */
.crit .k, .crit-line, .crit-cell { font-family: 'IBM Plex Sans Thai', 'Noto Emoji', system-ui, sans-serif; }
/* The customer's 5 criteria in the chat header: always written out in full */
.crit-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px; margin-top: 6px; }
.crit { border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; min-width: 0; background: var(--surface); }
.crit.auto { border-style: dashed; }
.crit.miss { background: transparent; border-style: dashed; }
.crit .k { display: block; font-size: 0.6875rem; color: var(--text-3); }
.crit .v { display: block; font-size: 0.8125rem; font-weight: 600; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.crit.miss .v { font-weight: 400; color: var(--text-3); }
/* Deal move requests */
.move-req { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.move-req:first-of-type { border-top: 0; }
/* Live sales updates */
.feed { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.feed-row { display: flex; gap: 8px; align-items: baseline; padding: 5px 2px; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 0.8125rem; }
.feed-row:first-child { border-top: 0; }
.feed-row:hover { background: var(--surface-2); }
.feed-row .fk { font-size: 0.6875rem; width: 14px; flex: none; }
.feed-row.good .fk { color: var(--good, #2e8540); }
.feed-row.bad .fk { color: var(--critical); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); margin-right: 4px; vertical-align: middle; animation: live 1.6s infinite; }
@keyframes live { 50% { opacity: .3; } }
/* Slot week board */
.slot-board th.today { background: var(--accent-soft); }
.slot-board td.slot-cell { padding: 4px; vertical-align: top; min-width: 96px; }
.slot-add { width: 100%; min-height: 42px; border: 1px dashed var(--border); border-radius: 8px; background: transparent; color: var(--text-3); font-size: 1.125rem; cursor: pointer; }
.slot-add { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.slot-add .small { font-size: 0.625rem; }
.slot-add:hover { border-color: var(--accent); color: var(--accent); }
.slot-box { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 5px 8px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft); color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.slot-box:disabled { cursor: default; opacity: .75; border-color: var(--border); background: var(--surface-2); }
.crit-text { color: var(--critical); }
.day-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; }
.day-pick label { display: flex; gap: 4px; align-items: center; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.8125rem; cursor: pointer; }
.day-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
/* วันนี้ของฉัน */
.myday { width: min(760px, 100%); margin: 0 auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.myday h3 { margin: 0; font-size: 0.9375rem; }
.myday .check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong, var(--border)); display: inline-grid; place-items: center; font-size: 0.75rem; flex: none; }
.myday .check.ok { background: var(--good); border-color: var(--good); color: #fff; }
.todo-row { display: block; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 0.8125rem; }
.todo-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.chat-pane:has(.myday) { overflow-y: auto; }

.chip.owner { font-weight: 600; color: var(--text); }
.perf-line { color: var(--text-2); margin: 2px 0; white-space: nowrap; }
/* Station priority picker */
.pref-pick td { padding: 4px 6px; vertical-align: middle; }
.pri { display: inline-flex; gap: 4px; align-items: center; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.75rem; cursor: pointer; white-space: nowrap; }
.pri input { margin: 0; }
.pri:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.pri.no:has(input:checked) { border-color: var(--critical); background: var(--critical-soft); }
.pref-line { color: var(--text-2); max-width: 260px; }
.sheet tr.day-head td { background: var(--surface-2); position: sticky; left: 0; padding: 6px 10px; }
.sheet tr.day-head td { max-width: none; overflow: visible; }
.day-table input[type=number] { width: 58px; }
.day-table tfoot td { border-top: 2px solid var(--border); background: var(--surface-2); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.link-ask { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 8px; }
.link-bar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 80; width: min(760px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px; border-radius: 12px; border: 2px solid var(--accent); background: var(--surface); box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 0.875rem; }
.slot-sug { display: flex; flex-direction: column; gap: 3px; }
.slot-box.sug { border-style: dashed; background: transparent; }
/* Chat list: number · phone · owner, then the 5 criteria with labels */
.row-facts { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.75rem; color: var(--text-2); margin-top: 2px; }
.row-crit { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 0.7188rem; color: var(--text-2); margin-top: 2px; font-family: 'IBM Plex Sans Thai', 'Noto Emoji', system-ui, sans-serif; }
.row-crit b { color: var(--text); font-weight: 600; }
.warn-text { color: var(--warning, #b7791f); font-weight: 600; }
.review-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.review-row:first-of-type { border-top: 0; }
/* Budget colours: stronger as the budget rises */
.bud { display: inline-flex; align-items: center; padding: 0 7px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.bud.b10 { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.bud.b15 { background: #e6f0fb; color: #1d4f8a; }
.bud.b20 { background: #fde7c2; color: #7a4a00; }
.bud.b25 { background: #f6a33a; color: #2b1700; }
.bud.b30 { background: #c2185b; color: #fff; box-shadow: 0 0 0 2px #f8bbd0; }
.conv.hb { border-left: 4px solid transparent; }
.conv.hb.b20 { border-left-color: #f2c26b; }
.conv.hb.b25 { border-left-color: #f6a33a; }
.conv.hb.b30 { border-left-color: #c2185b; background: color-mix(in srgb, #c2185b 6%, transparent); }
.crit.bud-box.b20 { border-color: #f2c26b; background: #fff6e5; }
.crit.bud-box.b25 { border-color: #f6a33a; background: #fdebd2; }
.crit.bud-box.b30 { border-color: #c2185b; background: #fce4ec; }
.crit-line-strong { font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .crit.bud-box.b20, :root:not([data-theme="light"]) .crit.bud-box.b25, :root:not([data-theme="light"]) .crit.bud-box.b30 { background: transparent; } }
:root[data-theme="dark"] .crit.bud-box.b20, :root[data-theme="dark"] .crit.bud-box.b25, :root[data-theme="dark"] .crit.bud-box.b30 { background: transparent; }

/* 👁 look at a chat without marking it read */
.conv .peek-btn { padding: 2px 6px; font-size: 0.75rem; }
.peek-msgs { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--surface-2); border-radius: 8px; }
.conv .preview.side-in b { color: var(--text-2); font-weight: 600; }
.conv .preview.side-out b { color: var(--accent, var(--text)); font-weight: 600; }

/* Customer quality check */
.chip.crit-soft { background: var(--critical-soft); color: var(--text); border-color: transparent; }
.cq-box { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; margin-top: 6px; display: grid; gap: 3px; background: var(--surface-2); }
.cq-box.cq-A { border-color: color-mix(in srgb, var(--good, #2e9e6b) 45%, var(--border)); }
.cq-box.cq-C { border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); }
.cq-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cq-row { display: grid; grid-template-columns: 110px 70px 38px 1fr; gap: 6px; align-items: center; font-size: 0.75rem; }
.cq-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.cq-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.cq-n { text-align: right; font-variant-numeric: tabular-nums; }
.cq-why { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cq-row:hover .cq-why { white-space: normal; }
@media (max-width: 640px) { .cq-row { grid-template-columns: 90px 50px 34px; } .cq-why { grid-column: 1 / -1; white-space: normal; } }

/* Sale Tracking: stage set by hand, and what is late */
.t.sheet .mn { font-size: 0.6875rem; color: #9a6700; margin-left: 2px; }
.t.sheet .delay-tag { font-size: 0.6875rem; line-height: 1.3; margin-top: 2px; white-space: nowrap; color: var(--critical, #c0392b); }
.t.sheet .delay-tag.quiet { color: var(--text-2); }

/* ------------------------------------------------------------------ calm, neutral look (2026-11-03)
   Colour only where it asks for action: a customer waiting past the limit, a take-over, a must-send room.
   Everything else is black / grey on white, so the eye goes to what needs doing. */
.ch, .ch.line, .ch.facebook, .ch.instagram, .ch.whatsapp, .ch.manual { background: var(--surface); color: var(--text-2); border: 1px solid var(--border-strong); }
.avatar .ch { border-width: 1px; box-shadow: 0 0 0 2px var(--surface); }
.st::before, .st.new::before, .st.ongoing::before, .st.first_room::before, .st.call::before, .st.visit::before, .st.reserve::before, .st.won::before, .st.lost::before { background: var(--text-3); border-radius: 50%; }
.st { color: var(--text-2); }
.chip.accent, .chip.good, .chip.warn { background: var(--surface-2); color: var(--text); }
.bud, .bud.b10, .bud.b15, .bud.b20, .bud.b25, .bud.b30 { background: transparent; color: var(--text); box-shadow: none; padding: 0; font-weight: 600; }
.conv.hb, .conv.hb.b20, .conv.hb.b25, .conv.hb.b30 { border-left: 3px solid transparent; }
.conv.hb.b20, .conv.hb.b25, .conv.hb.b30 { border-left-color: var(--text); }
.timer.ok, .timer.warn { color: var(--text-2); background: transparent; }
.timer.warn::before { content: ''; }
.unread-n { background: var(--accent); }
.stage-ask { background: var(--surface); border-color: var(--border-strong); }
.tag { filter: saturate(.35); }

/* List row: name · last message · what they want · owner/stage · one action */
.conv .l2 { font-size: 0.8125rem; color: var(--text-2); }
.conv .l2 b { color: var(--text); font-weight: 600; }
.conv .l3 { font-size: 0.75rem; color: var(--text-2); margin-top: 1px; }
.conv .l4 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.75rem; color: var(--text-3); margin-top: 3px; }
.conv .l4 .owner-none { color: var(--critical); font-weight: 600; }
.conv .act { font-size: 0.75rem; font-weight: 600; color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 6px; }
.conv .act.urgent { color: #fff; background: var(--critical); border-color: var(--critical); }
.grade { font-size: 0.6875rem; font-weight: 700; color: var(--text-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }

/* Chat head: one line of who / where / owner / stage */
.chat-head .sub { font-size: 0.75rem; color: var(--text-2); }
.chat-head .sub .mn { color: var(--text); font-weight: 600; }

/* Advisor panel (right): read top to bottom */
.adv { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 18px; }
.adv h4 { margin: 0 0 6px; font-size: 0.6875rem; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.adv .todo { display: flex; flex-direction: column; gap: 6px; }
.adv .todo .it { display: flex; gap: 8px; align-items: flex-start; font-size: 0.8125rem; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.adv .todo .it.urgent { border-color: var(--critical); }
.adv .todo .it.urgent b { color: var(--critical); }
.adv .todo .it .grow { min-width: 0; }
.adv .todo .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.adv .big { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; }
.adv ul { margin: 4px 0 0; padding-left: 18px; font-size: 0.8125rem; color: var(--text-2); }
.adv ul li { margin: 2px 0; }
.adv .wants { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 0.8125rem; }
.adv .wants dt { color: var(--text-3); }
.adv .wants dd { margin: 0; font-weight: 600; }
.adv .wants dd.miss { font-weight: 400; color: var(--text-3); }
.adv .mk { font-size: 0.8125rem; display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--border); }
.adv .mk span:last-child { color: var(--text-2); white-space: nowrap; }
.adv .fit { font-weight: 600; font-size: 0.8125rem; margin-top: 6px; }
.adv .opt { margin-top: 8px; }
.adv .opt .st-name { font-size: 0.8125rem; font-weight: 600; }
.adv .opt .st-name small { font-weight: 400; color: var(--text-3); }
.adv .opt .condos { font-size: 0.8125rem; color: var(--text-2); }
.adv .script { white-space: pre-wrap; font-size: 0.8125rem; line-height: 1.55; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.adv details summary { cursor: pointer; font-size: 0.75rem; color: var(--text-3); }
.adv .muted-line { font-size: 0.75rem; color: var(--text-3); }

.my-rank { margin-bottom: 12px; }
.t tr.me td { background: var(--surface-2); font-weight: 600; }

/* Follow-up batch */
.fu-list { display: flex; flex-direction: column; gap: 14px; max-height: 62vh; overflow: auto; margin-top: 8px; }
.fu-head { justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.fu-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.fu-row textarea { width: 100%; margin-top: 6px; font-size: 0.8125rem; }
.fu-row.off { opacity: .55; }
.fu-row.sent { opacity: .6; }

/* Demo lab */
.demo-lab { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; }
.dl-intro p { color: var(--text-2); }
.dl-progress { font-size: 0.8125rem; color: var(--text-2); margin-bottom: 6px; }
.dl-steps { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; }
.dl-steps li { display: flex; gap: 8px; font-size: 0.8125rem; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.dl-steps li .tick { width: 18px; height: 18px; flex: none; border: 1px solid var(--border-strong); border-radius: 50%; display: grid; place-items: center; font-size: 0.6875rem; }
.dl-steps li.done { color: var(--text-3); }
.dl-steps li.done .tick { background: var(--text); color: var(--surface); border-color: var(--text); }
.dl-cust { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 6px; background: var(--surface); }
.dl-custs h4 { margin: 0; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.dl-phones { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }
.dl-trig { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; background: var(--surface); }
.dl-trig h4 { margin: 0; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.phone { border: 1px solid var(--border-strong); border-radius: 16px; background: #8ca0b8; display: flex; flex-direction: column; height: 72vh; overflow: hidden; }
.ph-head { background: var(--surface); padding: 8px 12px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); }
.ph-body { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ph-bot { align-self: flex-start; background: #fff; color: #111; border-radius: 14px; padding: 8px 12px; max-width: 88%; white-space: pre-wrap; font-size: 0.8125rem; }
.ph-me { align-self: flex-end; background: #8de055; color: #111; border-radius: 14px; padding: 8px 12px; max-width: 80%; font-size: 0.8125rem; }
.ph-quick { display: flex; flex-wrap: wrap; gap: 4px; }
.ph-quick .btn, .ph-quick label.btn { background: #fff; color: #111; border-color: #fff; border-radius: 999px; }
.ph-quick input[type=date] { width: 0; opacity: 0; position: absolute; }
.ph-quick label.btn { position: relative; }
.ph-input { display: flex; gap: 6px; padding: 8px; background: var(--surface); border-top: 1px solid var(--border); }
.ph-input input { flex: 1; }
.fx-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.fx-card { flex: none; width: 260px; background: #fff; color: #111; border-radius: 14px; display: flex; flex-direction: column; align-self: flex-start; overflow: hidden; }
.fx-head { padding: 11px 12px; display: flex; flex-direction: column; gap: 2px; color: #fff; }
.fx-bd { padding: 11px 12px; display: flex; flex-direction: column; gap: 4px; }
.fx-sep { border-top: 1px solid #eee; margin: 4px 0; }
.fx-t.fx-xxs { font-size: 0.625rem; } .fx-t.fx-xs { font-size: 0.6875rem; } .fx-t.fx-sm { font-size: 0.7812rem; } .fx-t.fx-lg { font-size: 0.9375rem; } .fx-t.fx-xl { font-size: 1.0625rem; } .fx-t.fx-xxl { font-size: 1.25rem; } .fx-t.fx-c { text-align: center; }
.fx-t { font-size: 0.8125rem; white-space: pre-wrap; }
.fx-t.b { font-weight: 700; font-size: 0.875rem; }
.fx-t.mute { color: #8a8a8a; } .fx-t.xs { font-size: 0.6875rem; }
.fx-kv { display: grid; grid-template-columns: 34% 1fr; gap: 6px; font-size: 0.75rem; }
.fx-kv .k { color: #8a8a8a; } .fx-kv .v { font-weight: 600; }
.fx-box { display: flex; flex-direction: column; gap: 3px; }
.fx-foot { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 12px; }
.fx-foot .btn { justify-content: center; }
.fx-foot .btn.primary { background: #111; border-color: #111; color: #fff; }
@media (max-width: 900px) { .demo-lab { grid-template-columns: minmax(0, 1fr); } }
.demo-lab > * { min-width: 0; }

/* Overview (numbers first) */
.home-scroll { overflow: auto; height: 100%; padding: 16px; }
.ov { margin-bottom: 18px; }
.ov-head h3 { font-size: 0.9375rem; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 8px; }
.ov-card { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.ov-card.hot { border-color: var(--text); }
.ov-big { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.ov-big b { font-size: 1.75rem; line-height: 1; }
.ov-big span { font-size: 0.8125rem; color: var(--text-2); }
.ov-item { display: flex; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; padding: 5px 4px; border-radius: 6px; font: inherit; font-size: 0.8125rem; color: var(--text); cursor: pointer; text-align: left; }
.ov-item:hover:not([disabled]) { background: var(--surface-2); }
.ov-item.zero { color: var(--text-3); cursor: default; }
.ov-item.urgent b { color: var(--critical); }
.ov-note { font-size: 0.6875rem; color: var(--text-3); margin-top: 4px; }
.group-banner { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 0.8125rem; font-weight: 600; position: sticky; top: 0; z-index: 1; }
.ph-body > * { flex-shrink: 0; }
button.chip { cursor: pointer; font: inherit; font-size: 0.75rem; }
.chip.on { background: var(--text); color: var(--surface); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.composer .warnline.good { background: var(--good-soft); }
.dl-sheet, .dl-share { margin-top: 14px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.dl-sheet h4, .dl-share h4 { margin: 0; }
.dl-sheet-wrap { overflow-x: auto; margin-top: 6px; }
.dl-sheet-t { border-collapse: collapse; font-size: 0.75rem; width: 100%; margin-top: 6px; }
.dl-sheet-t th, .dl-sheet-t td { border: 1px solid var(--border); padding: 3px 6px; text-align: left; white-space: nowrap; }
.dl-sheet-t th { background: var(--surface-2); font-weight: 600; }
/* Calendar */
.cal { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .cal { grid-template-columns: 1fr; } }
.cal-sum { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 22px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 0.75rem; color: var(--text-muted, #777); text-align: center; padding: 2px 0; }
.cal-cell { all: unset; box-sizing: border-box; cursor: pointer; min-height: 92px; padding: 4px 5px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-cell.out { opacity: .45; }
.cal-cell.today .n { background: var(--text); color: var(--surface); border-radius: 999px; padding: 0 6px; }
.cal-cell.sel { outline: 2px solid var(--text); outline-offset: -1px; }
.cal-cell .n { font-size: 0.75rem; font-weight: 600; align-self: flex-start; }
.cal-cell .ev { font-size: 0.6875rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted, #666); }
.cal-cell .ev.appt { color: var(--text); }
.cal-cell .ev.done { text-decoration: line-through; opacity: .6; }
.cal-cell .more { font-size: 0.6875rem; color: var(--text-muted, #777); }
.cal-day { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 10px; position: sticky; top: 8px; }
.cal-item { padding: 8px 0; border-top: 1px solid var(--border); }
.cal-item .t { min-width: 44px; font-variant-numeric: tabular-nums; }
.cal-item.done { opacity: .6; }
.btn.hint { box-shadow: inset 0 0 0 1px var(--text); }
label.chip { cursor: pointer; }
/* Stations picker */
.st-page { max-width: 980px; }
.st-sum { position: sticky; top: 0; z-index: 2; background: var(--bg, var(--surface)); padding: 8px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.st-zone { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 8px 10px; margin-bottom: 10px; }
.st-zone summary { cursor: pointer; padding: 4px 0; }
.st-zh { gap: 8px; align-items: center; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.st-row { display: flex; align-items: center; gap: 8px; padding: 3px 0 3px 12px; }
.st-row .n { min-width: 70px; text-align: right; }
.st-line { margin: 8px 0; }
.tag { font-size: 0.6875rem; padding: 0 5px; border-radius: 4px; background: var(--surface-2); color: var(--text-muted, #666); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { all: unset; cursor: pointer; padding: 3px 8px; font-size: 0.8125rem; border-left: 1px solid var(--border); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--text); color: var(--surface); }
.seg button.on.soft { background: var(--surface-2); color: var(--text); }
@media (max-width: 640px) { .seg .lbl { display: none; } }
.adv .expert ol.tactics { margin: 4px 0 6px; padding-left: 18px; }
.adv .expert ol.tactics li { margin: 3px 0; line-height: 1.4; }
.adv .protocol { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }
.adv .protocol .check { display: block; font-size: 0.8125rem; margin: 2px 0; }
.adv .bc { margin-top: 6px; }
.adv .bc-add input, .adv .bc-add select { font-size: 0.75rem; padding: 2px 4px; }

/* One-scan codes for linking LINE to the team bot */
.code-qrs { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0; }
.code-qr { margin: 0; text-align: center; }
.code-qr img { background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--border, #ddd); display: block; }
.code-qr figcaption { margin-top: 4px; }

/* One-colour line icons that replace emoji (js/glyphs.js) */
.gl { width: 1.05em; height: 1.05em; vertical-align: -0.17em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.gl-fill { fill: currentColor; stroke: none; }
.gl-w { display: inline; white-space: nowrap; }

/* Link-by-code: a code to type on the phone */
.pair-code { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--border, #ddd); border-radius: 10px; }
.big-code { font-size: 2.125rem; font-weight: 700; letter-spacing: 4px; font-variant-numeric: tabular-nums; }

/* Demo Lab: features grouped, each one playable */
.dl-play { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.dl-group { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin-bottom: 8px; }
.dl-group > summary { cursor: pointer; padding: 8px 10px; list-style: none; display: flex; gap: 8px; align-items: baseline; }
.dl-group > summary::-webkit-details-marker { display: none; }
.dl-group > summary::before { content: '›'; color: var(--text-3); transition: transform .15s; display: inline-block; }
.dl-group[open] > summary::before { transform: rotate(90deg); }
.dl-group .dl-steps { padding: 0 8px 8px; margin: 0; }
.dl-steps li .grow { flex: 1; }
.dl-steps li.now { border-color: var(--text); }
.phone.flash { box-shadow: 0 0 0 2px var(--text); transition: box-shadow .2s; }

.dl-trig > summary { cursor: pointer; list-style: none; }
.dl-trig > summary::-webkit-details-marker { display: none; }

/* Team bot admins: one row per admin account, its own QR until linked */
.admin-lines { display: grid; gap: 8px; margin: 6px 0; }
.admin-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius, 8px); }
.admin-line .code-qr { margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-text, var(--accent)); cursor: pointer; text-decoration: underline; }

/* Headings never get squeezed under the buttons next to them: a page title stays on one line and pushes
   the controls to the next line instead; card headings keep at least their longest word. */
h1.grow, h2.grow, h3.grow { min-width: min-content; }
.page-head > h1.grow, .page-head > h1 { flex: 1 0 auto; min-width: max-content; white-space: nowrap; }

/* "รอยืนยัน": suggested from a chat, dashed until someone confirms */
.ev.suggested { background: transparent; border: 1px dashed var(--accent); color: var(--text-2); }
.cal-item.suggested { border: 1px dashed var(--accent); border-radius: var(--radius, 8px); background: var(--accent-soft); }
.confirm-items { display: grid; gap: 8px; padding: 8px 0 4px; }
.confirm-item { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius, 8px); background: var(--surface); }
.confirm-group { margin-bottom: 10px; }
.toast .effects { margin: 4px 0 0; padding-left: 18px; font-size: 0.8125rem; }

/* หลังเช่า */
.care-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; }
.care-wrap > * { min-width: 0; }
.care-list { display: grid; gap: 6px; align-content: start; }
.care-row { all: unset; cursor: pointer; display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius, 8px); background: var(--surface); }
.care-row.on { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 900px) { .care-wrap { grid-template-columns: minmax(0, 1fr); } }

/* Tabs inside a menu group (ลูกค้า · ผลงาน · ทีม) */
.subtabs { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.subtabs a { padding: 8px 12px; border-radius: 8px 8px 0 0; color: var(--text-2); text-decoration: none; white-space: nowrap; font-weight: 500; }
.subtabs a.on { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-bottom-color: var(--surface); margin-bottom: -1px; }

/* Red dots: where to act (menu numbers, tab dots, the item a link opened, the "ทำต่อ" pill) */
.subtabs a { position: relative; }
.dot-n { display: inline-block; margin-left: 5px; min-width: 16px; line-height: 1.6; padding: 0 4px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 0.625rem; font-weight: 700; text-align: center; vertical-align: 1px; }
.dot-n.hidden { display: none; }
.red-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--critical); box-shadow: 0 0 0 0 color-mix(in srgb, var(--critical) 60%, transparent); animation: redpulse 1.4s infinite; }
@keyframes redpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--critical) 55%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.spot { position: relative; outline: 2px solid var(--critical); outline-offset: 3px; border-radius: 10px; }
.spot::before { content: ''; position: absolute; top: -7px; left: -7px; width: 12px; height: 12px; border-radius: 50%; background: var(--critical); animation: redpulse 1.4s infinite; z-index: 2; }
.next-pill { display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--critical); border-radius: 999px; padding: 7px 14px; font-size: 0.8125rem; box-shadow: 0 4px 14px rgb(0 0 0 / .14); text-decoration: none; max-width: min(560px, 100%); }
.next-pill .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.next-pill:hover { background: var(--surface-2); }
[data-nextbar] { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
[data-nextbar]:empty { display: none; }
.line-back { display: inline-flex; align-items: center; gap: 6px; background: #06c755; color: #fff; border-radius: 999px; padding: 7px 14px; font-size: 0.8125rem; font-weight: 600; text-decoration: none; box-shadow: 0 4px 14px rgb(0 0 0 / .14); }
.line-hint { background: var(--good-soft); border-radius: 10px; padding: 10px 12px; font-size: 0.8125rem; display: flex; flex-direction: column; gap: 8px; }
.line-hint .btn { justify-content: center; background: #06c755; color: #fff; border-color: #06c755; }
.done-box { background: var(--good-soft); border: 1px solid var(--good); border-radius: 12px; padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.choice-row .btn:not(.sm) { flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 10px 14px; min-width: 190px; }
.choice-row .btn .small { display: block; font-weight: 400; }
.choice-row .btn.primary .small { color: inherit; opacity: .85; }
.group-row h2, .page-body > .stack > h2 { margin-top: 8px; }
.care-steps { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.75rem; margin-bottom: 8px; }
.care-steps span { padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.care-steps span.done { background: var(--good-soft); color: var(--text); }
.care-steps span.now { background: var(--critical-soft); color: var(--text); font-weight: 600; }
/* "ลองแบบเรื่องเล่า" */
.story .story-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 14px; margin-top: 12px; }
.story-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.story-steps li { padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 0.8125rem; color: var(--text-2); border: 1px solid transparent; }
.story-steps li:hover { background: var(--surface-2); }
.story-steps li.now { background: var(--accent-soft); color: var(--text); border-color: var(--accent); font-weight: 600; }
.story-steps li.done { color: var(--text); }
.story-now h2 { margin: 0; }
.story-now .btn .red-dot { margin-right: 4px; }
.story-phones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.story-phones .phone { flex: 1 1 280px; max-width: 380px; }
.story-phones .ph-body { max-height: 460px; overflow: auto; }
.story-phones .ph-body button, .story-phones .ph-body a.btn { pointer-events: none; }
.map-web { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; position: relative; }
.map-node { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.map-hub { grid-column: 1 / -1; text-align: center; border: 2px dashed var(--accent); border-radius: 12px; padding: 8px; background: var(--accent-soft); }
.tag-line, .tag-web { display: inline-block; font-size: 0.625rem; font-weight: 700; border-radius: 4px; padding: 0 5px; margin-right: 4px; color: #fff; }
.tag-line { background: #06c755; }
.tag-web { background: var(--accent); }
@media (max-width: 760px) { .story .story-wrap { grid-template-columns: 1fr; } .story-steps { flex-direction: row; overflow-x: auto; } .story-steps li { white-space: nowrap; } .map-web { grid-template-columns: 1fr; } }

/* Side panel: every part has a bold title over a line, so the eye finds the parts at once. */
.side-pane .section h3, .adv section > h4 { font-size: 0.8125rem; font-weight: 700; color: var(--text); letter-spacing: 0; text-transform: none;
  margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border-strong); }
.adv section { padding-bottom: 2px; }
/* "ทำอะไรต่อ": the one place to look first — tinted, with an accent edge. */
.adv section.next-box { background: var(--warning-soft); border: 1px solid var(--warning); border-left: 4px solid var(--warning); border-radius: var(--radius); padding: 10px 12px; }
.adv section.next-box > h4 { border-bottom-color: var(--warning); }
.adv section.next-box .todo .it { background: var(--surface); }
.miss-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--critical); margin-left: 4px; vertical-align: 1px; }
.field .link-btn.small { font-size: 0.75rem; text-align: left; margin-top: 3px; }
.share-line { display: flex; gap: 8px; align-items: baseline; font-size: 0.8125rem; padding: 3px 0; color: var(--text-2); }
.share-line .share-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; transform: translateY(-1px); }
.share-line.ok { color: var(--text); }
.share-line.ok .share-dot { background: var(--good); }
.today-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.today-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.today-box.none { opacity: .75; }
.today-head { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 5px; margin-bottom: 2px; }
.today-head b { flex: 1; font-size: 0.8125rem; }
.today-n { min-width: 22px; text-align: center; font-weight: 700; font-size: 0.8125rem; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.today-box.none .today-n { background: var(--surface-2); color: var(--text-3); }
.today-money { font-size: 1.375rem; font-weight: 700; }
.sheet th .th-in { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.sheet th .th-sort { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: inherit; cursor: pointer; }
.sheet th .th-filter { background: none; border: 0; padding: 0 3px; cursor: pointer; color: var(--text-3); font-size: 0.6875rem; border-radius: 4px; }
.sheet th.filtered .th-filter { color: #fff; background: var(--accent); }
.th-pop { position: absolute; z-index: 50; width: 270px; padding: 10px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); background: var(--surface); }
.th-pop .th-vals { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.th-pop .th-vals label { display: flex; gap: 6px; align-items: center; }
.cap-sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.cap-tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.cap-tile.crit { border-color: var(--critical); background: var(--critical-soft); }
.cap-tile.good { border-color: var(--good); }
.cap-n { font-size: 1.375rem; font-weight: 700; }
.cap-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.cap-bar span { display: block; height: 100%; background: var(--good); }
.cap-t tr.over .cap-bar span { background: var(--critical); }
.cap-t tr.over td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
.composer .warnline.next { background: var(--accent-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.next-card { border-color: var(--accent); }
.week-plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.wp-day { border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.wp-day.unset { border-style: dashed; }
.wp-b { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; font: inherit; font-size: 0.75rem; padding: 2px 4px; cursor: pointer; color: var(--text-2); }
.wp-b.on.lv100 { background: var(--good-soft); border-color: var(--good); color: var(--text); font-weight: 600; }
.wp-b.on.lv50 { background: var(--warning-soft); border-color: var(--warning); color: var(--text); font-weight: 600; }
.wp-b.on.lv0 { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); font-weight: 600; }
.warn-text { color: var(--serious); }
.dl-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dl-focus { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); position: sticky; top: 0; z-index: 3; }
.dl-step-name { text-align: left; color: var(--text); font-size: 0.8125rem; }
.dl-step-name.on { color: var(--accent-text); font-weight: 700; }
.phone[hidden] { display: none !important; }
.ph-older { padding: 6px 10px; text-align: center; border-bottom: 1px dashed var(--border); }
.dl-scene.on > summary b { color: var(--accent-text); }
.dl-scene.on { border-color: var(--accent); }
.dl-story { margin-top: 4px; line-height: 1.5; }
.adv section.protocol-box { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 12px; }
.protocol-box .rules { margin: 4px 0 6px; }
.protocol-box .proto-step { display: flex; gap: 8px; align-items: flex-start; font-size: 0.8125rem; padding: 3px 0; }
.protocol-box .proto-step.done span { color: var(--text-3); text-decoration: line-through; }
.protocol-box .proto-sub { margin: 0 0 4px 24px; }
/* Demo hats: one colour per person, the same on the chat header, the turn list and the step list. */
.hat { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-bottom: 4px; color: #fff; background: var(--text-3); }
.h-sys { --hat: #85847e; } .h-cust { --hat: #0ca30c; } .h-web { --hat: #2a78d6; } .h-team { --hat: #7a5af8; } .h-agent { --hat: #d97706; }
.h-ext { --hat: #db2777; } .h-admin { --hat: #d03b3b; } .h-care { --hat: #0e9384; }
.hat[class*="h-"] { background: var(--hat); }
.turns { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.turn { font-size: 0.75rem; padding: 3px 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--hat, var(--border)); border-left: 4px solid var(--hat, var(--border)); }
.turn b { color: var(--hat); }
.turn-arrow { color: var(--text-3); }
.phone.my-turn { outline: 3px solid var(--warning); outline-offset: 1px; }
.turn-note { margin-top: 4px; font-size: 0.75rem; font-weight: 600; background: var(--warning-soft); border-radius: 6px; padding: 4px 6px; }
.step-hats { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: 1px; }
.hat-dot { font-size: 0.625rem; padding: 0 5px; border-radius: 999px; color: #fff; background: var(--hat, var(--text-3)); font-weight: 600; }

/* Tracking: one tap "มอบให้ <suggested>" next to ไม่มีเจ้าของ; the picker keeps the cell's width (reasons show when open) */
.give-btn { margin-left: 6px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--accent, #2a78d6); background: transparent; color: var(--accent-text, inherit); font: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.give-btn:hover { background: var(--accent, #2a78d6); color: #fff; }
.give-btn:disabled { opacity: .5; cursor: wait; }
td.editing select { max-width: 260px; }
.sug-hint { margin-top: 4px; max-width: 260px; font-size: 0.7188rem; line-height: 1.35; color: var(--accent-text, #1c5cab); white-space: normal; }
.fx-navrow { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.fx-nav { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 0.7188rem; color: var(--accent, #2a78d6); text-decoration: underline; cursor: pointer; }
/* ลีด co-agent */
.co-kind { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 0.7188rem; font-weight: 600; border: 1px solid var(--border, #ddd); }
.co-kind.k-line { color: #0b7a3e; border-color: #9fd8b5; }
.co-kind.k-fb { color: #1c5cab; border-color: #a9c6ee; }
.co-kind.k-bot { color: #7a4b00; border-color: #e6c88f; }
.co-text { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-skip { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border, #eee); }
.co-add textarea { width: 100%; }
.src-link { color: var(--muted, #777); border-left: 3px solid var(--warning, #d9a400); padding-left: 6px; margin: 4px 0; }
.claim-window { align-items: center; gap: 8px; border-left: 4px solid var(--border, #ddd); }
.claim-window.open { border-left-color: var(--good, #0b7a3e); }
.claim-pend { align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border, #eee); }
.replied-by { color: var(--muted, #777); }
.recap-box { border: 1px solid var(--border, #e3e2dc); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.recap-box summary { cursor: pointer; font-weight: 700; font-size: 0.8125rem; }
.recap-row { display: grid; grid-template-columns: 92px 1fr; gap: 6px; font-size: 0.7812rem; padding: 3px 0; }
.recap-row span { color: var(--muted, #777); }
.recap-row b { font-weight: 600; }
.rm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.rm-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border, #eee); }
.rm-score { font-size: 1.25rem; font-weight: 800; min-width: 56px; text-align: center; }
.rm-parts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rm-part { font-size: 0.6875rem; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border, #ddd); }
.rm-part.good { border-color: #9fd8b5; color: #0b7a3e; } .rm-part.mid { border-color: #e6c88f; color: #7a4b00; } .rm-part.bad { border-color: #f0b4ad; color: #b42318; }
.co-take { margin-left: 6px; }
.co-tier { display: inline-block; font-size: 0.6875rem; font-weight: 700; padding: 0 6px; border-radius: 6px; margin-right: 4px; }
.co-tier.t-jc { background: #e3f4ea; color: #0b7a3e; } .co-tier.t-condo { background: #e3eefb; color: #1c5cab; } .co-tier.t-area { background: #f1efe9; color: #6b6b66; }
.rail-jump { opacity: .8; } .rail-jump:hover { opacity: 1; }
.jumps { display: flex; gap: 10px; flex-wrap: wrap; } .jumps a, .jumps .link-btn { font-size: 0.75rem; }
.fu-one { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.fu-last { font-size: 0.75rem; color: var(--muted, #6b6b66); border-left: 3px solid var(--border, #e3e2dc); padding: 2px 0 2px 8px; margin: 4px 0; }
.ck-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border, #eee); }
.ck-box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border, #ccc); display: grid; place-items: center; font-size: 0.8125rem; font-weight: 800; flex: none; }
.ck-row.done .ck-box { background: var(--good, #0b7a3e); border-color: var(--good, #0b7a3e); color: #fff; }
.ck-row.done b { color: var(--muted, #777); text-decoration: line-through; }

/* ---- ทดสอบ 1-2-3 (#/tour) ---- */
.tour .tour-cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.tour-p { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; border-top: 3px solid var(--tone, var(--border)); }
.tour-p.on { outline: 2px solid var(--accent); }
.tour-p.c-admin { --tone: #7c5cff; } .tour-p.c-agent { --tone: #1a7f5a; } .tour-p.c-cust { --tone: #06c755; } .tour-p.c-ext { --tone: #c46a00; } .tour-p.c-care { --tone: #2f6fd6; }
.tour-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.8125rem; color: #fff; background: var(--tone, var(--accent)); flex: none; }
.tour-p dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0; font-size: 0.75rem; }
.tour-p dt { color: var(--text-3, var(--text-2)); }
.tour-p dd { margin: 0; }
.tour .tour-wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; align-items: start; }
.tour-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 8px; }
.tour-ch { font-size: 0.6875rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; margin: 10px 0 2px; letter-spacing: .02em; }
.tour-ch:first-child { margin-top: 0; }
.tour-s { display: flex; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 10px; cursor: pointer; font-size: 0.8125rem; color: var(--text-2); border: 1px solid transparent; }
.tour-s:hover { background: var(--surface-2); }
.tour-s.now { background: var(--accent-soft); color: var(--text); border-color: var(--accent); font-weight: 600; }
.tour-n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-size: 0.6875rem; flex: none; }
.tour-s.done .tour-n { background: var(--good, #1a7f5a); border-color: transparent; color: #fff; }
.tour-s.now .tour-n { border-color: var(--accent); }
.tour-now { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tour-card h2 { margin: 0; }
.tour-phones { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.tour-ph .ph-body { max-height: 460px; overflow: auto; }
.tour-ph .tour-old { opacity: .45; }
.tour-ph .tour-new { border-left: 3px solid var(--accent); padding-left: 4px; }
.tour-sheet { min-width: 0; }
.tour-sheet [data-feed], .tour-sheet a[href$=".gs"] { display: none; }
.tour-back { position: fixed; right: 16px; bottom: 72px; z-index: 60; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 999px; font-weight: 600; font-size: 0.875rem; text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
@media (max-width: 860px) { .tour .tour-wrap { grid-template-columns: 1fr; } .tour-steps { position: static; flex-direction: row; overflow-x: auto; } .tour-ch { display: none; } .tour-s { flex: none; } .tour-phones { grid-template-columns: 1fr; } }

.tour-castbox { margin: 10px 0 14px; } .tour-castbox > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .tour-castbox[open] > summary { margin-bottom: 0; }
.tour-castbox .chip.on { outline: 2px solid var(--accent); }
/* เปิดเบอร์ห้อง */
button.link { background: none; border: 0; padding: 0; color: var(--accent-text, var(--accent)); cursor: pointer; font: inherit; text-align: left; }
.t tr.sel td { background: var(--accent-soft); }
/* ยังไม่ได้ห้อง */
.nr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.nr-rooms { display: flex; flex-direction: column; gap: 6px; }
.nr-room { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; }
/* ของฉัน */
.me-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.me-row { padding: 6px 0; border-top: 1px solid var(--border); }
.perm-box { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.perm-box legend { font-weight: 600; font-size: 0.8125rem; padding: 0 4px; }
.assign-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
/* call: who can give the room */
.src-box { margin: 4px 0 6px 18px; }
.src-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.src-form input:not([type=number]) { max-width: 180px; }
.src-saved { margin-left: 18px; color: var(--text-2); }
.me-stations .page-head { padding: 0 0 8px; }
.me-stations .page-body { padding: 0; }
/* chat list: the search gets its own full row */
.list-head > .row:first-child { flex-wrap: wrap; gap: 6px; }
.list-head [data-search] { flex: 1 1 100%; min-width: 0; font-size: 0.9375rem; padding: 9px 12px; }
/* chat page: drag the column edges (widths kept per person) */
.inbox { position: relative; }
@media (min-width: 1201px) { .inbox { grid-template-columns: var(--list-w, 340px) 1fr var(--side-w, 340px); } }
.col-drag { position: absolute; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; }
.col-drag[data-col-drag="list"] { left: calc(var(--list-w, 340px) - 4px); }
.col-drag[data-col-drag="side"] { right: calc(var(--side-w, 340px) - 4px); }
.col-drag:hover, .inbox.dragging-col .col-drag { background: var(--accent-soft); }
.inbox.dragging-col { user-select: none; cursor: col-resize; }
@media (min-width: 761px) and (max-width: 1200px) { .inbox { grid-template-columns: var(--list-w, 300px) 1fr; } }
@media (max-width: 1200px) { .col-drag[data-col-drag="side"] { display: none; } }
@media (max-width: 760px) { .col-drag { display: none; } }

/* Pictures waiting to be sent (chat box): preview row, ✕ to take one out */
.pic-tray { border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 6px; background: var(--surface-2, var(--bg)); }
.pic-tray .pic-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.pic-tray .pic-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.pic-tray .pic { position: relative; flex: 0 0 auto; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.pic-tray .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic-tray .pic.bad { outline: 2px solid var(--danger, #d64545); }
.pic-tray .pic-n { position: absolute; left: 4px; bottom: 4px; font-size: 0.6875rem; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); border-radius: 4px; padding: 0 5px; }
.pic-tray .pic-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 0.9375rem; line-height: 22px; padding: 0; cursor: pointer; }
.pic-tray .pic.add { display: flex; align-items: center; justify-content: center; font-size: 1.75rem; color: var(--muted, #888); cursor: pointer; border-style: dashed; }
.composer.drop { outline: 2px dashed var(--accent, #2a78d6); outline-offset: -4px; }

/* Tracking: who may fill in Agent Name — names in columns so the buttons stay in view */
.pick-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 2px 10px; max-height: 210px; overflow: auto; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; transition: opacity .15s; }

/* Status picker in the chat header + the system's suggestion */
.head-status { width: auto; display: inline-block; padding: 1px 22px 1px 6px; font-size: 0.75rem; height: auto; min-height: 0; border-radius: 6px; vertical-align: baseline; }
.sug-chip { border: 1px dashed var(--accent, #2a78d6); background: var(--accent-soft, #eaf2fc); color: var(--accent, #2a78d6); border-radius: 999px; padding: 0 8px; font-size: 0.7188rem; cursor: pointer; white-space: nowrap; }
.sug-chip:hover { background: var(--accent, #2a78d6); color: #fff; }
.head-status-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0; }

/* สุขภาพระบบ */
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.sys-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--border); }
.sys-card h2 + .sys-row { border-top: 0; }
.sys-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint, #bbb); flex: 0 0 auto; margin-top: 5px; display: inline-block; }
.sys-dot.good { background: var(--good, #2e9e5b); } .sys-dot.warn { background: var(--warning, #d99a1b); } .sys-dot.crit { background: var(--danger, #d64545); }
.sys-sum { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.sys-sum.good .sys-dot { background: var(--good, #2e9e5b); } .sys-sum.warn .sys-dot { background: var(--warning, #d99a1b); } .sys-sum.crit .sys-dot { background: var(--danger, #d64545); }
.sys-sum.crit { border-color: var(--danger, #d64545); }
.st-row.st-must { background: var(--warning-soft, #fff6e0); border-radius: 6px; }
.st-all { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
/* stations: zones minimize to one line */
.st-zone.collapsed .st-rows { display: none; }
.st-zone.collapsed .st-zh { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.st-tog { border: 0; background: none; font-size: 0.875rem; width: 22px; padding: 0; cursor: pointer; color: var(--muted, #888); align-self: flex-start; margin-top: 2px; }
.st-zt { cursor: pointer; min-width: 0; }
.st-tally { display: inline-flex; gap: 4px; margin-left: 4px; }
/* "มีเวอร์ชันใหม่" — no automatic reload; the person presses รีเฟรช */
.update-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 90; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 12px; padding: 8px 12px; font-size: 0.8125rem; max-width: calc(100vw - 32px); }
/* Lite mode (slow computers): nothing moves, nothing casts shadows — the same screens, cheaper to draw */
html.lite *, html.lite *::before, html.lite *::after { animation: none !important; transition: none !important; box-shadow: none !important; text-shadow: none !important; backdrop-filter: none !important; scroll-behavior: auto !important; }
html.lite .card, html.lite .modal, html.lite .update-bar { border: 1px solid var(--border); }
.more-row td { text-align: center; padding: 10px; background: var(--surface); }

/* Sale Tracking: the customer's name opens their chat */
.t.sheet a.cust-link { color: inherit; text-decoration: none; }
.t.sheet a.cust-link:hover b { color: var(--accent, #2a78d6); text-decoration: underline; }

/* Chat list: status chips (tap = only that status), each with its count and colour */
.status-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.status-chips .stc { border: 1px solid var(--border-strong, #d0d0d0); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 3px 9px; font-size: 0.75rem; cursor: pointer; line-height: 1.3; }
.status-chips .stc b { font-weight: 700; color: var(--text); margin-left: 2px; }
.status-chips .stc:hover { border-color: var(--accent); }
.status-chips .stc.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-chips .stc.on b { color: #fff; }
.status-chips .stc.on::before { background: #fff; }

.th-pop .th-vals label.gone { display: none; }

/* Sale Tracking: the row you came for from a chat (ดูใน Sale Tracking) */
.t.sheet tr.row-focus > td { background: var(--accent-soft, #e3eefb) !important; transition: background .6s; }
.t.sheet tr.row-focus > td:first-child { box-shadow: inset 3px 0 0 var(--accent, #2a78d6); }

/* Grouped customer lists (ลีด 3 วัน, Non-active) */
.lg-group { padding: 0; margin-bottom: 10px; }
.lg-group > summary { cursor: pointer; padding: 10px 14px; list-style: none; }
.lg-group > summary::-webkit-details-marker { display: none; }
.lg-group.lg-jc { border-color: var(--good, #1a7f37); }
.lg-rows { border-top: 1px solid var(--border); }
.lg-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); }
.lg-row:first-child { border-top: 0; }
.lg-score { font-weight: 800; font-size: 1.0625rem; min-width: 50px; text-align: center; }

/* Phones: the chat header is one compact line (name + who); ⋯ opens the status, links and other buttons below it,
   so the conversation is never covered. */
.chat-head .head-more-btn { display: none; font-size: 1.125rem; line-height: 1; padding: 4px 10px; }
/* The links under the name sit side by side and wrap (never one per line). */
.chat-head .jumps { display: flex !important; flex-wrap: wrap; align-items: center; gap: 2px 12px; white-space: normal; }
.chat-head .jumps > * { white-space: nowrap; display: inline-flex; }
/* Phones, tablets and small laptops (the chat column is narrow): one compact line; ⋯ opens the rest. */
@media (max-width: 1200px) {
  .chat-head { flex-wrap: wrap; padding: 8px 10px; gap: 8px; min-height: 0; }
  .chat-head .head-more-btn { display: inline-flex; }
  .chat-head:not(.open) .head-extra, .chat-head:not(.open) .head-act { display: none !important; }
  .chat-head.open { max-height: 55vh; overflow-y: auto; }
  .chat-head.open .head-act { order: 10; }
}

/* Fold any section: tap its heading (▾ open · ▸ folded) */
.foldable { cursor: pointer; user-select: none; }
.foldable::after { content: ' ▾'; color: var(--text-3, #999); font-size: .75em; font-weight: 400; }
.foldable.folded::after { content: ' ▸'; }
.card.card-folded > :not(:first-child), section.card-folded > :not(:first-child) { display: none !important; }
section.card-folded > h4 { margin-bottom: 0; opacity: .75; }
.fold-hidden { display: none !important; }
/* Drag to make tables / lists taller or shorter */
.table-wrap, .lg-rows { resize: vertical; overflow: auto; }
.lg-rows { max-height: 70vh; }
/* Chat screen: a side dragged shut is hidden; the bar stays to drag it back */
@media (min-width: 761px) {
  .inbox.hide-list .list-pane { display: none; }
  .inbox.hide-list .col-drag[data-col-drag="list"] { left: 0; width: 10px; background: var(--border); }
}
@media (min-width: 1201px) {
  .inbox.hide-sidecol .side-pane { display: none; }
  .inbox.hide-sidecol .col-drag[data-col-drag="side"] { right: 0; width: 10px; background: var(--border); }
}

/* #/do: facts of one request */
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { text-align: left; font-weight: 500; color: var(--text-2); width: 34%; padding: 6px 8px 6px 0; vertical-align: top; }
table.kv td { padding: 6px 0; font-weight: 600; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid var(--border); }

/* #/jc — จะเช็ค */
.jc-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.jc-room { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.jc-room input { width: 20px; height: 20px; flex: none; }
.jc-n { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: var(--ink, #111); color: var(--bg, #fff); font-weight: 700; font-size: 0.8125rem; flex: none; }

.jc-mini { margin-top: 4px; display: grid; gap: 2px; }

/* ลีด co-agent: contact + Just-check rooms on each lead */
.co-contact { margin-top: 3px; }
.co-jc { margin-top: 3px; padding: 4px 8px; border-radius: 8px; background: var(--good-bg, rgba(30, 123, 69, .08)); }

/* Lead list rows (ลีดใหม่ · ติดตามลูกค้า · Non-active): the buttons sit together on the right; on a phone they go under
   the text (full width for the text, buttons in one row) instead of squeezing the text into a thin column. */
.lg-act { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; flex: 0 1 auto; max-width: 46%; }
.lg-act .btn { white-space: nowrap; }
@media (max-width: 760px) {
  .lg-row { flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; padding: 12px; }
  .lg-score { min-width: 34px; font-size: 0.9375rem; padding-top: 2px; }
  .lg-row > .grow { flex: 1 1 calc(100% - 50px); }
  .lg-act { flex: 1 1 100%; max-width: none; justify-content: flex-start; padding-left: 44px; }
  .lg-act .btn { flex: 1 1 auto; text-align: center; justify-content: center; }
}

/* Notices can be removed: ✕ on each pop-up and on the "ทำต่อ" bar; "ลบทั้งหมด" when several pop-ups stack. */
.toast { position: relative; padding-right: 34px; }
.toast-x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: inherit; opacity: .6; cursor: pointer; font-size: 0.8125rem; line-height: 24px; padding: 0; }
.toast-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.toast-clear { align-self: flex-end; border: 1px solid var(--border); background: var(--surface); color: inherit; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.75rem; cursor: pointer; pointer-events: auto; }
.next-x { border: 0; background: transparent; color: inherit; opacity: .55; cursor: pointer; padding: 0 4px; font-size: 0.8125rem; }
.next-x:hover { opacity: 1; }

/* Chat list: a co-agent group is one block that opens to its deals (each post one card). */
.co-folder { background: var(--surface-2, rgba(0, 0, 0, .025)); }
.co-folder-ic { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); font-size: 0.8125rem; }
.co-items { border-left: 3px solid var(--border); margin-left: 14px; }
.co-items .conv { padding-left: 10px; }

/* ทดสอบทุกบทบาท (public/js/roletest.js) */
.rt { display: grid; gap: 12px; max-width: 980px; }
.rt .card { padding: 12px 14px; }
.rt .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rt-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.rt-chips button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 0.8125rem; }
.rt-chips button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.rt-flow.done { border-color: var(--good); }
.rt-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
.rt-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 8px; }
.rt-steps li.now { background: var(--accent-soft); }
.rt-steps li.ok { color: var(--text-2); }
.rt-mark { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); }
.rt-steps li.ok .rt-mark { background: var(--good-soft); color: var(--good); border-color: transparent; }
.rt-steps li.now .rt-mark { background: var(--accent); color: #fff; border-color: transparent; }
.rt-role { font-weight: 600; margin-right: 6px; }
.rt-where { display: inline-block; font-size: 0.6875rem; font-weight: 600; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); margin-right: 6px; }
.rt-act { flex: none; display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) { .rt-steps li { flex-wrap: wrap; } .rt-act { width: 100%; justify-content: flex-end; } }

/* Sale Tracking: two tables, never mixed — main leads / co-agent group leads (2026-11-16) */
.track-parts { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.track-part { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border: 2px solid var(--border); border-radius: 10px; min-width: 220px; }
.track-part span { font-size: 0.75rem; color: var(--muted, #666); }
.track-part.on.main { border-color: #111111; background: rgba(17, 17, 17, .06); }
.track-part.on.co { border-color: #0B6E69; background: rgba(11, 110, 105, .08); }
.track-part.co b { color: #0B6E69; }

/* Non-active: tick several to close Lost (2026-11-16) */
.na-pick { display: flex; align-items: flex-start; padding: 6px 6px 0 0; }
.na-bulk { padding: 6px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* เกณฑ์และตัวเลข (#/rules) */
.rule-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px 120px; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.rule-label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rule-input { display: flex; gap: 6px; align-items: center; }
.rule-input input { width: 140px; }
@media (max-width: 700px) { .rule-row { grid-template-columns: 1fr; } .rule-input input { width: 100%; } }

/* ดีลจับคู่ co-agent (#/matchdeals) */
.md-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.md-side, .md-ans { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.md-ans textarea { width: 100%; font-size: 0.75rem; }
.md-todo { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--bg-soft, rgba(0,0,0,.03)); }
.md-fee { margin-top: 8px; }
@media (max-width: 700px) { .md-sides { grid-template-columns: 1fr; } }

/* ศูนย์เรียนรู้ inside Omni (public/learn.html) */
.learn-frame { display: block; width: 100%; height: calc(100dvh - 120px); min-height: 480px; border: 0; border-radius: var(--radius, 10px); background: #f4f4f2; }
/* ห้องทดลองตอบลูกค้า (js/autolab.js) */
.lab { display: grid; grid-template-columns: 240px minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.lab-list { display: flex; flex-direction: column; gap: 6px; }
.lab-note { font-size: 0.75rem; color: var(--warning, #b57900); background: var(--warning-soft, #fff4dc); border-radius: 8px; padding: 6px 8px; }
.lab-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: inherit; text-decoration: none; }
.lab-item.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.pill-s { display: inline-block; align-self: flex-start; font-size: 0.6875rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.pill-s.on { background: var(--good-soft, #e3f5e3); color: var(--good, #0b8a0b); } .pill-s.warn { background: var(--warning-soft, #fff4dc); color: var(--warning, #b57900); }
.lab-chat { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; min-height: 70vh; }
.lab-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.lab-head [data-title] { flex: 1; min-width: 140px; font-weight: 600; border: 1px solid transparent; background: none; padding: 4px 6px; border-radius: 6px; }
.lab-head [data-title]:hover, .lab-head [data-title]:focus { border-color: var(--border); }
.lab-head select { width: auto; }
.lab-sw { display: inline-flex; gap: 6px; align-items: center; font-size: 0.8125rem; font-weight: 600; }
.lab-msgs { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 52vh; background: var(--bg, #f4f4f2); }
.lab-b { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; font-size: 0.875rem; }
.lab-b.in { align-self: flex-start; }
.lab-b.out { align-self: flex-end; background: var(--accent-soft, #e3eefb); border-color: transparent; }
.lab-t { display: block; font-size: 0.6875rem; color: var(--text-3); margin-top: 3px; }
.lab-draft { padding: 10px; border-top: 1px solid var(--border); background: var(--warning-soft, #fff4dc); display: flex; flex-direction: column; gap: 6px; }
.lab-draft textarea, .lab-input textarea { width: 100%; resize: vertical; }
.lab-input { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.lab-input .row { display: flex; gap: 6px; align-items: flex-end; }
.lab-samples { display: flex; gap: 4px; flex-wrap: wrap; }
.lab-side { display: flex; flex-direction: column; gap: 10px; }
.lab-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 10px 12px; }
.lab-card h3 { margin: 0 0 6px; font-size: 0.875rem; }
.lab-card ul { margin: 0; padding-left: 18px; }
.lab-card .chips { display: flex; gap: 4px; flex-wrap: wrap; }
.lab-task { border-top: 1px solid var(--border); padding: 8px 0; display: flex; flex-direction: column; gap: 3px; }
.lab-task .row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.lab-task.done b, .lab-task.skip b { color: var(--text-3); }
@media (max-width: 1100px) { .lab { grid-template-columns: minmax(0, 1fr) 320px; } .lab-list { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; } .lab-item { min-width: 200px; } }
@media (max-width: 760px) { .lab { grid-template-columns: minmax(0, 1fr); } .lab-b { max-width: 90%; } }

/* 2.2 call the building (Protocol box): numbers to call, or boxes to put them in */
.jur-box { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin: 6px 0; background: var(--surface, #fff); }
.jur-h { font-size: 0.7812rem; margin-bottom: 4px; }
.jur-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; font-size: 0.8125rem; }
.jur-k { width: 104px; flex: none; color: var(--text-2); }
.jur-row input { width: 150px; padding: 5px 8px; font-size: 0.8125rem; }

/* Chat list: status is one filter; agents' "other people's leads" tabs stand apart */
.status-filter { margin: 2px 0 6px; }
.status-filter { display: flex; gap: 6px; }
.status-filter select { width: 100%; min-width: 0; flex: 1; }
.status-filter select[data-scopesel].on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.status-filter select.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.scopes button.other { border: 1px dashed var(--border-strong, #c9c8c1); background: transparent; }
.scopes button.other.on { border-style: solid !important; color: #fff !important; font-weight: 700; background: var(--accent) !important; border-color: var(--accent) !important; }
/* each "other people's leads" tab has its own colour: outlined in it when not picked, filled when picked —
   Not reply customer red · 2 h open rooms teal · no fitting room amber (user 2026-11-18: "noticeable, not white") */
.scopes button.other[data-scope="takeover"] { color: #c0392b; border-color: #c0392b; background: #fdecea; }
.scopes button.other[data-scope="open_rooms"] { color: #0B6E69; border-color: #0B6E69; background: #e6f4f3; }
.scopes button.other[data-scope="noroom"] { color: #8a5a12; border-color: #b7791f; background: #fdf3e1; }
.scopes button.other.on[data-scope="takeover"] { background: #c0392b !important; border-color: #c0392b !important; }
.scopes button.other.on[data-scope="open_rooms"] { background: #0B6E69 !important; border-color: #0B6E69 !important; }
.scopes button.other.on[data-scope="noroom"] { background: #b7791f !important; border-color: #b7791f !important; }

/* ขนาดตัวอักษร (account menu): five steps, each "ก" drawn at its size */
.ts-pick .seg { display: flex; gap: 4px; margin-top: 4px; }
.ts-pick .seg button { flex: 1; min-height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; line-height: 1; }
.ts-pick .seg button.on { background: var(--text); color: var(--surface); border-color: var(--text); }

/* Chat drag bars: under the customer header and above the reply box (every screen size) */
.head-grip, .comp-grip { display: flex; justify-content: center; align-items: center; height: 14px; flex: none; cursor: row-resize; touch-action: none; user-select: none;
  background: var(--surface); position: relative; z-index: 1; }
.head-grip { border-bottom: 1px solid var(--border); }
.comp-grip { border-top: 1px solid var(--border); }
.head-grip span, .comp-grip span { width: 44px; height: 4px; border-radius: 2px; background: var(--border-strong, #c9c8c1); }
.head-grip:hover span, .comp-grip:hover span, .head-grip.dragging span, .comp-grip.dragging span, .head-grip:focus-visible span, .comp-grip:focus-visible span { background: var(--accent); width: 64px; }
.chat-head + .head-grip { margin-top: -1px; }
.comp-grip + .composer { border-top: 0; }
.head-mini-st { display: none; }
.chat-head.size-mini { padding: 4px 8px; gap: 6px; min-height: 0; }
.chat-head.size-mini .avatar, .chat-head.size-mini .sub, .chat-head.size-mini .presence,
.chat-head.size-mini .head-act, .chat-head.size-mini [data-preview], .chat-head.size-mini .row > .chip:not(.head-mini-st) { display: none !important; }
.chat-head.size-mini .head-mini-st { display: inline-block; margin-left: 6px; flex: 0 1 auto; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head.size-mini .row > b { min-width: 40%; }
/* Reply box dragged all the way down: only the box and its tools stay */
.composer.compact > :not(textarea):not(.tools):not(.pic-tray):not(.popup) { display: none !important; }
/* The chat itself always keeps room: header and reply box scroll inside themselves before squeezing the messages */
@media (max-width: 760px) {
  .chat-pane { min-height: 0; }
  .chat-pane .messages { min-height: 30dvh; }
  .chat-head.open { max-height: 45dvh; }
}

/* Notices above the reply box: on a phone, 2+ of them fold into one line (tap to open) */
.warn-fold { display: none; }
@media (max-width: 760px) {
  .warn-fold { display: flex; width: 100%; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
    padding: 6px 10px; margin-bottom: 6px; font: inherit; font-size: 0.8125rem; color: inherit; cursor: pointer; text-align: left; }
  .composer.notes-folded > .warnline { display: none; }
}
/* Rooms that fit: where each room comes from */
.chip.jc-badge { background: var(--good-soft); color: var(--good); border-color: transparent; font-weight: 700; font-size: 0.6875rem; }
.chip.site-badge { background: var(--surface-2); color: var(--text-2); font-size: 0.6875rem; }

/* ของฉัน: the รอยืนยัน part (merged 2026-11-18) */
.me-confirm { margin-top: 8px; }
.me-confirm-h { font-size: 1.125rem; margin: 8px 0 4px; scroll-margin-top: 12px; }

/* ผลเช็คห้อง beside the chat */
.chk-req { border-top: 1px solid var(--border); padding: 6px 0; }
.chk-req:first-of-type { border-top: 0; }
.chk-room { align-items: center; gap: 6px; }

/* The deal owner in the chat header: big and clear (set by the user 2026-11-18) */
.owner-tag { flex: none; margin-left: 8px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 0.9375rem; white-space: nowrap; max-width: 65%; overflow: hidden; text-overflow: ellipsis; }
.chat-head .row > b.ellipsis { min-width: 25%; }
.owner-tag.none { background: var(--critical-soft, #fbe7e7); color: var(--critical, #d03b3b); }
.chat-head.size-mini .owner-tag { font-size: 0.8125rem; padding: 0 8px; }

/* Rooms box: each room's check result + share buttons on its row */
.rc-pick .rc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.rc-share { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.rc-share .btn { padding: 2px 8px; min-height: 26px; }
.rc-pick.rc-free { background: var(--good-soft); border-radius: 8px; }
.rc-pick.rc-taken { opacity: .55; }

/* The deal code (CM…) in the chat header: visible, one tap copies it */
.cm-code { flex: none; margin-left: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-strong, #c9c8c1); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: 0.875rem; font-variant-numeric: tabular-nums; cursor: copy; }
.cm-code:hover { border-color: var(--accent); color: var(--accent-text); }

/* A co-agent deal's LINE group, talked to from Omni */
.dg-composer textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--surface); resize: vertical; min-height: 56px; margin-top: 6px; }

/* ของฉัน: lead board (main / co-agent, progress, leads to take) */
.me-board { display: grid; gap: 12px; margin-bottom: 12px; }
.me-sides { display: flex; gap: 8px; flex-wrap: wrap; }
.me-prog-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; margin-top: 6px; }
.me-prog-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: inherit; background: var(--surface); }
.me-prog-cell b { font-size: 1.25rem; }
.me-prog-cell span { font-size: 0.75rem; color: var(--text-2); }
.me-pending { background: #fff3c4 !important; color: #7a5a00 !important; border-color: #f2d36b !important; font-weight: 700; }

/* Chat list: drag bar under the search + filter area (up = smaller, down = bigger, tap = smallest / full) */
.list-grip { display: flex; justify-content: center; align-items: center; height: 16px; flex: none; cursor: row-resize; touch-action: none; user-select: none;
  background: var(--surface); border-bottom: 1px solid var(--border); position: relative; }
.list-grip span { width: 44px; height: 4px; border-radius: 2px; background: var(--border-strong, #c9c8c1); }
.list-grip:hover span, .list-grip.dragging span, .list-grip:focus-visible span { background: var(--accent); width: 64px; }
.list-grip em { position: absolute; right: 10px; font-style: normal; font-size: 0.75rem; color: var(--accent); font-weight: 600; }
.list-head { border-bottom: 0; }
.list-head.lh-normal-size .lh-full, .list-head.lh-mini-size .lh-full,
.list-head.lh-mini-size .scopes, .list-head.lh-mini-size .status-filter { display: none !important; }
.list-head.lh-mini-size > .row:first-child > :not([data-search]) { display: none !important; }
.list-head.lh-mini-size { padding-bottom: 4px; }

/* ของฉัน: two parts — Status update · Potential lead to get (Deal waiting for taken: ลีด 3 วัน · co-agent · ติดตามลูกค้า) */
.me-modes { padding: 0 20px; margin-bottom: 4px; }
.me-modes .track-part { flex: 1 1 240px; min-width: 0; }
.me-modes .track-part.co b { color: #0B6E69; }
.me-modes .track-part.co .chip { margin-left: 4px; }
.me-pot .me-pot-tabs { margin: 0 20px; }
.me-pot .page-head { padding-top: 10px; }
.me-pot .page-head h1 { font-size: 1.05rem; }
.lg-row.me-pending { background: #fff3c4 !important; border-color: #f2d36b !important; color: inherit !important; font-weight: inherit; }
@media (max-width: 640px) { .me-modes { padding: 0 12px; } .me-modes .track-part { flex-basis: 100%; padding: 6px 10px; } .me-pot .me-pot-tabs { margin: 0 12px; } }

/* Co-agent pool (ลูกค้า → Co-agent pool; "(Internal coagent)" in the chat's rooms box) */
.pool-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pool-table { min-width: 1100px; }
.pool-table td { padding: 3px 4px; vertical-align: top; }
.pool-table input, .pool-table select { min-width: 70px; padding: 5px 6px; font-size: 0.85rem; }
.pool-table input.need { border: 2px solid var(--critical, #c0392b); background: #fff5f4; }
.pool-table tr.need-row > td:first-child { color: var(--critical, #c0392b); font-weight: 700; }
.pool-table tr.pool-raw td { border-top: 0; padding-top: 0; }
.bad-text { color: var(--critical, #c0392b); font-weight: 600; }
.pool-badge { background: #111111; color: #fff; border-color: #111111; }
.pool-row { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; padding: 6px 0; border-top: 1px dashed var(--border); }
.pool-stale { opacity: .7; }
/* Waiting list line under the chat head (core/waitlist.js) */
.waitline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 12px; background: #f3f6ff; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
/* ยังไม่มีห้องตรง in the chat list: a teammate's customer without name / phone (opens the room-offer page) */
.conv.masked { background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(0,0,0,.025) 10px 20px); }
.conv.masked .avatar.ph { display: grid; place-items: center; background: var(--surface-2); color: var(--muted, #888); font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .scopes button.other:not(.on) { background: transparent; } :root:not([data-theme="light"]) .scopes button.other[data-scope="takeover"]:not(.on) { color: #ff8a7a; } :root:not([data-theme="light"]) .scopes button.other[data-scope="open_rooms"]:not(.on) { color: #5fd3c8; } :root:not([data-theme="light"]) .scopes button.other[data-scope="noroom"]:not(.on) { color: #f0b85a; } }
:root[data-theme="dark"] .scopes button.other:not(.on) { background: transparent; }
:root[data-theme="dark"] .scopes button.other[data-scope="takeover"]:not(.on) { color: #ff8a7a; }
:root[data-theme="dark"] .scopes button.other[data-scope="open_rooms"]:not(.on) { color: #5fd3c8; }
:root[data-theme="dark"] .scopes button.other[data-scope="noroom"]:not(.on) { color: #f0b85a; }
/* ★ Follow (any customer) · seeking mode for someone else's customer (read-only) */
.follow-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; cursor: pointer; margin-left: 6px; white-space: nowrap; }
.follow-btn.on { background: #fff4cc; border-color: #e0b100; color: #7a5a00; font-weight: 700; }
.follow-star { color: #e0a800; }
.chip.view-chip { background: var(--surface-2); color: var(--text-2); font-size: 0.7rem; }
.warnline.seek { background: #eef2ff; color: #2d3a8c; border-color: #c7d0ff; }
.waitline .wl-name { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 0.8rem; font-weight: 600; }
.waitline .wl-x { all: unset; cursor: pointer; color: var(--muted, #888); padding: 0 2px; }
.waitline select { width: auto; max-width: 200px; padding: 3px 6px; font-size: 0.8rem; }
.waitline .wl-rule { flex-basis: 100%; }
/* file picker inside a button: invisible but present (LINE's iPhone browser won't open a display:none file box) */
.file-pick { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
label:has(> .file-pick) { position: relative; }
/* ของฉัน for admins: the team first (KPIs + one row per agent), their own customers folded below */
.me-admin-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-bottom: 8px; }
.me-kpi { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
.me-kpi b { font-size: 1.6rem; line-height: 1.1; }
.me-kpi span { font-size: 0.8rem; color: var(--text-2); }
.me-kpi.crit { border-color: #c0392b; } .me-kpi.crit b { color: #c0392b; }
.me-kpi.warn { border-color: #e0a800; } .me-kpi.warn b { color: #9a6b00; }
.me-team-wrap { overflow-x: auto; }
.me-team td.num { text-align: center; font-weight: 600; }
.me-team td.me-crit { background: #fdecea; color: #c0392b; }
.me-team td.me-warn { background: #fff6dc; color: #8a5a00; }
.me-own > summary { cursor: pointer; }
.me-own[open] > summary { margin-bottom: 8px; }
.me-tiles-h { margin: 10px 0 4px; font-size: 0.85rem; color: var(--text-2); font-weight: 700; }
.me-kpi.good b { color: #0B6E69; } .me-kpi.good { border-color: #0B6E69; }
/* Admin context under a row (public/js/adminctx.js): the facts, then the suggested next step */
.ctx-box { margin-top: 6px; padding: 6px 8px; border-left: 3px solid #1F4E8C; background: #f3f6ff; border-radius: 0 6px 6px 0; }
.ctx-facts { color: var(--text-2); }
.ctx-next { margin-top: 2px; color: #1F4E8C; }
.ctx-pick { max-width: 260px; }
.ctx-pick option.ctx-full { color: #a33; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ctx-box { background: rgba(31, 78, 140, .18); } :root:not([data-theme="light"]) .ctx-next { color: #8fb4ff; } }
:root[data-theme="dark"] .ctx-box { background: rgba(31, 78, 140, .18); } :root[data-theme="dark"] .ctx-next { color: #8fb4ff; }
.me-move { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.me-move:first-of-type { border-top: 0; }

/* Select many, act once (bulk.js) */
.bulk-bar { gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.bulk-bar[hidden] { display: none; }
.sel-box { width: 18px; height: 18px; flex: 0 0 auto; cursor: pointer; accent-color: var(--accent); }

/* ของฉัน by duty (2026-11-18): three parts; part 3 = reasoned warnings */
.me-duty .track-part { flex: 1 1 200px; }
.me-duty .track-part.on { border-color: var(--accent); background: var(--accent-soft); }
.me-duty .track-part.on b { color: var(--accent-text); }
.me-warn.crit { border-left: 4px solid var(--critical); }
.me-warn.warn { border-left: 4px solid var(--warning); }
.me-warn.info { border-left: 4px solid var(--border-strong); }
.me-warn .ctx-next { color: var(--text); }
.me-warn-items { display: flex; flex-direction: column; gap: 2px; }
.me-back { padding: 8px 20px 0; }
@media (max-width: 640px) { .me-back { padding: 8px 12px 0; } }

/* A tab's views (ลูกค้า → ลูกค้าทั้งหมด: Tracking · Non-active · …) */
.views-bar { display: flex; gap: 6px; padding: 10px 20px 2px; overflow-x: auto; scrollbar-width: none; }
.views-bar a { position: relative; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); text-decoration: none; white-space: nowrap; font-size: 0.875rem; background: var(--surface); }
.views-bar a.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (max-width: 640px) { .views-bar { padding: 8px 12px 2px; } }

/* A picture posted in the deal group, shown in the team note */
.note-pic { display: block; margin-top: 6px; }
.note-pic img { max-width: 240px; max-height: 240px; border-radius: 8px; display: block; }

/* ชวนเอเจนต์นอกเข้าระบบ: QR beside the ready message */
.invite-grid { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: start; }
.invite-qr svg { width: 100%; height: auto; display: block; background: #fff; border-radius: var(--radius); padding: 6px; }
.invite-grid textarea { width: 100%; font-size: 0.875rem; }
@media (max-width: 640px) { .invite-grid { grid-template-columns: 1fr; } .invite-qr { max-width: 200px; } }

/* The advisor's decision: how sure, alternatives, signals; the customer's flexibility answers */
.sure-chip { font-size: 0.72rem; vertical-align: 1px; }
.alt-steps { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; }
.alt-step { padding-left: 10px; border-left: 2px solid var(--border); }
.signal-box ul { margin: 0; padding-left: 18px; } .signal-box li { margin: 2px 0; font-size: 0.86rem; }
.flex-box .btns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
/* Auto / Manual per admin decision (js/automode.js) */
.automode > summary { cursor: pointer; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.automode-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
.automode-row:first-child { border-top: 0; }
.automode-log { margin-top: 8px; }
/* Phone (user 2026-11-19 screenshot: request text squeezed into one word per line): in a wrapping row the text part keeps at
   least 260px, so the picker and buttons drop under it instead of crushing it. */
.move-req > .grow, .me-move > .grow { flex: 1 1 260px; min-width: 0; }
@media (max-width: 640px) {
  .move-req > select, .me-move > select { flex: 1 1 100%; max-width: 100%; }
  .automode-row { flex-wrap: wrap; }
  .automode-row > .grow { flex: 1 1 100%; }
}
/* Same squeeze found by the phone sweep: lead rows (ลีด), group names (กลุ่ม), time labels (รอยืนยัน). */
.confirm-item > .grow, .row.wrap > .grow { flex: 1 1 240px; min-width: 0; }
@media (max-width: 640px) {
  .confirm-item > .grow { flex-basis: 100%; }
  label.row { flex-wrap: wrap; }
  label.row > .faint { flex: 1 1 100%; }
}
/* A grid column of 1fr grows to its widest child on a phone (the lead card went 593px wide): never wider than the screen. */
.confirm-items { grid-template-columns: minmax(0, 1fr); }
.confirm-item { min-width: 0; max-width: 100%; }
/* Phone: the chat header's name · owner · CM code wrap instead of pushing the CM code off the screen; long links wrap. */
@media (max-width: 640px) {
  .chat-head .row { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
  .chat-head > .grow, .chat-head > div { min-width: 0; }
}
main a { overflow-wrap: anywhere; }
/* Non-active → ส่งทีละกลุ่ม */
.na-groups > summary { cursor: pointer; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.na-group { border-top: 1px solid var(--border); padding: 10px 0; }
.na-group textarea { width: 100%; margin-top: 6px; }
/* สลับบทบาท (Masters): a small button bottom-left, above the phone menu */
.rolepop-btn { position: fixed; left: 12px; bottom: 16px; z-index: 60; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 0.8125rem; box-shadow: 0 2px 8px rgba(0,0,0,.12); cursor: pointer; }
@media (max-width: 640px) { .rolepop-btn { bottom: 84px; } }
.rolepop-item { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.rolepop-item:hover, .rolepop-item.on { border-color: var(--accent); background: var(--accent-soft); }
