    html, body {
      height: 100%;
    }

    body {
      background: #0f0f0f;
      margin: 0;
      overflow: hidden; /* page scroll handled inside panels */
    }

    /* ==============================
       STICKY HEADER
    ============================== */
    #statsHeader {
      position: sticky;
      top: 0;
      z-index: 100;
      height: 56px;
      padding: 0 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: linear-gradient(
        to bottom,
        rgba(15, 15, 15, 0.95),
        rgba(15, 15, 15, 0.85)
      );
      backdrop-filter: blur(6px);
      border-bottom: 1px solid #222;
    }

    .back-link {
      color: #ccc;
      text-decoration: none;
      font-size: 14px;
    }
    .back-link:hover { color: #fff; }

    .stats-header-title {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      font-size: 13px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: #aaa;
      pointer-events: none;
    }

    /* ==============================
       GRID LAYOUT
    ============================== */
    #statsPage {
      max-width: 1800px;
      margin: 0 auto;
      padding: 24px;
      height: calc(100vh - 56px); /* full viewport minus header */
      box-sizing: border-box;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 1fr 1fr;
      gap: 24px;
      height: 100%;
    }
    
    .stats-panel {
      background: rgba(255, 255, 255, 0.04);
      border-radius: 16px;
      padding: 16px 18px;
      display: flex;
      flex-direction: column;
      min-height: 0;      /* 🔑 needed so children can scroll */
      overflow: hidden;   /* prevents chart bleed */
    }


    /* Right-hand panel spans both rows 
    .stats-panel--right {
      grid-column: 2;
      grid-row: 1 / span 2;
      display: flex;
      flex-direction: column;
      min-height: 0; 
      overflow-y: auto;
    }
    */

    .stats-panel--right {
      grid-column: 2;
      grid-row: 1 / span 2;
      display: flex;
      flex-direction: column;
      min-height: 0;          /* 🔑 allows children to scroll */
    }

    /* Fixed header */
    .stats-panel--right .panel-head {
      flex: 0 0 auto;
    }

    .stats-panel h2,
    .stats-panel h3 {
      margin: 0 0 12px;
      font-size: 18px;
      font-weight: 600;
      color: #fff;
    }

    .panel-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      flex: 0 0 auto;
    }

    .stats-select {
      background: #1a1a1a;
      color: #fff;
      border: 1px solid #333;
      border-radius: 10px;
      padding: 8px 12px;
      font-size: 13px;
      outline: none;
    }

    /* Chart fill wrapper so axis labels don't get clipped */
    .chart-fill {
      flex: 1;
      min-height: 0;
      position: relative;
      padding-bottom: 10px; /* ✅ room for x-axis labels */
    }

    .chart-fill canvas {
      width: 100% !important;
      height: 100% !important;
      display: block;
    }

    /* Scroll container */
    .airline-scroll {
      flex: 1 1 auto;
      min-height: 0;          /* 🔑 REQUIRED */
      overflow-y: auto;
      padding-right: 12px;
    }

    /* Nice scrollbar (optional) */
    .airline-scroll::-webkit-scrollbar {
      width: 10px;
    }
    .airline-scroll::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.18);
      border-radius: 6px;
    }
    .airline-scroll::-webkit-scrollbar-thumb:hover {
      background: rgba(255,255,255,0.25);
    }
    
    .airline-chart-scroll {
      height: 100%;
      overflow-y: auto;
      min-height: 0;
    }

    .airline-chart-scroll::-webkit-scrollbar {
      width: 10px;
    }
    
    .airline-chart-scroll::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.18);
      border-radius: 6px;
    }
    
    .airline-chart-scroll::-webkit-scrollbar-thumb:hover {
      background: rgba(255,255,255,0.25);
    }

    /* This canvas MUST be allowed to be taller than viewport */
    #airlineYearChart {
      width: 100% !important;
      display: block;
    }

    /* Placeholder panel */
    .stats-placeholder {
      color: #777;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px dashed #333;
      border-radius: 12px;
      height: 100%;
    }

    /* IMPORTANT: prevent canvas being stretched (causes fuzzy/distorted text) */
    .airline-chart-scroll canvas {
      height: auto !important;
    }

    /* Chart must be allowed to be tall */
    #flightsPerAirlineYearChart {
      display: block;
      width: 100% !important;
    }
