:root {
  --ink: #17231f; --muted: #66736e; --line: #e4e6e0; --bg: #f5f5f0; --card: #fff;
  --brand: #0f6b5c; --brand-dark: #0a4f44; --brand-soft: #e1f1ec; --side: #10211d;
  --good: #137a58; --good-bg: #dff3ea; --bad: #b3372c; --bad-bg: #fbe6e2; --warn: #94650a; --warn-bg: #fbf0d4; --info: #27608f; --info-bg: #e2eef8;
  --mute-bg: #eeefea; --r: 10px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 22px 0 8px; }
p { margin: 0 0 10px; }
code { background: var(--mute-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-word; background: #f7f7f3; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12.5px; max-height: 420px; overflow: auto; }
blockquote { margin: 10px 0; padding: 10px 14px; background: #f7f7f3; border-left: 3px solid var(--brand); border-radius: 0 8px 8px 0; font-size: 14px; }
.muted, small { color: var(--muted); }
small { font-size: 12.5px; }
.good-text { color: var(--good); font-weight: 600; }

.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: #cfdad6; padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.side nav a { color: #b9c7c2; padding: 8px 12px; border-radius: 8px; }
.side nav a:hover { background: #1b312b; color: #fff; text-decoration: none; }
.side nav a.on { background: #1f4a40; color: #fff; font-weight: 600; }
.side-foot { padding: 8px 12px 0; }
.linkbtn { background: none; border: 0; color: #8fa39c; cursor: pointer; padding: 0; font: inherit; }
.linkbtn:hover { color: #fff; }
main { padding: 24px 30px 60px; max-width: 1320px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 4px 0 0; }
.stopbar { background: var(--bad); color: #fff; padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5cac1; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: #eccfca; }
.btn.danger-ghost:hover { background: var(--bad-bg); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.inline { display: inline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.card > table:last-child { margin-bottom: -6px; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card[open] summary { margin-bottom: 10px; }
.stack > * + * { margin-top: 12px; }
aside.stack .card, .stack .card { margin-bottom: 0; }
.stack > .card + .card { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.top-align { align-items: start; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.sticky { position: sticky; top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.row-between h2 { margin: 0; }
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row-form .field { flex: 1; min-width: 200px; }
.narrow { max-width: 340px; }
.mt { margin-top: 12px; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }

.field { display: block; }
.field-label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.field small { display: block; margin-top: 3px; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #d6d9d2; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--brand); }
input[type=file] { font: inherit; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 4px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0; }
legend { font-weight: 600; font-size: 13.5px; padding: 0 6px; }
.daypick { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.daypick input, .seg input { position: absolute; opacity: 0; }
.daypick span { display: block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; font-size: 13px; }
.daypick input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.keyrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.filters input, .filters select { width: auto !important; min-width: 130px; padding: 6px 9px !important; }
.card > .filters:only-child { margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #efefea; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.clip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card:has(table) { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.mute { background: var(--mute-bg); color: var(--muted); }
.flash { padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; word-break: break-word; }
.flash.good { background: var(--good-bg); color: #0d5a41; }
.flash.bad { background: var(--bad-bg); color: #8b2a21; }
.flash.warn { background: var(--warn-bg); color: #6f4b07; }
.empty { color: var(--muted); padding: 10px 0; margin: 0; }
.empty-state { text-align: center; padding: 44px 20px; }
.empty-state p { color: var(--muted); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; color: var(--ink); display: block; }
a.kpi:hover { border-color: var(--brand); text-decoration: none; }
.kpi span { display: block; font-size: 12.5px; color: var(--muted); }
.kpi b { display: block; font-size: 27px; line-height: 1.25; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi small { display: block; min-height: 18px; }
.kpi.hero { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpi.hero span, .kpi.hero small { color: #c6e6dd; }
.kpis.small .kpi { padding: 8px 12px; }
.kpis.small .kpi b { font-size: 19px; }
progress { width: 100%; height: 7px; margin-bottom: 14px; display: block; border: 0; border-radius: 5px; overflow: hidden; background: #e6e7e1; accent-color: var(--brand); }
progress::-webkit-progress-bar { background: #e6e7e1; }
progress::-webkit-progress-value { background: var(--brand); }

.chart { width: 100%; height: auto; display: block; }
.bar { fill: var(--brand); }
.bar.alt { fill: #3f8fb5; }
.bar-v { font-size: 11px; text-anchor: middle; fill: var(--ink); font-weight: 600; }
.bar-l { font-size: 10.5px; text-anchor: middle; fill: var(--muted); }

.setup { background: #fbfbf7; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 8px; align-items: center; }
.steps li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; background: var(--mute-bg); color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.steps li.ok::before { content: "✓"; background: var(--good-bg); color: var(--good); }
.steps li.ok a { color: var(--muted); text-decoration: line-through; }
.todo { margin: 0 0 12px; padding-left: 18px; color: var(--warn); font-size: 14px; }
.mini-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #efefea; color: var(--ink); }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { text-decoration: none; color: var(--brand); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.agent-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; gap: 12px; align-items: center; color: var(--ink); }
.agent-card:hover { border-color: var(--brand); text-decoration: none; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; background: var(--brand-soft); color: var(--brand-dark); }
.avatar.male { background: var(--info-bg); color: var(--info); }
.agent-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; color: var(--muted); }
.agent-stats b { color: var(--ink); }

.tabs { display: flex; gap: 4px; position: sticky; top: 0; background: var(--bg); padding: 6px 0 10px; z-index: 5; overflow-x: auto; }
.tabs a { padding: 5px 11px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.tabs a:hover { background: var(--mute-bg); text-decoration: none; }
.savebar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.voice-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.voice-tools select { width: auto !important; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg span { display: block; padding: 7px 18px; cursor: pointer; font-weight: 600; }
.seg input:checked + span { background: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -3px; }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; max-height: 390px; overflow: auto; padding: 2px; }
.voice { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; }
.voice.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: #f6fbf9; }
.voice-top { display: flex; justify-content: space-between; gap: 6px; }
.voice-tag { font-size: 13px; margin: 2px 0; color: var(--ink); flex: 1; }
.voice small { text-transform: capitalize; }
.voice-btns { display: flex; gap: 6px; margin-top: 8px; }
.testform > * + * { margin-top: 10px; }
.testform .btn { width: 100%; }

.chat { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.msg { max-width: 82%; }
.msg p { margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--mute-bg); }
.msg.us { align-self: flex-start; }
.msg.them { align-self: flex-end; text-align: right; }
.msg.them p { background: var(--brand-soft); text-align: left; }
.live-card { margin: 0; }
dl { display: grid; grid-template-columns: 96px 1fr; gap: 5px 10px; margin: 0 0 12px; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--side); }
.auth-card { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; }
.auth-card > * + * { margin-top: 14px; }
.auth-brand { display: flex; gap: 10px; align-items: center; font-size: 19px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { display: none; }
  main { padding: 16px; }
  .split, .grid2, .grid3 { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
