:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --surface-3: #262b36;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #939aa8;
  --accent: #4c8dff;
  --ok: #3fb950;
  --watch: #58a6ff;
  --medium: #d29922;
  --high: #f0883e;
  --critical: #f85149;
  --expired: #a371f7;
  --row: 34px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: 68px;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
h1 { font-size: 19px; margin: 0 0 2px; }
h2 { font-size: 13px; margin: 18px 0 8px; color: var(--muted); font-weight: 600;
     text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* --- каркас --- */
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
}
header.top strong { font-size: 15px; display: block; }
header.top .who { font-size: 12px; color: var(--muted); }
header.top .act { font-size: 13px; white-space: nowrap; }

main { padding: 12px 14px; max-width: 1200px; margin: 0 auto; }

nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
}
nav.bottom a { flex: 1; text-align: center; padding: 7px 2px 9px; color: var(--muted); font-size: 11px; }
nav.bottom a.active { color: var(--accent); }
nav.bottom a span { display: block; font-size: 17px; line-height: 1.25; }

.impersonating {
  background: rgba(163, 113, 247, .16); color: var(--expired);
  padding: 7px 14px; font-size: 13px; display: flex; justify-content: space-between; gap: 10px;
}
.impersonating a { color: var(--expired); text-decoration: underline; }

