:root {   /* dark is the default */
  color-scheme: dark;
  --bg: #12151a; --panel: #1b2027; --text: #e7eaee; --muted: #9aa4b2; --line: #2f3641;
  --healthy: #4cc98a; --degraded: #f0b25a; --unhealthy: #ff7a80; --unknown: #9aa4b2;
  --healthy-bg: #173326; --degraded-bg: #3a2a12; --unhealthy-bg: #3d1b1e; --unknown-bg: #262c35;
  --accent: #7aa2ff; --info: #7fb0ff; --info-bg: #17284a;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9; --panel: #fff; --text: #1b1f24; --muted: #5d6673; --line: #dde1e7;
  --healthy: #1a7f4b; --degraded: #a15c00; --unhealthy: #c0262d; --unknown: #5d6673;
  --healthy-bg: #e3f4ea; --degraded-bg: #fdf0d9; --unhealthy-bg: #fbe5e6; --unknown-bg: #eceef2;
  --accent: #2257c5; --info: #1f5fbf; --info-bg: #e1ecfb;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1 { margin: 0; font-size: 1.35rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.sub { margin: .15rem 0 0; color: var(--muted); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 16px; flex-wrap: wrap; }
.top-right { display: flex; gap: .6rem; align-items: center; }
main { padding: 0 16px 3rem; max-width: 1400px; margin: 0 auto; }
section { margin-bottom: 1.8rem; }
button { font: inherit; padding: .35rem .8rem; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--unknown-bg); color: var(--unknown); }
.badge.mock { background: var(--degraded-bg); color: var(--degraded); }
.badge.healthy { background: var(--healthy-bg); color: var(--healthy); }
.badge.degraded { background: var(--degraded-bg); color: var(--degraded); }
.badge.unhealthy { background: var(--unhealthy-bg); color: var(--unhealthy); }
.badge.unknown { background: var(--unknown-bg); color: var(--unknown); }
.banner { margin: 0 16px 1rem; padding: .6rem .9rem; border-radius: 8px; background: var(--degraded-bg); color: var(--degraded); font-weight: 600; }
.error { margin: 0 16px 1rem; padding: .6rem .9rem; border-radius: 8px; background: var(--unhealthy-bg); color: var(--unhealthy); }

.overall { display: flex; align-items: center; gap: 1rem; background: var(--panel); border: 1px solid var(--line); border-left-width: 8px; border-radius: 10px; padding: .9rem 1.1rem; margin-bottom: .9rem; }
.overall.healthy { border-left-color: var(--healthy); } .overall.degraded { border-left-color: var(--degraded); }
.overall.unhealthy { border-left-color: var(--unhealthy); } .overall.unknown { border-left-color: var(--unknown); }
.overall .label { color: var(--muted); font-size: .85rem; }
.overall .value { font-size: 1.6rem; font-weight: 700; text-transform: capitalize; }
.overall .why { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; }
.card .n { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.card .l { color: var(--muted); font-size: .85rem; }
.card.healthy .n { color: var(--healthy); } .card.degraded .n { color: var(--degraded); }
.card.unhealthy .n, .card.blocked .n { color: var(--unhealthy); } .card.unknown .n { color: var(--unknown); }

.platforms { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: .9rem; }
.plat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.plat h3 { margin: 0 0 .6rem; font-size: 1rem; display: flex; justify-content: space-between; }
.plat dl { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; margin: .6rem 0 0; }
.plat dt { color: var(--muted); } .plat dd { margin: 0; text-align: right; font-weight: 600; }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--unknown-bg); }
.stack span { display: block; height: 100%; }
.seg-healthy { background: var(--healthy); } .seg-degraded { background: var(--degraded); }
.seg-unhealthy { background: var(--unhealthy); } .seg-unknown { background: var(--unknown); opacity: .5; }
.compare { margin-top: .9rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.compare h3 { margin: 0 0 .6rem; font-size: 1rem; }
.cmp-row { display: grid; grid-template-columns: 130px 1fr; gap: .8rem; align-items: center; margin: .5rem 0; }
.cmp-bars > div { display: grid; grid-template-columns: 64px 1fr 52px; gap: .5rem; align-items: center; font-size: .85rem; }
.bar { height: 10px; background: var(--unknown-bg); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.cmp-note { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }

.filters { display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: end; margin-bottom: .6rem; }
.filters label { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.filters label.check { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--text); padding-bottom: .4rem; }
input[type=search], select { font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); min-width: 160px; }
.count { color: var(--muted); margin: .2rem 0 .5rem; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 980px; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
th[data-sort] { cursor: pointer; user-select: none; } th[data-sort]:hover { color: var(--text); }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--unknown-bg); }
tbody tr:last-child td { border-bottom: 0; }
td.reason { max-width: 340px; color: var(--muted); }
td.mono { font-family: ui-monospace, monospace; font-size: .85rem; white-space: nowrap; }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); }
.yes { color: var(--unhealthy); font-weight: 700; }

