:root {
  /* Тема тёмная и для нативных элементов: иначе браузер рисует белые полосы прокрутки. */
  color-scheme: dark;
  --bg: #151515;
  --panel: #20201f;
  --line: rgba(255, 255, 255, .09);
  --text: #f2f0ed;
  --muted: #9b968f;
  --accent: #d97757;
  --good: #6ea87a;
  --bad: #c9553f;
  --radius: 10px;
  /* Палитра линий: по цвету на тему, шесть тем на графике. */
  --series-1: #d97757;
  --series-2: #6ea87a;
  --series-3: #7a9bd1;
  --series-4: #c9a83f;
  --series-5: #a98bd1;
  --series-6: #4fa8a0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Serif 4", Georgia, serif;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; }

.head {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px;
}

h1 { margin: 0; font-size: 30px; letter-spacing: .01em; color: var(--accent); }
h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 14px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

select, button {
  font: inherit; font-size: 14px;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 10px;
}

button { cursor: pointer; border-color: var(--accent); color: var(--accent); }
button:hover { background: rgba(217, 119, 87, .12); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}

.card-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }

.cols { display: grid; gap: 18px;
        grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }

.kpi { display: grid; gap: 14px; margin-bottom: 18px;
       grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); }

.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.tile .value { font-size: 28px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile.alert .value { color: var(--accent); }

.chart { width: 100%; height: 300px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 400; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }
td.nowrap { white-space: nowrap; color: var(--muted); }

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

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; }
.pill.high { color: var(--bad); border-color: var(--bad); }
.pill.medium { color: var(--accent); border-color: var(--accent); }
.pill.low { color: var(--muted); }
.pill.negative { color: var(--bad); border-color: var(--bad); }
.pill.neutral { color: var(--muted); }
.pill.positive { color: var(--good); border-color: var(--good); }

.hint { margin: -8px 0 10px; font-size: 13px; }

.drill {
  width: min(92vw, 880px); max-height: 88vh;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.drill::backdrop { background: rgba(0, 0, 0, .6); }
.drill-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.drill-head h2 { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.chips button { padding: 4px 12px; font-size: 13px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.post { border-bottom: 1px solid var(--line); padding: 12px 0; }
.post:last-child { border-bottom: 0; }
.post-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.post p { margin: 6px 0; white-space: pre-wrap; }

.digest { border-bottom: 1px solid var(--line); padding: 10px 0; }
.digest:last-child { border-bottom: 0; }
.digest summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.digest pre { white-space: pre-wrap; font: inherit; margin: 8px 0 0; }

.empty { color: var(--muted); font-size: 14px; padding: 12px 0; }

footer { margin-top: 24px; font-size: 13px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { max-width: 420px; margin: 0; text-align: center; }
.login h1 { margin-bottom: 6px; }
.login .muted { margin-bottom: 14px; }
.login #widget { margin-top: 18px; min-height: 46px; }
/* Кнопка живёт в iframe: без этого браузер подкладывает под неё светлый фон. */
.login #widget iframe { background: transparent; color-scheme: light; }

.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.who form { margin: 0; }
.who button { padding: 4px 10px; font-size: 12px; }

/* Выбор тем для графика: кнопка со списком чекбоксов поверх карточки. */
.picker { position: relative; }
.picker-btn { font: inherit; color: var(--text); background: var(--bg);
              border: 1px solid var(--line); border-radius: var(--radius);
              padding: 6px 12px; cursor: pointer; }
.picker-btn:hover { border-color: var(--accent); }
.picker-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
               min-width: 240px; max-height: 320px; overflow-y: auto;
               background: var(--panel); border: 1px solid var(--line);
               border-radius: var(--radius); padding: 8px; }
.picker-menu label { display: flex; gap: 8px; align-items: center;
                     padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.picker-menu label:hover { background: var(--bg); }
.picker-menu .picker-reset { width: 100%; margin-top: 6px; }
