/* ═══════════════════════════════════════════════════════════════════
   redlnd platform — тёмная тема, читаемая
   правило: каждая цифра объясняет себя сама; подписи видно без прищура
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:       #0B0C0F;
  --surface:  #14171C;      /* блоки светлее фона + волосяной контур */
  --raised:   #1C2027;      /* наведение, шапки таблиц */
  --hair:     #262A32;      /* разделители */
  --edge:     rgba(255,255,255,.055);

  --ink:      #F1F2F4;      /* основной текст и цифры */
  --ink-2:    #B4BAC4;      /* подписи, заголовки колонок — ЧИТАЕМЫЕ */
  --ink-3:    #858C98;      /* третьестепенное, но всё ещё видимое */

  --gold:     #E8C77E;      /* деньги */
  --blue:     #7AA2F7;      /* клики */
  --mint:     #7FD1AE;      /* конверсии / рост */
  --rose:     #F7768E;      /* отказы / падение */
  --amber:    #E0AF68;      /* ожидание */

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --r: 14px;
  --pad: 22px;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

/* ── шапка ──────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--edge);
}
.brand {
  display: flex; align-items: baseline; gap: 9px;
  font-size: 19px; font-weight: 700; letter-spacing: -.035em;
  font-variation-settings: "wdth" 78, "opsz" 24;
}
.brand i { font-style: normal; color: var(--gold); }
.brand small {
  font-family: var(--mono); font-size: 10px; font-weight: 400;
  color: var(--ink-3); letter-spacing: .18em; text-transform: uppercase;
}
.top__spacer { flex: 1; }

.seg { display: flex; gap: 2px; background: var(--surface); border-radius: 10px; padding: 3px; box-shadow: inset 0 0 0 1px var(--edge); }
.seg button {
  font-family: var(--mono); font-size: 12px; letter-spacing: .02em;
  padding: 6px 14px; border-radius: 7px; color: var(--ink-3);
  transition: background .18s, color .18s;
}
.seg button:hover { color: var(--ink-2); }
.seg button.on { background: var(--raised); color: var(--ink); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .02em;
  padding: 9px 15px; border-radius: 10px;
  background: var(--surface); color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--edge);
  transition: background .18s, color .18s;
}
.btn:hover { background: var(--raised); color: var(--ink); }
.btn--ghost { background: none; box-shadow: none; }
.btn--ghost:hover { background: var(--surface); }
.btn[disabled] { opacity: .45; cursor: progress; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot--ok { background: var(--mint); }
.dot--warn { background: var(--amber); }
.dot--err { background: var(--rose); }

/* ── сетка ──────────────────────────────────────────────────────── */
.wrap { padding: 22px 28px 70px; display: grid; gap: 22px; max-width: 1640px; margin: 0 auto; }
.row { display: grid; gap: 22px; }
.row--kpi {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px; background: var(--hair); border-radius: var(--r); overflow: hidden;
  box-shadow: 0 0 0 1px var(--edge);
}
.row--2 { grid-template-columns: minmax(0, 2.3fr) minmax(0, 1fr); }
/* внизу наоборот: кампаний мало, лента конверсий шире */
.row--2r { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
@media (max-width: 1150px) { .row--2, .row--2r { grid-template-columns: 1fr; } }

/* заголовок секции — объясняет, что ниже */
.sec { display: flex; align-items: baseline; gap: 12px; margin-bottom: -6px; }
.sec h1 { font-size: 17px; font-weight: 600; letter-spacing: -.025em; font-variation-settings: "wdth" 85, "opsz" 20; }
.sec__note { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

.card { background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: 0 0 0 1px var(--edge); }
.card__head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px var(--pad) 14px;
  border-bottom: 1px solid var(--hair);
}
.card__head h2 {
  font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap;
  letter-spacing: -.02em; font-variation-settings: "wdth" 88, "opsz" 18;
}
.card__head .note {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__head .sp { flex: 1; }
.card__body { padding: var(--pad); }
.card__body--flush { padding: 0; }

/* ── KPI: цифра + что она значит ────────────────────────────────── */
.kpi { background: var(--surface); padding: 18px var(--pad) 20px; }
.kpi__label {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: .04em; color: var(--ink-2); margin-bottom: 10px;
}
.kpi__row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kpi__value {
  font-size: 40px; font-weight: 600; line-height: 1;
  letter-spacing: -.03em; font-variation-settings: "wdth" 88, "opsz" 44;
  font-variant-numeric: tabular-nums;
}
.kpi__value small { font-size: 21px; opacity: .5; font-weight: 400; }
.kpi__sub { margin-top: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
.kpi--money .kpi__value { color: var(--gold); }
.kpi--clicks .kpi__value { color: var(--blue); }
.kpi--conv .kpi__value   { color: var(--mint); }

.dl {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}
.dl--up   { color: var(--mint); background: color-mix(in srgb, var(--mint) 13%, transparent); }
.dl--dn   { color: var(--rose); background: color-mix(in srgb, var(--rose) 13%, transparent); }
.dl--flat { color: var(--ink-3); background: var(--raised); }

/* ── график ─────────────────────────────────────────────────────── */
.chart-wrap { position: relative; padding: 16px var(--pad) 10px; }
.chart { width: 100%; height: 264px; display: block; }
.chart .grid { stroke: var(--hair); stroke-width: 1; }
.chart .grid--0 { stroke: #30353E; }
.chart .bar { fill: var(--blue); opacity: .34; }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#goldFade); }
.chart .pt { fill: var(--bg); stroke: var(--gold); stroke-width: 2; }
.chart .ax { font-family: var(--mono); font-size: 10.5px; fill: var(--ink-3); }
.chart .ax--gold { fill: color-mix(in srgb, var(--gold) 70%, var(--ink-3)); }
.chart .ax--blue { fill: color-mix(in srgb, var(--blue) 70%, var(--ink-3)); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(255,255,255,.035); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }

.tip {
  position: absolute; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
  background: #1F242C; border-radius: 10px; padding: 10px 13px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.09), 0 12px 28px rgba(0,0,0,.55);
  font-family: var(--mono); font-size: 12px; white-space: nowrap; z-index: 20;
}
.tip.on { opacity: 1; transform: translateY(0); }
.tip b { display: block; font-family: var(--sans); font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.tip .r { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.tip .r + .r { margin-top: 3px; }
.tip .r i { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.tip .r span { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 18px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: -1px; }
.legend em { font-style: normal; color: var(--ink-3); }

/* ── таблицы ────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
thead th {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: .02em; color: var(--ink-2);
  text-align: left; padding: 11px var(--pad); white-space: nowrap;
  background: var(--raised);
  cursor: pointer; user-select: none; transition: color .15s;
  position: sticky; top: 0; z-index: 2;
}
thead th:hover { color: var(--ink); }
thead th.num, td.num { text-align: right; }
thead th .arrow { opacity: .25; margin-left: 5px; }
thead th.sorted { color: var(--ink); }
thead th.sorted .arrow { opacity: 1; color: var(--gold); }
tbody td {
  padding: 12px var(--pad); font-size: 13.5px; white-space: nowrap;
  border-bottom: 1px solid var(--hair);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--raised); }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
td.key { font-family: var(--mono); font-size: 12.5px; }
td.dim { color: var(--ink-2); }
.money { color: var(--gold); }
.zero { color: var(--ink-3); opacity: .55; }

tfoot td {
  padding: 12px var(--pad); font-size: 13px; white-space: nowrap;
  border-top: 1px solid var(--hair); background: var(--raised);
  font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink);
}
tfoot td.lbl { font-family: var(--mono); color: var(--ink-2); }

.rank td.key::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 9px; vertical-align: middle; background: var(--gold);
}
.rank-2 td.key::before { opacity: .6; }
.rank-3 td.key::before { opacity: .32; }

/* доля кликов — черта под числом */
.share { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.share em { font-style: normal; }
.share i { display: block; height: 2px; border-radius: 1px; background: var(--blue); opacity: .5; }

.tag {
  display: inline-block; font-family: var(--mono); font-size: 10.5px;
  padding: 3px 8px; border-radius: 6px; letter-spacing: .03em;
  background: var(--raised); color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--edge);
}
.tag--ok   { color: var(--mint); }
.tag--wait { color: var(--amber); }
.tag--bad  { color: var(--rose); }

.empty { padding: 34px var(--pad); color: var(--ink-3); font-family: var(--mono); font-size: 12px; }

/* ── разбивка: доля читается заливкой строки ────────────────────── */
.bd { display: grid; }
.bd__row {
  position: relative; display: grid;
  grid-template-columns: 1fr auto auto; align-items: center; gap: 14px;
  padding: 11px var(--pad); border-bottom: 1px solid var(--hair);
}
.bd__row:last-child { border-bottom: 0; }
.bd__fill {
  position: absolute; inset: 0 auto 0 0;
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  border-right: 2px solid color-mix(in srgb, var(--blue) 70%, transparent);
}
.bd__key { position: relative; font-family: var(--mono); font-size: 13px; color: var(--ink); }
.bd__val { position: relative; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); }
.bd__pct { position: relative; font-family: var(--mono); font-size: 12px; color: var(--ink-3); width: 44px; text-align: right; }

/* ── вход ───────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(370px, 100%); background: var(--surface); border-radius: 18px; padding: 32px; box-shadow: 0 0 0 1px var(--edge); }
.login h1 {
  font-size: 25px; letter-spacing: -.04em; margin-bottom: 6px;
  font-variation-settings: "wdth" 78, "opsz" 28;
}
.login p.hint { color: var(--ink-3); font-family: var(--mono); font-size: 11px; letter-spacing: .14em; margin-bottom: 26px; }
.login input {
  width: 100%; padding: 13px 15px; margin-bottom: 12px;
  background: var(--bg); border: 0; border-radius: 11px;
  color: var(--ink); font-family: var(--mono); font-size: 13px;
}
.login input:focus { outline: 1px solid var(--gold); }
.login button {
  width: 100%; padding: 13px; border-radius: 11px;
  background: var(--gold); color: #17140C; font-weight: 600;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .04em;
}
.login .err { color: var(--rose); font-family: var(--mono); font-size: 11.5px; margin-bottom: 12px; }

.skel { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hair); border-radius: 5px; border: 3px solid var(--bg); }

/* лента конверсий: колонка узкая, ужимаем поля */
#convTable thead th, #convTable tbody td { padding-left: 14px; padding-right: 14px; }
#convTable tbody td { font-size: 12.5px; }

/* вторая строка в ячейке: оффер под названием кампании */
td.key .sub { margin-top: 4px; font-size: 11.5px; color: var(--ink-3); }
#campTable thead th, #campTable tbody td { padding-left: 16px; padding-right: 16px; }
