/* Админка AI Verdict. Палитра и вид — как у расширения: нейтральные оттенки, цвет только у статусов и данных.
   Встроенных стилей (style="") нет: их запрещает Content-Security-Policy, размеры задаются из JS через CSSOM. */
:root {
  color-scheme: light;
  --bg: #fafafa; --surface: #ffffff; --raised: #ffffff; --fg: #09090b; --fg-2: #3f3f46; --muted: #71717a; --faint: #a1a1aa;
  --line: #e4e4e7; --line-2: #f1f1f3; --tint: #f4f4f5; --hover: #f7f7f8;
  --primary: #18181b; --primary-fg: #fafafa; --primary-hover: #27272a;
  --accent: #4f46e5; --accent-bg: rgba(79, 70, 229, .08); --ring: rgba(79, 70, 229, .28);
  --ok: #16a34a; --ok-bg: rgba(22, 163, 74, .09); --amber: #d97706; --amber-bg: rgba(217, 119, 6, .1);
  --bad: #dc2626; --bad-bg: rgba(220, 38, 38, .08);
  --series-1: #2a78d6; /* единственный ряд данных на графиках; проверен валидатором на светлом фоне */
  --grid: #ececee;
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, .05); --shadow-lg: 0 2px 6px rgba(9, 9, 11, .06), 0 18px 48px rgba(9, 9, 11, .16);
  --font: "Inter var", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #09090b; --surface: #111113; --raised: #1c1c1f; --fg: #fafafa; --fg-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
    --line: #27272a; --line-2: #1f1f23; --tint: #1c1c1f; --hover: #17171a;
    --primary: #fafafa; --primary-fg: #09090b; --primary-hover: #e4e4e7;
    --accent: #818cf8; --accent-bg: rgba(129, 140, 248, .14); --ring: rgba(129, 140, 248, .35);
    --ok: #4ade80; --ok-bg: rgba(74, 222, 128, .1); --amber: #fbbf24; --amber-bg: rgba(251, 191, 36, .1);
    --bad: #f87171; --bad-bg: rgba(248, 113, 113, .1);
    --series-1: #3987e5; --grid: #222226;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b; --surface: #111113; --raised: #1c1c1f; --fg: #fafafa; --fg-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
  --line: #27272a; --line-2: #1f1f23; --tint: #1c1c1f; --hover: #17171a;
  --primary: #fafafa; --primary-fg: #09090b; --primary-hover: #e4e4e7;
  --accent: #818cf8; --accent-bg: rgba(129, 140, 248, .14); --ring: rgba(129, 140, 248, .35);
  --ok: #4ade80; --ok-bg: rgba(74, 222, 128, .1); --amber: #fbbf24; --amber-bg: rgba(251, 191, 36, .1);
  --bad: #f87171; --bad-bg: rgba(248, 113, 113, .1);
  --series-1: #3987e5; --grid: #222226;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { min-height: 100vh; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
p { margin: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.i { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.14em; }

/* ---------- кнопки и поля ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--raised); color: var(--fg);
  font: 500 13px/1 var(--font); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--hover); text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); font-weight: 600; }
button.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--bad); }
button.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
button.ghost:hover { background: var(--tint); color: var(--fg); }
button.icon { width: 34px; padding: 0; font-size: 16px; }
:is(button, a, input, select, textarea):focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
input, select, textarea {
  height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); color: var(--fg);
  font: 14px var(--font); box-shadow: var(--shadow-sm); min-width: 0;
}
textarea { height: auto; padding: 8px 11px; }
input::placeholder { color: var(--faint); }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--fg-2); }
.form > .field > input, .form > .field > select { width: 100%; }
.form > .field .mono { font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input:not(.switch) { width: 16px; height: 16px; accent-color: var(--primary); box-shadow: none; }
.switch { appearance: none; position: relative; width: 36px; height: 21px; padding: 0; border: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: background-color .2s; box-shadow: none; }
.switch::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { background: var(--primary-fg); transform: translateX(15px); }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--tint); }
.seg button { height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; box-shadow: none; color: var(--muted); font-size: 12.5px; }
.seg button:hover { color: var(--fg); background: transparent; }
.seg button.on { background: var(--raised); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px; background: var(--tint); color: var(--fg-2); font-size: 11.5px; font-weight: 500; 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-bg); color: var(--ok); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.accent { background: var(--accent-bg); color: var(--accent); }

.note { padding: 10px 12px; border-radius: 11px; background: var(--tint); color: var(--fg-2); font-size: 13px; line-height: 1.5; }
.note.warn { background: var(--amber-bg); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.ok { background: var(--ok-bg); }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); padding: 28px 24px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 16px 0 4px; font-size: 20px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login-card button { height: 40px; }
.login-card .msg { min-height: 20px; font-size: 13px; }

/* ---------- каркас ---------- */
.logo { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--primary-fg); font-size: 20px; }
.logo .i { stroke-width: 2.6; }
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 16px; }
.brand b { font-size: 15px; letter-spacing: -.02em; }
.brand .badge { margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 9px; color: var(--fg-2); font-weight: 500; font-size: 13.5px; text-decoration: none; }
.nav a .i { font-size: 17px; color: var(--muted); }
.nav a:hover { background: var(--tint); }
.nav a.on { background: var(--tint); color: var(--fg); font-weight: 600; }
.nav a.on .i { color: var(--fg); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--line-2); }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who button { margin-left: auto; }
.main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.head h1 { font-size: 22px; font-weight: 650; }
.head .sub { margin-top: 2px; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 0; }
  .brand b, .brand .badge { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 0 9px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; }
  .who span { display: none; }
  .main { padding: 18px 16px 48px; }
}

