@import url("https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700;800&display=swap");

:root {
  --brand: #0d3fa6; --brand-2: #2563d9; --brand-soft: #eaf0fc;
  --bg: #f3f6fb; --panel: #ffffff; --text: #14213d; --muted: #6b7a90; --line: #e6ebf3;
  --head: #f7f9fd; --row-hover: #f5f8fe;
  --red: #d92d3f; --red-bg: #fdecee; --orange: #d97a12; --orange-bg: #fdf3e4;
  --green: #12925a; --green-bg: #e5f6ee; --bar: #2563d9;
  --shadow: 0 1px 2px rgba(20, 33, 61, .04), 0 4px 16px rgba(20, 33, 61, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #7aa5ff; --brand-2: #5b8cf5; --brand-soft: #1a2747;
    --bg: #0c1220; --panel: #141c2e; --text: #e7ecf5; --muted: #8d9ab0; --line: #243049;
    --head: #18223a; --row-hover: #1a2440;
    --red: #ff6b78; --red-bg: #3a1c25; --orange: #f5a54a; --orange-bg: #3a2a17;
    --green: #45d08f; --green-bg: #12332a; --bar: #5b8cf5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  --brand: #7aa5ff; --brand-2: #5b8cf5; --brand-soft: #1a2747;
  --bg: #0c1220; --panel: #141c2e; --text: #e7ecf5; --muted: #8d9ab0; --line: #243049;
  --head: #18223a; --row-hover: #1a2440;
  --red: #ff6b78; --red-bg: #3a1c25; --orange: #f5a54a; --orange-bg: #3a2a17;
  --green: #45d08f; --green-bg: #12332a; --bar: #5b8cf5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Heebo", system-ui, "Segoe UI", Arial, sans-serif;
  display: flex; flex-direction: column; gap: 14px; padding: 14px 18px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ---------- top bar ---------- */
header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 16px; border-bottom: 3px solid var(--brand);
}
.logo { height: 46px; width: auto; display: block; background: #fff; border-radius: 8px; padding: 2px 6px; }
.titles { display: flex; flex-direction: column; line-height: 1.15; }
h1 { font-size: 21px; margin: 0; font-weight: 800; color: var(--brand); letter-spacing: -.2px; }
.titles .sub { font-size: 12px; color: var(--muted); }
#status {
  padding: 8px 14px; border-radius: 999px; font-weight: 600; flex: 1; min-width: 220px;
  display: flex; align-items: center; gap: 8px;
}
#status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
#status.ok { background: var(--green-bg); color: var(--green); }
#status.bad { background: var(--red-bg); color: var(--red); }
#status.bad::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; vertical-align: middle; }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
#demo { background: var(--orange-bg); color: var(--orange); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
button {
  background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 999px;
  width: 30px; height: 30px; cursor: pointer; font-size: 15px;
}
button:hover { filter: brightness(.95); }
.back {
  color: var(--brand); text-decoration: none; font-size: 13px; font-weight: 600;
  background: var(--brand-soft); padding: 5px 12px; border-radius: 999px;
}

/* ---------- KPI cards ---------- */
.kpis { display: flex; flex-wrap: wrap; gap: 12px; }
.kpis > .kpi { flex: 1 1 170px; }
.kpi {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px; position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-2); opacity: .5; }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .v { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; margin-top: 2px; }
.kpi.red { background: linear-gradient(0deg, var(--red-bg), var(--panel)); }
.kpi.red::after { background: var(--red); opacity: 1; } .kpi.red .v { color: var(--red); }
.kpi.orange::after { background: var(--orange); opacity: 1; } .kpi.orange .v { color: var(--orange); }
.kpi.green::after { background: var(--green); opacity: 1; }

