:root {
  --bg: #0E1118;
  --panel: #12161F;
  --line: #2A2E39;
  --text: #D1D4DC;
  --muted: #848E9C;
  --green: #26A69A;
  --red: #FF4A4A;
  --gold: #F0B90B;
  --blue: #0052FF;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.45 "Segoe UI", Arial, sans-serif; }
body { display: flex; flex-direction: column; }
button, input, select { font: inherit; color: var(--text); }
button { background: #1E222D; border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--gold); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
input, select {
  background: #1E222D; border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 8px; width: 100%;
}
input:focus, select:focus { outline: 1px solid var(--gold); }
.top {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; color: #fff; }
.tabs { display: flex; gap: 6px; }
.tabs button.on { border-color: var(--gold); color: #fff; }
.meta { margin-left: auto; color: var(--muted); }
.proc { padding: 8px 16px 10px; border-bottom: 1px solid var(--line); }
.proc-text { margin: 0 0 6px; color: var(--text); font-variant-numeric: tabular-nums; }
main { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px 28px; }
.page { display: none; max-width: 1180px; }
#page-result { max-width: 1280px; }
.page.on { display: block; }
h2 { margin: 0 0 12px; font-size: 15px; color: #fff; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; margin-bottom: 14px;
}
.grid-form {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px;
}
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.span-2 { grid-column: span 2; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); margin: 8px 0 0; }
.err { color: var(--red); min-height: 1.2em; }
.ok { color: var(--green); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 500; }
th.sort { cursor: pointer; user-select: none; }
th.sort.on { color: #fff; }
.chips { margin-bottom: 4px; }
.chips button.on { border-color: var(--gold); color: #fff; }
button.tiny { padding: 2px 8px; }
.coin-chart { height: 380px; min-height: 320px; }
.ep-dialog {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 0; width: min(1280px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}
.ep-dialog[open] { display: flex; flex-direction: column; }
.ep-dialog::backdrop { background: #0008; }
.ep-body { overflow: auto; padding: 0 14px 16px; }
.ep-body h3 { margin: 14px 0 6px; font-size: 14px; color: #fff; }
.ep-session { height: 480px; min-height: 420px; }
.ep-minutes { height: 280px; min-height: 240px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #1E222D; }
.stats {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
}
.stat {
  background: #1E222D; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
.stat b { display: block; color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 11px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.chart-tools { display: flex; gap: 14px; align-items: center; margin: 0 0 8px; color: var(--muted); }
.chart-tools .check, .chart-tools .chart-tf { display: flex; flex-direction: row; align-items: center; gap: 6px; }
.chart-tools .chart-tf { margin-left: auto; }
.chart-tools .ep-signal { margin-left: 0; flex: 1; min-width: 0; }
.chart-tools .ep-signal select { width: 100%; max-width: 460px; }
.chart-tools input, .chart-tools select { width: auto; }
select:disabled { opacity: 0.45; }
.chart-box { position: relative; height: calc(100vh - 340px); min-height: 520px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chart-box.ruler-on { cursor: crosshair; }
#ep-ruler.on { border-color: var(--gold); color: #fff; }
.coin-ruler { display: none; position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.coin-ruler.on { display: block; }
.coin-ruler-band {
  position: absolute; left: 0; right: 52px;
  background: #26A69A22;
  border-top: 1px dashed #26A69A;
  border-bottom: 1px dashed #26A69A;
}
.coin-ruler.down .coin-ruler-band {
  background: #FF4A4A22;
  border-top-color: #FF4A4A;
  border-bottom-color: #FF4A4A;
}
.coin-ruler-label {
  position: absolute; left: 10px; transform: translateY(-50%);
  background: #1E222D; border: 1px solid #26A69A; color: #26A69A;
  font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 4px;
  white-space: nowrap;
}
.coin-ruler.down .coin-ruler-label { border-color: #FF4A4A; color: #FF4A4A; }
.run-meta { color: var(--muted); margin: 10px 0 8px; font-variant-numeric: tabular-nums; }
.run-bar { height: 6px; background: #242c39; border-radius: 3px; overflow: hidden; }
.run-bar i { display: block; height: 100%; width: 0; background: #3d8bfd; }
.run-bar.wait i { width: 35%; animation: run-wait 1.1s ease-in-out infinite; }
@keyframes run-wait {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.unit-cfgs { display: grid; gap: 8px; }
.cfg-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #181d27;
}
.cfg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cfg-head b { color: #fff; }
.cfg-head .pill {
  border-radius: 99px; padding: 1px 8px; font-size: 11px; border: 1px solid var(--line); color: #c5ced9;
}
.cfg-head .pill.long { color: #00c087; border-color: #00c08755; }
.cfg-head .pill.short { color: #ff5b69; border-color: #ff5b6955; }
.cfg-head .name { width: 140px; }
.cfg-head button { margin-left: auto; }
.unit-add { margin-top: 10px; }
.grid-range-field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.grid-range-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 8px; align-items: center;
}
.grid-range-sep { color: #6d7a8d; }
.grid-range-row input { width: 100%; color-scheme: dark; }
#run-pick-range, #run-range-pick {
  background: #1b2433; border: 1px solid var(--line); color: #fff;
  border-radius: 4px; padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
#run-pick-range:hover, #run-range-pick:hover { border-color: #3d8bfd; }
#run-range-pick.on { background: #3d8bfd; border-color: #3d8bfd; }
.range-dialog {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 0; width: min(1200px, calc(100vw - 20px));
  height: min(900px, calc(100vh - 20px));
}
.range-dialog[open] { display: flex; flex-direction: column; }
.range-dialog::backdrop { background: #0008; }
.range-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 14px 8px;
}
.range-head h2 { margin: 0; }
.range-head .hint { margin: 4px 0 0; }
.range-head .icon {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  border-radius: 4px; cursor: pointer; padding: 0 8px; line-height: 22px;
}
.grid-range-tools {
  min-height: 38px; padding: 5px 15px; display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; border-top: 1px solid var(--line);
}
#run-range-apply { padding: 5px 12px; }
#run-range-apply:disabled { opacity: .55; cursor: default; }
.grid-range-tools .tfs { display: flex; gap: 4px; }
.grid-range-tools .tfs button {
  background: #1b2433; border: 1px solid var(--line); color: #c5ced9;
  border-radius: 4px; padding: 2px 7px; cursor: pointer;
}
.grid-range-tools .tfs button.on { background: #3d8bfd; border-color: #3d8bfd; color: #fff; }
#run-range-limit {
  width: auto; background: #0E1118; color: #fff; border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 6px;
}
#run-range-hint { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.range-box { position: relative; flex: 1; min-height: 0; width: 100%; border-top: 1px solid var(--line); }
.range-box.pick-on { cursor: crosshair; }
.run-time-ruler { display: none; position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.run-time-ruler.on { display: block; }
.run-time-ruler-band {
  position: absolute; top: 0; bottom: 22px;
  background: #3d8bfd33;
  border-left: 1px dashed #3d8bfd;
  border-right: 1px dashed #3d8bfd;
}
.run-time-ruler-label {
  position: absolute; top: 10px; transform: translateX(-50%);
  background: #1E222D; border: 1px solid #3d8bfd; color: #8ec0ff;
  font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 4px;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .grid-form, .stats, .protocol-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
textarea {
  background: #1E222D; color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 6px 8px; width: 100%; min-height: 72px; resize: vertical;
}
.protocol-grid { grid-template-columns: 1fr 1fr; }
.subhead { margin-top: 16px; }
.rules {
  white-space: pre-wrap; color: var(--muted); font: 12px/1.45 "Segoe UI", Arial, sans-serif;
  margin: 0;
}
.flag { color: var(--red); margin: 4px 0; }
.verdict { color: #fff; font-size: 15px; margin: 0 0 8px; }
.step h3 { display: flex; gap: 10px; align-items: center; margin: 0; }
.step .pill { border-radius: 99px; padding: 1px 8px; font-size: 11px; border: 1px solid var(--line); color: #c5ced9; }
.step ul { list-style: none; margin: 10px 0 0; padding: 0; }
.step li { margin: 6px 0; }
.step .link, .barrier-trades button {
  margin-left: 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: #8eb6ff;
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  font: inherit;
}
.barrier-trades { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.barrier-trades button { margin-left: 0; }
.pill.ok { color: #00c087; border-color: #00c08755; }
.pill.bad { color: #ff5b69; border-color: #ff5b6955; }
input[type="checkbox"] { width: auto; }
#card-signals input[type="number"] { max-width: 120px; }
.subhead { margin: 16px 0 8px; font-size: 13px; color: #fff; }
details summary { cursor: pointer; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #1E222D; }

/* вход и пользователи */
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.who #who-name { color: #fff; }
.login {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login[hidden] { display: none; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }
button.link { background: none; border: 0; padding: 0 2px; color: var(--gold); cursor: pointer; }
button.link:hover { text-decoration: underline; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
label.check input { width: auto; }

#lockbox-details > summary { cursor: pointer; padding: 2px 0; }
#lockbox-details[open] > summary { margin-bottom: 8px; }
.flag-inline { color: #ff5b69; }

#map-sp, #map-mx, #map-lane { width: 100%; background: #0B0E14; border: 1px solid var(--line); border-radius: 4px; display: block; }
#map-mx { max-width: 720px; aspect-ratio: 1; height: auto; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; }
.map-legend span i { display: inline-block; width: 10px; height: 3px; margin-right: 4px; vertical-align: middle; }
#map-groups tr { cursor: pointer; }
#map-groups tr.sel { background: #1E222D; }
label.check { flex-direction: row; align-items: center; gap: 6px; align-self: end; }

.map-how { margin: 10px 0; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.map-how > summary { cursor: pointer; color: var(--gold); }
.map-how h4 { margin: 12px 0 4px; }
.map-how ol { margin: 4px 0 4px 18px; padding: 0; color: var(--text); }
.map-how li { margin: 3px 0; }

.map-stale { margin: 6px 0 10px; padding: 8px 12px; border-left: 3px solid #F0B90B; background: rgba(240,185,11,0.08); border-radius: 4px; font-size: 13px; }
.map-stale.ok { border-left-color: #2EBD85; background: rgba(46,189,133,0.06); color: #848E9C; }
.map-stale ul { margin: 4px 0 0 18px; padding: 0; }

a.button { display: inline-block; background: #1E222D; border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; color: var(--text); text-decoration: none; }
a.button:hover { border-color: var(--gold); }
a.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
#help-dialog { max-width: 640px; background: var(--panel, #161A25); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 18px; }
#help-dialog::backdrop { background: rgba(0, 0, 0, .55); }

.assist { display: grid; grid-template-columns: var(--as-left, 230px) 8px minmax(0, 1fr) 8px var(--as-right, 380px); gap: 4px; align-items: stretch; }
.as-grip { cursor: col-resize; border-radius: 4px; min-height: 200px; position: relative; }
.as-grip::after { content: ""; position: absolute; top: 40px; bottom: 40px; left: 3px; width: 2px; border-radius: 1px; background: var(--line); }
.as-grip:hover::after, .as-grip.drag::after { background: var(--gold); }
.assist > aside, .assist > .assist-main { align-self: start; }
body.as-resizing { cursor: col-resize; user-select: none; }
@media (max-width: 1100px) { .assist { grid-template-columns: var(--as-left, 220px) 8px minmax(0, 1fr); } .assist-right { grid-column: 1 / -1; } .as-grip[data-grip="right"] { display: none; } }
@media (max-width: 800px) { .assist { grid-template-columns: 1fr; } .as-grip { display: none; } }
.as-chats { list-style: none; padding: 0; margin: 8px 0 0; }
.as-chats li { padding: 6px 8px; border-radius: 4px; cursor: pointer; color: var(--muted); font-size: 13px; }
.as-chats li:hover, .as-chats li.on { background: #1E222D; color: #fff; }
.as-log { max-height: 60vh; overflow-y: auto; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.as-msg { padding: 8px 12px; border-radius: 6px; line-height: 1.45; white-space: normal; max-width: 92%; }
.as-msg.user { background: #1B2A4A; align-self: flex-end; }
.as-msg.assistant { background: #1E222D; align-self: flex-start; }
.as-msg.retell { border-left: 3px solid var(--gold); }
.as-msg .as-at { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
#as-prov input, #as-roles input { width: 100%; }

.model-picker { zoom: var(--as-zoom, 1); position: fixed; z-index: 50; width: 520px; max-width: calc(100vw - 16px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.model-picker .row { justify-content: space-between; }
.model-picker ul { list-style: none; margin: 8px 0; padding: 0; max-height: 320px; overflow-y: auto; }
.model-picker li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 8px; border-radius: 4px; cursor: pointer; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.model-picker li:hover { background: #1E222D; }

.as-counter { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.as-counter b { color: var(--text); font-weight: 600; }

.cache-line { font-size: 12px; margin-top: 2px; }
.cache-ok { color: #2EBD85; }
.cache-warn { color: var(--gold); }
.cache-bad { color: #F6465D; }

#as-state.busy { color: var(--gold); font-weight: 600; }
#as-state.busy::before { content: "● "; animation: as-pulse 1s ease-in-out infinite; }
@keyframes as-pulse { 50% { opacity: .25; } }

.as-top { align-items: center; }
.as-font button { padding: 2px 8px; margin-left: 4px; }
.assist { zoom: var(--as-zoom, 1); }   /* A− / A+ масштабируют всю вкладку: разговор, поле ввода, кнопки, подсказки */
.as-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.as-chip { background: #1E222D; border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; font-size: 12px; }
.as-chip button { background: none; border: none; padding: 0 0 0 6px; color: var(--muted); cursor: pointer; }
.as-msg img { max-width: 320px; max-height: 240px; border-radius: 4px; display: block; margin: 4px 0; cursor: zoom-in; }
.as-msg .as-fname { display: inline-block; font-size: 12px; color: var(--muted); margin-right: 8px; }
#as-input.drop { outline: 2px dashed var(--gold); }

.as-msg.check { border-left: 3px solid #3AA0FF; }

.as-mode { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 6px 0 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.as-next { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }

.as-chats li { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.as-del { background: none; border: none; padding: 0 2px; cursor: pointer; opacity: .35; font-size: 13px; }
.as-chats li:hover .as-del, .as-del:hover, #as-prov .as-del { opacity: .9; }

#page-assist { max-width: none; }              /* вкладка «Помощник» — на всю ширину окна */
.assist-right { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; max-height: calc(100vh - 90px); overflow-y: auto; }
.assist-right .card { margin: 0; overflow-x: auto; }
.assist-right table { font-size: 12px; }
.assist-right input, .assist-right select { min-width: 0; width: 100%; }
.assist-main .as-log { max-height: calc(100vh - 380px); min-height: 240px; }
.assist-side { position: sticky; top: 0; max-height: calc(100vh - 90px); overflow-y: auto; }

table.act th, table.act td { white-space: nowrap; text-align: center; font-size: 12px; }
table.act td:first-child, table.act th:first-child { text-align: left; }
table.act tr.idle td { color: var(--muted); }
table.act tr.total td { border-top: 2px solid var(--line); font-weight: 600; }

.assist-main .as-log.empty { min-height: 0; margin: 4px 0; }

/* стоимость разговора */
.as-chat-r { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.as-cost { font-size: 11px; color: #9ACD32; background: #2A2E39; border-radius: 3px; padding: 1px 4px; white-space: nowrap; }
.as-chat-cost { margin: 4px 0; font-size: 12px; }

.as-check { margin: 8px 0 4px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.as-check.ok { background: rgba(0, 192, 135, 0.12); color: #00C087; }
.as-check.bad { background: rgba(226, 75, 74, 0.12); color: #F2777A; }
.as-dl { display: inline-block; margin: 6px 8px 2px 0; padding: 6px 12px; border-radius: 6px; background: #0052FF; color: #fff !important; text-decoration: none; font-weight: 600; }
.as-dl:hover { background: #2E6BFF; }

/* кто пишет файл для Glass — у кнопки «Собрать файл для Glass» */
#as-code-model.as-ok { color: #00C087; }
#as-code-model.as-warn { color: #F0B90B; }

/* страница «Файлы» */
.files-tab { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.files-tab th, .files-tab td { text-align: left; padding: 4px 8px; border-bottom: 1px solid #2a2f3a; vertical-align: top; }
.files-tab td:nth-child(4) { white-space: nowrap; }
