:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #171a21;
  --muted: #6b7280;
  --accent: #c2700a;
  --accent-strong: #a35c05;
  --accent-soft: #fdf1dd;
  --on-accent: #ffffff;
  --pos: #12805c;
  --pos-soft: #e2f5ec;
  --neg: #c2413a;
  --neg-soft: #fbe9e7;
  --warn: #9a6400;
  --warn-soft: #fdf3d3;
  --sidebar: #14171d;
  --sidebar-text: #aeb4c0;
  --sidebar-active: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  /* Цвета рядов на графиках: закреплены за сетью и не меняются от фильтров. */
  --series-bybit: #2a78d6;
  --series-ton: #eb6834;
  --series-trc20: #1baf7a;
  --series-bep20: #eda100;
  --series-subs: #4a3aa7;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #171a21;
    --surface-2: #1d2129;
    --border: #2a2f3a;
    --text: #e8eaee;
    --muted: #9099a8;
    --accent: #f0a431;
    --accent-strong: #f7b955;
    --accent-soft: #33260f;
    --on-accent: #1a1203;
    --pos: #4ccb98;
    --pos-soft: #12301f;
    --neg: #f0807a;
    --neg-soft: #3a1917;
    --warn: #eabf55;
    --warn-soft: #33290d;
    --sidebar: #0a0c0f;
    --shadow: none;
    --series-bybit: #3987e5;
    --series-ton: #d95926;
    --series-trc20: #199e70;
    --series-bep20: #c98500;
    --series-subs: #9085e9;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
h2 { margin: 0 0 14px; font-size: 15px; font-weight: 650; }

code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
.muted { color: var(--muted); }
.right { text-align: right; }
.grow { flex: 1 1 0; min-width: 0; }

/* --- Каркас --- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 240px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  overflow-y: auto;
}

.brand { display: block; padding: 4px 10px 18px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand span { margin-left: 6px; color: #f0a431; font-weight: 500; }
.brand-center { text-align: center; color: var(--text); padding-bottom: 6px; }
.brand-center span { color: var(--accent); }

.nav-group { margin: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6c7482; }

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(240, 164, 49, .16); color: var(--sidebar-active); font-weight: 600; }

.nav-badge { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; text-align: center; }

.sidebar-footer { margin-top: auto; padding-top: 16px; }
.sidebar-footer .btn { color: var(--sidebar-text); border-color: rgba(255, 255, 255, .14); background: transparent; }
.sidebar-footer .btn:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.main { flex: 1 1 0; min-width: 0; padding: 26px 32px 48px; max-width: 1400px; }

.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.topbar-title { flex: 1 1 0; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; }
.back { display: inline-block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.menu-toggle { display: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 16px; cursor: pointer; }

.lead { max-width: 76ch; margin: -6px 0 18px; color: var(--muted); }
.total { margin: 12px 2px 0; color: var(--muted); font-size: 13px; }

/* --- Карточки и плитки --- */