.drawer { position: fixed; top: 0; right: 0; width: min(480px, 100vw); height: 100vh; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.18); padding: 1rem 16px 2rem; z-index: 5; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.drawer-head h2 { margin: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .35rem .8rem; margin: 0 0 1.2rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .3rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem 1rem; }
.timeline li::before { content: ""; position: absolute; left: -.48rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); }
.timeline li.healthy::before { background: var(--healthy); } .timeline li.degraded::before { background: var(--degraded); }
.timeline li.unhealthy::before { background: var(--unhealthy); }
.timeline .when { color: var(--muted); font-size: .8rem; }
.timeline .chg { font-size: .75rem; font-weight: 700; color: var(--accent); margin-left: .4rem; }
@media (max-width: 600px) { .cmp-row { grid-template-columns: 1fr; } }
.maybe { color: var(--degraded); font-weight: 700; }
.na { color: var(--muted); }
.chk { font-weight: 600; white-space: nowrap; } .chk.ok { color: var(--healthy); } .chk.fail { color: var(--degraded); }
.overall .checks { margin-top: .25rem; font-size: .9rem; }
td.reason { word-break: break-word; max-width: 420px; font-size: .85rem; }

.fleet { display: flex; gap: 1rem 1.4rem; align-items: center; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-left-width: 8px; border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: .9rem; }
.fleet.working { border-left-color: var(--healthy); } .fleet.struggling { border-left-color: var(--degraded); }
.fleet.failing { border-left-color: var(--unhealthy); } .fleet.idle, .fleet.no_data { border-left-color: var(--unknown); }
.fleet .state { font-size: 1.7rem; font-weight: 700; white-space: nowrap; }
.fleet .state small { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); }
.fleet .msg { flex: 1; min-width: 260px; } .fleet .msg p { margin: .15rem 0; }
.fleet .sub2 { color: var(--muted); font-size: .9rem; }
.plat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: .9rem; margin-bottom: .9rem; }
.pt { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; }
.pt h3 { margin: 0 0 .15rem; font-size: 1rem; display: flex; justify-content: space-between; align-items: baseline; }
.pt .line { color: var(--muted); font-size: .88rem; margin: .1rem 0; }
.days { display: flex; gap: 6px; align-items: flex-end; margin-top: .7rem; height: 74px; }
.day { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; min-width: 0; }
.day .bars { display: flex; flex-direction: column; justify-content: flex-end; flex: 1; border-radius: 3px; overflow: hidden; }
.day .okb { background: var(--healthy); } .day .badb { background: var(--unhealthy); }
.day .none { background: var(--unknown-bg); height: 3px; }
.day span { font-size: .68rem; color: var(--muted); text-align: center; margin-top: 3px; white-space: nowrap; }
.legend { font-size: .75rem; color: var(--muted); margin-top: .35rem; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: baseline; }
.foot { color: var(--muted); font-size: .85rem; margin: .7rem 0 0; }
td .acct { font-family: ui-monospace, monospace; font-size: .85rem; font-weight: 600; }
td .mail { color: var(--muted); font-size: .8rem; word-break: break-all; }
td.fail { min-width: 260px; max-width: 520px; }
td.fail .kind { font-weight: 600; color: var(--degraded); }
td.fail .txt { color: var(--muted); font-size: .8rem; margin-top: .15rem; word-break: break-word; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 0 .35rem; border-radius: 4px; background: var(--degraded-bg); color: var(--degraded); margin-left: .3rem; }
table { min-width: 880px; }

