/* FPG CEO Mini App — mobile-first, no framework, no build step.
   Colours follow Telegram's theme variables where available so the app matches
   the client's light/dark setting, with explicit fallbacks. */

:root {
  --bg:        var(--tg-theme-bg-color, #ffffff);
  --fg:        var(--tg-theme-text-color, #16181c);
  --muted:     var(--tg-theme-hint-color, #707579);
  --card:      var(--tg-theme-secondary-bg-color, #f4f4f6);
  --accent:    var(--tg-theme-link-color, #2f7bf6);
  --line:      rgba(128, 128, 128, 0.22);

  /* Status palette. `unknown` is deliberately NOT a shade of green — a
     "cannot tell" that looks healthy is the failure this app exists to avoid.

     `partial` is a fourth colour and must read as NEUTRAL, not as a weaker
     amber: "the latest week is still filling" is true every day, and when it
     shared amber with `unknown` the dashboard was permanently off-green, which
     trains the eye to skip amber entirely — including the day it means
     something. Slate blue is the choice because it is not on the
     green-amber-red severity axis at all, so it reads as information rather
     than as a lesser warning. */
  --ok:        #1a9e5c;
  --partial:   #5a7d9a;
  --unknown:   #b0820a;
  --bad:       #d1453b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 72px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── top bar ───────────────────────────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#title { font-size: 17px; font-weight: 650; margin: 0; flex: 1; }
.role {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.back {
  background: none; border: none; color: var(--accent);
  font-size: 28px; line-height: 1; padding: 0 4px; cursor: pointer;
}

/* ── banners ───────────────────────────────────────────────────────────── */
.banner {
  margin: 12px 16px; padding: 12px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
}
.banner-bad {
  background: rgba(209, 69, 59, .12);
  border-color: rgba(209, 69, 59, .45);
  color: var(--bad);
}
.banner strong { display: block; margin-bottom: 3px; }

/* ── tiles ─────────────────────────────────────────────────────────────── */
.tiles { display: grid; gap: 12px; padding: 14px 16px; }
@media (min-width: 620px) { .tiles { grid-template-columns: 1fr 1fr; } }

.tile {
  background: var(--card); border-radius: 16px; padding: 14px 16px;
  border: 1px solid var(--line); cursor: pointer;
  transition: transform .08s ease;
}
.tile:active { transform: scale(.985); }
.tile-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tile-name { font-weight: 650; font-size: 16px; flex: 1; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); }
/* Hollow, not filled: distinguishable from the severity dots even in
   greyscale or for a red-green colour-blind reader, who would otherwise be
   separating four states by hue alone. */
.dot-partial { background: transparent; box-shadow: inset 0 0 0 2px var(--partial); }
.dot-unknown { background: var(--unknown); }
.dot-bad { background: var(--bad); }

.metrics { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.metric-label { font-size: 12px; color: var(--muted); }
.metric-value { font-size: 17px; font-weight: 640; letter-spacing: -.01em; }

/* Dimming is the visual half of the stale rule: numbers stay readable but
   stop looking authoritative. */
.dimmed .metric-value,
.dimmed .stat-value { opacity: .42; }

.tile-foot {
  margin-top: 10px; font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 8px;
}

/* ── sections ──────────────────────────────────────────────────────────── */
.section { padding: 4px 16px 18px; }
.section h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 18px 0 10px; font-weight: 600;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-label { font-size: 14px; }
.row-sub { font-size: 12px; color: var(--muted); display: block; }
.stat-value { font-weight: 640; white-space: nowrap; }

.headline-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 14px 16px 4px;
}
.headline-grid .card { padding: 12px 14px; }
.headline-grid .metric-value { font-size: 20px; }

/* ── unreliable / flagged figures ──────────────────────────────────────── */
.unreliable {
  border-style: dashed !important;
  border-color: rgba(209, 69, 59, .5) !important;
}
.tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 6px; margin-left: 6px;
  vertical-align: middle;
}
.tag-bad     { background: rgba(209, 69, 59, .15);  color: var(--bad); }
.tag-unknown { background: rgba(176, 130, 10, .16); color: var(--unknown); }
.tag-partial { background: rgba(90, 125, 154, .16); color: var(--partial); }

/* ── caveats ───────────────────────────────────────────────────────────── */
.caveat { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.caveat:last-child { border-bottom: none; }
.caveat .dot { margin-top: 6px; }
.caveat-label { font-weight: 600; font-size: 14px; }
.caveat-detail { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── trend ─────────────────────────────────────────────────────────────── */
.trend { display: flex; align-items: flex-end; gap: 6px; height: 92px; padding: 6px 0 0; }
.bar { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; opacity: .82; }
.trend-labels { display: flex; gap: 6px; margin-top: 6px; }
.trend-labels span { flex: 1; font-size: 10px; color: var(--muted); text-align: center; }

/* ── misc ──────────────────────────────────────────────────────────────── */
.loading, .empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.deny { padding: 44px 24px; text-align: center; }
.deny h2 { font-size: 17px; margin: 0 0 8px; }
.deny p { color: var(--muted); font-size: 14px; margin: 0; }
.muted { color: var(--muted); }

#footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--muted);
  background: var(--bg); border-top: 1px solid var(--line);
}
