/* Balanser Panel — тёмная тема. Все цвета — токены. */
:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-elev: #151a21;
  --bg-elev-2: #1b212a;
  --bg-input: #0f1319;
  --line: #262d38;
  --line-strong: #343d4a;
  --text: #e6e9ee;
  --text-dim: #9aa4b2;
  --text-faint: #6b7584;
  --accent: #5b9cff;
  --accent-strong: #3d86ff;
  --accent-soft: rgba(91, 156, 255, .12);
  --ok: #3fbf7f;
  --ok-soft: rgba(63, 191, 127, .13);
  --warn: #e6a53d;
  --warn-soft: rgba(230, 165, 61, .13);
  --err: #f0616d;
  --err-soft: rgba(240, 97, 109, .13);
  --muted-soft: rgba(154, 164, 178, .12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 620; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 620; margin: 0 0 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ── Каркас ── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--bg-elev) 232px, var(--line) 232px, var(--line) 233px, var(--bg) 233px); }
.sidebar { background: var(--bg-elev); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #8b6bff); display: grid; place-items: center; font-size: 13px; color: #fff; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-dim); font-weight: 500; }
.nav a:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav .mobile-only { display: none; }
.nav svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.sidebar .spacer { flex: 1; }
.sidebar .who { padding: 10px; border-top: 1px solid var(--line); margin-top: 8px; font-size: 12.5px; color: var(--text-dim); }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-dim); margin-top: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Карточки и панели ── */
.panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.tight { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; transition: border-color .15s; }
.card:hover { border-color: var(--line-strong); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 650; font-size: 15px; color: var(--text); }
.card-title:hover { text-decoration: none; color: var(--accent); }
.card-sub { color: var(--text-faint); font-size: 12.5px; font-family: var(--mono); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg-elev-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.stat .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11.5px; color: var(--text-faint); }
.card-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--text-faint); font-size: 12px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ── Бейджи ── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--muted-soft); color: var(--text-dim); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--bg-elev-2); border: 1px solid var(--line); font-size: 11.5px; font-family: var(--mono); color: var(--text-dim); }

