:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --border: #dfe4ea;
  --text: #18202a;
  --muted: #5d6b7c;
  --accent: #0a8f66;
  --accent-strong: #077553;
  --accent-soft: #e2f5ee;
  --accent-ink: #ffffff;
  --danger: #c9303c;
  --danger-soft: #fdecee;
  --warn: #9a5b00;
  --warn-soft: #fff3d9;
  --info-soft: #e8f0fe;
  --info: #2457c5;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", "Leelawadee UI", "Noto Sans Thai", "Sarabun", "Thonburi", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Noto Sans Thai", monospace;
  --brand-bot: #0d9488; /* รุ่น 43: สีคำว่า bot ในโลโก้ */
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-bot: #2dd4bf;
    --bg: #0f1418;
    --surface: #182027;
    --surface-2: #212b34;
    --border: #2d3944;
    --text: #e8edf2;
    --muted: #9aa8b6;
    --accent: #2fc493;
    --accent-strong: #52d6aa;
    --accent-soft: #143629;
    --accent-ink: #06231a;
    --danger: #ff6b76;
    --danger-soft: #3a1a1e;
    --warn: #f2b84b;
    --warn-soft: #3a2c10;
    --info-soft: #17274a;
    --info: #8fb1ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.35; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent-strong); }

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .field:focus-visible, .tab:focus-visible, .nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.small { min-height: 30px; padding: 2px 10px; font-size: 13px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

/* ---------- ฟอร์ม ---------- */
.field {
  width: 100%;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
textarea.field { resize: vertical; line-height: 1.6; }
.field:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
textarea.prompt { min-height: 320px; font-size: 14.5px; }
.form-row { display: grid; gap: 6px; margin-bottom: 16px; align-content: start; }
.form-row > label, .label { font-weight: 600; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- โครงหน้า ---------- */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto; /* รุ่น 57: เมนูยาวขึ้น (QC แชต) จอเตี้ยกว่า ~900px เลื่อนเมนูซ้ายได้ ปุ่มออกจากระบบไม่ถูกตัด */
  overscroll-behavior: contain;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; font-size: 16px; }
/* รุ่น 43: โลโก้ Studio Chatbot — เครื่องหมายเป็น SVG บนพื้นน้ำเงินเข้ม (คงสีเดิมทุกธีม) ชื่อระบบเป็น SVG สีตามข้อความ คำว่า bot ใช้ --brand-bot */
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: #0f172a; overflow: hidden; flex: none; }
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-word { display: inline-flex; align-items: center; color: var(--text); min-width: 0; }
.brand-word svg { display: block; height: 17px; width: auto; }
.brand-word .bot { fill: var(--brand-bot); }
.login .brand-mark { width: 40px; height: 40px; border-radius: 9px; }
.login .brand-word svg { height: 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.side-foot { margin-top: auto; padding: 8px 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.me { padding: 0 10px 6px; min-width: 0; max-width: 100%; }
.me-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center;
}
.main { padding: 26px 30px 60px; min-width: 0; }
.page { max-width: 1040px; margin: 0 auto; }
.page.wide { max-width: 1240px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cards .card + .card { margin-top: 0; }
.bot-card { display: block; text-decoration: none; color: inherit; transition: border-color 0.12s, transform 0.12s; }
.bot-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.bot-card .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stats { display: flex; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--accent-soft); color: var(--accent-strong); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--info-soft); color: var(--info); }

.notice { padding: 10px 14px; border-radius: 10px; background: var(--info-soft); color: var(--text); font-size: 14px; }
.notice.warn { background: var(--warn-soft); }
.notice.err { background: var(--danger-soft); }
.notice.ok { background: var(--accent-soft); }

code, .code {
  font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px;
  overflow-wrap: anywhere;
}

/* ---------- แท็บ ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

.savebar {
  position: sticky; top: 0; z-index: 5; margin: -26px -30px 20px; padding: 12px 30px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.savebar .inner { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crumb h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; }
.dirty { color: var(--warn); font-size: 13px; font-weight: 600; }

/* ---------- รายการ ---------- */
.list { display: grid; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
}
.item .body { min-width: 0; flex: 1; }
.item .snippet { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }

.url-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.url-row .code { flex: 1; min-width: 200px; padding: 7px 10px; }
ol.steps { margin: 8px 0 0; padding-left: 22px; color: var(--muted); font-size: 14px; }
ol.steps li { margin-bottom: 3px; }

/* ---------- หน้าต่างลอย ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 16, 22, 0.55); display: grid; place-items: center;
  padding: 16px; z-index: 50;
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); background: var(--surface); border-radius: 14px;
  border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); display: flex; flex-direction: column;
}
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- คลังรูป ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 16px; }
.img-card { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.img-card .thumb { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-2); }
.img-card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.img-card .badge {
  position: absolute; left: 8px; top: 8px; padding: 1px 8px; border-radius: 7px; font-family: var(--mono);
  font-size: 12.5px; font-weight: 700; background: rgba(12, 18, 24, 0.82); color: #fff;
}
.img-card .info { padding: 8px 10px 0; font-size: 12.5px; color: var(--muted); }
.img-card .name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-card .row { display: flex; gap: 6px; padding: 10px; margin-top: auto; }
.img-card .row .btn { flex: 1; }
.img-card .desc-box { padding: 8px 10px 0; display: grid; gap: 6px; }
.img-card .desc { font-size: 13px; line-height: 1.45; resize: vertical; min-height: 96px; }
.img-card .desc-state { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.img-card .desc-state.warn { color: var(--warn); font-weight: 600; }
.img-card .desc-state.err { color: var(--danger); }
.img-card .desc-state.ok { color: var(--accent); }
.img-card .row.tight { padding: 0; margin-top: 0; }
.upload-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- แชต ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 16px; overflow: auto; background: var(--surface-2); flex: 1; min-height: 240px; }
.msg { max-width: min(78%, 560px); display: flex; flex-direction: column; gap: 3px; }
.msg.user { align-self: flex-start; }
.msg.assistant, .msg.admin { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 12px; color: var(--muted); }
.msg .who .free-tag { margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent-strong); }
.free-hint { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-variant-numeric: tabular-nums; background: var(--accent-soft); color: var(--accent-strong); }
.slip { margin-top: 4px; padding: 8px 11px; border-radius: 11px; font-size: 13px; max-width: 380px; border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.slip.ok { background: var(--accent-soft); border-color: transparent; }
.slip.ok b { color: var(--accent-strong); }
.slip.fail { background: var(--danger-soft); border-color: transparent; }
.slip.fail b { color: var(--danger); }
.slip.pending { background: var(--warn-soft); border-color: transparent; }
.slip.pending b { color: var(--warn); }
.slip.none { border: 0; background: none; padding: 0; flex-direction: row; align-items: center; gap: 8px; }
.slip-facts { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.free-hint.soon { background: var(--warn-soft); color: var(--warn); }
.bubble { padding: 9px 13px; border-radius: 15px; background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant .bubble { background: var(--accent-soft); border-color: transparent; }
.msg.admin .bubble { background: var(--info-soft); border-color: transparent; }
.msg .pics { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg .pics img { width: 132px; height: 132px; object-fit: cover; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); }
.msg.user .pics { justify-content: flex-start; }
.msg .pics a { display: block; line-height: 0; border-radius: 11px; }
.msg .pics a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.attach-bar, .quick-attach-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.attach-bar img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.attach-bar img.outgoing { width: 96px; height: 96px; object-fit: contain; background: var(--surface-2); }
.attach-bar .name, .quick-attach-bar .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--muted); }
.msg .pics img.sticker { width: 112px; height: 112px; object-fit: contain; border: 0; border-radius: 0; background: none; }
/* วิดีโอ/เสียง/ไฟล์ที่ลูกค้าส่ง (ไฟล์อยู่ที่ LINE กดแล้วค่อยโหลด) */
.msg .pics .media { display: flex; flex-direction: column; gap: 6px; max-width: 320px; padding: 8px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); line-height: 1.35; }
.msg .pics .media-thumb { position: relative; width: 240px; max-width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #1c2630; cursor: pointer; }
.msg .pics .media-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; background: none; }
.msg .pics .media-play { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: #111; font-size: 22px; line-height: 52px; text-align: center; padding: 0 0 0 4px; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); }
.msg .pics .media-play:hover { background: #fff; }
.msg .pics .media-play:disabled { opacity: 0.6; cursor: default; }
.msg .pics .media-audio .media-play { position: static; width: 34px; height: 34px; margin: 0; font-size: 15px; line-height: 34px; background: var(--accent); color: #fff; box-shadow: none; }
.msg .pics .media-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.msg .pics .media a.btn { text-decoration: none; line-height: 1.3; }
.msg .pics .media-label { flex: 1; min-width: 0; font-weight: 600; }
.msg .pics .media-player { display: block; width: 300px; max-width: 100%; border-radius: 10px; background: #000; }
.msg .pics audio.media-player { background: none; height: 40px; }
.msg .pics .media-file { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.msg .pics .media-file > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.msg .pics .media-icon { font-size: 24px; }
.msg .pics .media-note:empty { display: none; }
.btn.icon { min-width: 42px; padding: 4px 8px; font-size: 20px; line-height: 1; }
.picker { border-top: 1px solid var(--border); background: var(--surface); padding: 10px 14px; max-height: 250px; overflow: auto; }
.picker-group + .picker-group { margin-top: 8px; }
.picker-label { font-size: 12.5px; color: var(--muted); margin: 2px 0 4px; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 2px; }
.emoji { width: 38px; height: 38px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 22px; line-height: 1; padding: 0; }
.emoji:hover, .sticker-tile:hover, .pack-tab:hover { background: var(--surface-2); }
.emoji:focus-visible, .sticker-tile:focus-visible, .pack-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pack-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.pack-tab { flex: none; width: 44px; height: 44px; padding: 4px; border: 0; border-radius: 9px; background: none; cursor: pointer; }
.pack-tab.active { background: var(--accent-soft); }
.pack-tab img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; }
.sticker-tile { aspect-ratio: 1 / 1; padding: 6px; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.sticker-tile img { width: 100%; height: 100%; object-fit: contain; display: block; }
.meter { width: 100%; height: 10px; margin: 12px 0 6px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); accent-color: var(--accent); }
.meter::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.sysnote { align-self: center; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); padding: 3px 12px; border-radius: 999px; text-align: center; }
.sysnote.err { color: var(--danger); border-color: var(--danger); }
.reply-as + .composer, .reply-as + .picker[hidden] + .composer { border-top: 0; padding-top: 4px; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; }
.chat-box { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); height: min(620px, calc(100vh - 260px)); min-height: 380px; }

/* ---------- กล่องข้อความ ---------- */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 14px; height: calc(100vh - 150px); min-height: 440px; }
.conv-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: auto; }
.conv {
  display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  text-decoration: none; color: inherit;
}
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.conv .body { min-width: 0; flex: 1; }
.conv .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .time { font-size: 12px; color: var(--muted); flex: none; }
.conv .last { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .chips { display: flex; gap: 6px; margin-top: 4px; }
.avatar-wrap { position: relative; flex: none; width: 40px; height: 40px; }
.oa-logo {
  flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 800;
}
.oa-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.oa-logo.mini { position: absolute; right: -5px; bottom: -5px; width: 22px; height: 22px; font-size: 11px; border: 2px solid var(--surface); }
.oa-logo.big { width: 52px; height: 52px; font-size: 21px; border: 1px solid var(--border); }
.conv.active .oa-logo.mini { border-color: var(--accent-soft); }
.reply-as { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.reply-as-text { min-width: 0; line-height: 1.35; }
.reply-as-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-as-note { color: var(--warn); font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.oa-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pane { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pane-foot-hint { padding: 0 14px 10px; font-size: 12.5px; color: var(--muted); background: var(--surface); }
.back-mobile { display: none; }
/* รุ่น 63: ชื่อเรียกลูกค้า — ปุ่มดินสอข้างชื่อ และชื่อ LINE ตัวเล็กใต้ชื่อเรียก */
.pane-head h3.cust-name { cursor: pointer; border-radius: 6px; position: relative; }
.pane-head h3.cust-name:hover, .pane-head h3.cust-name:focus-visible { text-decoration: underline dotted; text-underline-offset: 3px; }
.pane-head h3.cust-name:hover::after, .pane-head h3.cust-name:focus-visible::after { content: '✏️'; position: absolute; right: -22px; top: 1px; font-size: 12px; opacity: 0.7; pointer-events: none; }
.pane-head .nick-line { font-size: 12px; margin: -2px 0 2px; }
/* รุ่น 63: รูปที่แนบกับข้อความสำเร็จรูป */
.quick-pics { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.quick-pics img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.quick-card .quick-pics img { width: 44px; height: 44px; }
.slash-item .quick-pics { margin-top: 2px; }
.slash-item .quick-pics img { width: 28px; height: 28px; border-radius: 6px; }
.quick-img-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.quick-img { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 108px; }
.quick-img img { width: 108px; height: 108px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.quick-img .quick-img-tools { display: flex; gap: 2px; }
.quick-img .quick-img-tools .btn { padding: 0 6px; min-height: 24px; font-size: 12px; }
.quick-img .quick-img-no { font-size: 11.5px; color: var(--muted); }
.quick-attach-bar { flex-wrap: wrap; } /* รุ่น 63: รูปจากข้อความสำเร็จรูปรอส่ง (คนละแถบกับรูปที่แอดมินเลือกส่งเอง) */
.quick-attach-bar .quick-pics { margin-top: 0; }
.msg .pics img.quick-pic { max-width: 220px; }
.pending-pics { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.pending-pics img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; opacity: 0.7; border: 1px solid var(--border); }

/* ---------- ตัวกรองเคส + ทีมงาน ---------- */
.conv-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.conv-col .conv-list { flex: 1; min-height: 0; }
.inbox-filter-tabs { flex-wrap: wrap; } /* รุ่น 78: แท็บกล่องข้อความ 6 ตัว (ทั้งหมด/รอรับเคส/ของฉัน/เพื่อนใหม่/ปิดแล้ว/สแปม) ขึ้นสองแถวแทนล้นขอบคอลัมน์ */
.inbox-filter-tabs .seg-btn { flex: 1 1 auto; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: var(--surface-2); }
.seg-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 4px 8px;
  border: 0; border-radius: 8px; background: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted);
}
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12); }
.seg-count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
.seg-count.quiet { background: var(--border); color: var(--text); }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 4px; }
.perms { display: grid; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.perm:hover { background: var(--surface-2); }
.perm input { width: 17px; height: 17px; margin-top: 4px; accent-color: var(--accent); flex: none; }
.perm span { display: grid; }
.perm:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

/* ---------- บันทึกระบบ ---------- */
.log { padding: 12px 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.log .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.log .text { margin-top: 4px; font-weight: 550; }
.log pre { margin: 8px 0 0; padding: 10px; background: var(--surface-2); border-radius: 8px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }

/* ---------- เข้าสู่ระบบ ---------- */
.login, .boot-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; } /* รุ่น 76.1: .boot-screen = การ์ด "กำลังเปิดระบบ…" ระหว่างรอ /api/session */
.login .card, .boot-screen .card { width: min(380px, 100%); padding: 28px; }
.login .brand { padding: 0 0 18px; }

/* ---------- แจ้งเตือน ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 36px)); }
.toast { padding: 11px 15px; border-radius: 10px; background: #18202a; color: #fff; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { background: #b3232e; }
.toast.ok { background: #0a7a57; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } /* แถบเมนูบนสูงเท่าเนื้อหาของมัน (ไม่ถูกยืดเมื่อหน้าสั้นกว่าจอ) */
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; gap: 8px; }
  .brand { padding: 0 4px; }
  .brand span { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 10px; white-space: nowrap; font-size: 14px; }
  .side-foot { margin: 0 0 0 auto; padding: 0; flex-direction: row; align-items: center; flex: none; }
  .me { display: none; }
  .side-foot .btn { white-space: nowrap; }
  .main { padding: 18px 14px 50px; }
  .savebar { margin: -18px -14px 16px; padding: 10px 14px; top: 55px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox.has-open .conv-col { display: none; }
  .inbox:not(.has-open) .pane { display: none; }
  .pane { height: calc(100vh - 170px); min-height: 420px; }
  .back-mobile { display: inline-flex; }
  .msg { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition: none !important; }
}

/* ---------- แท็กและโน้ตลูกค้า ---------- */
.chip.tag { background: hsl(var(--tag-h) 70% 91%); color: hsl(var(--tag-h) 65% 26%); }
.tag-x { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; color: inherit; opacity: 0.7; }
.tag-x:hover, .tag-x:focus-visible { opacity: 1; }
.conv .chips { flex-wrap: wrap; }
.tag-filter, .case-filter, .inbox-vip { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.inbox-filters { display: flex; gap: 6px; }
.inbox-filters > select { flex: 1; min-width: 0; }
.inbox-filters > select[hidden] { display: none; }
.inbox-vip.active { border-color: var(--warn); color: var(--warn); font-weight: 600; }
.oa-pick { position: relative; }
.conv-col .inbox-team { margin-bottom: 8px; font-weight: 600; }
.conv-col .inbox-brand { margin-bottom: 8px; font-weight: 600; }
/* VIP (รุ่น 35): ป้ายระดับ เห็นเฉพาะคนที่มีสิทธิ์ */
.chip.vip { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.vip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vip-total { font-size: 13px; color: var(--muted); }
.vip-total b { color: var(--text); }
.same-list { display: grid; gap: 6px; }
.same-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.same-row:hover { border-color: var(--accent); }
.same-row .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier-rows { display: grid; gap: 6px; }
.tier-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.tier-row .lvl { font-weight: 700; color: var(--muted); }
.brand-item .stats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.oa-current, .oa-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.oa-current:hover, .oa-row:hover { border-color: var(--accent); }
.oa-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oa-counts { display: flex; gap: 5px; flex-shrink: 0; }
.oa-counts .chip { font-size: 11.5px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.oa-caret { color: var(--muted); font-size: 12px; }
.oa-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-height: 360px; overflow: auto; padding: 5px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 30px rgb(0 0 0 / 0.16); display: flex; flex-direction: column; gap: 3px; }
.oa-row { border-color: transparent; padding: 7px 8px; }
.oa-row.active { background: var(--accent-soft); }
.inbox-search { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.list-info { padding: 0 4px; margin-top: -4px; }
.list-more { display: flex; justify-content: center; padding: 12px; }

.cust-bar { padding: 8px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.cust-bar:empty { display: none; }
.cust-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag-input { width: 190px; min-height: 30px; padding: 2px 9px; font-size: 13.5px; }
.note-view { background: var(--warn-soft); border-radius: 9px; padding: 8px 12px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; max-height: 96px; overflow: auto; }
.note-edit { display: grid; gap: 8px; }

/* ---------- ข้อความสำเร็จรูป ---------- */
.quick-head { display: flex; gap: 8px; align-items: center; }
.quick-list { display: grid; gap: 4px; }
.quick-item { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); cursor: pointer; }
.quick-item:hover { background: var(--surface-2); border-color: var(--accent); }
.quick-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.quick-item > span { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.quick-form { box-shadow: none; }
.quick-form .label { margin-bottom: 10px; }

/* ---------- เลือก LINE OA ให้ทีมงาน ---------- */
.oa-logo.tiny { width: 24px; height: 24px; font-size: 11px; border: 1px solid var(--border); }
.oa-pick { align-items: center; }
.oa-pick input { margin-top: 0; }
.oa-cell { display: flex; align-items: center; gap: 8px; }

/* ---------- การแจ้งเตือนเคส ---------- */
#alerts { position: fixed; top: 10px; right: 16px; display: grid; gap: 6px; z-index: 101; max-width: min(420px, calc(100vw - 32px)); }
.toast.alert { background: #8a4b00; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 8px; font-size: 13px; line-height: 1.35; }
.toast.alert b { white-space: nowrap; }
.toast.alert .alert-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.95; }
.toast.alert .alert-x { flex: none; width: 24px; height: 24px; border: 0; border-radius: 6px; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; padding: 0; }
.toast.alert .alert-x:hover { background: rgba(255, 255, 255, 0.28); }
.toast.alert:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.toast-hint { font-size: 12px; opacity: 0.85; }

/* ---------- แดชบอร์ด ---------- */
.dash-seg { min-width: 240px; }
.dash-rolled { margin: -6px 0 12px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--text); } /* รุ่น 52.2: ช่วงที่ใช้สรุปรายวัน */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-tile.warn { border-color: var(--warn); background: var(--warn-soft); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 750; line-height: 1.3; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: stretch; gap: 4px; height: 190px; margin-top: 12px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bar-set { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--border); }
.bar { flex: 1; max-width: 16px; border-radius: 3px 3px 0 0; }
.bar.customer, .key.customer::before { background: var(--info); }
.bar.bot, .key.bot::before { background: var(--accent); }
.bar.admin, .key.admin::before { background: var(--warn); }
.bar-label { height: 16px; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.key::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table th { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: 0; }
@media (prefers-color-scheme: dark) {
  .chip.tag { background: hsl(var(--tag-h) 40% 22%); color: hsl(var(--tag-h) 75% 82%); }
  .toast.alert { background: #6e3d05; }
}

/* ---------- สาย และค่าใช้จ่าย ---------- */
.team-item .stats { margin-top: 8px; }
.field.price { width: 120px; min-height: 32px; padding: 3px 8px; text-align: right; }
.table td .field.price { display: inline-block; }
.seg-btn { white-space: nowrap; }
.dash-seg.wide { min-width: 340px; }
.list + .card { margin-top: 14px; }

/* ---------- แดชบอร์ดรายคน ---------- */
button.stat-tile { font: inherit; color: inherit; text-align: left; cursor: pointer; display: block; width: 100%; }
button.stat-tile:hover { border-color: var(--accent); }
button.stat-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-more { color: var(--accent-strong); font-weight: 600; margin-top: 2px; }
.person { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legend-list { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 2px; }

/* ประเภทเคส */
.chip.cat { background: var(--info-soft); color: var(--info); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-list { display: flex; flex-direction: column; gap: 8px; }
.case-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: center; }
.case-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.case-select { min-height: 30px; padding: 2px 8px; font-size: 13px; width: auto; max-width: 220px; }
.reason-name { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.reason-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.reason-bar > div { height: 100%; background: var(--info); border-radius: 3px; }
@media (max-width: 640px) {
  .case-row { grid-template-columns: 1fr auto; }
  .case-row .case-hint { grid-column: 1 / -1; grid-row: 2; }
}

/* สุขภาพของ LINE OA: โควตาข้อความ และสิทธิ์ตอบฟรี */
.oa-health { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.oa-health-row { border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-width: 0; }
.oa-health-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.oa-health-head .label { margin: 0; }
.oa-health-row .hint { margin: 6px 0 0; }
.oa-health-row .notice { margin: 0 0 10px; font-size: 14px; }
.oa-health-row .notice > div + div { margin-top: 4px; }
.quota-text { font-size: 14px; }
.quota-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.quota-bar > div { height: 100%; border-radius: 4px; background: var(--accent); }
.quota-bar.low > div { background: var(--warn); }
.quota-bar.out > div { background: var(--danger); }
@media (max-width: 760px) {
  .oa-health { grid-template-columns: 1fr; }
}

/* ข้อความที่เพิ่งกดส่ง (รอผล / ส่งไม่สำเร็จ) */
.msg.pending .bubble { opacity: 0.6; }
.msg.failed .bubble { background: var(--danger-soft); border-color: var(--danger); }
.msg.failed .who { color: var(--danger); font-weight: 600; }
.send-error { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 13px; color: var(--danger); text-align: right; }
.send-error .actions { display: flex; gap: 6px; }

/* คีย์ลัดและรายการข้อความสำเร็จรูปที่ขึ้นเมื่อพิมพ์ / ในช่องตอบ */
.chip.quick-key { background: var(--accent-soft); color: var(--accent-strong); font-family: var(--mono); font-weight: 600; }
.shortcut-row { display: flex; align-items: center; gap: 8px; max-width: 320px; }
.shortcut-slash { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--muted); }
.composer { position: relative; }
.slash-list { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 4px); z-index: 5; display: grid; gap: 4px; max-height: 300px; overflow: auto; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.slash-list[hidden] { display: none; }
.slash-item { display: grid; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid transparent; border-radius: 9px; background: none; cursor: pointer; font: inherit; color: inherit; }
.slash-item.active, .slash-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.slash-item > span { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.slash-tip { font-size: 12px; color: var(--muted); padding: 2px 4px 0; }
.slash-empty { padding: 6px 4px; }

/* แผงข้อความสำเร็จรูปแบบเต็มจอ (กดปุ่ม ⚡) */
.overlay.quick-overlay { display: flex; align-items: stretch; justify-items: stretch; padding: 28px; }
.quick-sheet { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); overflow: hidden; }
.quick-sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.quick-sheet-head h2 { margin: 0; font-size: 20px; white-space: nowrap; }
.quick-sheet-oa { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.quick-search { flex: 1; min-width: 240px; min-height: 48px; padding: 8px 16px; font-size: 17px; border: 2px solid var(--accent); border-radius: 12px; }
.quick-grid { flex: 1; overflow: auto; padding: 20px 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); grid-auto-rows: max-content; gap: 14px; align-content: start; background: var(--bg); }
.quick-card { display: flex; flex-direction: column; gap: 8px; min-height: 120px; padding: 14px 16px; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; cursor: pointer; }
.quick-card:hover { border-color: var(--accent); }
.quick-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quick-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quick-card-head b { font-size: 17px; overflow-wrap: anywhere; }
.quick-card-head .chip.quick-key { font-size: 15px; padding: 2px 10px; }
.quick-card-text { font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.quick-empty { grid-column: 1 / -1; }
.quick-sheet-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
@media (max-width: 760px) {
  .overlay.quick-overlay { padding: 0; }
  .quick-sheet { border-radius: 0; }
  .quick-sheet-head { padding: 12px 14px; gap: 8px; }
  .quick-sheet-head h2 { font-size: 17px; }
  .quick-sheet-head h2 { flex: 1; }
  .quick-sheet-oa { order: 6; flex-basis: 100%; max-width: none; }
  .quick-search { order: 5; min-width: 100%; }
  .quick-grid { padding: 12px; grid-template-columns: 1fr; }
  .quick-sheet-foot { padding: 10px 14px; }
  .quick-sheet-keys { display: none; }
}

/* หน้าโปรโมชั่นและคูปอง */
.promo-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.promo-oa { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; max-width: 420px; }
.offer-list { display: grid; gap: 12px; }
.offer-card { display: flex; gap: 16px; align-items: flex-start; margin: 0; }
.offer-card.dim { opacity: 0.72; }
.offer-thumb { flex: none; width: 168px; height: 112px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.offer-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.offer-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.offer-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.offer-title h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.offer-when { margin: 0; }
.offer-detail { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.offer-actions { margin-top: 4px; }
/* รุ่น 38: แยกส่วน "ทั้งแบรนด์" กับ "เฉพาะ OA นี้" */
.offer-group { margin-bottom: 18px; }
.offer-group-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.offer-group-head h2 { margin: 0; font-size: 16px; }
.offer-group-head .hint { margin: 0; }
#offer-group-brand .offer-card { border-left: 3px solid var(--accent); }
.offer-empty { padding: 18px; }
.offer-empty h2 { font-size: 15px; }
.offer-readonly { align-self: center; }
.field-static { margin: 0; padding: 8px 0; font-size: 14.5px; }
.grant-oa { color: var(--muted); font-size: 13px; }
.offer-image-box { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.offer-image-box img { max-width: 240px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); }
@media (max-width: 640px) {
  .offer-card { flex-direction: column; }
  .offer-thumb { width: 100%; height: 160px; }
}

/* ตอบกลับแบบอ้างถึงข้อความ (quote) */
.msg .who .quote-btn { margin-left: 8px; padding: 0 4px; border: 0; background: none; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; border-radius: 6px; }
.msg .who .quote-btn:hover, .msg .who .quote-btn:focus-visible { color: var(--accent-strong); background: var(--accent-soft); outline: none; }
.msg .quoted { display: flex; flex-direction: column; gap: 1px; max-width: 100%; padding: 5px 10px; border: 0; border-left: 3px solid var(--border-strong, var(--border)); border-radius: 8px; background: var(--surface-2); font: inherit; font-size: 12.5px; color: var(--muted); text-align: left; cursor: pointer; }
.msg .quoted b { font-size: 11.5px; color: var(--text); }
.msg .quoted span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.flash .bubble, .msg.flash .pics img { outline: 2px solid var(--accent); outline-offset: 2px; transition: outline-color 0.3s; }
.quote-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.quote-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 10px; border-left: 3px solid var(--accent); font-size: 13px; }
.quote-bar-text b { font-size: 12px; color: var(--accent-strong); }
.quote-bar-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.quote-bar:not([hidden]) + .composer { border-top: 0; padding-top: 4px; }
/* ลากไฟล์รูปมาวางในแชต */
.pane.dropping { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* ---------- ข้อมูลลูกค้า (เฉพาะเจ้าของระบบ) ---------- */
.link-btn { font: inherit; color: var(--accent-strong); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button.stat-tile.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.contact-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.contact-filters .field { width: auto; min-width: 150px; flex: 0 1 190px; }
.contact-filters input[type='search'] { flex: 1 1 200px; }
.contact-table .group-row td { background: var(--surface-2); font-weight: 650; font-size: 13px; color: var(--muted); padding: 6px 10px; }
.contact-table td { vertical-align: top; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; font-size: 14px; color: var(--muted); }
.contact-setting { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border); }
.contact-setting:first-of-type { border-top: 0; padding-top: 0; }
.contact-setting > div { flex: 1; min-width: 0; }
.contact-setting .btn { flex: none; }
.contact-phone { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.contact-phone > div:first-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quote-src { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .contact-setting { flex-direction: column; }
}

/* ---------- เจ้าของระบบ: เลือกสายก่อนดูรายการ ---------- */
button.team-card { font: inherit; text-align: left; cursor: pointer; width: 100%; }
button.team-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.team-card h2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-search { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.team-search .field { flex: 1 1 280px; max-width: 460px; }
.team-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.team-bar .field { width: auto; min-width: 200px; max-width: 100%; }
#dash-team, #bill-team { width: auto; min-width: 150px; max-width: 100%; } /* รุ่น 44: ตัวเลือกสายบนแดชบอร์ด อยู่แถวเดียวกับปุ่มช่วงวัน · รุ่น 58: หน้าบิลด้วย */

/* ตัวแปรในข้อความสำเร็จรูป */
.quick-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.quick-vars .hint { margin: 0; }

/* ประวัติเคส */
.case-history { font-size: 14px; }
.case-day { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.case-day:first-child { margin-top: 4px; }
.case-event { display: grid; grid-template-columns: 46px 26px 1fr; gap: 8px; align-items: start; padding: 7px 0; }
.case-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.case-icon { font-size: 16px; line-height: 1.3; }
.case-text b { display: block; font-weight: 600; }
.case-text span { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
.case-event.legacy .case-text b { font-weight: 500; }

/* ช่องข้อมูลลูกค้าที่ทีมตั้งเอง */
.cust-fields { gap: 6px; }
.cust-field { border: 1px solid var(--border); border-radius: 8px; padding: 2px 9px; font-size: 13.5px; background: var(--surface); max-width: 100%; overflow-wrap: anywhere; }
.cust-field-name { color: var(--muted); }
.field-hit { font-size: 13px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.field-hit mark { background: var(--warn-soft); color: var(--text); border-radius: 4px; padding: 0 4px; font-weight: 700; }
.cf-form { margin-top: 16px; }
.cf-item h3 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* รูปและสลิปทั้งหมดของลูกค้ารายคน */
.gallery-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.gallery-sum { font-size: 14px; font-weight: 600; background: var(--accent-soft); color: var(--accent-strong); border-radius: 9px; padding: 6px 12px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.gallery-grid .empty { grid-column: 1 / -1; }
.gallery-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; min-width: 0; }
.gallery-pic { display: block; height: 190px; background: var(--surface-2); overflow: hidden; }
.gallery-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.gallery-pic.gone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 13.5px; text-align: center; padding: 10px; }
.gallery-info { padding: 9px 11px 10px; display: grid; gap: 4px; }
.gallery-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gallery-amount { font-weight: 700; font-size: 14px; }
.gallery-more { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.gallery-jump { border: 0; background: none; padding: 0; margin-top: 2px; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent-strong); cursor: pointer; text-align: left; }
.gallery-jump:hover { text-decoration: underline; }
.gallery-jump:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.gallery-old { font-size: 12.5px; }
.gallery-foot { margin: 14px 0 0; text-align: center; }
@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .gallery-pic { height: 150px; }
  .cf-form .grid-2 { grid-template-columns: 1fr; }
}

/* Facebook เพจ (รุ่นทดลอง) */
.inbox-tabs { flex: none; align-self: center; }
.inbox-tabs a.seg-btn { text-decoration: none; padding: 4px 16px; min-width: 96px; }
.meta-steps { margin: 6px 0 0; padding-left: 22px; display: grid; gap: 6px; font-size: 14px; line-height: 1.6; }
#meta-app-card h2, #meta-connect-card h2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#meta-app-card .url-row .code { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  #meta-app-card .grid-2 { grid-template-columns: 1fr; }
}
/* มีแท็บ LINE OA / Facebook (เจ้าของระบบที่เชื่อมเพจแล้ว): หัวหน้าไม่สูงขึ้น แท็บอยู่แถวเดียวกับชื่อหน้า จอแคบซ่อนคำอธิบายใต้ชื่อ */
.page-head:has(.inbox-tabs:not([hidden])) { flex-wrap: nowrap; align-items: center; }
.page-head:has(.inbox-tabs:not([hidden])) > div:first-child { min-width: 0; }
@media (max-width: 1100px) {
  .page-head:has(.inbox-tabs:not([hidden])) .sub { display: none; }
}
@media (max-width: 640px) {
  .inbox-tabs a.seg-btn { min-width: 0; padding: 4px 10px; }
}

/* ---------- หน้าแชต: ให้พื้นที่กับบทสนทนามากขึ้น ---------- */
/* ช่องพิมพ์ต้องอยู่ในจอเสมอ: บนจอเตี้ย แถบข้อมูลลูกค้าที่กางอยู่จะเลื่อนในตัวเองแทนการดันช่องพิมพ์ตกขอบ */
.pane .chat { min-height: 150px; }
.cust-bar { min-height: 0; overflow-y: auto; flex-shrink: 1; }
.pane-head, .reply-as, .composer, .pane-foot-hint, .quick-attach-bar { flex: none; }
/* แถบข้อมูลลูกค้าแบบย่อ: บรรทัดเดียว ส่วนที่ยาวเกินถูกตัดท้าย */
.cust-bar:has(.cust-compact) { padding: 6px 16px; overflow: hidden; }
.cust-compact { flex-wrap: nowrap; gap: 8px; min-width: 0; }
.cust-compact-items { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.cust-compact-items > * { flex: none; }
.cust-mini { font-size: 13.5px; }
.cust-note-mini { flex: 0 1 auto !important; min-width: 96px; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; background: var(--warn-soft); border-radius: 7px; padding: 1px 8px; }
.chip.cat-none { border: 1px dashed var(--border); background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip.cat-none:hover { color: var(--text); border-color: var(--muted); }
.chip.cat-none:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cust-compact #cust-toggle { flex: none; white-space: nowrap; }
.cust-collapse { margin-left: auto; }
/* แถบ "กำลังตอบในนาม": บรรทัดเดียว โลโก้เล็ก (ชี้ที่โน้ตเพื่ออ่านเต็ม) */
.reply-as { padding: 5px 14px; gap: 8px; }
.reply-as .oa-logo.big { width: 26px; height: 26px; font-size: 12px; }
.reply-as-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; line-height: 1.5; }
.reply-as-text .hint { flex: none; }
.reply-as-name { font-size: 14px; flex: 0 0 auto; max-width: 45%; }
.reply-as-note { font-size: 13px; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
/* ขยายแชต: ซ่อนรายการแชตด้านซ้ายและหัวข้อหน้า */
@media (min-width: 861px) {
  .inbox.chat-wide { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 28px); }
  .inbox.chat-wide .conv-col { display: none; }
  .chat-wide-page .page-head { display: none; }
  .page.chat-wide-page { max-width: none; }
  .main:has(> .chat-wide-page) { padding: 14px 18px; }
}
@media (max-width: 860px) {
  .chat-wide-btn { display: none; } /* จอมือถือ แชตเต็มจออยู่แล้ว */
}
@media (max-width: 640px) {
  .reply-as-text { flex-wrap: wrap; white-space: normal; gap: 0 8px; }
  .reply-as-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow-wrap: anywhere; flex-basis: 100%; }
}

/* ข้อความสำเร็จรูป: รายการโปรดและใช้ล่าสุด */
.quick-card-wrap { position: relative; display: flex; min-width: 0; }
.quick-card-wrap .quick-card { flex: 1; min-width: 0; }
.quick-card-wrap .quick-card-head { padding-right: 34px; }
.quick-star { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; font-size: 21px; line-height: 1; color: var(--muted); cursor: pointer; }
.quick-star:hover { background: var(--surface-2); color: var(--warn); }
.quick-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.quick-card-wrap.fav .quick-star { color: #d97706; }
.quick-card-wrap.fav .quick-card { border-color: #f3c97a; }
.quick-card-wrap.fav .quick-card.active, .quick-card-wrap.fav .quick-card:hover { border-color: var(--accent); }
.chip.quick-recent { background: var(--info-soft); color: var(--info); font-size: 12px; }
.slash-fav { color: #d97706; }

/* รูปที่ตรวจแล้วไม่ใช่สลิป: เหลือลิงก์เล็ก ๆ ให้กดตรวจเอง */
.slip-quiet { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.slip-quiet:hover { color: var(--text); }
.slip-quiet:disabled { opacity: 0.6; cursor: default; }
.slip.none.quiet { margin-top: 2px; line-height: 1.2; }
/* จอที่มีเมาส์: ซ่อนไว้จนกว่าจะชี้ที่ข้อความนั้น (หรือโฟกัสด้วยแป้นพิมพ์) · จอสัมผัสแสดงเป็นลิงก์เล็กตลอด */
@media (hover: hover) {
  .slip.none.quiet .slip-quiet { opacity: 0; transition: opacity 0.12s; }
  .msg:hover .slip.none.quiet .slip-quiet, .slip.none.quiet .slip-quiet:focus-visible, .slip.none.quiet .slip-quiet:disabled { opacity: 1; }
}

/* ---------- ดูรูปขยายในหน้าเดิม ---------- */
.overlay.img-viewer { display: flex; flex-direction: column; align-items: stretch; padding: 0; background: rgba(8, 12, 16, 0.9); z-index: 60; }
.img-viewer-bar { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; }
.img-viewer-bar .btn { background: rgba(255, 255, 255, 0.94); color: #1b2430; border-color: transparent; text-decoration: none; }
.img-viewer-bar .btn:hover { background: #fff; }
.img-viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 0 14px 14px; }
.img-viewer-pic { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; background: #fff; cursor: zoom-in; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.img-viewer-stage.zoomed .img-viewer-pic { max-width: none; max-height: none; height: auto; cursor: zoom-out; }
.img-viewer-error { margin: auto; max-width: 420px; padding: 18px 20px; border-radius: 12px; background: var(--surface); color: var(--text); text-align: center; line-height: 1.6; }

/* ---------- แดชบอร์ด: เลือกช่วงวันที่เอง ---------- */
.dash-seg { min-width: 0; }
.dash-range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px; margin: -8px 0 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.dash-range-field { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dash-range-field .field { width: auto; min-height: 34px; padding: 4px 8px; }
.dash-range .hint { flex-basis: 100%; }
.bars.dense { overflow-x: auto; padding-bottom: 4px; }
.bars.dense .bar-col { flex: 0 0 24px; }

/* ---------- แถบเตือนเคส (จอเล็ก: อยู่ใต้แถบเมนูด้านบน) ---------- */
@media (max-width: 860px) {
  #alerts { top: 58px; right: 10px; left: 10px; max-width: none; }
}

/* ---------- แชตที่ถูกทำเครื่องหมายสแปม ---------- */
.chip.spam { background: #3a3a3a; color: #fff; }
@media (prefers-color-scheme: dark) { .chip.spam { background: #5a5a5a; color: #fff; } }

/* ---------- สร้างรูปด้วย AI ---------- */
.img-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.img-layout[hidden], .img-history[hidden] { display: none; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-3 .form-row { margin-bottom: 0; }
.chips-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 13.5px; text-align: left; }
.pick b { font-size: 14px; }
.pick span { font-size: 12px; color: var(--muted); }
.pick.small { flex-direction: row; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-weight: 600; }
.pick.small .pick-sub { font-weight: 500; }
.pick:hover { border-color: var(--accent); }
.pick.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.pick.active span { color: var(--accent-strong); opacity: 0.85; }
.pick:disabled { opacity: 0.45; cursor: not-allowed; }
.pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.img-custom { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.img-custom .field { width: 110px; }
.img-examples { display: grid; gap: 6px; margin-top: 8px; }
.img-example { text-align: left; padding: 8px 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; font-size: 13.5px; }
.img-example:hover { border-color: var(--accent); background: var(--accent-soft); }
.img-refs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.img-ref { position: relative; width: 84px; height: 84px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.img-ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-ref-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
.img-result { position: sticky; top: 14px; }
.img-stage { position: relative; width: 100%; max-height: 70vh; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.img-stage.failed { cursor: default; background: var(--danger-soft); }
.img-pic { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-wait { display: grid; justify-items: center; gap: 8px; padding: 24px; text-align: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.img-actions { margin-top: 12px; }
.img-prompt { margin: 12px 0 4px; font-size: 14px; white-space: pre-wrap; }
.img-ref-mode { margin: 2px 0 10px; }
.img-size-pick { margin: 2px 0 6px; }
.img-size-pick .pick.small span { font-size: 11.5px; }
.img-sent { margin: 6px 0 2px; font-size: 13px; }
.img-sent summary { cursor: pointer; color: var(--muted); }
.img-sent-text { margin: 6px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font: inherit; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.img-meta { margin-top: 4px; }
.img-edit { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.img-edit[hidden] { display: none; }
.img-empty { display: grid; justify-items: center; gap: 6px; padding: 60px 20px; text-align: center; color: var(--muted); }
.img-empty-art { font-size: 44px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; align-items: start; }
.img-card { display: block; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: inherit; box-shadow: var(--shadow); }
.img-card:hover, .img-card.active { border-color: var(--accent); }
.img-card.active { box-shadow: 0 0 0 2px var(--accent-soft); }
.img-thumb { width: 100%; aspect-ratio: 1 / 1; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-card-body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.img-card-prompt { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.img-card.failed .img-thumb { background: var(--danger-soft); }
@media (max-width: 960px) {
  .img-layout { grid-template-columns: 1fr; }
  .img-result { position: static; }
  .grid-3 { grid-template-columns: 1fr; }
}
.img-form .form-row > .btn { justify-self: start; }
.pick.ai { border-style: dashed; }
.pick.ai.active { border-style: solid; }
/* โหมดบรีฟ (รุ่น 41): สวิตช์ 2 โหมด บรีฟช่องเดียว ตัวหนังสือที่ระบบวางเอง และผลการตีความ */
.img-mode { margin-bottom: 14px; }
.img-mode .seg-btn { flex: 1; }
.img-brief-hint { margin: 6px 0 0; }
.img-note { margin: 6px 0 2px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--text); }
.img-preview { display: grid; gap: 8px; margin-top: 10px; padding: 12px; border: 1px solid var(--accent); border-radius: 12px; background: var(--surface-2); }
.img-preview[hidden] { display: none; }
.img-preview textarea { font-size: 13px; }
.img-overlay-box { display: grid; gap: 8px; margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 12px; }
.img-overlay-box[hidden] { display: none; }
.img-overlay-box .label-row { gap: 10px; flex-wrap: wrap; }
.img-overlay-box .label-row .label { margin: 0; min-width: 64px; }
.img-stage canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
/* ช่องกำหนดขนาดเอง (รุ่น 41.1): สลับ ใส่พิกเซล / ใส่สัดส่วน */
.img-custom-box { display: grid; gap: 8px; margin-top: 8px; }
.img-size-mode { display: inline-flex; width: auto; }
.img-size-mode .seg-btn { padding: 5px 12px; font-size: 13px; }
.img-ratio { display: grid; gap: 6px; }
.img-ratio .img-custom { margin-top: 0; }
.img-ratio .img-custom .field { width: 84px; }
.img-ratio[hidden], .img-custom[hidden] { display: none; }
.hint.err { color: var(--danger); }
/* ฟอนต์ไทยสำหรับวางตัวหนังสือทับรูป (โหลดเฉพาะตอนใช้) ดู public/fonts/LICENSE-Loma.txt */
@font-face { font-family: 'LAS Thai'; src: url('/fonts/Loma.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'LAS Thai'; src: url('/fonts/Loma-Bold.otf') format('opentype'); font-weight: 700; font-display: swap; }

/* ---------- บรอดแคสต์ ---------- */
.bc-item .label-row { justify-content: flex-start; }
.bc-steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.bc-step { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13.5px; }
.bc-step b { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--border); color: var(--text); font-size: 12px; }
.bc-step.active { background: var(--accent-soft); color: var(--accent-strong); }
.bc-step.active b, .bc-step.done b { background: var(--accent); color: #fff; }
.bc-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.bc-items { display: grid; gap: 12px; margin-bottom: 12px; }
.bc-items .card + .card { margin-top: 0; }
.bc-item-card { padding: 12px 14px; }
.bc-editor { display: grid; gap: 8px; margin-top: 8px; }
.bc-editor textarea.field { width: 100%; }
.bc-action { display: grid; grid-template-columns: minmax(0, 1fr) 150px minmax(0, 1.4fr); gap: 6px; flex: 1; }
.bc-areas { display: grid; gap: 4px; }
.bc-buttons { display: grid; gap: 6px; }
.bc-buttons .actions { flex-wrap: nowrap; }
.bc-card-editors { display: grid; gap: 10px; }
.bc-card-editor { padding: 12px; display: grid; gap: 8px; background: var(--surface-2); }
.bc-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.bc-sticker-grid { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.sticker-tile.active { outline: 2px solid var(--accent); background: var(--accent-soft); }
.bc-json { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.bc-preview { position: sticky; top: 0; padding: 14px; border-radius: 14px; background: #8cabd9; display: grid; gap: 10px; align-content: start; min-height: 200px; }
.bc-preview-head { font-size: 12.5px; color: #fff; font-weight: 600; opacity: 0.9; }
.bc-preview-item { display: grid; justify-items: start; }
.bc-bubble { max-width: 100%; padding: 8px 12px; border-radius: 14px; background: #fff; color: #222; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bc-bubble .hint { color: #777; }
.bc-pic, .bc-rich img { max-width: 100%; border-radius: 12px; display: block; }
.bc-sticker { width: 110px; height: 110px; object-fit: contain; }
.bc-rich { position: relative; width: 100%; }
.bc-rich-grid { position: absolute; inset: 0; display: grid; }
.bc-rich-grid span { display: flex; align-items: center; justify-content: center; border: 1px dashed rgba(255, 255, 255, 0.85); color: #fff; font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.bc-rich.layout-2h .bc-rich-grid { grid-template-columns: 1fr 1fr; }
.bc-rich.layout-2v .bc-rich-grid { grid-template-rows: 1fr 1fr; }
.bc-rich.layout-3v .bc-rich-grid { grid-template-rows: 1fr 1fr 1fr; }
.bc-rich.layout-4 .bc-rich-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.bc-cards { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding-bottom: 4px; }
.bc-card { flex: 0 0 170px; display: grid; gap: 4px; padding: 0 0 10px; border-radius: 12px; background: #fff; color: #222; font-size: 13px; overflow: hidden; }
.bc-card img { width: 100%; aspect-ratio: 20 / 13; object-fit: cover; display: block; }
.bc-card b, .bc-card p, .bc-card .bc-price, .bc-card .bc-code { margin: 0 10px; }
.bc-card b { margin-top: 8px; }
.bc-card p { color: #666; font-size: 12.5px; white-space: pre-wrap; }
.bc-price { color: #1a7f4b; font-weight: 700; }
.bc-btn { margin: 4px 10px 0; padding: 6px; border-radius: 8px; background: #06c755; color: #fff; text-align: center; font-weight: 600; font-size: 12.5px; }
.bc-btn ~ .bc-btn { background: #eef1f4; color: #222; }
.bc-coupon { flex-basis: 220px; padding-top: 10px; }
.bc-code { padding: 8px 10px; border-radius: 8px; background: #f2f8f4; color: #1a7f4b; font-weight: 800; font-size: 18px; letter-spacing: 1px; }
.bc-report h3 { margin: 14px 0 6px; font-size: 15px; }
.bc-failures { margin: 0; padding-left: 20px; font-size: 14px; }
.bc-failures li { margin-bottom: 4px; }
.msg .who .free-tag.bc-tag { background: var(--info-soft); color: var(--info); }
/* รุ่น 52.1: ฟองบรอดแคสต์ในแชตวาดของจริง (รูป ริชเมสเสจ การ์ด สติกเกอร์ คูปอง) เรียงตามลำดับที่ส่ง ชิดขวาเหมือนข้อความแอดมิน */
/* รุ่น 53: ป้าย "ทันที" ข้างหัวข้อกล่องข้อความเมื่อเส้นเด้งบอกต่ออยู่ (จอแคบที่มีแท็บ LINE OA / Facebook ไม่พอวาง ซ่อนไว้ หัวหน้าจะได้ไม่สูงขึ้น) */
.page-head h1 .push-chip { margin-left: 10px; vertical-align: middle; font-size: 12px; font-weight: 650; }
.push-chip[hidden] { display: none; }
@media (max-width: 640px) {
  .page-head:has(.inbox-tabs:not([hidden])) .push-chip { display: none; }
}
.bc-msg { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 100%; }
.bc-msg-head { font-size: 12px; color: var(--muted); }
.bc-msg-item { display: flex; justify-content: flex-end; max-width: 100%; }
.bc-msg-item .bubble { max-width: 100%; }
.bc-msg-item a { display: block; line-height: 0; border-radius: 11px; }
.bc-msg-item a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bc-msg-pic { max-width: 240px; max-height: 240px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); display: block; }
.bc-msg-rich { max-width: 300px; width: 100%; border-radius: 11px; display: block; }
.bc-msg-item img.sticker { width: 112px; height: 112px; object-fit: contain; }
.bc-msg-item .bc-card { border: 1px solid var(--border); }
.bc-msg-item .bc-coupon .bc-code { margin: 6px 10px 0; display: inline-block; }
@media (max-width: 860px) {
  .bc-editor-grid { grid-template-columns: 1fr; }
  .bc-preview { position: static; }
  .bc-action { grid-template-columns: 1fr; }
}
.log-oa { cursor: pointer; border: 0; font: inherit; font-size: 12px; }
.log-oa:hover { text-decoration: underline; }
.log-chat { text-decoration: none; }
.log-chat:hover { text-decoration: underline; }
#logs-oa { max-width: 240px; min-height: 36px; padding: 4px 10px; font-size: 14px; }

/* รุ่น 38: การ์ดแบรนด์แบบย่อ/กาง ค้นหา และตัวกรองแบรนด์ของรายการ LINE OA */
#brands h2 .hint { font-weight: 400; font-size: 13px; margin-left: 6px; }
#brands.collapsed { padding-top: 12px; padding-bottom: 12px; }
.oa-filter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.oa-filter .field { width: auto; min-width: 220px; max-width: 100%; }

/* รุ่น 47: วิธีตั้งค่าฝั่ง LINE — ปุ่ม "ดูรูป" ท้ายข้อ รูปกางใต้ข้อ (กดรูปดูขยาย) */
ol.help-steps { color: var(--text); font-size: 14.5px; }
ol.help-steps li { margin-bottom: 10px; line-height: 1.55; }
.help-toggle { vertical-align: 1px; margin-left: 2px; }
.help-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 10px 0 6px; }
.help-figs figure { margin: 0; }
.help-figs img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; cursor: zoom-in; background: #fff; }
.help-figs figcaption { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* รุ่น 48: ห้องรวมลูกค้า — ป้าย "🔗 N OA" ป้าย OA ท้ายชื่อผู้ส่งในแชต ตัวเลือก "ตอบผ่าน" และแถบจับคู่ข้าม provider */
.chip.group-chip { font-weight: 600; }
.conv.grouped .group-chip { background: var(--info-soft); color: var(--info); }
.msg .who .oa-tag { margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--info-soft); color: var(--info); font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.reply-via-wrap { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; flex: none; }
.reply-via-wrap .field.reply-via { width: auto; max-width: 240px; padding: 4px 8px; font-size: 13px; }
.link-bar { display: grid; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.link-bar[hidden] { display: none; }
.link-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; line-height: 1.45; padding: 6px 10px; border-radius: 10px; }
.link-row.pending { background: var(--warn-soft, #fff7e6); border: 1px solid var(--warn, #d97706); }
.link-row.confirmed { background: var(--info-soft); }
.link-row .link-text { flex: 1 1 260px; min-width: 0; }
.link-row .actions { display: flex; gap: 6px; flex: none; }
.merge-head { font-size: 14px; margin: 14px 0 6px; }
.cf-identity-chip { font-weight: 600; }
/* รุ่น 52: หน้า LINE OA / เมนูเลือก OA รองรับ OA หลักร้อย (ค้นหา + แสดงทีละ 20) */
.oa-search-row { margin-bottom: 10px; }
.oa-search-row .field { flex: 1 1 320px; max-width: 460px; }
.oa-pager { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; flex-wrap: wrap; }
.oa-rows { display: flex; flex-direction: column; gap: 3px; }
.oa-menu-many { overflow: hidden; max-height: none; }
.oa-menu-many .oa-search-input { margin: 2px 3px 4px; width: calc(100% - 6px); font-size: 13px; padding: 6px 10px; }
.oa-menu-many .oa-rows { overflow: auto; max-height: min(360px, 50vh); }
.oa-menu .oa-none { padding: 10px 12px; }
/* รุ่น 52: รายการติ๊กโมเดล AI ที่สายใช้ได้ (หน้าต่างสาย) */
.model-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 14px; margin: 4px 0 12px; max-height: 320px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.model-pick .label { grid-column: 1 / -1; }
.model-pick .model-row { font-weight: 500; font-size: 13.5px; }
.model-warn-chip { margin-left: 6px; font-weight: 600; }
/* รุ่น 49: รายการ "จับคู่ว่าเป็นคนเดียวกันจาก" ในหน้าต่างแบรนด์ (แถวละข้อ: ติ๊ก + ถามก่อน/รวมทันที) และตัวเลือกโหมดคีย์ในหน้าต่างช่องข้อมูล */
.match-list { display: grid; gap: 8px; margin: 8px 0; }
#bd-match-fields { display: contents; }
.match-row { display: flex; align-items: center; gap: 10px; margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.match-row .check { margin: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.match-row .match-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.match-row .match-text .hint { font-weight: 400; font-size: 12.5px; line-height: 1.35; margin: 0; }
.match-row .field.match-mode { width: auto; padding: 4px 8px; font-size: 13px; margin-left: auto; flex: 0 0 auto; }
.match-row .match-off { margin-left: auto; flex: 0 0 auto; }
.match-row.off { opacity: 0.8; }
.match-row.locked { opacity: 0.55; }
.cf-identity-mode { width: auto; display: inline-block; padding: 4px 8px; font-size: 13px; margin: 4px 0 2px 26px; }
@media (max-width: 720px) {
  .match-row { flex-wrap: wrap; }
  .match-row .check { flex: 1 1 100%; }
  .match-row .field.match-mode, .match-row .match-off { margin-left: 26px; }
}
@media (max-width: 720px) {
  .reply-as:has(.reply-via-wrap) { flex-wrap: wrap; }
  .reply-via-wrap { margin-left: 0; flex-basis: 100%; }
  .reply-via-wrap .field.reply-via { flex: 1 1 auto; max-width: none; }
}

/* รุ่น 46: ป้าย "บอท" ท้ายค่าที่บอทกรอกในแผงข้อมูลลูกค้า และป้ายในรายการช่อง */
.chip.bot-filled { font-size: 10.5px; padding: 0 6px; margin-left: 4px; background: var(--accent-soft); color: var(--accent-strong); vertical-align: 1px; user-select: none; }
/* รุ่น 76.1: คัดลอกค่าในช่องข้อมูลลูกค้า — คลิก/ดับเบิลคลิกเลือกได้เฉพาะค่า ไม่ติดชื่อช่องและชิป "บอท" มาด้วย (เดิมดับเบิลคลิกเบอร์ได้ "0812345678บอท") */
.cust-field b, .cust-mini b { user-select: all; }
.cust-field-name { user-select: none; }
.cf-bot-chip { font-weight: 600; }

/* ---------- ธีมหน้าเว็บ (รุ่น 39 · ปรับรุ่น 45) ---------- */
/* เลือกได้ที่มุมล่างของเมนูซ้าย จำไว้ในเบราว์เซอร์ของแต่ละคน · ค่าเริ่มต้น = Aurora (รุ่น 45) · "คลาสสิก" = ธีมเดิมด้านบนทั้งหมด (รวมโหมดมืดตามระบบ)
   รุ่น 45 เอา Ivory Gold กับ Sunset Orange (รุ่น 39–44) ออก คนที่เคยเลือกไว้จะถูกย้ายมา Aurora อัตโนมัติ (app.js: LEGACY_THEMES)
   Aurora ซ้อนทับเฉพาะตัวแปรสีกับของตกแต่งไม่กี่จุด ไม่แตะโครงหน้า จึงไม่กระทบการทำงานของหน้าใด ๆ และเป็นธีมสว่างเสมอ (ไม่ตามโหมดมืดของระบบ)
   ห้ามทับสไตล์พื้นฐานของ .btn / .card / .toast / .field ใต้ html[data-theme] เพราะความจำเพาะจะไปชนะ .btn.danger:hover, .toast.err ฯลฯ ทับได้เฉพาะตัวแปรกับส่วนที่เป็นสีเน้น
   ข้อยกเว้นที่ตรวจแล้วว่าไม่ชนกับสไตล์ย่อย: มุมโค้งของ .btn:not(.small) / .field และสีของ .side .btn / .side .field (ในเมนูซ้ายมีแต่ปุ่ม ghost กับช่องเลือกธีม) */
html[data-theme="aurora"] {
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f3f6fb;
  --border: #e2e8f0;
  --border-strong: #c7d2e0;
  --text: #0f172a;
  --muted: #5b6b82;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: #d6f5ef;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.07);
  --radius: 16px;
  --navy: #0f172a;
  --mint: #2dd4bf;
  --mint-hi: #5eead4;
  --indigo: #6366f1;
  --brand-bot: #0d9488;
  color-scheme: light;
}
html[data-theme="aurora"] body { background: radial-gradient(1000px 520px at 100% -10%, rgba(45, 212, 191, 0.16), transparent 60%), radial-gradient(800px 480px at -5% 110%, rgba(99, 102, 241, 0.12), transparent 60%), var(--bg); }
html[data-theme="aurora"] h1 { font-weight: 700; letter-spacing: -0.01em; }
html[data-theme="aurora"] h2 { font-weight: 650; }
html[data-theme="aurora"] .page-head h1::after { content: ''; display: block; width: 44px; height: 3px; margin-top: 7px; background: linear-gradient(90deg, var(--mint), var(--indigo)); border-radius: 3px; }
/* แถบเมนูซ้าย (บนมือถือคือแถบบน): น้ำเงินกลางคืน ตัวหนังสือสว่าง เมนูที่เลือกเป็นเม็ดมินต์ */
html[data-theme="aurora"] .side { background: linear-gradient(180deg, #0f172a 0%, #131c33 55%, #0f172a 100%); border-right: 0; border-bottom-color: rgba(255, 255, 255, 0.08); box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06); }
html[data-theme="aurora"] .side .brand-word { color: #ffffff; }
html[data-theme="aurora"] .side .brand-word .bot { fill: var(--mint); }
html[data-theme="aurora"] .side .brand-mark { background: #1e293b; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 16px rgba(0, 0, 0, 0.35); }
html[data-theme="aurora"] .nav a { color: #b6c2d3; border-radius: 10px; font-weight: 520; }
html[data-theme="aurora"] .nav a:hover { color: #ffffff; background: rgba(255, 255, 255, 0.06); }
html[data-theme="aurora"] .nav a.active { color: #ccfbf1; background: linear-gradient(90deg, rgba(45, 212, 191, 0.22), rgba(45, 212, 191, 0.08)); box-shadow: inset 3px 0 0 var(--mint); font-weight: 650; }
html[data-theme="aurora"] .count { background: var(--mint); color: #042f2e; }
html[data-theme="aurora"] .side .me-name { color: #ffffff; }
html[data-theme="aurora"] .side .hint, html[data-theme="aurora"] .side .theme-pick { color: #8a9bb3; }
html[data-theme="aurora"] .side .field { background: #1e293b; color: #e2e8f0; border-color: #334155; }
html[data-theme="aurora"] .side .btn { background: transparent; color: #cbd5e1; border-color: transparent; }
html[data-theme="aurora"] .side .btn:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
html[data-theme="aurora"] .side-foot { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; }
/* ปุ่มหลัก ป้าย แท็บ */
html[data-theme="aurora"] .btn.primary { background: linear-gradient(135deg, #14b8a6, #0d9488 55%, #0f766e); border-color: transparent; color: #ffffff; font-weight: 650; box-shadow: 0 6px 16px rgba(13, 148, 136, 0.28); }
html[data-theme="aurora"] .btn.primary:hover { background: linear-gradient(135deg, #2dd4bf, #14b8a6 55%, #0d9488); border-color: transparent; }
html[data-theme="aurora"] .btn:not(.small) { border-radius: 10px; }
html[data-theme="aurora"] .field { border-radius: 10px; }
html[data-theme="aurora"] .chip.ok { box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.25); }
html[data-theme="aurora"] .tab.active { color: var(--accent-strong); border-bottom-color: var(--mint); }
html[data-theme="aurora"] .seg { background: #e6ecf4; }
html[data-theme="aurora"] .seg-btn.active { background: var(--surface); color: var(--accent-strong); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), inset 0 0 0 1px rgba(13, 148, 136, 0.35); }
html[data-theme="aurora"] .toast.ok { background: #0f766e; }
html[data-theme="aurora"] .bot-card:hover { border-color: var(--mint); box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.35), var(--shadow); }
html[data-theme="aurora"] .stat-tile { background: linear-gradient(180deg, #ffffff, #fbfcfe); }
html[data-theme="aurora"] .stat-tile.warn { border-color: #fcd34d; background: linear-gradient(180deg, #fffbeb, #fef3c7); }
html[data-theme="aurora"] .stat-value { letter-spacing: -0.02em; }
/* กล่องข้อความ */
html[data-theme="aurora"] .conv.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--mint); }
html[data-theme="aurora"] .chat { background: linear-gradient(180deg, #eef2f8, #e9eef6); }
html[data-theme="aurora"] .bubble { border-radius: 16px; }
html[data-theme="aurora"] .msg.assistant .bubble { background: #dcf7f1; border: 1px solid rgba(13, 148, 136, 0.18); }
html[data-theme="aurora"] .msg.admin .bubble { background: #e0e7ff; border: 1px solid rgba(99, 102, 241, 0.18); }
html[data-theme="aurora"] .msg.failed .bubble { background: var(--danger-soft); border-color: var(--danger); } /* ข้อความแอดมินที่ส่งไม่สำเร็จต้องยังเป็นสีแดง (กฎ .msg.admin ด้านบนจำเพาะกว่ากฎพื้นฐาน) */
html[data-theme="aurora"] .pane-head { background: linear-gradient(180deg, #ffffff, #f8fafc); }
/* หน้าเข้าสู่ระบบ: พื้นน้ำเงินกลางคืนกับแสงออโรรา การ์ดขาวลอย */
html[data-theme="aurora"] .login { background: radial-gradient(900px 600px at 50% -10%, rgba(45, 212, 191, 0.28), transparent 60%), radial-gradient(700px 520px at 95% 105%, rgba(99, 102, 241, 0.30), transparent 60%), #0b1220; }
html[data-theme="aurora"] .login .card, html[data-theme="aurora"] .boot-screen .card { border: 0; box-shadow: 0 30px 80px rgba(2, 6, 23, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06); padding: 34px 30px; border-radius: 20px; }
html[data-theme="aurora"] .login .brand { justify-content: center; }
html[data-theme="aurora"] .login .brand-mark { width: 44px; height: 44px; border-radius: 11px; }
html[data-theme="aurora"] .login .brand-word svg { height: 24px; }
/* กราฟแดชบอร์ด: ลูกค้าฟ้า · บอทมินต์ · แอดมินคราม (สามสีไม่กลืนกัน) */
html[data-theme="aurora"] .bar.customer, html[data-theme="aurora"] .key.customer::before { background: #3b82f6; }
html[data-theme="aurora"] .bar.bot, html[data-theme="aurora"] .key.bot::before { background: #14b8a6; }
html[data-theme="aurora"] .bar.admin, html[data-theme="aurora"] .key.admin::before { background: var(--indigo); }
/* ตัวเลือกธีมที่มุมล่างของเมนูซ้าย */
.theme-pick { display: flex; align-items: center; gap: 6px; padding: 2px 10px 6px; font-size: 13px; color: var(--muted); max-width: 100%; }
.theme-pick select { width: auto; min-height: 30px; padding: 2px 8px; font-size: 13px; border-radius: 7px; }
@media (max-width: 860px) {
  .theme-pick { padding: 0; }
  .theme-pick span { display: none; }
}
/* รุ่น 54: ตั้งค่าโยนเคสอัตโนมัติในหน้าต่างแบรนด์ + ปุ่มพักรับเคส */
.assign-users { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 4px 26px; }
.assign-users .check { margin: 0; }
.assign-users.locked { opacity: 0.5; }
.assign-cats { display: grid; gap: 6px; margin: 6px 0 10px; }
.assign-cat { border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }
.assign-cat summary { cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.assign-cat summary .chip { margin-left: auto; }
.assign-cat .assign-users { margin-left: 6px; margin-top: 8px; }
.brand-assign-chip { font-weight: 600; }
.page-head h1 .assign-pause { margin-left: 10px; vertical-align: middle; font-size: 12.5px; font-weight: 600; }
.page-head h1 .assign-pause.paused { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
/* รุ่น 55: รูดแชต */
.inbox-filters .sweep-btn { flex: 0 0 auto; white-space: nowrap; }
.sweep-list { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin: 8px 0 12px; display: grid; gap: 4px; }
.sweep-item { display: flex; gap: 10px; align-items: baseline; font-size: 13.5px; }
.sweep-item .sweep-name { font-weight: 600; }
.sweep-item .hint { margin: 0; }
.sweep-image-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.sweep-image-bar img.outgoing { width: 96px; height: 96px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.sweep-image-bar .name { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); }
.sweep-failures { margin: 8px 0 0 18px; display: grid; gap: 4px; font-size: 13.5px; }
@media (max-width: 640px) {
  .page-head:has(.inbox-tabs:not([hidden])) .assign-pause { display: none; }
}

/* รุ่น 56.1: หน้าค่าใช้จ่าย — ตารางรายวัน (แถวรวมเน้น และช่องเลือกสายชิดขวาของหัวการ์ด) */
#usage-daily-card .label-row { gap: 10px; flex-wrap: wrap; }
#usage-daily-card .usage-daily-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#usage-daily-card .label-row select { width: auto; min-width: 160px; }
.usage-daily-total td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface-2); }

/* รุ่น 57: QC แชต — หน้าต่างแบรนด์ (เกณฑ์) · หน้า QC · ป้ายในแชต · คอลัมน์แดชบอร์ด */
.qc-sample { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qc-sample .field { width: 90px; }
.qc-rows { display: grid; gap: 6px; margin: 4px 0 8px; }
.qc-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; }
.qc-row input.qc-row-on { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.qc-row .qc-row-fields { flex: 1; min-width: 0; display: grid; gap: 4px; }
.qc-row .qc-row-fields .field { min-height: 32px; padding: 4px 8px; font-size: 13.5px; }
.qc-row .field.qc-row-sev { width: auto; padding: 4px 8px; font-size: 13px; flex: none; }
.qc-row:has(.qc-row-on:not(:checked)) .qc-row-fields { opacity: 0.55; }
.qc-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.qc-filters .field { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13.5px; }
.qc-list .qc-item { align-items: flex-start; }
.qc-item .avatar { flex: none; }
.qc-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.qc-item-head .hint { margin: 0; }
.qc-item-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.qc-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.chip.qc-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip.qc-score.big { font-size: 20px; padding: 6px 14px; }
.chip.qc-flag.dismissed { opacity: 0.5; text-decoration: line-through; }
.qc-reason { font-weight: 400; }
.qc-detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.qc-transcript { display: grid; gap: 10px; max-height: 60vh; overflow: auto; padding: 4px 2px; }
.qc-line { display: grid; gap: 4px; max-width: 80%; }
.qc-line.user { justify-self: start; }
.qc-line.admin, .qc-line.assistant { justify-self: end; text-align: right; }
.qc-line.admin .bubble, .qc-line.assistant .bubble { text-align: left; }
.qc-line .who { font-size: 12px; color: var(--muted); }
.qc-line.flagged .bubble { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
.qc-line-flags { display: grid; gap: 4px; justify-items: end; }
.qc-finding { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.qc-finding.dismissed { opacity: 0.7; }
.qc-msg-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.qc-msg-flags .chip { cursor: pointer; border: 0; font: inherit; font-size: 12px; }
.qc-cell { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: inherit; }
.stat-tile.err { border-color: var(--danger); background: var(--danger-soft); }
a.stat-tile { color: inherit; text-decoration: none; display: block; }
a.stat-tile:hover { border-color: var(--accent); }
@media (max-width: 640px) {
  .qc-row { flex-wrap: wrap; }
  .qc-row .qc-row-fields { flex-basis: 100%; order: 3; }
  .qc-item-side { flex-direction: row; flex-wrap: wrap; }
  .qc-line { max-width: 100%; }
}
.qc-line.context { opacity: 0.7; }

/* รุ่น 58: บิลรายสาย */
.stat-tile.bill-total .stat-value { color: var(--accent-strong); }
.bill-seg { flex-wrap: wrap; } /* รุ่น 58.2: ปุ่มช่วงเวลา 5 ปุ่ม (วันนี้ · เมื่อวาน · เดือนนี้ · เดือนก่อน · เลือกเอง) ขึ้นบรรทัดใหม่ได้บนจอแคบ */
.bill-rates { margin-bottom: 6px; }
@media (max-width: 640px) {
  .bill-rates { grid-template-columns: 1fr; }
}

/* รุ่น 66: คีย์ API ของสาย (หน้าต่างแก้ไขสาย) + ชิปสลิปรอระบบภายนอก */
.api-clients { display: grid; gap: 8px; margin-bottom: 4px; }
.api-client { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.api-client .body { min-width: 0; flex: 1; }
.api-client .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.api-client .hint { margin: 4px 0 0; }
.api-client .api-webhook { overflow-wrap: anywhere; }
.api-key-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.api-key-once { flex: 1; min-width: 240px; padding: 9px 12px; font-size: 14px; user-select: all; }
@media (max-width: 640px) {
  .api-client { flex-direction: column; }
  .api-client .actions { justify-content: flex-start; }
}

/* รุ่น 71: สายทดลอง 7 วัน — ตัวเลือกประเภทสายในหน้าต่างสาย (เจ้าของ) และแถบนับถอยหลังบนหน้าของทีมงานในสายทดลอง */
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.trial-bar { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 10px 16px; margin: 0 0 16px; border-radius: 12px; background: var(--warn-soft); color: var(--text); font-size: 14px; }
.trial-bar.err { background: var(--danger-soft); }
.trial-bar b { font-weight: 700; }

/* รุ่น 72: ช่องทางติดต่อใต้ฟอร์มเข้าสู่ระบบ (เจ้าของระบบตั้งที่หน้า "ตั้งค่า") */
.login .contact { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; }
.login .contact-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.login .contact-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.login .contact-links .btn { text-decoration: none; }
.login .contact-line { background: #06c755; border-color: #06c755; color: #fff; }
.login .contact-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.login .contact .hint { margin-top: 10px; }

/* รุ่น 74: รายการคีย์ one2p ที่อนุญาตให้สาย (หน้าต่างสายของเจ้าของระบบ) */
.key-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 6px 0 2px; }
.key-checks .check { font-weight: 500; }

/* รุ่น 75: AI Calling — ปุ่มโทรที่หัวแชต การ์ดผลโทรในแชต หน้าเมนู AI Calling บทสนทนาของสาย แม่แบบพรอมต์ (เจ้าของ) */
.call-btn { border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.call-card { max-width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.call-card.ok { border-color: var(--accent); background: var(--accent-soft); }
.call-card.err { border-color: var(--danger); background: var(--danger-soft); }
.call-card.warn { border-color: var(--warn); background: var(--warn-soft); }
.call-card.info { border-color: var(--info); background: var(--info-soft); }
.call-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.call-card-summary { margin: 6px 0 0; white-space: pre-wrap; }
.call-card .actions { margin-top: 8px; }
.calling-seg { flex-wrap: wrap; }
.calling-brand h2 { margin: 0; }
.call-summary { margin: 4px 0 0; color: var(--text); white-space: pre-wrap; }
.call-item .label-row { flex-wrap: wrap; }
.call-transcript { max-height: 420px; overflow: auto; padding: 10px; border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.call-transcript .msg.assistant { align-self: flex-end; }
.call-transcript .bubble { white-space: pre-wrap; }
.co-prompt { white-space: pre-wrap; font-size: 13px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); max-height: 320px; overflow: auto; }

/* รุ่น 76: บันทึกเหตุการณ์แทรกในไทม์ไลน์ของแชต (บรรทัดเล็ก จาง ไม่ใช่ฟองข้อความ) */
.tl-event { font-size: 11.5px; color: var(--muted, #8a93a6); text-align: center; margin: 6px 12px; line-height: 1.5; opacity: 0.85; word-break: break-word; }
.tl-event .tl-time { font-variant-numeric: tabular-nums; opacity: 0.8; margin-right: 2px; }
.tl-event .tl-more { opacity: 0.85; }
.tl-event[data-event='close'], .tl-event[data-event='open'] { color: var(--accent, #2fbf9a); opacity: 0.95; }
.tl-event[data-event='unfollow'] { color: var(--danger, #d9534f); }
#events-toggle-btn.muted { opacity: 0.6; }
/* รุ่น 76: ป้ายสถานะ "ปิดแล้ว" (จาง) */
.chip.muted { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.status-chip { font-size: 11px; }

/* รุ่น 76: คอลัมน์ตัวกรองด้านซ้ายของกล่องข้อความ (เปิดต่อสาย) — ตัวควบคุมเดิมซ่อนไว้ จอแคบกลับไปใช้ตัวควบคุมเดิม */
.inbox.with-side { grid-template-columns: 236px 330px minmax(0, 1fr); }
.inbox.with-side .legacy-filters { display: none; }
.inbox-side { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; padding: 4px 6px 12px 0; border-right: 1px solid var(--border); }
.side-sec { display: flex; flex-direction: column; }
.side-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 7px 8px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; cursor: pointer; border-radius: 8px; text-align: left; }
.side-head:hover { background: var(--accent-soft); color: var(--text); }
.side-caret { width: 12px; font-size: 11px; }
.side-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-n { font-size: 11px; font-weight: 600; color: var(--muted); }
.side-items { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.side-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px 6px 20px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; border-radius: 8px; }
.side-item:hover { background: var(--accent-soft); }
.side-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.side-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.side-item .oa-logo.tiny { margin-left: -12px; }
.side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.side-count.quiet { background: var(--border); color: var(--text); }
.side-sub { font-size: 11px; color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; }
.side-x { padding: 0 5px; border-radius: 6px; color: var(--muted); font-size: 12px; opacity: 0; }
.side-item:hover .side-x, .side-item:focus-within .side-x { opacity: 1; }
.side-x:hover { background: var(--danger); color: #fff; }
.side-more { margin: 2px 0 0 20px; padding: 4px 8px; border: 0; background: transparent; color: var(--accent-strong); font: inherit; font-size: 13px; text-align: left; cursor: pointer; border-radius: 6px; }
.side-more:hover { background: var(--accent-soft); }
.side-hint { padding: 2px 8px 4px 20px; font-size: 12.5px; }
.side-search { margin: 0 0 4px 20px; min-height: 30px; padding: 4px 10px; font-size: 13px; width: calc(100% - 20px); }
/* รุ่น 79: รายการปักในคอลัมน์ตัวกรอง — ระดับ VIP สองบรรทัด (ชื่อขั้น + เกณฑ์ยอด) ดาวตามระดับ และปุ่มกลุ่มที่พับได้ */
.side-two { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.side-note { font-size: 11px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-stars { font-size: 11px; letter-spacing: -1px; margin-left: -12px; min-width: 36px; text-align: right; flex: none; }
.side-group { margin-left: 12px; }
.conv-col .side-row { align-items: center; }
.conv-col .side-row .inbox-search { flex: 1; }
@media (min-width: 861px) {
  .inbox.chat-wide.with-side { grid-template-columns: minmax(0, 1fr); }
  .inbox.chat-wide .inbox-side { display: none; }
}
@media (max-width: 1180px) {
  .inbox.with-side { grid-template-columns: 200px 300px minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .inbox.with-side { grid-template-columns: 330px minmax(0, 1fr); }
  .inbox.with-side .inbox-side { display: none; }
  .inbox.with-side .legacy-filters { display: contents; }
}
@media (max-width: 860px) {
  .inbox.with-side { grid-template-columns: 1fr; }
  .inbox.with-side.has-open .inbox-side { display: none; }
}

/* รุ่น 76: บรอดแคสต์แบบไฟล์ */
.bc-file { margin: 4px 0 10px; }
.bc-file-preview { overflow: auto; max-height: 160px; margin: 6px 0 10px; border: 1px solid var(--border); border-radius: 8px; }
.bc-file-preview table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.bc-file-preview th, .bc-file-preview td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.bc-file-preview th { position: sticky; top: 0; background: var(--surface); font-weight: 600; }

/* รุ่น 76: เมนูลูกค้า */
.cust-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.cust-filters .field { width: auto; min-width: 140px; flex: 1 1 140px; max-width: 260px; }
.cust-filters #cust-q { flex: 2 1 220px; max-width: 320px; }
.cust-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 10px; border-radius: 10px; background: var(--accent-soft); }
.cust-table th:first-child, .cust-table td:first-child { width: 28px; }
.cust-table .cust-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.cust-table .cust-link .avatar { width: 30px; height: 30px; flex: none; }
.cust-table .cust-link:hover b { text-decoration: underline; }
.cust-table .cust-tags { max-width: 260px; }
.cust-table tr.picked td { background: var(--accent-soft); }
.cust-table td .chip { margin-right: 4px; }
.cust-pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.cust-table td.empty { text-align: center; color: var(--muted); padding: 24px; }
@media (max-width: 760px) { .cust-filters .field { max-width: none; } }

/* รุ่น 78: แถบส่งข้อความหาเพื่อนใหม่ (แท็บเพื่อนใหม่) */
.nf-bar { display: flex; flex-direction: column; gap: 8px; margin: 0 0 8px; }
.nf-bar .nf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nf-bar .nf-row .field { width: auto; min-width: 160px; max-width: 100%; }
.nf-bar .hint { margin: 0; }
