/* Support Desk — โทนกระดาษ หมึกดำ เขียวสน เน้นอ่านง่ายและใช้งานทั้งวัน */

:root {
  --paper: #f5f3ee;
  --paper-2: #ece9e1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --line: #e3dfd5;
  --line-2: #cdc8bb;
  --ink: #1c1b19;
  --ink-2: #44423d;
  --muted: #7d7970;
  --pine: #0b7d52;
  --pine-2: #08663f;
  --pine-tint: #e2f8ee;
  --mint: #38e291;
  --red: #b42318;
  --red-tint: #fbeae8;
  --amber: #a15c07;
  --amber-tint: #fbf0dc;
  --blue: #1d4ed8;
  --blue-tint: #e8eefc;
  --grey-tint: #efede8;
  --focus: 0 0 0 3px rgba(56, 226, 145, 0.35);
  --r: 6px;
  --r-lg: 8px;
  --sidebar: 236px;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Anuphan", "IBM Plex Sans Thai", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-size: 1.45rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 0.98rem; font-weight: 600; }
h3 { font-size: 0.92rem; font-weight: 600; margin: 22px 0 10px; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--grey-tint); padding: 1px 5px; border-radius: 4px; }
.ic { flex-shrink: 0; }
::selection { background: #c4f5dc; }
hr.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30;
  background: var(--paper-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px 14px;
  transition: transform .25s ease;
}
.shell { margin-left: var(--sidebar); min-height: 100vh; }
.content { width: 100%; min-width: 0; padding: 28px 36px 64px; }

.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; color: var(--ink); padding: 2px 8px 18px; }
.brand-logo { display: block; width: 186px; height: auto; }
.brand-logo.sm { width: 127px; }
.brand-sub { font-size: 0.74rem; color: var(--muted); padding-left: 2px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 5px; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-weight: 700; font-size: 0.95rem; letter-spacing: -0.02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 0.98rem; font-weight: 700; }
.brand-text small { font-size: 0.74rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-label { font-size: 0.72rem; color: var(--muted); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r);
  color: var(--ink-2); font-size: 0.92rem; border: 1px solid transparent;
}
.nav-item:hover { background: rgba(0, 0, 0, 0.035); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--mint), 0 1px 0 rgba(0, 0, 0, 0.03); }
.nav-item .ic { color: var(--muted); }
.nav-item.active .ic { color: var(--pine); }
.nav-item .cicon { width: 20px; height: 20px; opacity: 0.85; filter: saturate(0.85); transition: transform .2s ease, opacity .15s, filter .15s; }
.nav-item:hover .cicon { opacity: 1; filter: none; transform: translateY(-1px) scale(1.08); }
.nav-item.active .cicon { opacity: 1; filter: none; }
.nav-badge {
  margin-left: auto; font-family: var(--mono); font-size: 0.74rem; font-weight: 500;
  padding: 0 6px; border-radius: 4px; background: var(--grey-tint); color: var(--ink-2); line-height: 1.6;
}
.nav-badge.hot { background: var(--red); color: #fff; }
.nav-badge:empty { display: none; }

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: var(--ink); padding: 4px; border-radius: var(--r); }
.user-chip:hover { background: rgba(0, 0, 0, 0.035); text-decoration: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta strong { font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 0.74rem; color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: #d9d4c7; color: var(--ink); font-weight: 600; font-size: 0.82rem;
}
.avatar.lg { width: 44px; height: 44px; font-size: 1.05rem; }
.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); }