/* ── Кнопки ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--bg-elev-2); color: var(--text); font: 550 13.5px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--text-faint); text-decoration: none; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { background: transparent; border-color: rgba(240,97,109,.45); color: var(--err); }
.btn.danger:hover { background: var(--err-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: var(--bg-elev-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
form.inline { display: inline; }

/* ── Формы ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 12.5px; color: var(--text-dim); font-weight: 550; }
.field .help { font-size: 12px; color: var(--text-faint); }
input[type=text], input[type=password], input[type=number], input[type=email], input:not([type]), select, textarea {
  width: 100%; background: var(--bg-input); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; font: 13.5px var(--sans); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.secret-set { display: flex; align-items: center; gap: 10px; }
.confirm-box { margin-top: 18px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg-elev-2); }
.confirm-box .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.confirm-box .row .field { margin: 0; flex: 1 1 200px; }

/* ── Таблицы ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.015); }
td input, td select { padding: 6px 8px; }

/* ── Сообщения ── */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; font-size: 13.5px; }
.flash.ok { background: var(--ok-soft); border-color: rgba(63,191,127,.35); color: #b8f0d2; }
.flash.warn { background: var(--warn-soft); border-color: rgba(230,165,61,.35); color: #f6d9a8; }
.flash.error { background: var(--err-soft); border-color: rgba(240,97,109,.35); color: #ffc7cc; }
.banner { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; background: var(--err-soft); border: 1px solid rgba(240,97,109,.4); color: #ffc7cc; }
.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg-elev-2); border-left: 3px solid var(--accent); margin-bottom: 14px; }
.callout.warn { border-left-color: var(--warn); }
.callout.err { border-left-color: var(--err); }
.callout.ok { border-left-color: var(--ok); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }

/* ── Вкладки ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--text-dim); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 550; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Лог и diff ── */
.log { background: #0a0d11; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font: 12.5px/1.55 var(--mono); max-height: 62vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .l-step { color: var(--accent); font-weight: 600; margin-top: 6px; }
.log .l-ok { color: var(--ok); }
.log .l-warn { color: var(--warn); }
.log .l-error { color: var(--err); font-weight: 600; }
.log .l-out { color: var(--text-dim); }
.diff { background: #0a0d11; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font: 12px/1.5 var(--mono); overflow-x: auto; white-space: pre; margin: 6px 0 14px; }
.diff .add { color: var(--ok); background: rgba(63,191,127,.07); display: block; }
.diff .del { color: var(--err); background: rgba(240,97,109,.07); display: block; }
.diff .hunk { color: var(--accent); display: block; }
.diff .meta { color: var(--text-faint); display: block; }
.actions-list { margin: 0; padding-left: 20px; }
.actions-list li { margin: 4px 0; }

/* ── Вход ── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, rgba(91,156,255,.12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 22px; font-size: 17px; }

.qr { background: #fff; padding: 10px; border-radius: 8px; width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 22px; font-family: var(--mono); }
.empty { text-align: center; padding: 48px 16px; color: var(--text-dim); }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .sidebar .spacer, .sidebar .who { display: none; }
  .nav .mobile-only { display: flex; }
  .main { padding: 18px 16px 48px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Утилиты (вместо inline style — CSP style-src 'self') ── */
.mt-0 { margin-top: 0; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; } .mt-18 { margin-top: 18px; } .mb-10 { margin-bottom: 10px; } .pl-0 { padding-left: 0; }
.c-err { color: var(--err); } .c-warn { color: var(--warn); } .c-ok { color: var(--ok); }
.w-60 { width: 60px; } .w-110 { width: 110px; } .w-full { width: 100%; } .minw-220 { min-width: 220px; } .maxw-220 { max-width: 220px; }
.fs-15 { font-size: 15px; } .pre-wrap { white-space: pre-wrap; } .f-140 { flex: 0 1 140px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; } .filter-field { margin: 0; flex: 1 1 160px; }
.notes { min-height: 60px; font-family: var(--sans); } .details-cell { max-width: 420px; overflow-wrap: anywhere; }
details > summary { list-style: none; } details > summary::-webkit-details-marker { display: none; }
details[open] { text-align: left; } details[open] .confirm-box { margin-top: 10px; }

/* ── Метрики и графики ── */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--text-dim); }
table.sortable th.sorted { color: var(--text); }
table.sortable th.sorted::after { content: " ▼"; font-size: 10px; }
table.sortable th.sorted.asc::after { content: " ▲"; }
.loadbar { display: inline-block; width: 46px; height: 6px; border-radius: 3px; background: var(--bg-elev-2); vertical-align: middle; margin-right: 6px; overflow: hidden; }
.loadbar > span { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.loadbar > span.mid { background: var(--warn); }
.loadbar > span.hi { background: var(--err); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: baseline; }
.s0 { background: #3987e5; } .s1 { background: #d95926; } .s2 { background: #199e70; } .s3 { background: #c98500; }
.s4 { background: #d55181; } .s5 { background: #008300; } .s6 { background: #9085e9; } .s7 { background: #e66767; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.chart { min-height: 120px; margin-bottom: 18px; }
.chart-empty { padding: 40px 0; text-align: center; color: var(--text-faint); border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--text-dim); padding: 6px 12px; font: 550 12.5px var(--sans); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.active { background: var(--accent-soft); color: var(--text); }
.uplot { font-family: var(--sans); color: var(--text-dim); }
.uplot .u-legend { font-size: 12.5px; text-align: left; margin-top: 4px; }
.uplot .u-legend th { text-transform: none; letter-spacing: 0; color: var(--text-dim); font-weight: 500; padding: 2px 8px; border: 0; }
.uplot .u-legend td { padding: 2px 8px; border: 0; color: var(--text); font-variant-numeric: tabular-nums; }
.uplot .u-legend tr:hover td { background: none; }
.u-select { background: var(--accent-soft); }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form select.w-140 { width: 140px; } .row-form input.w-90 { width: 90px; }
.w-90 { width: 90px; } .w-140 { width: 140px; } .mb-0 { margin-bottom: 0; }
.callout.big { font-size: 15px; padding: 16px 18px; border-left-width: 5px; background: var(--err-soft); }
.loadbar > span.w0 { width: 0%; }
.loadbar > span.w5 { width: 5%; }
.loadbar > span.w10 { width: 10%; }
.loadbar > span.w15 { width: 15%; }
.loadbar > span.w20 { width: 20%; }
.loadbar > span.w25 { width: 25%; }
.loadbar > span.w30 { width: 30%; }
.loadbar > span.w35 { width: 35%; }
.loadbar > span.w40 { width: 40%; }
.loadbar > span.w45 { width: 45%; }
.loadbar > span.w50 { width: 50%; }
.loadbar > span.w55 { width: 55%; }
.loadbar > span.w60 { width: 60%; }
.loadbar > span.w65 { width: 65%; }
.loadbar > span.w70 { width: 70%; }
.loadbar > span.w75 { width: 75%; }
.loadbar > span.w80 { width: 80%; }
.loadbar > span.w85 { width: 85%; }
.loadbar > span.w90 { width: 90%; }
.loadbar > span.w95 { width: 95%; }
.loadbar > span.w100 { width: 100%; }
