:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5f6b78;
  --line: #e1e5ea;
  --brand: #0f2a44;
  --brand-ink: #ffffff;
  --accent: #1d5fd1;
  --accent-ink: #ffffff;
  --ok: #1a7f4b;
  --ok-bg: #e5f4ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --idle: #5f6b78;
  --idle-bg: #edf0f3;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #171e26;
    --ink: #e6ebf0;
    --muted: #93a0ae;
    --line: #2a3440;
    --brand: #0b1724;
    --accent: #4d8bf0;
    --ok: #4cc38a;
    --ok-bg: #12301f;
    --warn: #e8a845;
    --warn-bg: #33270f;
    --bad: #f07a70;
    --bad-bg: #3a1714;
    --idle: #93a0ae;
    --idle-bg: #222b35;
    color-scheme: dark;
  }
}

* { 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, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
.err-text { color: var(--bad); }

/* Header */
.top { background: var(--brand); color: var(--brand-ink); }
.top-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--brand-ink); text-decoration: none !important; }
.brand-mark { font-weight: 800; letter-spacing: 0.08em; font-size: 1.1rem; }
.brand-sub { opacity: 0.75; font-size: 0.9rem; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--brand-ink); opacity: 0.8; padding: 6px 10px; border-radius: 6px; text-decoration: none; }
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.nav a.active { opacity: 1; background: rgba(255, 255, 255, 0.14); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.who-org { opacity: 0.7; }
.who form { margin: 0; }
.who .link { color: var(--brand-ink); opacity: 0.85; }

/* Layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.wrap.narrow { max-width: 560px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.back { font-size: 0.9rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > .card { margin-bottom: 0; }
.two-col + .card { margin-top: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.top-gap { margin-top: 16px; }
.login { margin-top: 40px; }
.empty { text-align: center; padding: 36px 18px; }

/* Site cards */
a.card.site { display: block; color: inherit; text-decoration: none; margin: 0; transition: border-color 0.15s; }
a.card.site:hover { border-color: var(--accent); }
.site-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.site-title { font-weight: 650; font-size: 1.05rem; }
.values { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 10px; }
.values div { background: var(--bg); border-radius: 6px; padding: 8px 10px; }
.values dt { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.values dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.site .values { grid-template-columns: repeat(2, 1fr); }
.soc { display: block; height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.soc-fill { display: block; height: 100%; }
.soc-ok { background: var(--ok); }
.soc-mid { background: var(--warn); }
.soc-low { background: var(--bad); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 0.8rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-online { color: var(--ok); background: var(--ok-bg); }
.s-low { color: var(--warn); background: var(--warn-bg); }
.s-offline, .s-error { color: var(--bad); background: var(--bad-bg); }
.s-nodata { color: var(--idle); background: var(--idle-bg); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; color: var(--muted); font-size: 0.85rem; }
.stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat.warn span { color: var(--warn); }
.stat.bad span { color: var(--bad); }

/* Key/value lists */
.kv { margin: 12px 0 0; display: grid; gap: 6px; }
.kv div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
table.dense td { padding: 5px 10px; }
td.actions { text-align: right; white-space: nowrap; }
details summary { cursor: pointer; font-weight: 600; }

/* Forms */
.form { display: grid; gap: 12px; }
.form.row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
label { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 600; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: vertical; }
form.inline { display: inline; margin: 0; }
.copy-row { display: flex; gap: 8px; margin: 12px 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer;
  padding: 9px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none !important; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--bad); }
.btn.danger-ghost:hover { border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }
.btn.wide { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }

/* Messages */
.flash { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }

/* Phones */
@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  .two-col > .card { margin-bottom: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .values { grid-template-columns: repeat(2, 1fr); }
  .who { margin-left: 0; width: 100%; }
  .who-org { display: none; }
  .who form { margin-left: auto; }
  .kv div { grid-template-columns: 1fr; gap: 0; }
  .grid { grid-template-columns: 1fr; }
  td.actions { white-space: normal; }
  td.actions .btn { margin: 2px 0; }
}

/* Width helpers (no inline styles allowed by the page security policy) */
.w0{width:0%}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}.w30{width:30%}.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}.w55{width:55%}.w60{width:60%}.w65{width:65%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}.w90{width:90%}.w95{width:95%}.w100{width:100%}
