/* Hydra — панель владельца.
   Premium true-black: чистый чёрный холст, тонкие линии-волоски вместо заливок,
   холодный циан как сигнал (а не украшение), плотная сетка профи-инструмента.
   Шрифт — Geologica (характерный гротеск с кириллицей). Без зависимостей. */

/* ----------------------------------------------------------------- Токены */
:root {
  /* Тёмно-серый холст; поверхности приподняты светлее фона */
  --bg:          #1c1f25;
  --bg-sidebar:  #17191e;
  --surface:     #23262e;
  --surface-2:   #2b2f38;
  --surface-3:   #353a45;

  /* Границы — волоски по белому */
  --border:       rgba(255,255,255,.10);
  --border-soft:  rgba(255,255,255,.06);
  --border-hard:  rgba(255,255,255,.18);

  --text:        #eceef1;
  --text-muted:  #9a9ea7;
  --text-dim:    #6b6f78;

  /* Монохромный акцент — сигнал через светлоту и контраст, без цвета */
  --accent:        #eceef1;
  --accent-hover:  #ffffff;
  --accent-ink:    #16181d;            /* тёмный текст на светлой заливке */
  --accent-soft:   rgba(255, 255, 255, 0.09);
  --accent-line:   rgba(255, 255, 255, 0.22);
  --fill:          #b6bac3;            /* заливка прогресс-баров — спокойный серый */

  --success: #36d399;  --success-soft: rgba(54, 211, 153, 0.12);
  --warning: #e8b53d;  --warning-soft: rgba(232, 181, 61, 0.12);
  --danger:  #fa5e5e;  --danger-soft:  rgba(250, 94, 94, 0.12);
  --info:    #8fb0c4;  --info-soft:    rgba(143, 176, 196, 0.12);
  --neutral: #9a9ea7;  --neutral-soft: rgba(154, 158, 167, 0.12);

  --radius:    8px;
  --radius-sm: 5px;
  --radius-xs: 4px;

  --font: "Geologica", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ------------------------------------------------------------------ Базис */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.mono  { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.is-hidden { display: none !important; }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* Скроллбары под тёмную тему */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px;
  border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #434855; }

/* ------------------------------------------------------------- Раскладка */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }

/* --------------------------------------------------------------- Сайдбар */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  padding: 16px 12px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand__logo {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--accent-ink); font-weight: 700; font-size: 12px; letter-spacing: .04em;
}
.brand__name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand__sub  { font-size: 10px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .12em; margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--text-dim); padding: 16px 10px 6px;
}
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 450;
  transition: background .12s, color .12s;
}
.nav__item:hover { background: rgba(255,255,255,.035); color: var(--text); }
.nav__item.is-active {
  background: rgba(255,255,255,.045); color: var(--text); font-weight: 550;
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav__item.is-active .nav__icon { color: var(--accent); }
.nav__icon { width: 16px; height: 16px; flex: none; color: currentColor; opacity: .9; }
.nav__item .badge { margin-left: auto; }
.sidebar__foot {
  margin-top: auto; padding: 12px 10px 2px;
  font-size: 10px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .1em;
  border-top: 1px solid var(--border-soft);
}

/* ----------------------------------------------------------------- Топбар */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: rgba(23,26,32,.72); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar__title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar__spacer { flex: 1; }
.capacity {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 11px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.capacity__label { font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em; }
.capacity__val { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.capacity .bar { width: 60px; }
.owner {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text-muted); font-size: 12.5px;
}
.owner__avatar {
  width: 24px; height: 24px; border-radius: var(--radius-xs);
  background: var(--surface-2); border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  color: var(--text); font-size: 11px; font-weight: 600;
}
.owner__logout {
  background: none; border: 0; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0; font-family: inherit; line-height: 1;
  transition: color .12s;
}
.owner__logout:hover { color: var(--danger); }

/* --------------------------------------------------------------- Контент */
.content { padding: 20px; max-width: 1280px; width: 100%; }
.content > * + * { margin-top: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { font-size: 19px; }
.page-head__spacer { flex: 1; }

.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 13.5px; font-weight: 600; }
.section-head .muted { font-size: 12px; }
.section-head__spacer { flex: 1; }

/* --------------------------------------------------------------- Карточки */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; }
.card--tight { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-soft); }
.card__head h2 { font-size: 13px; font-weight: 600; }
.card__head .link, .card__head .section-head__spacer + .link { margin-left: auto; }
.link { color: var(--accent); font-size: 12.5px; font-weight: 500; transition: color .12s; }
.link:hover { color: var(--accent-hover); }

