/* Control: an operations console. Layout: one column, summary first, then a tile grid per group. */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --fg: #171b22;
  --muted: #5c6675;
  --line: #d9dde4;
  --accent: #3d63dd;
  --accent-fg: #ffffff;
  --healthy: #23875a;
  --degraded: #b97709;
  --down: #c93b3b;
  --waiting: #7d8796;
  --healthy-bg: #e3f3eb;
  --degraded-bg: #fbf0d9;
  --down-bg: #fbe4e4;
  --waiting-bg: #eceef2;
  --logs-bg: #0f131a;
  --logs-fg: #d5dbe4;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #161b22; --surface-2: #1d232c; --fg: #e4e8ee; --muted: #949fae; --line: #29313c;
    --accent: #7d9bff; --accent-fg: #0b0f16;
    --healthy: #4cc38a; --degraded: #e5a93a; --down: #ef6b6b; --waiting: #8a95a5;
    --healthy-bg: #13281f; --degraded-bg: #2c2312; --down-bg: #321818; --waiting-bg: #1f252e;
    --logs-bg: #0a0d12; --logs-fg: #d5dbe4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { text-wrap: balance; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 0.8rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
p { margin: 0.25rem 0; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0.7rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--fg); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.brand-host { color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.page { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1rem 4rem; display: flex; flex-direction: column; gap: 1.75rem; }

.btn { font: inherit; font-size: 0.9rem; padding: 0.4rem 0.85rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--line)); }
.btn-danger[type="submit"] { background: var(--down); color: #fff; border-color: var(--down); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-lg { font-size: 0.85rem; padding: 0.15rem 0.65rem; }
.pill-healthy { color: var(--healthy); background: var(--healthy-bg); }
.pill-degraded { color: var(--degraded); background: var(--degraded-bg); }
.pill-down { color: var(--down); background: var(--down-bg); }
.pill-waiting, .pill-unknown { color: var(--waiting); background: var(--waiting-bg); }

.summary { display: flex; flex-direction: column; gap: 0.6rem; }
.summary-title { font-size: 1.75rem; }
.summary-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; max-width: 640px; }
.seg-healthy { background: var(--healthy); } .seg-degraded { background: var(--degraded); }
.seg-down { background: var(--down); } .seg-waiting, .seg-unknown { background: var(--waiting); opacity: 0.6; }

.group { display: flex; flex-direction: column; gap: 0.7rem; }
.group-desc { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 0.4rem; }
.group-attention h2 { color: var(--down); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.tile { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.85rem 0.95rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--fg); min-width: 0; }
.tile:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.tile.state-down { border-color: color-mix(in srgb, var(--down) 55%, var(--line)); background: color-mix(in srgb, var(--down-bg) 45%, var(--surface)); }
.tile.state-degraded { border-color: color-mix(in srgb, var(--degraded) 50%, var(--line)); }
.tile.state-waiting .tile-name { color: var(--muted); }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.tile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-summary { font-size: 0.88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.8rem; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.events li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.7rem; padding: 0.55rem 0.85rem; border-top: 1px solid var(--line); font-size: 0.9rem; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 5.5rem; }

.flash { padding: 0.6rem 0.85rem; border-radius: 6px; font-size: 0.9rem; border: 1px solid; }
.flash-ok { color: var(--healthy); background: var(--healthy-bg); border-color: color-mix(in srgb, var(--healthy) 35%, transparent); }
.flash-bad { color: var(--down); background: var(--down-bg); border-color: color-mix(in srgb, var(--down) 35%, transparent); }
.flash-warn { color: var(--degraded); background: var(--degraded-bg); border-color: color-mix(in srgb, var(--degraded) 35%, transparent); max-width: 780px; }

.crumbs { font-size: 0.9rem; }
.item-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.item-head > div:first-child { min-width: 0; max-width: 760px; display: flex; flex-direction: column; gap: 0.3rem; }
.item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.item-actions form { display: flex; gap: 0.4rem; align-items: center; }
.confirm { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; padding: 0.25rem 0.5rem; background: var(--surface-2); border-radius: 6px; font-size: 0.9rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.table-wrap { overflow-x: auto; }
table.checks { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.checks th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 0.3rem 0.6rem 0.4rem 0; border-bottom: 1px solid var(--line); }
table.checks td { padding: 0.5rem 0.6rem 0.5rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.checks tr:last-child td { border-bottom: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.45rem; vertical-align: 1px; }
.dot-ok { background: var(--healthy); } .dot-warn { background: var(--degraded); } .dot-fail { background: var(--down); }
.dot-waiting, .dot-info { background: var(--waiting); }
details summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; margin-top: 0.2rem; }
pre.detail { margin: 0.4rem 0 0; padding: 0.6rem; background: var(--surface-2); border-radius: 6px; font: 0.8rem/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }

.history { display: flex; gap: 2px; height: 30px; }
.bar { flex: 1; border-radius: 2px; background: var(--surface-2); }
.bar-healthy { background: var(--healthy); } .bar-degraded { background: var(--degraded); }
.bar-down { background: var(--down); } .bar-waiting, .bar-unknown { background: var(--waiting); opacity: 0.45; }
.history-axis { display: flex; justify-content: space-between; font-size: 0.75rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; font-size: 0.9rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; font-variant-numeric: tabular-nums; }
.envlist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.envlist li { background: var(--surface-2); padding: 0.1rem 0.45rem; border-radius: 4px; }

.logs-tools { display: flex; gap: 0.8rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.logs-out { margin: 0; background: var(--logs-bg); color: var(--logs-fg); border-radius: 6px; padding: 0.75rem; font: 0.78rem/1.5 var(--mono); height: 440px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.logs-out .err { color: #ff8f8f; }
.logs-out .ts { color: #7a8596; }

.login { max-width: 380px; margin: 3rem auto; display: flex; flex-direction: column; gap: 0.8rem; }
.stack { display: flex; flex-direction: column; gap: 0.45rem; }
.stack label { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
.stack input { font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.stack .btn { margin-top: 0.7rem; padding: 0.55rem; }

@media (max-width: 560px) {
  .summary-title { font-size: 1.35rem; }
  .brand-host { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
