/* ============ Токены ============ */
:root {
  color-scheme: light;
  --bg: #f6f6f8; --bg-glow: rgba(124, 92, 246, .10);
  --panel: #ffffff; --panel-2: #f3f3f6; --panel-3: #eaeaef; --elev: #ffffff;
  --border: #e6e6ec; --border-2: #d9d9e1;
  --text: #0c0c10; --muted: #5f5f6b; --dim: #8b8b97;
  --accent: #7c5cf6; --accent-2: #5b6cf9; --accent-text: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--panel));
  --accent-line: color-mix(in srgb, var(--accent) 35%, var(--border));
  --ok: #0f9960; --ok-soft: #e4f6ee; --bad: #d9382c; --bad-soft: #fde9e7; --warn: #b26a00; --warn-soft: #fff3dc;
  --code-bg: #0f1015; --code-text: #e7e7ee; --code-dim: #8a8a99;
  --shadow-sm: 0 1px 2px rgba(16, 16, 32, .05);
  --shadow: 0 1px 2px rgba(16, 16, 32, .04), 0 8px 24px -12px rgba(16, 16, 32, .12);
  --shadow-lg: 0 24px 60px -20px rgba(16, 16, 32, .35);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .6);
  --r: 16px; --r-sm: 11px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08080b; --bg-glow: rgba(124, 92, 246, .16);
    --panel: #111116; --panel-2: #17171e; --panel-3: #1f1f28; --elev: #15151c;
    --border: rgba(255, 255, 255, .075); --border-2: rgba(255, 255, 255, .12);
    --text: #f3f3f6; --muted: #a3a3b2; --dim: #6f6f7f;
    --accent: #8b6cff; --accent-2: #6d7cff;
    --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--panel));
    --ok: #3ccf8e; --ok-soft: rgba(60, 207, 142, .12); --bad: #ff6b5f; --bad-soft: rgba(255, 107, 95, .12);
    --warn: #f3b24b; --warn-soft: rgba(243, 178, 75, .12);
    --code-bg: #0b0b10;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 10px 30px -15px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8); --hl: inset 0 1px 0 rgba(255, 255, 255, .04);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08080b; --bg-glow: rgba(124, 92, 246, .16);
  --panel: #111116; --panel-2: #17171e; --panel-3: #1f1f28; --elev: #15151c;
  --border: rgba(255, 255, 255, .075); --border-2: rgba(255, 255, 255, .12);
  --text: #f3f3f6; --muted: #a3a3b2; --dim: #6f6f7f;
  --accent: #8b6cff; --accent-2: #6d7cff;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--panel));
  --ok: #3ccf8e; --ok-soft: rgba(60, 207, 142, .12); --bad: #ff6b5f; --bad-soft: rgba(255, 107, 95, .12);
  --warn: #f3b24b; --warn-soft: rgba(243, 178, 75, .12);
  --code-bg: #0b0b10;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 10px 30px -15px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8); --hl: inset 0 1px 0 rgba(255, 255, 255, .04);
}
/* Цвет кабинета по типу ключа */
:root[data-ktype="codex"]    { --accent: #10a37f; --accent-2: #2dd4a0; --bg-glow: rgba(16, 163, 127, .14); }
:root[data-ktype="claude"]   { --accent: #d97757; --accent-2: #f0a35e; --bg-glow: rgba(217, 119, 87, .14); }
:root[data-ktype="deepseek"] { --accent: #4d6bfe; --accent-2: #7aa2ff; --bg-glow: rgba(77, 107, 254, .15); }

/* ============ База ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
  background-image: radial-gradient(1100px 520px at 85% -10%, var(--bg-glow), transparent 60%),
                    radial-gradient(800px 400px at -10% 110%, var(--bg-glow), transparent 60%);
  background-attachment: fixed; min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14.5px; font-weight: 620; }
p { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.ic.sm { width: 15px; height: 15px; }
.ic.lg { width: 22px; height: 22px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ============ Каркас: сайдбар + контент ============ */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px; border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 70%, transparent); backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255,255,255,.25);
}
.logo .ic { width: 18px; height: 18px; }
.logo b { font-weight: 800; font-size: 13.5px; letter-spacing: -.03em; }

