:root {
  --bg: #ffffff; --fg: #1d1d1f; --muted: #6e6e73; --line: #e5e5ea; --panel: #f5f5f7;
  --green: #1a7f37; --red: #c62828; --amber: #9a6700; --accent: #b8860b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113; --fg: #ececf0; --muted: #9a9aa2; --line: #2a2a2e; --panel: #1b1b1f;
    --green: #4ac26b; --red: #ff6b6b; --amber: #e3b341; --accent: #e0b23c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
       display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.link { background: none; border: none; color: var(--muted); padding: 5px 4px; }
code { font-size: 12px; }

header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
         padding: 10px 16px; border-bottom: 1px solid var(--line); }
.status, .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--panel); color: var(--muted); }
.pill.good { color: var(--green); }
.pill.bad { color: var(--red); }
.pill a { color: inherit; font-weight: 600; }

nav { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); }
nav button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 12px; color: var(--muted); }
nav button.on { color: var(--fg); border-bottom-color: var(--accent); }

main { flex: 1; min-height: 0; display: flex; }
section { flex: 1; min-width: 0; display: flex; flex-direction: column; }
section[hidden] { display: none; }

#logs { position: relative; }
#log { flex: 1; margin: 0; padding: 10px 16px; overflow: auto; white-space: pre-wrap; word-break: break-word;
       font: 12px/1.5 ui-monospace, Consolas, monospace; background: var(--panel); }
#log .w { color: var(--amber); }
#log .e { color: var(--red); }
#log .s { color: var(--accent); }
.follow { position: absolute; right: 22px; bottom: 10px; font-size: 12px; color: var(--muted);
          background: var(--bg); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }

#news, #settings { overflow: auto; padding: 12px 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters input { flex: 1; min-width: 160px; }
.filters input, .filters select, #settingsForm input, #settingsForm select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
#newsCount { color: var(--muted); font-size: 12px; }
#newsList { list-style: none; margin: 0; padding: 0; }
#newsList li { padding: 8px 0; border-bottom: 1px solid var(--line); }
#newsList a { color: var(--fg); text-decoration: none; }
#newsList a:hover { text-decoration: underline; }
.meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; }
.meta .up { color: var(--green); font-weight: 600; }
.meta .down { color: var(--red); font-weight: 600; }
.meta .high { color: var(--amber); font-weight: 600; }
.summary { font-size: 12px; color: var(--muted); margin-top: 2px; }

#settingsForm { display: grid; gap: 10px; max-width: 460px; }
#settingsForm label { display: grid; gap: 3px; font-size: 13px; }
#settingsForm .err { color: var(--red); font-size: 12px; }
#settingsForm button { justify-self: start; margin-top: 4px; }
.hint { color: var(--muted); font-size: 12px; max-width: 460px; }
.ok { color: var(--green); }

body.signin { align-items: center; justify-content: center; }
body.signin form { display: grid; gap: 10px; width: min(300px, calc(100vw - 32px)); }
body.signin h1 { font-size: 20px; margin: 0 0 4px; }
body.signin input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
body.signin button { padding: 8px; }
.err { color: var(--red); margin: 0; }

#performance { overflow: auto; padding: 12px 16px 32px; display: block; }
#performance[hidden] { display: none; }
#performance h2 { font-size: 15px; margin: 22px 0 8px; text-wrap: balance; }
#performance h2:first-child { margin-top: 4px; }
#performance h2 small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
#performance h3 { font-size: 14px; margin: 16px 0 6px; }
#performance details { margin-top: 8px; }
#performance summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 8px; }
.stat { background: var(--panel); border-radius: 6px; padding: 6px 10px; display: grid; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }
.up { color: var(--green); }
.down { color: var(--red); }
.muted { color: var(--muted); }
.chart svg { width: 100%; max-width: 720px; height: auto; display: block; margin: 4px 0 8px; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .zero { stroke: var(--line); }
.chart .eq { fill: none; stroke-width: 2; }
.chart .eq.up { stroke: var(--green); }
.chart .eq.down { stroke: var(--red); }
.scroll { overflow-x: auto; margin-bottom: 10px; }
#performance table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 100%; }
#performance th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; }
#performance td { border-bottom: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; }
#performance tr.click { cursor: pointer; }
#performance tr.click:hover td, #performance tr.sel td { background: var(--panel); }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.breakdowns > * { min-width: 0; }