/* ------------------------------------------------------------------- KPI */
.grid-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; }
.kpi__label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); }
.kpi__value { font-size: 26px; font-weight: 600; margin-top: 8px;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.kpi__sub { margin-top: 10px; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi__sub .dot-sep { color: var(--text-dim); }

/* ----------------------------------------------------- Опс-консоль (обзор) */
/* Единый бордюр, разбитый тонкими волосками, вместо россыпи плавающих карточек:
   слева — рабочая область (кампании-герой), справа — узкая колонка состояния. */
.console { display: grid; grid-template-columns: minmax(0, 1fr) 312px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; }
.console__main { min-width: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; }
.console__rail { display: flex; flex-direction: column; }

/* Секция консоли с тонким заголовком-меткой */
.panel { border-bottom: 1px solid var(--border-soft); }
.panel:last-child { border-bottom: 0; }
.console__main > .panel:last-child { flex: 1; }
.panel__head { display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border-soft); }
.panel__title { font-size: 10px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-muted); font-weight: 600; }
.panel__meta { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.panel__body { padding: 14px 16px; }
.spacer { flex: 1; }

/* Пары ключ→значение (правая сводка) — цифры встроены в строку, не в плитки */
.kv { display: flex; flex-direction: column; }
.kv__row { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.kv__row:last-child { border-bottom: 0; }
.kv__k { font-size: 12.5px; color: var(--text-muted); }
.kv__main { display: flex; flex-direction: column; align-items: flex-end; }
.kv__v { font-size: 17px; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kv__sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; white-space: nowrap; }

@media (max-width: 980px) {
  .console { grid-template-columns: 1fr; }
  .console__main { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ---------------------------------------------------------------- Воронка */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel__row { display: grid; grid-template-columns: 92px 1fr 70px 56px;
  align-items: center; gap: 12px; font-size: 12.5px; }
.funnel__name { color: var(--text-muted); }
.funnel__track { height: 6px; background: var(--surface-3);
  border-radius: 2px; overflow: hidden; }
.funnel__fill { height: 100%; background: var(--fill); border-radius: 2px; }
.funnel__val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel__pct { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ Бар */
.bar { height: 5px; background: var(--surface-3);
  border-radius: 2px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--fill); border-radius: 2px; }
.bar__fill.is-warm { background: var(--warning); }
.bar__fill.is-danger { background: var(--danger); }

/* --------------------------------------------------------------- Таблицы */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted);
  padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border-soft);
  font-size: 13px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255,255,255,.022); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .name { font-weight: 550; }
.table a.name:hover { color: var(--accent-hover); }
.table--rows tbody tr { cursor: default; }

/* ---------------------------------------------------------------- Бейджи */
.badge { display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  border-radius: var(--radius-xs);
  background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.is-bare { text-transform: none; letter-spacing: 0; }
.badge.is-bare::before { display: none; }
.badge.is-success { background: var(--success-soft); color: var(--success); }
.badge.is-warning { background: var(--warning-soft); color: var(--warning); }
.badge.is-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge.is-info    { background: var(--info-soft);    color: var(--info); }
.badge.is-accent  { background: var(--accent-soft);  color: var(--accent-hover); }
.badge.is-neutral { background: var(--neutral-soft); color: var(--neutral); }

/* ---------------------------------------------------------------- Кнопки */
.btn { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text); font-size: 12.5px; font-weight: 550; cursor: pointer;
  font-family: inherit; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: rgba(255,255,255,.045); border-color: var(--border-hard); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: rgba(255,255,255,.045); border-color: transparent; }
.btn--danger { background: transparent; border-color: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--sm { padding: 6px 11px; font-size: 12px; }
.btn__icon { width: 15px; height: 15px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------- Алерты */
.alerts { display: flex; flex-direction: column; }
.alert { display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.alert:last-child { border-bottom: 0; }
.alert__dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: none; }
.alert.is-danger  .alert__dot { background: var(--danger); }
.alert.is-warning .alert__dot { background: var(--warning); }
.alert.is-info    .alert__dot { background: var(--info); }
.alert__title { font-size: 13px; }
.alert__meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* --------------------------------------------------- Мини-список серверов */
.srv { display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border-soft); }
.srv:last-child { border-bottom: 0; }
.srv__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.srv__dot.is-active { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.srv__dot.is-error  { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-soft); }
.srv__dot.is-idle   { background: var(--neutral); box-shadow: 0 0 0 3px var(--neutral-soft); }
.srv__main { min-width: 0; flex: 1; }
.srv__domain { font-size: 12.5px; font-weight: 550; }
.srv__meta { font-size: 11px; color: var(--text-muted); margin-top: 3px;
  display: flex; align-items: center; gap: 6px; }
.srv__cap { width: 96px; flex: none; text-align: right; }
.srv__cap .bar { margin-top: 5px; }
.srv__capval { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------- Серверы — карточки */
.srv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.srv-card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; }
.srv-card__head { display: flex; align-items: center; gap: 10px; }
.srv-card__name { font-weight: 600; }
.srv-card__head .badge { margin-left: auto; }
.srv-card__rows { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.srv-card__row { display: flex; justify-content: space-between; font-size: 12.5px; }
.srv-card__row .k { color: var(--text-muted); }
.srv-card__foot { display: flex; align-items: center; gap: 8px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border-soft); }

/* ---------------------------------------------------------- Фильтры/чипсы */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar__spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 12px; background: transparent; cursor: pointer; transition: background .12s, color .12s; }
.chip:hover { background: rgba(255,255,255,.045); color: var(--text); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-hover); }
.search { display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 10px; transition: border-color .12s; }
.search:focus-within { border-color: var(--accent-line); }
.search input { background: none; border: 0; color: var(--text);
  padding: 8px 2px; font-size: 12.5px; outline: none; min-width: 200px; font-family: inherit; }
