/* Pagine billing/list/stats utente — chrome = app.css (brand + avatar). Admin resta su admin.css.
 * Stesso scroll di Board: scroll solo su html (overflow-y:scroll), body non è scroll container
 * (evita salti del header fixed tra Board e List). */
html.bl-html {
  height: auto !important;
  min-height: 100% !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: scroll !important;
  overscroll-behavior: auto !important;
  touch-action: pan-y !important;
  scrollbar-gutter: stable;
}
html.bl-html body.bl-page {
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
  min-height: 100% !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  overscroll-behavior: auto !important;
  touch-action: pan-y !important;
}
body.bl-page {
  background: var(--bg);
  font-family: var(--font);
  color: var(--ink);
  position: relative;
}
body.bl-page .topbar .topbar-chip {
  text-decoration: none;
  pointer-events: auto;
}
body.bl-page .app-header {
  pointer-events: none;
}
body.bl-page .app-header > * {
  pointer-events: auto;
}
body.bl-page .topbar {
  min-width: min-content;
  pointer-events: auto;
}
body.bl-page .topbar-user {
  max-width: none;
  flex-wrap: nowrap;
  gap: 0.4rem;
}
body.bl-page .bl-top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  min-width: 0;
  pointer-events: auto;
}
/* Stesso look di Undo/Redo / List chip sul board (hover soft da app.css) */
body.bl-page .bl-top-nav .fab-undo,
body.bl-page .bl-top-nav a.fab-undo {
  text-decoration: none;
  box-sizing: border-box;
  white-space: nowrap;
  max-width: min(46vw, 12rem);
  overflow: hidden;
  text-overflow: ellipsis;
}
body.bl-page .bl-top-nav .fab-danger:hover {
  background: #fce8e6;
  border-color: #f6aea9;
  color: var(--bad);
}
.bl-cancel-form { margin: 0; display: inline-flex; }

.bl-main {
  width: min(100%, var(--content-max, 1000px));
  margin: 0 auto;
  box-sizing: border-box;
  padding:
    var(--content-top)
    var(--content-x, clamp(0.85rem, 3vw, 1.35rem))
    2.5rem; /* spazio standard prima del footer */
  font-family: var(--font);
  color: var(--ink);
}
.bl-main-wide {
  /* Stessa larghezza di .bl-main: niente colonne “wide” diverse */
  width: min(100%, var(--content-max, 1000px));
}

/* Header pagina standard (List / Emittenti / Stats / Billing / …) */
.bl-page-head,
.lib-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.75rem;
  margin: 0 0 0.85rem;
  min-width: 0;
}
.bl-page-head {
  align-items: flex-start;
}
.bl-page-head h1,
.lib-title {
  margin: 0;
  min-width: 0;
  font-family: var(--font);
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}
.lib-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
  justify-content: flex-end;
}