/* Логотипы нейросетей и программ */
.brand-tile { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; flex: none;
  background: var(--elev); border: 1px solid var(--border-2); color: var(--text); box-shadow: var(--shadow-sm); }
.brand-tile svg { width: 62%; height: 62%; display: block; }
.brand-tile b { font-size: 12px; font-weight: 800; color: var(--accent); letter-spacing: -.02em; }
.brand-tile.xs { width: 20px; height: 20px; border-radius: 6px; box-shadow: none; }
.brand-tile.xs b { font-size: 8.5px; }
.brand-tile.sm { width: 26px; height: 26px; border-radius: 8px; }
.brand-tile.sm b { font-size: 10px; }
.brand-tile.lg { width: 42px; height: 42px; border-radius: 12px; }
.brand-tile.xl { width: 54px; height: 54px; border-radius: 15px; }
.brand-tile.xl b { font-size: 17px; }
.brand-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge .brand-tile.xs { width: 17px; height: 17px; border-radius: 5px; border: 0; }
.plan-chip .brand-tile.xs { border: 0; }
.key-card .brand-tile { width: 32px; height: 32px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; padding: 10px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--muted); font: inherit; font-weight: 550; cursor: pointer; text-align: left; width: 100%; position: relative;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .ic { color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-row { display: flex; gap: 6px; }

.main { padding: 28px 36px 64px; min-width: 0; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 5px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* мобильная версия: сайдбар становится верхней панелью */
.mobile-bar { display: none; }
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 30; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .side .nav-label { display: none; }
  .side .nav-item { width: auto; white-space: nowrap; padding: 7px 12px; }
  .side .nav-item.active::before { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .side-foot .hide-m { display: none; }
  .main { padding: 20px 16px 56px; }
  h1 { font-size: 21px; }
}

/* ============ Карточки ============ */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: 20px;
  box-shadow: var(--shadow), var(--hl);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .title { display: flex; align-items: center; gap: 10px; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.flush > .card-head { padding: 18px 20px 0; }
.ic-chip {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}
.ic-chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.ic-chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.ic-chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.ic-chip.mute { background: var(--panel-2); color: var(--muted); border-color: var(--border); }
.grid { display: grid; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.stats { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .stats { grid-template-columns: 1fr; } }
.stat { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.stat .value.sm { font-size: 18px; }
.stat .sub { color: var(--dim); font-size: 12.5px; margin-top: 4px; }

/* ============ Кнопки и поля ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--border-2); background: var(--elev); color: var(--text);
  font: inherit; font-weight: 580; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.22);
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.danger-solid { color: #fff; background: var(--bad); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; flex: none; padding: 0;
  border: 1px solid var(--border); background: var(--elev); color: var(--muted); cursor: pointer; transition: all .15s;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); border-color: var(--border-2); }
.icon-btn .ic { width: 16px; height: 16px; }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.sm .ic { width: 14px; height: 14px; }
.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.icon-btn.okc:hover { color: var(--ok); background: var(--ok-soft); border-color: transparent; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--elev); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 0 12px; height: 40px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; }
select { padding-right: 32px; appearance: none; 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='%238b8b97' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 560; color: var(--muted); }
.input-ic { position: relative; }
.input-ic > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); width: 17px; height: 17px; pointer-events: none; }
.input-ic > input { padding-left: 38px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ============ Метки ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--panel-2); color: var(--muted);
}
.badge .ic { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.type-badge { --tc: var(--accent); color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, transparent); }
.type-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--tc, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc, var(--accent)) 20%, transparent); }
.mult { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 7px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

/* ============ Таблицы ============ */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar select, .toolbar input { height: 34px; font-size: 13.5px; width: auto; }
.toolbar .input-ic input { width: 240px; padding-left: 34px; }
.toolbar .input-ic > .ic { left: 11px; width: 15px; height: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  background: var(--panel-2); position: sticky; top: 0; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td .sub { display: block; font-size: 12px; color: var(--dim); margin-top: 1px; }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }
.pill-code { font-family: var(--mono); font-size: 12px; padding: 3px 8px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.keycell { display: flex; align-items: center; gap: 6px; }
.keycell .mono { font-size: 13px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic-chip { width: 44px; height: 44px; border-radius: 13px; }
.empty b { color: var(--text); font-weight: 600; }

/* ============ Hero ============ */
.hero {
  position: relative; overflow: hidden; padding: 26px; display: grid; grid-template-columns: 1fr auto; gap: 22px; align-items: center;
  background: radial-gradient(600px 240px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
              radial-gradient(500px 220px at 100% 120%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 70%), var(--panel);
  border-color: var(--accent-line);
}
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: radial-gradient(400px 200px at 90% 0%, #000, transparent 70%); }
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-chip { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 6px; border-radius: 99px;
  background: color-mix(in srgb, var(--panel) 70%, transparent); border: 1px solid var(--accent-line); font-weight: 600; font-size: 13px; }
.plan-chip .mini { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.hero .bal { font-size: 44px; font-weight: 750; letter-spacing: -.035em; line-height: 1.05; margin-top: 14px; font-variant-numeric: tabular-nums; }
.hero .bal span { font-size: 18px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.hero .est { margin-top: 4px; color: var(--muted); }
.hero .est b { color: var(--text); font-weight: 650; }
.est-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); margin-top: 10px; }
.est-title > .ic { color: var(--accent); }
.est-title b { color: var(--text); }
.link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; }
.link:hover { text-decoration: underline; }
.task-est { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; max-width: 560px; }
.te { border: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 70%, transparent); border-radius: 12px; padding: 10px 12px;
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; }
.te .ic { color: var(--accent); grid-row: span 2; }
.te b { font-size: 20px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.te span { font-size: 12px; color: var(--muted); line-height: 1.25; }
.te.low b { color: var(--bad); font-size: 15px; }
.te.low .ic { color: var(--bad); }
@media (max-width: 560px) { .task-est { grid-template-columns: 1fr; } }
.warn-line { display: flex; gap: 9px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 11px; max-width: 560px;
  background: var(--warn-soft); color: var(--text); font-size: 13px; }
.warn-line .ic { color: var(--warn); margin-top: 2px; }
.model-est { display: flex; gap: 7px; align-items: center; font-size: 12.5px; color: var(--muted); cursor: help; }
.model-est .ic { color: var(--accent); }
.model-est b { color: var(--text); }
.modal:has(.flow) { max-width: 620px; }
.modal-body:has(.flow) { max-height: 70vh; overflow-y: auto; }
.modal-body > * { flex-shrink: 0; }
.flow { display: flex; flex-direction: column; gap: 6px; }
.flow-step { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 13.5px; }
.flow-step .ic { color: var(--accent); }
.flow-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); flex: none; }
.explain-table { border: 1px solid var(--border); border-radius: 12px; }
.explain-table th:first-child, .explain-table td:first-child { padding-left: 12px; }
.explain-table td { white-space: normal; }
.explain-table td.num { white-space: nowrap; }
.explain-table td .ic { color: var(--accent); }
.meter { margin-top: 16px; max-width: 460px; }
.meter-bar { height: 7px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-top: 6px; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero .bal { font-size: 36px; } .hero-actions { flex-direction: row; flex-wrap: wrap; min-width: 0; } }

/* ============ Список ключей (переключатель) ============ */
.keysw { position: relative; }
.key-card {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid var(--border); background: var(--elev); color: var(--text); font: inherit; box-shadow: var(--shadow-sm);
}
.key-card:hover { border-color: var(--border-2); }
.key-card .mini { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.key-card .t { min-width: 0; flex: 1; }
.key-card b { display: block; font-size: 13.5px; font-weight: 620; }
.key-card small { display: block; color: var(--dim); font-size: 12px; font-family: var(--mono); }
.key-card .ic { color: var(--dim); }
.menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 40; min-width: 270px; background: var(--elev);
  border: 1px solid var(--border-2); border-radius: 14px; padding: 6px; box-shadow: var(--shadow-lg); }
.menu .item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--text);
  font: inherit; text-align: left; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.menu .item:hover { background: var(--panel-2); }
.menu .item.cur { background: var(--accent-soft); }
.menu .item small { display: block; color: var(--dim); font-size: 12px; }
.menu .item .ic { color: var(--muted); }
.menu .item .check { margin-left: auto; color: var(--accent); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
@media (max-width: 920px) {
  .keysw .key-card { padding: 6px 8px; }
  .keysw .key-card .t small, .keysw .key-card > .ic { display: none; }
  .menu { left: auto; right: 0; bottom: auto; top: calc(100% + 8px); }
}

/* ============ График ============ */
.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: url(#barGrad); transition: opacity .15s; }
.chart .bar:hover { opacity: .75; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart text { fill: var(--dim); font-size: 11px; font-family: var(--font); }

/* ============ Модели ============ */
.models { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.model { display: flex; flex-direction: column; gap: 12px; padding: 18px; transition: border-color .15s, transform .15s; }
.model:hover { border-color: var(--border-2); }
.model.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.model-head { display: flex; align-items: center; gap: 12px; }
.model-logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--tc, var(--accent)), color-mix(in srgb, var(--tc, var(--accent)) 55%, #fff)); }
.model-head .t { flex: 1; min-width: 0; }
.model-head small { display: block; color: var(--dim); font-size: 12px; }
.model .desc { color: var(--muted); font-size: 13.5px; flex: 1; }
.model-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.model-top { display: flex; align-items: center; gap: 9px; }
.model-top .prov { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-name { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.model.popular { background: radial-gradient(420px 180px at 0% 0%, color-mix(in srgb, var(--tc) 14%, transparent), transparent 70%), var(--panel); }
.price-row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.price { font-size: 30px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.price-row .per { color: var(--muted); font-size: 13.5px; }
.price-row .ctx { margin-left: auto; color: var(--dim); font-size: 12.5px; }
.badge.save { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.badge.pop { background: color-mix(in srgb, #c06cff 16%, transparent); color: #c06cff; text-transform: uppercase; letter-spacing: .05em; font-size: 11px; }
.formula { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--dim); }
.formula .mult { font-size: 11.5px; padding: 1px 6px; }
.formula .ic { cursor: help; }
.model-foot .pill-code { flex-wrap: nowrap; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.model-foot .btn { flex: none; }
.group-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.group-title:first-child { margin-top: 0; }
.group-title .line { flex: 1; height: 1px; background: var(--border); }

/* ============ Мастер подключения ============ */
.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 16px; padding-bottom: 26px; position: relative; }
.step::before { content: ""; position: absolute; left: 16px; top: 36px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.step:last-child { padding-bottom: 0; }
.step:last-child::before { display: none; }
.step-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.step-body > h2 { margin: 6px 0 14px; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choices.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--border); background: var(--elev);
  color: var(--text); border-radius: 13px; padding: 11px 14px; font: inherit; cursor: pointer; min-width: 0; transition: all .15s; box-shadow: var(--shadow-sm); }
.choice:hover { border-color: var(--border-2); background: var(--panel-2); }
.choice.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice b { display: block; font-weight: 620; }
.choice small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.choice .tile { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 12.5px;
  background: var(--panel-2); color: var(--accent); border: 1px solid var(--border); }
.choice.active .tile { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.choice .ic { color: var(--muted); }
.choice.active .ic { color: var(--accent); }
@media (max-width: 560px) {
  .choices.tools { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .choice { padding: 9px 10px; gap: 9px; }
  .choice .tile { width: 30px; height: 30px; font-size: 11px; }
  .choice small { font-size: 11px; }
  .step { grid-template-columns: 28px 1fr; gap: 10px; }
  .step-num { width: 28px; height: 28px; font-size: 13px; }
  .step::before { left: 13px; top: 30px; }
  .card { padding: 16px; }
  .field-row { grid-template-columns: 1fr auto; } .field-row > span { grid-column: 1 / -1; }
}

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }
.plan { text-align: left; border: 1px solid var(--border); background: var(--elev); color: var(--text); border-radius: 14px; padding: 16px;
  font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 10px; transition: all .15s; box-shadow: var(--shadow-sm); }
.plan:hover { border-color: var(--border-2); }
.plan.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--elev)); }
.plan-head { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.plan-head .badge { margin-left: auto; }
.plan-radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-2); flex: none; position: relative; }
.plan.active .plan-radio { border-color: var(--accent); }
.plan.active .plan-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.plan .checklist { margin: 0; gap: 6px; font-size: 13.5px; }
.plan .checklist b { color: var(--text); }
.plan-est { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); padding-top: 10px; border-top: 1px dashed var(--border); }
.plan-est .ic { color: var(--accent); }
.plan-est b { color: var(--text); }
.switch-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 900px) { .switch-grid { grid-template-columns: 1fr; } }
.source-card { margin-bottom: 18px; }
.source-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.source-opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; border: 1px solid var(--border); background: var(--elev);
  color: var(--text); border-radius: 13px; padding: 13px 14px; font: inherit; cursor: pointer; transition: all .15s; }
.source-opt:hover { border-color: var(--border-2); }
.source-opt.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--elev)); }
.source-opt.active .plan-radio { border-color: var(--accent); }
.source-opt.active .plan-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.source-opt .plan-radio { margin-top: 2px; }
.source-opt b { display: block; font-weight: 620; }
.source-opt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.4; }
.terminal { border-radius: 13px; overflow: hidden; background: var(--code-bg); border: 1px solid rgba(255,255,255,.08); margin-top: 10px;
  box-shadow: 0 14px 40px -20px rgba(0,0,0,.6); }
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,.07); color: var(--code-dim); font-size: 12px; }
.terminal-bar .dots { display: flex; gap: 6px; margin-right: 6px; }
.terminal-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: #3a3a46; display: block; }
.terminal-bar .dots i:nth-child(1) { background: #ff5f57; } .terminal-bar .dots i:nth-child(2) { background: #febc2e; } .terminal-bar .dots i:nth-child(3) { background: #28c840; }
.terminal-bar .btn { margin-left: auto; height: 28px; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #e7e7ee; box-shadow: none; }
.terminal-bar .btn:hover { background: rgba(255,255,255,.12); }
.terminal pre { margin: 0; padding: 14px 16px; color: var(--code-text); white-space: pre-wrap; word-break: break-all; font-size: 13px; line-height: 1.6; }
.terminal pre .prompt { color: #6ee7b7; user-select: none; }
.checklist { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 9px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); }
.checklist li .ic { color: var(--ok); margin-top: 1px; width: 17px; height: 17px; }
.checklist li code, .guide-note code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; color: var(--text); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.subcard { border: 1px solid var(--border); border-radius: 13px; padding: 16px; background: var(--panel-2); }
.subcard h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.subcard h3 .ic { color: var(--accent); }
.guide-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-top: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text); font-size: 13.5px; }
.guide-note .ic { color: var(--accent); margin-top: 1px; }
.guide-note.warn { background: var(--warn-soft); border-color: transparent; }
.guide-note.warn .ic { color: var(--warn); }
.olist { counter-reset: s; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.olist li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; }
.olist li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; background: var(--panel-3); color: var(--muted); margin-top: 1px; }
.field-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.field-row:last-child { border-bottom: 0; }
.field-row code { overflow-wrap: anywhere; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--elev); border-radius: 10px; padding: 6px 8px 6px 11px; font-size: 13px; }
.mchip code { color: var(--muted); font-size: 12px; }
.cred { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.cred-item { border: 1px solid var(--border); background: var(--panel-2); border-radius: 12px; padding: 11px 12px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.cred-item .t { min-width: 0; flex: 1; }
.cred-item small { display: block; font-size: 11.5px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.cred-item code { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--muted); user-select: none; }
.switch input { display: none; }
.switch i { width: 34px; height: 20px; border-radius: 99px; background: var(--panel-3); position: relative; transition: background .2s; border: 1px solid var(--border-2); }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--accent); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(14px); }

