/* Operations — пульт ботов. Светлая и тёмная тема — по настройке устройства.
   Текст не мельче 14,5 px, для чтения — тёмный (на тёмной теме — светлый);
   серый — только у состояний и подсказок. Цвета состояния: зелёный — работает,
   красный — остановлен или ошибка, жёлтый — переходное или нет связи. */

@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/fira-sans-400-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/fira-sans-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/fira-sans-500-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/fira-sans-500-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/fira-sans-600-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/fira-sans-600-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/fira-sans-700-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Fira Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/fira-sans-700-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fira Sans Extra Condensed"; font-style: normal; font-weight: 800; font-display: swap; src: url("/fonts/fira-sans-xcond-800-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Fira Sans Extra Condensed"; font-style: normal; font-weight: 800; font-display: swap; src: url("/fonts/fira-sans-xcond-800-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --bg: #eceff3;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --ink: #15171b;
  --ink-2: #353a42;
  --muted: #5b616b;
  --line: #d3d8df;
  --line-strong: #b8bfc9;
  --accent: #2563eb;
  --accent-hover: #1d4fd0;
  --accent-ink: #ffffff;
  --accent-soft: #e5edfd;
  --ok: #11743f;
  --ok-soft: #dff3e7;
  --bad: #c2261f;
  --bad-soft: #fde8e7;
  --warn: #8a5300;
  --warn-soft: #fff0d2;
  --idle: #5b616b;
  --idle-soft: #e7eaee;
  --nav-bg: #14161a;
  --nav-ink: #e9ecf0;
  --nav-muted: #a8afb9;
  --nav-active: #ffffff;
  --log-bg: #101215;
  --log-ink: #dfe3e8;
  --log-time: #8b939e;
  --shadow: 0 1px 2px rgba(16, 20, 26, 0.06), 0 2px 8px rgba(16, 20, 26, 0.05);
  --radius: 14px;
  --radius-small: 10px;
  --body: "Fira Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fira Sans Extra Condensed", "Arial Narrow", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --nav-height: 64px;
  --sidebar: 232px;

  /* Категории уведомлений */
  --cat-alert: #c2261f;
  --cat-error: #d1452b;
  --cat-stop_loss: #b4235a;
  --cat-take_profit: #11743f;
  --cat-trailing: #0f7a7a;
  --cat-trade: #2563eb;
  --cat-signal: #6d3fd1;
  --cat-skip: #5b616b;
  --cat-system: #485466;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1114;
    --surface: #181b20;
    --surface-2: #20242a;
    --ink: #f2f4f6;
    --ink-2: #d2d7de;
    --muted: #a3aab4;
    --line: #2c3138;
    --line-strong: #3a4049;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-ink: #0b1020;
    --accent-soft: #1b2741;
    --ok: #46d08a;
    --ok-soft: #133524;
    --bad: #ff6b63;
    --bad-soft: #3d1715;
    --warn: #f6bd4c;
    --warn-soft: #3a2b0d;
    --idle: #a3aab4;
    --idle-soft: #262a31;
    --nav-bg: #0b0c0f;
    --log-bg: #0b0c0f;
    --shadow: none;
    --cat-alert: #ff6b63;
    --cat-error: #ff8a65;
    --cat-stop_loss: #ff6fa3;
    --cat-take_profit: #46d08a;
    --cat-trailing: #3cc8c8;
    --cat-trade: #7aa2ff;
    --cat-signal: #b195ff;
    --cat-skip: #a3aab4;
    --cat-system: #9fb0c8;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

body.has-overlay { overflow: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 600; }

.sprite { display: none; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  vertical-align: -4px;
}

