* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: #333;
  background: #fff;
  line-height: 1.5;
}

/* --- sidebar --- */

#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 220px;
  height: 100vh;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  padding: 1.2rem 0;
  z-index: 10;
}

.sidebar-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #111;
  padding: 0 1rem 1rem;
}

.nav-section {
  margin-bottom: 0.2rem;
}

.nav-header {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.nav-header:hover { color: #111; }
.nav-header .chevron {
  font-size: 0.7rem;
  transition: transform 0.2s;
}
.nav-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.nav-group {
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.nav-group.collapsed {
  max-height: 0 !important;
}

.nav-link {
  display: block;
  padding: 0.35rem 1rem 0.35rem 1.5rem;
  font-size: 0.82rem;
  color: #555;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.nav-link:hover {
  color: #111;
  background: #f0f0f0;
}
.nav-link.active {
  color: #111;
  font-weight: 600;
  border-left-color: #F7931A;
  background: #fff5eb;
}
.nav-link.nav-top {
  padding-left: 1rem;
  font-weight: 500;
}

/* --- main content --- */

#content {
  margin-left: 220px;
  padding: 2rem 2.5rem;
  max-width: 960px;
}

.breadcrumb {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.3rem;
}
.breadcrumb a {
  color: #F7931A;
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 0.3rem;
}

.page-subtitle {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.chart-container {
  width: 100%;
  margin-bottom: 1.5rem;
  position: relative;
}
.chart-container svg {
  width: 100%;
  height: auto;
}

.chart-tooltip {
  position: absolute;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 20;
  min-width: 120px;
}
.tip-date {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 0.25rem;
}
.tip-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: #555;
  line-height: 1.6;
}
.tip-swatch {
  width: 10px;
  height: 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: #555;
}
.chart-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.chart-legend .swatch {
  width: 14px;
  height: 3px;
  border-radius: 1px;
}

.page-description {
  font-size: 0.92rem;
  color: #555;
  line-height: 1.7;
  max-width: 680px;
  margin-top: 1.5rem;
}
.page-description p { margin-bottom: 1rem; }
.page-description h3 {
  font-size: 1.05rem;
  color: #111;
  margin: 1.8rem 0 0.5rem;
}
.page-description h3:first-child { margin-top: 0; }
.page-description h4 {
  font-size: 0.95rem;
  color: #333;
  margin: 1.2rem 0 0.3rem;
}
.page-description code {
  background: #f4f4f4;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.page-description a {
  color: #F7931A;
  text-decoration: none;
}
.page-description a:hover { text-decoration: underline; }
.page-description ul {
  margin: 0.5rem 0 1rem 1.5rem;
  list-style: disc;
}
.page-description li { margin-bottom: 0.3rem; }

.attribution {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e8e8e8;
  font-size: 0.85rem;
  color: #888;
}
.attribution a { color: #F7931A; }
.attribution a:hover { text-decoration: underline; }

.empty-state {
  padding: 3rem;
  text-align: center;
  color: #999;
  font-size: 0.95rem;
}

/* --- hardcoded detail --- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 0.8rem;
  text-align: center;
}
.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111;
}
.stat-card .label {
  font-size: 0.78rem;
  color: #888;
  margin-top: 0.2rem;
}
.stat-card.orange .value { color: #F7931A; }
.stat-card.green .value { color: #2e7d32; }
.stat-card.red .value { color: #c62828; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 1rem;
}
table.data-table th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid #e0e0e0;
  color: #888;
  font-weight: 600;
  cursor: pointer;
}
table.data-table th:hover { color: #333; }
table.data-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #f0f0f0;
}
table.data-table tr:hover { background: #fafafa; }

.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag.up { background: #e8f5e9; color: #2e7d32; }
.tag.down { background: #ffebee; color: #c62828; }

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}
.filter-btn {
  background: #f0f0f0;
  border: 1px solid #ddd;
  color: #555;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.filter-btn.active {
  background: #fff5eb;
  border-color: #F7931A;
  color: #F7931A;
  font-weight: 600;
}
.filter-btn.reset-btn {
  margin-left: auto;
  background: #fff5eb;
  border-color: #F7931A;
  color: #F7931A;
}

.brush .selection {
  fill: #F7931A;
  fill-opacity: 0.15;
  stroke: #F7931A;
  stroke-width: 1;
}
.brush .handle {
  fill: #F7931A;
  fill-opacity: 0.4;
}

.table-wrap {
  max-height: 450px;
  overflow-y: auto;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
}

/* --- hamburger button --- */

#menu-toggle {
  display: none;
  position: fixed;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 30;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 1.3rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  color: #333;
}

#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 9;
}

/* --- mobile --- */

@media (max-width: 768px) {
  #menu-toggle { display: block; }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }
  #sidebar.open {
    transform: translateX(0);
  }

  #overlay.open { display: block; }

  #content {
    margin-left: 0;
    padding: 3rem 1rem 1.5rem;
    max-width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .filter-bar {
    flex-wrap: wrap;
  }

  .chart-legend {
    gap: 0.5rem;
  }

  .page-title {
    font-size: 1.2rem;
  }
}