/* ============ Баннеры ============ */
.banner { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13.5px;
  background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.banner .ic { color: var(--warn); }
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.banner.bad .ic { color: var(--bad); }

/* ============ Вход ============ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 430px; padding: 32px; }
.auth-card .logo { width: 46px; height: 46px; border-radius: 14px; }
.auth-card .logo .ic { width: 24px; height: 24px; }
.auth-card h1 { margin-top: 22px; font-size: 25px; }
.auth-card > p { margin: 8px 0 22px; color: var(--muted); }
.auth-feats { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.auth-feats div { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13.5px; }
.auth-feats .ic-chip { width: 30px; height: 30px; border-radius: 9px; }
.auth-feats .ic-chip .ic { width: 15px; height: 15px; }

/* ============ Модалки и уведомления ============ */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 8, 12, .55); backdrop-filter: blur(6px); opacity: 0; transition: opacity .18s; }
.modal-wrap.show { opacity: 1; }
.modal { width: 100%; max-width: 460px; background: var(--elev); border: 1px solid var(--border-2); border-radius: 18px;
  box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform .18s; }
.modal-wrap.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 0; }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.modal-ic.danger { background: var(--bad-soft); color: var(--bad); }
.modal-body { padding: 14px 18px 4px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; }
.modal-body b { color: var(--text); }
.modal-err { color: var(--bad); font-size: 13px; padding: 0 18px; min-height: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 18px; }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.preset { height: 30px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--elev); color: var(--text);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.preset:hover { background: var(--panel-2); }
.preset.neg { color: var(--bad); }
.type-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.type-opt { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border-2);
  background: var(--elev); cursor: pointer; text-align: left; font: inherit; color: var(--text); transition: all .15s; }
