:root {
  --bg: #0e1117; --panel: #161b22; --panel2: #1c2330; --line: #2a3140;
  --fg: #e6edf3; --muted: #8b97a6; --accent: #3b82f6; --ok: #22c55e;
  --local: #f59e0b; --ours: #3b82f6;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
/* Пропорции как на admin.gsaworld.ru: карточка 320px, padding 24, заголовок 20px,
   вертикальный ритм — flex-gap, а не margin у каждого поля. */
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .sub { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; margin-top: 6px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--fg); font-size: 15px; }
.login-card button { width: 100%; padding: 11px; background: var(--accent); border: 0; border-radius: 8px; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.error { background: #3b1418; border: 1px solid #7f1d1d; color: #fca5a5; padding: 9px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* shell */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; gap: 8px; }
.brand { font-size: 20px; font-weight: 700; }
.brand span { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
.meta { color: var(--muted); font-size: 13px; }
main { max-width: 1080px; margin: 0 auto; padding: 28px; }

.hero h1 { font-size: 22px; margin: 0 0 14px; }
.position { display: flex; align-items: center; gap: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; }
.pos-num { font-size: 52px; font-weight: 800; color: var(--accent); line-height: 1; }
.pos-facts b { font-size: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 22px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.card.done { border-color: var(--ok); }
.card-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.card-goal { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.card-add { font-size: 13px; color: var(--local); }
.card.done .card-add { color: var(--ok); }

.block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; margin: 16px 0; }
.block h2 { margin: 0 0 10px; font-size: 17px; }
.block p { margin: 0; color: #cdd6e0; }
.variant-c { border-left: 3px solid var(--accent); }
.block.race { border-left: 3px solid var(--ok); }

.back { color: var(--muted); }
.back:hover { color: var(--fg); }

/* landing tiles */
.home-title { font-size: 22px; margin: 4px 0 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.tile { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; color: var(--fg); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.tile-ico { font-size: 34px; }
.tile h2 { margin: 12px 0 8px; font-size: 20px; }
.tile p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.tile-go { color: var(--accent); font-weight: 600; font-size: 14px; }

/* info row: gauge + gap */
.info-row { display: grid; grid-template-columns: 300px 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 720px) { .info-row { grid-template-columns: 1fr; } }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.g-track { fill: none; stroke: var(--panel2); stroke-width: 12; }
.g-fill { fill: none; stroke: var(--ok); stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray .5s; }
.g-pct { fill: var(--fg); font-size: 26px; font-weight: 800; text-anchor: middle; }
.g-sub { fill: var(--muted); font-size: 12px; text-anchor: middle; }

/* gap bar chart */
.bars { display: flex; flex-direction: column; gap: 9px; margin-bottom: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr max-content; align-items: center; gap: 10px; font-size: 13px; }
.bar-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--panel2); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #3b82f6); border-radius: 6px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
.bar-row.ours .bar-name { color: var(--accent); font-weight: 700; }
.bar-row.ours .bar-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-sub { color: var(--muted); font-size: 11px; }

/* LI flow diagram */
.flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.flow-step { flex: 1 1 150px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.flow-step b { display: block; font-size: 14px; }
.flow-step span { color: var(--muted); font-size: 12px; }
.flow-step.highlight { border-color: var(--ok); }
.flow-arrow { display: flex; align-items: center; color: var(--muted); font-size: 20px; }
.notes { margin: 0; padding-left: 18px; color: #cdd6e0; font-size: 14px; }
.notes li { margin: 4px 0; }

/* checklist red → green */
.sec-count { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; gap: 12px; align-items: flex-start; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--local); border-radius: 10px; padding: 12px 14px; margin: 0; }
.check-item.done { border-left-color: var(--ok); }
.status { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--local); background: transparent; color: var(--local); font-size: 15px; font-weight: 800; cursor: pointer; }
.check-item.done .status { border-color: var(--ok); background: var(--ok); color: #06210f; }
.check-body { flex: 1; min-width: 0; }
.check-title { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.check-title::-webkit-details-marker { display: none; }
.check-item.done .check-title { color: var(--ok); }
.check-title .expand { font-size: 11px; font-weight: 400; color: var(--muted); white-space: nowrap; }
details[open] > .check-title .expand { color: var(--accent); }
details[open] > .check-title .expand::after { content: ''; }
.check-detail { color: var(--muted); font-size: 13px; margin-top: 6px; }
.steps-label { font-size: 12px; color: var(--accent); margin-top: 10px; font-weight: 600; }
.check-steps { margin: 6px 0 2px; padding-left: 22px; color: #cdd6e0; font-size: 13px; }
.check-steps li { margin: 4px 0; }

/* динамика: форма периода, пресеты, график, таблица */
.range-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 12px; }
.range-label { color: var(--muted); font-size: 13px; }
.range-form input#range { margin-left: 8px; min-width: 240px; padding: 9px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--fg); }
.btn { display: inline-block; padding: 9px 14px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; opacity: .92; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.btn-soft { background: var(--panel2); color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
.btn-soft.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.note { margin: 8px 0 18px; }
.small { font-size: 12.5px; }
.chart-wrap { position: relative; height: 340px; }
.tbl-scroll { overflow-x: auto; max-width: 100%; }
.board td.up { color: var(--ok); }
.board td.down { color: #f87171; }
.board td.closed { color: var(--muted); font-style: italic; }
.hint { margin-top: 14px; background: var(--panel2); border-left: 3px solid var(--local); border-radius: 8px; padding: 12px 16px; font-size: 13px; }
.hint ul { margin: 8px 0 0; padding-left: 18px; color: #cdd6e0; }
.hint li { margin: 4px 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; }
table td { padding: 8px 10px; border-bottom: 1px solid var(--panel2); }
.board tr.ours { background: rgba(59,130,246,.14); }
.board tr.local { background: rgba(245,158,11,.08); }
.board .descr { display: block; color: var(--muted); font-size: 12px; }
.net-badge { display: inline-block; font-size: 11px; color: #c4b5fd; background: rgba(139,92,246,.16); border: 1px solid rgba(139,92,246,.4); border-radius: 6px; padding: 1px 6px; vertical-align: middle; white-space: nowrap; }

/* цель-трекер липкости */
.goal-track { margin: 14px 0 6px; }
.goal-bar { position: relative; height: 16px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; margin: 26px 0 8px; }
.goal-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #22c55e); border-radius: 8px; transition: width .5s; }
.goal-mile { position: absolute; top: -24px; transform: translateX(-50%); text-align: center; }
.goal-mile::after { content: ''; position: absolute; left: 50%; top: 22px; width: 1px; height: 16px; background: var(--line); transform: translateX(-50%); }
.goal-flag { font-size: 11px; color: var(--muted); white-space: nowrap; }
.goal-mile.reached .goal-flag { color: var(--ok); font-weight: 700; }
.goal-meta { color: #cdd6e0; font-size: 13px; }
.legend { margin-top: 12px; color: var(--muted); font-size: 12px; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.sw.ours { background: rgba(59,130,246,.6); }
.sw.local { background: rgba(245,158,11,.5); }

/* Планы: шапка-цель + переключатель оси группировки */
.goal-banner { border-left: 3px solid var(--ok); background: linear-gradient(180deg, rgba(34,197,94,.08), var(--panel)); }
.goal-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.goal-flag { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--ok); font-weight: 700; }
.goal-banner h1 { margin: 0; font-size: 22px; }
.goal-nums { display: flex; gap: 28px; flex-wrap: wrap; margin: 14px 0 10px; }
.goal-num b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.goal-num span { font-size: 12px; color: var(--muted); }
.goal-num.accent b { color: var(--ok); }

.axis-switch { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.axis-label { font-size: 13px; color: var(--muted); }
.axis-tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.axis-tab { padding: 7px 16px; font-size: 14px; color: var(--muted); background: var(--bg); }
.axis-tab + .axis-tab { border-left: 1px solid var(--line); }
.axis-tab:hover { text-decoration: none; color: var(--fg); }
.axis-tab.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Кабинет LI: сетка карточек-отчётов */
.kab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 8px; }
.kab-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kab-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; gap: 8px; }
.kab-head b { font-size: 14px; }
.kab-card .bar-name { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kab-delta { font-size: 11px; margin-left: 4px; }

/* Гео-атрибуция: сравнительные пары и апсайд */
.cmp-shares { display: flex; gap: 24px; flex-wrap: wrap; margin: 6px 0 10px; }
.cmp-one { display: flex; flex-direction: column; gap: 2px; }
.cmp-lbl { font-size: 12px; color: var(--muted); }
.cmp-one b { font-size: 26px; line-height: 1; }
.uplift-nums { display: flex; gap: 22px; flex-wrap: wrap; margin: 8px 0 10px; }
.v1-steps { margin: 6px 0 8px; padding-left: 20px; }
.v1-steps li { margin: 4px 0; color: #cdd6e0; }
.v1-sub { font-size: 15px; margin: 16px 0 8px; }
.letter-box { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; background: var(--panel2); }
.letter-box summary { cursor: pointer; padding: 10px 14px; font-size: 14px; }
.letter-box summary:hover { color: var(--fg); }
.letter { margin: 0; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--bg);
  font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; color: #cdd6e0;
  white-space: pre-wrap; overflow-x: auto; }

/* GSC: тревога по каналу */
.alarm-card { border-left: 3px solid #ef4444; background: linear-gradient(180deg, rgba(239,68,68,.08), var(--panel)); }
.alarm-card h2 { color: #fca5a5; }
.bar-fill.down-fill { background: rgba(239,68,68,.55); }

/* Карта лидерства: день × час */
.leadgrid { border-collapse: collapse; }
.leadgrid th.lg-h { font-size: 9px; color: var(--muted); font-weight: 400; padding: 0 1px 4px; }
.leadgrid td.lg-day, .leadgrid th.lg-day { font-size: 11px; color: var(--muted); padding-right: 8px; white-space: nowrap; }
.leadgrid td.lg-cell { width: 15px; height: 15px; border: 1px solid var(--bg); border-radius: 2px; }
.lg-lead { background: var(--ok); }
.lg-mixed { background: var(--local); }
.lg-lost { background: rgba(239,68,68,.5); }
.lg-nodata { background: var(--line); }
.lg-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin: 0 2px 0 8px; }
.check-note { background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.35); border-radius: 8px;
  padding: 10px 14px; margin: 10px 0; font-size: 13px; color: #cdd6e0; }
