/* ============================================
   CSH DESIGN SYSTEM - Brand Colors & Variables
   ============================================ */
   :root {
    --color-navy-dark: #073050;
    --color-blue: #005393;
    --color-orange: #EF8B22;
    --color-gray-light: #F5F5F5;
    --color-white: #ffffff;
    --color-text-dark: #073050;
    --color-text-gray: #666666;
    --color-border: #dddddd;
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  html,
  body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: "Montserrat", sans-serif;
    font-optical-sizing: auto;
    color: var(--color-text-dark);
  }
  
  /* ============================================
     TYPOGRAPHY - Montserrat Heading Styles
     ============================================ */
  h1, .h1 {
    font-family: "Montserrat", sans-serif;
    font-size: 42px;
    font-weight: 700;
    line-height: 52px;
    color: var(--color-navy-dark);
  }
  
  h2, .h2 {
    font-family: "Montserrat", sans-serif;
    font-size: 42px;
    font-weight: 700;
    line-height: 52px;
    color: var(--color-navy-dark);
  }
  
  h3, .h3 {
    font-family: "Montserrat", sans-serif;
    font-size: 28px;
    font-weight: 900;
    line-height: 50px;
    color: var(--color-navy-dark);
  }
  
  h4, .h4 {
    font-family: "Montserrat", sans-serif;
    font-size: 22px;
    font-weight: 900;
    line-height: 30px;
    color: var(--color-navy-dark);
  }
  
  h5, .h5 {
    font-family: "Montserrat", sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    color: var(--color-navy-dark);
  }
  
  h6, .h6 {
    font-family: "Montserrat", sans-serif;
    font-size: 18px;
    font-weight: 900;
    line-height: 25px;
    color: var(--color-navy-dark);
  }
  
  /* Responsive typography for smaller screens */
  @media (max-width: 1008px) {
    h1, .h1 {
      font-size: 30px;
      line-height: 40px;
    }
    
    h2, .h2 {
      font-size: 30px;
      line-height: 40px;
    }
    
    h3, .h3 {
      font-size: 22px;
      line-height: 30px;
    }
    
    h4, .h4 {
      font-size: 18px;
      line-height: 24px;
    }
    
    h5, .h5 {
      font-size: 16px;
      line-height: 24px;
    }
  }
  
  /* ============================================
     BUTTON STYLES - Based on Design System
     ============================================ */
  
  /* Primary Button - Blue filled, white text */
  .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 30px;
    background-color: var(--color-blue);
    color: var(--color-white);
    border: 2px solid var(--color-blue);
    border-radius: 50px;
    font-family: "Montserrat", sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
  }
  
  .btn-primary:hover {
    background-color: #0066b3;
    border-color: #0066b3;
  }
  
  /* Secondary Button - White/light with dark border */
  .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 30px;
    background-color: var(--color-white);
    color: var(--color-navy-dark);
    border: 2px solid var(--color-border);
    border-radius: 50px;
    font-family: "Montserrat", sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
  }
  
  .btn-secondary:hover {
    background-color: #e8e8e8;
    border-color: #999999;
  }
  
  /* Tertiary Button - Blue outline */
  .btn-tertiary-blue {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 30px;
    background-color: transparent;
    color: var(--color-blue);
    border: 2px solid var(--color-blue);
    border-radius: 50px;
    font-family: "Montserrat", sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
  }
  
  .btn-tertiary-blue:hover {
    background-color: var(--color-blue);
    color: var(--color-white);
  }
  
  /* Tertiary Button - Orange outline */
  .btn-tertiary-orange {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 30px;
    background-color: transparent;
    color: var(--color-orange);
    border: 2px solid var(--color-orange);
    border-radius: 50px;
    font-family: "Montserrat", sans-serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
  }
  
  .btn-tertiary-orange:hover {
    background-color: var(--color-orange);
    color: var(--color-white);
  }
  
  /* Link Styles */
  a.link {
    color: var(--color-blue);
    text-decoration: none;
    transition: text-decoration 0.2s ease;
  }
  
  a.link:hover {
    text-decoration: underline;
  }
  
  /* Header Section */
  #header {
    background: var(--color-white);
    padding: 5px 12px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  
  .logo {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .logo img {
    height: 35px;
    width: auto;
  }
  
  .header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-navy-dark);
    margin: 0;
  }
  
   .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .nav-links {
    display: flex;
    gap: 8px;
  }
  
  .nav-link {
    color: var(--color-blue);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 50px;
    border: 2px solid transparent;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  }
  
  .nav-link:hover {
    background-color: var(--color-gray-light);
    border-color: var(--color-border);
  }
  
  .nav-link.active {
    background-color: var(--color-blue);
    color: var(--color-white);
    font-weight: 700;
    border-color: var(--color-blue);
  }
  
  .nav-link.active:hover {
    background-color: #0066b3;
    border-color: #0066b3;
  }
  
  /* Export button in header */
  #export-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 50px;
    border: 2px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-navy-dark);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
  }
  
  #export-button:hover {
    background: var(--color-gray-light);
    border-color: #999999;
  }
  
  .export-icon {
    font-size: 13px;
    line-height: 1;
  }
  
  .export-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  
  /* Map Container - Full screen except header */
  #map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 48px);
  }
  
  #viewDiv {
    width: 100%;
    height: 100%;
  }
  
  /* Affordability Map Container */
  #affordability-map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 48px);
  }
  
  #affordabilityViewDiv {
    width: 100%;
    height: 100%;
  }
  
  /* Affordability histogram - Desktop: floating, Mobile: flows below */
  #affordability-histogram-panel {
    position: absolute;
    bottom: 35px;
    right: 15px;
    width: 50%;
    height: 200px;
    z-index: 10;
  }
  
  /* PIT/HIC Map Container */
  #pit-hic-map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 48px);
  }
  
  #pitHicViewDiv {
    width: 100%;
    height: 100%;
  }
  
  /* PIT/HIC charts - Desktop: floating, Mobile: flows below */
  #pit-hic-charts-section {
    position: absolute;
    bottom: 35px;
    left: 15px;
    right: 15px;
    height: 200px;
    display: flex;
    gap: 10px;
    z-index: 10;
  }
  
  #pit-hic-charts-section .chart-panel {
    flex: 1;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0px 10px 5px 10px;
    position: relative;
  }
  
  /* Tabs Section - Floating on map */
  #tabs {
    position: absolute;
    top: 15px;
    left: 60px;
    /* transform: translateX(-50%); */
    background: var(--color-white);
    padding: 4px;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 4px;
    z-index: 50;
  }
  
  .tab {
    padding: 8px 16px;
    background: var(--color-gray-light);
    border: 2px solid transparent;
    cursor: pointer;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-gray);
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  }
  
  .tab.active {
    background: var(--color-blue);
    color: var(--color-white);
    font-weight: 700;
    border-color: var(--color-blue);
  }
  
  .tab:hover {
    background: #e0e0e0;
  }
  
  .tab.active:hover {
    background: #0066b3;
    border-color: #0066b3;
  }
  
  /* Filter Panel - Floating on right */
  #filter-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 180px;
    max-height: calc(100vh - 360px);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 10px;
    overflow-y: auto;
    z-index: 50;
  }
  
  .filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 12px;
    color: var(--color-navy-dark);
  }
  
  .search-icon {
    width: 16px;
    height: 16px;
    cursor: pointer;
  }
  
  .filter-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
  }
  
  .filter-item input[type="checkbox"] {
    margin-right: 6px;
    width: 11px;
    height: 11px;
    cursor: pointer;
    accent-color: var(--color-blue);
  }
  
  .filter-item label {
    cursor: pointer;
    font-size: 11px;
    color: var(--color-navy-dark);
    line-height: 1.3;
  }
  
  /* Charts Section - Floating at bottom */
  #charts-section {
    position: absolute;
    bottom: 35px;
    left: 15px;
    right: 15px;
    height: 200px;
    display: flex;
    gap: 10px;
    z-index: 10;
  }
  
  .chart-panel {
    flex: 1;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0px 10px 5px 10px;
    position: relative;
  }
  
  .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    margin-top: 5px;
  }
  
  .chart-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-navy-dark);
  }
  
  .chart-options {
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.5;
  }
  
  .chart-content {
    height: calc(100% - 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-gray);
    font-size: 12px;
  }
  
  .pie-chart-panel .chart-content {
    height: calc(100% - 30px);
    overflow: visible;
  }
  
  /* Ensure canvases have proper dimensions */
  #pieChartCanvas,
  #histogramCanvas,
  #costHistogramCanvas,
  #pitHicHistogramCanvas,
  #pitHicHistogram2Canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
  }
  
  /* Ensure map popup appears above all floating widgets */
  .esri-view .esri-ui {
    z-index: 100 !important;
  }
  
  .esri-popup,
  .esri-popup__main-container {
    z-index: 100 !important;
  }
  
  /* Tab Content Containers */
  .tab-content {
    display: none;
    width: 100%;
    height: calc(100vh - 48px);
  }
  
  .tab-content.active {
    display: block;
  }
  
  /* Blank Page Style */
  .blank-page {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-gray-light);
  }
  
  .blank-page p {
    color: var(--color-text-gray);
    font-size: 16px;
    font-style: italic;
  }
  
  /* Export modal */
  .export-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 48, 80, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1010;
  }
  
  .export-modal-overlay.visible {
    display: flex;
  }
  
  .export-modal {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 520px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 18px 22px 20px 22px;
  }
  
  .export-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
  }
  
  .export-modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-navy-dark);
  }
  
  .export-modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-text-gray);
    transition: color 0.2s ease;
  }
  
  .export-modal-close:hover {
    color: var(--color-navy-dark);
  }
  
  .export-modal-body {
    overflow-y: auto;
    padding-right: 4px;
  }
  
  .export-field-group {
    margin-bottom: 14px;
  }
  
  .export-field-group .export-label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-navy-dark);
    margin-bottom: 8px;
  }
  
  .export-radio-group {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--color-navy-dark);
  }
  
  .export-radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }
  
  .export-radio-group input[type="radio"] {
    accent-color: var(--color-blue);
  }
  
  .export-checkbox-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--color-navy-dark);
  }
  
  .export-checkbox-column label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
  }
  
  .export-checkbox-column input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--color-blue);
  }
  
  .export-help-text {
    font-size: 12px;
    color: var(--color-text-gray);
    line-height: 1.4;
  }
  
  .export-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
  }
  
  .export-primary-button,
  .export-secondary-button {
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
  }
  
  .export-primary-button {
    border: 2px solid var(--color-blue);
    background: var(--color-blue);
    color: var(--color-white);
  }
  
  .export-primary-button:hover {
    background: #0066b3;
    border-color: #0066b3;
  }
  
  .export-secondary-button {
    border: 2px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-navy-dark);
  }
  
  .export-secondary-button:hover {
    background: var(--color-gray-light);
    border-color: #999999;
  }
  
  .export-hidden {
    display: none;
  }
  
  /* Export modal tabs */
  .export-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-radius: 50px;
    background: var(--color-gray-light);
    padding: 4px;
  }
  
  .export-tab {
    flex: 1;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--color-text-gray);
    font-family: "Montserrat", sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 50px;
    transition: background-color 0.3s ease, color 0.3s ease;
  }
  
  .export-tab:hover {
    color: var(--color-navy-dark);
  }
  
  .export-tab.active {
    background: var(--color-blue);
    color: var(--color-white);
  }
  
  .export-tab.active:hover {
    background: #0066b3;
  }
  
  /* Hide color box tab in legend, only show range/size tab */
  .esri-legend__service-label[title*="Color"],
  .esri-legend__layer-caption[title*="Color"],
  .esri-legend__layer-table--color-ramp,
  .esri-legend__layer-body--color-ramp {
    display: none !important;
  }
  
  /* Hide color symbols/polygons in legend, only show gradient/text */
  .esri-legend__symbol {
    display: none !important;
  }
  
  /* Hide legend title/layer name */
  .esri-legend__layer-caption,
  .esri-legend__service-label {
    display: none !important;
  }
  
  /* Reduce legend card width */
  .esri-legend {
    max-width: 200px !important;
    width: auto !important;
  }
  
  .esri-legend__service {
    padding: 0px 8px 8px 8px !important;
    margin-top: 0px !important;
  }
  
  .esri-legend__layer-body {
    padding: 4px !important;
  }
  
  /* Reduce gap between custom title and gradient */
  .esri-legend section:first-child {
    margin-top: -8px !important;
  }
  
  /* Add custom title above legend gradient for Needs Assessment tab */
  /* Layer 2: Supportive Housing Needs */
  #viewDiv .esri-legend[data-active-layer="2"]::before {
    content: "PSH Units Needed";
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-navy-dark);
    padding: 8px 8px 2px 8px;
    text-align: center;
  }
  
  /* Layer 4: Supportive Housing Needs per Capita */
  #viewDiv .esri-legend[data-active-layer="4"]::before {
    content: "PSH Units Needed per Capita";
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-navy-dark);
    padding: 8px 8px 2px 8px;
    text-align: center;
  }
  
  /* Layer 5: Financial Model and Affordability */
  #viewDiv .esri-legend[data-active-layer="5"]::before {
    content: "10-Year Costs";
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-navy-dark);
    padding: 8px 8px 2px 8px;
    text-align: center;
  }
  
  /* Affordability tab legend title */
  #affordabilityViewDiv .esri-legend::before {
    content: "% of All Renters that are ELI and SCB";
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-navy-dark);
    padding: 8px 8px 2px 8px;
    text-align: center;
  }
  
  /* PIT/HIC tab legend title */
  #pitHicViewDiv .esri-legend::before {
    content: "Overall Chronically Homeless";
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--color-navy-dark);
    padding: 8px 8px 2px 8px;
    text-align: center;
  }
  
  /* ============================================
     MOBILE RESPONSIVE STYLES
     ============================================ */
  
  /* Tablet and smaller devices */
  @media (max-width: 1024px) {
    /* Reduce chart height on tablets */
    #charts-section,
    #pit-hic-charts-section {
      height: 180px;
    }
    
    /* Adjust filter panel */
    #filter-panel {
      width: 160px;
      max-height: calc(100vh - 320px);
    }
    
    /* Make legend more compact */
    .esri-legend {
      max-width: 180px !important;
    }
  }
  
  /* Mobile devices (landscape tablets and smaller) */
  @media (max-width: 768px) {
    /* Enable page scroll instead of fixed positioning */
    body {
      overflow: auto !important;
    }
    
    /* Header adjustments - Sticky at top */
    #header {
      padding: 8px 10px;
      gap: 8px;
      position: sticky;
      top: 0;
      z-index: 100;
      background: var(--color-white);
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .header-title {
      font-size: 14px;
    }
    
    .logo img {
      height: 28px;
    }
    
    .header-right {
      width: 100%;
      justify-content: space-between;
      margin-top: 6px;
    }
    
    .nav-links {
      gap: 8px;
      flex-wrap: wrap;
    }
    
    .nav-link {
      font-size: 11px;
      padding: 6px 10px;
    }
    
    #export-button {
      font-size: 10px;
      padding: 6px 10px;
      height: 32px;
    }
    
    /* Map container - Fixed height instead of viewport height */
    #map-container,
    #affordability-map-container,
    #pit-hic-map-container {
      position: relative;
      height: 60vh;
      min-height: 400px;
      border-bottom: 1px solid #e0e0e0;
    }
    
    .tab-content {
      height: auto !important;
    }
    
    /* Tabs - Position relative in flow */
    #tabs {
      position: relative;
      left: 0;
      top: 0;
      margin: 10px 10px 0 10px;
      max-width: calc(100vw - 20px);
      overflow-x: auto;
      overflow-y: hidden;
      flex-wrap: nowrap;
      padding: 4px;
      gap: 4px;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
    }
    
    /* Hide scrollbar for Chrome, Safari and Opera */
    #tabs::-webkit-scrollbar {
      height: 3px;
    }
    
    #tabs::-webkit-scrollbar-track {
      background: transparent;
    }
    
    #tabs::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.2);
      border-radius: 2px;
    }
    
    .tab {
      padding: 5px 8px;
      font-size: 10px;
      white-space: nowrap;
      flex-shrink: 0;
    }
    
    /* Use shorter tab text on mobile */
    .tab[data-layer="2"] {
      max-width: none;
    }
    
    .tab[data-layer="4"] {
      max-width: none;
    }
    
    .tab[data-layer="5"] {
      max-width: none;
    }
    
    /* Filter panel - Absolute within map container */
    #filter-panel {
      width: 140px;
      right: 10px;
      top: 10px;
      max-height: 300px;
      padding: 8px;
      position: absolute;
    }
    
    .filter-item label {
      font-size: 10px;
    }
    
    /* Charts section - Position relative in flow, no scrolling */
    #charts-section {
      position: relative;
      bottom: auto;
      left: 0;
      right: 0;
      flex-direction: column;
      height: auto;
      max-height: none;
      margin: 10px;
      gap: 8px;
      padding: 12px 8px;
      background: var(--color-white);
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
      overflow-y: visible;
      border-top: 2px solid var(--color-gray-light);
    }
    
    .chart-panel {
      flex: none;
      min-height: 200px;
      height: auto;
      padding: 8px;
      margin-bottom: 8px;
    }
    
    .chart-panel:last-child {
      margin-bottom: 0;
    }
    
    .pie-chart-panel {
      min-height: 300px;
      height: auto;
    }
    
    .chart-title {
      font-size: 11px;
      line-height: 1.2;
      font-weight: 600;
    }
    
    .chart-header {
      margin-bottom: 4px;
      padding-top: 2px;
    }
    
    .chart-header label {
      font-size: 10px;
    }
    
    .chart-content {
      min-height: 150px;
      height: auto;
    }
    
    .pie-chart-panel .chart-content {
      min-height: 220px;
      height: auto;
    }
    
    /* Make pie chart legend more compact on mobile - use smaller font */
    #pieChartCanvas {
      max-height: none !important;
    }
    
    /* Affordability histogram - Position relative in flow */
    #affordability-histogram-panel {
      position: relative !important;
      width: calc(100% - 20px) !important;
      right: auto !important;
      bottom: auto !important;
      height: auto !important;
      min-height: 200px;
      margin: 10px;
      padding: 12px 8px;
      background: var(--color-white);
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
      border-top: 2px solid var(--color-gray-light);
    }
    
    /* PIT/HIC charts section - Position relative in flow */
    #pit-hic-charts-section {
      position: relative;
      bottom: auto;
      left: 0;
      right: 0;
      flex-direction: column;
      height: auto;
      max-height: none;
      margin: 10px;
      gap: 8px;
      padding: 12px 8px;
      background: var(--color-white);
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
      overflow-y: visible;
      border-top: 2px solid var(--color-gray-light);
    }
    
    #pit-hic-charts-section .chart-panel {
      flex: none;
      min-height: 200px;
      margin-bottom: 8px;
    }
    
    #pit-hic-charts-section .chart-panel:last-child {
      margin-bottom: 0;
    }
    
    #pitHicHistogramToggle {
      font-size: 10px;
      padding: 2px 6px;
    }
    
    /* Legend adjustments */
    .esri-legend {
      max-width: 150px !important;
      font-size: 11px !important;
    }
    
    .esri-legend::before {
      font-size: 11px !important;
      padding: 6px 6px 2px 6px !important;
    }
    
    /* Export modal */
    .export-modal {
      width: 90vw;
      max-height: 85vh;
      padding: 12px 14px;
    }
    
    .export-modal-header h2 {
      font-size: 14px;
    }
    
    .export-label,
    .export-radio-group,
    .export-checkbox-column {
      font-size: 11px;
    }
  }
  
  /* Small mobile devices */
  @media (max-width: 480px) {
    /* Header - More compact */
    #header {
      padding: 6px 8px;
    }
    
    .header-title {
      font-size: 12px;
    }
    
    .logo {
      gap: 8px;
    }
    
    .logo img {
      height: 24px;
    }
    
    .nav-links {
      gap: 6px;
    }
    
    .nav-link {
      font-size: 10px;
      padding: 5px 8px;
    }
    
    #export-button {
      font-size: 9px;
      padding: 5px 8px;
      height: 28px;
      min-width: 28px;
    }
    
    .export-label {
      display: none !important;
    }
    
    .export-icon {
      font-size: 16px;
      margin: 0 !important;
    }
    
    /* Map container adjustments for very small screens */
    #map-container,
    #affordability-map-container,
    #pit-hic-map-container {
      height: 55vh;
      min-height: 350px;
    }
    
    /* Tabs - Very compact */
    #tabs {
      margin: 8px 8px 0 8px;
      max-width: calc(100vw - 16px);
      padding: 3px;
      gap: 3px;
    }
    
    .tab {
      padding: 5px 8px;
      font-size: 10px;
    }
    
    /* Filter panel - More compact */
    #filter-panel {
      width: 120px;
      right: 5px;
      top: 5px;
      max-height: 250px;
      padding: 6px;
      font-size: 9px;
    }
    
    .filter-item input[type="checkbox"] {
      width: 10px;
      height: 10px;
    }
    
    .filter-item label {
      font-size: 9px;
    }
    
    /* Charts - More compact stacking */
    #charts-section,
    #pit-hic-charts-section {
      margin: 8px;
      padding: 6px;
      gap: 6px;
    }
    
    .chart-panel {
      min-height: 180px;
      padding: 6px;
      margin-bottom: 6px;
    }
    
    .chart-panel:last-child {
      margin-bottom: 0;
    }
    
    .pie-chart-panel {
      min-height: 260px;
    }
    
    .chart-title {
      font-size: 11px;
    }
    
    .chart-header label,
    .chart-header span {
      font-size: 9px;
    }
    
    .chart-content {
      min-height: 130px;
      font-size: 10px;
    }
    
    .pie-chart-panel .chart-content {
      min-height: 160px;
    }
    
    /* Affordability histogram */
    #affordability-histogram-panel {
      margin: 8px !important;
      min-height: 180px;
    }
    
    #pitHicHistogramToggle {
      font-size: 9px;
      padding: 2px 4px;
    }
    
    /* Legend - More compact */
    .esri-legend {
      max-width: 130px !important;
      font-size: 10px !important;
    }
    
    .esri-legend::before {
      font-size: 10px !important;
      padding: 5px 4px 2px 4px !important;
    }
    
    .esri-legend__service {
      padding: 0px 6px 6px 6px !important;
    }
    
    .esri-legend__layer-body {
      padding: 3px !important;
    }
    
    /* Additional spacing for very small screens */
    body {
      padding-bottom: 20px;
    }
    
    /* Export modal - Full width on small screens */
    .export-modal {
      width: 95vw;
      padding: 10px 12px;
    }
    
    .export-modal-header h2 {
      font-size: 13px;
    }
    
    .export-label,
    .export-radio-group,
    .export-checkbox-column,
    .export-help-text {
      font-size: 10px;
    }
    
    .export-primary-button,
    .export-secondary-button {
      font-size: 11px;
      padding: 5px 10px;
    }
  }
  
  /* Landscape orientation adjustments for mobile */
  @media (max-width: 768px) and (orientation: landscape) {
    #map-container,
    #affordability-map-container,
    #pit-hic-map-container {
      height: 70vh;
      min-height: 300px;
    }
    
    .chart-panel {
      min-height: 160px;
    }
    
    .pie-chart-panel {
      min-height: 250px;
    }
    
    #filter-panel {
      max-height: 250px;
    }
    
    .esri-legend {
      max-height: 250px !important;
    }
  }
  
  /* Fix for Chart.js canvas responsiveness */
  @media (max-width: 768px) {
    #pieChartCanvas,
    #histogramCanvas,
    #costHistogramCanvas,
    #affordabilityHistogramCanvas,
    #pitHicHistogramCanvas,
    #pitHicHistogram2Canvas {
      max-width: 100% !important;
      height: auto !important;
    }
    
    /* ArcGIS UI components positioning for mobile */
    .esri-ui-top-left {
      top: 10px !important;
      left: 5px !important;
    }
    
    .esri-ui-top-right {
      top: 5px !important;
      right: 5px !important;
    }
    
    .esri-ui-bottom-right {
      bottom: auto !important;
      top: 10px !important;
      right: 5px !important;
      max-height: 300px !important;
      overflow-y: auto !important;
    }
    
    .esri-ui-bottom-left {
      bottom: 10px !important;
      top: auto !important;
      left: 5px !important;
    }
    
    /* Make legend position better on mobile */
    .esri-legend.esri-widget {
      max-height: 300px !important;
      overflow-y: auto !important;
      font-size: 10px !important;
    }
    
    /* Reduce legend item spacing */
    .esri-legend__layer-row {
      padding: 2px 0 !important;
    }
    
    .esri-legend__ramp-label {
      font-size: 9px !important;
    }
    
    /* Ensure zoom controls don't overlap */
    .esri-zoom {
      margin-top: 5px !important;
    }
    
    /* Make basemap toggle smaller */
    .esri-basemap-toggle {
      width: 50px !important;
      height: 50px !important;
    }
  }
  
  @media (max-width: 480px) {
    /* Even more compact ArcGIS widgets */
    .esri-legend {
      max-width: 120px !important;
      max-height: 250px !important;
    }
    
    .esri-ui-top-left {
      top: 10px !important;
    }
    
    .esri-ui-bottom-right {
      top: 10px !important;
      max-height: 250px !important;
    }
    
    .esri-basemap-toggle {
      width: 45px !important;
      height: 45px !important;
    }
    
    /* Compact zoom controls */
    .esri-zoom .esri-widget--button {
      width: 28px !important;
      height: 28px !important;
      font-size: 14px !important;
    }
  }
  
  /* Enable smooth page scrolling on mobile */
  @media (max-width: 768px) {
    html {
      scroll-behavior: smooth;
      -webkit-overflow-scrolling: touch;
    }
    
    body {
      min-height: 100vh;
      overflow-x: hidden;
      overflow-y: auto;
    }
    
    #viewDiv,
    #affordabilityViewDiv,
    #pitHicViewDiv {
      touch-action: pan-x pan-y;
      position: relative;
      width: 100%;
      height: 100%;
    }
    
    /* Ensure chart canvas containers have proper overflow handling */
    .chart-content canvas {
      display: block !important;
      box-sizing: border-box !important;
    }
    
    /* Improve scroll indicator */
    ::-webkit-scrollbar {
      width: 4px;
    }
    
    ::-webkit-scrollbar-track {
      background: transparent;
    }
    
    ::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.3);
      border-radius: 2px;
    }
  }
  
  /* Additional improvements for very small screens */
  @media (max-width: 360px) {
    .header-title {
      font-size: 11px;
    }
    
    .logo img {
      height: 20px;
    }
    
    .nav-link {
      font-size: 9px;
      padding: 4px 6px;
    }
    
    #tabs {
      padding: 2px;
      gap: 2px;
    }
    
    .tab {
      padding: 4px 6px;
      font-size: 9px;
    }
    
    .chart-title {
      font-size: 10px;
    }
    
    .chart-header {
      margin-bottom: 3px;
    }
    
    #filter-panel {
      width: 100px;
      font-size: 8px;
    }
    
    .esri-legend {
      max-width: 110px !important;
      font-size: 9px !important;
    }
    
    .pie-chart-panel {
      min-height: 280px;
      max-height: 360px;
    }
    
    #pieChartCanvas {
      max-height: 260px !important;
    }
    
    /* Add bottom spacing to page for comfortable scrolling */
    .tab-content {
      padding-bottom: 20px;
    }
  }
  