:root {
  --card:#111827; --muted:#a8a8a8;  --ok:#10b981; --warn:#f59e0b;
  --radius:14px; --shadow:0 10px 30px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
#privacy-manage-btn { position: relative; left: 100px; bottom: 16px; z-index: 9997; border: 0; padding: 10px 14px; background: var(--card); color: #f2f2f2; border-radius: 999px; box-shadow: var(--shadow); cursor: pointer; font-weight: 600; }
.cookie-banner { position: fixed; inset-inline: 0; bottom: 0; z-index: 9998; display: none; }
.cookie-banner__card { margin: 16px auto; max-width: 980px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.cookie-banner__title { font-size: 18px; margin: 0 0 6px; color: var(--text); }
.cookie-banner__text { margin: 0; color: #f2f2f2; line-height: 1.4; }
.cookie-banner__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 700; cursor: pointer; }
.btn--ghost { background: transparent; color: #f2f2f2; outline: 1px solid #374151; }
.btn--primary { background: var(--ok); color: #052e1c; }
.btn--warn { background: #1f2937; color: #f2f2f2; outline: 1px solid #374151; }

/* MODALE: fix mobile/viewport.
   Prima la modale usava min-height:100vh su mobile senza scroll: il footer usciva dallo schermo.
   Ora il dialog rimane nel viewport e il contenuto centrale scorre. */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  color: color: #f2f2f2;
}
.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.modal__dialog {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  color: #f2f2f2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.modal__title { margin: 0; font-size: 20px; }
.modal__close { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: #f2f2f2; }
.modal__content {
  margin-top: 10px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  padding-right: 4px;
}
.category { border: 1px solid #1f2937; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.category h4 { margin: 0 0 6px; color: #f2f2f2; }
.category p { margin: 0 0 8px; color: #f2f2f2; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background:#374151; transition: .2s; border-radius: 999px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background: white; transition: .2s; border-radius: 50%; }
input:checked + .slider { background: var(--ok); }
input:checked + .slider:before { transform: translateX(20px); }
.modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #1f2937;
  background: var(--card);
  flex: 0 0 auto;
}
.modal__footer .left { color: #f2f2f2; font-size: 14px; }
.modal__footer .right { display: flex; gap: 10px; flex-wrap: wrap; }
.deferred-iframe { background:#0f172a; border:1px dashed #334155; border-radius:12px; padding:16px; color:#e5e7eb; }

@media (min-width: 721px) {
  .modal {
    display: none;
    align-items: center;
    justify-content: center;
  }
  .modal[style*="block"] {
    display: flex !important;
  }
}

@media (max-width: 720px) {
  #privacy-manage-btn {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
  .cookie-banner__card {
    grid-template-columns: 1fr;
    margin: 10px;
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
  }
  .modal {
    padding: 0;
  }
  .modal__dialog {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    padding: 16px;
  }
  .modal__content {
    padding-bottom: 8px;
  }
  .modal__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .modal__footer .right {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .modal__footer .right .btn {
    width: 100%;
  }
}


/* ==========================================================
   Fix 1.1.2: evita overflow orizzontale su mobile
   ========================================================== */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}
@supports not (overflow-x: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

#privacy-manage-btn,
.cookie-banner,
.cookie-banner *,
.modal,
.modal * {
  box-sizing: border-box;
}

#privacy-manage-btn {
  max-width: calc(100vw - 32px);
  white-space: normal;
  overflow-wrap: anywhere;
}

.cookie-banner {
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.cookie-banner__card {
  width: calc(100% - 32px);
  max-width: 980px;
  min-width: 0;
}

.cookie-banner__card > *,
.cookie-banner__text,
.cookie-banner__actions,
.modal__dialog,
.modal__content,
.modal__footer,
.category,
.category p,
.category h4 {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cookie-banner__actions .btn,
.modal__footer .btn {
  max-width: 100%;
  white-space: normal;
}

.modal {
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.modal__dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

@media (max-width: 720px) {
  #privacy-manage-btn {
    left: 12px;
    right: 12px;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .cookie-banner__card {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    margin: 10px auto;
  }

  .modal__dialog {
    width: 100vw;
    max-width: 100vw;
  }
}
