:root {
  --bg: #f4f5f8; --panel: #ffffff; --panel2: #f0f2f6; --line: #dfe3ea; --text: #1d2330; --muted: #677086;
  --accent: #3d63dd; --ok: #1f8a4c; --ok-bg: #e3f4ea; --warn: #a35f00; --warn-bg: #fdf0dc;
  --crit: #c0352b; --crit-bg: #fbe5e3; --info: #3d63dd; --info-bg: #e5ebfc; --neutral-bg: #eef0f4;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --panel: #1a1e28; --panel2: #212633; --line: #2c3242; --text: #dde2ee; --muted: #8b93a8;
    --accent: #7aa2f7; --ok: #6fd08f; --ok-bg: #173323; --warn: #f0b45a; --warn-bg: #3a2c12;
    --crit: #ff7b72; --crit-bg: #3d1a18; --info: #7aa2f7; --info-bg: #1b2645; --neutral-bg: #252b39;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151c; --panel: #1a1e28; --panel2: #212633; --line: #2c3242; --text: #dde2ee; --muted: #8b93a8;
  --accent: #7aa2f7; --ok: #6fd08f; --ok-bg: #173323; --warn: #f0b45a; --warn-bg: #3a2c12;
  --crit: #ff7b72; --crit-bg: #3d1a18; --info: #7aa2f7; --info-bg: #1b2645; --neutral-bg: #252b39;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }
.help { cursor: help; }
th.help { text-decoration: underline dotted; text-underline-offset: 3px; }
.trunc { display: inline-block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.more { margin-top: 10px; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .bad-text { color: var(--crit); }
button, select, input {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.danger { color: var(--crit); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { width: 20px; height: 20px; border-radius: 5px; display: inline-block;
  background: linear-gradient(180deg, var(--accent) 0 40%, var(--ok) 40% 75%, var(--muted) 75%); }
#tabs { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
#tabs button { background: none; border: 0; border-radius: 7px; color: var(--muted); padding: 6px 11px; }
#tabs button:hover { color: var(--text); background: var(--panel2); }
#tabs button.active { color: var(--text); background: var(--panel2); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.who { display: flex; gap: 8px; align-items: center; }
main#view { padding: 18px; max-width: 1700px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

/* cards + grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card h2 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 { margin: 16px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tile.ok { border-left-color: var(--ok); } .tile.warn { border-left-color: var(--warn); }
.tile.crit { border-left-color: var(--crit); background: var(--crit-bg); } .tile.info { border-left-color: var(--info); }
.tile.neutral { border-left-color: var(--accent); }
.tlabel { color: var(--muted); font-size: 12px; }
.tvalue { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tsub { color: var(--muted); font-size: 11.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-tiles .tvalue { font-size: 18px; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.bad td { background: var(--crit-bg); }
tr.failrow td { background: color-mix(in srgb, var(--crit-bg) 45%, transparent); }
tbody tr:hover td { background: var(--panel2); }

/* pills + bars */
.pill { display: inline-block; padding: 1px 8px; margin: 1px 3px 1px 0; border-radius: 99px; font-size: 11.5px;
  background: var(--neutral-bg); color: var(--text); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.crit { background: var(--crit-bg); color: var(--crit); } .pill.info { background: var(--info-bg); color: var(--info); }
.bar { position: relative; width: 110px; height: 18px; background: var(--panel2); border-radius: 5px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; }
.bar .fill.ok { background: color-mix(in srgb, var(--ok) 35%, transparent); }
.bar .fill.warn { background: color-mix(in srgb, var(--warn) 45%, transparent); }
.bar .fill.crit { background: color-mix(in srgb, var(--crit) 50%, transparent); }
.bar span { position: relative; font-size: 11.5px; padding-left: 6px; line-height: 18px; font-variant-numeric: tabular-nums; }

/* misc */
.issues { list-style: none; margin: 0; padding: 0; }
.issues li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.issues li b { margin-right: 4px; }
.roles { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.roles dt { font-weight: 600; } .roles dd { margin: 0; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.unitgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.unitbox { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.unitbox h3 { margin: 0 0 6px; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 13.5px; }
.units { display: flex; flex-wrap: wrap; gap: 3px; }
.unit { font-family: var(--mono); font-size: 11.5px; background: var(--panel2); border-radius: 5px; padding: 1px 6px; }
.newtoken { background: var(--ok-bg); border-radius: 9px; padding: 10px 12px; margin: 10px 0; }
.newtoken code { display: block; word-break: break-all; font-size: 13px; padding: 6px 0; user-select: all; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.login-card h1 { margin: 0 0 16px; font-size: 20px; display: flex; gap: 8px; align-items: center; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 8px 10px; }
.login-card button[type=submit] { background: var(--accent); color: #fff; border: 0; padding: 9px; font-weight: 600; }
.qr { background: #fff; border-radius: 10px; padding: 8px; display: grid; place-items: center; }
.qr svg { width: 220px; height: 220px; }
.msg { color: var(--crit); min-height: 1.2em; }

@media (max-width: 700px) {
  .top { padding: 8px 12px; }
  main#view { padding: 12px 16px; }
  .tvalue { font-size: 19px; }
  .roles { grid-template-columns: 1fr; }
}
