/* Призма — дашборд. Светлая плотная тема в духе Яндекс Метрики:
   белые виджеты на сером фоне, тонкие разделители, синий для ссылок/графиков,
   жёлтый #fc0 — точечный акцент (примари-кнопки, активные состояния, логотип). */
:root {
  color-scheme: light;
  --page: #f3f4f6;          /* серый холст */
  --surface: #ffffff;       /* белые виджеты */
  --ink: #21252b;
  --ink-2: #4b5058;
  --muted: #848a93;
  --grid: #eef0f2;          /* линии сетки графиков и таблиц */
  --baseline: #c9cdd2;
  --border: #e3e5e9;        /* граница виджетов */
  --border-strong: #d5d8dd; /* граница контролов */
  --hover: #f6f7f9;         /* ховер строк и пунктов */
  --ya: #fc0;               /* жёлтый акцент — только точечно */
  --ya-press: #f2c200;
  --series-1: #0d66d0;      /* синий: ссылки и первая серия графиков */
  --series-2: #e8684a;
  --series-3: #1e9e6a;
  --good: #14a14a;
  --good-text: #0f7d3a;
  --critical: #d93025;
  --warning: #fab219;
  --positive: #0f7d3a;      /* используется инлайн в app.js */
  --accent: #0d66d0;        /* используется инлайн в app.js (кнопка тепловой карты) */
  --accent-soft: rgba(13, 102, 208, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 13px/1.5 "YS Text", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }

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

/* Сайдбар */
.sidebar {
  width: 208px; flex: none;
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  background: var(--surface);
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px; letter-spacing: 0.01em;
  padding: 4px 10px 16px; color: var(--ink);
}
.logo span { color: inherit; }
/* Жёлтая призма — знак логотипа */
.logo-mark {
  width: 15px; height: 13px; flex: none;
  background: var(--ya);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.nav a {
  display: block; padding: 7px 10px 7px 13px; border-radius: 6px;
  color: var(--ink-2); margin-bottom: 1px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.nav a.active {
  background: var(--hover); color: var(--ink); font-weight: 600;
  border-left-color: var(--ya);
}

/* Контент */
.main { flex: 1; padding: 0 28px 60px; min-width: 0; }
.topbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
  background: var(--page);
  padding: 14px 0 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 700; margin: 0 auto 0 0; letter-spacing: -0.01em; }
select, input[type=text], input[type=date], textarea {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 6px 9px; font: inherit;
}
select:hover, input[type=text]:hover, input[type=date]:hover { border-color: var(--baseline); }
button {
  background: var(--ya); color: var(--ink); border: 0; border-radius: 7px;
  padding: 7px 14px; font: inherit; font-weight: 500; cursor: pointer;
}
button:hover { background: var(--ya-press); }
button.ghost {
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--border-strong); font-weight: 400;
}
button.ghost:hover { background: var(--hover); color: var(--ink); }
button.ghost.active {
  background: var(--ya); border-color: var(--ya);
  color: var(--ink); font-weight: 500;
}
button.danger { background: var(--critical); color: #fff; }
button.danger:hover { background: #c22619; }

/* Карточки ключевых цифр */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px 14px;
  box-shadow: 0 1px 2px rgba(24, 30, 40, 0.04);
}
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card .value {
  font-size: 30px; font-weight: 600; line-height: 1.15;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.card .delta { font-size: 12px; margin-top: 4px; font-weight: 500; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--critical); }
.delta.flat { color: var(--muted); }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 20px 16px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(24, 30, 40, 0.04);
}
.panel h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.panel .hint { color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Таблицы: тонкие разделители, плотные строки */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); }
th { color: var(--muted); font-weight: 400; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--hover); }
.scroll-x { overflow-x: auto; }

/* Легенда и графики */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin: 4px 0 8px; flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-tooltip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(24, 30, 40, 0.14);
  display: none; max-width: 260px;
}
.chart-tooltip b { font-variant-numeric: tabular-nums; }
details.table-view { margin-top: 8px; }
details.table-view summary { cursor: pointer; color: var(--muted); font-size: 12px; }

/* Горизонтальные бары */
.hbar-row { display: grid; grid-template-columns: minmax(120px, 40%) 1fr 76px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar-track { height: 8px; position: relative; background: var(--grid); border-radius: 4px; }
.hbar-fill { height: 100%; border-radius: 4px; background: var(--series-1); min-width: 2px; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; }

/* Воронка */
.funnel-step { margin-bottom: 14px; }
.funnel-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.funnel-bar { height: 22px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 3px; }
.funnel-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Гистограмма скролла */
.hist { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.hist .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hist .bar { background: var(--series-1); border-radius: 3px 3px 0 0; min-height: 2px; }
.hist .x { font-size: 10px; color: var(--muted); text-align: center; margin-top: 3px; }

/* Бейджи */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.fraud { background: rgba(217, 48, 37, 0.1); color: var(--critical); }
.badge.ok { background: rgba(20, 161, 74, 0.12); color: var(--good-text); }
.badge.dv { background: var(--accent-soft); color: var(--series-1); font-family: ui-monospace, monospace; }

/* Таймлайн сессии */
.timeline { border-left: 2px solid var(--grid); margin-left: 8px; padding-left: 16px; }
.tl-item { position: relative; padding: 6px 0; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 13px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--series-1);
}
.tl-item .t { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; margin-right: 8px; }
.tl-item .type { font-weight: 600; margin-right: 6px; }

/* Аннет */
.annet-answer { white-space: pre-wrap; }
.annet-q { font-weight: 600; margin-bottom: 6px; }
.annet-trace { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.annet-step { font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.annet-step code { font-size: 11px; }
code, pre {
  font-family: ui-monospace, "Cascadia Code", monospace; font-size: 12px;
  background: var(--page); border: 1px solid var(--grid); border-radius: 6px;
}
pre { padding: 10px 12px; overflow-x: auto; }
code { padding: 1px 5px; }

.form-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.form-row input[type=text] { flex: 1; min-width: 140px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Мобильный: сайдбар схлопывается в горизонтальную навигацию */
@media (max-width: 800px) {
  .layout { display: block; }
  .sidebar {
    width: auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    display: flex; align-items: center; gap: 10px;
  }
  .logo { padding: 0 4px 0 0; font-size: 15px; }
  .nav { display: flex; overflow-x: auto; gap: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a {
    white-space: nowrap; margin-bottom: 0; padding: 7px 10px;
    border-left: 0; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
  }
  .nav a.active { background: transparent; border-bottom-color: var(--ya); }
  .main { padding: 0 14px 40px; }
  .topbar { position: static; }
  .card .value { font-size: 26px; }
}
