/* ===================================================================
   OpenTracker — дизайн-система (light / shadcn dashboard)
   Нейтральная светлая палитра, тонкие границы, мягкие тени,
   монохромный primary, воздух и спокойная типографика.
   =================================================================== */
:root {
  --bg: #f7f7f8;
  --bg-soft: #fafafa;
  --panel: #ffffff;
  --panel2: #f4f4f5;
  --panel3: #e9e9ec;
  --card: var(--panel);
  --border: #e7e7ea;
  --border-strong: #d6d7db;
  --text: #111113;
  --fg: var(--text);
  --text2: #71717a;
  --muted: #71717a;
  --accent: #111113;
  --accent-hover: #2a2a2e;
  --accent-dim: #f1f1f3;
  --green: #15803d;
  --red: #b91c1c;
  --yellow: #a16207;
  --orange: #b45309;
  --blue: #1d4ed8;
  --grid: rgba(17, 17, 19, 0.07);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 12px 32px rgba(17, 17, 19, 0.06);
  --shadow-sm: 0 1px 2px rgba(17, 17, 19, 0.05);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::selection { background: rgba(17, 17, 19, 0.14); }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font: 14px/1.55 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  letter-spacing: -0.011em;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 20px; margin-top: 10px; font-size: 13px; }
a { color: var(--text); text-decoration: none; transition: color 0.18s var(--ease); }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
code {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 12px;
  background: var(--panel2); padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--border);
}

:focus-visible { outline: 2px solid rgba(17, 17, 19, 0.35); outline-offset: 2px; }