.st { display: inline-block; padding: .1rem .55rem; border-radius: 6px; font-size: .82rem; font-weight: 600; background: var(--unknown-bg); color: var(--unknown); }
.st-active { background: var(--healthy-bg); color: var(--healthy); }
.st-needs_login { background: var(--degraded-bg); color: var(--degraded); }
.st-cooling_down { background: var(--info-bg); color: var(--info); }
.st-flagged { background: var(--unhealthy-bg); color: var(--unhealthy); }
.st-disabled { background: var(--unknown-bg); color: var(--unknown); }
.fleet.unclear { border-left-color: var(--degraded); }

.av { display: inline-block; padding: .1rem .55rem; border-radius: 6px; font-size: .82rem; font-weight: 600; background: var(--unknown-bg); color: var(--unknown); }
.av-ready, .av-in_use { background: var(--healthy-bg); color: var(--healthy); }
.av-resting { background: var(--info-bg); color: var(--info); }
.av-needs_verify, .av-needs_login { background: var(--degraded-bg); color: var(--degraded); }
.av-flagged { background: var(--unhealthy-bg); color: var(--unhealthy); }
.use { min-width: 90px; font-size: .82rem; } .use span { color: var(--muted); }
.usebar { height: 7px; background: var(--unknown-bg); border-radius: 4px; overflow: hidden; margin-bottom: 2px; }
.usebar i { display: block; height: 100%; } .usebar i.ok { background: var(--healthy); } .usebar i.near { background: var(--degraded); } .usebar i.full { background: var(--unhealthy); }
.tag.red { background: var(--unhealthy-bg); color: var(--unhealthy); }
table { min-width: 1080px; }
.plat dd.rowbar { display: flex; align-items: center; gap: .6rem; justify-content: flex-end; }
.mini { width: 90px; height: 7px; background: var(--unknown-bg); border-radius: 4px; overflow: hidden; display: inline-block; }
.mini i { display: block; height: 100%; } .mini i.ok { background: var(--healthy); } .mini i.warn { background: var(--degraded); } .mini i.bad { background: var(--unhealthy); }
.plat dd.rowbar b { min-width: 1.4em; text-align: right; }

