:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #16202b;
  --muted: #5b6875;
  --accent: #0f5c68;
  --accent-soft: #e2f0f2;
  --pos: #1a7f5a;
  --neg: #b23a30;
  --warn: #9a6206;
  --warn-soft: #fdf3e2;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151b; --surface: #171e26; --surface-2: #1d262f; --border: #2b3742;
    --text: #e6ecf2; --muted: #93a2b1; --accent: #4bb3c4; --accent-soft: #14313a;
    --pos: #4cc38a; --neg: #f0776a; --warn: #e0a33a; --warn-soft: #2a2113;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

/* Оформление */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 1.25rem;
  display: flex; align-items: center; gap: 1.25rem; min-height: 56px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; color: var(--text); }
.brand span { color: var(--accent); }
nav.main { display: flex; gap: .25rem; flex-wrap: wrap; }
nav.main a {
  padding: .4rem .7rem; border-radius: 7px; color: var(--muted); font-size: .9rem;
}
nav.main a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
nav.main a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* Карти и решетки */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1.1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi .value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.kpi.pos .value { color: var(--pos); } .kpi.neg .value { color: var(--neg); }

/* Таблици */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: .84rem; }
tbody tr:hover { background: var(--surface-2); }
tr.breach { background: var(--warn-soft); }
tr.breach:hover { background: var(--warn-soft); }

/* Форми */
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea, button {
  font: inherit; color: var(--text);
}
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface); 
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { margin-bottom: .7rem; }
.form-row { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
button, .btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 7px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; font-size: .88rem; font-weight: 500;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); }
button.danger, .btn.danger { background: transparent; border-color: var(--border); color: var(--neg); }
button.small, .btn.small { padding: .25rem .55rem; font-size: .8rem; }

/* Дребни елементи */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .74rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.notice {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 7px; padding: .7rem .9rem;
  font-size: .85rem; color: var(--muted); margin-bottom: 1.1rem;
}
.notice strong { color: var(--text); }
.notice.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: .9rem; }
.legal-footer {
  max-width: 1200px; margin: 2rem auto 0; padding: 1.25rem;
  font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); line-height: 1.6;
}
details summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
details[open] summary { margin-bottom: .5rem; }

/* Графика */
.chart { width: 100%; height: 220px; display: block; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .buffer { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.chart .dot { fill: var(--accent); }
.chart .dot.breach { fill: var(--neg); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.bars .bar { flex: 1; border-radius: 2px 2px 0 0; min-height: 1px; }
.bars .bar.in { background: var(--pos); opacity: .75; }
.bars .bar.out { background: var(--neg); opacity: .65; }
.axis { display: flex; justify-content: space-between; font-size: .68rem; color: var(--muted); margin-top: .25rem; }

/* Меню „Още" */
.menu { position: relative; }
.menu summary {
  list-style: none; padding: .4rem .7rem; border-radius: 7px;
  color: var(--muted); font-size: .9rem; user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--surface-2); color: var(--text); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  min-width: 220px; padding: .35rem; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.menu-panel a { padding: .45rem .6rem; border-radius: 6px; color: var(--text); font-size: .88rem; }
.menu-panel a:hover { background: var(--surface-2); text-decoration: none; }

/* Голямо число на видно място */
.headline { font-size: 2.4rem; font-weight: 680; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1; }
.headline.neg { color: var(--neg); }
.lead { font-size: 1rem; color: var(--muted); margin-bottom: 1.25rem; }
.answer { padding: 1.25rem 1.4rem; }
.answer .q { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: .35rem; }
.split { display: grid; gap: 1.1rem; grid-template-columns: 1.4fr 1fr; align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }
.quick { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); align-items: end; }