/* тонкий скроллбар */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(17, 17, 19, 0.18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(17, 17, 19, 0.3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- логин ---------- */
.login-wrap {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
  background:
    radial-gradient(ellipse 60% 45% at 50% -8%, rgba(17, 17, 19, 0.06), transparent 62%),
    var(--bg);
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 42px 36px;
  width: 380px; max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: rise 0.45s var(--ease);
}
.login-box h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; margin-bottom: 6px; }
.login-box .icon.lg { color: var(--panel); background: var(--accent); border-radius: 8px; padding: 5px; width: 30px; height: 30px; }
.login-box input { margin: 26px 0 12px; text-align: center; }
.login-remember { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 18px; color: var(--muted); font-size: 13px; cursor: pointer; }
.login-box .login-remember input { width: 16px; height: 16px; margin: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- каркас ---------- */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px; min-width: 236px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 650; letter-spacing: -0.02em;
  padding: 4px 8px 16px; color: var(--text);
}
.logo .icon {
  width: 28px; height: 28px; padding: 6px; border-radius: 8px;
  background: var(--accent); color: #fff; flex: 0 0 28px;
  margin: 0; vertical-align: middle;
}
.logo .icon svg { stroke-width: 2.1; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; padding-bottom: 4px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: #9a9aa2; padding: 14px 10px 5px;
}
.sidebar nav .nav-label:first-child { padding-top: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: #4b4b53; font-weight: 500; font-size: 13px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar nav a:hover { background: var(--panel2); color: var(--text); }
.sidebar nav a:active { transform: scale(0.99); }
.sidebar nav a.active {
  background: var(--panel2); color: var(--text); font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.sidebar nav a.active .nav-icon { color: var(--text); }
.sidebar nav a.nav-off { opacity: 0.45; cursor: not-allowed; }
.sidebar nav a.nav-off:hover { background: none; color: #4b4b53; }
.sidebar nav a.nav-off:active { transform: none; }

main {
  flex: 1; min-width: 0; padding: 30px 34px 52px; max-width: 1520px; overflow-x: auto;
  background: var(--bg);
  animation: fade 0.25s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

h2 { font-size: 23px; font-weight: 650; letter-spacing: -0.03em; margin-bottom: 20px; }
h3 { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.summary-line {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); margin: -6px 0 16px;
}
.summary-line b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-line .summary-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- элементы форм ---------- */
input, select, textarea {
  width: 100%; padding: 8px 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
  color-scheme: light;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: #a1a1aa; background: var(--panel);
  box-shadow: 0 0 0 3px rgba(17, 17, 19, 0.07);
}
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2371717a' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px; cursor: pointer;
}
label {
  display: block; font-size: 12px; color: #52525b;
  margin: 14px 0 6px; font-weight: 500; letter-spacing: 0;
}
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px;
  cursor: pointer; background: var(--panel); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; letter-spacing: -0.005em;
  white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover { background: var(--panel2); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 14px rgba(17, 17, 19, 0.18); }
.btn.danger { background: transparent; border-color: rgba(185, 28, 28, 0.28); color: var(--red); box-shadow: none; }
.btn.danger:hover { background: #fef2f2; border-color: rgba(185, 28, 28, 0.45); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary:disabled { background: var(--panel3); color: #a1a1aa; border-color: transparent; opacity: 1; }
.empty-ico { width: 36px; height: 36px; margin: 0 auto 12px; color: #a1a1aa; }
.empty-ico .icon { width: 100%; height: 100%; }
h3 .icon { width: 16px; height: 16px; color: var(--muted); vertical-align: -2px; margin-right: 4px; }
label .icon { width: 13px; height: 13px; color: var(--muted); vertical-align: -2px; }

/* ---------- таблицы ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  font-variant-numeric: tabular-nums;
}
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
th {
  background: var(--bg-soft); color: var(--muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover td { background: #fbfbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.warn { color: var(--yellow); font-weight: 600; }

/* ---------- блок состояния сервера ---------- */
.server-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-top: 16px;
}
.server-item {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
}
.server-item .val { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 8px; }
.server-item .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.meter { height: 5px; background: var(--panel3); border-radius: 980px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 980px; transition: width 0.4s var(--ease); }
.meter-fill.pos { background: var(--green); }
.meter-fill.warn { background: #d97706; }
.meter-fill.neg { background: var(--red); }

/* ---------- график истории нагрузки ---------- */
.range-tabs { display: flex; gap: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.range-tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: 500 12px/1 inherit; padding: 6px 10px; border-radius: 6px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.range-tab:hover { color: var(--text); }
.range-tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.metrics-legend { display: flex; gap: 18px; margin: 14px 0 4px; flex-wrap: wrap; }
.metrics-legend .lg-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text); }
.metrics-legend .lg-item b { font-weight: 600; }
.metrics-legend .lg-item i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.metrics-chart { position: relative; margin-top: 6px; }
.metrics-chart svg { display: block; width: 100%; min-width: 560px; }
.mgrid { stroke: var(--grid); stroke-width: 1; }
.maxis { fill: var(--muted); font-size: 10.5px; }
.mcross { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.metrics-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 12px;
  box-shadow: var(--shadow); font-size: 12px;
}
.metrics-tip .tip-t { font-weight: 600; margin-bottom: 6px; }
.metrics-tip .tip-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.metrics-tip .tip-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500; letter-spacing: 0;
  background: var(--panel2); color: #52525b; border: 1px solid var(--border);
}
.tag.on { background: #ecfdf3; color: #15803d; border-color: #d1fae0; }
.tag.off { background: #fef2f2; color: #b91c1c; border-color: #fee2e2; }
.tag.pending { background: #fffbeb; color: #a16207; border-color: #fef3c7; }

/* ---------- карточки метрик ---------- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; margin-bottom: 20px;
}
.card {
  background: var(--panel); border-radius: 0; padding: 17px 18px;
  transition: background 0.15s var(--ease);
}
.card:hover { background: #fcfcfd; }
.card .muted, .card-label {
  font-size: 12px; color: var(--muted); font-weight: 500;
  display: flex; align-items: center; gap: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-label .icon { width: 14px; height: 14px; color: #9a9aa2; flex: none; }
.card .val {
  font-size: 27px; font-weight: 650; letter-spacing: -0.035em;
  margin-top: 8px; color: var(--text); font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.card .val.pos { color: var(--green); }
.card .val.neg { color: var(--red); }
.card .sub { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.card-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; margin-top: 7px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.card-delta.up { color: var(--green); }
.card-delta.down { color: #dc2626; }
.card-delta .arr { font-size: 11px; line-height: 1; }

/* одиночная KPI-карточка (используется в PRO и аналитике) */
.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 15px 16px;
}
.kpi .v { font-size: 23px; font-weight: 650; letter-spacing: -0.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- график ---------- */
.chart-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; margin-bottom: 18px;
  min-width: 0;
}
.chart-box > strong {
  display: block; font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
}
.chart-box > strong .icon { width: 15px; height: 15px; color: var(--muted); margin-right: 6px; vertical-align: -0.2em; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-head .chart-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.chart-ico {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-soft); color: var(--muted); flex: 0 0 28px;
}
.chart-ico .icon { width: 15px; height: 15px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 18px; align-items: start; }
.dash-grid > * { min-width: 0; }
.dash-grid > .chart-box { margin-bottom: 0; }
@media (max-width: 1180px) { .dash-grid { grid-template-columns: 1fr; } }

.bars { display: flex; align-items: flex-end; gap: 5px; height: 150px; margin-top: 16px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bar {
  width: 100%; max-width: 44px; min-width: 3px;
  background: #18181b;
  border-radius: 4px 4px 2px 2px; min-height: 2px;
  transition: opacity 0.15s var(--ease);
}
.bar-col:hover .bar { opacity: 0.72; }
.bar-lbl { font-size: 10px; color: var(--muted); white-space: nowrap; }
.bar-val { font-size: 10px; font-weight: 600; line-height: 1; white-space: nowrap; color: #3f3f46; }

/* ---------- модальные окна ---------- */
.modal-wrap {
  position: fixed; inset: 0;
  background: rgba(24, 24, 27, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; z-index: 100; overflow-y: auto;
  animation: fade 0.18s var(--ease);
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px; width: 100%; max-width: 720px;
  box-shadow: 0 24px 70px rgba(17, 17, 19, 0.18);
  animation: rise 0.28s var(--ease);
}
.modal h3 { margin-bottom: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.row { display: flex; gap: 14px; }
.row > * { flex: 1; }

/* ---------- редактор потоков ---------- */
.stream-box {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-top: 14px;
}
.stream-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stream-head strong { font-size: 13px; }
.mini-list { margin-top: 8px; }
.mini-row { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.mini-row select { flex: 3; } .mini-row input { flex: 1; }
.filters-box { margin-top: 10px; }

/* ---------- прочее ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.toolbar > div { min-width: 140px; }

.ck-summary {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; color: var(--muted);
}
.ck-summary b { color: var(--text); margin-right: 4px; }

.multi-select details { position: relative; }
.multi-select summary {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer;
  color: var(--text); font-size: 13px; min-width: 160px;
}
.multi-select summary:hover { border-color: var(--border-strong); }
.multi-options {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; min-width: 220px; max-height: 320px; overflow: auto;
  box-shadow: var(--shadow);
}
.multi-options label {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 6px; cursor: pointer;
  font-size: 13px; white-space: nowrap; color: var(--text);
}
.multi-options label:hover { background: var(--panel2); }
.multi-options input[type="checkbox"] { accent-color: var(--accent); }

.copy-box {
  background: var(--bg-soft); border: 1px dashed var(--border-strong);
  border-radius: 8px; padding: 9px 12px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 12px;
  word-break: break-all; cursor: pointer; margin-top: 6px; white-space: normal;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.copy-box:hover { border-color: #a1a1aa; background: var(--panel2); }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--accent); color: #fff;
  font-weight: 500; font-size: 13px;
  padding: 11px 16px; border-radius: 10px; z-index: 200;
  box-shadow: 0 10px 34px rgba(17, 17, 19, 0.22);
  animation: rise 0.28s var(--ease);
}
.toast .icon { color: #fff; }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.55; }
.table-scroll { overflow-x: auto; border-radius: 12px; max-width: 100%; scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 8px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* ---------- inline SVG icons ---------- */
.icon {
  display: inline-block;
  width: 1.05em; height: 1.05em;
  vertical-align: -0.18em;
  flex-shrink: 0;
}
.icon svg {
  width: 100%; height: 100%;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon.lg { width: 1.3em; height: 1.3em; vertical-align: -0.28em; }
.nav-icon { width: 16px; height: 16px; color: #9a9aa2; vertical-align: middle; }
.btn .icon { width: 14px; height: 14px; vertical-align: middle; }
.btn.sm .icon { width: 12px; height: 12px; }
.bot-icon { color: var(--muted); }

/* Карточки-переходы между сервисами в сайдбаре */
.nav-service {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-top: 4px;
  border-radius: 9px;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background .15s var(--ease), border-color .15s var(--ease);
}
.nav-service:hover { background: var(--bg-soft); border-color: var(--border-strong); text-decoration: none; }
.nav-service .icon { width: 16px; height: 16px; color: var(--muted); }
.nav-service .nav-arrow { width: 13px; height: 13px; margin-left: auto; color: #a1a1aa; opacity: 0.8; transition: transform .15s var(--ease), color .15s var(--ease); }
.nav-service:hover .nav-arrow { color: var(--text); transform: translateX(2px); }
.md-foot .nav-service { margin-top: 0; }
.bot-row { background: #fef2f2; }
.bot-row:hover { background: #fee2e2; }

.sidebar > .btn { margin-top: 4px; justify-content: flex-start; font-size: 13px; }

/* ---------- App Switcher (Tracker / TG Bots) ---------- */
.app-switch {
  display: flex; gap: 3px;
  padding: 3px; margin: 8px 4px 12px;
  background: var(--panel2);
  border-radius: 9px;
  border: 1px solid var(--border);
}
.app-switch-btn {
  flex: 1; padding: 6px 0; border: none; border-radius: 7px;
  background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 500; letter-spacing: 0; cursor: pointer;
  transition: all 0.15s var(--ease);
}
.app-switch-btn.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.app-switch-btn:hover:not(.active) { color: var(--text); }

/* ---------- TG Bot Selector ---------- */
.tg-bot-selector {
  display: inline-flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.tg-bot-selector .tbs-icon { display: flex; color: var(--muted); }
.tg-bot-selector .tbs-icon .icon { width: 18px; height: 18px; }
.tg-bot-selector label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; margin: 0;
}
.tg-bot-selector select {
  width: auto; min-width: 200px; max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 32px 7px 11px;
  font-size: 13px; font-weight: 500;
}
.tg-bot-selector select:focus { border-color: #a1a1aa; }

/* ---------- сортировка таблиц ---------- */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: '↕'; margin-left: 5px; font-size: 10px; opacity: .4; }
th.sortable[data-dir="desc"]::after { content: '↓'; opacity: 1; color: var(--text); }
th.sortable[data-dir="asc"]::after { content: '↑'; opacity: 1; color: var(--text); }

/* ---------- TG Chat UI ---------- */
.tg-chats-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 110px);
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}
.tg-chats-sidebar { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; }
.tg-chats-sidebar .chat-item {
  padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}
.tg-chats-sidebar .chat-item:hover { background: var(--bg-soft); }
.tg-chats-sidebar .chat-item.active { background: var(--panel2); }
.tg-chats-sidebar .chat-item .name { font-weight: 600; font-size: 13px; }
.tg-chats-sidebar .chat-item .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tg-chat-area { display: flex; flex-direction: column; min-width: 0; }
.tg-chat-header { padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--panel); font-weight: 600; font-size: 13.5px; }
.tg-chat-messages { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-soft); }
.tg-chat-msg { max-width: 70%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.tg-chat-msg.outgoing { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.tg-chat-msg.incoming { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.tg-chat-msg .time { font-size: 10px; opacity: 0.6; margin-top: 4px; }
.tg-chat-input { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel); display: flex; gap: 8px; }
.tg-chat-input textarea {
  flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); padding: 9px 12px; font-size: 13px; resize: none; min-height: 40px; max-height: 100px;
}
.tg-chat-input button { align-self: flex-end; }

/* ---------- TG Broadcast Progress ---------- */
.tg-progress-bar { height: 5px; background: var(--panel3); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.tg-progress-bar .fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }

/* ---------- TG Funnel Steps ---------- */
.tg-funnel-step {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; margin-bottom: 10px;
}
.tg-funnel-step .step-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tg-funnel-step .step-num { font-weight: 600; font-size: 12px; color: var(--text); background: var(--panel2); padding: 3px 8px; border-radius: 6px; }
.tg-funnel-step .step-delay { font-size: 11px; color: var(--muted); }
.tg-funnel-step .step-msg { font-size: 13px; white-space: pre-wrap; }

/* ---------- TG Status Badges ---------- */
.tg-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; border: 1px solid transparent; }
.tg-badge.active { background: #ecfdf3; color: #15803d; border-color: #d1fae0; }
.tg-badge.inactive { background: #fef2f2; color: #b91c1c; border-color: #fee2e2; }
.tg-badge.draft { background: var(--panel2); color: var(--muted); border-color: var(--border); }
.tg-badge.sending { background: #fffbeb; color: #a16207; border-color: #fef3c7; }
.tg-badge.completed { background: #ecfdf3; color: #15803d; border-color: #d1fae0; }
.tg-badge.scheduled { background: #eff6ff; color: #1d4ed8; border-color: #dbeafe; }
.tg-badge.pending { background: #fffbeb; color: #a16207; border-color: #fef3c7; }

/* Индекс вовлечённости 1–10 (inline background задаётся в JS) */
.eng-chip {
  display: inline-block; min-width: 46px; text-align: center;
  padding: 3px 8px; border-radius: 20px; color: #fff;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ---------- Nutra генератор текстов ---------- */
.nutra-grid { display: grid; grid-template-columns: minmax(400px, 500px) 1fr; gap: 20px; align-items: start; margin-bottom: 26px; }
@media (max-width: 1100px) { .nutra-grid { grid-template-columns: 1fr; } }

.design-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }
.design-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.design-card:hover { border-color: var(--border-strong); }
.design-card.selected { border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent); }
.design-card .dc-name { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.design-card.selected .dc-name { color: var(--text); }
.design-card .dc-desc { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

.photo-drop {
  display: flex; align-items: center; gap: 10px;
  border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; color: var(--muted); font-size: 12.5px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.photo-drop:hover { border-color: #a1a1aa; background: var(--panel2); }
.photo-drop img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.gen-result {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px;
  min-height: 320px; max-height: 560px; overflow-y: auto;
  white-space: pre-wrap; line-height: 1.65; font-size: 13.5px;
}
.gen-spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid var(--panel3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--border); }

/* ---------- Нутра: лендинги ---------- */
.ld-swatch { display: inline-block; width: 30px; height: 13px; border-radius: 4px; vertical-align: -2px; margin-right: 8px; border: 1px solid rgba(17, 17, 19, .15); }
.device-switch { display: inline-flex; gap: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.device-switch button {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; color: var(--muted);
  font: inherit; font-size: 12.5px; padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.device-switch button.active { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.preview-frame-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow: auto; }
#ld-frame {
  width: 100%; height: 720px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; display: block; transition: width .25s;
}
#ld-frame.mobile {
  width: 390px; height: 760px; margin: 0 auto; border-radius: 28px;
  border: 6px solid #27272a; box-shadow: 0 14px 40px rgba(17, 17, 19, .22);
}

/* ---------- Тонкая настройка стиля текста ---------- */
.style-box { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--bg-soft); }
.style-box summary { cursor: pointer; font-weight: 600; font-size: 13px; outline: none; }
.style-box summary:hover { color: var(--text); }
.style-presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.style-presets .btn { border-radius: 8px; padding: 5px 15px; font-size: 12.5px; }
.style-presets .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.style-adv { margin-top: 10px; }
.style-adv summary { cursor: pointer; font-size: 12px; color: var(--muted); outline: none; }
.style-adv summary:hover { color: var(--text); }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-top: 10px; }
.style-item label { margin: 0 0 4px; font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.style-item .sv { font-weight: 600; color: var(--text); font-size: 12px; min-width: 24px; text-align: right; }
.style-item input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; }
.style-item select { width: 100%; }
@media (max-width: 760px) { .style-grid { grid-template-columns: 1fr; } }

/* компактная форма нутра-генератора: группы + чекбоксы блоков */
.nt-form { padding: 20px; }
.nt-sec {
  display: flex; align-items: center; gap: 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 22px 0 8px;
}
.nt-form > .nt-sec:first-child { margin-top: 0; }
.nt-sec::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.blocks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; margin-top: 10px; }
.block-item {
  display: flex; align-items: center; gap: 7px; margin: 0; padding: 5px 8px;
  font-size: 12.5px; font-weight: 400; color: var(--text); cursor: pointer;
  border-radius: 7px; transition: background 0.15s var(--ease);
}
.block-item:hover { background: var(--panel2); }
.block-item input { width: auto; padding: 0; margin: 0; accent-color: var(--accent); }
@media (max-width: 900px) { .blocks-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Галерея AI-картинок лендинга ---------- */
.ai-images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.ai-img {
  position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  cursor: pointer; background: var(--panel); transition: border-color .15s, box-shadow .15s;
}
.ai-img:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.ai-img.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ai-img img { width: 100%; height: 120px; object-fit: cover; display: block; }
.ai-img p { margin: 0; padding: 8px 10px; font-size: 11px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ai-img-badge { position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.ai-img-err { cursor: default; border-style: dashed; opacity: .85; }
.ai-img-err:hover { border-color: var(--border-strong); box-shadow: none; }
.ai-img-err p { -webkit-line-clamp: 6; }
.ai-img-miss { height: 120px; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; color: var(--muted); background: var(--panel2); font-size: 12px; }

/* ---------- Button Builder ---------- */
.btn-builder { margin: 10px 0; padding: 10px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 9px; }
.btn-builder > label { font-weight: 600; font-size: 13px; margin-bottom: 8px; display: block; }
.btn-builder-rows { display: flex; flex-direction: column; gap: 8px; }
.btn-row { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.btn-row-items { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.btn-item {
  flex: 1; min-width: 160px; max-width: 250px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.btn-item input, .btn-item select { font-size: 12px; padding: 4px 6px; }
.btn-row-actions { display: flex; gap: 6px; }

/* ===================================================================
   Адаптивность (мобильные) — общая для Трекера, TG Bots и Sports CRM
   =================================================================== */
.burger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 36px; padding: 9px 9px; margin-left: auto; flex: 0 0 auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.burger span { display: block; height: 2px; width: 100%; background: var(--text); border-radius: 2px; transition: transform .2s var(--ease), opacity .15s var(--ease); }
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-drawer {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 70;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(17, 17, 19, .14);
  max-height: calc(100vh - 58px); max-height: calc(100dvh - 58px);
  overflow-y: auto; padding: 10px 12px 14px;
  animation: abFade .18s var(--ease);
}
.mobile-drawer .md-nav { display: flex; flex-direction: column; gap: 2px; }
.mobile-drawer .nav-label { padding: 12px 10px 4px; }
.mobile-drawer a[data-page] {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text); white-space: nowrap;
}
.mobile-drawer a[data-page]:active { background: var(--panel2); }
.mobile-drawer a[data-page].active { background: var(--panel2); color: var(--text); font-weight: 600; }
.mobile-drawer a.nav-off { opacity: .45; }
.mobile-drawer .md-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.mobile-drawer .md-foot .btn { text-align: center; margin-top: 0 !important; }

@media (max-width: 900px) {
  #app { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: 80;
    width: 100%; min-width: 0; height: auto;
    flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .logo { padding: 0; font-size: 15px; flex: 0 0 auto; }
  .logo .icon { width: 26px; height: 26px; flex-basis: 26px; }
  .sidebar nav { display: none; }
  .sidebar > .btn { display: none; }
  .sidebar > .nav-service { display: none !important; }
  .burger { display: flex; }

  main { padding: 18px 14px 40px; max-width: 100%; }
  h2 { font-size: 21px; }

  .login-box { width: 100%; max-width: 380px; padding: 34px 24px; }
  .modal-wrap { padding: 24px 12px; }
  .modal { padding: 20px; }
  .row { flex-direction: column; }

  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .server-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .chart-box { padding: 16px; overflow-x: auto; }

  .bars { min-width: 0; gap: 3px; }
  .bar-lbl { font-size: 9px; }
  .metrics-chart { overflow-x: auto; }
  #dash-chart { overflow-x: auto; }
  #dash-chart svg { min-width: 600px; }
  .summary-line { margin-top: 0; }
}

@media (max-width: 600px) {
  main { padding: 14px 10px 36px; }
  th, td { padding: 9px 10px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .cards .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .card { padding: 14px 14px; }
  .card .val { font-size: 22px; }
  .server-item .val { font-size: 19px; }
  .page-head { align-items: flex-start; flex-direction: column; }
}

@media (min-width: 901px) {
  .burger, .mobile-drawer { display: none !important; }
}

/* ─── Авто-рассылка ─────────────────────────────────────────────── */
.ab-form { display: flex; flex-direction: column; gap: 16px; }
.ab-section { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.ab-section-title { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.ab-hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* iOS-переключатель */
.ab-switch { display: inline-flex; align-items: center; cursor: pointer; user-select: none; font-size: 14px; color: var(--text); }
.ab-switch input { display: none; }
.ab-switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--panel3); position: relative; transition: background .2s var(--ease); flex: none; margin-right: 12px; }
.ab-switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(17, 17, 19, .25); }
.ab-switch input:checked + .track { background: var(--accent); }
.ab-switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- глобальный iOS-свитч ---------- */
.switch { display: inline-flex; align-items: center; cursor: pointer; user-select: none; font-size: 13px; color: var(--text); }
.switch input { display: none; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--panel3); position: relative; transition: background .2s var(--ease); flex: none; margin-right: 10px; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(17, 17, 19, .25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* блок «Отправить по расписанию» */
.bc-schedule-box { margin-top: 12px; padding: 14px 16px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: 12px; }

/* Карточки ботов */
.ab-bots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) { .ab-bots { grid-template-columns: 1fr; } }
.ab-bot-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; background: var(--panel);
  transition: border-color .15s var(--ease), background .15s var(--ease);
  display: block;
}
.ab-bot-card:hover { border-color: var(--border-strong); }
.ab-bot-card.sel { border-color: var(--accent); background: var(--accent-dim); }
.ab-bot-card input { display: none; }
.ab-bot-card .nm { font-weight: 600; font-size: 13px; margin-bottom: 4px; color: var(--text); }
.ab-bot-card .meta { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ab-lang-badge { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .04em; padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: #52525b; border: 1px solid var(--border); }

/* Пилюли дней недели */
.ab-days { display: flex; gap: 6px; }
.ab-day { flex: 1; }
.ab-day input { display: none; }
.ab-day span {
  display: block; text-align: center; padding: 8px 0; border-radius: 8px;
  border: 1px solid var(--border); font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer; transition: all .15s var(--ease);
  background: var(--panel);
}
.ab-day span:hover { border-color: var(--border-strong); color: var(--text); }
.ab-day input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

.ab-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .ab-row { grid-template-columns: 1fr; } }
.ab-field label { display: block; font-size: 12px; color: #52525b; margin-bottom: 6px; }
.ab-field input, .ab-field textarea, .ab-field select { width: 100%; }

/* Чипы плейсхолдеров */
.ab-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ab-chip {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11px;
  padding: 3px 10px; border-radius: 6px; background: var(--panel2);
  border: 1px solid var(--border); color: #3f3f46; cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.ab-chip:hover { border-color: var(--border-strong); background: var(--panel3); }

/* Предпросмотр */
.ab-preview-box { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); padding: 14px; animation: abFade .22s var(--ease); }
@keyframes abFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ab-preview-text { white-space: pre-wrap; font-size: 13px; line-height: 1.55; }
.ab-preview-text blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--accent); background: var(--panel2); border-radius: 0 8px 8px 0; }
.ab-preview-text tg-spoiler { background: var(--panel3); color: var(--muted); border-radius: 4px; padding: 0 4px; font-size: 12px; }

/* История запусков авто-рассылки */
.btn.hist-open { color: var(--muted); }
.btn.hist-open:hover { color: var(--text); }
.btn.hist-open.open { border-color: var(--border-strong); color: var(--text); background: var(--panel2); }
.btn.hist-open .arr { display: inline-block; transition: transform .2s var(--ease); font-size: 11px; }
.btn.hist-open.open .arr { transform: rotate(180deg); }
.ab-hist-wrap > td { background: var(--bg-soft); padding: 0; border-bottom: 1px solid var(--border); }
.ab-hist { padding: 16px 20px 18px; display: flex; flex-direction: column; gap: 16px; animation: abFade .22s var(--ease); }
.ab-hist-day-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ab-hist-date { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; text-transform: capitalize; }
.ab-hist-sum { font-size: 11.5px; color: var(--muted); }
.ab-hist-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; margin-bottom: 6px;
  transition: border-color .15s var(--ease);
}
.ab-hist-item:hover { border-color: var(--border-strong); }
.ab-hist-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.ab-hist-top .time { color: var(--muted); font-size: 11.5px; margin-left: auto; }
.ab-bar { height: 5px; border-radius: 3px; background: var(--panel3); overflow: hidden; display: flex; }
.ab-bar .ok { background: var(--accent); height: 100%; }
.ab-bar .fail { background: var(--red); height: 100%; }
.ab-hist-nums { font-size: 11.5px; color: var(--muted); }

/* ---------- Визард прелендингов ---------- */
.pl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.pl-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.pl-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.pl-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pl-card-top .tag { white-space: nowrap; flex-shrink: 0; }
.pl-card-meta { font-size: 12px; }
.pl-card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: auto; }

.wz-wrap { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .wz-wrap { grid-template-columns: 1fr; } }
.wz-steps { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 14px; }
.wz-step { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; color: var(--muted); font-size: 13px; transition: background .15s var(--ease); }
.wz-step b { display: block; font-size: 13px; color: inherit; }
.wz-step small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.wz-step.clickable { cursor: pointer; }
.wz-step.clickable:hover { background: var(--panel2); }
.wz-step.done { color: var(--text); }
.wz-step.active { background: var(--panel2); color: var(--text); }
.wz-step.active b { color: var(--text); }
.wz-num { flex: 0 0 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.wz-step.done .wz-num { border-color: var(--accent); color: var(--text); }
.wz-step.active .wz-num { border-color: var(--accent); background: var(--accent); color: #fff; }
.wz-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; min-height: 320px; }
.wz-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.wz-frame { width: 100%; height: 720px; border: 1px solid var(--border); border-radius: 8px; background: #fff; display: block; }

/* карточки тем сторителлинга */
.themes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.theme-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  font-size: 13px; line-height: 1.45; cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.theme-card:hover { border-color: var(--border-strong); }
.theme-card.sel { border-color: var(--accent); background: var(--accent-dim); }
.theme-angle { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }

/* карточки идей креативов */
.idea-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.idea-card label { margin: 4px 0 0; }
.idea-card input, .idea-card textarea { margin: 0; }

/* галерея креативов */
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cr-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.cr-img-wrap { position: relative; background: var(--panel2); aspect-ratio: 1 / 1; }
.cr-img-wrap.vert { aspect-ratio: 9 / 16; max-height: 420px; margin: 0 auto; width: 100%; }
.cr-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-aspect { position: absolute; top: 8px; right: 8px; background: rgba(17, 17, 19, .72); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.cr-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cr-body p { margin: 0; font-size: 11.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cr-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }

/* ---------- полировка визарда ---------- */
.toast { max-width: min(560px, calc(100vw - 56px)); border-radius: 10px; line-height: 1.45; text-align: left; }

.wz-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.wz-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--text);
}
.wz-chip small { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.wz-chip b { font-weight: 600; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wz-chip.on { border-color: var(--border-strong); background: var(--panel2); }
.wz-chip.on small { color: var(--text); }

.wz-card { border-radius: 14px; padding: 24px; }
.wz-steps { border-radius: 14px; }

/* читаемый предпросмотр текста */
.wz-preview { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; max-height: 480px; overflow: auto; margin-top: 4px; }
.wz-preview h3 { margin: 0 0 6px; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
.wz-preview h4 { margin: 16px 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.wz-preview p { margin: 0 0 8px; font-size: 13px; line-height: 1.65; color: #3f3f46; }
.wz-preview p b { color: var(--text); }
.wz-preview .wz-sub { color: var(--muted); font-style: italic; }
.wz-preview details { margin: 10px 0; }
.wz-preview summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text); }
.wz-preview::-webkit-scrollbar { width: 8px; }
.wz-preview::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* структура: двухколоночный чек-лист с описанием блоков */
.blocks-grid-wide { grid-template-columns: repeat(2, 1fr); gap: 6px 10px; }
.blocks-grid-wide .block-item { align-items: flex-start; padding: 8px 10px; }
.blocks-grid-wide .block-item input { margin-top: 3px; }
.blocks-grid-wide .block-item span { display: flex; flex-direction: column; gap: 1px; }
.blocks-grid-wide .block-item b { font-size: 12.5px; font-weight: 600; }
.blocks-grid-wide .block-item small { font-size: 11px; color: var(--muted); line-height: 1.35; }
@media (max-width: 900px) { .blocks-grid-wide { grid-template-columns: 1fr; } }

/* шаг 4: фото продукта */
.s4-photo { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.s4-photo-prev { flex: 0 0 84px; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; background: var(--bg-soft); border: 1px dashed var(--border-strong); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; }
.s4-photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.ai-img-err .btn { margin-top: 10px; }

/* ответы в цепочках отзывов */
.wz-preview .wz-reply { margin: -2px 0 8px 18px; color: var(--muted); }

/* Чипы выбора стилей креативов */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px solid var(--border); background: var(--panel); color: var(--muted); border-radius: 8px; padding: 6px 13px; font-size: 13px; cursor: pointer; transition: all 0.15s ease; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--accent-dim); border-color: var(--border-strong); color: var(--text); font-weight: 500; }

/* переключатель вертикали креативов (нутра / adult) */
.vswitch { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; background: var(--panel2); }
.vswitch button { border: none; background: transparent; color: var(--muted); border-radius: 7px; padding: 7px 18px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s var(--ease); }
.vswitch button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.vswitch button:not(.on):hover { color: var(--text); }

/* Бейдж стиля на карточке идеи креатива */
.idea-style { display: inline-block; margin-bottom: 6px; padding: 3px 10px; border-radius: 6px; background: var(--panel2); color: #3f3f46; border: 1px solid var(--border); font-size: 12px; font-weight: 500; }

/* Библиотека креативов: оффер + дата в карточке */
.cr-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; }
