*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select, textarea { font-family: "Times New Roman", Times, serif; }

body {
  font-family: "Times New Roman", Times, serif;
  background: #FAFAFA;
  color: #2D2D2D;
  height: 100vh;
  overflow: hidden;
}

/* ── App shell: sidebar + main ────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #005030;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #003d24;
  overflow-y: auto;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #F47321;
}
.sidebar-header .wordmark {
  font-size: 15px;
  font-weight: bold;
  color: #FFFFFF;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.sidebar-header .page-title {
  font-size: 14px;
  color: #FFFFFF;
  margin-top: 10px;
  font-weight: normal;
}
.sidebar-header .page-subtitle {
  font-size: 10px;
  color: rgba(255,255,255,.65);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 3px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}
.sidebar-group-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 10px 20px 4px;
}
.sidebar-nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-family: "Times New Roman", Times, serif;
  font-size: 13px;
  padding: 7px 20px 7px 28px;
  cursor: pointer;
  transition: background .12s;
}
.sidebar-nav button:hover {
  background: #003d24;
}
.sidebar-nav button.active,
.sidebar-nav .nav-parent-btn.active {
  background: #FFFFFF;
  color: #005030;
  font-weight: 600;
}

/* Expandable parent items */
.nav-parent { }
.nav-parent-btn {
  display: flex;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-family: "Times New Roman", Times, serif;
  font-size: 13px;
  padding: 7px 20px 7px 28px;
  cursor: pointer;
  transition: background .12s;
  align-items: center;
  justify-content: space-between;
}
.nav-parent-btn:hover { background: #003d24; }
.nav-parent-btn .chevron {
  font-size: 10px;
  opacity: .6;
  transition: transform .2s;
}
.nav-parent.expanded .nav-parent-btn .chevron {
  transform: rotate(90deg);
}
.nav-children {
  display: none;
  padding-left: 12px;
}
.nav-parent.expanded .nav-children {
  display: block;
}
.nav-children button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  font-family: "Times New Roman", Times, serif;
  font-size: 12px;
  padding: 5px 20px 5px 28px;
  cursor: pointer;
  transition: background .12s;
}
.nav-children button:hover { background: #003d24; }
.nav-children button.active {
  background: rgba(255,255,255,.15);
  color: #FFFFFF;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #003d24;
}
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 12px;
  background: #003d24;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background .15s;
}
.sidebar-badge:hover {
  background: #002a18;
}

