:root {
  --bg: #f4f7f9; --card: #ffffff; --ink: #14232e; --muted: #5d7080; --line: #dde5ea;
  --brand: #0b7a99; --brand-ink: #ffffff; --brand-soft: #e1f2f7;
  --ok: #1a8f4c; --ok-bg: #e3f5ea; --warn: #b36b00; --warn-bg: #fff2d9;
  --bad: #c0352b; --bad-bg: #fde7e4; --off: #5b3fa0; --off-bg: #ece6f8; --new: #5d7080; --new-bg: #e9eef2;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,35,46,.06), 0 4px 14px rgba(20,35,46,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e171d; --card: #16232b; --ink: #e6eef3; --muted: #90a4b2; --line: #263944;
    --brand: #3fb6d6; --brand-ink: #06232c; --brand-soft: #14323d;
    --ok: #4cc27c; --ok-bg: #143324; --warn: #f0b04c; --warn-bg: #3a2c10;
    --bad: #f0786f; --bad-bg: #3d1a17; --off: #b39cf0; --off-bg: #2a2144; --new: #90a4b2; --new-bg: #1f2e37;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); 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; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }

header.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
header.top .in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.1rem; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.logo i { width: 26px; height: 26px; border-radius: 8px; background: var(--brand); display: inline-block; position: relative; }
.logo i::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 6px; height: 8px; border-radius: 0 0 4px 4px; background: var(--brand-ink); opacity: .85; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav.main a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
nav.main a:hover { background: var(--brand-soft); text-decoration: none; color: var(--ink); }
nav.main a.on { background: var(--brand-soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.role { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }

main { padding-top: 22px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gmain { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .g2, .g3, .gmain { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: block; color: var(--ink); }
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat b { font-size: 1.7rem; display: block; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-bg); } .b-warn { color: var(--warn); background: var(--warn-bg); }
.b-bad { color: var(--bad); background: var(--bad-bg); } .b-offline { color: var(--off); background: var(--off-bg); }
.b-new { color: var(--new); background: var(--new-bg); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

form.inline { display: inline; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 12px; }
.field { margin-bottom: 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--ink); margin: 0; font-size: .92rem; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters > * { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }

.flash { background: var(--brand-soft); border: 1px solid var(--brand); color: var(--ink); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.find { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.find:last-child { border: 0; }
.tag { font-size: .72rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
#map { height: 360px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
.chart-box { position: relative; height: 240px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.secret { background: var(--bg); border: 1px dashed var(--line); padding: 6px 10px; border-radius: 6px; display: inline-block; word-break: break-all; }

.login-box { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login-box .card { padding: 26px; }
.err { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
@media (max-width: 640px) {
  header.top .in { padding-bottom: 8px; }
  .who { width: 100%; justify-content: space-between; }
  .kv { grid-template-columns: 110px 1fr; }
}
