:root {
  --gcfa-primary: #173456;
  --gcfa-secondary: #00688b;
  --gcfa-accent: #e3170d;
  --gcfa-bg: #f6f9fb;
  --gcfa-text: #173456;
  --gcfa-muted: #4f5c6b;
  --gcfa-border: #b6b6b6;
  --gcfa-success: #08986d;
  --gcfa-warning: #e3170d;
  --gcfa-danger: #e3170d;
  --gcfa-info: #a4d3d8;
  --gcfa-surface: #ffffff;
  --header-height: 64px;
  --footer-height: 40px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Open Sans', system-ui, Arial, sans-serif;
  margin: 0;
  background: var(--gcfa-bg);
  color: var(--gcfa-text);
}

#maintenanceBanner {
  display: none;
  background: var(--gcfa-warning);
  color: #ffffff;
  padding: 12px 24px;
  text-align: center;
  font-weight: 600;
}

#maintenanceBanner.visible { display: block; }

header {
  background: var(--gcfa-primary);
  color: #ffffff;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-pill {
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  margin-right: auto;
}

.app-brand-logo {
  display: block;
  height: 34px;
  width: auto;
  max-width: min(40vw, 240px);
}

.header-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-nav a {
  color: #ffffff;
  text-decoration: none;
  font-size: 0.875rem;
  opacity: 0.9;
  transition: opacity 0.15s;
}

.header-nav a:hover { opacity: 1; text-decoration: underline; }

.export-btn {
  background: var(--gcfa-secondary);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.export-btn:hover { opacity: 0.95; transform: translateY(-1px); }
.export-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.export-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

main {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - var(--header-height));
}

#sidebar {
  background: var(--gcfa-surface);
  border-right: 1px solid var(--gcfa-border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#sidebar h2 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gcfa-muted);
  margin: 0 0 12px 0;
}

.report-btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 16px;
  background: var(--gcfa-bg);
  border: 1px solid var(--gcfa-border);
  border-radius: 6px;
  text-align: left;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.report-btn:hover { background: #e8f1f4; border-color: var(--gcfa-secondary); }
.report-btn.active { background: var(--gcfa-primary); color: #ffffff; border-color: var(--gcfa-primary); }
.report-btn.unavailable { opacity: 0.5; cursor: not-allowed; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--gcfa-border);
}

.sidebar-footer a {
  display: block;
  color: var(--gcfa-secondary);
  text-decoration: none;
  padding: 8px 0;
  font-size: 0.875rem;
}

.sidebar-footer a:hover { text-decoration: underline; }

.sidebar-logo {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.sidebar-logo img {
  max-width: 180px;
  width: 100%;
  height: auto;
  opacity: 0.9;
}

#reportContainer {
  height: 100%;
  width: 100%;
  background: var(--gcfa-surface);
}

#reportContainer iframe { border: none; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gcfa-muted);
}

.error-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gcfa-danger);
  text-align: center;
  padding: 24px;
}

.error-message h3 { margin: 0 0 8px 0; }
.error-message p { margin: 0; color: var(--gcfa-muted); }

footer {
  background: var(--gcfa-surface);
  border-top: 1px solid var(--gcfa-border);
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 0.75rem;
  color: var(--gcfa-muted);
}

footer a { color: var(--gcfa-secondary); text-decoration: none; }
footer a:hover { text-decoration: underline; }

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.footer-logo {
  height: 24px;
  width: auto;
  opacity: 0.9;
}

#dataFreshness {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.freshness-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gcfa-success);
}

.freshness-indicator.stale { background: var(--gcfa-warning); }
.freshness-indicator.unknown { background: var(--gcfa-border); }

@media (max-width: 900px) {
  main { grid-template-columns: 200px 1fr; }
  #sidebar { padding: 12px; }
  .report-btn { padding: 10px 12px; font-size: 0.875rem; }
  .header-nav { gap: 12px; }
  .header-nav a { font-size: 0.75rem; }
  .export-btn { padding: 6px 10px; font-size: 0.75rem; }
  .export-group { gap: 6px; }
}

@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
  }
  .app-brand-logo {
    height: 30px;
    max-width: min(62vw, 220px);
  }
  .export-group {
    width: 100%;
    justify-content: flex-start;
  }
  main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  #sidebar {
    border-right: none;
    border-bottom: 1px solid var(--gcfa-border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  #sidebar h2 { width: 100%; margin-bottom: 4px; }
  .report-btn { width: auto; flex: 1 1 auto; min-width: 120px; }
  .sidebar-footer { display: none; }
  #reportContainer { min-height: 500px; }
  footer { flex-direction: column; height: auto; padding: 8px 16px; gap: 4px; }
  .footer-brand { margin-right: 0; }
  #dataFreshness { margin-left: 0; }
}
