/* AppRevolt Stats — phone-first, dark only (matches apprevolt.io). */
:root {
  --bg: #0c0e14;
  --card: #141820;
  --elev: #1c2130;
  --border: #2a3040;
  --accent: #4a90d9;
  --text: #e6edf3;
  --muted: #8b949e;
  --dim: #484f58;
  /* dataviz dark slots: blue, orange, aqua */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  /* status colours always travel with an icon + word */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --radius: 14px;
  --tabs-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  font-family: 'Exo 2', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 700; }

/* ── buttons: never greyed; a pressed one keeps its shape and says what it's doing */
.btn {
  font: inherit; font-weight: 700; color: #fff; background: var(--accent);
  border: 0; border-radius: 12px; min-height: 48px; padding: 0 22px; cursor: pointer;
}
.btn:active { filter: brightness(1.15); }
.btn.small { min-height: 40px; min-width: 112px; padding: 0 14px; font-size: 14px; }
.btn.ghost { background: var(--elev); color: var(--text); border: 1px solid var(--border); }

/* ── login */
.login {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 24px; padding-top: calc(24px + env(safe-area-inset-top));
}
.login-logo { border-radius: 16px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login label { color: var(--muted); font-size: 13px; }
.login input {
  font: inherit; font-size: 17px; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; min-height: 50px; padding: 0 14px;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-msg { min-height: 20px; color: var(--serious); font-size: 14px; }

/* ── header */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  border-bottom: 1px solid var(--border);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 20px; }
.updated { color: var(--muted); font-size: 12.5px; min-height: 18px; margin-top: 2px; }
.apps { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.chip {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: var(--card);
  border: 1px solid var(--border); border-radius: 999px; min-height: 40px; padding: 0 16px; white-space: nowrap;
}
.chip.on { color: var(--text); border-color: var(--accent); }

/* ── content */
.view {
  padding: 14px 14px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.card h3 { font-size: 14px; font-weight: 700; margin: 12px 0 4px; }
.sub { color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* stat tiles */
.hero { padding: 18px 16px; }
.hero .label { color: var(--muted); font-size: 14px; }
.hero .value { font-size: 52px; font-weight: 800; line-height: 1.05; margin: 2px 0 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 700; line-height: 1.15; margin: 2px 0; }
.delta { font-size: 13px; color: var(--muted); }
.delta.up { color: var(--text); }

/* rows */
.rows { list-style: none; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14.5px; }
.rows li:first-child { border-top: 0; }
.rows .k { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.rows .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rows .v small { color: var(--muted); font-weight: 400; }

/* status */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.st i { font-style: normal; font-weight: 800; }
.st.ok i { color: var(--good); }
.st.waiting i { color: var(--warn); }
.st.error i { color: var(--crit); }
.pill { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }

/* charts */
.chart { margin-top: 4px; }
.readout { min-height: 22px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.readout span { color: var(--muted); font-weight: 400; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--s1); }
.chart .bar.s2 { fill: var(--s2); }
.chart .bar.s3 { fill: var(--s3); }
.chart .bar.dim { opacity: .45; }
.chart .ln { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--s1); stroke: var(--card); stroke-width: 2; }
details.tbl { margin-top: 8px; }
details.tbl summary { color: var(--muted); font-size: 13px; min-height: 36px; display: flex; align-items: center; cursor: pointer; }
details.tbl table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
details.tbl td, details.tbl th { padding: 5px 0; border-top: 1px solid var(--border); text-align: right; font-weight: 400; }
details.tbl th:first-child, details.tbl td:first-child { text-align: left; color: var(--muted); }

/* toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; width: 100%;
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px; }
.toggle .sw { width: 46px; height: 28px; border-radius: 999px; background: var(--elev); border: 1px solid var(--border); position: relative; flex: none; }
.toggle .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.toggle[aria-pressed="true"] .sw { background: var(--accent); border-color: var(--accent); }
.toggle[aria-pressed="true"] .sw::after { transform: translateX(18px); background: #fff; }

/* bottom tabs — fixed, so nothing above can move a tap target */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20, 24, 32, .96); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
.tab { font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); background: none; border: 0; border-top: 3px solid transparent; }
.tab.on { color: var(--text); border-top-color: var(--accent); }
.signout { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; min-height: 44px; text-decoration: underline; }
.center { text-align: center; }