/* Toggle Brani | Keywords (hits / stats) — pill tabs a destra del titolo */
.sm-mode-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
.sm-mode-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line, #e5e7eb);
  background: var(--card, #fff);
  color: var(--ink, inherit);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.sm-mode-btn:hover {
  border-color: color-mix(in srgb, var(--accent, #1292d1) 45%, var(--line, #e5e7eb));
}
.sm-mode-btn.is-on {
  border-color: var(--accent, #1292d1);
  background: var(--accent-soft, color-mix(in srgb, var(--accent, #1292d1) 14%, #fff));
  font-weight: 600;
  color: var(--accent-ink, var(--ink));
}
.sm-mode-btn:focus-visible {
  outline: 2px solid var(--accent, #1292d1);
  outline-offset: 2px;
}
@media (max-width: 420px) {
  .sm-mode-btn {
    min-height: 40px;
    padding: 0.3rem 0.7rem;
    font-size: 0.84rem;
  }
}

/* —— Status strip (metriche sole in card) —— */
.bl-status {
  display: block;
  padding: 0.85rem 1rem;
  margin: 0 0 0.55rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.bl-status-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.85rem 1.35rem;
  min-width: 0;
}
.bl-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.bl-metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.bl-metric.is-over .bl-metric-value {
  color: #b42318;
}
.bl-metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  white-space: nowrap;
}
.bl-metric-date {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.bl-metric-ico {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
/* Riga sotto: aiuto a sx, coupon/gestisci a dx */
.bl-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 1rem;
  margin: 0 0 1.5rem;
  min-width: 0;
}
.bl-status-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}
.bl-btn-ghost,
.bl-btn-solid {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.bl-btn-compact {
  min-height: 2rem;
  padding: 0.28rem 0.72rem;
  font-size: 0.8rem;
}
.bl-btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  list-style: none;
}
.bl-btn-ghost::-webkit-details-marker { display: none; }
.bl-btn-ghost:hover {
  background: #f1f3f4;
  border-color: #dadce0;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(60, 64, 67, 0.1);
}
.bl-btn-solid {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
}
.bl-btn-solid:hover {
  background: #111;
  border-color: #111;
}
.bl-btn-danger {
  color: var(--bad);
  border-color: #f1b4ae;
}
.bl-btn-danger:hover {
  background: #fce8e6;
  border-color: #f1b4ae;
  color: var(--bad);
}

.bl-support {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  min-width: 0;
  flex: 1 1 12rem;
}
.bl-support a { color: var(--accent); }

.bl-upgrade {
  margin: 0 0 1.75rem;
}
.bl-upgrade-head {
  text-align: center;
  margin: 0 0 1.15rem;
}
.bl-upgrade-head h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.bl-upgrade-head p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.bl-plan-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent);
}
.bl-plan-badge.is-current {
  background: rgba(14, 122, 176, 0.12);
}
.bl-plan-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
  padding-right: 4.5rem;
  min-width: 0;
}
.bl-cta-muted {
  background: #e8eaed !important;
  color: var(--muted) !important;
}
.bl-cta-muted:hover {
  background: #e8eaed !important;
}

@media (max-width: 640px) {
  .bl-status {
    padding: 0.75rem 0.85rem;
  }
  .bl-status-metrics {
    gap: 0.75rem 1rem;
    width: 100%;
  }
  .bl-metric {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 5.5rem;
  }
  .bl-status-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .bl-status-actions {
    width: 100%;
    margin-left: 0;
    justify-content: stretch;
  }
  .bl-status-actions .bl-btn-ghost,
  .bl-status-actions .bl-btn-solid,
  .bl-manage {
    flex: 1 1 auto;
  }
  .bl-manage > summary.bl-btn-ghost,
  .bl-status-actions .bl-btn-solid {
    width: 100%;
  }
  .bl-plan-desc { padding-right: 0; }
}

.bl-sub, .bl-lead, .bl-note, .bl-muted {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  font-family: var(--font);
}
.lib-meta {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  font-family: var(--font);
}
.bl-lead { margin: 0 0 1rem; }
.bl-note { margin: 1rem 0 0; }
.bl-note a, .bl-muted a { color: var(--accent); }

.bl-banner {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 0.9rem;
  margin: 0 0 0.85rem;
}
.bl-banner.ok { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.bl-banner.bad { background: #fef2f2; border-color: #fecaca; color: var(--bad); }

.bl-paused {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  margin: 0 0 1rem;
}
.bl-paused strong { font-size: 1rem; }
.bl-paused span { font-size: 0.9rem; }
.bl-paused-admin { font-size: 0.82rem; color: #92400e; opacity: 0.9; }

.bl-quota { margin: 0 0 1rem; font-size: 0.95rem; }
.bl-quota.big { font-size: 1.35rem; margin: 0 0 0.35rem; }

.bl-plans {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin: 1rem 0;
  padding: 0.35rem 0.15rem;
}
@media (min-width: 640px) {
  .bl-plans { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.bl-plan {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  box-shadow: var(--shadow);
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.35s ease;
  will-change: transform;
  z-index: 0;
}
.bl-plan:hover {
  z-index: 2;
  transform: translate3d(0, -4px, 0) scale(1.035);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.14);
  border-color: #c5cad3;
}
.bl-plan.current:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 122, 176, 0.15), 0 14px 32px rgba(15, 23, 42, 0.12);
}
@media (hover: none) {
  .bl-plan:hover {
    transform: none;
    box-shadow: var(--shadow);
    border-color: var(--line);
    z-index: 0;
  }
  .bl-plan.current:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(14, 122, 176, 0.15);
  }
}
@media (prefers-reduced-motion: reduce) {
  .bl-plan {
    transition: none;
  }
  .bl-plan:hover {
    transform: none;
  }
}
.bl-plan.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(21,101,192,0.15); }
.bl-plan.locked { opacity: 0.72; }
.bl-plan.locked .bl-cta[disabled] { background: #9ca3af; }
.bl-plan h2 { margin: 0; font-size: 1.05rem; color: var(--accent); }
.bl-price { margin: 0; font-size: 0.9rem; color: var(--muted); }
.bl-price span { font-size: 1.75rem; font-weight: 800; color: var(--ink); }
.bl-tracks { margin: 0 0 0.5rem; font-size: 0.9rem; }
.bl-plan-feats {
  list-style: none;
  margin: 0.35rem 0 0.15rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
.bl-plan-feats li {
  position: relative;
  margin: 0;
  padding: 0 0 0 1.35rem;
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--ink);
  min-width: 0;
}
.bl-plan-feats li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(14, 122, 176, 0.25);
}
.bl-plan-feats li::after {
  content: "";
  position: absolute;
  left: 0.28rem;
  top: 0.38rem;
  width: 0.28rem;
  height: 0.48rem;
  border: solid var(--accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.bl-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  margin-top: auto;
}
.bl-cta:hover { background: #0a6a9a; }
.bl-cta:disabled,
.bl-cta[disabled] { opacity: 0.5; cursor: not-allowed; }
.bl-cta[aria-disabled="true"] { cursor: not-allowed; }
.bl-cta.inline { margin-top: 0.75rem; width: fit-content; }

.bl-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  margin: 0 0 0.85rem;
  box-shadow: var(--shadow);
}

/* Form pubblici (contatti / partner): allineati a sinistra, larghezza fluida */
.bl-public-form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(100%, 36rem);
  max-width: 100%;
  margin-inline: 0;
  box-sizing: border-box;
  min-width: 0;
}
.bl-public-form .bl-btn-solid:disabled,
.bl-public-form .bl-btn-solid[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
/* Honeypot: fuori schermo, non interrompe layout */
.bl-hp {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
.bl-card h2 { margin: 0 0 0.55rem; font-size: 1rem; }
.bl-plan-summary .bl-price { margin-bottom: 0.25rem; }

.bl-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: stretch;
}
.bl-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.65rem;
  width: 100%;
  min-width: 0;
  align-items: end;
}
.bl-form-row > .bl-field {
  min-width: 0;
  width: 100%;
}
.bl-form .bl-cta-row {
  flex: none;
  width: 100%;
  margin-top: 0.15rem;
}
.bl-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.bl-field span {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.bl-field input, .bl-field select {
  min-height: 40px;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  width: 100%;
  background: #fff;
  box-sizing: border-box;
}
.bl-only-company[hidden],
.bl-field-off { display: none !important; }

@media (max-width: 560px) {
  .bl-form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.bl-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.bl-table th, .bl-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.bl-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
}
.bl-inv-report {
  width: 3rem;
  text-align: center;
  vertical-align: middle;
}
.bl-pdf-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: #b91c1c;
  text-decoration: none;
  border-radius: 8px;
}
.bl-pdf-dl:hover,
.bl-pdf-dl:focus-visible {
  background: #fef2f2;
  color: #991b1b;
  outline: none;
}
.bl-pdf-na {
  color: var(--muted);
  font-weight: 600;
}

/* Coupon modal — stessa animazione degli auth-modal */
body.bl-modal-open {
  overflow: hidden !important;
}
.bl-modal[hidden] {
  display: none !important;
}
.bl-modal {
  position: fixed;
  inset: 0;
  /* Sopra chrome SPA (topbar ~92); fuori da #spa-view stacking context */
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.32s ease,
    visibility 0.32s ease;
}
.bl-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.bl-modal.is-closing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.bl-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-scrim, rgba(15, 23, 42, 0.45));
}
.bl-modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 22rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  padding: 1rem 1.05rem 1.1rem;
  min-width: 0;
  opacity: 0;
  transform: translate3d(0, 22px, 0) scale(0.94);
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
@media (min-width: 720px) {
  /* 22rem −⅓ → floor(14.666) = 14rem */
  .bl-modal-panel {
    width: min(100%, 14rem);
  }
}
.bl-modal.is-open .bl-modal-panel {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}
.bl-modal.is-closing .bl-modal-panel {
  opacity: 0;
  transform: translate3d(0, 12px, 0) scale(0.96);
}
.bl-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}
.bl-modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 0;
}
.bl-modal-x {
  border: 0;
  background: transparent;
  font-size: 1.45rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 8px;
  touch-action: manipulation;
}
.bl-modal-x:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.bl-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.bl-modal-msg {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}
.bl-modal-msg.ok { color: var(--ok, #15803d); }
.bl-modal-msg.bad { color: var(--bad, #b91c1c); font-weight: 600; }
.bl-modal-body .bl-cta-row {
  margin-top: 0;
}

.bl-profile-hint {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.4;
}
.bl-profile-hint.bad {
  color: var(--bad);
  font-weight: 600;
}
.bl-field.is-invalid input,
.bl-field.is-invalid select {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
  outline: none;
}
.bl-field.is-invalid > span {
  color: var(--bad);
}
.bl-upgrade .bl-card {
  margin-top: 1.25rem;
}
