/* Responsive public navigation and cross-device layout hardening */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 92px;
  min-height: 44px;
  border: 1px solid rgba(152, 0, 90, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 0 15px;
  box-shadow: 0 12px 28px rgba(23, 23, 31, 0.1);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.nav-toggle-icon {
  display: grid;
  gap: 4px;
  width: 18px;
}

.nav-toggle-icon span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-header.nav-open .nav-toggle-icon span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.site-header.nav-open .nav-toggle-icon span:nth-child(2) {
  opacity: 0;
}

.site-header.nav-open .nav-toggle-icon span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.site-nav a[aria-current="page"]:not(.nav-cta) {
  background: rgba(228, 0, 127, 0.08);
  color: var(--pink-deep);
}

.nav-toggle:focus-visible,
.site-nav a:focus-visible,
.nav-link-button:focus-visible,
.brand:focus-visible,
.footer-links a:focus-visible,
.call-float:focus-visible,
.whatsapp-float:focus-visible {
  outline: 3px solid rgba(228, 0, 127, 0.32);
  outline-offset: 3px;
}

img,
video,
iframe {
  max-width: 100%;
}

@media (max-width: 1040px) {
  .site-header {
    position: relative;
    z-index: 100;
    align-items: center !important;
    flex-direction: row !important;
    gap: 14px;
    padding: 12px 0;
  }

  .site-header .brand {
    width: auto;
    min-width: 0;
    max-width: calc(100% - 108px);
  }

  .site-header .brand > span:last-child {
    min-width: 0;
  }

  .site-header .brand strong,
  .site-header .brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .site-header .site-nav {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 120;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100%;
    max-height: min(560px, calc(100vh - 100px));
    gap: 8px;
    border: 1px solid rgba(152, 0, 90, 0.14);
    border-radius: 24px;
    background: #fffdf9;
    padding: 14px;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(23, 23, 31, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(0.985);
    transform-origin: top right;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    white-space: normal;
  }

  .site-header.nav-open .site-nav {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .site-header .site-nav > * {
    grid-column: auto !important;
    min-width: 0;
    width: 100%;
  }

  .site-header .site-nav a,
  .site-header .nav-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    border-radius: 14px;
    padding: 8px 12px;
    text-align: center;
  }

  .site-header .site-nav a:not(.nav-cta):hover,
  .site-header .site-nav a:not(.nav-cta):focus-visible,
  .site-header .nav-link-button:hover,
  .site-header .nav-link-button:focus-visible {
    background: rgba(228, 0, 127, 0.08);
    color: var(--pink-deep);
  }

  .site-header .site-nav .nav-cta {
    width: 100%;
    max-width: none;
    min-height: 44px;
    justify-self: stretch;
    border-radius: 14px;
  }

  .site-header .nav-form {
    display: flex;
    margin: 0;
  }
}

@media (max-width: 700px) {
  .site-header,
  main,
  .site-footer {
    width: calc(100% - 24px);
    max-width: calc(100vw - 24px);
    margin-right: auto;
    margin-left: auto;
  }

  .site-header .brand {
    max-width: calc(100% - 70px);
    gap: 9px;
  }

  .site-header .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .site-header .brand-mark img {
    width: 31px;
    height: 31px;
  }

  .site-header .brand strong {
    font-size: 15px;
  }

  .site-header .brand small {
    font-size: 10.5px;
  }

  .nav-toggle {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .nav-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .site-header .site-nav {
    border-radius: 20px;
    padding: 12px;
  }

  .site-header .site-nav a,
  .site-header .nav-link-button,
  .site-header .site-nav .nav-cta {
    min-height: 42px;
    font-size: 13px;
  }

  .page-hero,
  .section,
  .hero,
  .premium-hero,
  .auth-shell,
  .auth-panel,
  .auth-aside,
  .contact-map,
  .footer-grid,
  .footer-top {
    min-width: 0;
    max-width: 100%;
  }

  .call-float,
  .whatsapp-float {
    right: 12px;
  }
}

@media (max-width: 380px) {
  .site-header .brand small {
    display: none;
  }

  .site-header .site-nav {
    grid-template-columns: 1fr !important;
    max-height: calc(100vh - 88px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle-icon span,
  .site-header .site-nav {
    transition: none;
  }
}

/* Agreements/invoices final responsive containment (must follow legacy admin overrides). */
.document-admin-main .admin-table-wrap {
  max-width: 100%;
  overflow-x: auto !important;
}

.document-admin-main .invoice-table {
  min-width: 720px;
}

@media (max-width: 980px) {
  body.admin-shell-body .dashboard-shell {
    width: min(100% - 24px, 980px) !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 16px !important;
  }

  body.admin-shell-body .dashboard-sidebar,
  body.admin-shell-body .dashboard-main,
  body.admin-shell-body .document-admin-main,
  body.admin-shell-body .document-admin-main .dashboard-section {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.admin-shell-body .dashboard-sidebar {
    position: static !important;
    overflow: visible !important;
  }

  body.admin-shell-body .document-admin-main .invoice-settings-form,
  body.admin-shell-body .document-admin-main .document-admin-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 640px) {
  body.admin-shell-body .dashboard-shell {
    width: calc(100% - 20px) !important;
  }

  body.admin-shell-body .dashboard-sidebar h1 {
    font-size: 30px !important;
    overflow-wrap: anywhere !important;
  }

  body.admin-shell-body .dashboard-sidebar nav {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  body.admin-shell-body .dashboard-sidebar nav a,
  body.admin-shell-body .dashboard-sidebar nav button {
    min-height: 42px !important;
    padding: 8px !important;
    font-size: 11px !important;
    justify-content: center !important;
    text-align: center !important;
  }

  body.admin-shell-body .document-admin-main .agreement-send-form,
  body.admin-shell-body .document-admin-main .document-filter-form,
  body.admin-shell-body .document-admin-main .invoice-settings-form,
  body.admin-shell-body .document-admin-main .recipient-search-list a,
  body.admin-shell-body .document-admin-main .verified-payment-strip article {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.admin-shell-body .document-admin-main .document-filter-form .button,
  body.admin-shell-body .document-admin-main .agreement-send-form .button,
  body.admin-shell-body .document-admin-main .invoice-settings-form .button {
    width: 100% !important;
  }
}

/* Branded invoice workflow cascade guard. */
body.admin-shell-body .invoice-entry-title {
  align-items: center !important;
  display: grid !important;
  gap: 18px !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  padding: 2px 4px 16px !important;
  text-align: left !important;
}

body.admin-shell-body .invoice-service-labels,
body.admin-shell-body .invoice-service-fields {
  grid-template-columns: minmax(260px, 1.65fr) minmax(140px, 0.75fr) minmax(90px, 0.45fr) minmax(180px, 0.8fr) !important;
}

@media (max-width: 1180px) {
  body.admin-shell-body .invoice-service-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 700px) {
  body.admin-shell-body .invoice-entry-title,
  body.admin-shell-body .invoice-delivery-grid .document-channel-form,
  body.admin-shell-body .invoice-service-fields,
  body.admin-shell-body .invoice-customer-filter {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.admin-shell-body .invoice-entry-type {
    border-top: 1px solid #d2d3d9;
    padding-top: 12px;
    text-align: left;
  }
}

/* Payment v7 cascade guard: keep the new workflow intact after legacy overrides. */
body.admin-shell-body .payment-filter-form {
  align-items: end !important;
  display: grid !important;
  gap: 12px !important;
  grid-template-columns: minmax(250px, 2fr) minmax(145px, 0.75fr) minmax(155px, 0.8fr) 88px auto auto !important;
}

body.admin-shell-body .payment-status-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

body.admin-shell-body .payment-review-card {
  min-width: 0 !important;
  overflow: hidden !important;
}

body.admin-shell-body .payment-record-facts dd,
body.admin-shell-body .payment-review-card p,
body.admin-shell-body .payment-review-card h2 {
  overflow-wrap: anywhere !important;
}

body.admin-shell-body .danger-button {
  background: #9f1239 !important;
  border-color: #9f1239 !important;
  color: #fff !important;
}

@media (max-width: 1220px) {
  body.admin-shell-body .payment-filter-form,
  body.admin-shell-body .payment-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 700px) {
  body.admin-shell-body .payment-filter-form,
  body.admin-shell-body .payment-status-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
