/* =========================================================
   หลังบ้าน LINE AI Reply — โทนแบบ LINE OA Manager
   สีทั้งหมดเป็นตัวแปร: โหมดกลางวัน (ค่าเริ่มต้น) / กลางคืน ([data-theme=dark] หรือ "ตามเครื่อง")
   ========================================================= */
:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e3e6ea;
  --line-2: #eff1f3;
  --ink: #1f2328;
  --muted: #69727d;
  --brand: #06c755;            /* เขียว LINE: ปุ่มส่ง ตัวเลข ป้าย */
  --brand-hover: #05b04b;
  --brand-ink: #04873b;        /* เขียวสำหรับตัวหนังสือบนพื้นขาว (อ่านง่ายกว่า) */
  --brand-tint: #e7f8ee;
  --hand: #b4361b;  --hand-tint: #fbe8e3;   /* ต้องให้คนรับเรื่อง / ผิดพลาด */
  --rev: #835700;   --rev-tint: #fbefd6;    /* รอตรวจ */
  --human: #3f4ba8; --human-tint: #e8eaf8;  /* พนักงานดูแล */
  --link: #1a5fd0;
  --bubble-in: #eff1f4;
  --bubble-out: #c9e0fc;       /* ข้อความของร้าน: ฟ้าอ่อนแบบ LINE OA Manager */
  --bubble-out-ink: #172435;
  --row-hover: #f6f7f9;
  --row-active: #eceff3;
  --unread: #e9f9ef;
  --unread-hover: #def5e7;
  --input-bg: #ffffff;
  --code-bg: #eef1f3;
  --shadow: 0 10px 30px rgba(20, 30, 40, .14);
  --radius: 10px;
  --appbar-h: 54px;
  --nav-w: 232px;
  /* ชื่อเดิม (หน้า setup.php ใช้อยู่) */
  --send: var(--brand-ink);
  --send-tint: var(--brand-tint);
  --line-green: var(--brand);
  color-scheme: light;
  font-size: 16px;
}
:root[data-theme="dark"] {
  --bg: #111315; --surface: #1a1d21; --surface-2: #22262b; --line: #31363c; --line-2: #262a2f;
  --ink: #e6e8eb; --muted: #9ba4ae; --brand-ink: #3ddc84; --brand-tint: #143523;
  --hand: #ff8f75; --hand-tint: #3b211b; --rev: #f2c35e; --rev-tint: #3a3019; --human: #aab3ff; --human-tint: #252a4b;
  --link: #79a8ff; --bubble-in: #2a2e34; --bubble-out: #23456b; --bubble-out-ink: #e8f0fb;
  --row-hover: #1f2327; --row-active: #262b31; --unread: #15301f; --unread-hover: #1a3a27;
  --input-bg: #15181b; --code-bg: #2a2e34; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #111315; --surface: #1a1d21; --surface-2: #22262b; --line: #31363c; --line-2: #262a2f;
    --ink: #e6e8eb; --muted: #9ba4ae; --brand-ink: #3ddc84; --brand-tint: #143523;
    --hand: #ff8f75; --hand-tint: #3b211b; --rev: #f2c35e; --rev-tint: #3a3019; --human: #aab3ff; --human-tint: #252a4b;
    --link: #79a8ff; --bubble-in: #2a2e34; --bubble-out: #23456b; --bubble-out-ink: #e8f0fb;
    --row-hover: #1f2327; --row-active: #262b31; --unread: #15301f; --unread-hover: #1a3a27;
    --input-bg: #15181b; --code-bg: #2a2e34; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
a { color: var(--brand-ink); }
h1 { font-size: 1.35rem; font-weight: 600; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .4rem; }
code { background: var(--code-bg); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.err-text { color: var(--hand); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ico { flex: none; display: block; }

/* ---------- แถบด้านบน ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30; height: var(--appbar-h);
  display: flex; align-items: center; gap: .6rem;
  padding: 0 .9rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; min-width: 0; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.05rem; }
.brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.mode { font-size: .74rem; font-weight: 600; padding: .12rem .55rem; border-radius: 6px; text-decoration: none; white-space: nowrap;
  background: #2f7cf6; color: #fff; }
.mode-auto { background: var(--brand); }
.spacer { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; font: inherit; text-decoration: none; padding: 0; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.menu-btn { display: none; }
.alert-toggle { display: inline-flex; align-items: center; gap: .35rem; font: inherit; font-size: .82rem; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 18px; padding: .2rem .7rem .2rem .5rem; }
.alert-toggle .ico { width: 17px; height: 17px; }
.alert-toggle.is-on { color: var(--brand-ink); border-color: var(--brand); }
.alert-toggle.is-need { color: #4a3a00; background: #f3c64d; border-color: #f3c64d; }
.who { display: flex; align-items: center; gap: .45rem; font-size: .88rem; color: var(--ink); }
.me-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .85rem;
  background: var(--brand-tint); color: var(--brand-ink); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: auto;
  background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 10px; font-style: normal; line-height: 1; }

/* ---------- โครงหน้า: เมนูซ้าย + เนื้อหา ---------- */
.app { display: flex; align-items: stretch; min-height: calc(100vh - var(--appbar-h)); }
.app > main { flex: 1; min-width: 0; }
.sidenav {
  width: var(--nav-w); flex: none; position: sticky; top: var(--appbar-h); height: calc(100vh - var(--appbar-h));
  display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); z-index: 25;
}
.nav-scroll { flex: 1; overflow-y: auto; padding: .6rem .5rem; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-size: .95rem; cursor: pointer; list-style: none; user-select: none; }
.nav-item::-webkit-details-marker { display: none; }
.nav-item:hover { background: var(--surface-2); }
.nav-item .ico { color: var(--muted); }
.nav-item.on, .nav-group.on > summary { color: var(--brand-ink); font-weight: 600; }
.nav-item.on .ico, .nav-group.on > summary .ico { color: var(--brand-ink); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caret { display: inline-block; flex: none; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid currentColor;
  opacity: .55; transition: transform .15s; }
.nav-group:not([open]) .caret { transform: rotate(-90deg); }
.nav-group .badge-dot { margin-left: 0; }
.nav-group[open] .badge-dot { display: none; }
.nav-sub { display: flex; flex-direction: column; padding: .1rem 0 .4rem 2.6rem; }
.nav-sub a { display: flex; align-items: center; gap: .4rem; padding: .38rem .6rem; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .9rem; }
.nav-sub a:hover { background: var(--surface-2); }
.nav-sub a.on { color: var(--brand-ink); font-weight: 600; }
.nav-mini-link { display: none; }
.nav-collapse { display: flex; align-items: center; gap: .75rem; margin: 0; padding: .7rem 1.25rem; border: 0; border-top: 1px solid var(--line);
  background: transparent; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; text-align: left; }
.nav-collapse:hover { color: var(--ink); }
.nav-shade { display: none; }

/* เมนูย่อแบบไอคอน — กด "ซ่อนเมนู" หรือหน้าแชทบนจอกลาง */
html.nav-min .sidenav { width: 64px; }
html.nav-min .nav-label, html.nav-min .caret, html.nav-min .nav-sub, html.nav-min .nav-group > summary { display: none; }
html.nav-min .nav-mini-link { display: flex; justify-content: center; padding: .62rem 0; border-radius: 8px; color: var(--muted); }
html.nav-min .nav-group.on .nav-mini-link { color: var(--brand-ink); }
html.nav-min .nav-mini-link:hover { background: var(--surface-2); }
html.nav-min .nav-item { justify-content: center; padding: .62rem 0; position: relative; }
html.nav-min .nav-item .badge { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; font-size: .62rem; padding: 0 4px; }
html.nav-min .nav-collapse { justify-content: center; padding: .7rem 0; }
html.nav-min .nav-collapse .ico { transform: rotate(180deg); }
@media (max-width: 1440px) and (min-width: 821px) {
  html:not(.nav-max) body.inbox-page:not(.shop-menu) .sidenav { width: 64px; }
  html:not(.nav-max) body.inbox-page:not(.shop-menu) :is(.nav-label, .caret, .nav-sub, .nav-group > summary) { display: none; }
  html:not(.nav-max) body.inbox-page:not(.shop-menu) .nav-mini-link { display: flex; justify-content: center; padding: .62rem 0; border-radius: 8px; color: var(--muted); }
  html:not(.nav-max) body.inbox-page:not(.shop-menu) .nav-item { justify-content: center; padding: .62rem 0; position: relative; }
  html:not(.nav-max) body.inbox-page:not(.shop-menu) .nav-item .badge { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; font-size: .62rem; padding: 0 4px; }
  html:not(.nav-max) body.inbox-page:not(.shop-menu) .nav-collapse { justify-content: center; padding: .7rem 0; }
  html:not(.nav-max) body.inbox-page:not(.shop-menu) .nav-collapse .ico { transform: rotate(180deg); }
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 1.3rem 1.4rem 3rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 1rem 0; }
.card > summary { cursor: pointer; font-weight: 500; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: .8rem; background: var(--brand-tint); color: var(--ink); }
.flash-err { background: var(--hand-tint); color: var(--hand); }
.page-sub { margin: 1rem 0 .2rem; }

/* ---------- ฟอร์ม ---------- */
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; background: var(--input-bg);
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--brand); }
input[type=file] { padding: .35rem; }
textarea { resize: vertical; }
label { display: block; margin: .6rem 0; font-size: .92rem; }
label > input, label > textarea, label > select { margin-top: .25rem; }
label.check { display: flex; align-items: center; gap: .45rem; margin: .35rem 0; }
.btn { font: inherit; border: 1px solid transparent; border-radius: 8px; padding: .5rem 1rem; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.linkbtn { font: inherit; background: none; border: 0; color: var(--brand-ink); cursor: pointer; padding: 0; text-decoration: underline; }
.inline { display: inline; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.search { margin: 0; }
.search input, .search select { width: auto; min-width: 220px; }
.tabs { display: flex; gap: .3rem; }
.tabs a { padding: .35rem .9rem; border-radius: 8px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--surface); }
.tabs a.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------- ป้าย ---------- */
.pill, .tag { display: inline-block; font-size: .76rem; padding: .05rem .55rem; border-radius: 9px; white-space: nowrap; vertical-align: middle; }
.pill-handoff { background: var(--hand-tint); color: var(--hand); }
.pill-review  { background: var(--rev-tint); color: var(--rev); }
.pill-pending, .pill-idle, .pill-muted { background: var(--surface-2); color: var(--muted); }
.pill-human   { background: var(--human-tint); color: var(--human); }
.pill-ready   { background: var(--brand-tint); color: var(--brand-ink); }
.tag { border: 1px solid var(--line); color: var(--muted); }
.tag-conf { border-color: var(--brand-ink); color: var(--brand-ink); }
.tag-warn { border-color: var(--rev); color: var(--rev); }

/* ป้ายธนาคาร: สีประจำธนาคาร + ชื่อย่อ (หรือโลโก้ที่แอดมินอัปโหลด) */
.bank { display: inline-grid; place-items: center; min-width: 2.6em; height: 1.55em; padding: 0 .45em; border-radius: 5px;
  background: var(--bk, #8a949e); color: var(--bk-ink, #fff); font-size: .72rem; font-weight: 700; line-height: 1; letter-spacing: .01em;
  vertical-align: middle; white-space: nowrap; }
.bank-unknown { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.bank-none { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }
.bank-logo { width: 1.7em; height: 1.7em; border-radius: 6px; object-fit: contain; vertical-align: middle; background: #fff; }
.bank-with-name { display: inline-flex; align-items: center; gap: .45rem; }

/* ---------- หน้าแชท (รายการ | ห้องแชท | ข้อมูลลูกค้า) ---------- */
body.inbox-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
body.inbox-page .appbar { position: static; flex: none; }
body.inbox-page .app { flex: 1; min-height: 0; }
body.inbox-page .sidenav { position: static; height: auto; }
.inbox-main { min-height: 0; display: flex; flex-direction: column; position: relative; }
.inbox-main > .flash { flex: none; margin: 0; border-radius: 0; padding: .35rem 1rem; font-size: .86rem; }
.inbox-main > .flash-float { position: absolute; top: .6rem; left: 50%; transform: translateX(-50%); z-index: 30; width: max-content; max-width: min(640px, 92vw);
  border-radius: 8px; padding: .55rem 1rem; box-shadow: var(--shadow); }
.inbox-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr) 310px; }
body.no-chat .inbox-grid { grid-template-columns: 340px minmax(0, 1fr); }

.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-weight: 600; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: .8rem; align-self: flex-start; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.6rem; }

/* รายการแชท */
.chatlist { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-head { display: flex; gap: .45rem; padding: .7rem .7rem .45rem; margin: 0; }
.list-head select { width: auto; flex: none; max-width: 58%; font-size: .9rem; padding: .42rem .5rem; }
.list-head input { flex: 1; min-width: 0; font-size: .9rem; padding: .42rem .65rem; }
.list-tools { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: 0 .8rem .5rem; font-size: .78rem; border-bottom: 1px solid var(--line); }
.list-tools .linkbtn { font-size: .78rem; text-decoration: none; }
.close-old { display: flex; align-items: center; gap: .3rem; margin: 0; }
.close-old select { width: auto; padding: .05rem .2rem; font-size: .78rem; }
.list-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.inbox { list-style: none; margin: 0; padding: 0; }
.inbox .row { position: relative; display: flex; align-items: stretch; }
.inbox .row:hover { background: var(--row-hover); }
.inbox .row.active { background: var(--row-active); }
.inbox .row.state-handoff { box-shadow: inset 3px 0 0 var(--hand); }
.inbox .row.state-review  { box-shadow: inset 3px 0 0 #d9a520; }
.inbox .row a { flex: 1; min-width: 0; display: flex; gap: .75rem; padding: .78rem .85rem; color: inherit; text-decoration: none; }
.inbox .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .05rem; }
.inbox .line1 { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.inbox .line1 strong { font-weight: 500; font-size: .96rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox .time { flex: none; font-size: .74rem; color: var(--muted); }
.inbox .line2 { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .85rem; min-width: 0; }
.inbox .line2 .pv { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ยังไม่อ่าน (แบบ LINE OA): พื้นเขียวอ่อน ตัวหนา + จำนวนข้อความ — เปิดอ่าน/ตอบแล้วสีหายเอง */
.inbox .row.unread { background: var(--unread); }
.inbox .row.unread:hover { background: var(--unread-hover); }
.inbox .row.unread .line1 strong { font-weight: 700; color: var(--ink); }
.inbox .row.unread .pv { color: var(--ink); font-weight: 500; }
.inbox .row.unread .time { color: var(--brand-ink); font-weight: 600; }
.unread-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff;
  font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; line-height: 1; }
.inbox .line2 em { font-style: normal; }
.inbox .line3 { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; min-height: 0; }
.inbox .line3 .pill { font-size: .7rem; padding: 0 .45rem; }
.inbox .wait { font-size: .72rem; color: var(--hand); }
.pick { display: none; align-items: center; padding-left: .7rem; margin: 0; cursor: pointer; }
.pick input { width: 16px; height: 16px; margin: 0; }
body.selecting .pick { display: flex; }
.done-form { position: absolute; right: .6rem; bottom: .55rem; margin: 0; opacity: 0; transition: opacity .12s; }
.inbox .row:hover .done-form, .done-form:focus-within { opacity: 1; }
.done-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--brand-ink); font-weight: 700; cursor: pointer; }
.done-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
@media (hover: none) { .done-form { opacity: 1; } }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .7rem; border-top: 1px solid var(--line); background: var(--surface); margin: 0; font-size: .88rem; }
.bulk-bar .btn { padding: .35rem .8rem; }

/* ห้องแชท */
.chatpane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); position: relative; }
.empty-pane { justify-content: center; background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: .7rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head .avatar { width: 38px; height: 38px; }
.chat-head .back { display: none; font-size: 1.8rem; line-height: 1; text-decoration: none; color: var(--ink); padding: 0 .2rem; }
.who-cust { flex: 1; min-width: 150px; display: flex; flex-direction: column; line-height: 1.35; }
.who-cust strong { font-size: 1.08rem; font-weight: 500; }
.head-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin: 0; }
.seg { display: inline-flex; align-items: center; gap: .3rem; font: inherit; font-size: .8rem; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); padding: .3rem .7rem; border-radius: 6px; cursor: pointer; }
.seg .ico { width: 15px; height: 15px; }
.seg:hover:not(:disabled) { border-color: var(--muted); }
.seg.on { background: var(--ink); border-color: var(--ink); color: var(--surface); cursor: default; }
#profileToggle { display: none; }
.find-bar { display: flex; align-items: center; gap: .4rem; padding: .4rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.find-bar input { flex: 1; padding: .3rem .6rem; font-size: .9rem; }
.find-bar .icon-btn { width: 30px; height: 30px; }
.msg.find-hit .bubble { box-shadow: 0 0 0 2px #f3c64d; }
.msg.find-on .bubble { box-shadow: 0 0 0 3px #e8a800; }

.thread-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: .9rem 1.4rem 1rem; }
.thread { display: flex; flex-direction: column; gap: .5rem; }
.older { text-align: center; }
.day-sep { align-self: center; margin: .5rem 0 .2rem; }
.day-sep span { font-size: .74rem; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: .1rem .75rem; }
.msg { display: flex; align-items: flex-end; gap: .45rem; max-width: 76%; }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; flex-direction: row-reverse; }
.msg .col { display: flex; flex-direction: column; min-width: 0; gap: .25rem; }
.msg-out .col { align-items: flex-end; }
.who-sent { font-size: .78rem; color: var(--muted); margin-top: .35rem; }
.bubble { padding: .5rem .9rem; border-radius: 18px; background: var(--bubble-in); line-height: 1.55; font-size: .95rem; word-break: break-word; overflow-wrap: anywhere; }
.msg-out .bubble { background: var(--bubble-out); color: var(--bubble-out-ink); }
.sender-system .bubble { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); font-size: .9rem; }
.bubble-media { padding: 0; background: transparent !important; border: 0 !important; }
.media { max-width: 220px; max-height: 300px; border-radius: 14px; display: block; border: 1px solid var(--line); }
.sticker-img { width: 120px; height: 120px; object-fit: contain; display: block; }
.sticker-text { color: var(--muted); }
.msg .meta { flex: none; display: flex; flex-direction: column; font-size: .68rem; color: var(--muted); line-height: 1.35; padding-bottom: .15rem; }
.msg-out .meta { align-items: flex-end; }
.msg .meta .fwd { color: var(--brand-ink); }
.ex-form { margin: 0; display: none; }
.msg:hover .ex-form { display: block; }
.ex-btn { font: inherit; font-size: .68rem; border: 0; background: none; color: var(--link); cursor: pointer; padding: 0; }
.was-draft { font-size: .78rem; color: var(--muted); max-width: 360px; }
.was-draft summary { cursor: pointer; }
.thread-wrap > .typing { display: flex; flex-direction: row; justify-content: flex-end; max-width: none; margin-top: .5rem; }
.ghost-typing { color: var(--muted); border: 1px dashed var(--line); background: var(--surface) !important; }
.msg-new .bubble { box-shadow: 0 0 0 2px #f3c64d; }
@media (prefers-reduced-motion: no-preference) {
  .msg-new .bubble { animation: newmsg 4s ease-out forwards; }
  @keyframes newmsg { 0%, 60% { box-shadow: 0 0 0 2px #f3c64d; } 100% { box-shadow: 0 0 0 0 transparent; } }
}

/* ผลตรวจสลิปใต้รูป */
.slip { max-width: 310px; border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: 10px; background: var(--surface); padding: .45rem .65rem; font-size: .83rem; line-height: 1.55; }
.slip-h { font-weight: 600; display: flex; flex-wrap: wrap; gap: .1rem .5rem; align-items: baseline; }
.slip-amt { font-size: 1rem; margin-left: auto; }
.slip-b { margin-top: .15rem; overflow-wrap: anywhere; }
.slip-b .bank, .slip-b .bank-logo { margin-right: .15rem; }
.slip-f { margin-top: .2rem; font-size: .75rem; color: var(--muted); }
.slip-force { margin: .35rem 0 0; }
.slip-ok { border-left-color: var(--brand); background: var(--brand-tint); }
.slip-duplicate, .slip-receiver_mismatch, .slip-error { border-left-color: var(--hand); background: var(--hand-tint); }
.slip-queued { border-left-color: var(--rev); }
.slip-skipped, .slip-not_slip { border-left-color: var(--line); background: var(--surface-2); }

/* กล่องพิมพ์ */
.composer-dock { position: relative; flex: none; border-top: 1px solid var(--line); background: var(--surface); padding: .55rem 1rem .65rem; }
.live-banner { border: 1px solid #e7c76a; background: var(--rev-tint); border-radius: 10px; padding: .6rem .8rem; margin: 0 0 .5rem; }
.live-banner p { margin: 0 0 .3rem; font-weight: 500; color: var(--rev); }
.live-banner blockquote { margin: .3rem 0; padding: .45rem .7rem; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; white-space: pre-wrap; max-height: 6.5em; overflow-y: auto; }
.live-banner .actions { margin-top: .4rem; }
.composer { margin: 0; }
.composer textarea { border: 0; border-radius: 0; padding: .35rem 0; resize: none; min-height: 4.6em; max-height: 38vh; font-size: .95rem; line-height: 1.55; background: transparent; }
.composer textarea:focus { outline: none; }
.composer.has-draft textarea { background: var(--surface-2); border: 1px dashed #8fb3ec; border-radius: 12px; padding: .5rem .75rem; }
.composer.route-handoff textarea { border-color: #e7a493; }
.draft-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .4rem; }
.ai-chip { font-size: .8rem; font-weight: 600; color: var(--link); }
.why { font-size: .83rem; width: 100%; }
.why summary { cursor: pointer; color: var(--muted); width: fit-content; }
.why p { margin: .2rem 0; }
.edit-reason { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .45rem; font-size: .86rem; }
.edit-reason.need { outline: 2px solid var(--hand); outline-offset: 4px; border-radius: 6px; }
.edit-reason input[name=edit_note] { flex: 1 1 200px; padding: .3rem .55rem; }
.chip { display: inline-flex; gap: .25rem; align-items: center; margin: 0; padding: .15rem .6rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.chip input { width: auto; margin: 0; }
.chip:has(input:checked) { border-color: var(--link); background: var(--surface-2); }
.confirm-new { color: var(--hand); font-size: .88rem; margin: .4rem 0 0; }
.confirm-new input { width: auto; }
.composer .actions { display: flex; align-items: center; gap: .3rem; margin-top: .4rem; flex-wrap: nowrap; }
.tool { display: inline-flex; align-items: center; gap: .3rem; font: inherit; font-size: .8rem; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 16px; padding: .25rem .7rem; cursor: pointer; white-space: nowrap; }
.tool .ico { width: 15px; height: 15px; }
.tool:hover { border-color: var(--muted); }
.tool-ico.on { background: var(--surface-2); color: var(--brand-ink); }
.hint { margin-left: auto; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* กล่องพิมพ์แคบ (จอโน้ตบุ๊กที่เปิดเมนูร้านค้างไว้) — ซ่อนคำแนะนำก่อน แล้วค่อยย่อปุ่มเหลือแต่ไอคอน ปุ่มส่งไม่ล้นออกนอกกรอบ */
.composer { container-type: inline-size; }
@container (max-width: 600px) { .composer .hint { display: none; } .composer .btn-send { margin-left: auto; } }
@container (max-width: 430px) { .composer .tool-label { display: none; } }
.btn-send { font: inherit; font-weight: 600; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: .45rem 1.5rem; cursor: pointer; margin-left: .3rem; }
.btn-send:hover { background: var(--brand-hover); }
.btn-send:disabled { opacity: .6; cursor: wait; }
.sticker-chosen { display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem; margin-top: .3rem; border: 1px dashed var(--line); border-radius: 12px; width: fit-content; }
.sticker-chosen img { width: 64px; height: 64px; object-fit: contain; }

/* ตัวเลือก: ข้อความตอบกลับ / อีโมจิ / สติกเกอร์ — ลอยเหนือกล่องพิมพ์ */
.quick-pop, .pick-pop { position: absolute; left: .8rem; right: .8rem; bottom: calc(100% - .3rem); z-index: 25; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: .55rem; max-height: 52vh; }
.pick-pop { right: auto; width: min(430px, calc(100% - 1.6rem)); height: min(360px, 52vh); }
.quick-pop input { padding: .4rem .6rem; font-size: .9rem; }
.quick-pop ul { list-style: none; margin: .4rem 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.quick-pop li { display: flex; flex-direction: column; padding: .4rem .6rem; border-radius: 8px; cursor: pointer; }
.quick-pop li.on, .quick-pop li:hover { background: var(--surface-2); }
.quick-pop li.none { color: var(--muted); cursor: default; background: none; }
.quick-pop li b { font-size: .85rem; font-weight: 600; }
.quick-pop li span { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-tabs { display: flex; gap: .15rem; overflow-x: auto; flex: none; padding-bottom: .35rem; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.pick-tabs button { flex: none; display: grid; place-items: center; width: 42px; min-width: 38px; height: 38px; overflow: hidden; padding: 0 .3rem; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 1.25rem; color: var(--muted); }
.pick-tabs button:hover { background: var(--surface-2); }
.pick-tabs button.on { background: var(--brand-tint); color: var(--brand-ink); }
.pick-tabs img { width: 30px; height: 30px; object-fit: contain; pointer-events: none; }
.emoji-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); align-content: start; padding-top: .35rem; }
.emoji-grid button { border: 0; background: none; font-size: 1.45rem; line-height: 1; height: 40px; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--surface-2); }
.sticker-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); grid-auto-rows: 84px;
  gap: .25rem; align-content: start; padding-top: .35rem; }
.sticker-grid button { position: relative; display: grid; place-items: center; height: 84px; border: 0; background: none; border-radius: 10px; padding: .3rem;
  cursor: pointer; overflow: hidden; font-size: .7rem; color: var(--muted); }
.sticker-grid button:hover, .sticker-grid button.on { background: var(--surface-2); }
.sticker-grid img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.pick-note { margin: .3rem 0 0; flex: none; }

/* ข้อมูลลูกค้า (ขวา) */
.profile { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; min-height: 0; padding: 1.1rem 1rem; }
.prof-top { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.prof-id { flex: 1; min-width: 0; }
.prof-name { display: flex; align-items: center; gap: .3rem; font-size: 1.08rem; }
.prof-name strong { font-weight: 500; overflow-wrap: anywhere; }
.prof-owner { margin-top: .25rem; }
.pencil { border: 0; background: none; cursor: pointer; color: var(--brand-ink); font-size: 1.05rem; padding: 0 .2rem; }
.nick-form { width: 100%; margin-top: .2rem; }
.nick-form .actions { margin-top: .35rem; }
.profile section { padding: .8rem 0; border-bottom: 1px solid var(--line); }
.profile section:last-child { border-bottom: 0; }
.profile h3 { display: flex; justify-content: space-between; font-size: .9rem; font-weight: 600; margin: 0 0 .45rem; }
.profile textarea { font-size: .88rem; margin-bottom: .35rem; }
.profile input[type=file] { font-size: .8rem; padding: .3rem; margin-bottom: .35rem; }
.profile p { margin: .35rem 0 0; }
.mini { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
.mini li { display: flex; justify-content: space-between; gap: .5rem; padding: .18rem 0; }
.mini li span:first-child { color: var(--muted); }
.slipdot { font-size: .78rem; }
.slipdot.slip-ok { color: var(--brand-ink); background: none; }
.slipdot.slip-duplicate, .slipdot.slip-receiver_mismatch { color: var(--hand); background: none; }

/* แจ้งผลสั้น ๆ */
.toast { position: fixed; left: 50%; bottom: 1.3rem; transform: translateX(-50%); z-index: 60; background: #1e2b2f; color: #fff;
  padding: .55rem 1.1rem; border-radius: 10px; font-size: .9rem; box-shadow: var(--shadow); max-width: 92vw; }
.toast-err { background: #b4361b; }

/* จอกลาง: ซ่อนข้อมูลลูกค้า กดปุ่ม "ข้อมูล" เพื่อเปิดเป็นแผงลอย */
@media (max-width: 1280px) {
  .inbox-grid, body.no-chat .inbox-grid { grid-template-columns: 310px minmax(0, 1fr); }
  #profileToggle { display: inline-block; }
  .profile { display: none; }
  body.show-profile .profile { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); z-index: 40; box-shadow: var(--shadow); }
}

/* ---------- ตาราง ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: .8rem 0; }
.table th, .table td { text-align: left; vertical-align: top; padding: .65rem .75rem; border-bottom: 1px solid var(--line); }
.table th { font-size: .82rem; font-weight: 500; color: var(--muted); background: var(--surface-2); }
.table tr.off { opacity: .5; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: .92rem; }
.toggle { font: inherit; font-size: .82rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: .1rem .7rem; cursor: pointer; }
.toggle.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.toggle.on.warn { background: var(--hand); border-color: var(--hand); }
.toggle:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- สถิติ ---------- */
.switch-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.switch-card.is-on { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.kpis div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.kpis b { display: block; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpis span { font-size: .82rem; color: var(--muted); }
.kpis .kpi-main { border-color: var(--brand); }
.kpis .kpi-main b { color: var(--brand-ink); }
.speed-form { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.speed-form label { margin: 0; flex: 0 1 260px; }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 170px 1fr 40px; gap: .6rem; align-items: center; margin: .3rem 0; font-size: .9rem; }
.bars i { display: block; height: 10px; border-radius: 5px; background: var(--rev); }
.bars b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- ข้อเสนอแก้ KB ---------- */
.sugg { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.sugg-context > div { margin-bottom: .6rem; }
.sugg-context p { margin: .15rem 0 0; font-size: .92rem; }
.label { font-size: .8rem; color: var(--muted); }
.strike { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(180,54,27,.5); }

/* ---------- เข้าสู่ระบบ ---------- */
.is-login { min-height: 100vh; display: grid; place-items: center; }
.login { width: 100%; max-width: 400px; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 2rem 1.8rem 1.8rem; }
.login-card fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.login-card .btn { width: 100%; margin-top: .6rem; }
/* โลโก้กลางด้านบน แล้วชื่อระบบ + คำอธิบายใต้โลโก้ */
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1.3rem; }
.login-logo { display: block; width: auto; height: auto; max-height: 128px; max-width: 100%; margin-bottom: 1rem; }
.login-icon { display: block; width: 88px; height: 88px; border-radius: 20px; object-fit: cover; margin-bottom: .9rem; }
.login-brand h1 { margin: 0; font-size: 1.45rem; line-height: 1.35; overflow-wrap: anywhere; }
.login-brand p { margin: .3rem 0 0; }
.login-preview { text-align: center; font-size: .85rem; color: var(--muted); margin: 0 0 .8rem; }
@media (max-width: 420px) { .login-logo { max-height: 104px; } .login-card { padding: 1.6rem 1.2rem 1.3rem; } }

/* ---------- หน้าตั้งค่า (แบบ "ตั้งค่าแชท" ของ LINE OA) ---------- */
.set-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: .4rem 0 1rem; }
.set-head h1 { font-size: 1.55rem; }
.set-tabs { display: flex; gap: .1rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scrollbar-width: thin; }
.set-tabs a { flex: none; padding: .55rem 1rem; color: var(--brand-ink); text-decoration: none; font-size: .92rem; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; margin-bottom: -1px; }
.set-tabs a:hover { background: var(--surface-2); }
.set-tabs a.on { color: var(--ink); background: var(--surface); border-color: var(--line); font-weight: 500; }
.set-card h2 { font-size: 1.1rem; }
.set-sub { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.set-row { display: grid; grid-template-columns: minmax(180px, 300px) minmax(0, 1fr); gap: .5rem 1.6rem; padding: .85rem 0; border-bottom: 1px solid var(--line-2); }
.set-row:last-of-type { border-bottom: 0; }
.set-label { display: flex; flex-direction: column; gap: .15rem; }
.set-label b { font-weight: 500; }
.set-field > label:first-child { margin-top: 0; }
.inline-num { display: flex; align-items: center; gap: .5rem; }
.inline-num input { width: 110px; }
.icon-preview { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.icon-now { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); }
.logo-preview { display: inline-flex; padding: .7rem 1rem; margin-bottom: .5rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.logo-now { display: block; height: 80px; width: auto; max-width: 260px; object-fit: contain; }
.set-field a.small { display: inline-block; margin-top: .35rem; }
.theme-pick { display: flex; gap: .7rem; flex-wrap: wrap; }
.theme-card { display: flex; flex-direction: column; align-items: center; gap: .35rem; margin: 0; padding: .55rem; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-size: .85rem; }
.theme-card:has(input:checked) { border-color: var(--brand); }
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-swatch { display: grid; grid-template-columns: 22px 1fr; grid-template-rows: 14px 1fr; width: 116px; height: 70px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.theme-swatch i:nth-child(1) { grid-column: 1 / 3; }
.theme-light i:nth-child(1) { background: #fff; border-bottom: 1px solid #e3e6ea; } .theme-light i:nth-child(2) { background: #f7f8fa; } .theme-light i:nth-child(3) { background: #fff; }
.theme-dark i:nth-child(1) { background: #1a1d21; border-bottom: 1px solid #31363c; } .theme-dark i:nth-child(2) { background: #22262b; } .theme-dark i:nth-child(3) { background: #111315; }
.theme-auto { background: linear-gradient(135deg, #f5f6f7 50%, #1a1d21 50%); }
.theme-auto i { background: transparent !important; }
.sound-pick { display: flex; flex-direction: column; }
.sound-row { display: flex; align-items: center; gap: .4rem; }
.sound-row label { flex: 0 1 220px; margin: .15rem 0; }
.play-btn { width: 30px; height: 30px; font-size: .75rem; border: 1px solid var(--line); border-radius: 50%; color: var(--brand-ink); }
.vol { display: flex; align-items: center; gap: .6rem; margin-top: .7rem; }
.vol input { flex: 1; max-width: 260px; }
.bank-grid { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem; }
.bank-grid li { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border: 1px solid var(--line-2); border-radius: 10px; }
.bank-grid .bank, .bank-grid .bank-logo { font-size: .85rem; }
.bank-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; font-size: .9rem; }
.bank-up { margin: 0; }
.up-label { margin: 0; }

/* ---------- ข้อความตอบกลับ / นำเข้า ---------- */
.len-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.len-form .chip { padding: .35rem .75rem; }
.map-table td, .map-table th { vertical-align: middle; }
.map-table select { width: auto; }
.preview-rows { font-size: .86rem; }
.preview-rows .dir-in { color: var(--muted); }
.preview-rows .dir-out { color: var(--link); }

/* ---------- พนักงาน ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.staff-act > summary { list-style: none; display: inline-block; }
.staff-act > summary::-webkit-details-marker { display: none; }
.staff-act[open] > summary { margin-bottom: .3rem; }
.staff-act .actions { margin-top: .35rem; flex-wrap: wrap; }

/* ---------- บัญชีรับเงิน ---------- */
.recv-ok { color: var(--brand-ink); font-weight: 500; }
.acc-form .grid-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.acc-test { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.acc-test label { margin: 0; flex: 1 1 220px; }
.match-ok { color: var(--brand-ink); font-weight: 600; }
.match-bad { color: var(--hand); font-weight: 600; }
.bank-pick { border: 0; margin: .4rem 0 .6rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .4rem; }
.bank-pick legend { font-size: .92rem; margin-bottom: .35rem; padding: 0; }
.bank-opt { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .86rem; line-height: 1.25; }
.bank-opt:hover { border-color: var(--muted); }
.bank-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.bank-opt input { position: absolute; opacity: 0; pointer-events: none; }
.bank-opt:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.bank-opt > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.bank-opt small { font-size: .72rem; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 820px) {
  .menu-btn { display: inline-grid; margin-left: -.3rem; }
  .brand span { max-width: 42vw; }
  .mode, .me-name, .alert-toggle span { display: none; }
  .alert-toggle { padding: .3rem; border-radius: 50%; }
  .sidenav { position: fixed !important; left: 0; top: var(--appbar-h); bottom: 0; height: auto !important; width: min(280px, 84vw) !important;
    transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); z-index: 45; }
  body.nav-open .sidenav { transform: none; }
  body.nav-open .nav-shade { display: block; position: fixed; inset: var(--appbar-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 44; }
  html .sidenav .nav-label { display: block !important; }
  html .sidenav .caret { display: inline-block !important; }
  html .sidenav .nav-sub { display: flex !important; }
  html .sidenav .nav-group > summary { display: flex !important; }
  html .sidenav .nav-mini-link, .nav-collapse { display: none !important; }
  html .sidenav .nav-item { justify-content: flex-start !important; padding: .62rem .75rem !important; }
  .inbox-grid, body.no-chat .inbox-grid { grid-template-columns: minmax(0, 1fr); }
  body.has-chat .chatlist { display: none; }
  body.no-chat .chatpane { display: none; }
  .chat-head { padding: .45rem .6rem; gap: .5rem; }
  .chat-head .back { display: block; }
  .chat-head .who-cust { min-width: 0; }
  .chat-head .who-cust .small { display: none; }
  .head-actions { width: 100%; }
  .thread-wrap { padding: .6rem .7rem; }
  .msg { max-width: 88%; }
  .composer-dock { padding: .45rem .6rem .6rem; }
  .hint, .tool-label { display: none; }
  .composer .actions { flex-wrap: wrap; }
  .btn-send { margin-left: auto; }
  .wrap { padding: 1rem .9rem 3rem; }
  .set-row { grid-template-columns: 1fr; }
  .edit-reason input[name=edit_note] { flex-basis: 100%; }
  .sugg { grid-template-columns: 1fr; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .stats th:nth-child(3), .stats td:nth-child(3) { display: table-cell; }
  .kpi-table th:nth-child(3), .kpi-table td:nth-child(3), .table-sm th:nth-child(3), .table-sm td:nth-child(3) { display: table-cell; }
  .bars li { grid-template-columns: 110px 1fr 32px; }
}

/* ---------- หลายร้าน ---------- */
.shop { display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; font-size: .72rem; font-weight: 600; line-height: 1.5;
  padding: 0 .5rem 0 .4rem; border-radius: 9px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.shop::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--shop, #8a949e); }
.who-cust strong .shop { margin-left: .3rem; font-weight: 500; }
.inbox .line-shop { display: flex; min-width: 0; margin: .05rem 0; }
.list-shop { margin: 0; padding: .6rem .7rem 0; }
.list-shop select { font-size: .88rem; padding: .38rem .5rem; font-weight: 500; }
.shop-pick { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0 0 1rem; }
.shop-pick a { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 18px;
  color: var(--ink); text-decoration: none; font-size: .88rem; background: var(--surface); }
.shop-pick a i { width: 9px; height: 9px; border-radius: 50%; }
.shop-pick a.on { border-color: var(--brand); background: var(--brand-tint); font-weight: 600; }
.oa-pic { width: 28px; height: 28px; border-radius: 50%; float: left; margin: .1rem .5rem 0 0; object-fit: cover; }
.color-pick { display: flex; gap: .45rem; flex-wrap: wrap; }
.color-pick label { margin: 0; cursor: pointer; }
.color-pick input { position: absolute; opacity: 0; pointer-events: none; }
.color-pick i { display: block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.color-pick input:checked + i { box-shadow: 0 0 0 2px var(--ink); }
.color-pick input:focus-visible + i { outline: 2px solid var(--brand); outline-offset: 2px; }
.shop-checks { border: 0; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.shop-checks legend { font-size: .92rem; margin-bottom: .3rem; padding: 0; }
.rules-shop { margin: .7rem 0 .25rem; }
.rules-shop:first-child { margin-top: 0; }
.import-sum { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 .8rem; }
.import-sum span { padding: .3rem .8rem; border-radius: 8px; background: var(--surface-2); font-size: .9rem; }
.import-sum .ok { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.import-sum .skip { background: var(--hand-tint); color: var(--hand); }
.inline-label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
/* เมนูย่อยของ แชท: ทุกร้าน / แต่ละร้าน */
.nav-sub a .nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sub a.off { opacity: .55; }
.nav-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.nav-mini-link { position: relative; }
.badge-mini { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; font-size: .62rem; padding: 0 4px; margin: 0; }
.list-shop { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .8rem 0; }
.list-shop .shop { font-size: .82rem; }

/* "ทุกร้าน" ใช้วงกลมว่าง ให้ตัวหนังสือตรงกับชื่อร้าน */
.nav-dot.all { background: none; box-shadow: inset 0 0 0 1.5px var(--muted); }

/* ---------- แนบรูปในกล่องพิมพ์ ---------- */
.img-chosen { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-top: .35rem; }
.img-thumbs { display: flex; gap: .5rem; flex-wrap: wrap; }
.img-thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(0,0,0,.62); color: #fff; font-size: .72rem; line-height: 22px; text-align: center; cursor: pointer; }
.img-x:hover, .img-x:focus-visible { background: rgba(0,0,0,.85); }
.drop-zone { position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; padding: 1.2rem;
  background: color-mix(in srgb, var(--surface) 94%, transparent); pointer-events: none; }
.drop-zone > div { display: flex; flex-direction: column; align-items: center; gap: .35rem; width: 100%; height: 100%; justify-content: center;
  border: 2px dashed var(--brand); border-radius: 16px; color: var(--brand-ink); text-align: center; }
.drop-zone .ico { width: 44px; height: 44px; }
.drop-zone b { font-size: 1.05rem; }

/* ---------- บัญชีของฉัน ---------- */
a.who { text-decoration: none; border-radius: 999px; padding: .15rem .55rem .15rem .15rem; }
a.who:hover { background: var(--surface-2); }
.acct-id { display: flex; flex-direction: column; gap: .15rem; }

/* ---------- ตำแหน่งงาน ---------- */
.pos { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 500; line-height: 1.3; padding: .1rem .5rem; border-radius: 999px;
  color: var(--ink); background: color-mix(in srgb, var(--pos) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--pos) 35%, var(--surface)); white-space: nowrap; }
.pos::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pos); }
.who-pos { color: var(--muted); font-weight: 400; }
.table .grp-row th { background: var(--surface); color: var(--ink); font-size: .9rem; padding-top: 1rem; display: table-cell; }
.grp-row .pos-rename { display: inline-block; margin-left: .6rem; vertical-align: middle; }
.grp-row .pos-rename summary { color: var(--muted); cursor: pointer; }
.grp-row .pos-rename form { margin-top: .4rem; }

/* ---------- รายงาน: KPI / การใช้ AI ---------- */
:root { --st-good: #06a548; --st-warn: #e0a106; --st-bad: #d9452b; }
:root[data-theme="dark"] { --st-good: #3ddc84; --st-warn: #f2c35e; --st-bad: #ff8f75; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --st-good: #3ddc84; --st-warn: #f2c35e; --st-bad: #ff8f75; } }
.kpi-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; margin-bottom: .4rem; }
.kpi-filter input[type=date] { width: auto; padding: .3rem .45rem; }
.kpi-filter select { width: auto; }
.period-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.period-seg a { padding: .38rem .75rem; font-size: .86rem; color: var(--ink); text-decoration: none; border-right: 1px solid var(--line); }
.period-seg a:last-child { border-right: 0; }
.period-seg a:hover { background: var(--surface-2); }
.period-seg a.on { background: var(--ink); color: var(--surface); }
.kpi-range { margin: .2rem 0 .9rem; }
.inline-set { display: inline-block; margin-left: .4rem; }
.inline-set summary { display: inline; cursor: pointer; color: var(--link); }
.inline-set form { margin-top: .4rem; }
.kpis .kpi-bad { border-color: var(--st-bad); }
.kpis .kpi-bad b { color: var(--st-bad); }
.txt-bad { color: var(--st-bad); }
.txt-warn { color: var(--rev); }
.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: .8rem 0; }
.table-wrap .table { margin: 0; }
.table-sm th, .table-sm td { padding: .42rem .6rem; font-size: .88rem; }
.kpi-table td, .kpi-table th { white-space: nowrap; }
.kpi-table td:first-child { white-space: normal; min-width: 150px; }
.kpi-table td:not(:first-child) { font-variant-numeric: tabular-nums; }
.kpi-table th[data-sort] { cursor: pointer; user-select: none; }
.kpi-table th[data-sort]:hover { color: var(--ink); }
.kpi-table th.sorted-asc::after { content: " ▲"; font-size: .7em; }
.kpi-table th.sorted-desc::after { content: " ▼"; font-size: .7em; }
.kpi-table tfoot td { background: var(--surface-2); border-bottom: 0; }
.kpi-table a { color: inherit; }
.meter { display: inline-block; width: 54px; height: 6px; border-radius: 3px; background: var(--line-2); vertical-align: middle; margin-right: .4rem; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; }
.meter-good i { background: var(--st-good); }
.meter-warn i { background: var(--st-warn); }
.meter-bad i { background: var(--st-bad); }
.meter-wide { width: min(320px, 100%); height: 8px; }
.budget { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin: .8rem 0; }
.kpi-person .kpi-who { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .7rem; }
.kpi-person .kpi-who h2 { margin: 0; }
.kpi-split { gap: 0 1rem; }
.kpi-split .card { margin: .5rem 0; }
.kpi-help ul { margin: .6rem 0 0; padding-left: 1.2rem; font-size: .88rem; line-height: 1.7; }
.empty-note { color: var(--muted); padding: 1.2rem 0; }
.ai-alert { border-color: var(--st-bad); background: var(--hand-tint); }
.credit-form { align-items: end; }
.price-form input { padding: .3rem .4rem; }
/* กราฟแท่ง */
.chart { margin: .4rem 0 .2rem; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: inherit; }
.chart .fill { fill: var(--brand); }
.chart .hit { fill: transparent; }
.chart .bar { cursor: default; outline: none; }
.chart .bar:hover .fill, .chart .bar:focus .fill { fill: var(--brand-ink); }
.chart .bar:hover .hit, .chart .bar:focus .hit { fill: var(--surface-2); }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: var(--surface); font-size: .8rem; line-height: 1.4;
  padding: .35rem .6rem; border-radius: 7px; box-shadow: var(--shadow); max-width: 280px; }

/* ---------- บอทฝากเงิน ---------- */
.dep { max-width: 310px; margin-top: .35rem; border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px;
  background: var(--surface); padding: .45rem .65rem; font-size: .83rem; line-height: 1.55; scroll-margin-top: 80px; }
.dep-h { display: flex; flex-wrap: wrap; gap: .1rem .5rem; align-items: baseline; }
.dep-h span { color: var(--muted); font-size: .76rem; font-weight: 600; }
.dep-h b { font-weight: 600; }
.dep-b { margin-top: .15rem; overflow-wrap: anywhere; }
.dep-f { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.dep-f form, .dep-act form { margin: 0; }
.dep.dep-sent { border-left-color: var(--brand); }
.dep.dep-waiting_info, .dep.dep-ready, .dep.dep-sending, .dep.dep-processing { border-left-color: var(--rev); }
.dep.dep-failed, .dep.dep-rejected { border-left-color: var(--hand); background: var(--hand-tint); }
.dep.dep-cancelled { opacity: .7; }
.dep:target { box-shadow: 0 0 0 2px #f3c64d; }
.dep-hold { color: var(--rev); }
.dep-err { color: var(--hand); }
.depdot { font-size: .78rem; font-weight: 600; white-space: nowrap; }
.depdot.dep-sent { color: var(--brand-ink); }
.depdot.dep-failed, .depdot.dep-rejected { color: var(--hand); }
.depdot.dep-waiting_info, .depdot.dep-ready, .depdot.dep-sending, .depdot.dep-processing { color: var(--rev); }
.depdot.dep-cancelled { color: var(--muted); }
/* ---------- บอทรีเซ็ตรหัส (ใช้การ์ด/ตารางแบบเดียวกับบอทฝากเงิน) ---------- */
.dep.pw-verified, .dep.pw-unsent { border-left-color: var(--rev); background: var(--rev-tint, var(--surface)); }
.dep.pw-collecting, .dep.pw-verifying, .dep.pw-confirming { border-left-color: var(--rev); }
.dep.pw-done { border-left-color: var(--brand); }
.dep.pw-mismatch, .dep.pw-error { border-left-color: var(--hand); background: var(--hand-tint); }
.dep.pw-cancelled, .dep.pw-expired { opacity: .7; }
.pw-ok { color: var(--brand-ink); font-weight: 700; }
.pw-fill { margin-top: .45rem; }
.pw-fill summary { cursor: pointer; color: var(--muted); }
.pw-fill form { margin-top: .4rem; }
.depdot.pw-done { color: var(--brand-ink); }
.depdot.pw-verified, .depdot.pw-unsent, .depdot.pw-collecting, .depdot.pw-verifying, .depdot.pw-confirming { color: var(--rev); }
.depdot.pw-mismatch, .depdot.pw-error { color: var(--hand); }
.depdot.pw-cancelled, .depdot.pw-expired { color: var(--muted); }
a.depdot { text-decoration: none; }
.pw-table .dep-act { white-space: normal; min-width: 210px; }
.pw-shops { margin-top: .4rem; border-top: 1px dashed var(--line); padding-top: .5rem; }
.pw-shops summary { cursor: pointer; }
.pw-shop-row { display: grid; grid-template-columns: 150px minmax(0, .7fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: .3rem .6rem; align-items: end; margin-top: .5rem; }
.pw-shop-name { padding-bottom: .55rem; }
.pw-ep li { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
@media (max-width: 720px) {
  .pw-shop-row { grid-template-columns: 1fr; }
  .pw-shop-name { padding-bottom: 0; }
  .pw-ep li { grid-template-columns: 1fr auto; }
  .pw-ep li > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
}
.pw-table .dep-act form.inline { display: inline-block; margin: 0 .3rem .3rem 0; }
.dep-row.pw-mismatch td, .dep-row.pw-error td { background: var(--hand-tint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; overflow-wrap: anywhere; }
.member-form label { display: block; font-size: .82rem; color: var(--muted); margin: 0 0 .45rem; }
.member-form input { margin-top: .15rem; }
.member-form p { margin: .4rem 0 0; }
.dep-kpis { margin-bottom: 1rem; }
.dep-filter .dep-search { width: auto; min-width: 210px; flex: 1 1 210px; max-width: 320px; }
.seg-n { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .2rem; border-radius: 8px; font-size: .74rem; line-height: 1.45;
  text-align: center; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.seg-n.seg-warn { background: var(--hand); color: #fff; }
.period-seg a.on .seg-n { background: var(--surface); color: var(--ink); }
.table-scroll { overflow-x: auto; }
.dep-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dep-table td { vertical-align: top; }
.dep-table .dep-st { min-width: 200px; }
.dep-table .dep-st .small { margin-top: .2rem; line-height: 1.55; overflow-wrap: anywhere; }
.dep-cust { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink); text-decoration: none; font-weight: 500; }
.dep-cust:hover span { text-decoration: underline; }
.dep-act { white-space: nowrap; }
.dep-act form + form { margin-left: .3rem; }
.dep-row.dep-failed td, .dep-row.dep-rejected td { background: var(--hand-tint); }
.api-doc pre, pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .65rem .8rem; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; line-height: 1.55; white-space: pre; }
.api-doc summary { cursor: pointer; font-weight: 600; }
@media (max-width: 760px) {
  /* มือถือ: แต่ละรายการเป็นการ์ด (เวลา / ลูกค้า + ยอด / สถานะ / ปุ่ม) */
  .table-scroll { overflow: visible; }
  .dep-table, .dep-table tbody { display: block; }
  .dep-table thead { display: none; }
  .dep-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .7rem; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
  .dep-table tr:last-child { border-bottom: 0; }
  .dep-table td:nth-child(n) { display: block; padding: 0; border: 0; min-width: 0; }
  .dep-table td:nth-child(1) { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); }
  .dep-table td:nth-child(1) br { display: none; }
  .dep-table td:nth-child(1) .small { margin-left: .4rem; }
  .dep-table td:nth-child(2) { grid-column: 1; }
  .dep-table td:nth-child(3) { grid-column: 2; grid-row: 2; font-size: 1rem; }
  .dep-table td:nth-child(4), .dep-table td:nth-child(5) { grid-column: 1 / -1; }
  .dep-table .dep-st { min-width: 0; }
  .dep-act { white-space: normal; margin-top: .2rem; }
  .dep-act form { display: inline-block; margin: 0 .3rem .3rem 0; }
  .dep-act form + form { margin-left: 0; }
  .dep-filter .dep-search { max-width: none; }
  .dep-row.pw-mismatch, .dep-row.pw-error, .dep-row.dep-failed, .dep-row.dep-rejected { background: var(--hand-tint); }
  .dep-table tr.dep-row td { background: transparent; }
}
.grid-end { align-items: end; }

/* ---------- ลดค่าใช้จ่าย AI ---------- */
.save-form .save-opt { display: flex; gap: .55rem; align-items: flex-start; margin: .45rem 0; line-height: 1.5; }
.save-form .save-opt input { margin-top: .3rem; flex: none; }
.save-form > label.small { display: block; margin: .7rem 0 .2rem; }
.save-form select { width: auto; max-width: 100%; margin-left: .4rem; }
.save-card h4 { margin: 1.1rem 0 .3rem; font-size: .95rem; }
.save-notes { margin: .5rem 0 0; padding-left: 1.1rem; line-height: 1.75; }
.cmp-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- แท็กลูกค้า ---------- */
.ctag { display: inline-flex; align-items: center; gap: .2rem; max-width: 11em; font-size: .72rem; font-weight: 500; line-height: 1.5;
  padding: 0 .5rem; border-radius: 9px; background: var(--tc, #8a949e); color: var(--tf, #fff); white-space: nowrap; vertical-align: middle; }
.ctag-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ctag-none { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }
.ctag-more { font-size: .7rem; color: var(--muted); align-self: center; }
.ctag-x { border: 0; background: none; color: inherit; font: inherit; font-size: .95rem; line-height: 1; padding: 0 0 0 .15rem; cursor: pointer; opacity: .75; }
.ctag-x:hover { opacity: 1; }
.inbox .line-tags { display: flex; gap: .25rem; align-items: center; overflow: hidden; margin: .1rem 0; }
.list-head { flex-wrap: wrap; }
.list-head .tag-sel { flex: 1 1 100%; max-width: none; }
.list-tag { padding-top: .45rem; }
.head-tags { display: inline-flex; flex-wrap: wrap; gap: .25rem; margin-left: .35rem; vertical-align: middle; }
.chat-head .head-tags .ctag { font-size: .68rem; }
.prof-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .45rem; }
.prof-tags form { display: inline; margin: 0; }
.prof-tags .ctag { font-size: .78rem; padding: .05rem .35rem .05rem .55rem; max-width: 100%; }
.tag-add { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: 0; }
.tag-add select, .tag-add input { flex: 1 1 8rem; width: auto; min-width: 0; font-size: .85rem; padding: .35rem .5rem; }
.tag-form-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; }
.tag-form-row > label { flex: 1 1 220px; margin: 0; }
.tag-form-row .lbl { display: block; font-size: .92rem; margin-bottom: .3rem; }
.tag-colors { display: flex; flex-wrap: wrap; gap: .3rem; }
.tag-color { margin: 0; cursor: pointer; }
.tag-color input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tag-color span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--tc); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.tag-color input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.tag-color input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.tag-table td { vertical-align: middle; }
.tag-table .ctag { font-size: .85rem; padding: .1rem .7rem; max-width: 18em; }
.tag-table .icon-btn { width: 26px; height: 26px; font-size: .7rem; }
.tag-table .icon-btn:disabled { opacity: .3; cursor: default; }
.tag-empty .ctag { margin: 0 .15rem .3rem 0; }

/* ---------- สิทธิ์เมนูของพนักงาน ---------- */
.perm-checks { border: 0; padding: 0; margin: .6rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .35rem .6rem; }
.perm-checks legend { font-size: .92rem; margin-bottom: .35rem; padding: 0; grid-column: 1 / -1; }
.perm-chk { display: grid; grid-template-columns: auto 1fr; gap: 0 .45rem; align-items: start; margin: 0; padding: .4rem .55rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: .88rem; line-height: 1.45; }
.perm-chk input { width: auto; margin: .2rem 0 0; grid-row: span 2; }
.perm-chk .perm-name { grid-column: 2; }
.perm-chk small { grid-column: 2; font-size: .76rem; }
.perm-chk:has(input:checked) { border-color: var(--link); background: var(--surface-2); }
.perm-high { display: inline-block; font-size: .66rem; font-weight: 600; padding: 0 .35rem; border-radius: 6px; margin-left: .2rem;
  background: var(--rev-tint); color: var(--rev); vertical-align: middle; }
.perm-chips { display: flex; flex-wrap: wrap; gap: .2rem; margin-top: .25rem; }
.perm-chip { font-size: .7rem; padding: 0 .45rem; border-radius: 8px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.perm-chip.high { background: var(--rev-tint); color: var(--rev); border-color: transparent; }
.perm-form { margin: .5rem 0; }
.perm-form .perm-checks { margin: .3rem 0 .4rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .8rem 0; }
.table-wrap > .table { margin: 0; }

/* ---------- บัญชีรับเงินกลาง ---------- */
.acc-filter { margin: .2rem 0 .6rem; }
.acc-shops { margin-top: .8rem; }
.acc-shop-cell { line-height: 1.9; }

/* ---------- โควตาข้อความ LINE / ฝากส่ง ---------- */
.flash-warn { background: var(--rev-tint); color: var(--rev); }
.reply-clock { display: inline-flex; align-items: center; gap: .25rem; font-size: .76rem; font-weight: 500; padding: .1rem .55rem; border-radius: 10px;
  white-space: nowrap; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--muted); }
.reply-clock:empty { display: none; }
.reply-clock.rc-free { background: var(--brand-tint); color: var(--brand-ink); }
.reply-clock.rc-free::before { content: "⚡"; }
.reply-clock.rc-out { background: var(--hand-tint); color: var(--hand); }
.msg-held .bubble { border: 1px dashed var(--rev); opacity: .85; }
.held-tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 0 .45rem; border-radius: 8px; background: var(--rev-tint); color: var(--rev); white-space: nowrap; }
.held-done { color: var(--brand-ink); white-space: nowrap; }
.held-form { margin: 0; }
.held-form .linkbtn { font-size: .72rem; }
.pill-held { background: var(--rev-tint); color: var(--rev); }
.quota-cell { min-width: 170px; line-height: 1.7; }
.quota-bar { display: block; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: .2rem 0; max-width: 180px; }
.quota-bar i { display: block; height: 100%; background: var(--brand); }
.quota-bar.low i { background: var(--rev); }
.quota-bar.out i { background: var(--hand); }
.composer .reply-clock { margin-left: auto; }
.composer .reply-clock + .hint { margin-left: .5rem; }
.composer .actions:has(.reply-clock) .btn-send { margin-left: .5rem; }
