/* Stakan Cloud — админка и личный кабинет. Тёмная и светлая темы:
   по системе, вручную — атрибут data-theme на <html>. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6eb;
  --text: #161a22;
  --text-2: #4a5160;
  --muted: #7a8190;
  --accent: #3d6fd9;
  --accent-ink: #ffffff;
  --accent-soft: #e7eefc;
  --ok: #18865d;
  --ok-soft: #e3f4ec;
  --warn: #a5650a;
  --warn-soft: #fbf0dc;
  --bad: #c43843;
  --bad-soft: #fbe6e7;
  --chart: #5b8def;
  --chart-hover: rgba(91, 141, 239, .10);
  --grid: #e8ebf0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1118;
    --surface: #161a24;
    --surface-2: #1d2230;
    --border: #2a3142;
    --text: #e7eaf0;
    --text-2: #b4bac7;
    --muted: #868ea0;
    --accent: #6b98f2;
    --accent-ink: #0b1020;
    --accent-soft: #1d2a47;
    --ok: #4cc999;
    --ok-soft: #14301f;
    --warn: #e0a54a;
    --warn-soft: #33270f;
    --bad: #ef6b73;
    --bad-soft: #3a1a1d;
    --chart: #6b98f2;
    --chart-hover: rgba(107, 152, 242, .14);
    --grid: #252c3b;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1118;
  --surface: #161a24;
  --surface-2: #1d2230;
  --border: #2a3142;
  --text: #e7eaf0;
  --text-2: #b4bac7;
  --muted: #868ea0;
  --accent: #6b98f2;
  --accent-ink: #0b1020;
  --accent-soft: #1d2a47;
  --ok: #4cc999;
  --ok-soft: #14301f;
  --warn: #e0a54a;
  --warn-soft: #33270f;
  --bad: #ef6b73;
  --bad-soft: #3a1a1d;
  --chart: #6b98f2;
  --chart-hover: rgba(107, 152, 242, .14);
  --grid: #252c3b;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1.mono { font-size: 22px; letter-spacing: .02em; }
td a.mono, td .mono { white-space: nowrap; }
.icon { width: 16px; height: 16px; vertical-align: -3px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
[hidden] { display: none !important; }

/* ---------- каркас админки ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 650; font-size: 15px; color: var(--text); }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 16px; height: 16px; flex: none; }
.side-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.side-foot .row { display: flex; gap: 6px; }
.main { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { color: var(--muted); margin: 2px 0 0; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- карточки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card > h2:first-child { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td .sub, .sub { color: var(--muted); font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- значки ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.plain::before { display: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- формы ---------- */
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 4px; color: var(--text-2); }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input, .inline select { width: auto; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; color: var(--text); margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; background: var(--surface-2); flex-wrap: wrap; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.copied { color: var(--ok); border-color: var(--ok); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline-form { display: inline; margin: 0; }

details.action { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
details.action > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.action > summary::-webkit-details-marker { display: none; }
details.action > summary::after { content: "›"; color: var(--muted); transition: transform .15s; font-size: 18px; line-height: 1; }
details.action[open] > summary::after { transform: rotate(90deg); }
details.action > .body { padding: 2px 14px 14px; }
details.action.danger > summary { color: var(--bad); }

/* ---------- сообщения ---------- */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.note { padding: 11px 14px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- ключ ---------- */
.key {
  font-family: var(--mono); font-size: 28px; font-weight: 600; letter-spacing: .06em;
  padding: 16px 20px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  text-align: center; user-select: all;
}
.copy-box { position: relative; }
.copy-box textarea { font-family: var(--sans); min-height: 240px; background: var(--surface-2); }

/* ---------- графики ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--chart); }
.chart-hover { fill: transparent; }
.chart-hit:hover .chart-hover { fill: var(--chart-hover); }
.chart-hit:hover .chart-bar { filter: brightness(1.12); }
.chart-grid { stroke: var(--grid); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.dist { display: grid; gap: 8px; }
.dist-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.dist-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.dist-row .track { display: block; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.dist-row .fill { display: block; height: 100%; background: var(--chart); border-radius: 4px; }
.dist-row .val { color: var(--text); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.heat td { text-align: center; font-size: 12px; padding: 7px 6px; }
.heat td.c { color: var(--text); }
.heat td.na { color: var(--muted); }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; padding-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 20px; }
.auth-card .lead { text-align: center; color: var(--muted); margin-bottom: 20px; }
.qr { display: flex; justify-content: center; margin: 8px 0 12px; }
.qr svg { width: 200px; height: 200px; border-radius: 10px; border: 8px solid #fff; }
.secret { font-family: var(--mono); text-align: center; word-break: break-all; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px; }
.otp { font-family: var(--mono); font-size: 24px !important; letter-spacing: .4em; text-align: center; }

/* ---------- кабинет ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .in { max-width: 1040px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .brand { padding: 0; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px 56px; }
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding: 40px 0 24px; }
.hero h1 { font-size: 40px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-bottom: 14px; }
.hero .lead { font-size: 17px; color: var(--text-2); margin-bottom: 22px; }
.hero ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.hero li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); }
.hero li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--chart); }
.status-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.big { font-size: 20px; font-weight: 650; }
.dl { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.dl.rec { border-color: var(--accent); background: var(--accent-soft); }
.notes h4 { font-size: 14px; margin: 10px 0 6px; }
.notes ul { margin: 0 0 10px; padding-left: 20px; }
.notes li { margin-bottom: 3px; }
.switch { display: flex; align-items: flex-start; gap: 12px; }
.switch input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; font-weight: 500; }
.footer { color: var(--muted); font-size: 12px; text-align: center; padding: 24px 0 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 8px 0 4px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side-foot { margin: 0 0 0 auto; border: 0; flex-direction: row; align-items: center; }
  .main { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .hero { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
  .key { font-size: 20px; }
}

/* Выбор доступов (модули, биржи, дополнительно). */
.ent { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 10px; background: var(--surface-2); }
.ent-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.ent-count { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 15px; }
.ent-gap { flex: 1; }
.ent-group { border: 0; padding: 0; margin: 10px 0 4px; min-width: 0; }
.ent-group legend { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0; margin-bottom: 6px; }
.linkish { background: none; border: 0; padding: 0 0 0 8px; color: var(--accent); font: inherit; font-size: 11px; text-transform: none; letter-spacing: 0; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.ent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.ent-item { position: relative; display: flex; gap: 9px; align-items: flex-start; margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); cursor: pointer; font-weight: 500; transition: border-color .12s, background .12s; }
.ent-item:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.ent-item input { width: 16px; height: 16px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.ent-item:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.ent-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ent-name { color: var(--text); display: flex; gap: 6px; align-items: center; }
.ent-hint { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.35; }
.ent-base { font-size: 10px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; text-transform: uppercase; letter-spacing: .04em; }
.ent-diff { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; }
.ent-item.added .ent-diff, .ent-dot.add { background: var(--ok); }
.ent-item.removed .ent-diff, .ent-dot.rm { background: var(--bad); }
.ent-item.removed .ent-name { text-decoration: line-through; color: var(--muted); }
.ent-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 3px 0 8px; }
.ent-legend { margin-top: 8px; }
.ent-chips .badge { font-weight: 500; }
.badge.g-module { background: var(--accent-soft); color: var(--accent); }
.badge.g-exchange { background: var(--ok-soft); color: var(--ok); }
.badge.g-addon { background: var(--warn-soft); color: var(--warn); }
tr.dim td { opacity: .55; }
.ent-view { display: grid; gap: 12px; }
.ent-view h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.ent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; list-style: none; padding: 0; margin: 0; }
.ent-list li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.ent-list li.off { opacity: .5; background: transparent; }
.ent-list li .mark { flex: none; width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.ent-list li.on .mark { background: var(--ok-soft); color: var(--ok); }
.ent-list li.off .mark { background: var(--surface-2); color: var(--muted); }
.ent-list li small { display: block; color: var(--muted); font-size: 11.5px; }