/* --- блоки --- */
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.card.tight { padding: 9px 11px; }
.card.flush { padding: 0; overflow: hidden; }
.muted { color: var(--muted); font-size: 12.5px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 760px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { background: var(--surface-2); border-radius: 9px; padding: 8px 9px; min-width: 0; }
.stat-value { display: block; font-size: 17px; font-weight: 650; line-height: 1.15;
              font-variant-numeric: tabular-nums; }
.stat-label { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px;
              overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 620px) {
  .stats { gap: 8px; }
  .stat { padding: 10px 11px; }
  .stat-value { font-size: 21px; }
  .stat-label { font-size: 11.5px; }
}

/* --- формы --- */
label { display: block; font-size: 12px; color: var(--muted); margin: 9px 0 3px; }
input, select, textarea, button {
  width: 100%; font: inherit; font-size: 15px; padding: 9px 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
button, .btn {
  display: block; text-align: center; cursor: pointer; background: var(--accent);
  color: #fff; border: none; font-weight: 600; padding: 10px; border-radius: 8px; margin-top: 10px;
}
button.ghost, .btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.danger, .btn.danger { background: var(--critical); }
button.slim, .btn.slim { padding: 6px 12px; font-size: 13px; margin-top: 0; width: auto; display: inline-block; }
.inline { display: flex; gap: 7px; align-items: flex-end; }
.inline > * { margin-top: 0; }
.inline button { width: auto; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.actions > * { margin-top: 0; }

.scan-field { font-size: 18px; text-align: center; letter-spacing: .5px;
              border: 2px dashed var(--accent); background: rgba(76, 141, 255, .07); }

/* --- фильтры --- */
details.filter-box { margin-bottom: 10px; }
details.filter-box > summary {
  cursor: pointer; list-style: none; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
details.filter-box[open] > summary { border-radius: 10px 10px 0 0; border-bottom: none; }
details.filter-box > summary::-webkit-details-marker { display: none; }
details.filter-box > .card { border-radius: 0 0 10px 10px; margin-bottom: 0; }
details.filter-box > summary .hint { color: var(--muted); font-size: 12px; }

.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(4, 1fr); } }
.filters label { margin: 0 0 2px; }
.filters select, .filters input { padding: 7px 8px; font-size: 13.5px; }
.filters .full { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px;
        background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip.on { background: rgba(76, 141, 255, .15); color: var(--accent); border-color: transparent; }

/* --- плотная таблица --- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.dtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.dtable th, table.dtable td {
  padding: 6px 9px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border); height: var(--row);
}
table.dtable thead th {
  background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
}
table.dtable thead th a { color: inherit; }
table.dtable thead th a.sorted { color: var(--accent); }
table.dtable tbody tr:hover td { background: var(--surface-2); }
table.dtable td.num, table.dtable th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dtable td.name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
table.dtable .sub { color: var(--muted); font-size: 11.5px; margin-left: 5px; }
@media (min-width: 760px) { table.dtable td.name { max-width: 340px; } }
table.dtable tbody tr.dim td { opacity: .55; }
table.dtable td.stick, table.dtable th.stick {
  position: sticky; left: 0; z-index: 5; background: var(--surface);
}
table.dtable thead th.stick { z-index: 7; background: var(--surface-3); }
table.dtable tbody tr:hover td.stick { background: var(--surface-2); }

/* --- метки состояния --- */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px;
        font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: rgba(63,185,80,.15); color: var(--ok); }
.pill.watch { background: rgba(88,166,255,.15); color: var(--watch); }
.pill.medium { background: rgba(210,153,34,.15); color: var(--medium); }
.pill.high { background: rgba(240,136,62,.16); color: var(--high); }
.pill.critical { background: rgba(248,81,73,.16); color: var(--critical); }
.pill.expired { background: rgba(163,113,247,.18); color: var(--expired); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.pill.accent { background: rgba(76,141,255,.15); color: var(--accent); }

td.expired-text { color: var(--expired); }
td.critical-text { color: var(--critical); font-weight: 600; }
td.high-text { color: var(--high); }
td.medium-text { color: var(--medium); }

.dot-level { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-level.ok { background: var(--ok); }
.dot-level.watch { background: var(--watch); }
.dot-level.medium { background: var(--medium); }
.dot-level.high { background: var(--high); }
.dot-level.critical { background: var(--critical); }
.dot-level.expired { background: var(--expired); }

/* --- графики --- */
.chart-empty { color: var(--muted); font-size: 12.5px; padding: 18px 0; text-align: center; }
.chart-columns { display: flex; align-items: flex-end; gap: 4px; height: var(--chart-h, 130px); }
.chart-columns .col { flex: 1; display: flex; flex-direction: column;
                      align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.col-value { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.col-bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); min-height: 2px; }
.col-bar.critical { background: var(--critical); }
.col-bar.high { background: var(--high); }
.col-bar.medium { background: var(--medium); }
.col-bar.watch { background: var(--watch); }
.col-bar.expired { background: var(--expired); }
.col-bar.ok { background: var(--ok); }
.col-label { font-size: 9.5px; color: var(--muted); margin-top: 5px; text-align: center;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
             max-width: 100%; height: 13px; line-height: 13px; }

.chart-bars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 1.4fr) 3fr 46px; gap: 8px; align-items: center; }
.hbar-label { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: var(--surface-2); border-radius: 4px; height: 9px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.hbar-track i.critical { background: var(--critical); }
.hbar-track i.high { background: var(--high); }
.hbar-track i.medium { background: var(--medium); }
.hbar-track i.watch { background: var(--watch); }
.hbar-track i.expired { background: var(--expired); }
.hbar-track i.ok { background: var(--ok); }
.hbar-value { font-size: 12.5px; text-align: right; color: var(--muted);
              font-variant-numeric: tabular-nums; }

.chart-line { width: 100%; height: 130px; display: block; }
.chart-line .area { fill: rgba(76,141,255,.14); }
.chart-line .line { fill: none; stroke: var(--accent); stroke-width: 2;
                    vector-effect: non-scaling-stroke; }
.chart-line .dot { fill: var(--accent); }
.chart-line .axis { fill: #939aa8; font-size: 9px; }
.chart-line .value { fill: #939aa8; font-size: 9px; }

/* --- служебное --- */
.banner { padding: 9px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13.5px; }
.banner.ok { background: rgba(63,185,80,.12); color: var(--ok); }
.banner.err { background: rgba(248,81,73,.14); color: var(--critical); }
.banner.info { background: rgba(88,166,255,.12); color: var(--watch); }
.empty { text-align: center; color: var(--muted); padding: 40px 14px; }
.empty span.icon { display: block; font-size: 34px; margin-bottom: 10px; }
.login-wrap { max-width: 360px; margin: 11vh auto; padding: 0 20px; }
.split { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.nowrap { white-space: nowrap; }
