/* The desktop app's colors, light and dark. */
:root {
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: #e1e0d9;
  --hover: #f0efec;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-wash: #e3eefc;
  --heat0: #f0efec;
  --heat1: #cde2fb;
  --heat2: #86b6ef;
  --heat3: #3987e5;
  --heat4: #1c5cab;
  --heat5: #0d366b;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink: #f0efec;
    --ink2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: #2c2c2a;
    --hover: #262624;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-wash: #16294a;
    --heat0: #262624;
    --heat1: #104281;
    --heat2: #1c5cab;
    --heat3: #3987e5;
    --heat4: #86b6ef;
    --heat5: #cde2fb;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }

.hint { color: var(--ink2); margin: 4px 0 0; }
.foot { margin-top: 20px; font-size: 12.5px; color: var(--muted); }
.error { color: #c0392b; min-height: 1.4em; margin: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error { color: #f08a7e; } }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

select, input, button {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 6px; padding: 6px 10px;
}
select { padding-right: 28px; max-width: 100%; }
button { cursor: pointer; }
button:hover { background: var(--hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-top: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.toggle { display: inline-flex; gap: 6px; }
.toggle button { padding: 4px 12px; }
.toggle button[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); }

.live {
  display: grid; gap: 6px; margin-top: 14px; padding: 10px 14px;
  background: var(--accent-wash); border: 1px solid var(--accent); border-radius: 8px;
}
.live-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent); align-self: center;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.live-clock { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.live-what { color: var(--ink2); }
.running { color: var(--accent); font-weight: 600; }

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px;
}
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
.tile .label { color: var(--ink2); font-size: 12px; }
.tile .value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .detail { color: var(--muted); font-size: 12px; }

.chart { margin-top: 12px; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: inherit; }
.empty { color: var(--ink2); text-align: center; padding: 28px 0; margin: 0; }

.table-wrap { margin-top: 12px; overflow: auto; max-height: 520px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink2); font-weight: 600; border-bottom-color: var(--axis); position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; }
td.note { white-space: normal; min-width: 160px; color: var(--ink2); }

.reports { list-style: none; margin: 12px 0 0; padding: 0; }
.reports li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.reports a { color: var(--accent); font-weight: 600; text-decoration: none; }
.reports a:hover { text-decoration: underline; }
.reports .meta { color: var(--muted); font-size: 12.5px; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; white-space: pre-line;
  background: var(--surface); color: var(--ink); border: 1px solid var(--axis);
  border-radius: 6px; padding: 6px 8px; font-size: 12.5px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.15);
  max-width: 260px;
}

.loading { text-align: center; color: var(--ink2); margin-top: 30vh; }

.pin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.pin-card { width: min(320px, 100%); display: grid; gap: 10px; margin: 0; text-align: center; }
.pin-card img { margin: 0 auto; }
.pin-card label { text-align: left; color: var(--ink2); }
.pin-card input { width: 100%; font-size: 16px; }

@media (max-width: 560px) {
  main { padding-top: 14px; }
  .filters, .filters select { width: 100%; }
  .filters select { flex: 1; }
  .tile .value { font-size: 19px; }
}
