/* voice-core · кабинет диспетчерской.
   Палитра: тёмно-синие «чернила» для структуры, бумажный фон, тёплый сигнальный оранжевый для срочного,
   морской зелёный для заявок и «линия слушает». Шрифт Manrope: крупные табличные цифры читаются с телефона. */
:root {
  --ink: #16213A; --ink-2: #2B3858; --paper: #F4F5F2; --card: #FFFFFF; --line: #E2E5EA; --muted: #6B7383;
  --text: #1C2333; --green: #0F766E; --green-soft: #E3F3F0; --orange: #D9480F; --orange-soft: #FBE9E1;
  --amber: #B7791F; --red: #B42318; --nav-text: #C9D2E6; --nav-on: #FFFFFF; --shadow: 0 1px 2px rgba(22, 33, 58, .06), 0 8px 24px -16px rgba(22, 33, 58, .25);
  --radius: 14px; --side: 232px;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #0F1420; --card: #171E2E; --line: #27304A; --muted: #93A0B8; --text: #E7ECF5; --ink: #0B1020; --ink-2: #1B2540;
          --green-soft: #12302C; --orange-soft: #3A1E12; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--text); font-family: Manrope, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 1rem; font-weight: 700; margin: 0 0 .7rem; display: flex; align-items: center; gap: 8px; }
h2 .i { color: var(--muted); }
.card > h2:not(:first-child) { margin-top: 20px; }
.eyebrow { margin: 0 0 2px; font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .bad { color: var(--red); } .ok { color: var(--green); }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -4px; }
.i.tiny { width: 14px; height: 14px; }
.i.flip { transform: rotate(180deg); }
.flag { width: 21px; height: 14px; border-radius: 3px; flex: none; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08) inset; }

/* каркас: боковое меню на широких экранах, вкладки снизу на телефоне */
.main { padding: 20px 20px 96px; max-width: 1120px; margin: 0 auto; }
.side { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); z-index: 5; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 10px; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabbar a .i { width: 22px; height: 22px; }
.tabbar a.on { color: var(--green); background: var(--green-soft); }
.tabbar a.soon { opacity: .4; }
@media (min-width: 900px) {
  body.auth { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
  .side { display: flex; flex-direction: column; background: var(--ink); color: var(--nav-text); padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
  .brand { display: flex; align-items: center; gap: 10px; color: var(--nav-on); font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; padding: 4px 10px 22px; }
  .brand .i { color: #5CE0B8; }
  .menu { display: flex; flex-direction: column; gap: 2px; }
  .menu a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: .95rem; }
  .menu a:hover { background: var(--ink-2); color: var(--nav-on); }
  .menu a.on { background: var(--ink-2); color: var(--nav-on); box-shadow: inset 3px 0 0 #5CE0B8; }
  .menu a.soon { opacity: .45; cursor: default; }
  .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--ink-2); }
  .me .name { flex: 1; font-weight: 600; color: var(--nav-on); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar { display: none; }
  .main { padding: 32px 36px 48px; }
}
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink-2); color: var(--nav-on); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.person .avatar { background: var(--green-soft); color: var(--green); }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--ink-2); }

/* шапка страницы и статус */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .eyebrow { display: flex; align-items: center; gap: 6px; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--card); border: 1px solid var(--line); }
.status .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(15,118,110,.5); animation: pulse 2.2s infinite; }
.status.bad .pulse { background: var(--red); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(15,118,110,.45); } 70% { box-shadow: 0 0 0 8px rgba(15,118,110,0); } 100% { box-shadow: 0 0 0 0 rgba(15,118,110,0); } }
@media (prefers-reduced-motion: reduce) { .status .pulse { animation: none; } }
.head-facts { display: flex; gap: 14px; flex-wrap: wrap; font-size: .95rem; color: var(--muted); }
.head-facts span { display: inline-flex; align-items: center; gap: 6px; }
.head-facts b { color: var(--text); font-size: 1.05rem; }
.back { margin: 0 0 10px; font-weight: 600; color: var(--muted); }
.back a { display: inline-flex; align-items: center; gap: 4px; }

