:root {
  /* Primary — from brand navy (no wordmark in the logo asset to sample; matches existing brand usage) */
  --primary: #1b2a4a;
  --primary-light: #243659;
  --primary-dark: #111b31;

  /* Accent — pixel-sampled from app/web/static/logo.png (dominant fill: rgb(182,153,64)) */
  --accent: #b69940;
  --accent-hover: #957d34; /* accent darkened ~18% */
  --accent-pale: rgba(182, 153, 64, 0.13);
  --accent-border: rgba(182, 153, 64, 0.28);

  --bg: #f4f3ee;
  --surface: #ffffff;
  --border: #ddd9d0;
  --text: #18160f;
  --text-2: #5c5852;
  --text-3: #9c9690;

  --radius: 9px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Barlow", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 {
  font-family: "Cormorant Garamond", serif;
  color: var(--primary);
}

/* Numeric/tabular figures get the monospace so columns of numbers align */
.stat-current,
.stats-panel dd,
table td:nth-child(2),
table th:nth-child(2) {
  font-family: "JetBrains Mono", monospace;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: relative;
  width: 220px;
  background: var(--primary);
  color: white;
  padding: 24px 16px;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s, padding 0.2s;
}

/* Task bar (sidebar) hide/unhide. Collapsed state persists via localStorage
   (see app.js) so the preference survives across page loads and sessions. */
.layout.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  border: none;
}

.sidebar-toggle-close {
  position: absolute;
  top: 14px;
  right: 10px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.18s;
}
.sidebar-toggle-close:hover { color: white; }

.sidebar-toggle-open {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 600;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: none;
  background: var(--primary);
  color: white;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.18s;
}
.sidebar-toggle-open:hover { background: var(--primary-light); }
.layout.sidebar-collapsed .sidebar-toggle-open { display: flex; align-items: center; justify-content: center; }

.logo { display: flex; align-items: center; justify-content: center; margin-bottom: 32px; }
.logo-mark {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar nav ul { list-style: none; padding: 0; margin: 0; white-space: nowrap; }
.sidebar nav li { margin-bottom: 4px; }
.sidebar nav a {
  color: #cfd6e4;
  text-decoration: none;
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: background 0.18s, color 0.18s;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.sidebar nav a.active { background: var(--accent); color: var(--primary); font-weight: 600; }

.content { flex: 1; padding: 32px 40px; max-width: 1320px; }

.page-title { margin: 0 0 8px; font-size: 28px; }
.page-subtitle { color: var(--text-2); margin-bottom: 32px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 32px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.stat-current { font-size: 32px; font-weight: 700; color: var(--primary); margin: 0 0 12px; }
.card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 0 0 12px; font-size: 13px; }
.card dl div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.card dt { color: var(--text-3); }
.card dd { margin: 0; font-weight: 600; font-family: "JetBrains Mono", monospace; }
.card-link { color: var(--accent-hover); font-weight: 600; text-decoration: none; font-size: 14px; }
.card-link:hover { text-decoration: underline; }

.last-updated { color: var(--text-3); font-size: 12px; margin: 0 0 8px; }

.no-data { color: var(--text-3); font-style: italic; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; margin-bottom: 32px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.chart-card h3 { margin: 0 0 8px; font-size: 15px; }
.chart-card img { max-width: 100%; }

/* Chart.js needs an explicitly-sized parent when maintainAspectRatio is false */
.chart-canvas-wrap { position: relative; width: 100%; height: 380px; }

.stats-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 32px; box-shadow: var(--shadow); }
.stats-panel dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0; }
.stats-panel div { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.stats-panel dt { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; font-family: "Barlow", sans-serif; }
.stats-panel dd { margin: 4px 0 0; font-size: 18px; font-weight: 600; }

.downloads { display: flex; gap: 10px; margin-bottom: 32px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}
.btn:hover { background: var(--primary-light); transform: translateY(-2px); }

.data-table-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-3); font-weight: 600; text-transform: uppercase; font-size: 11px; font-family: "Barlow", sans-serif; }

.table-scroll { max-height: 520px; overflow-y: auto; }

/* Collapsible sections (data table hide/unhide) */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.section-header h3 { margin: 0; }
.toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: "Barlow", sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.toggle-btn:hover { background: var(--accent-pale); color: var(--primary); }
.collapsible.collapsed { display: none; }

.stats-table-wrap { overflow-x: auto; }

.upload-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.upload-form button {
  background: var(--accent);
  color: var(--primary);
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.upload-form button:hover { background: var(--accent-hover); color: white; }
#upload-result { font-size: 13px; }

/* --- Splash overlay (Home page only) ---
   Structure/timing/easing copied verbatim from the reference source; only the
   gradient/button colors are substituted with our own pixel-sampled tokens
   (the reference's example hexes, e.g. rgba(196,160,68,...), are literally the
   OLD placeholder accent we already corrected away from — not ours). */

.start-pg {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}

.start-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 110% 65% at 38% 0%, var(--accent) 0%, var(--accent-hover) 25%, transparent 52%),
    radial-gradient(ellipse 70% 50% at 95% 5%, rgba(182, 153, 64, 0.55) 0%, transparent 42%),
    linear-gradient(162deg, var(--accent-hover) 0%, var(--primary-light) 40%, var(--primary) 65%, var(--primary-dark) 100%);
}

.start-pg.exiting {
  animation: startExit 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}
@keyframes startExit {
  to { opacity: 0; transform: scale(0.97) translateY(-16px); }
}

.start-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 40px;
  animation: startEnter 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes startEnter {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.start-logo-img {
  max-width: 480px; max-height: 130px; object-fit: contain; display: block;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.45));
}

.start-btn {
  background: var(--primary); color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.2); border-radius: var(--radius);
  padding: 14px 56px;
  font-family: "Barlow", sans-serif; font-size: 15px; font-weight: 600; letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.start-btn:hover { background: var(--primary-light); border-color: rgba(255, 255, 255, 0.36); transform: translateY(-2px); }
.start-btn:active { transform: translateY(0); }

.start-copyright {
  position: absolute; bottom: 24px; left: 0; right: 0;
  text-align: center; font-size: 11px; color: rgba(255, 255, 255, 0.28); letter-spacing: 0.3px;
  z-index: 1;
}

.hidden { display: none; }