.type-opt:hover { background: var(--panel-2); }
.type-opt.active { border-color: var(--tc); box-shadow: 0 0 0 1px var(--tc); background: color-mix(in srgb, var(--tc) 9%, var(--elev)); }
.type-opt .tile { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 11.5px; flex: none;
  background: linear-gradient(135deg, var(--tc), color-mix(in srgb, var(--tc) 55%, #fff)); }
.type-opt b { display: block; font-size: 13.5px; }
.type-opt small { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.3; }
@media (max-width: 560px) { .type-pick { grid-template-columns: 1fr; } }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 550;
  background: var(--elev); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: all .25s; }
.toast.show { opacity: 1; transform: none; }
.toast .ic { color: var(--ok); }
.toast.err .ic { color: var(--bad); }

/* ============ Админка ============ */
.gen-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .gen-grid { grid-template-columns: 1fr; } }
.form-grid { display: grid; grid-template-columns: 1fr 120px; gap: 12px; }
.out-box { border: 1px dashed var(--accent-line); background: var(--accent-soft); border-radius: 13px; padding: 14px; }
.out-box textarea { font-family: var(--mono); font-size: 12.5px; min-height: 110px; background: var(--elev); resize: vertical; }
.type-bars { display: flex; flex-direction: column; gap: 12px; }
.type-bar-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: 12px; align-items: center; font-size: 13.5px; }
.type-bar-row .track { height: 8px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.type-bar-row .track i { display: block; height: 100%; border-radius: 99px; background: var(--tc); }
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .t { flex: 1; min-width: 0; }
.feed-item small { display: block; color: var(--dim); font-size: 12px; }
.type-btn { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; }
.type-btn:hover .badge { filter: brightness(1.1); text-decoration: underline; }
.mode-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .05em; }
.mode-pill.live { background: var(--ok-soft); color: var(--ok); }
.mode-pill.mock { background: var(--warn-soft); color: var(--warn); }

