:root {
  color-scheme: light;
  --plane:          #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --series-3:       #1baf7a;
  --series-4:       #eda100;
  --series-5:       #e87ba4;
  --series-6:       #008300;
  --series-7:       #4a3aa7;
  --series-8:       #e34948;
  --series-1-soft:  #cde2fb;
  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;
  --radius:         10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:          #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255, 255, 255, 0.10);
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;
    --series-4:       #c98500;
    --series-5:       #d55181;
    --series-6:       #008300;
    --series-7:       #9085e9;
    --series-8:       #e66767;
    --series-1-soft:  #184f95;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:          #0d0d0d;
  --surface-1:      #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255, 255, 255, 0.10);
  --series-1:       #3987e5;
  --series-2:       #d95926;
  --series-3:       #199e70;
  --series-4:       #c98500;
  --series-5:       #d55181;
  --series-6:       #008300;
  --series-7:       #9085e9;
  --series-8:       #e66767;
  --series-1-soft:  #184f95;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--plane);
  color: var(--text-primary);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

header.page {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  padding: 20px 0 12px;
}
header.page h1 { font-size: 20px; margin: 0; font-weight: 650; }
header.page .sub { color: var(--text-muted); font-size: 12px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

form.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
}
form.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
form.filters input,
form.filters select {
  font: inherit;
  padding: 6px 8px;
  min-width: 140px;
  color: var(--text-primary);
  background: var(--plane);
  border: 1px solid var(--axis);
  border-radius: 6px;
}
form.filters button,
.btn {
  font: inherit;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--series-1);
  background: var(--series-1);
  color: #fff;
  cursor: pointer;
}
.btn.ghost {
  background: transparent;
  color: var(--series-1);
}
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets a {
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.tile .value {
  font-size: 28px;
  font-weight: 620;
  line-height: 1.15;
  margin-top: 6px;
}
.tile .note { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--grid);
  margin-top: 10px;
  overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--series-1); }
.meter.warn > span { background: var(--warning); }
.meter.crit > span { background: var(--critical); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.status .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--good); }
.status.warn .dot { background: var(--warning); }
.status.crit .dot { background: var(--critical); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in oklab, var(--series-1) 6%, transparent); }
.scroll { overflow-x: auto; }

.muted { color: var(--text-muted); }
.warnbox {
  border-left: 3px solid var(--warning);
  padding: 8px 12px;
  background: color-mix(in oklab, var(--warning) 10%, transparent);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  margin-bottom: 12px;
}
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  z-index: 20;
  white-space: nowrap;
}
.chart-empty { color: var(--text-muted); padding: 24px 0; text-align: center; }
svg text { font: 11px system-ui, -apple-system, "Segoe UI", sans-serif; }

/* Легенда серий: цвет рядом с подписью, сам текст остаётся текстовым цветом. */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 2px; font-size: 12px; }
.legend span.item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* Список учётных записей с флажками — компактная сетка, не простыня. */
.picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 2px 14px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-top: 6px;
}
.picker label { display: flex; gap: 7px; align-items: center; font-size: 12px; cursor: pointer; }
.picker label:hover { color: var(--series-1); }
.picker .shared { color: var(--text-muted); }