/* ---------- layout ---------- */
main { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; flex: 1; min-height: 0; }
.col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.panel {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; min-height: 0;
}
.panel h2 { font-size: 15px; margin: 0 0 10px; color: var(--text); font-weight: 700; display: flex; gap: 6px; align-items: center; }
.panel h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--brand); }
.panel h2 span { color: var(--muted); font-weight: 500; }
.scroll { overflow: auto; }
.scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
#waitingPanel { flex: 1; display: flex; flex-direction: column; }
#waitingPanel .scroll { flex: 1; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--head); position: sticky; top: 0; z-index: 1; }
th:first-child { border-start-start-radius: 8px; } th:last-child { border-start-end-radius: 8px; }
tbody tr:hover td { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: center; }
td.red, td.orange { font-weight: 700; }
td.red { color: var(--red); } td.orange { color: var(--orange); }
td.red::before, td.orange::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-inline-end: 5px; vertical-align: middle; }
td.preview { max-width: 170px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
td.name { font-weight: 700; }
td.name a { text-decoration: none; color: var(--brand); }
td.name a:hover { text-decoration: underline; }
.ltr { direction: ltr; unicode-bidi: embed; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.chart { background: var(--head); border-radius: 10px; padding: 8px 10px; }
.chart h3 { font-size: 13px; margin: 0 0 4px; font-weight: 600; }
.chart svg { width: 100%; height: 90px; display: block; }
.chart.big svg { height: 140px; }
.chart .axis { font-size: 10px; fill: var(--muted); font-family: inherit; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.legend { color: var(--muted); font-size: 11px; font-weight: 400; }

.hbar { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; margin: 7px 0; }
.hbar .track { background: var(--head); border-radius: 999px; height: 12px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--bar); border-radius: 999px; transition: width .4s; }
.hbar .fill.orange { background: var(--orange); } .hbar .fill.red { background: var(--red); }
.hbar .n { text-align: left; font-variant-numeric: tabular-nums; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .charts { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  #waitingPanel .scroll { max-height: 60vh; }
}
@media (max-width: 600px) {
  body { padding: 12px 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 24px; }
  .charts { grid-template-columns: 1fr; }
  .logo { height: 36px; }
}
.cname { font-weight: 600; }
.cphone { color: var(--muted); font-size: 12px; }
.rtag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }

.kpi .v small { font-size: 16px; color: var(--muted); font-weight: 600; }
.oc { display: inline-block; width: 110px; height: 10px; border-radius: 999px; background: var(--orange-bg); overflow: hidden; vertical-align: middle; }
.oc-c { height: 100%; background: var(--green); border-radius: 999px; }
.oc-l { font-size: 12px; color: var(--muted); margin-inline-start: 8px; }
.closeBtn {
  width: auto; height: auto; padding: 3px 10px; font: inherit; font-size: 12px; font-weight: 600;
  background: var(--green-bg); color: var(--green); border-radius: 999px;
}
.st { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.st-closed { background: var(--green-bg); color: var(--green); }
.st-wait { background: var(--red-bg); color: var(--red); }
.st-open { background: var(--orange-bg); color: var(--orange); }
.kpi[data-filter] { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.kpi[data-filter]:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20,33,61,.06), 0 10px 24px rgba(20,33,61,.12); }
.kpi[data-filter] .l::after { content: " ›"; opacity: .5; }
.modal { position: fixed; inset: 0; background: rgba(10, 18, 35, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(1200px, 100%); max-height: 88vh; display: flex; flex-direction: column; padding: 14px 16px; }
.modal-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; color: var(--brand); }
.modal-head h2 span { color: var(--muted); font-weight: 500; }
.modal-head input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; min-width: 240px; }
.modal-box .scroll { flex: 1; }
.modal .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 20px; width: auto; height: auto; }
a.dial { color: var(--brand); text-decoration: none; font-weight: 600; white-space: nowrap; border-radius: 6px; padding: 1px 4px; }
a.dial:hover { background: var(--brand-soft); text-decoration: underline; }
tr[data-chat] { cursor: pointer; }
.chat-box { width: min(720px, 100%); height: 86vh; }
.chat-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.chat-meta i { font-style: normal; opacity: .75; }
.chat { flex: 1; overflow: auto; background: var(--head); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.chat-day { align-self: center; font-size: 11px; color: var(--muted); background: var(--panel); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }
.bubble { max-width: 78%; padding: 8px 12px 6px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: normal; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.b-in { align-self: flex-start; background: var(--panel); border-start-start-radius: 4px; }
.b-out { align-self: flex-end; background: #d9fdd3; color: #14213d; border-start-end-radius: 4px; }
:root[data-theme="dark"] .b-out { background: #1f4d3a; color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .b-out { background: #1f4d3a; color: var(--text); } }
.b-at { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: left; }
.b-media { font-size: 12px; color: var(--brand); font-weight: 600; }
.chat-foot { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.chat-foot .sub { margin-inline-start: auto; }
.ctag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #ede7fb; color: #5b3bb5; margin-inline-end: 4px; }
:root[data-theme="dark"] .ctag { background: #2c2350; color: #c3b2ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ctag { background: #2c2350; color: #c3b2ff; } }
.tone { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--head); color: var(--muted); margin-inline-end: 4px; }
.tone-ok { background: var(--green-bg); color: var(--green); }
.tone-warn { background: var(--orange-bg); color: var(--orange); }
.tone-bad { background: var(--red-bg); color: var(--red); }
.catrow { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; padding: 6px 6px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.catrow:hover { background: var(--row-hover); }
.catrow .cn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow .track { background: var(--head); border-radius: 999px; height: 10px; overflow: hidden; }
.catrow .fill { height: 100%; background: #7c5cdb; border-radius: 999px; }
.catrow .n { white-space: nowrap; font-variant-numeric: tabular-nums; }
.copen { color: var(--orange); font-size: 12px; font-weight: 600; }
.aibox { flex-basis: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-top: 6px; color: var(--text); font-size: 13px; }
.ai-yes { color: var(--green); font-weight: 600; margin-top: 2px; }
.ai-no { color: var(--orange); font-weight: 600; margin-top: 2px; }
/* category cards stretch to fill the full width, whatever the number of categories */
.catcards { display: flex; flex-wrap: wrap; gap: 12px; }
.catcards > .catcard { flex: 1 1 130px; min-width: 0; }
.catcards:empty { display: none; }
.catcard { cursor: pointer; padding: 10px 14px; transition: transform .12s, box-shadow .12s; }
.catcard:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20,33,61,.06), 0 10px 24px rgba(20,33,61,.12); }
.catcard::after { background: #7c5cdb !important; opacity: 1 !important; }
.catcard .l { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catcard .l::after { content: " ›"; opacity: .5; }
.catcard .v { font-size: 26px; }
.catcard .cs { font-size: 12px; margin-top: 2px; }
.catcard.has-open::after { background: var(--orange) !important; }
/* center cards on the main screen */
.ccards { display: flex; flex-wrap: wrap; gap: 14px; }
.ccard { flex: 1 1 320px; display: block; text-decoration: none; color: inherit; background: var(--head); border-radius: var(--radius);
  padding: 14px 18px; border-inline-start: 6px solid var(--green); transition: transform .12s, box-shadow .12s; }
.ccard:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20,33,61,.06), 0 10px 24px rgba(20,33,61,.12); }
.ccard.warn { border-inline-start-color: var(--orange); }
.ccard.bad { border-inline-start-color: var(--red); background: linear-gradient(0deg, var(--red-bg), var(--head)); }
.ccard .ch { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ccard .cn { font-size: 22px; font-weight: 800; color: var(--brand); }
.ccard .cnum { color: var(--muted); font-size: 14px; }
.ccard .cst { margin-inline-start: auto; font-weight: 700; font-size: 14px; color: var(--green); }
.ccard.warn .cst { color: var(--orange); } .ccard.bad .cst { color: var(--red); }
.ccard .cstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ccard .s { background: var(--panel); border-radius: 10px; padding: 8px 6px; text-align: center; }
.ccard .s b { display: block; font-size: 34px; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; }
.ccard .s span { font-size: 14px; color: var(--muted); font-weight: 600; }
.ccard .s.orange b { color: var(--orange); } .ccard .s.red b { color: var(--red); } .ccard .s.green b { color: var(--green); }
.owner { font-size: 11px; background: var(--head); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.owner.me { background: var(--green-bg); color: var(--green); font-weight: 700; }
select.xfer, select#xfer { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--brand-soft); color: var(--brand); font: inherit; font-size: 13px; font-weight: 600; }
#agentsPanel { flex: none; }
.back.logout { background: var(--head); color: var(--muted); }
.back.logout:hover { background: var(--red-bg); color: var(--red); }