.mono { font-family: var(--mono); font-size: 14.5px; }
.hint { color: var(--muted); font-size: 14.5px; }
.hint.inline { display: block; margin-top: 2px; }
.tone-ok { color: var(--ok); }
.tone-bad { color: var(--bad); }
.tone-warn { color: var(--warn); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.state-msg {
  margin: 32px 16px;
  text-align: center;
  color: var(--muted);
}

/* ——— Оболочка ——— */

.shell { min-height: 100dvh; }

.nav {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--nav-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav .brand { display: none; }

.nav-item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  color: var(--nav-muted);
  font-size: 14.5px;
  text-decoration: none;
}

.nav-item:hover { text-decoration: none; color: var(--nav-ink); }
.nav-item .icon { width: 24px; height: 24px; }
.nav-item.active { color: var(--nav-active); }
.nav-item.active .icon { color: #7aa2ff; }

.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.nav-count {
  position: absolute;
  top: 7px;
  left: calc(50% + 6px);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #ff5a4f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

.main {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1120px;
  margin: 0 auto;
  min-height: 60px;
  padding: 8px 16px;
}

.topbar-titles { flex: 1; min-width: 0; }

.topbar-title {
  margin: 0;
  font: 800 26px/1.1 var(--display);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle { color: var(--muted); font-size: 14.5px; }
.topbar-actions { display: flex; gap: 8px; flex: none; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  border-radius: 12px;
  color: var(--ink);
}

.icon-button:hover { background: var(--surface-2); text-decoration: none; }
.icon-button .icon { width: 24px; height: 24px; }

.screen {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
}

.screen-lead { margin: 0 0 14px; color: var(--ink-2); }

@media (min-width: 900px) {
  .nav {
    top: 0;
    right: auto;
    bottom: 0;
    width: var(--sidebar);
    height: auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding: 18px 12px;
    border-top: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .nav .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 20px;
    color: #fff;
    font: 800 26px/1 var(--display);
    text-decoration: none;
  }

  .nav .brand .icon { width: 28px; height: 28px; color: #46d08a; }

  .nav-item {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    height: 46px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 16px;
  }

  .nav-item.active { background: rgba(255, 255, 255, 0.08); }

  .nav-count { position: static; margin-left: auto; }

  .chip-row { flex-wrap: wrap; overflow: visible; }

  .main {
    margin-left: var(--sidebar);
    padding-bottom: 32px;
  }

  .topbar-inner { padding: 10px 28px; }
  .screen { padding: 22px 28px; }
}

/* ——— Кнопки и поля ——— */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: 500 16px/1.2 var(--body);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover { background: var(--surface-2); text-decoration: none; }
.button:disabled { opacity: 0.5; cursor: default; }
.button.small { min-height: 38px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.button.wide { width: 100%; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.button.danger-ghost { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.button.ghost:hover:not(:disabled) { background: var(--accent-soft); }

@media (max-width: 420px) {
  .topbar-actions .button span { display: none; }
  .topbar-actions .button { padding: 0 10px; }
}

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* На телефоне кнопки ряда — одинаковой ширины, по две в строке. */
@media (max-width: 560px) {
  .button-row { display: grid; grid-template-columns: 1fr 1fr; }
  .button-row .button { padding: 0 10px; }
  .button-row > :only-child { grid-column: 1 / -1; }
  .tab .icon { display: none; }
  .tab { padding: 0 10px; }
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.field.narrow { max-width: 220px; }
.field-label { font-weight: 500; color: var(--ink-2); font-size: 15px; }

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.3 var(--body);
}

.input.mono { font-family: var(--mono); font-size: 15px; }
textarea.input { resize: vertical; min-height: 96px; }
.input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 0; }
.input::placeholder { color: var(--muted); opacity: 0.8; }
.select { width: auto; min-width: 150px; padding-right: 30px; }

.form-error { margin: 0 0 12px; color: var(--bad); font-weight: 500; }

.search { position: relative; flex: 1; min-width: 180px; display: block; margin: 0; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 40px; }

/* Переключатель */
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 16px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .switch, .switch::after { transition: none; }
}

.toggle-list { display: flex; flex-direction: column; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.toggle-row:first-child { border-top: 0; }
.toggle-row.big { padding: 14px 0; }
.toggle-row.disabled, .toggle-row.locked { cursor: default; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle-title { font-weight: 600; font-size: 17px; }

/* ——— Блоки ——— */

.panel {
  margin: 0 0 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
}

.panel-title .icon { color: var(--muted); }
.panel > p { margin: 0 0 10px; }

.notice {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-small);
  background: var(--idle-soft);
}

.notice p { margin: 0 0 6px; }
.notice p:last-child { margin-bottom: 0; }
.notice.ok { background: var(--ok-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.warn { background: var(--warn-soft); }
.notice .button { margin-top: 8px; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}

.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }

.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.danger-row:first-of-type { border-top: 0; padding-top: 0; }

@media (max-width: 560px) {
  .danger-row { flex-direction: column; align-items: stretch; }
}

/* ——— Метки ——— */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  background: var(--idle-soft);
  color: var(--idle);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.status-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.status-pill.big { font-size: 17px; padding: 6px 14px 6px 12px; }
.status-pill.tone-ok { background: var(--ok-soft); color: var(--ok); }
.status-pill.tone-ok .dot { box-shadow: 0 0 0 0 currentColor; animation: live 2s infinite; }
.status-pill.tone-bad { background: var(--bad-soft); color: var(--bad); }
.status-pill.tone-warn { background: var(--warn-soft); color: var(--warn); }

@keyframes live {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .status-pill.tone-ok .dot { animation: none; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--idle-soft);
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
}

.chip.tone-ok { background: var(--ok-soft); color: var(--ok); }
.chip.tone-bad { background: var(--bad-soft); color: var(--bad); }
.chip.tone-warn { background: var(--warn-soft); color: var(--warn); }
.chip.plain { background: var(--surface-2); color: var(--ink-2); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
}

.cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}

.cat::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--cat-color, var(--cat-system)); flex: none; }
.cat-alert { --cat-color: var(--cat-alert); }
.cat-error { --cat-color: var(--cat-error); }
.cat-stop_loss { --cat-color: var(--cat-stop_loss); }
.cat-take_profit { --cat-color: var(--cat-take_profit); }
.cat-trailing { --cat-color: var(--cat-trailing); }
.cat-trade { --cat-color: var(--cat-trade); }
.cat-signal { --cat-color: var(--cat-signal); }
.cat-skip { --cat-color: var(--cat-skip); }
.cat-system { --cat-color: var(--cat-system); }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 15px/1 var(--body);
  cursor: pointer;
}

.chip-toggle[class*="cat-"]::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--cat-color); }
.chip-toggle.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-toggle.clear { color: var(--accent); border-color: transparent; }
.chip-toggle .icon { width: 16px; height: 16px; }

/* ——— Главный экран ——— */

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.summary-item.link:hover { text-decoration: none; border-color: var(--accent); }
.summary-value { font: 800 30px/1.05 var(--display); }
.summary-value small { font-size: 20px; color: var(--ink-2); }
.summary-label { overflow-wrap: normal; }
.summary-item.tone-bad .summary-value { color: var(--bad); }
.summary-label { color: var(--ink-2); font-size: 14.5px; }

.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

@media (max-width: 420px) {
  .bot-grid { grid-template-columns: 1fr; }
  .summary { gap: 8px; }
  .summary-item { padding: 10px; }
  .summary-value { font-size: 26px; }
}

.bot-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.bot-card:hover { text-decoration: none; border-color: var(--accent); }
.bot-card.tone-ok { border-left-color: var(--ok); }
.bot-card.tone-bad { border-left-color: var(--bad); }
.bot-card.tone-warn { border-left-color: var(--warn); }

.bot-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kind-label { color: var(--muted); font-size: 14.5px; white-space: nowrap; }
.bot-card-name { display: flex; align-items: center; gap: 10px; }
.bot-name { font: 800 25px/1.1 var(--display); min-width: 0; }
.bot-card-meta { color: var(--ink-2); font-size: 15px; }

.bot-card-last {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.last-time { color: var(--muted); justify-self: end; font-size: 14.5px; }
.last-text { grid-column: 1 / -1; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.last-empty { grid-column: 1 / -1; color: var(--muted); }
.bot-card-muted { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14.5px; }

.empty {
  max-width: 460px;
  margin: 40px auto;
  text-align: center;
}

.empty > .icon { width: 56px; height: 56px; color: var(--muted); }
.empty h2 { margin: 12px 0 8px; font: 800 28px/1.1 var(--display); }
.empty p { margin: 0 0 20px; color: var(--ink-2); }

/* ——— Экран бота ——— */

.bot-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.bot-head-main { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.bot-head-uptime { font-weight: 500; color: var(--ink-2); }
.bot-head-facts { color: var(--ink-2); font-size: 15px; }
.bot-head-error { color: var(--bad); font-size: 15px; }
.bot-head-checked { color: var(--muted); font-size: 14.5px; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 -16px 16px;
  padding: 0 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 46px;
  padding: 0 12px;
  border-bottom: 3px solid transparent;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
}

.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .icon { width: 18px; height: 18px; }

@media (min-width: 900px) {
  .tabs { margin: 0 0 18px; padding: 0; }
}

.control { display: grid; gap: 0 16px; }
.control-block:empty { display: none; }

@media (min-width: 1100px) {
  .control { grid-template-columns: 1fr 1fr; align-items: start; }
}

.traders { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.trader-list { margin: 8px 0 0; padding: 0; list-style: none; }
.trader { padding: 10px 0; border-top: 1px solid var(--line); }
.trader:first-child { border-top: 0; }
.trader-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 2px; }
.trader.off b { color: var(--ink-2); }

.extras { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

.extra-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.tickers { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.tickers-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.ticker-list { display: flex; flex-wrap: wrap; gap: 6px; }

.ticker-list.editable {
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}

.ticker {
  min-width: 64px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font: 500 14.5px/1.2 var(--mono);
  text-align: center;
}

.ticker.on { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 55%, transparent); color: var(--ok); }
button.ticker { cursor: pointer; }

.ticker-editor .filter-row { margin-bottom: 10px; }
.ticker-diff { margin-top: 10px; color: var(--ink-2); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row .select { flex: 1 1 150px; }

/* ——— Лента ——— */

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.day {
  margin: 18px 0 8px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
}

.day:first-child { margin-top: 0; }

.events, .audit-list { display: flex; flex-direction: column; gap: 8px; }

.event, .audit {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.event.unread { border-left: 4px solid var(--accent); }
.event.alert { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.event.focus { outline: 3px solid var(--accent); outline-offset: 1px; }

.event-head, .audit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 6px;
}

.event-time, .audit-time { font-family: var(--mono); font-size: 14.5px; color: var(--muted); }
.event-bot { font-weight: 600; font-size: 15px; color: var(--ink); }
a.event-bot { color: var(--accent); }

.event-text {
  white-space: pre-wrap;
  font-size: 15.5px;
  line-height: 1.5;
}

.event-text.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event .link-button { margin-top: 6px; }

.audit.failed { border-left: 4px solid var(--bad); }
.audit-result { display: inline-flex; align-items: center; gap: 4px; font-size: 14.5px; font-weight: 600; }
.audit-result .icon { width: 16px; height: 16px; }
.audit-title { font-size: 16px; }
.audit-detail { margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.audit-message { margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.audit.failed .audit-message { color: var(--bad); }
.audit-device { margin-top: 6px; color: var(--muted); font-size: 14.5px; }

/* ——— Журнал ——— */

.log-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.log-toolbar .search { min-width: 160px; }
.log-status { display: flex; align-items: center; gap: 8px; min-height: 26px; margin-bottom: 6px; color: var(--ink-2); font-size: 14.5px; }

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  animation: live 2s infinite;
  color: var(--ok);
}

.log {
  height: 60vh;
  overflow: auto;
  padding: 8px 0;
  border-radius: var(--radius-small);
  background: var(--log-bg);
  color: var(--log-ink);
  font: 14.5px/1.45 var(--mono);
  overscroll-behavior: contain;
}

.log-line {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 12px;
  padding: 1px 12px;
}

.log-line:hover { background: rgba(255, 255, 255, 0.04); }
.log-time { color: var(--log-time); user-select: none; }
.log-msg { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.log-line.err .log-msg { color: #ff8a80; }
.log-line.warn .log-msg { color: #ffd479; }
.log .state-msg { color: var(--log-time); }
.log-more { margin: 4px 12px 8px; color: #8fb0ff; }

@media (max-width: 560px) {
  .log { font-size: 14.5px; }
  .log-line { grid-template-columns: 1fr; gap: 0; padding: 3px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
}

/* ——— Позиции ——— */

.report-chips { margin-bottom: 14px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th {
  padding: 8px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .row-bad td { background: var(--bad-soft); }

.signal-list { margin: 0; padding: 0; list-style: none; }

.signal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}

.signal:first-child { border-top: 0; }
.signal-time { color: var(--muted); font-family: var(--mono); font-size: 14.5px; }
.signal-reason { flex-basis: 100%; color: var(--ink-2); font-size: 14.5px; }

/* ——— Подключение ——— */

.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }

.step {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-2);
}

.step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.step-title { font-weight: 600; font-size: 16.5px; }
.step-where { color: var(--muted); font-size: 14.5px; }
.step .hint { margin: 0 0 8px; }

.code-block { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.code {
  width: 100%;
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--log-bg);
  color: var(--log-ink);
  font: 14.5px/1.5 var(--mono);
  white-space: pre;
}

/* ——— Добавление бота ——— */

.form { max-width: 720px; }

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }

.kind-choice {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.kind-choice legend { margin-bottom: 8px; padding: 0; }

.kind-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  cursor: pointer;
}

.kind-option input { position: absolute; opacity: 0; pointer-events: none; }
.kind-option.on, .kind-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.kind-option:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.kind-title { font-weight: 600; font-size: 16.5px; }
.kind-text { color: var(--ink-2); font-size: 14.5px; }

/* ——— Настройки ——— */

.settings { max-width: 760px; }
.status-line { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.device-list { margin: 0; padding: 0; list-style: none; }

.device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.device:first-child { border-top: 0; padding-top: 0; }
.device-name { font-weight: 600; }

/* ——— Вход ——— */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 16px;
  background: var(--nav-bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 24px;
  border-radius: 18px;
  background: var(--surface);
}

.login-brand { display: flex; align-items: center; gap: 10px; font: 800 34px/1 var(--display); }
.login-brand .icon { width: 34px; height: 34px; color: var(--ok); }
.login-lead { margin: 10px 0 22px; color: var(--ink-2); }

.boot-error { max-width: 420px; margin: 80px auto; padding: 16px; text-align: center; }

/* ——— Окна и сообщения ——— */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(8, 10, 14, 0.55);
}

.dialog {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--ink);
}

@media (min-width: 640px) {
  .overlay { align-items: center; }
  .dialog { border-radius: 18px; padding-bottom: 20px; }
}

.dialog-title { margin: 0 0 10px; font-size: 20px; font-weight: 600; line-height: 1.25; }
.dialog-text { margin: 0 0 14px; color: var(--ink-2); font-size: 16px; }
.dialog-list { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); }
.dialog-list li { margin-bottom: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 639px) {
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 14px);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #1f2329;
  color: #fff;
  font-size: 15.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8e1d18; }
.toast .icon { color: #7ee2a8; }
.toast.error .icon { color: #ffd0cc; }

@media (min-width: 900px) {
  .toast { bottom: 24px; left: calc(50% + var(--sidebar) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
