:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --line: #e2e0d8;
  --text: #1d1f1e;
  --muted: #6b6f6c;
  --accent: #1f6f5c;
  --accent-soft: #dcefe8;
  --mark: #ffe58a;
  --now: #e8f4ef;
  --err: #b3261e;
  --heat-0: #ecebe5;
  --heat-1: #cfe7dd;
  --heat-2: #9fd0bd;
  --heat-3: #5fae93;
  --heat-4: #1f6f5c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  /* цвета объектов на графиках: проверены валидатором палитры на фоне карточек */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #ecebe5;
  --axis: #c3c2b7;
  --good: #0ca30c;
  --warn: #fab219;
  --crit: #d03b3b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615;
    --surface: #1c1f1e;
    --surface-2: #232726;
    --line: #2f3432;
    --text: #e8eae8;
    --muted: #9aa19d;
    --accent: #5fc3a2;
    --accent-soft: #1d3a31;
    --mark: #6b5a12;
    --now: #1f3029;
    --err: #ff8a80;
    --heat-0: #262a29;
    --heat-1: #1d3a31;
    --heat-2: #24604f;
    --heat-3: #2f8a6e;
    --heat-4: #5fc3a2;
    --shadow: none;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2a2e2d;
    --axis: #3a3f3d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 1.2em; margin: 0; font-size: 14px; }
[hidden] { display: none !important; }

/* шапка */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  -webkit-mask: url(/favicon.svg) center / contain no-repeat;
          mask: url(/favicon.svg) center / contain no-repeat;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.on { color: var(--text); background: var(--surface-2); font-weight: 550; }
.who { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 14px; }