.search svg { width: 15px; height: 15px; color: var(--text-dim); }

/* ----------------------------------------------------------------- Формы */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field__hint { font-size: 11.5px; color: var(--text-dim); }
.field__error { font-size: 11.5px; color: var(--danger); }
.input, input[type=text], input[type=email], input[type=url], input[type=password],
input[type=datetime-local], input[type=number], textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 9px 11px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
textarea.code { font-family: var(--font-mono); font-size: 12.5px; min-height: 320px; }
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--text-dim); }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text); }
.checks input { width: auto; }
/* Рендер CheckboxSelectMultiple — это <ul><li><label><input>. */
.field ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.field li label { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text); }
.field li input[type=checkbox] { width: auto; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
input[type=file] { width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted); padding: 9px 11px; font-size: 12.5px; }
input[type=file]::file-selector-button { background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 5px 10px; margin-right: 10px;
  cursor: pointer; font-family: inherit; }
.form__actions { display: flex; gap: 10px; align-items: center;
  padding-top: 14px; border-top: 1px solid var(--border-soft); margin-top: 4px; }
.form__actions .toolbar__spacer { flex: 1; }

/* --------------------------------------------------------- Превью письма */
.preview { background: #fff; color: #111; border-radius: var(--radius-sm);
  padding: 18px; min-height: 320px; overflow: auto; }
.preview__bar { font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; }

/* --------------------------------------------------------- Импорт (dropzone) */
/* Селектор "label.dropzone" (не просто .dropzone) специально совпадает по
   специфичности с ".field > label" и стоит ниже по файлу — иначе общий стиль
   подписи поля (мелкий приглушенный текст) перебивает вид дропзоны, когда
   она используется как <label for=...> (клик открывает диалог без JS). */
label.dropzone { border: 1px dashed var(--border-hard); border-radius: var(--radius);
  padding: 28px; text-align: center; background: var(--surface); cursor: pointer;
  display: block; font-size: 13px; font-weight: 400; color: var(--text);
  transition: border-color .12s, background .12s; }
.dropzone:hover { border-color: var(--accent-line); }
.dropzone:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone.is-drag { border-color: var(--accent-line); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; }
.dropzone svg { width: 30px; height: 30px; color: var(--text-dim); }
.dropzone__hint { color: var(--text-muted); font-size: 12.5px; margin-top: 8px; }
.dropzone__filename { margin-top: 10px; font-size: 13px; color: var(--text); font-weight: 500; }
.dropzone__input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.result { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; }
.result__val { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em; }
.result__label { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* -------------------------------------------------------------- Сообщения */
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface); }
.msg--success { border-color: var(--success-soft); background: var(--success-soft); color: var(--success); }
.msg--error, .msg--danger { border-color: var(--danger-soft); background: var(--danger-soft); color: var(--danger); }
.msg--warning { border-color: var(--warning-soft); background: var(--warning-soft); color: var(--warning); }
.msg--info { border-color: var(--info-soft); background: var(--info-soft); color: var(--info); }

/* ------------------------------------------------------------- Пагинация */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 14px; color: var(--text-muted); font-size: 12.5px; }
.pagination a { padding: 6px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted); transition: background .12s, color .12s; }
.pagination a:hover { background: rgba(255,255,255,.045); color: var(--text); }

