/* Responsive layout overrides. Loaded last so these rules can safely refine every page. */
html { overflow-x: hidden; }
body { min-width: 320px; }
img, svg, video { max-width: 100%; }
button, input, select, textarea { max-width: 100%; }
.phone {
  background-image: linear-gradient(#1d1014aa, #471c23);
  background-position: center;
  background-size: cover;
}

@media (max-width: 1180px) {
  .sidebar {
    width: 84px;
    padding: 24px 12px;
    align-items: stretch;
  }

  .brand { justify-content: center; }
  .brand div, .help, .profile > div:not(.avatar), .logout span { display: none; }
  .sidebar nav { margin-top: 42px; }
  .nav { justify-content: center; padding: 14px 8px; font-size: 18px; }
  .nav span { display: none; }
  .profile { justify-content: center; flex-direction: column; }
  .logout { margin-left: 0; width: 36px; padding: 0; justify-content: center; }

  main {
    width: auto;
    max-width: none;
    margin-left: 84px;
    padding: 0 28px 42px;
  }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .deal-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deal-options article:last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  main { padding-inline: 20px; }
  header { height: 88px; gap: 14px; }
  .header-actions .icon { display: none; }
  .header-actions .primary { white-space: nowrap; }
  .hero { height: auto; min-height: 235px; padding: 30px; }
  .hero-art { display: none; }
  .workflow { align-items: stretch; }
  .upload-form { grid-template-columns: 1fr 1fr; }
  .upload-form label:last-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  .sidebar {
    inset: auto 0 0;
    width: 100%;
    height: calc(66px + env(safe-area-inset-bottom));
    padding: 7px 8px env(safe-area-inset-bottom);
    border-top: 1px solid #312d31;
    box-shadow: 0 -8px 28px #17141724;
    z-index: 15;
  }

  .brand, .help, .profile { display: none; }
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(64px, 1fr));
    gap: 3px;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav {
    min-width: 64px;
    min-height: 52px;
    padding: 5px 3px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-align: center;
    font-size: 17px;
  }
  .nav span {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
    line-height: 1.2;
  }

  main {
    width: 100%;
    margin-left: 0;
    padding: 0 14px 28px;
  }

  header {
    height: auto;
    min-height: 78px;
    padding: 13px 0;
    align-items: center;
  }
  header .eyebrow { display: none; }
  h1 { font-size: clamp(20px, 6vw, 27px); line-height: 1.1; }
  h2 { font-size: clamp(27px, 8vw, 35px); line-height: 1.12; }
  .header-actions { flex: none; }
  .header-actions .primary { padding: 10px 12px; font-size: 0; }
  .header-actions .primary::after { content: '+ Upload'; font-size: 12px; }

  .hero { min-height: 0; padding: 25px 22px; border-radius: 16px; }
  .hero h2 { font-size: clamp(27px, 8vw, 34px); }
  .hero h2 br { display: none; }
  .hero p { line-height: 1.55; }

  .section-title { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
  .section-title .primary { width: 100%; }
  .metrics { grid-template-columns: 1fr; }
  .metrics article { min-width: 0; }
  .panel { padding: 18px 15px; }
  .panel-head { gap: 12px; }
  .panel-head b { font-size: 18px; }

  .upload-card { min-height: 0; border-radius: 16px; }
  .upload-card .upload-form { grid-template-columns: 1fr; }
  .upload-form label:last-child { grid-column: auto; }
  .upload-submit { width: 100%; }

  .deal-options { grid-template-columns: 1fr; }
  .deal-options article:last-child { grid-column: auto; }
  .workflow { padding: 20px; }
  .agreement-list { overflow: hidden; }
  .agreement-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .agreement-row > * { min-width: 0; overflow-wrap: anywhere; }

  .login-screen { padding: 14px; }
  .login-card { padding: 30px 20px; border-radius: 20px; }
  .login-card h2 { font-size: 27px; }
  .login-card #googleButton { max-width: 100%; overflow: hidden; }
  .deal-form { padding: 30px 20px; border-radius: 18px; }
}

@media (max-width: 480px) {
  .metrics strong { font-size: 20px; }
  .chart { margin-left: -8px; }
  .content-list { overflow: hidden; }
  .content-row { grid-template-columns: minmax(0, 1fr) auto; }
  .title-cell { min-width: 0; }
  .title-cell > div { min-width: 0; }
  .title-cell b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cover-picker { width: min(72vw, 220px); }
}