.app { max-width: 1040px; margin: 0 auto; padding: 28px 24px 120px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* кнопки и поля */
.btn, .link { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font-weight: 550; font-size: 14px;
}
:root .btn { color: var(--surface); }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
:root .btn--ghost { color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 14px; }
.link:hover { text-decoration: underline; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* вход */
.login { max-width: 360px; margin: 10vh auto 0; padding: 28px; }
.login h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login .brand__mark { width: 28px; height: 28px; }
.login__sub { margin: 0 0 6px; }

/* объекты */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.site { display: block; padding: 20px; color: var(--text); }
.site:hover { text-decoration: none; border-color: var(--accent); }
.site__title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.site__meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 14px; }
.site__meta dt { color: var(--muted); }
.site__meta dd { margin: 0; font-variant-numeric: tabular-nums; }

/* календарь */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.month { padding: 16px; }
.month h3 { margin: 0 0 10px; font-size: 15px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__wd { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal__d {
  aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center;
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted);
}
a.cal__d { color: var(--text); }
a.cal__d:hover { outline: 2px solid var(--accent); text-decoration: none; }
.cal__d[data-h="0"] { background: var(--heat-0); }
.cal__d[data-h="1"] { background: var(--heat-1); }
.cal__d[data-h="2"] { background: var(--heat-2); }
.cal__d[data-h="3"] { background: var(--heat-3); color: #fff; }
.cal__d[data-h="4"] { background: var(--heat-4); color: var(--surface); }
.cal__d.today { box-shadow: inset 0 0 0 2px var(--text); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; aspect-ratio: auto; }

/* день */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input { max-width: 320px; }
.stat { font-size: 14px; color: var(--muted); }
.chunk { margin-bottom: 14px; overflow: hidden; }
.chunk__head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.chunk__time { font-weight: 600; font-variant-numeric: tabular-nums; }
.chunk--empty .chunk__head { border-bottom: 0; color: var(--muted); }
.chunk--empty .chunk__time { font-weight: 400; }
.cue {
  display: grid; grid-template-columns: 76px 1fr; gap: 12px;
  padding: 7px 16px; border-top: 1px solid var(--line); cursor: pointer;
}
.cue:first-child { border-top: 0; }
.cue:hover { background: var(--surface-2); }
.cue.now { background: var(--now); box-shadow: inset 3px 0 0 var(--accent); }
.cue.target { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 40% { background: var(--mark); } 100% { background: transparent; } }
.cue__t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; padding-top: 1px; }
.cue--noaudio { cursor: default; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.pill {
  display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.pill--ok { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

/* поиск */
.search { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; padding: 16px; margin-bottom: 20px; }
.hits { display: grid; gap: 4px; }
.hits__day { font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 0 6px; }
.hit { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 8px 14px; color: var(--text); }
.hit:hover { text-decoration: none; border-color: var(--accent); }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--muted); font-size: 13px; background: var(--surface-2); }
.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tblwrap { overflow-x: auto; }

/* проигрыватель */
.player {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6;
  width: min(760px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
}
.player audio { flex: 1; min-width: 0; height: 36px; }
.player__label { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  background: var(--surface); color: var(--text); width: min(420px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.35); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.loading { color: var(--muted); padding: 40px 0; }

/* дашборд */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select { width: auto; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: 14px; border: 0; background: none; color: var(--muted); padding: 7px 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { padding: 16px; }
.tile__label { font-size: 13px; color: var(--muted); }
.tile__value { font-size: 30px; font-weight: 650; line-height: 1.2; margin: 4px 0 2px; letter-spacing: -.01em; }
.tile__sub { font-size: 12px; color: var(--muted); }
.panel { padding: 16px; margin-bottom: 16px; overflow: hidden; }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel__head h2 { margin: 0; font-size: 16px; }
.panel__sub { font-size: 13px; margin: 4px 0 12px; }
.dash.refetch { opacity: .55; transition: opacity .15s; }
.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .label { fill: var(--text); font-size: 13px; }
.chart .value { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .bar.s1 { fill: var(--series-1); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .bar.accent { fill: var(--accent); }
.chart .col.on { filter: brightness(1.15); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 1; }
.chart .cell { outline: none; }
.chart .cell.h0 { fill: var(--surface-2); }
.chart .cell.h1 { fill: var(--heat-1); }
.chart .cell.h2 { fill: var(--heat-2); }
.chart .cell.h3 { fill: var(--heat-3); }
.chart .cell.h4 { fill: var(--heat-4); }
.chart .cell.on, .chart .cell:focus-visible { stroke: var(--text); stroke-width: 1.5; }
.key { display: inline-block; flex: none; }
.key.box { width: 10px; height: 10px; border-radius: 3px; }
.tip .key { width: 12px; height: 2px; border-radius: 1px; align-self: center; }
.key.s1 { background: var(--series-1); }
.key.s2 { background: var(--series-2); }
.legend2 { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend2 span { display: inline-flex; align-items: center; gap: 6px; }
.tip {
  position: fixed; z-index: 20; pointer-events: none; min-width: 140px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 8px 10px; font-size: 13px;
}
.tip__title { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tip__row { display: flex; gap: 8px; align-items: baseline; }
.tip__row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip__row span { color: var(--muted); }
.tv { margin-top: 10px; font-size: 13px; }
.tv summary { cursor: pointer; color: var(--muted); }
.tv .tblwrap { max-height: 320px; overflow: auto; margin-top: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status .ico { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; }
.status.good .ico { background: var(--good); }
.status.warn .ico { background: var(--warn); color: #1d1f1e; }
.status.crit .ico { background: var(--crit); }
.tile .status { margin-top: 6px; }

@media (max-width: 720px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile__value { font-size: 24px; }
  .top { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .who { margin-left: auto; }
  #who-name { display: none; }
  .app { padding: 20px 16px 120px; }
  .search { grid-template-columns: 1fr 1fr; }
  .search > :first-child { grid-column: 1 / -1; }
  .cue, .hit { grid-template-columns: 64px 1fr; gap: 8px; padding-left: 12px; padding-right: 12px; }
  .player__label { display: none; }
}