/* ---------------------------------------------------- Пустые состояния */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty svg { width: 36px; height: 36px; color: var(--text-dim); margin-bottom: 12px; }
.empty h3 { font-size: 14px; color: var(--text); margin-bottom: 6px; }

/* --------------------------------------------------------------- Метрики */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; }
.metric__label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.metric__value { font-size: 22px; font-weight: 600; margin-top: 6px;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric__sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* --------------------------------------------------------------- Логин */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60% 60% at 50% 0%, rgba(255,255,255,.04), transparent 70%),
    var(--bg); }
.auth__card { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.auth__title { font-size: 17px; font-weight: 600; margin: 16px 0 4px; letter-spacing: -0.02em; }
.auth__sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 20px; }
.auth .form { gap: 14px; }
.auth .btn { width: 100%; justify-content: center; }

/* -------------------------------------------------------------- Утилиты */
.row { display: flex; align-items: center; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.trend-up   { color: var(--success); }
.trend-down { color: var(--danger); }
code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2);
  padding: 1px 5px; border-radius: var(--radius-xs); color: var(--text); }

/* -------------------------------------------- Редактор шаблона письма */
/* Слева — код вёрстки, справа — живое превью письма (iframe).            */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  align-items: stretch; height: calc(100vh - 250px); min-height: 420px; }
.editor__pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor__bar { display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.editor__bar .dim { color: var(--text-dim); text-transform: none;
  letter-spacing: 0; font-size: 11.5px; }
.editor__bar .dim code { background: none; padding: 0; color: var(--text-muted); }
.editor textarea.code { flex: 1; height: 100%; min-height: 0; resize: none; margin: 0; }
.preview-frame { flex: 1; width: 100%; min-height: 0; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Панель «примерных значений» для плейсхолдеров {{ … }} над превью. */
.merge-panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.merge-panel__head { font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-bottom: 8px; }
.merge-fields { display: flex; flex-direction: column; gap: 6px;
  max-height: 140px; overflow: auto; }
.merge-row { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 10px; }
.merge-row__key { font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merge-row input { padding: 6px 9px; font-size: 12.5px; }

@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor textarea.code { min-height: 320px; }
  .preview-frame { min-height: 360px; }
}

/* ====================================================== Дашборд v2 ====== */
/* Просторный обзор: KPI-полоса, кампании с рельсом, воронка+пончик, два
   равноправных канала (Postal/Resend), активность за период. Всё на токенах,
   монохромный акцент, без зависимостей. */

/* KPI-полоса: 6 крупных карточек, переносятся на узких экранах */
.dash-kpis { display: grid; gap: 12px; grid-template-columns: repeat(6, 1fr); }
.dash-kpis .metric__value { font-size: 24px; }
.metric__value.tone-success { color: var(--success); }
.metric__value.tone-warning { color: var(--warning); }
.metric__value.tone-danger  { color: var(--danger); }

/* Широкая секция (кампании/активность) + узкий рельс справа */
.dash-row { display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 340px; }

/* Действия в шапке карточки — прижаты вправо без конфликта с .card__head .link */
.dash-head__actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.dash-head__actions .link { margin-left: 0; }

/* Тело карточки с отступами (аналог .panel__body для .card) */
.card__body { padding: 14px 16px; }

/* Строка-ссылка в рельсе (проблемные / лучшие кампании) */
.dash-item { display: flex; align-items: center; gap: 11px;
  padding: 11px 16px; border-bottom: 1px solid var(--border-soft);
  transition: background .12s; }
.dash-item:last-child { border-bottom: 0; }
.dash-item:hover { background: rgba(255,255,255,.022); }
.dash-item__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dash-item__dot.is-danger  { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-soft); }
.dash-item__dot.is-warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.dash-item__dot.is-info    { background: var(--info);    box-shadow: 0 0 0 3px var(--info-soft); }
.dash-item__main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.dash-item__name { font-size: 12.5px; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-item:hover .dash-item__name { color: var(--accent-hover); }
.dash-item__meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.dash-item__val { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Пустые мини-блоки внутри карточек */
.dash-empty { padding: 16px; font-size: 12.5px; }

/* Воронка (широкая) + пончик доставляемости (узкий) */
.dash-funnel { display: grid; gap: 16px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 280px; }

/* Утечки снизу воронки: отписки / жалобы / bounce */
.leaks { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--border-soft); }
.leak { display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 7px 11px; }
.leak__val { font-weight: 600; font-variant-numeric: tabular-nums; }
.leak__rate { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Пончик доставляемости (inline SVG + stroke-dasharray) */
.donut-body { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut { position: relative; width: 120px; height: 120px; }
.donut__center { position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center; }
.donut__val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; }
.donut__label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); margin-top: 2px; }
.donut__legend { width: 100%; display: flex; flex-direction: column; gap: 9px; }

/* Два равноправных канала отправки */
.dash-channels { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.chan-cap { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); }
.chan-cap__row { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; margin-bottom: 8px; }

/* Активность: сегодня крупно + за 7 дней мелко */
.act-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.act { padding: 16px; border-right: 1px solid var(--border-soft); }
.act:last-child { border-right: 0; }
.act__label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted); }
.act__today { font-size: 24px; font-weight: 600; margin-top: 8px;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.act__week { font-size: 11.5px; color: var(--text-muted); margin-top: 4px;
  font-variant-numeric: tabular-nums; }

/* Адаптив: ужимаем сетки на узких экранах */
@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(3, 1fr); }
  .dash-row { grid-template-columns: 1fr; }
  .dash-funnel { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-channels { grid-template-columns: 1fr; }
  .act-grid { grid-template-columns: repeat(2, 1fr); }
  .act:nth-child(2) { border-right: 0; }
  .act:nth-child(-n+2) { border-bottom: 1px solid var(--border-soft); }
}