.mobilebar { display: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 8px 0 30px rgba(0, 0, 0, 0.12); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(28, 27, 25, 0.3); z-index: 25; }
  .shell { margin-left: 0; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 8px 12px; background: rgba(245, 243, 238, 0.92); border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .mobilebar .brand { padding: 0; flex: 1; }
  .mobilebar .brand-sub { display: none; }
  .content { padding: 20px 16px 56px; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.page-head .sub { color: var(--muted); margin: 3px 0 0; font-size: 0.9rem; max-width: 680px; }
.crumb { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; color: var(--muted); margin-bottom: 10px; }
.crumb:hover { color: var(--ink); }

/* ---------- panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head .ic { color: var(--muted); }
.section-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin: 0 0 8px; }

/* ---------- buttons ---------- */
.btn, button:where(:not(.toast-x, .icon-btn, .switch)) {
  font: inherit; font-size: 0.88rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--r); line-height: 1.5;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  transition: background .12s, border-color .12s;
}
.btn:hover, button:where(:not(.toast-x, .icon-btn, .switch)):hover { background: var(--surface-2); border-color: #b9b3a4; text-decoration: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus); }
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary, button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover, button.primary:hover { background: #33312d; border-color: #33312d; }
.btn.go, button.go { background: var(--pine); color: #fff; border-color: var(--pine-2); }
.btn.go:hover, button.go:hover { background: var(--pine-2); }
.btn.danger, button.danger { color: var(--red); }
.btn.danger:hover, button.danger:hover { background: var(--red-tint); border-color: #e3b1ab; }
.btn.ghost, button.ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--ink-2); }
.btn.ghost:hover, button.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn.block, button.block { width: 100%; }
.btn.sm, button.sm { padding: 3px 9px; font-size: 0.82rem; }
.btn.lg, button.lg { padding: 9px 16px; font-size: 0.95rem; }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 180px; }
.grow { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.84rem; font-weight: 500; color: var(--ink-2); }
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
input, textarea, select {
  font: inherit; font-size: 0.92rem; color: var(--ink); width: 100%;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 7px 10px;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: #a8a397; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--pine); box-shadow: var(--focus); }
textarea { resize: vertical; line-height: 1.6; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237d7970' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.key-status { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); margin-top: -6px; }
.key-status .dot { margin-right: 2px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 0.92rem; }
.check-row:last-child { border-bottom: 0; }
.check-row input { width: 16px; height: 16px; margin-top: 4px; accent-color: var(--pine); flex-shrink: 0; }
.check-row .hint { display: block; }

/* toggle (ติดตามแชท) */
.switch { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 2px 0; cursor: pointer; font: inherit; font-size: 0.85rem; color: var(--muted); }
.switch .track { width: 30px; height: 17px; border-radius: 999px; background: #d3cec2; position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.switch.on { color: var(--ink); }
.switch.on .track { background: var(--pine); }
.switch.on .track::after { transform: translateX(13px); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(400px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 10px 10px 12px; border-radius: var(--r);
  background: var(--ink); color: #f3f1ea; font-size: 0.9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  animation: toastIn .2s ease-out;
}
.toast.error { background: var(--red); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .2s; }
.toast-ic { display: grid; padding-top: 2px; opacity: 0.85; }
.toast-msg { flex: 1; }
.toast-x { background: none; border: 0; color: inherit; opacity: 0.6; cursor: pointer; padding: 3px; display: grid; border-radius: 4px; }
.toast-x:hover { opacity: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- notes ---------- */
.note { border-left: 3px solid var(--line-2); background: var(--surface-2); padding: 9px 12px; font-size: 0.9rem; color: var(--ink-2); border-radius: 0 var(--r) var(--r) 0; }
.note strong { color: var(--ink); font-weight: 600; }
.note.error { border-color: var(--red); background: var(--red-tint); color: #7a1a12; }
.note.warn { border-color: var(--amber); background: var(--amber-tint); color: #6b3d05; }
.note ul { margin: 4px 0 0; padding-left: 18px; }
.storage-warn { margin-bottom: 18px; }

.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.error-text { color: var(--red); }
.ok-text { color: var(--pine); }

/* ---------- dashboard ---------- */
.ledger { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; overflow: hidden; }
.ledger a { padding: 16px 18px; color: var(--ink); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.ledger a:last-child { border-right: 0; }
.ledger a:hover { background: var(--surface-2); text-decoration: none; }
.ledger .label { font-size: 0.82rem; color: var(--muted); }
.ledger .value { font-family: var(--mono); font-size: 1.75rem; font-weight: 500; line-height: 1.25; letter-spacing: -0.02em; }
.ledger .value.attention { color: var(--red); }
.ledger .value.text { font-family: inherit; font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 7px; padding: 8px 0 5px; }
.ledger .foot { font-size: 0.78rem; color: var(--muted); }
@media (max-width: 900px) { .ledger { grid-template-columns: 1fr 1fr; } .ledger a:nth-child(2) { border-right: 0; } .ledger a:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.live { background: #12a150; }
.dot.off { background: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card, .grid-2 > .panel { margin-bottom: 0; }
.grid-2 + * { margin-top: 16px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.75fr) minmax(270px, 1fr); align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 20px; }

.cat-table td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.cat-table tr:hover { background: none; }
.cat-table .meter { width: 38%; padding-left: 14px; }
.meter-track { height: 6px; background: var(--grey-tint); border-radius: 3px; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; }

/* ---------- lists & tables ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { text-decoration: none; }
a.list-item:hover .li-title { text-decoration: underline; text-underline-offset: 3px; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.li-sub { font-size: 0.8rem; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 0.8rem; background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 0.85rem; }
tr.dim td { color: var(--muted); }
td .title-link { color: var(--ink); font-weight: 500; }
.col-title { min-width: 220px; }
.nowrap { white-space: nowrap; }
@media (max-width: 1240px) { .col-opt { display: none; } }
.id { font-family: var(--mono); color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.when { font-family: var(--mono); color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* ---------- tags ---------- */
.tag {
  display: inline-block; font-size: 0.76rem; font-weight: 500; padding: 1px 7px; border-radius: 4px; white-space: nowrap; line-height: 1.6;
  background: var(--grey-tint); color: var(--ink-2); border: 1px solid transparent;
}
a.tag:hover { text-decoration: none; border-color: var(--line-2); }
.sev-low { background: var(--grey-tint); color: var(--muted); }
.sev-medium { background: var(--blue-tint); color: var(--blue); }
.sev-high { background: var(--amber-tint); color: var(--amber); }
.sev-critical { background: var(--red); color: #fff; }
.st-open { background: var(--amber-tint); color: var(--amber); }
.st-in_progress { background: var(--blue-tint); color: var(--blue); }
.st-resolved { background: var(--pine-tint); color: var(--pine); }
.st-closed { background: var(--grey-tint); color: var(--muted); }
.rs-pending { background: var(--amber-tint); color: var(--amber); }
.rs-sending { background: var(--blue-tint); color: var(--blue); }
.rs-sent { background: var(--pine-tint); color: var(--pine); }
.rs-rejected, .rs-failed { background: var(--red-tint); color: var(--red); }
.rs-superseded { background: var(--grey-tint); color: var(--muted); text-decoration: line-through; }

/* ---------- tabs & filters ---------- */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin: -4px 0 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 0 7px; color: var(--muted); font-size: 0.9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 160px; }

/* ---------- approval queue ---------- */
.reply { padding: 0; overflow: hidden; }
.reply-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 11px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.reply-head .who { font-weight: 600; flex: 1; min-width: 140px; }
.reply-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.reply-body > div { padding: 16px 18px; }
.reply-body > div + div { border-left: 1px solid var(--line); }
.reply-body.single { display: block; }
@media (max-width: 900px) { .reply-body { grid-template-columns: 1fr; } .reply-body > div + div { border-left: 0; border-top: 1px solid var(--line); } }
.composer textarea { min-height: 120px; }
.reply-head .who { display: flex; align-items: center; gap: 7px; }

/* ---------- กล่องรออนุมัติ: ตอบลูกค้า / ส่งเข้ากลุ่มโปรแกรมเมอร์ ---------- */
.boxtabs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.boxtab {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--ink);
}
.boxtab:hover { text-decoration: none; border-color: var(--line-2); }
.boxtab.active { border-color: var(--pine); box-shadow: inset 0 0 0 1px var(--pine); background: #fbfefc; }
.boxtab.dev.active { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); background: #fbfcff; }
.boxtab-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); }
.boxtab-text { display: flex; flex-direction: column; min-width: 0; }
.boxtab-text strong { font-weight: 600; }
.boxtab-text small { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boxtab-count { font-family: var(--mono); font-size: 1.3rem; min-width: 36px; text-align: center; padding: 2px 8px; border-radius: 99px; background: var(--grey-tint); color: var(--muted); }
.boxtab-count.hot { background: var(--red-tint); color: var(--red); }
@media (max-width: 700px) { .boxtabs { grid-template-columns: 1fr; } }

.dticket { padding: 0; overflow: hidden; border-left: 3px solid var(--blue); }
.dt-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.dt-id { font-family: var(--mono); font-weight: 600; font-size: 0.95rem; color: var(--blue); background: var(--blue-tint); border-radius: var(--r); padding: 4px 9px; }
.dt-title { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.dt-title strong { font-size: 1.02rem; font-weight: 600; line-height: 1.35; }
.dt-title span { color: var(--muted); font-size: 0.8rem; }
.dt-body { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.dt-body > div { padding: 16px 18px; min-width: 0; }
.dt-msg { border-left: 1px solid var(--line); background: var(--surface-2); }
.dt-msg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dt-summary { margin: 0 0 14px; font-size: 0.9rem; line-height: 1.6; color: var(--ink-2); }
.tg-bubble {
  white-space: pre-wrap; word-break: break-word; font-size: 0.88rem; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: 12px 14px;
}
.dt-msg textarea { width: 100%; font-size: 0.86rem; line-height: 1.55; }
.dt-foot { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.dt-hint { flex: 1; min-width: 180px; }
.site-pill { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; font-size: 0.78rem; padding: 1px 8px; border-radius: 99px; background: var(--grey-tint); }
.site-pill.up { background: var(--pine-tint); color: var(--pine); }
.site-pill.moved { background: var(--amber-tint); color: var(--amber); }
.site-pill.down { background: var(--red-tint); color: var(--red); }
@media (max-width: 900px) { .dt-body { grid-template-columns: 1fr; } .dt-msg { border-left: 0; border-top: 1px solid var(--line); } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.tools { display: flex; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.tools form { display: flex; gap: 6px; min-width: 0; }
.tools form:first-child { flex: 1; min-width: 260px; }
.tools input { min-width: 0; }
.sent-text { white-space: pre-wrap; }
.decided { font-size: 0.82rem; color: var(--muted); margin-top: 8px; }

/* ---------- chat ---------- */
.chatlog { display: flex; flex-direction: column; gap: 8px; }
.chatlog.compact { max-height: 330px; overflow-y: auto; padding-right: 4px; }
.chatlog.full { padding: 20px; background: var(--surface-2); }
.msg { max-width: 80%; align-self: flex-start; padding: 7px 11px; border-radius: 10px 10px 10px 3px; background: var(--surface); border: 1px solid var(--line); }
.msg.out { align-self: flex-end; border-radius: 10px 10px 3px 10px; background: var(--pine-tint); border-color: #bdeed5; }
.msg.target { border-color: var(--amber); box-shadow: inset 3px 0 0 var(--amber); }
.msg .meta { font-size: 0.75rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.msg .body { white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; }
.thumb { max-width: 240px; max-height: 240px; border-radius: var(--r); margin-top: 6px; display: block; border: 1px solid var(--line); }
.thumb.small { max-width: 140px; max-height: 140px; }
@media (max-width: 640px) { .msg { max-width: 94%; } }

/* ---------- ticket ---------- */
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 7px 14px; margin: 0 0 14px; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.summary { white-space: pre-wrap; line-height: 1.75; padding-top: 12px; border-top: 1px solid var(--line); }
.facts + .section-title { border-top: 1px solid var(--line); padding-top: 12px; }
.section-title + .summary { border-top: 0; padding-top: 0; }
.site-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.site-status .state { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.site-status.down .state { color: var(--red); }
.site-status.up .state { color: var(--pine); }
.site-status.moved .state { color: var(--amber); }
.site-edit { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }
.card.site-edit { border-top: 1px solid var(--line); margin-top: 0; }
.site-edit .row input { flex: 1; }
.check-inline { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 0.84rem; font-weight: 400; color: var(--ink-2); cursor: pointer; }
.check-inline input { width: 15px; height: 15px; accent-color: var(--pine); flex-shrink: 0; }
.tl-pics { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tl-pics img { width: 96px; height: 72px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); display: block; }
.tl-pics a:hover img { border-color: var(--line-2); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.gallery a { display: block; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.gallery img { width: 100%; height: 140px; object-fit: cover; display: block; }
.timeline { list-style: none; padding: 0; margin: 0 0 16px; }
.timeline li { display: grid; grid-template-columns: 128px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .tl-when { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); padding-top: 2px; white-space: nowrap; }
.timeline .tl-who { font-size: 0.8rem; color: var(--muted); }
.timeline .tl-who strong { color: var(--ink); font-weight: 600; }
.timeline .body { white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; }
.ev-customer_message .tl-who strong { color: var(--amber); }
.ev-note .tl-who strong { color: var(--pine); }
@media (max-width: 640px) { .timeline li { grid-template-columns: 1fr; gap: 2px; } }
.mini-reply { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; white-space: pre-wrap; }
.mini-reply:last-child { border-bottom: 0; }
.mini-reply .tag { margin-bottom: 4px; }

/* ---------- telegram steps ---------- */
.step { display: grid; grid-template-columns: 30px 1fr; gap: 14px; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 0.82rem; font-weight: 500;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); margin-top: 16px;
}
.step.current .step-num { background: var(--ink); color: #fff; border-color: var(--ink); }
.step.done .step-num { background: var(--pine); color: #fff; border-color: var(--pine); }
.step.locked .card { opacity: 0.55; }
.step.locked .card form { pointer-events: none; }
.account-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- empty ---------- */
.empty { padding: 22px 20px; color: var(--muted); font-size: 0.92rem; }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.card.empty { border-style: dashed; background: transparent; }

/* ---------- strips (แถบตัวเลขแบ่งช่อง) ---------- */
.strip {
  --cols: 4;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 16px;
}
.strip-cell {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 12px;
  padding: 14px 16px; border-right: 1px solid var(--line); color: var(--ink); min-width: 0; position: relative;
}
.strip-cell:last-child { border-right: 0; }
a.strip-cell:hover { background: var(--surface-2); text-decoration: none; }
.strip-cell.active { background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--mint); }
.strip-ic {
  grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.cicon { display: block; transition: transform .2s ease; }
a.strip-cell:hover .cicon { transform: translateY(-2px) scale(1.08); }
.strip-ic.alive { background: var(--amber-tint); border-color: #f1d9a9; }
.strip-ic.alive .cicon { animation: nudge 2.6s ease-in-out infinite; }
.strip-ic.dim .cicon { filter: grayscale(1); opacity: 0.55; }
@keyframes nudge { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-10deg); } 84% { transform: rotate(8deg); } 92% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .strip-ic.alive .cicon { animation: none; } }
.strip-label { font-size: 0.8rem; color: var(--muted); align-self: end; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-value { font-family: var(--mono); font-size: 1.45rem; font-weight: 500; line-height: 1.2; align-self: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip-value.text { font-family: inherit; font-size: 0.98rem; font-weight: 600; padding-top: 3px; display: flex; align-items: center; gap: 6px; }
.strip.compact .strip-cell { padding: 11px 14px; }
.strip.compact .strip-ic { width: 38px; height: 38px; border-radius: 10px; }
.strip.compact .strip-value { font-size: 1.15rem; }
.tone-red { --tint: var(--red-tint); --tone: var(--red); }
.tone-amber { --tint: var(--amber-tint); --tone: var(--amber); }
.tone-blue { --tint: var(--blue-tint); --tone: var(--blue); }
.tone-green { --tint: var(--pine-tint); --tone: var(--pine); }
.tone-grey { --tint: var(--grey-tint); --tone: var(--ink-2); }
.strip-value.hot { color: var(--red); }
@media (max-width: 1100px) { .strip { --cols: 2 !important; } .strip-cell:nth-child(2n) { border-right: 0; } .strip-cell { border-bottom: 1px solid var(--line); } }
.section-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); margin: 4px 0 8px; display: flex; align-items: center; gap: 6px; }

/* ---------- panels (กล่องตารางมีหัว) ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 16px; }
.grid-2 > .panel { margin-bottom: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.panel-head h2 { font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.panel-head h2 .ic { color: var(--pine); }
.panel-head .count { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); font-weight: 400; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 0.82rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.panel-foot b { color: var(--ink); font-weight: 600; font-family: var(--mono); }

.grid-table th, .grid-table td { border-right: 1px solid var(--line); }
.grid-table th:last-child, .grid-table td:last-child { border-right: 0; }
.grid-table th { position: sticky; top: 0; z-index: 1; }
.grid-table td.center, .grid-table th.center { text-align: center; }
.grid-table td.shrink, .grid-table th.shrink { width: 1%; white-space: nowrap; }
.grid-table .empty-row td { text-align: center; padding: 30px 16px; color: var(--muted); border-right: 0; }
.grid-table .empty-row:hover { background: none; }
.empty-row .ic { display: block; margin: 0 auto 8px; color: var(--line-2); }
.empty-row strong { display: block; color: var(--ink-2); font-weight: 600; margin-bottom: 2px; }
.truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-table td.fill { width: 100%; max-width: 0; }
.zero { color: var(--line-2); }
.mini-bar { height: 6px; min-width: 80px; background: var(--grey-tint); border-radius: 3px; overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--pine); border-radius: 3px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 500; white-space: nowrap; }
.state.ok { color: var(--pine); }
.state.bad { color: var(--red); }
.state.off { color: var(--muted); }
.state.warn { color: var(--amber); }
.dot.wait { background: var(--amber); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.ai-cell { display: flex; align-items: center; gap: 6px; }
.icon-btn.sm { width: 26px; height: 26px; border: 1px solid var(--line-2); background: var(--surface); }
.icon-btn.del:hover { color: var(--red); border-color: #e3b1ab; background: var(--red-tint); }
.icon-btn.del:hover .cicon, button.danger:hover .cicon { transform: translateY(-1px) scale(1.1); }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--red-tint); border-bottom: 1px solid #f1c5bf; font-size: 0.88rem; }
.bulk-bar[hidden] { display: none; }
.bulk-bar span { margin-right: auto; }
.grid-table input[type="checkbox"] { width: 16px; height: 16px; padding: 0; accent-color: var(--pine); cursor: pointer; }
.delete-zone { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* ---------- หลอดโควตา ---------- */
.qbar { display: block; height: 8px; min-width: 120px; border-radius: 4px; background: var(--grey-tint); overflow: hidden; }
.qbar span { display: block; height: 100%; border-radius: 4px; background: #12a150; transition: width .4s ease; }
.qbar.mid span { background: #d9a400; }
.qbar.high span { background: #e8590c; }
.qbar.full span { background: var(--red); width: 100% !important; }
.quota-table .qbar { margin-bottom: 3px; }
.quota-table tr.is-current td { background: #f6fbf8; }
.limits-table { margin-top: 4px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.limits-table td, .limits-table th { padding: 6px 10px; }
.limits-table input { width: 90px; padding: 4px 8px; }
.quota-mini {
  display: block; margin: 0 4px 12px; padding: 10px 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.quota-mini:hover { text-decoration: none; border-color: var(--line-2); }
.quota-mini-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.quota-mini-head b { font-family: var(--mono); color: var(--ink); font-size: 0.85rem; font-weight: 500; }
.quota-mini .qbar { min-width: 0; height: 6px; }
.quota-mini-foot { display: block; margin-top: 5px; font-size: 0.72rem; color: var(--muted); }

/* ---------- toolbar / checklist ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { position: relative; flex: 1; min-width: 220px; }
.toolbar .search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 170px; }
.checklist td:first-child { width: 44px; text-align: center; }
.checklist .done { color: var(--pine); }
.checklist .todo { color: var(--line-2); }
.checklist tr.is-done .task { color: var(--muted); text-decoration: line-through; }
.progress { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; background: var(--surface); }

.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px 24px; position: relative; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: block; width: 200px; height: auto; margin-bottom: 34px; }
.login-card h1 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.login-sub { color: var(--muted); margin: 6px 0 26px; font-size: 0.92rem; }
.login-alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 16px; border-radius: var(--r);
  background: var(--red-tint); color: #8a1c13; font-size: 0.9rem; border: 1px solid #f1c5bf;
}
.login-alert .ic { margin-top: 3px; color: var(--red); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); }
.input-wrap { position: relative; display: block; }
.input-wrap > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap input { padding: 11px 44px 11px 40px; font-size: 0.98rem; border-radius: 8px; background: var(--surface-2); }
.input-wrap input:focus { background: var(--surface); }
.input-wrap:focus-within > .ic { color: var(--pine); }
.reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px;
  display: grid; place-items: center; padding: 0; border: 0; box-shadow: none; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer;
}
.reveal:hover { background: var(--grey-tint); color: var(--ink); }
.reveal .when-shown, .reveal.on .when-hidden { display: none; }
.reveal.on .when-shown { display: grid; }
.reveal .when-hidden { display: grid; }
.caps-hint { margin: -8px 0 0; font-size: 0.8rem; color: var(--amber); display: flex; align-items: center; gap: 5px; }
.caps-hint[hidden] { display: none; }
.login-submit {
  margin-top: 6px; width: 100%; padding: 12px 16px; border-radius: 8px; border: 0; cursor: pointer;
  font: inherit; font-size: 1rem; font-weight: 600; color: #fff; background: var(--pine);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  transition: background .15s, transform .05s;
}
.login-submit:hover { background: var(--pine-2); }
.login-submit:active { transform: translateY(1px); }
.login-submit:disabled { opacity: 0.7; cursor: progress; }
.login-submit:focus-visible { outline: none; box-shadow: var(--focus); }
.login-help { margin: 18px 0 0; font-size: 0.84rem; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .login-main { justify-content: flex-start; padding-top: 48px; }
  .login-logo { margin-bottom: 26px; }
}

/* ---------- คู่มือตอบคำถาม ---------- */
.guide-answer { white-space: pre-wrap; color: var(--ink-2); font-size: 0.86rem; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; }
.kw-cell { min-width: 200px; max-width: 280px; white-space: normal; }
.kw { display: inline-block; white-space: nowrap; font-size: 0.74rem; padding: 0 7px; border-radius: 99px; background: var(--grey-tint); color: var(--ink-2); margin: 3px 4px 0 0; }
.q-row td { vertical-align: middle; }
.guide-form textarea[name=answer] { min-height: 260px; font-size: 0.92rem; line-height: 1.6; }
.guide-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .guide-layout { grid-template-columns: 1fr; } }

/* ---------- popup ยืนยัน ---------- */
.cdialog {
  border: 0; padding: 0; border-radius: 14px; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(28, 27, 25, 0.28); overflow: hidden;
}
.cdialog::backdrop { background: rgba(28, 27, 25, 0.42); backdrop-filter: blur(2px); }
.cdialog[open] { animation: cd-pop .16s ease-out; }
.cdialog[open]::backdrop { animation: cd-fade .16s ease-out; }
@keyframes cd-pop { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes cd-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cdialog[open], .cdialog[open]::backdrop { animation: none; } }
.cd-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 22px 22px 18px; }
.cd-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--amber-tint); border: 1px solid #f1d9a9; }
.cdialog.danger .cd-ic { background: var(--red-tint); border-color: #f0c9c4; }
.cdialog.send .cd-ic { background: var(--pine-tint); border-color: #bfe9d3; }
.cd-title { margin: 3px 0 5px; font-size: 1.06rem; font-weight: 600; line-height: 1.4; word-break: break-word; }
.cd-msg { margin: 0; color: var(--ink-2); font-size: 0.9rem; line-height: 1.6; word-break: break-word; }
.cd-preview {
  grid-column: 1 / -1; white-space: pre-wrap; word-break: break-word; font-size: 0.86rem; line-height: 1.55;
  max-height: 220px; overflow: auto; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px 10px 10px 10px;
}
.cd-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px; background: var(--surface-2); border-top: 1px solid var(--line); }
.cd-actions button { min-width: 96px; }
button.danger-solid { background: var(--red); color: #fff; border-color: #96200f; }
button.danger-solid:hover { background: #96200f; border-color: #96200f; }

/* ---------- โควตาแยกตามคีย์ ---------- */
.qkey { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.qkey + .qkey { margin-top: 6px; }
.qkey .qbar { margin: 0; }
.qkey-state + .qkey-state { margin-top: 6px; }

/* ---------- popup ฟอร์ม (เพิ่ม/แก้ไขคู่มือ) ---------- */
.mdialog {
  border: 0; padding: 0; border-radius: 14px; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(28, 27, 25, 0.28); overflow: hidden;
}
.mdialog[open] { display: flex; flex-direction: column; animation: cd-pop .16s ease-out; }
.mdialog::backdrop { background: rgba(28, 27, 25, 0.42); backdrop-filter: blur(2px); }
.mdialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.md-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.md-head h3 { margin: 0; font-size: 1.08rem; font-weight: 600; }
.md-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--pine-tint); border: 1px solid #bfe9d3; }
.md-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.md-body textarea[name=answer] { min-height: 170px; font-size: 0.92rem; line-height: 1.6; }
.md-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.md-foot > span:first-child { margin-right: auto; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 10px; background: var(--surface-2); display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--pine); background: var(--pine-tint); }
.up-thumbs { display: contents; }
.up-thumb { position: relative; width: 104px; height: 78px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.up-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.up-thumb.removed img { opacity: .3; filter: grayscale(1); }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(28, 27, 25, .72); color: #fff; font-size: 15px; line-height: 22px; padding: 0; display: grid; place-items: center; }
.thumb-x:hover { background: var(--red); }
.thumb-tag { position: absolute; left: 4px; bottom: 4px; font-size: 0.68rem; padding: 0 6px; border-radius: 99px; background: rgba(255, 255, 255, .92); color: var(--ink-2); }
.drop-add { flex: 1; min-width: 200px; min-height: 78px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; color: var(--ink-2); font-size: 0.86rem; font-weight: 400; text-align: left; }
.drop-add:hover { background: var(--surface); }
.drop-add[hidden] { display: none; }
.drop-add input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.guide-pics { display: flex; align-items: center; gap: 4px; }
.guide-pics img { width: 40px; height: 30px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.guide-pics .more { font-size: 0.74rem; color: var(--muted); }
.reply-pics { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-pic { position: relative; width: 96px; height: 72px; border-radius: 8px; overflow: hidden; border: 2px solid var(--pine); cursor: pointer; display: block; }
.pick-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-pic input { position: absolute; opacity: 0; pointer-events: none; }
.pick-mark { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--pine); color: #fff; display: grid; place-items: center; }
.pick-pic:has(input:not(:checked)) { border-color: var(--line-2); }
.pick-pic:has(input:not(:checked)) img { opacity: .35; filter: grayscale(1); }
.pick-pic:has(input:not(:checked)) .pick-mark { background: var(--surface); color: var(--muted); border: 1px solid var(--line-2); }
.pick-pic:has(input:focus-visible) { box-shadow: var(--focus); }

/* โลโก้แทนตัวอักษรในวงกลม (ผู้ใช้ / บัญชี Telegram) */
img.avatar.logo { object-fit: cover; background: #fff; border: 1px solid var(--line); padding: 0; flex-shrink: 0; }

/* ---------- หน้าแชท (แบบแอปแชท) ---------- */
.chat-panel .panel-head { flex-wrap: wrap; gap: 8px 16px; }
.chat-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-2); }
.chat-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 3px; }
.lg-in { background: var(--surface); border: 1px solid var(--line-2); }
.lg-out { background: #d9f5e7; border: 1px solid #a9e3c5; }
.chatview {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 20px 20px; max-height: 72vh; overflow-y: auto;
  background: #efece4 radial-gradient(rgba(28, 27, 25, .045) 1px, transparent 1px) 0 0 / 16px 16px;
}
.day-sep { display: flex; justify-content: center; margin: 14px 0 8px; position: sticky; top: 0; z-index: 1; }
.day-sep span { font-size: 0.76rem; font-weight: 500; color: var(--ink-2); background: rgba(255, 255, 255, .92); border: 1px solid var(--line);
  padding: 2px 12px; border-radius: 99px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
.cm { display: flex; align-items: flex-end; gap: 8px; max-width: min(720px, 82%); }
.cm.first { margin-top: 8px; }
.cm.in { align-self: flex-start; }
.cm.out { align-self: flex-end; flex-direction: row-reverse; }
.cm-av, .cm-av-gap { width: 30px; height: 30px; flex-shrink: 0; }
.cm-av { border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 0.8rem; }
.cm-bubble {
  position: relative; min-width: 120px; padding: 6px 10px 5px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 1px 1px rgba(0, 0, 0, .04); word-break: break-word;
}
.cm.in.last .cm-bubble { border-bottom-left-radius: 4px; }
.cm.out .cm-bubble { background: #d9f5e7; border-color: #a9e3c5; }
.cm.out.last .cm-bubble { border-bottom-right-radius: 4px; }
.cm-name { font-size: 0.8rem; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cm.out .cm-name { color: var(--pine-2); }
.cm-user { font-weight: 400; color: var(--muted); }
.cm-badge { font-size: 0.68rem; font-weight: 500; padding: 0 6px; border-radius: 99px; background: rgba(11, 125, 82, .14); color: var(--pine-2); }
.cm-text { white-space: pre-wrap; font-size: 0.93rem; line-height: 1.5; }
.cm-text a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.cm-note { font-size: 0.84rem; font-style: italic; color: var(--muted); }
.cm-photo img { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: 8px; margin: 2px 0 4px; }
.cm-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 2px; font-size: 0.7rem; color: var(--muted); }
.cm-id { font-family: var(--mono); opacity: 0; transition: opacity .15s; }
.cm-bubble:hover .cm-id { opacity: 1; }
.cm-wait { color: var(--amber); font-weight: 500; }
.cm-wait::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 4px; vertical-align: 1px; }
.cm-bubble.sticker { background: transparent; border-style: dashed; box-shadow: none; }
@media (max-width: 640px) { .cm { max-width: 94%; } .chatview { padding: 12px; } }
