:root {
  --bg: #f5f6fa; --card: #fff; --line: #e6e8ef; --line2: #eef0f5;
  --ink: #141a2e; --ink2: #4a5168; --ink3: #8a90a6;
  --brand: #4f46e5; --brand2: #eef0ff; --brand-ink: #3730a3;
  --side: #0f1424; --side2: #1a2036; --side-ink: #aeb4c8;
  --pos: #12a150; --pos-bg: #e7f7ee; --neu: #8a90a6; --neu-bg: #eff1f6; --neg: #dc3545; --neg-bg: #fdecee;
  --warn: #d97706; --warn-bg: #fff4e0;
  --r: 12px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--ink); -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; margin: 0; color: var(--ink2); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--ink3); } .small { font-size: 12px; } .mono { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; } .grow { flex: 1; } .wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--side) 232px, transparent 232px); }
.side { background: var(--side); color: var(--side-ink); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; padding: 4px 8px 20px; font-size: 15px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side2); color: #fff; }
.nav a.on { background: var(--side2); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav svg { width: 18px; height: 18px; opacity: .85; }
.side .foot { margin-top: auto; border-top: 1px solid #232a44; padding-top: 12px; font-size: 12px; }
.side .foot .who { color: #fff; font-weight: 600; font-size: 13px; }
.side .foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; margin-top: 6px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.page { padding: 24px 28px 60px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--ink3); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line2); }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g-2 { grid-template-columns: 2fr 1fr; } .g-2e { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .g-2, .g-2e { grid-template-columns: 1fr; } }
.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--ink3); font-size: 12px; font-weight: 550; text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-size: 26px; font-weight: 680; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--ink3); margin-top: 2px; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: #cfd3df; background: #fafbfd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.input, select.input, textarea.input { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0; }
.input:focus { outline: 2px solid var(--brand2); border-color: var(--brand); }
textarea.input { width: 100%; resize: vertical; min-height: 70px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink2); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line2); align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 5px 11px; cursor: pointer; font-weight: 550; color: var(--ink2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand2); color: var(--brand-ink); }
.seg button.on.yes { background: var(--pos-bg); color: var(--pos); }
.seg button.on.no { background: var(--neg-bg); color: var(--neg); }
.seg button.on.na { background: var(--neu-bg); color: var(--ink2); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d4d8e3; border-radius: 20px; cursor: pointer; transition: .15s; }
.switch span:before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span:before { transform: translateX(16px); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.p-pos { background: var(--pos-bg); color: var(--pos); } .p-neu { background: var(--neu-bg); color: var(--ink2); }
.p-neg { background: var(--neg-bg); color: var(--neg); } .p-warn { background: var(--warn-bg); color: var(--warn); }
.p-brand { background: var(--brand2); color: var(--brand-ink); } .p-plain { background: var(--neu-bg); color: var(--ink2); }

/* table */
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfbfd; white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: #f8f9fd; }
.t tr:last-child td { border-bottom: 0; }
.dir { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--brand2); color: var(--brand); }
.dir.out { background: #e8f4fd; color: #0b78c2; } .dir.int { background: var(--neu-bg); color: var(--ink2); }
.dir svg { width: 16px; height: 16px; }
.who b { display: block; font-weight: 600; } .who span { color: var(--ink3); font-size: 12px; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.pass { color: var(--pos); } .score.fail { color: var(--neg); }
.sbar { width: 64px; height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--neg), #d9dce6 45%, var(--pos)); position: relative; }
.sbar i { position: absolute; top: -3px; width: 3px; height: 12px; border-radius: 2px; background: var(--ink); }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line2); }
.empty { text-align: center; color: var(--ink3); padding: 40px 10px; }

/* charts */
.chart svg { width: 100%; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.bar-mini { height: 6px; border-radius: 6px; background: var(--line2); overflow: hidden; min-width: 60px; }
.bar-mini i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }

