/* Кабинет «Елена» — v2. Серьёзная аналитика: zinc-нейтраль + один акцент (indigo),
   тонкие линейные иконки (Lucide, 1.5px), tabular-nums, hairline-границы.
   Ориентир: Stripe / Linear / Baremetrics. */

:root {
  --bg: #fafafa; --surface: #ffffff; --surface-2: #f4f4f5;
  --border: #e4e4e7; --border-strong: #d4d4d8;
  --ink: #18181b; --ink-2: #3f3f46; --muted: #71717a; --muted-2: #a1a1aa;
  --accent: #6366f1; --accent-hover: #4f46e5; --accent-soft: #eef2ff;
  --up: #059669; --up-soft: #ecfdf5; --down: #dc2626; --down-soft: #fef2f2;
  --warn: #d97706; --warn-soft: #fffbeb;
  --sidebar-bg: #18181b; --sidebar-fg: #a1a1aa; --sidebar-active: #ffffff; --sidebar-hover: #27272a;
  --sidebar-w: 236px; --topbar-h: 56px; --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
.num, .kpi__value, .delta, td.n, th.n, table { font-variant-numeric: tabular-nums; }
svg.i { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.s { width: 16px; height: 16px; }
svg.i.lg { width: 22px; height: 22px; }

/* ── Вход ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 34px; width: 348px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px rgba(0,0,0,.06); }
.login-card .mark { display: flex; align-items: center; gap: 9px; color: var(--accent); margin-bottom: 18px; }
.login-card h1 { font-size: 18px; margin: 0 0 3px; color: var(--ink); }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 5px; font-weight: 500; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { width: 100%; margin-top: 20px; padding: 11px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-size: 15px; font-weight: 600; }
.login-card button:hover { background: var(--accent-hover); }
.login-err { color: var(--down); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* ── Каркас ───────────────────────────────────────────────────────────── */
.app { display: none; }
.app.shown { display: block; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-fg); overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 17px 20px; font-size: 15px; font-weight: 600; color: #fff; }
.brand .m { color: var(--accent); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; color: var(--sidebar-fg); border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.nav a:hover { background: var(--sidebar-hover); color: #d4d4d8; }
.nav a.active { background: var(--sidebar-hover); color: var(--sidebar-active); }
.nav a.active .i { color: var(--accent); }
.sidebar .foot { margin-top: auto; padding: 16px 20px; font-size: 11px; color: #52525b; line-height: 1.5; }

.topbar { position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h); background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; z-index: 5; }
.topbar h2 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.topbar button { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--ink-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; font-size: 12.5px; font-weight: 500; }
.topbar button:hover { background: var(--surface-2); }

.work { margin-left: var(--sidebar-w); padding: calc(var(--topbar-h) + 24px) 26px 48px; max-width: 1280px; }
.section { display: none; }
.section.shown { display: block; }

/* ── Секции / сетки ───────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 8px; }
.c2 { grid-template-columns: 1fr 1fr; }
.c3 { grid-template-columns: repeat(3, 1fr); }
.c23 { grid-template-columns: 2fr 1fr; }

.sec-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.sec-title .i { color: var(--muted-2); }
.sec-title:first-child { margin-top: 4px; }
.card-h { font-size: 14px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-h .hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: auto; }

/* KPI-плитка */
.kpi { position: relative; }
.kpi__head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.kpi__label { font-size: 11.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi__ico { color: var(--muted-2); }
.kpi__value { font-size: 29px; font-weight: 600; color: var(--ink); line-height: 1.05; }
.kpi__value .unit { font-size: 16px; color: var(--muted-2); font-weight: 500; margin-left: 2px; }
.kpi__foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.kpi__sub { font-size: 12px; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.flat { color: var(--muted); }
.delta .i { width: 14px; height: 14px; }
.spark { margin-left: auto; }

.est { font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; text-transform: uppercase; letter-spacing: .03em; vertical-align: middle; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 13px; padding: 16px 2px; }
.bench { font-size: 11px; color: var(--muted-2); margin-top: 6px; }

/* Пилюли статуса / RAG */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.green { background: var(--up); } .dot.amber { background: var(--warn); }
.dot.red { background: var(--down); } .dot.gray { background: var(--muted-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.chip.active { background: var(--up-soft); color: var(--up); }
.chip.quiet { background: var(--warn-soft); color: var(--warn); }
.chip.expired { background: var(--down-soft); color: var(--down); }
.chip.revoked { background: var(--surface-2); color: var(--muted); }

/* Карточки-действия «что чинить» */
.attn { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: 10px; border: 1px solid var(--border); background: #fff; margin-bottom: 9px; }
.attn.red { background: var(--down-soft); border-color: #fecaca; }
.attn.amber { background: var(--warn-soft); border-color: #fde68a; }
.attn.green { background: var(--up-soft); border-color: #a7f3d0; }
.attn .i { margin-top: 1px; flex: none; }
.attn.red .i { color: var(--down); } .attn.amber .i { color: var(--warn); } .attn.green .i { color: var(--up); }
.attn .t { font-weight: 600; font-size: 13.5px; }
.attn .b { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.attn ul { margin: 6px 0 0; padding-left: 17px; font-size: 12.5px; }

/* Таблицы */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcfcfd; }
td.n, th.n { text-align: right; }
.money { font-weight: 600; }
.pos { color: var(--up); } .neg { color: var(--down); }

/* Мини-бары (расход/активность) */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 92px; margin-top: 4px; }
.bars .bar { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .bar > i { position: absolute; inset: 0; background: var(--accent); opacity: .55; border-radius: 3px 3px 0 0; }
.bars .bar.b2 > i { background: var(--up); }
.bars-x { display: flex; gap: 5px; margin-top: 5px; }
.bars-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted-2); }

/* Воронка */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.fstep { }
.fstep .frow { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; font-size: 13px; }
.fstep .flabel { font-weight: 500; }
.fstep .fmeta { font-size: 12px; color: var(--muted); }
.fstep .ftrack { height: 26px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fstep .ffill { height: 100%; background: var(--accent); opacity: .85; border-radius: 6px; min-width: 2px; display: flex; align-items: center; padding-left: 9px; color: #fff; font-size: 12px; font-weight: 600; }
.fdrop { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--down); background: var(--down-soft); padding: 1px 7px; border-radius: 5px; margin-left: 6px; }

/* Когорты (heatmap) */
.cohort td.cell { text-align: center; font-size: 12px; border: 1px solid var(--surface); border-radius: 4px; }
.cohort td.small { color: var(--muted-2); }
.cohort .csize { color: var(--muted); font-weight: 600; }

/* Формы */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .fld { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.form-row input, .form-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-row button { padding: 9px 15px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-weight: 600; font-size: 13px; }
.form-row button:hover { background: var(--accent-hover); }
.form-err { color: var(--down); font-size: 12px; margin-top: 8px; min-height: 14px; }
.linkbox { display: inline-flex; align-items: center; gap: 6px; }
.linkbox code { background: var(--surface-2); padding: 3px 7px; border-radius: 5px; font-size: 12px; color: var(--ink-2); }
.copy { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 11px; color: var(--muted); }
.copy:hover { background: var(--surface-2); }

.banner { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border: 1px solid #c7d2fe; color: #3730a3; padding: 12px 15px; border-radius: 10px; font-size: 12.5px; margin-bottom: 16px; }
.banner .i { color: var(--accent); flex: none; margin-top: 1px; }

/* ── Адаптив ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .c2, .c3, .c23 { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; flex-direction: column; }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px 8px; }
  .nav a { white-space: nowrap; }
  .sidebar .foot { display: none; }
  .topbar { position: static; left: 0; }
  .work { margin-left: 0; padding: 20px 14px 44px; }
}
