/* หลังร้าน v3: แชท LINE / ผลงานพนักงาน / นักพัฒนา (โหลดหลัง style.css และ ui.css) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.modal-warning .modal-icon { background: var(--warn-soft); color: var(--warn); }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--bad) !important; box-shadow: 0 0 0 3px var(--bad-soft) !important; }
.sub-h { margin: 6px 0 0; font-size: .95rem; color: var(--muted); }
.meter { display: block; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; width: var(--w, 0); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }

/* พร้อมรับแชท */
.online-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.online-btn i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.online-btn.is-on { color: var(--ok); border-color: rgba(61, 220, 151, .45); background: var(--ok-soft); }
.online-btn.is-on i { background: var(--ok); box-shadow: 0 0 0 4px rgba(61, 220, 151, .2); }

/* ป้ายชื่อพนักงาน / เวลารอ */
.who-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 3px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--primary)) 18%, transparent); color: var(--ink); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.who-chip i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--c, var(--primary)); color: #0b1030; font-style: normal; font-size: .7rem; font-weight: 700; }
.who-chip.is-none { padding: 2px 9px; background: var(--warn-soft); color: var(--warn); }
.who-chip.is-bot { padding: 2px 9px; background: var(--surface-3); color: var(--muted); }
.wait-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wait-pill .ic { width: 15px; height: 15px; }
.wait-pill.tone-ok { background: var(--ok-soft); color: var(--ok); }
.wait-pill.tone-warn { background: var(--warn-soft); color: var(--warn); }
.wait-pill.tone-bad { background: var(--bad); color: #fff; animation: pulse 1.6s infinite; }
.tiles-sm .tile { padding: 12px 14px; }
.tiles-sm .tile-value { font-size: 1.3rem; }

/* กล่องแชท 3 คอลัมน์ */
.desk { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(220px, 280px); gap: 14px; height: max(560px, calc(100vh - 290px)); }
.desk > .card { padding: 14px; display: flex; flex-direction: column; min-height: 0; }
.desk-list { gap: 10px; }
.desk-filters .chip-btn { padding: 5px 11px; font-size: .84rem; }
.desk-filters i { font-style: normal; opacity: .8; }
.chat-list { list-style: none; margin: 0 -6px; padding: 0; overflow-y: auto; flex: 1; display: grid; align-content: start; gap: 2px; }
.chat-item { width: 100%; display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 0; border-radius: 14px; background: none; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.is-active { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--primary-2); }
.chat-item.is-waiting .ci-last { color: var(--ink); font-weight: 500; }
.chat-item .avatar { width: 40px; height: 40px; color: #0b1030; }
.ci-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.ci-main b { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-main b small { color: var(--muted); font-weight: 400; }
.ci-last { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-side { display: grid; justify-items: end; gap: 6px; flex: none; }
.desk-main { position: relative; padding: 0 !important; overflow: hidden; }
.desk-empty { margin: auto; display: grid; justify-items: center; gap: 8px; padding: 24px; text-align: center; max-width: 340px; }
.desk-empty[hidden] { display: none; }
.desk-empty > .ic { width: 42px; height: 42px; color: var(--primary-2); }
.conv { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.conv[hidden] { display: none; }
.conv-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.conv-head .avatar { color: #0b1030; }
.conv-back { display: none; }
.conv-who { flex: 1; min-width: 0; display: grid; }
.conv-who small { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.conv-state { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; margin-right: auto; }
.conv-state .ic { width: 16px; height: 16px; }
.conv-transfer select { min-height: 34px; padding: 4px 34px 4px 10px; font-size: .85rem; width: auto; }
.conv-note-line { flex-basis: 100%; }
.conv-note-line .link { background: none; border: 0; padding: 0; color: var(--primary-2); font: inherit; cursor: pointer; text-decoration: underline; }
.conv-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.cm { display: grid; gap: 3px; max-width: 78%; }
.cm-in { align-self: flex-start; justify-items: start; }
.cm-out { align-self: flex-end; justify-items: end; }
.cm-who { font-size: .72rem; color: var(--muted); }
.cm-bubble { padding: 9px 13px; border-radius: 16px; background: var(--surface-3); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: .92rem; }
.cm-out .cm-bubble { background: linear-gradient(135deg, var(--primary), #5b8cff); color: #fff; }
.cm-out.is-bot .cm-bubble { background: var(--surface-2); color: var(--ink); border: 1px dashed var(--line); }
.cm-time { font-size: .68rem; color: var(--muted); }
.cm-sys { align-self: center; margin: 2px 0; padding: 3px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); font-size: .74rem; text-align: center; }
.cm-day { align-self: center; margin: 6px 0; font-size: .74rem; color: var(--muted); }
.cm-img { display: grid; gap: 4px; justify-items: center; padding: 8px; border-radius: 14px; background: var(--surface-3); font-size: .8rem; color: var(--muted); }
.cm-img img { width: 120px; border-radius: 10px; display: block; }
.cm-img .ic { width: 30px; height: 30px; }
.cm-card { display: grid; gap: 2px; min-width: 200px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--info); font-size: .82rem; }
.cm-card.tone-ok { border-left-color: var(--ok); }
.cm-card.tone-bad { border-left-color: var(--bad); }
.cm-card small { color: var(--muted); }
.cm-rated { display: block; margin-top: 4px; opacity: .85; }
.conv-quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 14px 0; scrollbar-width: none; }
.conv-quick::-webkit-scrollbar { display: none; }
.conv-quick .chip-btn { flex: none; font-size: .8rem; padding: 5px 11px; font-weight: 500; }
.conv-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 6px; }
.conv-input textarea { resize: none; min-height: 44px; max-height: 160px; line-height: 1.45; }
.conv-input .btn { flex: none; height: 44px; }
.conv-note { margin: 0; padding: 0 14px 10px; display: flex; align-items: center; gap: 6px; }
.conv-note .ic { width: 15px; height: 15px; }
.desk-info { overflow-y: auto; gap: 8px; }
.desk-info h3 { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
.info-dl { margin: 0; display: grid; gap: 6px; font-size: .86rem; }
.info-dl div { display: flex; justify-content: space-between; gap: 10px; }
.info-dl dt { color: var(--muted); }
.info-dl dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 500; }
.info-orders, .info-tickets { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.info-orders .row-link { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font: inherit; text-align: left; }
.info-orders .row-link:hover { border-color: var(--primary); }
.info-orders span { display: grid; font-size: .84rem; }
.info-orders small, .info-tickets small { color: var(--muted); font-size: .76rem; }
.info-tickets li { display: grid; padding: 8px 10px; border-radius: 12px; background: var(--bg-2); font-size: .84rem; }

/* ผลงานพนักงาน */
.team-head { margin: 0; align-items: center; }
.score { display: inline-grid; grid-template-columns: 30px 80px; align-items: center; gap: 8px; }
.score b { font-variant-numeric: tabular-nums; }
.score i { display: block; height: 8px; border-radius: 99px; background: var(--surface-3); position: relative; overflow: hidden; }
.score i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: inherit; background: var(--ok); }
.score.tone-warn i::after { background: var(--warn); }
.score.tone-bad i::after { background: var(--bad); }
.score.tone-ok b { color: var(--ok); }
.score.tone-warn b { color: var(--warn); }
.score.tone-bad b { color: var(--bad); }
.team-table td { white-space: nowrap; }
.perf-parts { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.perf-parts li { display: grid; gap: 6px; }
.pd-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .9rem; }
.pd-top span { color: var(--muted); }
.pay-dl { margin: 0; display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.pay-dl div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; font-size: .9rem; }
.pay-dl div + div { border-top: 1px solid var(--line); }
.pay-dl dt { color: var(--muted); }
.pay-dl dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.pay-dl .total-row { background: var(--surface-2); }
.pay-dl .total-row dt, .pay-dl .total-row dd { color: var(--ink); font-weight: 700; }
.tips { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--muted); font-size: .9rem; }
.bonus-edit { display: grid; gap: 8px; max-width: 460px; }
.bonus-head, .bonus-row { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 8px; align-items: center; }
.bonus-head { font-size: .82rem; color: var(--muted); font-weight: 600; }
.save-bar-inline { position: static; box-shadow: none; }
.staff-list .avatar { color: #0b1030; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.is-active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface); }

/* นักพัฒนา */
.dev-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.dev-steps b { color: var(--ink); }
.secret { position: relative; display: block; }
.secret input { padding-right: 50px !important; }
.secret .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; }
.copy-field { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: var(--radius-sm); border: 1.5px dashed var(--line); background: var(--bg-2); min-width: 0; }
.copy-field code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .84rem; }
.copy-field .icon-btn { width: 34px; height: 34px; flex: none; }
.quota { display: grid; gap: 8px; }
.quota-row { display: flex; justify-content: space-between; gap: 12px; }
.quota-row b { font-family: var(--font-head); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.hook-events { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 8px; }
.hook-events code { font-size: .8rem; color: var(--primary-2); }
.event-list, .api-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 520px; overflow-y: auto; }
.event-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font: inherit; text-align: left; }
.event-item:hover { border-color: var(--primary); }
.ev-main { flex: 1; min-width: 0; display: grid; }
.ev-main b { font-size: .86rem; font-weight: 600; }
.ev-main small { color: var(--muted); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-item > small { flex: none; font-size: .74rem; }
.api-list li { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 2px 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--bg-2); }
.api-list code { font-size: .82rem; overflow-wrap: anywhere; }
.api-list small { grid-column: 2; font-size: .78rem; }
.method { justify-self: start; padding: 2px 7px; border-radius: 6px; font-size: .7rem; font-weight: 700; font-family: ui-monospace, monospace; }
.m-get { background: var(--info-soft); color: var(--info); }
.m-post { background: var(--ok-soft); color: var(--ok); }
pre.code { margin: 0; padding: 12px 14px; border-radius: 12px; background: #070b24; color: #cfe3ff; font-size: .78rem; line-height: 1.55; overflow: auto; max-height: 340px; white-space: pre-wrap; overflow-wrap: anywhere; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

@media (max-width: 1180px) {
  .desk { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); height: auto; }
  .desk-list, .desk-main { height: max(560px, calc(100vh - 290px)); }
  .desk-info { grid-column: 1 / -1; }
}
@media (max-width: 899px) {
  .online-btn span { display: none; }
  .online-btn { padding: 0 12px; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .desk-list { height: auto; max-height: calc(100vh - 230px - var(--nav-h)); min-height: 360px; }
  .desk-main, .desk-info { display: none !important; }
  .desk.has-conv .desk-list { display: none; }
  .desk.has-conv .desk-main { display: flex !important; height: calc(100vh - 140px - var(--nav-h)); min-height: 420px; }
  .desk.has-conv .desk-info { display: flex !important; }
  .conv-back { display: grid; }
  .cm { max-width: 88%; }
  [data-panel="chat"] .tiles-sm { display: none; }
}
@media (max-width: 480px) {
  .conv-bar .btn { flex: 1; }
  .conv-transfer { flex: 1; }
  .conv-transfer select { width: 100%; }
  .event-item { flex-wrap: wrap; }
  .event-item > small { width: 100%; }
  .score { grid-template-columns: 30px 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .wait-pill.tone-bad { animation: none; }
}
.desk-list .search { flex: none; }
.desk-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: none; }
.desk-filters::-webkit-scrollbar { display: none; }
.desk-filters .chip-btn { flex: none; }
.hook-events .check span { display: block; }
[data-panel="dev"] .row-actions { flex-wrap: wrap; }
@media (max-width: 980px) { [data-panel="dev"] .grid-main { grid-template-columns: minmax(0, 1fr); } }
.info-orders .row-link { flex-wrap: wrap; }
.info-orders .status { white-space: normal; text-align: center; }
.desk-info { overflow-x: hidden; }
.live-note { margin: 0; padding: 10px 14px; border-radius: 12px; border: 1px dashed var(--warn); background: var(--warn-soft); color: var(--warn); font-size: .86rem; font-weight: 500; }
