@media (max-width: 1280px) {
  .page-shell {
    width: min(100vw - 24px, 1280px);
  }
}

@media (max-width: 1180px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 20px;
  }

  .card {
    grid-column: span 6;
  }

  .kpi-section,
  .leaderboard-card,
  .insights-card,
  .wide-card,
  .highlights-card {
    grid-column: 1 / -1;
  }

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

  .highlights-grid,
  .insight-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .page-shell {
    width: min(100vw - 22px, 1280px);
    padding-top: 18px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .card,
  .wide-card,
  .kpi-section,
  .leaderboard-card,
  .highlights-card,
  .insights-card {
    grid-column: 1 / -1;
  }

  .kpi-grid,
  .highlights-grid,
  .insight-list {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-controls {
    width: 100%;
  }

  .table-controls select {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-value {
    text-align: left;
  }

  .hero-panel-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    align-self: flex-start;
  }

  .legend-item span {
    white-space: normal;
  }
}

@media (max-width: 768px) {
  .page-shell {
    width: min(100vw - 18px, 1280px);
    padding-top: 14px;
    padding-bottom: 28px;
  }

  .top-nav,
  .announcement-bar {
    padding: 12px;
  }

  .announcement-bar {
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
  }

  .announcement-bar strong,
  .announcement-bar > span:not(.announce-chip) {
    flex: 1 0 100%;
    margin-right: 0;
  }

  .announce-chip {
    min-height: 30px;
    padding: 6px 10px;
    font-size: 0.82rem;
    line-height: 1.2;
    justify-content: center;
  }

  .hero-copy,
  .hero-panel,
  .card,
  .footer {
    padding: 20px;
    border-radius: 22px;
  }

  .hero-panel {
    gap: 16px;
  }

  .hero-panel-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .hero-copy h4 {
    max-width: none;
    font-size: clamp(2rem, 9vw, 2.8rem);
    line-height: 1.02;
    letter-spacing: -0.03em;
    word-break: break-word;
  }

  .hero-copy p {
    max-width: 100%;
    font-size: 0.96rem;
    line-height: 1.6;
  }

  .eyebrow,
  .section-label,
  .panel-label {
    max-width: 100%;
    white-space: normal;
    line-height: 1.35;
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
  }

  .status-pill {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    font-size: 0.74rem;
    line-height: 1.35;
  }

  .date-range-value {
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
  }

  .hero-stats strong {
    font-size: 1.12rem;
  }

  .hero-stats span {
    font-size: 0.82rem;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    width: 100%;
  }

  .upload-button {
    width: 100%;
    text-align: center;
  }

  .upload-row {
    flex-direction: column;
  }

  #csvUpload,
  .reset-button {
    width: 100%;
  }

  .donut-legend {
    grid-template-columns: 1fr;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .footer-main,
  .footer-contact {
    width: 100%;
    justify-items: start;
    text-align: left;
  }

  .footer-contact {
    padding-top: 8px;
    border-top: 1px solid rgba(32, 33, 36, 0.2);
  }

  .footer p,
  .footer a {
    line-height: 1.45;
    word-break: break-word;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  table {
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
    background: transparent;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: block;
    border-radius: 16px;
    border: 1px solid rgba(60, 64, 67, 0.16);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 249, 250, 0.94));
    box-shadow: 0 10px 24px rgba(26, 115, 232, 0.08);
    overflow: hidden;
  }

  tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    border-top: 1px dashed rgba(60, 64, 67, 0.14);
    font-size: 0.9rem;
  }

  tbody td:first-child {
    border-top: 0;
    padding-top: 14px;
  }

  tbody td:last-child {
    padding-bottom: 14px;
  }

  tbody td::before {
    content: attr(data-label);
    flex: 0 0 44%;
    color: var(--muted);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.3;
  }

  .campaign-cell {
    justify-items: end;
    text-align: right;
  }

  .metric-bar-cell {
    min-width: 0;
    width: 100%;
  }

  .metric-bar-cell > div:first-child {
    margin-left: auto;
    text-align: right;
  }

  .mini-track {
    display: none;
  }

  .status-chip {
    margin-left: auto;
  }

  .empty-row td {
    display: block;
    text-align: left;
    border-top: 0;
    padding: 14px;
  }

  .empty-row td::before {
    display: none;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100vw - 14px, 1280px);
  }

  .top-nav,
  .announcement-bar {
    border-radius: 14px;
  }

  .announcement-bar {
    font-size: 0.92rem;
    gap: 8px;
    padding: 13px 12px;
  }

  .announce-chip {
    padding: 6px 9px;
    font-size: 0.8rem;
  }

  .section-head h2 {
    font-size: 1.2rem;
  }

  .hero-copy h4 {
    font-size: clamp(1.6rem, 8.2vw, 2.15rem);
    line-height: 1.08;
  }

  .eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
  }

  .panel-label {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
  }

  .status-pill {
    font-size: 0.68rem;
    padding: 6px 10px;
  }

  .hero-copy p {
    font-size: 0.9rem;
  }

  .hero-stats strong {
    font-size: 1.02rem;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-card strong {
    font-size: 1.12rem;
  }

  tbody td::before {
    flex-basis: 40%;
    font-size: 0.7rem;
  }

  tbody td {
    gap: 10px;
    padding-inline: 12px;
  }
}
