:root {
  --bg: #f4f6f8; --panel: #fff; --text: #1d2733; --muted: #6b7785; --line: #e2e7ec;
  --brand: #06c755; --brand-dark: #05a647; --danger: #d64545; --warn: #b7791f; --blue: #2b6cb0;
  --radius: 10px;
  font-family: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.4em; }
.mono { font-family: Consolas, monospace; font-size: 13px; }

.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side { background: #12202d; color: #cfd8e3; padding: 18px 12px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 17px; padding: 0 6px 4px; line-height: 1.2; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: #8fa3b8; }
.brand-ico { font-size: 26px; }
.biz-pick { background: #1a2f42; border-radius: 10px; padding: 8px 10px; }
.biz-pick label { display: block; font-size: 12px; color: #8fa3b8; margin-bottom: 4px; }
.biz-pick select { background: #12202d; color: #fff; border-color: #34495d; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-sec { font-size: 11.5px; letter-spacing: .04em; color: #8fa3b8; padding: 12px 10px 4px; }
.side nav a { color: #cfd8e3; text-decoration: none; padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; gap: 9px; }
.side nav a .ico { width: 22px; text-align: center; }
.side nav a .lbl { flex: 1; }
.side nav a:hover { background: #1c3042; }
.side nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.badges { display: inline-flex; gap: 4px; }
.badge { display: inline-block; min-width: 20px; padding: 0 7px; border-radius: 99px; font-size: 12px; font-weight: 600; text-align: center; background: #e8edf2; color: #45525f; }
.badge.blue { background: #2b6cb0; color: #fff; }
.badge.amber { background: #f6ad55; color: #4a2b00; }
.badge.green { background: #d9f5e3; color: #0a7a35; }
.badge.gray { background: #e8edf2; color: #45525f; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-top: 1px solid #243a4e; }
.me-avatar { width: 34px; height: 34px; border-radius: 50%; background: #5b6cff; color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-text { min-width: 0; font-size: 13px; }
.me-text div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.me-text small { color: #8fa3b8; }
.menu-btn { display: none; position: fixed; top: 10px; left: 10px; z-index: 30; border: 0; background: #12202d; color: #fff; border-radius: 8px; width: 40px; height: 40px; font-size: 20px; }
.main { padding: 26px 30px 60px; max-width: 1500px; width: 100%; min-width: 0; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
  .side { position: fixed; left: 0; top: 0; z-index: 20; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .main { padding: 60px 14px 40px; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: 13px; }

input, select, textarea, button { font: inherit; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cdd5dd; border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9adbb5; border-color: var(--brand); }
input:disabled, select:disabled { background: #eef1f4; color: #98a3ae; }
textarea { resize: vertical; min-height: 70px; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.btn { border: 1px solid #cdd5dd; background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f3f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #e9b8b8; }
.btn.ghost { background: transparent; color: #cfd8e3; border-color: #34495d; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7fafc; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: #e8edf2; color: #45525f; }
.pill.ok { background: #d9f5e3; color: #0a7a35; }
.pill.off { background: #fbe3e3; color: #a02c2c; }
.pill.warn { background: #fdf0d5; color: #8a5a10; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #dfe6ec; object-fit: cover; flex: none; }
.avatar.big { width: 64px; height: 64px; }
.who { display: flex; align-items: center; gap: 10px; }

.bots { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.bot-card { cursor: pointer; }
.bot-card:hover { border-color: var(--brand); }
.bot-card h2 { margin-bottom: 4px; }

.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 16px; }
.section { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; }
.bars .bar { flex: 1; background: #9adbb5; border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .bar:hover { background: var(--brand); }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

.chat { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 2px; }
.msg .bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg .meta { font-size: 11.5px; color: var(--muted); }
.msg.in { align-self: flex-start; }
.msg.in .bubble { background: #eef1f4; border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .bubble { background: #d5f5df; border-top-right-radius: 4px; }
.msg.admin .bubble { background: #dbe8fb; }
.msg.system .bubble { background: #fdf0d5; }
.msg.err .bubble { background: #fbe3e3; color: #8c2626; }
.compose { display: flex; gap: 8px; margin-top: 10px; }
.compose textarea { min-height: 42px; height: 42px; }

dialog { border: 0; border-radius: 12px; padding: 22px; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(18,32,45,.55); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #12202d; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 50; max-width: 90vw; }
.toast.err { background: var(--danger); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.copybox { display: flex; gap: 6px; }
.copybox input { flex: 1; }

/* ---------- v2: shared bits ---------- */
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 6px; }
.warn-text { color: var(--warn); }
.avatar { display: grid; place-items: center; font-weight: 700; color: #5b6b7b; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; background: #eef1f4; color: #7b8794; }
.chip.on { background: #d9f5e3; color: #0a7a35; }
.chip a { color: inherit; text-decoration: none; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; white-space: nowrap; }
.tag.vip { background: #d9f5e3; color: #0a7a35; }
.tag.angry { background: #fbe3e3; color: #a02c2c; }
.tag.normal { background: #dbe8fb; color: #24518f; }
.tag.attention { background: #fdf0d5; color: #8a5a10; }
.btn-pill { border: 0; cursor: pointer; }
.pill.warn { background: #fdf0d5; color: #8a5a10; }
.tabs, .seg { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tabs button, .seg button { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--text); }
.tabs button.on, .seg button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.seg button { padding: 5px 10px; font-size: 13px; }
.hint-box { background: #eef7f1; border: 1px solid #cfe9d8; border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 13.5px; }
.block { margin-bottom: 18px; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.block-head h2 { margin: 0; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.report-body { white-space: pre-wrap; line-height: 1.7; margin-top: 8px; }
.hist-row { padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.hist-row:hover { background: #f7fafc; }
.insight, .insight-box { background: #fdf8e8; border: 1px solid #f1e2b0; border-radius: 8px; padding: 7px 10px; margin-top: 6px; font-size: 13.5px; }
.persona { background: #f4f6f8; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.login-logo { font-size: 44px; text-align: center; }
.login-card h1, .login-card > p { text-align: center; }

/* ---------- charts ---------- */
.gbars { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 6px; }
.gday { flex: 1; height: 100%; display: flex; align-items: flex-end; gap: 1px; min-width: 0; }
.gday i { flex: 1; border-radius: 2px 2px 0 0; min-height: 0; display: block; }
.gday:hover { background: #f0f6ff; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.legend.v { flex-direction: column; gap: 6px; font-size: 14px; color: var(--text); }
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; }
.donut > div { width: 100px; height: 100px; background: #fff; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut small { color: var(--muted); font-size: 11.5px; }
.progress { height: 8px; background: #e8edf2; border-radius: 99px; overflow: hidden; margin-top: 6px; max-width: 420px; }
.progress i { display: block; height: 100%; background: var(--brand); }
.quota { margin-bottom: 12px; font-size: 14px; }
.quota-card { margin-bottom: 14px; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1000px) { .inbox { grid-template-columns: 1fr; } }
.ib-list { padding: 12px; }
.ib-items { max-height: 68vh; overflow-y: auto; margin-top: 8px; }
.ib-item { display: flex; gap: 10px; padding: 9px 8px; border-radius: 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ib-item:hover { background: #f4f8fb; }
.ib-item.sel { background: #e9f8ef; }
.ib-body { min-width: 0; flex: 1; }
.ib-top { display: flex; justify-content: space-between; gap: 6px; }
.ib-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ib-prev { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.ib-chat { min-height: 60vh; }
.ib-head { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }

/* ---------- pickers ---------- */
.opts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.opt { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; background: #fff; }
.opt.big { flex-direction: column; align-items: flex-start; padding: 12px 16px; min-width: 260px; flex: 1; }
.opt.big small { color: var(--muted); }
.opt:has(input:checked) { border-color: var(--brand); background: #eafaf0; }
.tagopt.vip:has(input:checked) { background: #d9f5e3; } .tagopt.angry:has(input:checked) { background: #fbe3e3; }
.tagopt.normal:has(input:checked) { background: #dbe8fb; } .tagopt.attention:has(input:checked) { background: #fdf0d5; }
.aud { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

/* ---------- rules / telegram ---------- */
.fs { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.fs legend { padding: 0 8px; font-weight: 600; font-size: 14px; }
.tg-banner.ok { background: #eafaf0; border-color: #bfe8cf; }
.tg-banner.warn { background: #fff8e6; border-color: #f1e2b0; }
.var-chip { cursor: pointer; }
.pre { white-space: pre-wrap; }
.steps { margin: 6px 0 12px; padding-left: 20px; line-height: 1.7; }

/* ---------- webhook checklist ---------- */
.checklist { margin-top: 10px; }
.ck { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; background: #f4f6f8; }
.ck.ok { background: #eafaf0; }
.ck.bad { background: #fdeeee; }
.hint-fix { color: #8c2626; margin-top: 2px; }

/* ---------- business settings popup ---------- */
dialog.wide { width: min(900px, 96vw); max-height: 92vh; padding: 0; overflow: hidden; }
dialog.wide[open] { display: flex; flex-direction: column; }
.bdlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 6px; }
.bdlg-head h2 { margin: 0; }
.bdlg-head .x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); }
.bdlg-tabs { padding: 6px 22px 0; margin-bottom: 0; flex-wrap: wrap; }
.bdlg-tabs button { flex: 1; min-width: 96px; }
.bdlg-body { overflow-y: auto; padding: 14px 22px; flex: 1; }
.bdlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--line); background: #fafbfc; }
.chips.quick { margin-top: 6px; }
.chips.quick .chip { border: 0; cursor: pointer; font: inherit; font-size: 12.5px; }
.hours-box { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; }
details.adv { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 12px; }
details.adv > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.ch-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.ch-card.ok { background: #f2fbf5; border-color: #bfe8cf; }
.ch-card.off { background: #f4f6f8; }
.ch-card h3 { margin-top: 0; }
.acct { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fbfcfd; }
.team-role { margin-bottom: 10px; }
.team-title { font-weight: 600; margin-bottom: 4px; }
.team-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 8px; background: #f4f6f8; border-radius: 8px; margin-bottom: 4px; }
.team-add { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }
.team-add .row { margin: 8px 0; }
.pg-head { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(90deg, #6c8cff, #8a6cff); color: #fff; padding: 10px 14px; border-radius: 10px; }
.pg-head .btn { color: var(--text); }
.imgpick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.imgpick input[type=file] { width: auto; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb.sm { width: 28px; height: 28px; vertical-align: middle; }
.msg-img { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-top: 6px; }

/* users & permissions */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin: 6px 0; }
.perm-grid .opt { margin: 0; }
.opt.dim { opacity: .55; cursor: not-allowed; }
table.matrix th, table.matrix td { text-align: center; white-space: nowrap; }
table.matrix th:first-child, table.matrix td:first-child { text-align: left; white-space: normal; }
.steps li { margin-bottom: 6px; }

/* in-page confirm / prompt dialogs, KB tick boxes */
dialog.ask { width: min(440px, 92vw); }
dialog.ask h2 { margin-bottom: 8px; }
.ask-msg { white-space: pre-line; margin: 0 0 10px; color: var(--text); }
dialog.ask input { width: 100%; }
th.sel, td.sel { width: 34px; text-align: center; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }

td.kw .pill { margin: 1px 2px 1px 0; display: inline-block; }

/* rule dialog (แก้ไขกฎการตอบ) */
.ruleform { display: flex; flex-direction: column; gap: 10px; }
.ruleform .f { margin-bottom: 0; }
.check.big { align-items: flex-start; gap: 8px; }
.check.big > span { flex: 1; }
.sep { border-top: 1px solid var(--line); margin: 6px 0; }
.hint.indent { margin: -4px 0 0 26px; }
.ruleform-foot { margin-top: 16px; }
.btn.grow { flex: 1; padding: 11px 16px; }
.f.dim { opacity: .5; }
details.profile-box { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 4px 0 10px; }
details.profile-box summary { cursor: pointer; font-weight: 600; }

/* emoji picker */
.emoji-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 9px; cursor: pointer; font-size: 17px; line-height: 1.3; align-self: flex-start; margin-top: 4px; }
.emoji-btn:hover { border-color: var(--brand); background: #eafaf0; }
.compose .emoji-btn { margin-top: 0; height: 42px; }
.emoji-pop { position: fixed; z-index: 9999; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.28); padding: 8px; }
.emoji-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.emoji-tabs button { border: 0; background: none; font-size: 19px; padding: 3px 6px; border-radius: 8px; cursor: pointer; }
.emoji-tabs button.on { background: #eafaf0; box-shadow: inset 0 -2px 0 var(--brand); }
.emoji-title { font-size: 12px; color: var(--muted); margin: 6px 4px 2px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); max-height: 230px; overflow-y: auto; }
.emoji-grid button { border: 0; background: none; font-size: 23px; line-height: 1.5; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: #f0f3f5; }

/* inbox: chat header, chips, actions, log */
.ib-head2 { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-start; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.ib-who { display: flex; gap: 12px; align-items: flex-start; min-width: 240px; flex: 1 1 260px; }
.ib-name { min-width: 0; }
.ib-name .nm { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ib-name .nm b { font-size: 17px; letter-spacing: .02em; }
.idchip { border: 1px solid var(--line); background: #f4f6f8; color: var(--muted); border-radius: 6px; padding: 1px 7px; font-size: 11.5px; cursor: pointer; font-family: ui-monospace, Consolas, monospace; }
.idchip:hover { border-color: var(--brand); color: var(--text); }
.note-line { margin-top: 4px; font-size: 13px; cursor: text; border-bottom: 1px dashed var(--line); padding-bottom: 2px; max-width: 420px; }
.note-line input { width: 100%; }
.ib-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 260px; align-content: flex-start; }
.pchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 3px 4px 3px 9px; font-size: 13px; background: #f8fafb; }
.pchip .k { color: var(--muted); font-size: 12px; }
.pchip .cp { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 5px; border-radius: 6px; }
.pchip .cp:hover { background: #e9eef2; color: var(--text); }
.ib-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; align-items: center; }
.btn.on { background: #eafaf0; border-color: var(--brand); }
.btn.ai { border-color: #cdb8f5; color: #6a3fc0; background: #f7f2ff; }
.btn.ai:hover { background: #ede2ff; }
.log-wrap { position: relative; }
.jump { position: absolute; right: 12px; bottom: 10px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; box-shadow: 0 4px 14px rgba(0,0,0,.2); cursor: pointer; font-size: 13px; font-weight: 600; }
.compose-locked { margin-top: 10px; border: 1px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); background: #fafbfc; }
.day-sep { text-align: center; margin: 6px 0; }
.day-sep span { background: #eef1f4; color: var(--muted); border-radius: 999px; padding: 2px 12px; font-size: 12px; }
.msg .meta b { color: var(--text); font-weight: 600; }
.msg .meta .more { opacity: .85; }
.bubble .tr { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(0,0,0,.18); font-size: 13.5px; color: #3a4a5a; }
.choice { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.summary-box { white-space: pre-wrap; background: #f7f2ff; border: 1px solid #ddd0f7; border-radius: 10px; padding: 12px 14px; line-height: 1.7; }

/* the amber card under a picture */
.bubble.analysis { background: #fff8e6; border: 1px solid #f0d58a; border-top-right-radius: 4px; min-width: 260px; }
.bubble.analysis.err { background: #fbe9e9; border-color: #efb5b5; }
.bubble.analysis .ahead { font-weight: 700; color: #a86a00; margin-bottom: 4px; }
.slip { margin: 8px 0 4px; padding: 8px 10px; background: #fff; border: 1px solid #f0e2b4; border-radius: 8px; }
.slip .amt { font-size: 22px; font-weight: 700; color: #0a7d3c; }
.slip .amt::after { content: ' บาท'; font-size: 13px; font-weight: 400; color: var(--muted); }
.kv2 { display: flex; gap: 8px; font-size: 13px; }
.kv2 span { color: var(--muted); min-width: 64px; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flag { border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.flag.ok { background: #e2f6e9; color: #146c3a; }
.flag.bad { background: #fde7e7; color: #a12727; }
.abtn { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* inbox: richer list + ปิดเคส + quick replies */
.badge.red { background: #e53e3e; color: #fff; }
.btn.success { background: #06c755; border-color: #06c755; color: #fff; font-weight: 600; }
.btn.success:hover { background: #05a647; }
.ib-sub { display: flex; align-items: center; gap: 6px; margin: 1px 0; }
.ib-sub .ib-time { margin-left: auto; }
.lchip { background: #d9f5e3; color: #0a7a35; border-radius: 5px; padding: 0 6px; font-size: 11px; font-weight: 600; }
.bchip { background: #eaf1fb; color: #2b5fa8; border-radius: 5px; padding: 0 6px; font-size: 11px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-phone { font-size: 12.5px; color: #b0286a; font-weight: 600; }
.ib-note { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hashtag { background: #e8f0fe; color: #2b5fa8; border-radius: 5px; padding: 0 6px; font-size: 11.5px; }
.ib-tagrow { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.unread-sep, .case-sep { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 12.5px; font-weight: 600; }
.unread-sep { color: #d33; }
.unread-sep::before, .unread-sep::after { content: ''; flex: 1; border-top: 1px solid #f0b3b3; }
.case-sep { justify-content: center; }
.case-sep span { border-radius: 999px; padding: 3px 14px; }
.case-sep.closed span { background: #e2f6e9; color: #146c3a; }
.case-sep.reopened span { background: #fff3d6; color: #8a5a00; }
.qr-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.qr { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12.5px; overflow: hidden; }
.qr button { border: 0; background: none; cursor: pointer; padding: 3px 10px; font-size: 12.5px; }
.qr button:hover { background: #f0f3f5; }
.qr .x { padding: 3px 8px 3px 2px; color: var(--muted); }
.qr.add { border-style: dashed; padding: 3px 12px; color: var(--muted); cursor: pointer; background: none; }
.attach-prev { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.attach-prev .thumb { max-height: 54px; }
.col-icons { display: flex; flex-direction: column; gap: 4px; }
.compose { align-items: flex-start; }
