/* Пульт управления UI. Палитра та же, что в приложении и личном кабинете. */
:root {
  --bg: #0d1017;
  --bg-2: #151a23;
  --card: #1c2230;
  --raised: #212a3a;
  --hover: #242d3d;
  --accent: #ff6a00;
  --accent-2: #ff9d00;
  --text: #e8eaf0;
  --text-2: #b0b5c0;
  --muted: #7d8594;
  --border: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.12);
  --ok: #4cd964;
  --warn: #ffcc02;
  --bad: #ff5147;
  --info: #5aa9ff;
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.offscreen { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-2); }
code, pre, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: grid; gap: 18px; padding: 32px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.login-card h1 { font-size: 20px; }
.login-logo { height: 34px; width: auto; justify-self: start; }

/* Каркас */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 24px 16px; background: var(--bg-2); border-right: 1px solid var(--border); }
.sidebar-logo { height: 30px; width: auto; align-self: flex-start; margin-left: 8px; }
.nav { display: grid; gap: 4px; }
.nav button, .nav a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--text-2); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.nav button:hover, .nav a:hover { background: var(--hover); color: var(--text); }
.nav-external { margin-left: auto; color: var(--muted); }
.nav button[aria-current="page"] { background: rgba(255, 106, 0, 0.14); color: var(--accent-2); }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding: 0 8px; }
.config-status { font-size: 13px; color: var(--muted); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { padding: 28px 32px 8px; }
.topbar h1 { font-size: 26px; letter-spacing: -0.01em; }
.page { flex: 1; display: grid; gap: 16px; align-content: start; padding: 16px 32px 120px; max-width: 1080px; width: 100%; }

/* Карточки */
.card { display: grid; gap: 16px; align-content: start; padding: 20px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-head { display: grid; gap: 4px; }
.card-head h2 { font-size: 17px; }
.card-head p, .hint { font-size: 14px; color: var(--text-2); }
.hint.small { font-size: 13px; color: var(--muted); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tile { padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.tile-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-label { font-size: 13px; color: var(--muted); }

/* Формы */
.field { display: grid; gap: 6px; align-content: start; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="number"], input[type="search"], input[type="datetime-local"], input[type="date"], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--bg-2); color: var(--text); border: 1px solid var(--border-2); border-radius: 10px; font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
textarea.short { min-height: 60px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 0; }
.row > input.narrow { flex: 0 0 84px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-wrap > .grow { flex: 1 1 220px; min-width: 0; width: auto; }
.rows { display: grid; gap: 8px; }
.stack { display: grid; gap: 16px; }
.arrow { color: var(--muted); flex: none; }
.form-error { color: var(--bad); font-size: 14px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 1px solid var(--border-2); border-radius: 10px; background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
a.button { text-decoration: none; }
.button:hover { background: var(--hover); }
.button.primary { border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.button.primary:hover { filter: brightness(1.08); }
.button.danger { color: var(--bad); }
.button.ghost { background: none; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.button.icon { width: 36px; min-height: 36px; padding: 0; flex: none; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 106, 0, 0.14); color: var(--accent-2); }
/* Кнопка, которая выглядит ссылкой: переход к провайдеру из списка счетов, «Забыли пароль?» в кабинете. */
.link-button { padding: 0; border: 0; background: none; color: var(--accent-2); font: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--accent); }

/* Сворачиваемая часть формы: условия рассылки. */
.fold { border: 1px solid var(--border-2); border-radius: var(--radius); }
.fold > summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-weight: 600; cursor: pointer; list-style: none; border-radius: var(--radius); }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: ""; flex: none; width: 7px; height: 7px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2); transform: rotate(-45deg); transition: transform 0.15s; }
.fold[open] > summary::before { transform: rotate(45deg); }
.fold > .stack { padding: 4px 14px 14px; }
/* Отметки одной строкой: языки устройств. */
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 10px; border: 1px solid var(--border-2); border-radius: 999px; background: var(--bg-2); font-size: 14px; cursor: pointer; }
.check-pill input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.check-pill:has(input:checked) { border-color: var(--accent); }
.picture { max-width: 160px; max-height: 96px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-2); object-fit: contain; }

/* Выбор цвета: образец открывает системную палитру, рядом — то же значение текстом. */
input[type="color"].swatch { flex: none; width: 44px; height: 44px; padding: 4px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg-2); cursor: pointer; }
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 6px; }
.swatch::-moz-color-swatch { border: 0; border-radius: 6px; }

