:root {
  --bg: #f4f6f9; --panel: #ffffff; --text: #1d2433; --muted: #6b7486; --line: #e3e7ee;
  --accent: #1f6feb; --accent-soft: #e8f0fe; --ok: #1a9d55; --warn: #d98a00; --bad: #d1373b;
  --side: #121a2b; --side-text: #c9d1e3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141d; --panel: #171e2b; --text: #e6eaf2; --muted: #93a0b6; --line: #273145;
    --accent: #4c8dff; --accent-soft: #1c2a45; --side: #0a0f17; --side-text: #b9c3d8;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.brand strong { display: block; color: #fff; }
.brand span { font-size: 12px; opacity: .75; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 18px; }
.sidebar a { color: var(--side-text); text-decoration: none; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; display: flex; justify-content: space-between; }
.sidebar a:hover { background: rgba(255,255,255,.06); }
.sidebar a.active { background: var(--accent); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 10px 12px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.badge { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.badge:empty { display: none; }
main { flex: 1; padding: 28px 36px; max-width: 1100px; }
h1 { margin: 0 0 18px; font-size: 24px; }
h2 { margin: 0 0 12px; font-size: 17px; }
h3 { margin: 18px 0 8px; font-size: 15px; }
.page { display: none; }
.page.active { display: block; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 4px 0 10px; }
.label { color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat .num { font-size: 30px; font-weight: 600; }
.agent-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.agent-state { font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.big { width: 13px; height: 13px; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 4px rgba(26,157,85,.18); }
.dot.starting { background: var(--warn); }
.dot.problem, .dot.crashed { background: var(--bad); }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 16px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-outline { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 11px 22px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.center { justify-content: center; }
.hidden { display: none !important; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.checklist li:last-child { border: 0; }
.checklist .ok { color: var(--ok); } .checklist .no { color: var(--bad); }
.log { background: #0b0f16; color: #cfd7e6; padding: 12px; border-radius: 8px; max-height: 360px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.pair { display: flex; gap: 8px; }
.mode-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-pick.two { grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
.mode { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; gap: 10px; cursor: pointer; color: var(--text); margin: 0; }
.mode input { width: auto; margin-top: 4px; }
.mode small { display: block; color: var(--muted); }
.mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
details summary { cursor: pointer; color: var(--accent); margin-top: 6px; }
.secret-state { font-size: 12px; color: var(--ok); }
.save-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; justify-content: flex-end; align-items: center; gap: 16px; }
.table-card { padding: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--accent-soft); }
td select { padding: 4px 8px; margin: 0; width: auto; }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.pill { padding: 1px 9px; border-radius: 10px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.call-card { text-align: center; padding: 30px; }
.call-visual { width: 120px; height: 120px; margin: 0 auto 14px; position: relative; display: grid; place-items: center; }
.call-icon { width: 84px; height: 84px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 36px; display: grid; place-items: center; z-index: 1; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; }
.call-visual.speaking .ring { animation: pulse 1.1s infinite; }
.call-visual.listening .call-icon { background: var(--ok); }
.call-visual.thinking .call-icon { background: var(--warn); }
@keyframes pulse { 0% { transform: scale(.75); opacity: .9 } 100% { transform: scale(1.15); opacity: 0 } }
.call-status { font-size: 20px; font-weight: 600; }
.transcript { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 12px; unicode-bidi: plaintext; }
.msg.agent { background: var(--accent-soft); align-self: flex-start; }
.msg.caller { background: var(--bg); border: 1px solid var(--line); align-self: flex-end; }
.msg small { display: block; color: var(--muted); font-size: 11px; }
.faq-item { border-bottom: 1px solid var(--line); padding: 10px 0; display: flex; gap: 12px; justify-content: space-between; }
.faq-item .q { font-weight: 600; unicode-bidi: plaintext; }
.faq-item .a { color: var(--muted); unicode-bidi: plaintext; }
.faq-form { margin-top: 14px; display: grid; gap: 8px; }
.faq-form input, .faq-form textarea { margin: 0; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.dropzone input[type=file] { display: none; }
.login-screen { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(380px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-box h1 { margin: 12px 0 2px; }
.big-logo { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.login-error { color: var(--bad); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.login-box:not(.setup) .setup-only { display: none; }
.sidebar-user { padding: 10px 12px; font-size: 13px; border-top: 1px solid rgba(255,255,255,.08); margin-top: auto; }
.sidebar-user b { color: #fff; display: block; }
.sidebar-user a { padding: 0; display: inline; color: var(--side-text); text-decoration: underline; cursor: pointer; }
.sidebar-foot { margin-top: 0; }
.role-admin { background: #fde8e8; color: var(--bad); }
.role-supervisor { background: #fff4dc; color: var(--warn); }
.role-agent { background: var(--accent-soft); color: var(--accent); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; margin-bottom: 8px; }
label.check input { width: auto; margin: 0; }
.guide ol { padding-left: 20px; }
.guide li { margin-bottom: 10px; }
.guide code { background: var(--accent-soft); padding: 1px 6px; border-radius: 4px; }
.status-line { display: flex; gap: 10px; align-items: center; margin: 4px 0; }
input.secret { -webkit-text-security: disc; text-security: disc; }
.sugg { border-bottom: 1px solid var(--line); padding: 10px 0; }
.sugg .q { font-weight: 600; unicode-bidi: plaintext; }
.sugg textarea { margin: 6px 0; }
.qa { font-weight: 600; }
.qa.good { color: var(--ok); } .qa.mid { color: var(--warn); } .qa.bad { color: var(--bad); }
td.summary { max-width: 340px; font-size: 13px; unicode-bidi: plaintext; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .num { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.hero { background: var(--accent); border-color: var(--accent); color: #fff; }
.kpi.hero .label, .kpi.hero .sub { color: rgba(255,255,255,.85); }
.perf-grid { gap: 16px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; padding-top: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
.bar { flex: 0 1 34px; display: flex; flex-direction: column-reverse; min-width: 14px; position: relative; }
.bar span:first-child { border-radius: 0 0 2px 2px; } .bar span:last-child { border-radius: 3px 3px 0 0; }
.bar span { display: block; }
.bar .ai, .sw.ai { background: var(--accent); }
.bar .human, .sw.human { background: var(--warn); }
.bar small { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 16px; margin-top: 26px; font-size: 13px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.hbar { display: grid; grid-template-columns: 90px 1fr 40px; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.hbar .track { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); }
.hbar .fill.positive { background: var(--ok); } .hbar .fill.negative { background: var(--bad); } .hbar .fill.neutral { background: var(--muted); }
@media (max-width: 800px) { .kpis { grid-template-columns: 1fr 1fr; } }
.copilot { border-color: var(--accent); }
.copilot .ctx { font-size: 14px; margin: 4px 0; }
.copilot .answer { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin-top: 10px; unicode-bidi: plaintext; }
.status-pick { display: flex; align-items: center; gap: 8px; padding: 6px 12px 0; }
.status-pick select { margin: 0; padding: 4px 8px; background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.15); font-size: 13px; }
.status-pick option { color: #000; }
.dot.available { background: var(--ok); } .dot.busy { background: var(--accent); } .dot.wrapup { background: var(--warn); }
.dot.break { background: #a77bdb; } .dot.offline { background: var(--muted); }
.hours-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; margin-bottom: 12px; }
.hours-row { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.hours-row input[type=time] { width: auto; margin: 0; padding: 4px 6px; }
.hours-row label { margin: 0; display: flex; gap: 4px; align-items: center; color: var(--text); width: 64px; }
.hours-row label input { width: auto; margin: 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 56px); gap: 8px; justify-content: center; margin-top: 16px; }
.keypad button { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 18px; cursor: pointer; }
.keypad button:active { background: var(--accent-soft); }
.wallboard { background: var(--bg); }
.wallboard:fullscreen { padding: 24px; overflow: auto; }
.wb-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.wb-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-align: center; }
.wb-tile .num { font-size: 44px; font-weight: 700; line-height: 1.1; }
.wb-tile.alert { border-color: var(--bad); background: #fde8e8; color: var(--bad); }
.wb-tile.good .num { color: var(--ok); }
.wb-agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.wb-agent { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
@media (max-width: 800px) { .wb-tiles { grid-template-columns: 1fr 1fr; } }
.kyc-card { display: grid; grid-template-columns: 260px 1fr; gap: 18px; }
.kyc-card img { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.kyc-card .noimg { height: 160px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 10px; }
.kyc-checks { list-style: none; padding: 0; margin: 8px 0; }
.kyc-checks li { padding: 3px 0; }
.verdict { font-weight: 700; }
.verdict.match { color: var(--ok); } .verdict.mismatch { color: var(--bad); } .verdict.unclear { color: var(--warn); }
@media (max-width: 800px) { .kyc-card { grid-template-columns: 1fr; } }
.audit-row { font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.dropzone.small { padding: 16px; justify-content: center; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.rules-box { background: var(--accent-soft); border-radius: 10px; padding: 12px 16px; margin: 4px 0 14px; font-size: 14px; }
.rules-box h3 { margin: 0 0 6px; }
.rules-box ul { margin: 6px 0; padding-left: 20px; }
.rules-box .disclaimer { color: var(--muted); font-size: 12px; margin-top: 8px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.days label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 0; color: var(--text); cursor: pointer; }
.days label.off { opacity: .45; cursor: not-allowed; }
.days input { width: auto; margin: 0; }
.pill.running { background: #e2f6ea; color: var(--ok); }
.pill.paused, .pill.draft { background: var(--bg); color: var(--muted); }
.pill.finished { background: var(--accent-soft); color: var(--accent); }
.pill.calling { background: #fff4dc; color: var(--warn); }
.pill.done { background: #e2f6ea; color: var(--ok); }
.pill.failed, .pill.skipped { background: #fde8e8; color: var(--bad); }
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; min-width: 120px; }
.progress span { display: block; height: 100%; background: var(--ok); }
.ringer { position: fixed; right: 20px; bottom: 20px; z-index: 30; background: var(--panel); border: 2px solid var(--ok); border-radius: 14px; padding: 14px 16px; display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.ringer-icon { width: 46px; height: 46px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 22px; animation: shake .6s infinite; }
.ringer-text { display: flex; flex-direction: column; }
.handover-pop { bottom: 110px; border-color: var(--warn); }
.handover-pop .ringer-icon { background: var(--warn); }
.handover-pop.urgent { border-color: var(--bad); }
.handover-pop.urgent .ringer-icon { background: var(--bad); }
.live-card { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.live-card .lines { font-size: 13px; color: var(--muted); margin-top: 6px; max-width: 640px; }
.live-card .lines div { unicode-bidi: plaintext; }
.live-card.urgent { border-color: var(--bad); }
.pill.urgent { background: #fde8e8; color: var(--bad); }
@keyframes shake { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-12deg) } 75% { transform: rotate(12deg) } }
.auto-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.auto-head h2 { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; color: var(--text); font-size: 14px; }
.switch input { display: none; }
.slider { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background .15s; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::after { left: 21px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.doc-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { margin: 0; }
.result { border-left: 3px solid var(--accent); padding: 6px 12px; margin-top: 10px; white-space: pre-wrap; unicode-bidi: plaintext; font-size: 14px; }
.result small { color: var(--muted); display: block; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal-box { background: var(--panel); border-radius: 14px; width: min(720px, 100%); max-height: 86vh; overflow: auto; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--side); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 20; max-width: 90vw; }
.toast.error { background: var(--bad); }
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .brand, .sidebar-foot { display: none; }
  main { padding: 16px; }
  .stats, .grid2, .mode-pick { grid-template-columns: 1fr 1fr; }
}

/* ---------- chats inbox ---------- */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.chat-list { padding: 6px; max-height: 70vh; overflow-y: auto; }
.chat-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--line); }
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.chat-item .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-view { display: flex; flex-direction: column; height: 70vh; padding: 0; overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.cmsg { max-width: 75%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.cmsg small { display: block; font-size: 11px; color: var(--muted); }
.cmsg.customer { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.cmsg.ai { align-self: flex-end; background: var(--accent-soft); }
.cmsg.agent { align-self: flex-end; background: #e2f6ea; color: #1d2433; }
.cmsg.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; padding: 2px; }
.chat-reply { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-reply textarea { flex: 1; margin: 0; height: 44px; resize: vertical; }
.pill.ai { background: var(--accent-soft); color: var(--accent); }
.pill.waiting { background: #fde8e8; color: var(--bad); }
.pill.agent { background: #e2f6ea; color: var(--ok); }
.pill.closed { background: var(--bg); color: var(--muted); }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } }

/* ---------- workforce ---------- */
.wfm-grid th, .wfm-grid td { vertical-align: top; min-width: 120px; }
.shift-chip { display: block; background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 4px 8px; margin: 3px 0; font-size: 12px; cursor: pointer; }
.shift-chip:hover { outline: 2px solid var(--accent); }
.gap-neg { color: var(--bad); font-weight: 600; }
.gap-pos { color: var(--ok); }
.abar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 80px; }
.abar > span { display: block; height: 100%; background: var(--ok); }
.abar.mid > span { background: var(--warn); }
.abar.low > span { background: var(--bad); }
