@media (max-width: 620px) {
  html:has(.auth-screen:not(.hidden)) {
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  html,
  body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    background: #ffffff;
  }

  body:has(.auth-screen:not(.hidden)) {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .auth-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    height: 100svh;
    height: 100dvh;
    min-height: 100svh;
    min-height: 100dvh;
    max-height: 100svh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    background:
      linear-gradient(180deg, rgba(32, 58, 73, 0.97), rgba(32, 58, 73, 0.9)),
      var(--brand-navy);
    padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  }

  .auth-panel {
    width: 100%;
    height: auto;
    max-height: calc(100svh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 36px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    align-self: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    touch-action: pan-x;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
  }

  .auth-brand {
    flex: 0 0 auto;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #ffffff;
    padding: 0 0 12px;
    text-align: left;
  }

  .auth-brand .brand-logo.auth-logo {
    width: 104px;
    height: 68px;
    background: transparent;
    padding: 0;
  }

  .auth-form {
    flex: 0 0 auto;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
    padding: 18px;
    max-height: calc(100dvh - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: hidden;
  }

  .auth-form h1 {
    font-size: 1.52rem;
  }

  .auth-hint {
    font-size: 0.82rem;
  }

  .auth-form .eyebrow {
    color: var(--brand-gold);
  }

  .auth-form label {
    gap: 6px;
    font-size: 0.78rem;
  }

  .auth-error,
  .auth-hint {
    margin: 0;
  }

  .app-shell {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-width: 100vw;
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    padding: max(10px, env(safe-area-inset-top)) 12px 12px;
  }

  .brand {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin-bottom: 0;
    justify-content: center;
    gap: 10px;
    border-color: transparent;
    background: transparent;
    padding: 8px 12px;
    text-align: center;
  }

  .brand-logo {
    width: 76px;
    height: 50px;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }

  .brand strong {
    font-size: 0.9rem;
    letter-spacing: 0.04em;
  }

  .brand small {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.7rem;
  }

  .sidebar-footer {
    display: none;
    margin-top: auto;
    padding: 0;
  }

  .sidebar-logout {
    min-height: 48px;
    box-shadow: none;
    padding: 0 16px;
    text-align: left;
  }

  .sidebar-export {
    min-height: 48px;
    margin-bottom: 0;
    color: #ffffff;
    padding: 0 16px;
    text-align: left;
  }

  .mobile-menu-toggle {
    grid-column: 1;
    grid-row: 1;
    display: inline-grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 1px solid rgba(235, 168, 58, 0.44);
    border-radius: 8px;
    background: rgba(235, 168, 58, 0.18);
    color: #ffffff;
    padding: 10px;
  }

  .mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 99px;
    background: #ffffff;
  }

  .nav-list {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-flow: row;
    align-content: start;
    width: min(82vw, 320px);
    gap: 10px;
    background: var(--brand-navy);
    box-shadow: 22px 0 45px rgba(0, 0, 0, 0.28);
    padding: calc(86px + env(safe-area-inset-top)) 18px 140px;
    transform: translateX(-110%);
    transition: transform 180ms ease;
  }

  .sidebar.menu-open .nav-list::before {
    content: "Menú";
    display: block;
    margin-bottom: 6px;
    color: var(--brand-gold);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  .nav-item {
    display: block;
    width: 100%;
    min-height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-weight: 850;
    padding: 0 16px;
    text-align: left;
    white-space: nowrap;
  }

  .sidebar.menu-open .nav-list,
  .sidebar.menu-open .sidebar-footer {
    display: grid;
  }

  .sidebar.menu-open .nav-list {
    transform: translateX(0);
  }

  .sidebar.menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(17, 24, 39, 0.48);
  }

  .sidebar.menu-open .sidebar-footer {
    position: fixed;
    left: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 45;
    width: min(calc(82vw - 36px), 284px);
    gap: 8px;
    background: var(--brand-navy);
  }

  .main {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 16px 12px calc(18px + env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 14px;
    margin-bottom: 16px;
  }

  body[data-view="quoteHistory"] .topbar {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
    text-align: center;
  }

  body[data-view="quoteHistory"] .search {
    width: min(100%, 360px);
    display: grid !important;
    justify-self: center;
    gap: 5px;
    text-align: left;
  }

  body[data-view="quoteHistory"] .topbar-actions {
    width: 100%;
    display: grid;
    justify-items: center;
  }

  body[data-view="quoteHistory"] .search span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 850;
    text-align: center;
  }

  body[data-view="quoteHistory"] .search input {
    width: 100%;
    min-height: 42px;
    border-radius: 8px;
    font-size: 16px;
    text-align: left;
  }

  body[data-view="quoteHistory"] .topbar > div {
    min-width: 0;
  }

  body[data-view="quoteHistory"] .topbar h1 {
    font-size: 1.38rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  body[data-view="quoteHistory"] .topbar .eyebrow {
    margin-bottom: 2px;
  }

  #quote-history-view > .panel {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }

  #quote-history-view .panel-header {
    width: fit-content;
    max-width: calc(100vw - 24px);
    display: inline-grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: auto;
    margin: 0 auto 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 12px 14px;
    text-align: left;
  }

  #quote-history-view .panel-header h2 {
    line-height: 1.16;
  }

  #quote-history-view .pill {
    justify-self: end;
    white-space: nowrap;
  }

  #quote-history-view .quote-history-list {
    justify-items: center;
  }

  h1 {
    font-size: 1.55rem;
  }

  .search input,
  .quote-client-form input,
  .quote-client-form select,
  .quote-client-form textarea,
  .product-form input,
  .auth-form input {
    min-height: 46px;
    font-size: 16px;
  }

  .panel,
  .quote-client-card,
  .product-card {
    border-radius: 8px;
    box-shadow: none;
  }

  .quote-card-actions,
  .quote-form-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .quote-card-actions button,
  .quote-form-actions button,
  .primary-button,
  .ghost-button,
  .danger-button,
  .whatsapp-button,
  .email-button {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }

  .metrics {
    gap: 10px;
  }

  .task-item,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-row,
  .quote-product-row {
    grid-template-columns: 1fr;
  }

  .commission-result {
    grid-template-columns: 1fr;
  }

  .quote-card-header {
    display: grid;
    gap: 6px;
  }

  .quote-card-header span {
    white-space: normal;
  }

  .quote-list-item {
    width: 100%;
    max-width: calc(100vw - 24px);
    min-width: 0;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: hidden;
    text-align: center;
  }

  .quote-list-main,
  .quote-list-main strong,
  .quote-list-main span {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .quote-list-total {
    justify-self: center;
    font-size: 1.08rem;
  }

  .quote-list-actions {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .quote-list-actions .app-action-button,
  .quote-list-actions .ghost-button,
  .quote-list-actions .danger-button {
    min-width: 0;
    padding-inline: 10px;
    overflow: hidden;
    font-size: 0.92rem;
    line-height: 1.1;
    white-space: nowrap;
  }

  .quote-list-actions .primary-button {
    grid-column: span 2;
  }

  .quote-list-actions .ghost-button,
  .quote-list-actions .danger-button {
    grid-column: span 2;
  }

  .quote-detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .quote-client-form {
    padding: 14px;
    gap: 15px;
  }

  .quote-section-title {
    margin-top: 4px;
    padding: 10px 11px;
  }

  .quote-product-price {
    text-align: left;
  }
}
