:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #161a21; --muted: #6b7280; --line: #e4e7ec; --hover: #f1f3f6;
  --primary: #2b4acb; --primary-ink: #fff; --side: #111522; --side-ink: #c9cfdc; --side-on: #ffffff;
  --note: #fff8db; --note-line: #f1dd8a; --bad: #c62828; --warn: #b26a00; --ok: #1b7f3a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: 12px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: var(--side); }
.card { width: 360px; background: var(--panel); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 12px; }
.brandmark { font-weight: 800; font-size: 22px; letter-spacing: .5px; }
.brandmark.small { font-size: 17px; color: var(--side-on); padding: 4px 10px 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
.primary { background: var(--primary); color: var(--primary-ink); border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 600; }
.primary:disabled { opacity: .5; }
.ghost { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.ghost:hover { background: var(--hover); }
.danger { color: var(--bad); }
.error { background: #fdecec; color: var(--bad); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.qr { display: grid; place-items: center; } .qr svg { width: 200px; height: 200px; }
code { background: var(--hover); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 220px 340px 1fr 320px; height: 100%; }
.app.pagemode { grid-template-columns: 220px 1fr; }
.app.pagemode .list, .app.pagemode .conv, .app.pagemode .info { display: none; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.navlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; opacity: .55; padding: 14px 10px 4px; }
.navgroup { display: flex; flex-direction: column; gap: 1px; }
.nav { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 7px 10px; border-radius: 7px; }
.nav:hover { background: rgba(255,255,255,.06); }
.nav.on { background: rgba(255,255,255,.12); color: var(--side-on); }
.nav .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.14); border-radius: 9px; padding: 0 7px; min-width: 22px; text-align: center; }
.nav .count.hot { background: #e5484d; color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; border: 2px solid; }
.me { margin-top: auto; padding: 12px 10px 4px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.me button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; opacity: .8; }

.list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.listhead { padding: 10px; border-bottom: 1px solid var(--line); }
.listhead input { width: 100%; }
.items { overflow-y: auto; flex: 1; }
.item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
.item:hover { background: var(--hover); }
.item.on { background: #eef2ff; box-shadow: inset 3px 0 var(--primary); }
.item .row1 { display: flex; align-items: center; gap: 6px; }
.item .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.item .last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 3px 0; }
.item .row3 { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.brandpill { border: 2px solid; }
.chan { background: var(--hover); color: #374151; }
.pri-urgent { background: #fde2e2; color: var(--bad); } .pri-high { background: #fff1d6; color: var(--warn); }
.mode-waiting { background: #fde2e2; color: var(--bad); } .mode-agent { background: #e3f4e8; color: var(--ok); } .mode-bot { background: #ece9fe; color: #5b3fd1; } .mode-closed { background: var(--hover); color: var(--muted); }
.risk { background: #3b0d0d; color: #ffd4d4; }
.emptylist { padding: 30px; text-align: center; color: var(--muted); }

.conv { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.empty { margin: auto; color: var(--muted); }
#conv { display: flex; flex-direction: column; height: 100%; }
.convhead { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.who { flex: 1; min-width: 0; } .cname { font-weight: 700; font-size: 16px; } .cmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.m { max-width: 72%; display: flex; flex-direction: column; }
.m .by { font-size: 11px; color: var(--muted); margin: 0 4px 2px; }
.m .b { padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; background: var(--panel); border: 1px solid var(--line); }
.m.contact { align-self: flex-start; }
.m .orig { margin-top: 6px; padding-top: 6px; border-top: 1px dashed rgba(0,0,0,.15); font-size: 12px; color: var(--muted); }
.m.bot, .m.agent { align-self: flex-end; align-items: flex-end; }
.m.bot .b { background: #ece9fe; border-color: #ddd6fe; }
.m.agent .b { background: #e6edff; border-color: #c9d6ff; }
.m.note { align-self: flex-end; align-items: flex-end; } .m.note .b { background: var(--note); border-color: var(--note-line); }
.m.system { align-self: center; max-width: 90%; } .m.system .b { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 2px; }
.m img { display: block; max-width: 260px; max-height: 300px; border-radius: 8px; margin-top: 4px; cursor: zoom-in; }
.m .btns { font-size: 11px; color: var(--muted); margin-top: 2px; }
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.tabs { display: flex; gap: 6px; align-items: center; }
.tab { background: none; border: 0; padding: 4px 10px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.tab.on { background: var(--hover); color: var(--ink); }
.tabs select { margin-left: auto; max-width: 220px; padding: 4px 8px; }
.composer.note textarea { background: var(--note); border-color: var(--note-line); }
textarea { resize: vertical; min-height: 64px; }
.send { display: flex; justify-content: space-between; align-items: center; }

.info { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 4px 0; }
.box { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.box h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 4px 8px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.result { margin-top: 8px; font-size: 12px; background: var(--hover); border-radius: 8px; padding: 8px; }
.result table { width: 100%; border-collapse: collapse; } .result td { padding: 2px 4px; border-bottom: 1px solid var(--line); }
.field { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 13px; }
.field select, .field input { padding: 5px 8px; }
.flag { background: #fdecec; color: var(--bad); border-radius: 6px; padding: 6px 8px; font-size: 12px; margin-bottom: 4px; }
.hist { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }

/* ---------- Pages ---------- */
.page { overflow-y: auto; padding: 24px 28px; }
.page h1 { margin: 0 0 16px; font-size: 22px; }
.page h2 { font-size: 15px; margin: 24px 0 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat .v { font-size: 26px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 12px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.tbl th { background: var(--hover); font-size: 12px; color: var(--muted); font-weight: 600; }
.bar { height: 10px; border-radius: 5px; background: var(--primary); }
.form { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.form .full { grid-column: 1 / -1; }
.form textarea { min-height: 160px; font-family: ui-monospace, monospace; font-size: 12px; }
.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; vertical-align: middle; border: 1px solid var(--line); }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--side); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 10; max-width: 90vw; }
.toast.bad { background: var(--bad); }

@media (max-width: 1280px) { .app { grid-template-columns: 200px 300px 1fr 280px; } }
.shade { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.dialog { background: #fff; color: #111; border-radius: 12px; padding: 20px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.dialog h3 { margin: 0; }
.dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
.pwwrap { position: relative; display: block; width: 100%; }
.pwwrap input { width: 100%; padding-right: 64px; box-sizing: border-box; }
.pwwrap .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 600; padding: 4px 8px; cursor: pointer; }
input[type=color] { width: 64px; height: 36px; padding: 2px; cursor: pointer; }
.dialog.wide { width: min(900px, 94vw); max-height: 88vh; }
.kbtext { width: 100%; min-height: 50vh; font-family: ui-monospace, monospace; font-size: 12px; margin-top: 8px; box-sizing: border-box; }
.kbadd { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.kbadd .form { margin-bottom: 0; grid-template-columns: 1fr; align-content: start; }
.answer { background: var(--hover); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.tbl tr.off td { opacity: .5; }
.clip { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.nowrap .ghost { margin: 0 4px 4px 0; }
.pill.bad, .small.bad { color: var(--bad); }
.pill.bad { background: #fde8e8; white-space: normal; }
.form textarea.short { min-height: 56px; font-family: inherit; font-size: 14px; }
.facebig { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: var(--hover); display: grid; place-items: center; font-weight: 700; font-size: 22px; flex: none; }
.facebig img { width: 100%; height: 100%; object-fit: cover; }

/* =====================================================================
   Look & feel v2: Inter font, light and dark themes, Matrix login.
   ===================================================================== */
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/static/desk/fonts/inter-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/static/desk/fonts/inter-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f9fafb; --ink: #0f172a; --muted: #64748b; --line: #e3e8ef; --hover: #f1f5f9;
  --input: #ffffff; --sel: #ecfdf5; --chip: #f1f5f9; --chip-ink: #334155;
  --primary: #047857; --primary-ink: #ffffff; --primary-soft: #d1fae5;
  --side: #0b1220; --side-ink: #b8c4d6; --side-on: #ffffff; --side-hover: rgba(255,255,255,.06); --side-sel: rgba(16,185,129,.16);
  --note: #fff8db; --note-line: #f1dd8a; --bad: #c62828; --warn: #b26a00; --ok: #15803d;
  --bad-bg: #fdecec; --warn-bg: #fff1d6; --ok-bg: #e3f4e8; --bot-bg: #f1edff; --bot-line: #ddd6fe; --agent-bg: #e8f0ff; --agent-line: #c9d6ff;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e13; --panel: #11161d; --panel-2: #0d1218; --ink: #e6edf3; --muted: #8b98a9; --line: #212a35; --hover: #18202a;
  --input: #0d1218; --sel: #0e2a1f; --chip: #1a222c; --chip-ink: #c5d0dc;
  --primary: #22c55e; --primary-ink: #04150b; --primary-soft: #0f2e1d;
  --side: #06090d; --side-ink: #9aa9bb; --side-on: #ffffff; --side-hover: rgba(255,255,255,.05); --side-sel: rgba(34,197,94,.16);
  --note: #2a2512; --note-line: #574a1a; --bad: #ff6b6b; --warn: #f0b04a; --ok: #4ade80;
  --bad-bg: #3a1517; --warn-bg: #3a2b10; --ok-bg: #11301d; --bot-bg: #221c3a; --bot-line: #34295c; --agent-bg: #142339; --agent-line: #213a5e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
}

body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Bengali', 'Noto Sans Tamil', 'Noto Sans Telugu', sans-serif;
  font-size: 14px; letter-spacing: -0.006em; -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 16px; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; margin: 22px 0 10px; }
input, select, textarea { background: var(--input); color: var(--ink); border-color: var(--line); border-radius: 9px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.primary { border-radius: 9px; box-shadow: 0 1px 0 rgba(0,0,0,.05); transition: filter .15s; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); border-radius: 9px; }
.error { background: var(--bad-bg); }
.tbl, .form { box-shadow: var(--shadow); border-color: var(--line); }
.tbl { background: var(--panel); }
.tbl th { background: var(--panel-2); }

/* Brand mark */
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.01em; }
.logo { width: 26px; height: 26px; border-radius: 8px; flex: none; background:
  repeating-linear-gradient(90deg, transparent 0 4px, rgba(0,0,0,.25) 4px 5px), linear-gradient(160deg, #34d399, #047857); box-shadow: 0 0 12px rgba(52,211,153,.45); }
.brandmark.small { font-size: 16px; padding: 6px 10px 14px; }

/* Sidebar */
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px; border-right: 1px solid rgba(255,255,255,.04); }
.nav { padding: 8px 10px; border-radius: 9px; font-weight: 500; transition: background .12s; }
.nav:hover { background: var(--side-hover); }
.nav.on { background: var(--side-sel); color: var(--side-on); box-shadow: inset 3px 0 #34d399; }
.navlabel { font-weight: 600; font-size: 10.5px; letter-spacing: .08em; }
.me { border-top-color: rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 4px; }
.mebox { display: flex; align-items: center; gap: 10px; }
.initials { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(160deg, #34d399, #047857); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.melinks { display: flex; gap: 12px; margin-top: 6px; }

/* Inbox list and chat */
.list { background: var(--panel); border-color: var(--line); }
.listhead { border-color: var(--line); }
.item { border-color: var(--line); padding: 12px 14px; }
.item.on { background: var(--sel); box-shadow: inset 3px 0 var(--primary); }
.chan { background: var(--chip); color: var(--chip-ink); }
.pri-urgent, .mode-waiting { background: var(--bad-bg); color: var(--bad); }
.pri-high { background: var(--warn-bg); color: var(--warn); }
.mode-agent { background: var(--ok-bg); color: var(--ok); }
.mode-bot { background: var(--bot-bg); color: #8b6cf6; }
.m .b { background: var(--panel); border-color: var(--line); }
.m .orig { border-top-color: var(--line); }
.m.bot .b { background: var(--bot-bg); border-color: var(--bot-line); }
.m.agent .b { background: var(--agent-bg); border-color: var(--agent-line); }
.flag, .pill.bad { background: var(--bad-bg); }
.dialog { background: var(--panel); color: var(--ink); }
.toast { background: #0b1220; color: #fff; }
[data-theme="dark"] .toast { background: #e6edf3; color: #0b1220; }
.answer { background: var(--panel-2); border: 1px solid var(--line); }

/* Login over the Matrix image */
.login { position: relative; background: #000 url(/static/desk/login-bg.jpg) center / cover no-repeat; overflow: hidden; }
.login::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(0,0,0,.35) 0%, rgba(0,0,0,.78) 70%); }
.login .card { position: relative; width: 380px; background: rgba(10,14,19,.72); color: #e6edf3; border: 1px solid rgba(52,211,153,.25);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 40px rgba(16,185,129,.12); }
.login .card .brandmark { font-size: 24px; color: #fff; }
.login .card label, .login .card .muted { color: #a9b6c6; }
.login .card input { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.14); color: #fff; }
.login .card input:focus { border-color: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.2); }
.login .card .primary { background: #10b981; color: #03130b; font-weight: 700; padding: 11px 16px; }
.login .card .eye { color: #34d399; }
.login .card code { background: rgba(255,255,255,.08); color: #d1fae5; }

/* Settings */
.settings { display: grid; grid-template-columns: 210px 1fr; gap: 24px; align-items: start; }
.setnav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); }
.setnav button { text-align: left; border: 0; background: none; color: var(--ink); padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.setnav button:hover { background: var(--hover); }
.setnav button.on { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.setnav .sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 12px 4px; font-weight: 600; }
.setbody { min-width: 0; }
.themes { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 12px; max-width: 560px; }
.themes button { border: 2px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px; padding: 10px; text-align: left; font-weight: 600; }
.themes button.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.swatchbox { height: 64px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--line); }
.sw-light { background: linear-gradient(90deg, #0b1220 0 22%, #f4f6f9 22%); }
.sw-dark { background: linear-gradient(90deg, #06090d 0 22%, #11161d 22%); }
.sw-auto { background: linear-gradient(135deg, #f4f6f9 0 50%, #11161d 50%); }
.convhead { flex-wrap: wrap; row-gap: 8px; }
.convhead .who { flex: 1 1 240px; min-width: 0; }
.convhead .cname { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.convhead .actions { display: flex; flex-wrap: wrap; gap: 6px; }
#pageNav { padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,.07); }
/* Availability and assignment */
.statusbox { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.statusbox select { flex: 1; background: rgba(255,255,255,.06); color: var(--side-on); border-color: rgba(255,255,255,.12); padding: 6px 8px; }
.statusbox select option { color: #0f172a; }
.sdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; vertical-align: middle; }
.s-online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); } .s-away { background: #f59e0b; } .s-offline { background: #6b7280; }
.modecards { display: grid; grid-template-columns: repeat(3, minmax(200px, 1fr)); gap: 12px; }
.modecard { text-align: left; border: 2px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.modecard .mt { font-weight: 700; font-size: 15px; }
.modecard.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.modecard:disabled { cursor: default; opacity: .9; }
.loadbar { width: 120px; height: 6px; border-radius: 4px; background: var(--hover); overflow: hidden; margin-bottom: 3px; }
.loadbar i { display: block; height: 100%; background: var(--primary); }
/* Live monitor */
.livehead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.livehead h1 { margin: 0; }
.livepulse { width: 10px; height: 10px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); } 70% { box-shadow: 0 0 0 10px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.cards .stat.hot { border-color: #f59e0b; } .cards .stat.hot .v { color: var(--warn); }
.cards { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); margin-bottom: 8px; }
.tbl.live td { vertical-align: middle; }
.tbl.live tr.dim td { opacity: .6; }
.initials.sm { width: 30px; height: 30px; font-size: 11px; }
.loadbar.full i { background: var(--warn); }
.livechats { display: flex; flex-direction: column; gap: 4px; }
.lchat { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 4px 8px; font-size: 12px; text-align: left; }
.lchat:hover { border-color: var(--primary); }
.lchat .pill { font-size: 10px; }
.lchat.amber { border-color: #f59e0b; background: var(--warn-bg); }
.lchat.red { border-color: var(--bad); background: var(--bad-bg); }
.warnink { color: var(--warn); }
.shotprev { max-width: 220px; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); }
/* Dashboard */
:root, [data-theme="light"], [data-theme="dark"] { --c-today: #059669; --c-yday: #6366f1; }
.stat.click { text-align: left; cursor: pointer; color: var(--ink); }
.stat.click:hover { border-color: var(--primary); }
.stat.bad { border-color: var(--bad); } .stat.bad .v { color: var(--bad); }
.dashrow { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-top: 14px; }
.dashrow.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card2 { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.cardh { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-weight: 650; margin-bottom: 10px; }
.kv { padding: 8px 0; border-bottom: 1px solid var(--line); } .kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: 12px; } .kv .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.chg { font-size: 11px; font-weight: 600; color: var(--muted); } .chg.up { color: var(--ok); } .chg.down { color: var(--bad); }
.chartbox { position: relative; }
.chartbox svg { width: 100%; height: auto; display: block; }
.chartbox .grid { stroke: var(--line); stroke-width: 1; }
.chartbox .axis { fill: var(--muted); font-size: 11px; }
.chartbox .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chartbox .ln.today { stroke: var(--c-today); } .chartbox .ln.yday { stroke: var(--c-yday); stroke-dasharray: 5 4; }
.chartbox .endlab { font-size: 11px; font-weight: 600; fill: var(--ink); }
.chartbox .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chartbox .dot { stroke: var(--panel); stroke-width: 2; } .chartbox .dot.today { fill: var(--c-today); } .chartbox .dot.yday { fill: var(--c-yday); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.sw { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.sw.today { border-color: var(--c-today); } .sw.yday { border-color: var(--c-yday); } .sw.yday.dash { border-top-style: dashed; }
.charttip { position: absolute; top: 24px; transform: translateX(-50%); background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; padding: 6px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; }
.csat { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 8px; }
.csat .emo { font-size: 30px; } .csat .v { font-size: 20px; font-weight: 700; }
.okink { color: var(--ok); } .badink { color: var(--bad); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.barrow { display: grid; grid-template-columns: 90px 1fr 32px; align-items: center; gap: 8px; font-size: 13px; }
.barrow .bar { height: 10px; background: var(--hover); border-radius: 5px; overflow: hidden; } .barrow .bar i { display: block; height: 100%; border-radius: 5px; }
.todos { display: flex; flex-direction: column; gap: 2px; }
.todo { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; padding: 5px 2px; border-bottom: 1px solid var(--line); }
.todo span { flex: 1; } .todo.done span { text-decoration: line-through; color: var(--muted); }
.todo .x { border: 0; background: none; color: var(--muted); }
.card2 .toolbar input { flex: 1; }
@media (max-width: 1100px) { .dashrow { grid-template-columns: 1fr; } }
.kv { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Tickets: list ---------- */
.views { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip.on { border-color: var(--ok); background: var(--ok-bg); color: var(--ink); font-weight: 600; }
.chip.add { border-style: dashed; color: var(--muted); }
.chip.mine { padding: 0 4px 0 0; }
.chip.mine button { border: 0; background: none; color: inherit; font: inherit; padding: 5px 4px 5px 12px; cursor: pointer; }
.chip.mine button.x { padding: 5px 6px; color: var(--muted); }
.toolbar.filters { flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.bulkbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--ok); background: var(--ok-bg); border-radius: 10px; }
.bulkbar[hidden] { display: none; }
.tbl.tickets tr.picked td { background: var(--ok-bg); }
.tbl.tickets a.subj { color: var(--ink); font-weight: 600; text-decoration: none; }
.tbl.tickets a.subj:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }
.pill.late { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.st-open { background: var(--agent-bg); } .st-pending { background: var(--warn-bg); } .st-resolved, .st-closed { background: var(--ok-bg); }
.pager { margin-top: 10px; }
.pager .toolbar { justify-content: flex-end; }

/* ---------- Tickets: one ticket ---------- */
.tkhead { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tkref { font-weight: 700; font-size: 15px; }
.tksubj { margin: 4px 0 2px; }
.tksubj.editable { cursor: text; }
.tksubj.editable:hover { text-decoration: underline dotted; }
.tkgrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; margin-top: 14px; align-items: start; }
@media (max-width: 1100px) { .tkgrid { grid-template-columns: 1fr; } }
.tkside .box, .tkmain .box { margin-bottom: 12px; }
.boxhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.boxhead h3 { margin: 0; }
.tksum { white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; margin-bottom: 6px; }
.tkmsgs { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow: auto; margin-top: 8px; }
.tkmsg { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; white-space: pre-wrap; }
.tkmsg.s-bot { background: var(--bot-bg); border-color: var(--bot-line); }
.tkmsg.s-agent { background: var(--agent-bg); border-color: var(--agent-line); }
.tkmsg.s-note { background: var(--warn-bg); }
.tkmsg.s-system { background: transparent; border-style: dashed; color: var(--muted); }
.tlrow { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.tlrow:last-child { border-bottom: 0; }
.tldot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 6px; flex: none; }
.kv dd.bad { color: var(--bad); font-weight: 600; } .kv dd.good { color: var(--ok); font-weight: 600; }

/* ---------- Tags ---------- */
.tag { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; padding: 0 7px; border-radius: 999px; background: var(--hover); border: 1px solid var(--line); font-size: 11.5px; color: var(--ink); line-height: 18px; }
.tag.big { margin: 0 6px 6px 0; font-size: 12.5px; padding: 2px 6px 2px 9px; }
.tag button { border: 0; background: none; color: var(--muted); padding: 0 2px; cursor: pointer; font-size: 14px; line-height: 1; }
.tagrow { display: flex; flex-wrap: wrap; align-items: center; }
.tagrow > .tag:first-child { margin-left: 0; }

/* ---------- Top bar: search, + New ticket, bell ---------- */
.app { grid-template-rows: 54px minmax(0, 1fr); }
.side { grid-row: 1 / 3; grid-column: 1; }
.topbar { grid-column: 2 / -1; grid-row: 1; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.list, .conv, .info, .page { grid-row: 2; min-height: 0; }
.tbsearch { position: relative; flex: 1; max-width: 620px; }
.tbsearch input { width: 100%; padding: 8px 12px 8px 32px; border-radius: 10px; background: var(--bg); }
.tbmag { position: absolute; left: 11px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 16px; pointer-events: none; }
.tbdrop, .bellpanel { position: absolute; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.25); z-index: 50; overflow-y: auto; max-height: 70vh; }
.tbdrop { left: 0; right: 0; padding: 6px; }
.tbdrop[hidden], .bellpanel[hidden], .bell .badge[hidden] { display: none; }
.tbhead { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px 4px; }
.tbitem, .notif { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--ink); cursor: pointer; font: inherit; }
.tbitem:hover, .notif:hover { background: var(--hover); }
.tbitem.more { color: var(--primary); font-weight: 600; justify-content: center; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; }
.tbicon { flex: none; width: 20px; text-align: center; }
.tbtext { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tbtext > span { overflow: hidden; text-overflow: ellipsis; }
.tbempty { padding: 14px 12px; color: var(--muted); font-size: 13px; }
.tbright { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tbnew { padding: 7px 14px; }
.bellbox { position: relative; }
.bell { position: relative; background: none; border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 36px; font-size: 16px; cursor: pointer; }
.bell .badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.bellpanel { right: 0; width: 380px; padding: 6px; }
.bellhead { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: 12.5px; padding: 0; }
.notif.unread { background: var(--agent-bg); }
.notif.unread .tbtext > span:first-child { font-weight: 600; }
.dialog.wide { overflow-y: auto; }
.form.two { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.form.two label select, .form.two label input, .form.two label > div > select { width: 100%; }

/* ---------- Automations ---------- */
.chkrow { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.rulesec { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; font-size: 14px; }
.dialog label.chk, .form label.chk, .chkrow label.chk { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.chkrow label.chk input { margin: 0; }
.form.two label.chk input, .form label.chk input[type=checkbox] { width: auto; flex: none; }
.chkrow label.chk { white-space: nowrap; }

/* ---------- Collision warning ---------- */
.presence { margin: 8px 16px 0; padding: 7px 12px; border-radius: 10px; background: var(--agent-bg); border: 1px solid var(--agent-line); font-size: 13px; }
.presence[hidden] { display: none; }
.presence.hot { background: var(--warn-bg); border-color: #f59e0b; font-weight: 600; }
.page .presence { margin: 0 0 10px; }

/* ---------- Unread replies in the inbox ---------- */
.item.unread .name { font-weight: 800; }
.item.unread { box-shadow: inset 3px 0 #10b981; }
.newdot { margin-left: auto; margin-right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #10b981; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* ---------- Alert sound choices ---------- */
.sndbox { display: flex; flex-direction: column; gap: 8px; padding: 6px 0 2px 26px; }
.sndrow { display: grid; grid-template-columns: minmax(180px, 1fr) 200px auto; gap: 10px; align-items: center; }
.sndrow select { width: 100%; }
@media (max-width: 900px) { .sndrow { grid-template-columns: 1fr; } }

/* ---------- More statuses ---------- */
.s-quality { background: #8b5cf6; } .s-team_brief { background: #3b82f6; } .s-hr_meeting { background: #ec4899; }
/* ---------- Agent time report ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 10px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--hover); gap: 2px; }
.stack i { display: block; height: 100%; }
.tbl.agenttime tr.total td { border-top: 2px solid var(--line); background: var(--hover); }

/* ---------- My status in the top bar ---------- */
.stbox { position: relative; }
.stbtn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stbtn.st-online { border-color: #22c55e; background: var(--ok-bg); }
.stbtn.st-break1, .stbtn.st-break2, .stbtn.st-break3 { border-color: #f59e0b; background: var(--warn-bg); }
.stbtn.st-quality { border-color: #8b5cf6; } .stbtn.st-team_brief { border-color: #3b82f6; } .stbtn.st-hr_meeting { border-color: #ec4899; }
.stbtn.warn { animation: stpulse 1s infinite; }
.stbtn.over { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); animation: stpulse 1.2s infinite; }
@keyframes stpulse { 50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, .25); } }
.stmenu { position: absolute; top: calc(100% + 6px); right: 0; width: 260px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.25); padding: 6px; z-index: 60; }
.stmenu[hidden] { display: none; }
.stitem { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 10px; color: var(--ink); cursor: pointer; font: inherit; }
.stitem:hover:not(:disabled) { background: var(--hover); }
.stitem.on { background: var(--ok-bg); }
.stitem:disabled { opacity: .5; cursor: default; }
.stsep { height: 1px; background: var(--line); margin: 4px 6px; }
.s-break1, .s-break2, .s-break3 { background: #f59e0b; }
.badink { color: var(--bad); font-weight: 600; }
