/* app.css: tokens, fixed full-screen shell (status bar, page track, bottom nav), shared card/button
   styles, settings and login. Page-specific layout lives in pages.css. */
:root {
  --bg: #0b1220; --card: #121c2e; --border: rgba(255,255,255,0.08); --text: #f2f5fa; --dim: #93a0b5;
  --ok: #3ddc84; --good: #0ca30c; --warn: #fab219; --bad: #d03b3b; --accent: #3987e5;
  --accent-track: rgba(57,135,229,.22); --track: rgba(255,255,255,0.08);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --r: 12px; color-scheme: dark;
}
/* Dark is the default. Light applies by system preference unless data-theme="dark" is set,
   or always when data-theme="light" is set (Settings theme selector). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2f6; --card: #ffffff; --border: rgba(0,0,0,0.08); --text: #0b1220; --dim: #52607a;
    --ok: #1a9c55; --accent: #2a78d6; --accent-track: rgba(42,120,214,.22); --track: rgba(0,0,0,0.08);
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef2f6; --card: #ffffff; --border: rgba(0,0,0,0.08); --text: #0b1220; --dim: #52607a;
  --ok: #1a9c55; --accent: #2a78d6; --accent-track: rgba(42,120,214,.22); --track: rgba(0,0,0,0.08);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; margin: 0; }
body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.fault { color: var(--bad); }
/* status bar */
#bar { flex: none; height: calc(40px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 10px; background: var(--card); border-bottom: 1px solid var(--border); }
.logo { height: 24px; width: auto; object-fit: contain; }
#bar h1 { margin: 0; font-size: 1rem; font-weight: 700; flex: 1 1 auto; min-width: 0; }
.clock { font-weight: 600; font-variant-numeric: tabular-nums; }
.pill { padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: .78rem; background: var(--track); color: var(--dim); white-space: nowrap; }
.pill.ok { background: var(--ok); color: #06210f; }
.pill.warn { background: var(--warn); color: #2b1b00; }
.pill.bad { background: var(--bad); color: #fff; }
.age { display: flex; align-items: baseline; gap: 6px; font-size: .8rem; white-space: nowrap; }
.age small { color: var(--dim); display: none; }
@media (min-width: 760px) { .age small { display: inline; } }
.age.ok b { color: var(--ok); } .age.warn b { color: var(--warn); } .age.bad b { color: var(--bad); }
/* page track: horizontal snap; pages scroll vertically only on short viewports (pages.css) */
#view { flex: 1 1 0; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior: contain; scrollbar-width: none; }
#view::-webkit-scrollbar { display: none; }
.page { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; height: 100%; min-width: 0;
  overflow: hidden; padding: 10px; }
.page > * { height: 100%; min-height: 0; }
/* bottom nav */
#nav { flex: none; display: flex; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--border); }
#nav a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--dim); text-decoration: none; font-size: .72rem; font-weight: 600; }
#nav a[aria-current="page"] { color: var(--accent); }
#nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* shared */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; min-width: 0; min-height: 0; overflow: hidden; }
.card h2 { margin: 0 0 6px; font-size: .72rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 10px; min-width: 0; }
.stat span { display: block; color: var(--dim); font-size: .72rem; }
.stat b { display: block; font-size: clamp(.85rem, 2.4vw, 1.1rem); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big { font-size: clamp(28px, 6vw, 44px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.msg { min-height: 1.2em; font-size: .85rem; margin-top: 4px; }
button { font: inherit; border: 0; border-radius: var(--r); cursor: pointer; min-height: 44px; padding: 0 16px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.toggle { width: 100%; font-size: 1.15rem; font-weight: 700; background: var(--accent); color: #031722; }
.toggle.on { background: var(--warn); color: #2b1b00; }
.confirm p { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; }
.confirm .btns { display: flex; gap: 10px; }
.confirm button { flex: 1; font-weight: 700; }
.yes { background: var(--ok); color: #06210f; } .no { background: var(--track); color: var(--text); }
/* settings */
.setrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.setrow:first-of-type { border-top: 0; }
.setrow > label, .setrow > span:first-child { color: var(--dim); flex: 0 0 100px; }
.setrow input, .setrow select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); flex: 1 1 160px; min-width: 0; }
.setrow button { background: var(--accent); color: #031722; font-weight: 700; }
.setrow button.danger { background: var(--bad); color: #fff; }
.small { font-size: .8rem; }
/* login overlay */
/* pull-to-refresh indicator (js/pull.js): a disc that follows the pull, flips its arrow when far enough, spins on release */
.ptr { position: fixed; top: 0; left: 0; right: 0; height: 0; display: flex; justify-content: center; pointer-events: none; z-index: 15; }
.ptr span { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; margin-top: 6px;
  background: var(--card); border: 1px solid var(--border); color: var(--dim); font-size: 20px; line-height: 1; box-shadow: 0 2px 10px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(-48px); transition: opacity .15s, background-color .15s, color .15s; }
.ptr.on span { opacity: 1; transform: translateY(calc(var(--p, 0) * 56px - 8px)) rotate(calc(var(--p, 0) * 180deg)); }
.ptr.ready span { background: var(--accent); color: #fff; border-color: transparent; }
.ptr.go span { animation: ptr-spin .7s linear infinite; }
@keyframes ptr-spin { to { transform: translateY(48px) rotate(540deg); } }
#login { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
#login form { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; width: 100%; max-width: 380px; }
#login h2 { margin: 0 0 12px; }
#login label { display: block; margin: 10px 0 4px; color: var(--dim); font-size: .9rem; }
#login input { width: 100%; font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
#login button { width: 100%; margin-top: 16px; background: var(--accent); color: #031722; font-weight: 700; }
#login details { margin-top: 12px; color: var(--dim); }
#login .err { color: var(--bad); margin: 8px 0 0; min-height: 1.2em; }