/* ── Main content area ────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.top-strip {
  height: 6px;
  background: #005030;
  flex-shrink: 0;
}
.content-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Page title strip ─────────────────────────────────────── */
.page-title-strip {
  background: #005030;
  padding: 0 32px;
  height: 80px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title-strip h1 {
  font-family: "Times New Roman", Times, serif;
  font-size: 22px;
  font-weight: normal;
  color: #FFFFFF;
  letter-spacing: .02em;
  white-space: nowrap;
}
.page-title-strip .back-link {
  font-family: "Times New Roman", Times, serif;
  font-size: 13px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  transition: color .15s;
  white-space: nowrap;
}
.page-title-strip .back-link:hover { color: #FFFFFF; }


/* ── Layout ──────────────────────────────────────────────── */
.page { display: none; }
.page.visible { display: block; }

.container { max-width: 1280px; width: 100%; margin: 0 auto; padding: 24px 32px; }

/* KPI row — now lives inside .page-title-strip */
.kpi-row {
  display: flex;
  align-items: center;
  margin-left: auto;
  height: 100%;
}
.kpi {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 20px;
  border-left: 1px solid rgba(255,255,255,.2) !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
  height: 56px;
  min-width: 130px;
  background: transparent !important;
  border-radius: 0;
}
.kpi:last-child, .kpi-card:last-child { padding-right: 0; }
.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 20px;
  border-left: 1px solid rgba(255,255,255,.2) !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
  height: 56px;
  min-width: 130px;
  background: transparent !important;
  border-radius: 0;
}
.kpi-card .kpi-label {
  font-family: "Times New Roman", Times, serif;
  font-size: 10px;
  color: rgba(255,255,255,.7);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-variant: small-caps;
  line-height: 1.2;
}
.kpi-card .kpi-value {
  font-family: "Times New Roman", Times, serif;
  font-size: 22px;
  color: #FFFFFF !important;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  font-weight: normal;
}
.kpi.orange, .kpi.teal, .kpi.red {
  border-left: 1px solid rgba(255,255,255,.2) !important;
}
.kpi-label {
  font-family: "Times New Roman", Times, serif;
  font-size: 10px;
  color: rgba(255,255,255,.7);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-variant: small-caps;
  line-height: 1.2;
}
.kpi-value {
  font-family: "Times New Roman", Times, serif;
  font-size: 22px;
  color: #FFFFFF !important;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin: 2px 0 0;
  font-weight: normal;
}
.kpi.orange .kpi-value,
.kpi.teal   .kpi-value,
.kpi.red    .kpi-value { color: #FFFFFF !important; }
.kpi-sub {
  font-family: "Times New Roman", Times, serif;
  font-size: 10px;
  color: rgba(255,255,255,.7);
  line-height: 1.2;
  margin-top: 1px;
}

/* Latest observation panel */
.latest-panel {
  background: white;
  border: 1px solid #E5E5E5;
  border-radius: 4px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.latest-panel h3 {
  font-size: .72rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 10px 0;
}
.latest-row {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.latest-row--with-sub {
  flex-direction: column;
  align-items: stretch;
}
.latest-row--with-sub > .headlines-cols {
  display: grid;
  grid-template-columns: 30% 20% 20% 30%;
  gap: 0 16px;
  align-items: baseline;
}
.latest-row--with-sub .latest-label { flex: none; white-space: nowrap; }
.latest-row--with-sub .latest-period { flex: none; }
.latest-row--with-sub .latest-value { flex: none; }
.latest-row--with-sub .latest-change { margin-left: 0; text-align: right; }
.latest-row:last-child { border-bottom: none; }
.latest-label { flex: 0 0 140px; font-size: .82rem; font-weight: 600; color: #444; }
.latest-period { flex: 0 0 80px; font-size: .78rem; color: #888; }
.latest-value { flex: 0 0 100px; font-size: .95rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.latest-change { font-size: .78rem; margin-left: 8px; font-variant-numeric: tabular-nums; }
.latest-change.up { color: #005030; }
.latest-change.down { color: #F47321; }
.latest-change.neutral { color: #555; }

/* Period toggle buttons */
.period-toggle {
  display: inline-flex;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #ddd;
}
.period-toggle button {
  padding: 4px 12px;
  font-size: .72rem;
  border: none;
  background: white;
  color: #666;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.period-toggle button.active {
  background: #005030;
  color: white;
}
.period-toggle button:hover:not(.active) {
  background: #f0f0f0;
}

.overview-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: stretch;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
.two-col > * {
  min-width: 0;
}
.full-col { margin-bottom: 24px; }

.card {
  background: white;
  border: 1px solid #E5E5E5;
  border-radius: 4px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.two-col .card canvas {
  flex: 1 1 auto;
  min-height: 0;
}
.card h2 {
  font-size: 1rem;
  color: #005030;
  border-bottom: 1px solid #E5E5E5;
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.card-note {
  font-size: .7rem;
  color: #999;
  margin-top: 8px;
  font-style: italic;
}
.card-note a { color: #2E5F7F; text-decoration: none; }
.card-note a:hover { text-decoration: underline; }

canvas { display: block; }

/* ── Year range controls ─────────────────────────────────── */
.year-controls {
  background: white;
  border: 1px solid #E5E5E5;
  border-radius: 4px;
  padding: 12px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.year-controls label { font-size: .82rem; color: #555; white-space: nowrap; }
.year-controls input[type=range] { flex: 1; accent-color: #005030; }
.year-controls span { font-weight: bold; color: #005030; min-width: 4em; }
.year-controls select {
  font-family: inherit;
  font-size: .82rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 8px;
  color: #2D2D2D;
}

/* ── Drill-down panel ────────────────────────────────────── */
.drilldown-panel {
  background: #FAFAFA;
  border: 1px solid #E5E5E5;
  border-radius: 4px;
  padding: 14px;
  min-height: 260px;
}
.drilldown-panel h3 {
  font-size: .9rem;
  color: #005030;
  margin-bottom: 6px;
}
.drilldown-panel .dd-source {
  font-size: .7rem;
  color: #aaa;
  margin-bottom: 10px;
  font-style: italic;
}
.drilldown-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #bbb;
  font-style: italic;
  font-size: .88rem;
}
.dd-bars { display: flex; flex-direction: column; gap: 6px; }
.dd-bar-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; }
.dd-bar-label { font-size: .78rem; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-bar-amount { font-size: .75rem; color: #666; font-weight: bold; white-space: nowrap; }
.dd-bar-track { height: 10px; background: #ebebeb; border-radius: 3px; margin-top: 2px; }
.dd-bar-fill { height: 10px; border-radius: 3px; }
.dd-bar-detail { font-size: .68rem; color: #aaa; font-style: italic; grid-column: 1 / -1; margin-bottom: 2px; }

/* ── Spending horizontal bars ────────────────────────────── */
.spend-bars { display: flex; flex-direction: column; gap: 8px; }
.spend-bar-item {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.spend-bar-item:hover, .spend-bar-item.selected { background: #f0f8f3; }
.spend-bar-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.spend-bar-name { font-size: .82rem; font-weight: bold; }
.spend-bar-val { font-size: .8rem; color: #666; }
.spend-bar-track { height: 12px; background: #eee; border-radius: 3px; }
.spend-bar-fill { height: 12px; border-radius: 3px; transition: width .4s; }

/* ── Legend ──────────────────────────────────────────────── */
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: .75rem; cursor: pointer; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ── Data tables ──────────────────────────────────────────── */
.it-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.it-table th {
  background: #005030; color: white; padding: 8px 12px;
  text-align: right; font-weight: normal; white-space: nowrap;
}
.it-table th:first-child { text-align: left; }
.it-table td {
  padding: 7px 12px; text-align: right; border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}
.it-table td:first-child { font-weight: bold; text-align: left; }
.it-table tr.row-total td { font-weight: bold; background: #f9f9f7; border-top: 2px solid #005030; color: #333; }
.it-table tr.row-basic  td:first-child { color: #005030; }
.it-table tr.row-higher td:first-child { color: #2E5F7F; }
.it-table tr.row-addl   td:first-child { color: #C0392B; }
.it-table tr.row-basic  td { background: rgba(0,80,48,.03); }
.it-table tr.row-higher td { background: rgba(46,95,127,.03); }
.it-table tr.row-addl   td { background: rgba(192,57,43,.03); }
.it-cell-main  { font-weight: bold; }
.it-cell-sub   { font-size: .7rem; color: #888; }

.back-btn {
  background: transparent;
  border: 1px solid #005030;
  color: #005030;
  font-family: "Times New Roman", Times, serif;
  font-size: .85rem;
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s;
}
.back-btn:hover { background: rgba(0,80,48,.06); }

/* ── Footer (hidden by default — content moved to modal) ── */
footer {
  display: none;
}

/* ── Data sources modal ───────────────────────────────────── */
.sources-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.sources-modal-overlay.visible {
  display: flex;
}
.sources-modal {
  background: white;
  border-radius: 6px;
  padding: 28px 32px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  font-size: .78rem;
  color: #555;
  line-height: 1.7;
}
.sources-modal h3 {
  font-size: 1rem;
  color: #005030;
  margin-bottom: 12px;
  border-bottom: 1px solid #E5E5E5;
  padding-bottom: 8px;
}
.sources-modal a { color: #2E5F7F; text-decoration: none; }
.sources-modal a:hover { text-decoration: underline; }
.sources-modal p { margin-bottom: 8px; }
.sources-modal .close-btn {
  float: right;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
}
.sources-modal .close-btn:hover { color: #333; }

/* ── Rates History sections ─────────────────────────────── */
.rates-history-section {
  margin-top: 20px;
  margin-bottom: 20px;
}
.rates-history-section .section-heading {
  font-family: "Times New Roman", Times, serif;
  font-size: 1.08rem;
  color: #005030;
  font-weight: normal;
  margin: 0 0 16px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid #E5E5E5;
}
.rh-summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.rh-stat-card {
  background: white;
  border: 1px solid #E5E5E5;
  border-radius: 4px;
  padding: 14px 18px;
  border-left: 4px solid #005030;
}
.rh-stat-card .rh-stat-label {
  font-size: .72rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.rh-stat-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.rh-stat-old {
  font-size: 1.1rem;
  color: #aaa;
  text-decoration: line-through;
  font-weight: bold;
}
.rh-stat-arrow {
  font-size: .85rem;
  color: #bbb;
}
.rh-stat-new {
  font-size: 1.45rem;
  font-weight: bold;
  color: #005030;
}
.rh-stat-sub {
  font-size: .72rem;
  color: #999;
  margin-top: 2px;
  font-style: italic;
}
.rh-chart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.rh-chart-tab {
  background: #f0f0f0;
  border: 1px solid #ddd;
  font-family: "Times New Roman", Times, serif;
  font-size: .78rem;
  padding: 4px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  color: #666;
}
.rh-chart-tab:hover { background: #e8e8e8; }
.rh-chart-tab.active {
  background: #005030;
  color: white;
  border-color: #005030;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .two-col { grid-template-columns: 1fr; }
  .overview-top-grid { grid-template-columns: 1fr; }
  .overview-top-grid > .card { grid-row: auto; }
  .page-title-strip { height: auto; min-height: 80px; flex-wrap: wrap; padding: 12px 24px; gap: 8px; }
  .kpi-row { flex-wrap: wrap; margin-left: 0; }
  .kpi { min-width: 100px; }
}
@media (max-width: 700px) {
  .sidebar { display: none; }
  .kpi-row { display: none; }
}