/* ---------- карточки и плитки ---------- */
.card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-h h2 { font-size: 14px; font-weight: 600; }
.card-h .muted { font-size: 12px; }
.card-b { padding: 12px 16px 16px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
/* шесть показателей: 3 + 3, в один ряд — только на широком экране, на телефоне по два */
.grid.tiles.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1560px) { .grid.tiles.six { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid.tiles.six, .grid.tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-gap { margin-top: 14px; }
.main > .note { margin-bottom: 14px; }
.tile { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.tile .k { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile .k .i { font-size: 15px; }
.tile .v { margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .s { margin-top: 3px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tile .s .up { color: var(--ok); }
.tile .s .down { color: var(--bad); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 9px 12px; text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--hover); }
tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 12.5px; }

/* ---------- графики: один ряд, столбцы ≤ 24 px с зазором 2 px, скругление 4 px только у вершины ---------- */
.chart { position: relative; }
.chart .plot { height: 180px; overflow: hidden; } /* до перерисовки под новую ширину старая картинка не распирает карточку */
.grid > * { min-width: 0; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hl { opacity: .78; }
.chart text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; color: var(--muted); font-size: 12px; }
.chart-total { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip { position: fixed; z-index: 50; pointer-events: none; padding: 7px 10px; border-radius: 9px; background: var(--primary); color: var(--primary-fg); font-size: 12px; line-height: 1.4; box-shadow: var(--shadow-lg); white-space: nowrap; }
.tip b { font-variant-numeric: tabular-nums; }
.linkish { padding: 0; height: auto; border: 0; background: none; box-shadow: none; color: var(--accent); font-size: 12px; }
.linkish:hover { background: none; text-decoration: underline; }

/* горизонтальные полосы: доля от максимума, подпись значения — текстом */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bars .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; font-size: 13px; }
.bars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .val { font-variant-numeric: tabular-nums; color: var(--fg-2); }
.bars .track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--tint); overflow: hidden; }
.bars .fill { height: 100%; width: 0; border-radius: 0 4px 4px 0; background: var(--series-1); }

/* ---------- пользователь ---------- */
.user-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--tint); color: var(--fg-2); font-weight: 650; font-size: 15px; text-transform: uppercase; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.actions .field input { width: 140px; }
.actions .field.wide input { width: 260px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.delta-plus { color: var(--ok); }
.delta-minus { color: var(--fg-2); }

/* ---------- настройки ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .grow { flex: 1; min-width: 220px; }
.form-row .grow input { width: 100%; }
.providers { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.provider { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: auto; padding: 11px 12px; border-radius: 12px; text-align: left; white-space: normal; }
.provider.on { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }
.provider b { font-size: 13.5px; }
.provider span { color: var(--muted); font-size: 12px; font-weight: 400; }
.secret { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret .saved { font-family: var(--mono); font-size: 12.5px; color: var(--fg-2); }
.pkg { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; }
.pkg input { width: 100%; }
.pkg .hint { color: var(--muted); font-size: 12px; white-space: nowrap; }
.divider { height: 1px; background: var(--line-2); margin: 4px 0; }
.errors { display: flex; flex-direction: column; }
.errors div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.errors div:last-child { border-bottom: 0; }
.errors code { font-family: var(--mono); font-size: 12px; color: var(--fg-2); overflow-wrap: anywhere; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: 360px; padding: 11px 14px; border-radius: 12px; background: var(--primary); color: var(--primary-fg); font-size: 13px; box-shadow: var(--shadow-lg); }
.toast.bad { background: var(--bad); color: #fff; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--fg); border-radius: 50%; animation: s .7s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; padding: 40px 0; color: var(--muted); }
