/* ============================================
   OPTIMIZE PAGE — MOBILE ONLY (max-width: 768px)
   ============================================ */

@media (max-width: 768px) {

  .page-buttons {
    padding: 130px 16px 0;
    flex-wrap: wrap;
    gap: 8px;
  }

  .buttons {
    padding: 0 16px 8px;
    margin-top: -28px;
  }

  .scenario-controls {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  #scenario-selector {
    min-width: 100%;
    width: 100%;
  }

  /* Stack panels vertically */
  .optimize-layout {
    flex-direction: column;
    height: auto;
    overflow-y: visible;
    padding: 12px 16px 40px;
    gap: 14px;
  }

  .left-panel,
  .right-panel {
    width: 100%;
    flex: none;
  }

  /* Graph: fixed height, full width */
  .graph-card {
    flex: none;
    height: 240px;
    min-height: 240px;
  }

  /* Model inputs: compact scrollable */
  .graph-meta-card {
    flex: none;
    min-height: 120px;
    max-height: 180px;
  }

  .graph-meta-card .card-body {
    max-height: 140px;
    overflow-y: auto;
  }

  /* Impact & queue tables: fixed height, truncated */
  .impact-card {
    flex: none;
    height: 190px;
  }

  .queue-card {
    flex: none;
    height: 190px;
  }

  .impact-card .card-body,
  .queue-card .card-body,
  .table-card .card-body {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 155px;
  }

  /* Truncate table text — no horizontal scroll */
  .recommendations-table {
    table-layout: fixed;
    width: 100%;
    min-width: unset;
  }

  .recommendations-table th,
  .recommendations-table td {
    padding: 7px 6px;
    font-size: 0.74rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Reset impact card column widths for mobile */
  .impact-card .recommendations-table th:nth-child(1),
  .impact-card .recommendations-table td:nth-child(1) { width: 22%; }

  .impact-card .recommendations-table th:nth-child(2),
  .impact-card .recommendations-table td:nth-child(2) { width: 26%; padding-left: 4px; }

  .impact-card .recommendations-table th:nth-child(3),
  .impact-card .recommendations-table td:nth-child(3) { width: 26%; padding-left: 4px; }

  .impact-card .recommendations-table th:nth-child(4),
  .impact-card .recommendations-table td:nth-child(4) { width: 26%; }

  /* Metrics grid: 1 column */
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric-value {
    font-size: 22px;
  }

  /* Tour tooltip — larger and full-width on mobile */
  #tour-tooltip {
    width: calc(100vw - 32px) !important;
    left: 16px !important;
    right: 16px !important;
    font-size: 1rem !important;
    line-height: 1.7 !important;
    padding: 18px 20px !important;
  }
}