dl.barlist { display: grid; grid-template-columns: minmax(0, 1fr) minmax(70px, 38%) 2.2rem; gap: .3rem .8rem; align-items: center; margin: .6rem 0 0; }
dl.barlist dt { color: var(--muted); } dl.barlist dd { margin: 0; }
dl.barlist dd.mini { width: auto; height: 8px; background: var(--unknown-bg); border-radius: 4px; overflow: hidden; display: block; }
dl.barlist dd.mini i { display: block; height: 100%; }
dl.barlist dd.mini i.ok { background: var(--healthy); } dl.barlist dd.mini i.warn { background: var(--degraded); }
dl.barlist dd.mini i.bad { background: var(--unhealthy); } dl.barlist dd.mini i.mute { background: var(--unknown); opacity: .55; }
dl.barlist dd.num { text-align: right; font-weight: 600; }
.risklist { display: grid; gap: .5rem; }
.riskrow { display: grid; grid-template-columns: 170px 70px 1fr; gap: .8rem; align-items: start; background: var(--panel); border: 1px solid var(--line); border-left-width: 6px; border-radius: 8px; padding: .6rem .9rem; cursor: pointer; }
.riskrow.lv-high { border-left-color: var(--unhealthy); } .riskrow.lv-medium { border-left-color: var(--degraded); } .riskrow.lv-low { border-left-color: var(--unknown); }
.riskrow:hover { border-color: var(--accent); } .riskrow ul { margin: 0; padding-left: 1.1rem; } .riskrow li { margin: .1rem 0; }
.riskrow .who { display: grid; } .riskrow .mail { color: var(--muted); font-size: .8rem; }
.riskempty { background: var(--healthy-bg); color: var(--healthy); border-radius: 8px; padding: .7rem 1rem; font-weight: 600; }
.lvl { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .05rem .4rem; border-radius: 4px; margin-left: .4rem; }
.riskrow .lvl { margin-left: 0; }
.lvl.lv-high { background: var(--unhealthy-bg); color: var(--unhealthy); } .lvl.lv-medium { background: var(--degraded-bg); color: var(--degraded); } .lvl.lv-low { background: var(--unknown-bg); color: var(--unknown); }
.mail.warn { color: var(--degraded); font-weight: 600; }
ul.wl { margin: 0; padding-left: 1rem; }
@media (max-width: 700px) { .riskrow { grid-template-columns: 1fr; } }
.riskrow { padding: .4rem .8rem; } .riskrow ul { margin: 0; } button.more { margin-top: .6rem; }

/* clickable rows: a small lift, a shadow and a nudge on the arrow so they read as buttons */
.riskrow { position: relative; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background-color .15s ease; }
.riskrow::after { content: "\203A"; position: absolute; right: 1rem; top: 50%; transform: translate(0, -50%); font-size: 1.6rem; line-height: 1; color: var(--muted); opacity: .5; transition: transform .15s ease, opacity .15s ease, color .15s ease; }
.riskrow:hover, .riskrow:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .18); border-color: var(--accent); }
.riskrow:hover::after, .riskrow:focus-visible::after { transform: translate(5px, -50%); opacity: 1; color: var(--accent); }
.riskrow:active { transform: translateY(0); box-shadow: none; }
.riskrow { padding-right: 2.6rem; }
@media (prefers-reduced-motion: reduce) { .riskrow, .riskrow::after { transition: none; } .riskrow:hover, .riskrow:focus-visible { transform: none; } }

/* clickable table rows: tinted row, accent bar on the left, the account name nudges right */
tbody tr { transition: background-color .15s ease, box-shadow .15s ease; }
tbody tr td:first-child { box-shadow: inset 0 0 0 var(--accent); transition: box-shadow .15s ease; }
tbody tr td:first-child .acct { display: inline-block; transition: transform .15s ease; }
tbody tr:hover, tbody tr:focus-visible { background: var(--info-bg); }
tbody tr:hover td:first-child, tbody tr:focus-visible td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
tbody tr:hover td:first-child .acct, tbody tr:focus-visible td:first-child .acct { transform: translateX(4px); }
tbody tr:active { background: var(--unknown-bg); }
tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { tbody tr, tbody tr td:first-child, tbody tr td:first-child .acct { transition: none; } tbody tr:hover td:first-child .acct, tbody tr:focus-visible td:first-child .acct { transform: none; } }
button.theme { min-width: 5.2rem; }
.stack, .bar, .usebar, .mini { forced-color-adjust: none; }

/* the two lists sit side by side, one column on narrow screens; a row is: name + tag, then the reasons */
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.5rem; align-items: start; }
@media (max-width: 1000px) { .pair { grid-template-columns: 1fr; } }
.riskrow { grid-template-columns: minmax(0, 1fr) auto; row-gap: .3rem; }
.riskrow ul { grid-column: 1 / -1; }
.riskrow .who { min-width: 0; } .riskrow .acct { overflow-wrap: anywhere; }
.riskrow li.dim { color: var(--muted); font-size: .85rem; }
