/* Minimalist, mobile-first styling. #0178d4 matches the accent color
   monitor.py's console panel already uses (build_panel's border_style), so
   the site reads as the same tool rather than an unrelated skin. Ink/surface
   tokens and the status palette (good/warning/critical) below come from the
   project's validated dataviz palette - status colors are fixed (same hex in
   light and dark) rather than themed, so a "good" meter always means the
   same thing regardless of mode. */

:root {
  --accent: #0178d4;
  --bg: #f9f9f7;
  --bg-alt: #f4f6f8;
  --text: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --border: #e1e0d9;
  --card-bg: #fcfcfb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --radius: 10px;

  /* status palette - fixed, never themed */
  --status-good: #0ca30c;
  --status-good-track: rgba(12, 163, 12, 0.15);
  --status-warning: #d98c00;
  --status-warning-track: rgba(217, 140, 0, 0.16);
  --status-critical: #d03b3b;
  --status-critical-track: rgba(208, 59, 59, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --bg-alt: #17181a;
    --text: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --border: #2c2c2a;
    --card-bg: #1a1a19;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.5);

    --status-warning: #fab219;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* iPhones with a notch/Dynamic Island (and the bottom home-indicator
     gesture bar) report non-zero env(safe-area-inset-*) only when the
     viewport meta tag has viewport-fit=cover (see base.html) - without
     both, content silently renders behind the island in fullscreen Mini
     Apps. Left/right covers the same case in landscape. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1 { font-size: 1.5rem; margin: 0.2em 0 0.6em; letter-spacing: -0.01em; }
h2 { font-size: 0.8rem; margin: 1.8em 0 0.7em; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(0.85rem + env(safe-area-inset-top, 0px)) 1rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand svg { flex-shrink: 0; }

.topnav {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem;
}
.topnav .tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.55rem 1.3rem;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.topnav .tab:hover { color: var(--text); text-decoration: none; }
.topnav .tab svg { opacity: 0.75; width: 19px; height: 19px; }
.topnav .tab-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(1, 120, 212, 0.35);
}
.topnav .tab-active svg { opacity: 1; }
.topnav .tab-active:hover { color: #fff; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.lang-switch { display: flex; gap: 0.4rem; font-size: 0.8rem; }
.lang-switch a {
  color: var(--text-muted);
  padding: 0.15rem 0.35rem;
  border-radius: 5px;
}
.lang-switch a.active { color: var(--accent); font-weight: 700; }
.lang-switch a:hover { text-decoration: none; background: var(--bg-alt); }
.lang-switch.center { justify-content: center; margin-top: 1.2rem; }

/* ---- cards (sessions / players lists) ---- */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.card-id { color: var(--text-muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.card-title { font-weight: 600; }

.card-meta {
  display: flex;
  gap: 0.8rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.badge-active { color: var(--status-warning); background: var(--status-warning-track); }
.badge-done { color: var(--status-good); background: var(--status-good-track); }

/* ---- meter (inline attendance-% indicator) ---- */
/* Fill carries the status color; track is a light tint of the same color,
   so the bar's length (not just its hue) always carries the magnitude - the
   percentage text beside it stays in normal ink, never colored by status. */

.meter {
  --meter-w: 64px;
  width: var(--meter-w);
  height: 6px;
  border-radius: 999px;
  background: var(--m-track, var(--status-good-track));
  overflow: hidden;
  flex-shrink: 0;
}
.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--m-fill, var(--status-good));
}
.meter-good { --m-fill: var(--status-good); --m-track: var(--status-good-track); }
.meter-warning { --m-fill: var(--status-warning); --m-track: var(--status-warning-track); }
.meter-critical { --m-fill: var(--status-critical); --m-track: var(--status-critical-track); }

.pct-cell { display: flex; align-items: center; gap: 0.55rem; }
.pct-num { font-variant-numeric: tabular-nums; }

/* ---- tables ---- */

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }

tr:last-child td { border-bottom: none; }
tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--bg-alt); }

/* ---- stat tiles (player page) ---- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.stat-value.muted { font-size: 1rem; font-weight: 500; color: var(--text-muted); }

.stat-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ---- misc ---- */

.back-link { display: inline-block; font-size: 0.9rem; margin-bottom: 0.4rem; color: var(--text-secondary); }
.back-link:hover { color: var(--accent); }
.session-meta, .totals { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.empty { color: var(--text-muted); font-style: italic; }

/* ---- mobile ---- */

@media (max-width: 560px) {
  .topbar { padding: calc(0.7rem + env(safe-area-inset-top, 0px)) 0.8rem 0.7rem; gap: 0.6rem; }
  .topnav .tab { padding: 0.55rem 0.85rem; }
  .topnav .tab svg { width: 21px; height: 21px; }
  .topnav span.label { display: none; }
  .topbar-right { gap: 0.6rem; }
  .container { padding: 1rem 0.75rem 2.5rem; }
  th, td { padding: 0.45rem 0.4rem; font-size: 0.85rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .meter { --meter-w: 48px; }
}