.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input { appearance: none; flex: none; width: 42px; height: 24px; margin: 2px 0 0; border-radius: 12px; background: var(--hover); border: 1px solid var(--border-2); position: relative; cursor: pointer; transition: background 0.15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s, background 0.15s; }
.toggle input:checked { background: var(--accent); border-color: transparent; }
.toggle input:checked::after { transform: translateX(18px); background: #fff; }
.toggle-text { display: grid; gap: 2px; }
.toggle-text span:last-child { font-size: 13px; color: var(--muted); }

/* Данные */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 8px 10px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
td { padding: 10px; border-top: 1px solid var(--border); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap.centered td { vertical-align: middle; }
tr.flagged td { background: rgba(255, 81, 71, 0.07); }
.empty { padding: 20px 0; text-align: center; color: var(--muted); }
/* Значение, которое копируется нажатием. */
.copy { --surface: var(--bg-2); display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 3px 8px 3px 10px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.copy:hover { --surface: var(--hover); }
.copy-icon { position: relative; flex: none; width: 11px; height: 12px; color: var(--muted); }
.copy:hover .copy-icon { color: var(--text-2); }
.copy-icon::before, .copy-icon::after { content: ""; position: absolute; box-sizing: border-box; width: 8px; height: 9px; border: 1.5px solid currentColor; border-radius: 2.5px; }
.copy-icon::before { top: 0; right: 0; }
.copy-icon::after { bottom: 0; left: 0; background: var(--surface); }
.hash { display: inline-block; min-width: 20ch; overflow-wrap: anywhere; color: var(--text-2); }
/* Логотип провайдера; пока его нет — первая буква названия. */
.named { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
td .named { min-width: 16ch; }
.logo { flex: none; width: 28px; height: 28px; border-radius: 8px; object-fit: cover; background: var(--bg-2); }
.logo.large { width: 64px; height: 64px; border-radius: 14px; }
.logo.blank { display: inline-grid; place-items: center; border: 1px solid var(--border-2); color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1; }
.logo.large.blank { font-size: 24px; }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, 0.08); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: rgba(76, 217, 100, 0.14); color: var(--ok); }
.badge.warn { background: rgba(255, 204, 2, 0.14); color: var(--warn); }
.badge.bad { background: rgba(255, 81, 71, 0.14); color: var(--bad); }
.badge.accent { background: rgba(255, 106, 0, 0.16); color: var(--accent-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.bar { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
/* Расход тарифа: заливка — пользователи, засечка — конец оплаченного блока, правее неё идёт запас. */
.meter { position: relative; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); }
.meter-fill { height: 100%; min-width: 4px; border-radius: 5px; background: var(--muted); }
.meter-fill.ok { background: var(--ok); }
.meter-fill.accent { background: var(--accent-2); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.bad { background: var(--bad); }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); }
.state-cell { display: grid; gap: 4px; justify-items: start; white-space: nowrap; }
.condition { font-size: 14px; color: var(--text-2); }
.condition.ok { color: var(--ok); }
.condition.accent { color: var(--accent-2); }
.condition.warn { color: var(--warn); }
.condition.bad { color: var(--bad); }
.snippet { position: relative; margin: 0; padding: 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; white-space: pre; }
.check { display: flex; gap: 10px; align-items: baseline; font-size: 14px; }
.check .mono { overflow-wrap: anywhere; }
.preview { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); border: 1px solid; font-size: 14px; }
.preview.info { border-color: rgba(90, 169, 255, 0.3); background: rgba(90, 169, 255, 0.1); }
.preview.success { border-color: rgba(76, 217, 100, 0.3); background: rgba(76, 217, 100, 0.1); }
.preview.warning { border-color: rgba(255, 204, 2, 0.3); background: rgba(255, 204, 2, 0.1); }
.preview.danger { border-color: rgba(255, 81, 71, 0.3); background: rgba(255, 81, 71, 0.1); }
/* Письма из журнала почты: тема в строке, текст со ссылками — по нажатию. */
.mail-list { display: grid; gap: 8px; }
.mail > summary { flex-wrap: wrap; font-weight: 500; }
.mail-subject { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.mail-meta { font-size: 13px; color: var(--muted); }
.mail-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; color: var(--text-2); }

/* Сбои: отбор над плитками, группы с раскрывающимися примерами, сообщения пользователей. */
.filters { gap: 8px; }
.filters select.filter { width: auto; flex: 0 1 150px; min-width: 0; padding: 6px 10px; font-size: 14px; }
tr.group { cursor: pointer; }
tr.group:hover > td, tr.group.open > td { background: rgba(255, 255, 255, 0.03); }
tr.group.resolved > td { color: var(--muted); }
tr.group-examples > td { padding: 4px 10px 16px; border-top: 0; background: rgba(255, 255, 255, 0.03); cursor: auto; }
.group-cell { min-width: 220px; }
.group-title { display: block; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.group-title:hover { color: var(--accent-2); }
.examples { display: grid; gap: 10px; }
.example { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border-2); border-radius: var(--radius); }
.example-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.example-message { overflow-wrap: anywhere; }
/* Стек и журнал бывают длинными: у блока своя прокрутка, страница не растягивается на десятки экранов. */
.snippet.scroll { max-height: 360px; overflow: auto; }
.snippet.log { max-height: 420px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-list { display: grid; gap: 10px; }
.feedback { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border-2); border-radius: var(--radius); }
.feedback-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Панель публикации */
.publish-bar { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 14px 32px; background: var(--raised); border-top: 1px solid var(--border-2); box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35); }
.publish-bar .publish-text { flex: 1; min-width: 220px; display: grid; gap: 2px; }
.publish-bar ul { margin: 4px 0 0; padding-left: 18px; color: var(--bad); font-size: 14px; }

/* Диалог и сообщения */
.dialog { width: min(440px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--border-2); border-radius: var(--radius-lg); background: var(--raised); color: var(--text); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog form { display: grid; gap: 12px; }
.dialog h2 { font-size: 18px; }
.dialog p { color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 10; display: grid; gap: 8px; width: min(380px, calc(100% - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--raised); border: 1px solid var(--border-2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); font-size: 14px; }
/* Исход операции показывает точка перед текстом, а не цветная полоса сбоку. */
.toast::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--ok); }
.toast.error { border-color: color-mix(in srgb, var(--bad) 45%, var(--border-2)); }
.toast.error::before { background: var(--bad); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px; overflow-x: auto; }
  .sidebar-logo { margin: 0; height: 24px; }
  .nav { display: flex; }
  .nav button { white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; display: flex; align-items: center; }
  .config-status { display: none; }
  .topbar { padding: 20px 16px 4px; }
  .page { padding: 12px 16px 120px; }
  .publish-bar { padding: 12px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