/* call view */
.call-head { padding: 18px 20px; display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.call-head .meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 10px; color: var(--ink2); }
.call-head .meta div span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink3); font-weight: 600; }
.player { padding: 16px 20px 14px; }
.wave-wrap { position: relative; height: 88px; cursor: pointer; user-select: none; }
.wave-wrap canvas { width: 100%; height: 100%; display: block; }
.wave-tip { position: absolute; top: -26px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; pointer-events: none; white-space: nowrap; }
.marker { position: absolute; top: -4px; transform: translateX(-50%); width: 16px; height: 16px; border-radius: 50% 50% 50% 0; rotate: -45deg; background: var(--warn); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); cursor: pointer; z-index: 2; }
.lanes { margin-top: 8px; display: grid; grid-template-columns: 64px 1fr; gap: 4px 10px; align-items: center; font-size: 11px; color: var(--ink3); font-weight: 600; }
.lane { position: relative; height: 12px; background: var(--line2); border-radius: 4px; overflow: hidden; }
.lane b { position: absolute; top: 0; bottom: 0; border-radius: 3px; cursor: pointer; }
.lane b:hover { outline: 2px solid var(--ink); z-index: 1; }
.controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; cursor: pointer; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.play svg { width: 20px; height: 20px; }
.time { font-variant-numeric: tabular-nums; color: var(--ink2); min-width: 110px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 1150px) { .split { grid-template-columns: 1fr; } }
.transcript { max-height: 640px; overflow-y: auto; padding: 8px 12px 16px; scroll-behavior: smooth; }
.utt { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.utt:hover { background: #f7f8fc; }
.utt.now { background: var(--brand2); }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--brand2); color: var(--brand); }
.utt.customer .av { background: #fff1e6; color: #c2410c; }
.utt .hd { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink3); margin-bottom: 2px; }
.utt .hd b { color: var(--ink); font-size: 13px; }
.utt .tx { line-height: 1.5; }
.utt mark { background: #fde68a; border-radius: 3px; padding: 0 1px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line2); }
.tabs button { border: 0; background: none; padding: 13px 12px 11px; cursor: pointer; font-weight: 600; color: var(--ink3); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.qa-sec { padding: 12px 18px 4px; }
.crit { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.crit:last-child { border-bottom: 0; }
.crit .lbl { font-weight: 600; } .crit .help { color: var(--ink3); font-size: 12px; margin-top: 2px; }
.crit .auto { font-size: 12px; margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.crit .auto.hit { color: var(--pos); } .crit .auto.miss { color: var(--ink3); }
.crit .auto q { color: var(--ink2); font-style: italic; }
.crit input.cmt { width: 100%; margin-top: 7px; font-size: 13px; }
.ring { position: relative; width: 74px; height: 74px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring div { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 750; font-size: 17px; }
.qa-foot { background: #fff; border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 8px; align-items: center; border-radius: 0 0 var(--r) var(--r); }
.ins { padding: 16px 18px; display: grid; gap: 14px; }
.ins .tile { border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; }
.gauge { height: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--neg), #d9dce6 50%, var(--pos)); position: relative; margin: 10px 0 4px; }
.gauge i { position: absolute; top: -4px; width: 4px; height: 16px; background: var(--ink); border-radius: 2px; transform: translateX(-50%); }
.note { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.banner { padding: 12px 16px; border-radius: 10px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--warn-bg); color: #92400e; } .banner.info { background: var(--brand2); color: var(--brand-ink); }
.banner.ok { background: var(--pos-bg); color: #0f6b39; } .banner.err { background: var(--neg-bg); color: #9b1c2c; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, #e0e3ff, transparent), var(--bg); }
.login .card { width: 380px; padding: 30px; }
.login .brand { color: var(--ink); padding: 0 0 18px; }
.login form { display: grid; gap: 14px; }
.err { color: var(--neg); font-size: 13px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; font-weight: 550; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--neu-bg); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; }
.chip button { border: 0; background: #fff; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; line-height: 1; color: var(--ink3); }
.sc-row td { padding: 8px 10px; }
.sc-row .input { width: 100%; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---- live wallboard ---- */
.neg { color: var(--neg) !important; } .warnc { color: var(--warn); }
.kpi-bad .val { color: var(--neg); }
.live-dot .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18,161,80,.6); } 70% { box-shadow: 0 0 0 7px rgba(18,161,80,0); } 100% { box-shadow: 0 0 0 0 rgba(18,161,80,0); } }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; margin-top: 16px; }
.qcard { padding: 16px 18px; border-top: 4px solid var(--pos); }
.qcard.busy { border-top-color: var(--warn); } .qcard.alert { border-top-color: var(--neg); background: linear-gradient(180deg, #fff5f6, #fff 60%); }
.qname { font-size: 16px; }
.qwait { font-size: 34px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.qcard.alert .qwait { color: var(--neg); } .qcard.busy .qwait { color: var(--warn); }
.stackbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin-top: 12px; gap: 2px; }
.qstats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line2); }
.qstats span { display: block; font-size: 11px; color: var(--ink3); font-weight: 600; }
.qstats b { font-size: 16px; font-variant-numeric: tabular-nums; }
.waitlist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip.wait { background: var(--warn-bg); padding: 3px 10px; gap: 8px; }
.live-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 1200px) { .live-split { grid-template-columns: 1fr; } }
.feed #feed { max-height: 560px; overflow: auto; padding: 4px 0; }
.fi { display: flex; gap: 10px; align-items: baseline; padding: 8px 16px; border-bottom: 1px solid var(--line2); font-size: 13px; }
.fi .sdot { flex: none; transform: translateY(-1px); }
.av.sm { width: 30px; height: 30px; font-size: 11px; }
.agents-t tr.off td { opacity: .5; }
.st { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; }
.st:before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-avail { background: var(--pos-bg); color: var(--pos); } .st-call { background: var(--brand2); color: var(--brand); }
.st-wrap { background: var(--warn-bg); color: var(--warn); } .st-unav { background: var(--neg-bg); color: var(--neg); }
.st-off { background: var(--neu-bg); color: var(--ink3); }
.btn.mon { color: #fff; background: var(--brand); border-color: var(--brand); }
.agents-t td, .agents-t th { padding-left: 10px; padding-right: 10px; }
body.wallboard .side, body.wallboard .topbar, body.wallboard .page-head p { display: none; }
body.wallboard .shell { grid-template-columns: 1fr; background: none; }
body.wallboard .page { max-width: none; padding: 18px 22px; }
body.wallboard .qwait { font-size: 52px; } body.wallboard .kpi .val { font-size: 34px; } body.wallboard { font-size: 15px; }

.agents-t .who b, .agents-t td:first-child { white-space: nowrap; }
