:root {
  --bg: #f5f7fa; --surface: #fff; --surface-2: #f0f3f7; --border: #dde3ea;
  --text: #1b2430; --muted: #64707d; --accent: #2457d6; --accent-ink: #fff;
  --ok: #1a7f4b; --ok-bg: #e3f5eb; --bad: #c0352b; --bad-bg: #fbe7e5; --warn: #9a6400; --warn-bg: #fdf3dc;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --surface: #171d25; --surface-2: #1e2630; --border: #2a3440;
    --text: #e4e9ef; --muted: #8b97a5; --accent: #5b8cff; --accent-ink: #0b1020;
    --ok: #4cc38a; --ok-bg: #12301f; --bad: #ff7b72; --bad-bg: #3a1714; --warn: #e3b341; --warn-bg: #352a0c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.error { color: var(--bad); }

/* buttons & inputs */
button { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 7px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .6; cursor: progress; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 10px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label input, label select { margin-top: 4px; font-weight: 400; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.auth-card .brand { margin-bottom: 20px; font-size: 17px; }
.auth-card button.primary { width: 100%; padding: 9px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 8px; padding: 8px; margin: 8px 0; }
.qr svg { width: 200px; height: 200px; }

/* shell */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent);
  color: var(--accent-ink); font-size: 12px; font-weight: 800; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 20px; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.top nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 7px; font-weight: 500; }
.top nav a:hover { color: var(--text); background: var(--surface-2); }
.top nav a.active { color: var(--text); background: var(--surface-2); }
.me { color: var(--muted); white-space: nowrap; }
.view { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards & grids */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.stat { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 180px; margin-bottom: 0; }

/* service tiles */
.svc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.svc { border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 8px; padding: 12px 14px; background: var(--surface); }
.svc.down { border-left-color: var(--bad); background: var(--bad-bg); }
.svc-head { display: flex; align-items: center; gap: 8px; }
.svc-head .pill { margin-left: auto; }
.svc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.svc.down .svc-dot { background: var(--bad); }
.svc-role { margin: 4px 0 8px; min-height: 36px; }
.svc-facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 8px; font-size: 13px; }
.svc-facts dt { color: var(--muted); }
.svc-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.warn-text { color: var(--warn); font-weight: 600; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.info { color: var(--muted); background: var(--surface-2); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button + button { margin-left: 6px; }
.value { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.empty { color: var(--muted); padding: 18px 10px; text-align: center; }

/* check results */
.check-section { margin-bottom: 10px; }
.check-section h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; margin: 0 0 4px; }
.check-line { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }

/* log viewer */
.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 70vh;
  overflow: auto; white-space: pre; font-family: var(--mono); font-size: 12px; margin: 0; }
.log .l-bad { color: var(--bad); } .log .l-warn { color: var(--warn); } .log .l-ok { color: var(--ok); }

/* secret reveal */
.reveal { background: var(--ok-bg); border: 1px solid var(--ok); border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.reveal dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0 0; }
.reveal dt { color: var(--muted); } .reveal dd { margin: 0; font-family: var(--mono); word-break: break-all; }

/* modal */
dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  padding: 22px; width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font-weight: 500; z-index: 50; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; }
  .view { padding: 18px 16px 50px; }
}
