:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --text: #1f1e1b;
  --muted: #6b6a64;
  --border: #e3e1d9;
  --border-strong: #cfccc1;
  --accent: #3c5a99;
  --accent-text: #ffffff;
  --ok: #1d7a55;      --ok-bg: #e3f3ec;
  --warn: #8a5a0b;    --warn-bg: #fbefd8;
  --bad: #a32d2d;     --bad-bg: #fbe6e6;
  --info-bg: #e8eef9;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171715;
    --surface: #201f1d;
    --surface-2: #262522;
    --text: #ecebe6;
    --muted: #a3a199;
    --border: #34332f;
    --border-strong: #46443f;
    --accent: #8fa9e0;
    --accent-text: #11131a;
    --ok: #6fcfa4;      --ok-bg: #173327;
    --warn: #f0be6a;    --warn-bg: #3a2c12;
    --bad: #f19a9a;     --bad-bg: #3d1c1c;
    --info-bg: #1e2638;
    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.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* layout */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a {
  padding: 6px 10px; border-radius: 6px; color: var(--muted); white-space: nowrap; font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.count.soft { background: var(--warn-bg); color: var(--warn); }
.usermenu { display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.usermenu form { margin: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 2px 0; }
.stat .sub { font-size: 13px; color: var(--muted); }
.stat.bad .value { color: var(--bad); }
.stat.warn .value { color: var(--warn); }
.stat.ok .value { color: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.empty { padding: 22px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.up { color: var(--bad); } .down { color: var(--ok); }

/* banners and flashes */
.banner, .flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px;
  display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.banner.warn, .flash.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad, .flash.bad { background: var(--bad-bg); color: var(--bad); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* forms */
form { margin: 0; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 14px; margin-bottom: 6px; }
.check input { margin-top: 3px; }
.check.disabled { color: var(--muted); }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; flex: 1; min-width: 160px; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 400; }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-group { margin-bottom: 14px; }
.perm-group h3 { margin-top: 0; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 16px; }
.steps li { counter-increment: step; position: relative; padding-left: 34px; margin-bottom: 10px; font-size: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px;
  border-radius: 50%; background: var(--info-bg); color: var(--accent); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.report li { margin-bottom: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.muted { background: var(--border-strong); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chart { width: 100%; height: auto; display: block; }
.chart polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.auth { max-width: 400px; margin: 60px auto; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; }
pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; margin: 0; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  main { padding: 18px 16px 50px; }
  .usermenu .who { display: none; }
}
.mt { margin-top: 16px; }
.mt-s { margin-top: 10px; }
.report { padding-left: 0; list-style: none; margin: 0; }
blockquote.card { margin: 10px 0; background: var(--surface-2); }
.nav a .count { vertical-align: 1px; }