.card { margin-bottom: 18px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-extra { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.grid-2, .grid-3 { display: grid; gap: 18px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2, .grid-3, .tiles { margin-bottom: 18px; }
.grid-tight { gap: 10px; margin-bottom: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }

.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; overflow-wrap: anywhere; }
.tile-value small { font-size: 15px; font-weight: 500; color: var(--muted); }
.tile-note { font-size: 12.5px; color: var(--muted); }

/* --- Таблицы --- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th { padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); text-align: left; white-space: nowrap; }
.table th.right { text-align: right; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table-compact td { padding: 9px 0; }
.table-compact tbody tr:hover td { background: transparent; }
.table form { margin: 0; }

.sub { font-size: 12.5px; color: var(--muted); }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-wrap { margin: 0 0 14px; overflow-wrap: anywhere; color: var(--muted); }

/* --- Значки --- */

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--pos-soft); color: var(--pos); }
.badge-danger { background: var(--neg-soft); color: var(--neg); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* --- Формы --- */

input, select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
.input-short { width: 96px; text-align: right; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }

.check { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; cursor: pointer; }

.stack { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 0; }
.row-end { justify-content: flex-end; align-items: center; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled):not(.disabled) { background: var(--surface-2); }
.btn-danger { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.btn-danger:hover { filter: brightness(.97); }
.btn-small { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }

/* --- Прочее --- */

.flash { display: block; margin-bottom: 16px; padding: 11px 15px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; }
.flash-ok { background: var(--pos-soft); color: var(--pos); }
.flash-error { background: var(--neg-soft); color: var(--neg); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
a.flash:hover { text-decoration: none; filter: brightness(.98); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.pager-info { color: var(--muted); font-size: 13px; }

.props { display: grid; grid-template-columns: max-content 1fr; gap: 9px 20px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; overflow-wrap: anywhere; }

.quote { margin: 14px 0 0; padding: 10px 14px; border-left: 3px solid var(--border); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: currentColor; }
.dot.s-bybit { color: var(--series-bybit); }
.dot.s-ton { color: var(--series-ton); }
.dot.s-trc20 { color: var(--series-trc20); }
.dot.s-bep20 { color: var(--series-bep20); }
.dot.s-subs { color: var(--series-subs); }

/* Ширина задана атрибутом: график сжимается под узкую карточку, но не растягивается. */
.chart { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-tick { fill: var(--muted); font-size: 10px; text-anchor: end; font-variant-numeric: tabular-nums; }
.chart-label { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.chart-hit { fill: transparent; }
.chart-column:hover .chart-hit { fill: var(--surface-2); }
.chart path.s-bybit { fill: var(--series-bybit); }
.chart path.s-ton { fill: var(--series-ton); }
.chart path.s-trc20 { fill: var(--series-trc20); }
.chart path.s-bep20 { fill: var(--series-bep20); }
.chart path.s-subs { fill: var(--series-subs); }
.chart-empty { margin: 0; padding: 36px 0; text-align: center; color: var(--muted); }
.chart-total { margin: -4px 0 12px; }
.chart-total b { font-size: 20px; letter-spacing: -.01em; }

.chart-tip { position: fixed; z-index: 50; pointer-events: none; padding: 8px 11px; border-radius: 8px; background: var(--text); color: var(--surface); font-size: 12.5px; line-height: 1.45; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, .22); }
.chart-tip[hidden] { display: none; }
.chart-tip b { display: block; margin-bottom: 2px; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.segmented a { padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--accent-soft); color: var(--accent-strong); }
.inline-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.toolbar .inline-field input { min-width: 0; }

.notes { margin: 0; padding-left: 18px; color: var(--muted); }
.notes li { margin-bottom: 8px; }
.notes b { color: var(--text); }

.included { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.included-title { display: block; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: 0; }
.check-mark { flex: 0 0 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-weight: 700; font-size: 14px; }
.check-ok .check-mark { background: var(--pos-soft); color: var(--pos); }
.check-warn .check-mark { background: var(--warn-soft); color: var(--warn); }
.check-fail .check-mark { background: var(--neg-soft); color: var(--neg); }
.check-title { font-weight: 600; }
.check-hint { color: var(--muted); font-size: 13px; }

/* --- Вход --- */

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.auth-hint { margin: 0 0 18px; text-align: center; color: var(--muted); }
.auth-note { margin: 16px 0; text-align: center; font-size: 13px; color: var(--muted); }
.auth-note:last-child { margin-bottom: 0; }
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }
.qr { display: flex; justify-content: center; margin-bottom: 4px; }
.qr svg { border-radius: 10px; }
.secret { display: inline-block; margin-top: 6px; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); letter-spacing: .08em; overflow-wrap: anywhere; }
.code-input { font-size: 22px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.error-code { margin: 0; text-align: center; font-size: 54px; font-weight: 700; letter-spacing: -.03em; }

/* --- Узкие экраны --- */

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .menu-toggle { display: block; }
  .main { padding: 18px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 160px; }
  .topbar { flex-wrap: wrap; }
}
