:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1b1f24; --muted: #66707a; --line: #dde1e6;
  --accent: #2563eb; --accent-text: #fff; --ok: #15803d; --ok-bg: #dcfce7; --warn: #a16207; --warn-bg: #fef3c7;
  --danger: #b91c1c; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --surface: #181c22; --text: #e8eaed; --muted: #98a2ad; --line: #2b323a;
    --accent: #5b8def; --ok: #4ade80; --ok-bg: #12301d; --warn: #fbbf24; --warn-bg: #3a2e0c; --danger: #f87171; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; display: flex; gap: .6rem; align-items: center; }
main { max-width: 920px; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.top { display: flex; align-items: center; gap: .75rem; padding: .7rem 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: .5rem 0; white-space: pre-wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.grid .card { margin: 0; }
.bot { display: flex; flex-direction: column; gap: .3rem; color: var(--text); }
.bot:hover { border-color: var(--accent); text-decoration: none; }
.form { display: flex; flex-direction: column; gap: .75rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
label small { font-weight: 400; }
input:not([type=checkbox]), select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 160px; }
.between { justify-content: space-between; }
.btn { font: inherit; cursor: pointer; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.badge { font-size: .75rem; font-weight: 500; padding: .1rem .55rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.check { flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 400; }
.check input { margin-top: .3rem; }
.check .badge { margin-left: .5rem; }
.savebar { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(transparent, var(--bg) 40%); }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: .75rem; }
.toolbar { margin-bottom: 1rem; }
.toolbar select { max-width: 240px; }
.text-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.text-card .row { margin-top: .5rem; }
.list { list-style: none; padding: 0; margin: 1rem 0 0; }
.list .card { margin-bottom: .5rem; padding: .6rem 1rem; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: .5rem; z-index: 10; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; box-shadow: 0 4px 16px #0004; }
.toast.err { background: var(--danger); color: #fff; }
[hidden] { display: none !important; }

.notice { background: var(--warn-bg); color: var(--warn); padding: .6rem .9rem; border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 1rem; }
.table th, .table td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 500; }
.table tr:last-child td { border-bottom: 0; }
.table tr.off { opacity: .55; }

.progress { height: 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin: .6rem 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.mailing p { margin: .25rem 0; }

/* --- статистика. Цвет серии - слот 1 валидированной палитры (проверен валидатором в обеих схемах) --- */
:root { --chart-1: #2a78d6; --chart-grid: #e1e0d9; --chart-axis: #c3c2b7; --chart-muted: #898781; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-1: #3987e5; --chart-grid: #2c2c2a; --chart-axis: #383835; } }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; background: transparent; color: var(--muted); border: 0; padding: .4rem .7rem; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button:hover { background: var(--bg); }
.segmented button.on { color: var(--text); font-weight: 600; background: var(--bg); box-shadow: inset 0 -2px 0 var(--chart-1); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.7rem; font-weight: 600; line-height: 1.2; }
.tile-note { color: var(--muted); font-size: .8rem; }
.chart-card h2 { margin: 0; }
.chart { position: relative; width: 100%; margin-top: .75rem; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart .tick { fill: var(--chart-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .peak { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart .bar { fill: var(--chart-1); transition: opacity .12s; }
.chart .bar.lift { opacity: .75; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:focus-visible { stroke: var(--chart-1); stroke-width: 2; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; box-shadow: 0 4px 14px #0003; white-space: nowrap; font-size: .85rem; }
.tip-date { color: var(--muted); }
.tip-row { display: flex; align-items: center; gap: .4rem; }
.tip-row strong { font-size: 1rem; }
.tip-name { color: var(--muted); }
.tip-row .key { width: 12px; height: 2px; background: var(--chart-1); display: inline-block; }
.empty { padding: 2rem 0; text-align: center; }
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.table-wrap .table { margin: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot th { color: var(--text); font-weight: 600; border-top: 1px solid var(--line); }