/* карточки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
section.card + section.card, .stack > * + * { margin-top: 12px; }
.two-col { display: grid; gap: 14px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.grid2 { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
details.card summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { margin-bottom: 10px; }

/* герой обзора: цифры дня и лента по часам */
.hero { padding: 22px 22px 16px; margin-bottom: 14px; }
.hero-nums { display: flex; gap: 32px; flex-wrap: wrap; margin-bottom: 18px; }
.big { display: flex; flex-direction: column; }
.big .num { font-size: 3.2rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.big.accent .num { color: var(--green); }
.big .lbl { font-weight: 600; color: var(--muted); margin-top: 4px; }
.big .delta { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.big .delta .i { width: 16px; height: 16px; }
.day-strip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 92px; align-items: end; padding-bottom: 18px; position: relative; }
.hour { height: 100%; display: flex; align-items: flex-end; position: relative; border-radius: 4px; }
.hour.night { background: linear-gradient(to top, rgba(22,33,58,.07), transparent); }
@media (prefers-color-scheme: dark) { .hour.night { background: linear-gradient(to top, rgba(255,255,255,.05), transparent); } }
.bar { width: 100%; min-height: 3px; background: var(--line); border-radius: 4px 4px 2px 2px; display: flex; align-items: flex-end; overflow: hidden; transition: height .4s ease; }
.bar .lead { width: 100%; background: var(--green); }
.hour .tick { position: absolute; bottom: -18px; left: 0; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { margin: 6px 0 0; font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--line); }
.sw.lead { background: var(--green); margin-left: 8px; }

/* плитки показателей */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 22px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { display: grid; grid-template-columns: 24px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); }
.stat .i { grid-row: 1 / 3; width: 24px; height: 24px; color: var(--muted); }
.stat .num { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .lbl { font-size: .8rem; color: var(--muted); }
.stat.good .num { color: var(--green); } .stat.warn .num { color: var(--amber); } .stat.bad .num { color: var(--red); }

/* линии */
.lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 22px; }
.line { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.line:hover { border-color: var(--green); }
.line-head { display: flex; align-items: center; gap: 8px; }
.line-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.up { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); } .dot.down { background: var(--red); }
.line-nums { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.line-nums b { color: var(--text); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.line-foot { font-size: .8rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row.between { justify-content: space-between; margin-top: 0; }
.more-link { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--green); font-size: .9rem; }

/* список звонков */
.calls { display: flex; flex-direction: column; gap: 6px; }
.call { display: grid; grid-template-columns: 28px 52px 1fr auto 24px 64px; gap: 10px; align-items: center; padding: 11px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.call:hover { border-color: var(--green); }
.call.test { opacity: .7; }
.call .k { color: var(--muted); display: inline-flex; }
.call.k-new_order .k { color: var(--green); } .call.k-complaint .k, .call.k-cancel .k { color: var(--orange); }
.call .when { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.call .who { min-width: 0; display: flex; flex-direction: column; }
.call .who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call .kind { font-size: .9rem; font-weight: 600; text-align: right; }
.call .kind small { display: block; font-weight: 500; color: var(--muted); }
.call .line-of { display: inline-flex; justify-content: center; }
.call .dur { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); display: inline-flex; justify-content: flex-end; align-items: center; gap: 4px; }
@media (max-width: 640px) {
  .call { grid-template-columns: 24px 1fr auto; grid-template-rows: auto auto; }
  .call .when { grid-column: 2; grid-row: 2; } .call .who { grid-column: 2; grid-row: 1; }
  .call .kind { grid-column: 3; grid-row: 1; } .call .dur { grid-column: 3; grid-row: 2; } .call .line-of { display: none; }
}
.tag { font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--orange-soft); color: var(--orange); vertical-align: middle; letter-spacing: .02em; }
h1 .tag { font-size: .8rem; }
h1.with-icon { display: flex; align-items: center; gap: 10px; }
h1.with-icon .i { width: 28px; height: 28px; }
h1.k-new_order .i { color: var(--green); } h1.k-complaint .i, h1.k-cancel .i { color: var(--orange); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 12px; }
.empty .i { width: 32px; height: 32px; }
button.more { width: 100%; margin-top: 8px; }

/* формы */
button, .chip { font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .chip:hover { border-color: var(--muted); }
button.primary { background: var(--green); color: #fff; border-color: var(--green); }
button.primary.big { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }
button.danger { color: var(--red); border-color: var(--red); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
input, select { font: inherit; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); min-width: 0; width: 100%; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); }
label > input, label > select { margin-top: 4px; font-weight: 500; }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
label.check input { width: auto; margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; margin-bottom: 14px; }
.field { display: inline-flex; align-items: center; gap: 6px; flex: 1 1 160px; }
.field.grow { flex: 2 1 220px; }
.field .i { color: var(--muted); } .field input, .field select { margin: 0; }
.flash { display: flex; align-items: center; gap: 8px; background: var(--green-soft); color: var(--green); border: 1px solid var(--green); padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.error { display: flex; align-items: center; gap: 8px; background: var(--orange-soft); color: var(--orange); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }

/* карточка звонка */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; font-weight: 500; }
audio { width: 100%; margin-bottom: 6px; }
.transcript { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 8px; }
.transcript li { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start; cursor: pointer; }
.transcript .t { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 8px; }
.transcript .bubble { padding: 8px 12px; border-radius: 14px; background: var(--paper); max-width: 92%; }
.transcript li.client .bubble { background: var(--green-soft); justify-self: end; border-bottom-right-radius: 4px; }
.transcript li.agent .bubble { border-bottom-left-radius: 4px; }
.transcript li.now .bubble { outline: 2px solid var(--green); }
.transcript-plain { white-space: pre-wrap; font: inherit; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 7px 6px; border-bottom: 1px solid var(--line); font-size: .9rem; }
table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* люди */
.people { display: grid; gap: 10px; margin-bottom: 14px; }
.person.off { opacity: .55; }
.person-head { display: flex; align-items: center; gap: 12px; }
.person details { margin-top: 10px; }
.person summary { cursor: pointer; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; list-style: none; }
.person summary::-webkit-details-marker { display: none; }

/* вход */
body.anon .main { max-width: 420px; padding-top: 10vh; }
.login { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 26px; box-shadow: var(--shadow); }
.login-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--green); margin-bottom: 14px; }
.login h1 { font-size: 1.45rem; margin-bottom: 4px; }
.login .muted { margin: 0 0 18px; }

/* агенты */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--muted); border: 1px solid var(--line); background: var(--card); }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
textarea { font: inherit; font-size: .95rem; line-height: 1.5; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); width: 100%; resize: vertical; }
textarea#prompt { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88rem; }
label > textarea { margin-top: 4px; font-weight: 400; }
.hidden { display: none; }
.agent-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.agent-meta span { display: inline-flex; align-items: center; gap: 4px; }
.diff { font: .82rem/1.45 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; background: var(--paper); border-radius: 10px; padding: 10px 12px; max-height: 360px; overflow: auto; }
.diff .add { color: var(--green); } .diff .del { color: var(--orange); } .diff .hdr { color: var(--muted); }
.versions { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.versions li { display: grid; grid-template-columns: 44px 1fr; gap: 2px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; }
.versions li.published { border-color: var(--green); background: var(--green-soft); }
.versions li.draft { border-style: dashed; }
.versions .v { font-weight: 800; grid-row: 1 / 4; font-variant-numeric: tabular-nums; }
.versions .st { font-weight: 600; } .versions .note { color: var(--muted); }
.versions button.link { justify-self: start; padding: 2px 0; }
.publish-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
code { font: .85em ui-monospace, Menlo, monospace; background: var(--paper); padding: 1px 5px; border-radius: 5px; }
#prompt-count.bad { color: var(--orange); font-weight: 700; }
.chip.primary-chip { background: var(--green); color: #fff; border-color: var(--green); }
.lines-list { display: grid; gap: 10px; margin-bottom: 18px; }
.line-row .route-now { margin: 6px 0 4px; }
.line-row form select { flex: 1 1 260px; }
.ext { font-weight: 800; font-variant-numeric: tabular-nums; background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 8px; }