/* ============ Список моделей ============ */
.mlist { margin-bottom: 6px; }
.mrow { display: grid; grid-template-columns: 26px minmax(0, 1.7fr) minmax(0, 1.3fr) 82px; gap: 14px; align-items: center;
  padding: 12px 18px; border-bottom: 1px solid var(--border); }
.mrow:last-child { border-bottom: 0; }
.mrow.selected { background: var(--accent-soft); }
.mhead { padding-top: 10px; padding-bottom: 10px; background: var(--panel-2); color: var(--dim); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; }
.mrow-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mrow-name b { font-size: 14.5px; font-weight: 650; }
.mrow-id { border: 0; background: none; padding: 0; font-family: var(--mono); font-size: 11.5px; color: var(--dim); cursor: pointer; }
.mrow-id:hover { color: var(--accent); }
.mrow-for { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mrow-rec { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.mrow-rec small { color: var(--dim); font-size: 12px; line-height: 1.35; }
.mrow-mult { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--text); text-align: right; }
.mrow-act { text-align: right; }
@media (max-width: 860px) {
  .mrow { grid-template-columns: 26px 1fr auto; row-gap: 8px; }
  .mrow-rec { grid-column: 2 / 3; } .mrow-mult { grid-column: 3; grid-row: 1; } .mrow-act { grid-column: 2 / 4; text-align: left; }
  .mhead { display: none; }
}
