:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #566170;
  --border: #cfd5dd;
  --accent: #1f4fd1;
  --accent-text: #ffffff;
  --danger-bg: #fdecea;
  --danger-text: #8f1d14;
  --focus: #1f4fd1;
  --ok: #1a7f37;
  --warn: #9a6700;
  --alert: #cf222e;
  --series-0: #1f4fd1;
  --series-1: #c2570c;
  --series-2: #1a7f37;
  --series-3: #8250df;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #171c23;
    --text: #e7eaee;
    --muted: #9aa5b4;
    --border: #2d3540;
    --accent: #6f9bff;
    --accent-text: #0b1220;
    --danger-bg: #3a1b18;
    --danger-text: #ffb4aa;
    --focus: #8fb2ff;
    --ok: #3fb950;
    --warn: #d29922;
    --alert: #ff7b72;
    --series-0: #6f9bff;
    --series-1: #f0a35a;
    --series-2: #3fb950;
    --series-3: #c297ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  line-height: 1.3;
}

/* Login, and the one-sentence pages: centred on the screen. */
.login,
.message {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  place-items: center;
}

.message h1 {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.card {
  width: 100%;
  max-width: 22rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
}

label {
  display: block;
  margin: 1rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

input {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  margin-top: 1.5rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.notice {
  margin: 0 0 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* The pages after login: the overview and the page of one App. */
.wrap {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  margin-bottom: 0.25rem;
}

.top h1 {
  margin: 0;
}

.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

/* Log out: a quiet button at the end of the header, not the full-width one of the login form. */
.top form {
  margin: 0;
}

.top form button {
  display: inline-block;
  width: auto;
  margin: 0;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 400;
}

a {
  color: var(--accent);
}

a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.0625rem;
  line-height: 1.3;
}

h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.3;
}

.muted {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.panel {
  margin: 0 0 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
}

.panel > .muted {
  margin-bottom: 0.5rem;
}

.empty {
  margin: 0;
  color: var(--muted);
}

/* Several charts in one panel: the next one starts a little lower. */
.block + .block {
  margin-top: 1.25rem;
}

.note {
  display: block;
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* The red banner at the top: a data source is late, so the numbers below may be old. */
.banner {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--danger-text);
  border-radius: 0.5rem;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.banner ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.alert-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.alert-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.alert-list li:first-child {
  padding-top: 0;
}

.alert-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.alert-list p {
  margin: 0;
}

.alert-title {
  margin-bottom: 0.125rem;
}

/* Tables scroll sideways on a narrow screen instead of squeezing the numbers. */
.scroll {
  overflow-x: auto;
}

.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.data th,
.data td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data th {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Five columns do not fit a phone: the table scrolls sideways (inside .scroll) and keeps its columns readable. */
.wide {
  min-width: 36rem;
}

/* A short name that must not be broken in the middle of its characters. */
.keep {
  white-space: nowrap;
}

.data tbody tr:last-child td {
  border-bottom: 0;
}

.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data .total td {
  font-weight: 600;
}

.data td .note {
  margin-top: 0;
}

/* Free quota and sources: how bad it is, in colour and in the words next to it. */
.bar {
  width: 6rem;
  height: 0.75rem;
  vertical-align: middle;
}

.level-ok .bar {
  accent-color: var(--ok);
}

.level-warn .bar {
  accent-color: var(--warn);
}

.level-alert .bar {
  accent-color: var(--alert);
}

.level-label {
  white-space: nowrap;
}

.level-warn .level-label {
  color: var(--warn);
  font-weight: 600;
}

.level-alert .level-label {
  color: var(--alert);
  font-weight: 600;
}

/* The line chart. Series 1 is dashed as well, so the two do not rest on colour alone. */
.chart {
  display: block;
  width: 100%;
  min-width: 40rem;
  height: auto;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-text {
  fill: var(--muted);
  font-size: 11px;
}

.line-0 {
  stroke: var(--series-0);
}

.line-1 {
  stroke: var(--series-1);
  stroke-dasharray: 6 4;
}

.line-2 {
  stroke: var(--series-2);
}

.line-3 {
  stroke: var(--series-3);
}

.dot-0 {
  fill: var(--series-0);
}

.dot-1 {
  fill: var(--series-1);
}

.dot-2 {
  fill: var(--series-2);
}

.dot-3 {
  fill: var(--series-3);
}