/* ================================================ Адаптив (каркас) ====== */
/* Каркас сворачивается в off-canvas drawer, сетки ужимаются в один-два
   столбца, плотные таблицы кампаний/контактов превращаются в карточки.
   Приоритет — телефон (от 360px); планшеты сохраняют полноразмерный сайдбар. */

/* Бургер и затемнение видны только в drawer-режиме (по умолчанию скрыты) */
.topbar__burger {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: -6px; flex: none;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  transition: background .12s, color .12s;
}
.topbar__burger:hover { background: rgba(255,255,255,.045); color: var(--text); }
.topbar__burger svg { width: 19px; height: 19px; }
.scrim { display: none; }

/* -------- Планшеты и телефоны: сайдбар уезжает в drawer --------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: 256px;
    z-index: 60; overflow-y: auto; transform: translateX(-100%);
    transition: transform .22s ease; will-change: transform;
  }
  .app.nav-open .sidebar {
    transform: translateX(0); box-shadow: 16px 0 48px rgba(0,0,0,.5);
  }

  .scrim {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,.5); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }

  .topbar__burger { display: inline-flex; }

  /* Сетки без собственного адаптива — в два/один столбец */
  .grid-kpi, .metric-grid, .result-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
}

/* -------- Телефоны: финальная подгонка плотности --------------------- */
@media (max-width: 600px) {
  .content { padding: 14px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .capacity { display: none; }
  .owner { padding: 4px 6px 4px 8px; }
  .owner__name { display: none; }

  .page-head { flex-wrap: wrap; row-gap: 10px; }
  .page-head__spacer { display: none; }

  /* Шапки карточек: заголовок/мета и действия переносятся, не сплющиваются */
  .card__head { flex-wrap: wrap; row-gap: 8px; }
  .panel__head { flex-wrap: wrap; row-gap: 8px; }

  /* Поиск на всю ширину под чипсами */
  .toolbar .search { width: 100%; }
  .toolbar .search input { min-width: 0; flex: 1; }

  .merge-row { grid-template-columns: 96px 1fr; }
  .funnel__row { grid-template-columns: 60px 1fr 44px 40px; gap: 8px; font-size: 11.5px; }

  /* Таблицы-карточки: строка → карточка «ключ → значение» */
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody { display: block; }
  .table--cards tbody tr {
    display: block; position: relative;
    padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
  }
  .table--cards tbody tr:last-child { border-bottom: 0; }
  .table--cards tbody tr:hover td { background: transparent; }
  .table--cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 3px 0; border: 0; text-align: right;
  }
  .table--cards td::before {
    content: attr(data-label); text-align: left;
    color: var(--text-muted); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
  }
  .table--cards td:empty { display: none; }
  .table--cards td.cell-primary {
    display: block; padding: 0 28px 8px 0; text-align: left;
    font-size: 14px; font-weight: 600;
  }
  .table--cards td.cell-primary::before { display: none; }
  .table--cards td.cell-check { position: absolute; top: 12px; right: 16px; padding: 0; }
  .table--cards td.cell-check::before { display: none; }
}

/* -------- Узкие телефоны: KPI и метрики в один столбец --------------- */
@media (max-width: 380px) {
  .grid-kpi, .metric-grid, .result-grid { grid-template-columns: 1fr; }
}
