/* CERTIFICATI - palette + font allineati a COMPETITION
   (clone di /var/www/competition/static/css/style.css). */

:root {
  --purple:      #8e70d4;
  --purple-dark: #7559bc;
  --purple-light:#f0ebff;
  --text:        #e8e8f0;
  --text-muted:  #8888a8;
  --bg:          #16162a;
  --bg-dark:     #0e0e1a;
  --bg-card:     #1c1c34;
  --border:      rgba(255,255,255,.1);
  --error:       #fc6868;
  --success:     #4ade80;
  --warning:     #fbbf24;
  --blue:        #5fa1ff;
  --orange:      #f4a052;
  --grey:        #8888a8;
  --font:        'Inter', sans-serif;
  --font-title:  'Anton', sans-serif;
  --radius:      12px;
  --radius-btn:  100px;
  --shadow:      0 4px 32px rgba(0,0,0,.4);
  --max-w:       960px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  overflow-x: hidden;
}
a { color: #b39bff; text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; color: var(--text-muted); }

main { flex: 1; padding: 24px 0 40px; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
body.public .container { max-width: 720px; }
body.admin .container { max-width: 1180px; }
/* Variante full-width per pagine admin che vogliono usare tutta la
   larghezza del browser (lista submissions). Override del max-width sopra. */
body.admin .container.full-width {
  max-width: none;
  padding: 0 18px;
}

/* ── HEADER (allineato a COMPETITION) ── */
header.topbar {
  background: rgba(14,14,26,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 68px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
header.topbar > .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
/* Variante 3 colonne (CROSSFIT IRIS sx | titolo centro | nav dx) per
   l'header admin. Grid 1fr auto 1fr garantisce il centro centrato
   indipendentemente dalle larghezze dei laterali.
   Override max-width: vogliamo che brand stia attaccato al bordo SX dello
   schermo e nav al bordo DX, non limitati al max-width 1180px del body.admin. */
header.topbar.topbar-3col > .container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  max-width: none;
  padding: 0 18px;
}
header.topbar.topbar-3col .topbar-center {
  text-align: center;
}
header.topbar.topbar-3col .admin-nav {
  justify-self: end;
}
.brand {
  font-family: var(--font-title);
  font-size: 22px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
}
.brand a { color: inherit; text-decoration: none; }
.brand-sub {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--purple);
  text-transform: uppercase;
}
.brand-sub a { color: inherit; text-decoration: none; }
.admin-nav { display: flex; gap: 8px; align-items: center; }
.admin-nav a {
  color: rgba(255,255,255,.75);
  font-size: 14px;
  padding: 7px 16px;
  border-radius: var(--radius-btn);
  transition: all .2s;
}
.admin-nav a:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }

.footer-pub {
  padding: 20px 0;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 24px;
  font-size: 13px;
}
.footer-pub a { color: var(--purple); }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}
.card h1 {
  font-family: var(--font-title);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 26px;
  margin-bottom: 8px;
  color: #fff;
}
.card h2 {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--purple);
  margin-bottom: 14px;
}
.card p.lead { color: rgba(255,255,255,.7); font-size: 16px; }

/* ── FORMS ── */
.form .field { margin-bottom: 18px; }
.form label, .form-grid label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.form input[type="text"],
.form input[type="password"],
.form input[type="date"],
.form-grid input,
.inline-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.form input:focus, .form-grid input:focus, .inline-form input:focus {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}
.form input[type="file"] {
  width: 100%;
  padding: 8px 0;
  color: var(--text);
}
.form input[type="file"]::file-selector-button {
  background: var(--purple);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  margin-right: 12px;
  cursor: pointer;
}
.form small { color: var(--text-muted); font-size: 12px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: end;
}
.form-grid > .field { grid-column: span 1; }
.form-grid > .btn { grid-column: span 2; justify-self: start; }
.form-grid > p { grid-column: span 2; margin: 0; }

.inline-form {
  display: flex; gap: 8px; align-items: end; margin-top: 14px;
}
.inline-form input { flex: 1; }
.inline-form label {
  margin-bottom: 4px; font-size: 12px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px;
}

/* ── BUTTONS (radius pill come COMPETITION) ── */
.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all .15s;
}
.btn:hover { background: rgba(255,255,255,.16); text-decoration: none; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: rgba(255,255,255,.06); }
.btn-lg { padding: 14px 30px; font-size: 16px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  text-decoration: none;
  color: var(--text);
  font-size: 16px;
}
.icon-btn:hover { background: rgba(255,255,255,.16); text-decoration: none; }
.icon-btn-danger {
  background: rgba(252,104,104,.10);
  color: var(--error);
  border: 1px solid rgba(252,104,104,.25);
}
.icon-btn-danger:hover {
  background: rgba(252,104,104,.22);
  color: #fff;
}

/* ── CHIPS ── */
.chip {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: rgba(255,255,255,.08);
  color: var(--text);
}
.chip-green { background: rgba(74,222,128,.15); color: var(--success); }
.chip-blue  { background: rgba(95,161,255,.15); color: var(--blue); }
.chip-red   { background: rgba(252,104,104,.15); color: var(--error); }
.chip-orange{ background: rgba(244,160,82,.18); color: var(--orange); }
.chip-grey  { background: rgba(255,255,255,.08); color: var(--text-muted); }
.chip-large {
  padding: 6px 16px;
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 800;
}
.chip-large.chip-green { background: rgba(74,222,128,.22); }
.chip-large.chip-red { background: rgba(252,104,104,.22); }

.chip-link {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-btn);
  background: rgba(255,255,255,.08);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.chip-link:hover { background: rgba(255,255,255,.16); text-decoration: none; }
.chip-link.active { background: var(--purple); color: #fff; }
.chip-link .badge {
  background: rgba(0,0,0,.25);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}
.chip-link.active .badge { background: rgba(255,255,255,.25); }

/* ── ALERTS / FLASH ── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin: 12px 0;
  font-size: 14px;
}
.alert-error { background: rgba(252,104,104,.12); color: var(--error); border: 1px solid rgba(252,104,104,.3); }
.flash { padding: 11px 14px; border-radius: 10px; margin: 10px 0; font-size: 14px; }
.flash-error { background: rgba(252,104,104,.12); color: var(--error); border: 1px solid rgba(252,104,104,.3); }
.flash-info  { background: rgba(95,161,255,.12); color: var(--blue); border: 1px solid rgba(95,161,255,.3); }

/* ── PUBLIC: confirm dates ── */
.dates-grid {
  display: grid;
  /* minmax(0, 1fr) impedisce alla track di espandersi col contenuto:
     senza, il default minmax(auto, 1fr) fa sforare le tile sui mobile
     stretti perche' "15/03/2027" in Anton 26px non entra. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin: 22px 0;
}
.date-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}
.date-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}
.date-value {
  font-family: var(--font-title);
  font-size: 26px;
  margin-top: 8px;
  letter-spacing: 1px;
  color: #fff;
  white-space: nowrap;
}
@media (max-width: 540px) {
  .dates-grid { gap: 10px; margin: 18px 0; }
  .date-tile { padding: 16px 10px; }
  .date-value { font-size: 20px; letter-spacing: 0.3px; }
}
@media (max-width: 380px) {
  .date-tile { padding: 14px 6px; }
  .date-value { font-size: 17px; letter-spacing: 0; }
}
.ai-type { color: var(--text-muted); margin-top: 14px; }
.confirm-actions { display: flex; gap: 12px; margin: 24px 0; flex-wrap: wrap; justify-content: center; }
.confirm-actions form.inline { display: inline-block; }

/* Bottone "suggerisci tu le date" (terzo CTA su status_confirm). Stile link
   discreto sotto i due bottoni principali; non rubare attenzione alla coppia
   Si / No. */
.hints-toggle { text-align: center; margin: 4px 0 0; }
.btn-link {
  background: transparent; border: 0; padding: 4px 8px;
  color: var(--purple); text-decoration: underline;
  font: inherit; cursor: pointer;
}
.btn-link:hover { color: var(--purple-dark); }

/* Form date suggerite — nasce hidden, appare al click del btn-link.
   2 input date affiancati su desktop, in colonna su <540. */
.hints-form {
  margin: 18px auto 0; max-width: 460px; text-align: left;
  padding: 18px; border: 1px dashed var(--purple);
  border-radius: 12px; background: rgba(142,112,212,0.05);
}
.hints-form p { margin: 0 0 14px; text-align: center; }
.hints-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.hints-label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text); }
.hints-label span { font-weight: 500; }
.hints-label em { color: var(--text-muted); font-style: normal; font-weight: 400; }
.hints-label input[type="date"] {
  padding: 10px 12px; border: 1.5px solid var(--purple);
  border-radius: 8px; font-size: 15px; color: var(--text);
  background: var(--bg-dark); color-scheme: dark;
}
.hints-label input[type="date"]:focus { outline: 2px solid var(--purple); outline-offset: 1px; }
/* Scadenza calcolata: stesso layout dell'input ma readonly visually disabled */
.hints-readonly-value {
  padding: 10px 12px; border: 1.5px dashed var(--purple);
  border-radius: 8px; font-size: 15px; color: var(--text-muted);
  background: rgba(142,112,212,0.06);
}
.hints-hint {
  display: block; margin-top: 4px;
  font-size: 11px; color: var(--text-muted); font-style: italic;
}
.hints-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 540px) {
  .hints-fields { grid-template-columns: 1fr; }
}

.status-icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
  margin: 0 auto 16px;
}
.status-icon.ok   { background: rgba(74,222,128,.15);  color: var(--success); }
.status-icon.warn { background: rgba(251,191,36,.18);  color: var(--warning); }
.status-icon.err  { background: rgba(252,104,104,.15); color: var(--error); }
.card-done, .card-pending, .card-rejected { text-align: center; }
.card-done h1, .card-pending h1, .card-rejected h1 { font-size: 24px; }

.recap {
  list-style: none; padding: 0; margin: 18px auto;
  /* display: block + max-width: 100% evita overflow del CF mono su mobile;
     l'interno (li flex) si adatta alla larghezza utile. */
  display: block; text-align: left;
  max-width: 100%;
}
.recap li {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.recap li:last-child { border-bottom: none; }
.recap li span { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; flex-shrink: 0; }
.recap li strong { color: #fff; min-width: 0; text-align: right; word-break: break-word; }
.recap li strong.mono { letter-spacing: 0; }
@media (max-width: 540px) {
  .recap li { gap: 10px; padding: 9px 0; }
  .recap li span { font-size: 12px; letter-spacing: .3px; }
  .recap li strong { font-size: 14px; }
  .recap li strong.mono { font-size: 13px; }
}

.help { margin-top: 22px; }
.help summary { cursor: pointer; color: var(--purple); font-size: 14px; font-weight: 600; }
.help summary:hover { color: var(--purple-dark); }
.help ol, .help p { margin: 10px 0 0 18px; color: rgba(255,255,255,.75); font-size: 14px; }

/* ── ADMIN list ── */
.admin-page-intro {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin: 12px 0 18px;
}
.admin-page-intro h1 {
  font-family: var(--font-title);
  font-size: 24px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: #fff;
}
.admin-page-intro p { color: var(--text-muted); font-size: 14px; }
.admin-page-intro a.back {
  display: inline-block;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.admin-page-intro a.back:hover { color: var(--purple); text-decoration: none; }
.admin-page-intro .page-title-row { display: flex; align-items: center; gap: 12px; }
.admin-page-intro .page-title-row h1 { margin-bottom: 0; flex: 1; }

.filters { margin: 14px 0; display: flex; gap: 8px; flex-wrap: wrap; }

.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  /* table-layout: auto - il browser ridistribuisce le colonne col contenuto */
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
  white-space: nowrap;
  color: var(--text);
}
.data-table thead th {
  background: rgba(255,255,255,.03);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table.small th, .data-table.small td { padding: 7px 10px; font-size: 12px; }
.data-table .empty { text-align: center; color: var(--text-muted); padding: 40px; }
.cliente-name { font-weight: 600; color: #fff; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.small { font-size: 12px; }
.err { color: var(--error); }

.th-tip { position: relative; cursor: help; }
.th-tip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: 100%; left: 0;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
  white-space: normal;
  width: 240px;
  z-index: 10;
  box-shadow: var(--shadow);
}

/* ── ADMIN detail ── */
.detail-grid {
  display: grid;
  /* Schede a sinistra (compatte), documento a destra a tutta colonna. */
  grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 22px;
  align-items: start;
}
.detail-grid .preview {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 88px; /* sotto l'header sticky 68px + qualche px di aria */
  margin: 0;
  padding: 18px 18px 14px;
  /* Altezza: occupa tutta la viewport visibile sotto l'header */
  max-height: calc(100vh - 110px);
}
.preview-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px; margin-bottom: 10px;
  flex-shrink: 0;
}
.preview-head strong { color: #fff; }
.page-stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: #0a0a14;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 400px;
  position: relative;
}
#pageImg {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.page-spinner {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 10px;
  flex-shrink: 0;
}
.page-nav .icon-btn { width: 36px; height: 36px; font-size: 18px; }
.page-nav .icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-counter {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-width: 80px;
  text-align: center;
}
.preview-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; flex-shrink: 0; }
.detail-side { display: flex; flex-direction: column; gap: 14px; }
.detail-side .card { margin: 0; }

dl.kv {
  margin: 0;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 14px;
  font-size: 13px;
}
dl.kv dt {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 700;
  padding-top: 3px;
}
dl.kv dd { margin: 0; color: var(--text); }
dl.kv dd.dd-info { color: var(--text-muted); font-size: 12px; }

.kv-divider {
  grid-column: span 2;
  height: 1px;
  background: var(--border);
  margin: 6px 0 2px;
}
.kv-final dt, .kv-final dd {
  padding-top: 6px;
}
.kv-final dt {
  color: var(--text);
  font-weight: 800;
  letter-spacing: 1.5px;
}

/* ── Pipeline banner (card MB) ── */
.pipeline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.pipeline-banner .pb-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pipeline-banner .pb-text { flex: 1; }
.pipeline-banner .pb-meta { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.pipeline-banner.banner-ok    { background: rgba(74,222,128,.10);  border-color: rgba(74,222,128,.3); color: var(--success); }
.pipeline-banner.banner-ok    .pb-dot { background: var(--success); }
.pipeline-banner.banner-err   { background: rgba(252,104,104,.10); border-color: rgba(252,104,104,.3); color: var(--error); }
.pipeline-banner.banner-err   .pb-dot { background: var(--error); }
.pipeline-banner.banner-ready { background: rgba(244,160,82,.10);  border-color: rgba(244,160,82,.3);  color: var(--orange); }
.pipeline-banner.banner-ready .pb-dot { background: var(--orange); }
.pipeline-banner.banner-wait  { background: rgba(255,255,255,.04); border-color: var(--border); color: var(--text-muted); }
.pipeline-banner.banner-wait  .pb-dot { background: var(--text-muted); }
.pipeline-banner ul.miss-list {
  list-style: disc;
  margin: 6px 0 0 18px;
  padding: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Modifica manuale form ── */
.manual-edit-form .field { margin-bottom: 14px; }
.manual-edit-form select,
.manual-edit-form input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.radio-row {
  display: flex;
  gap: 18px;
  padding: 6px 0;
}
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
}
.radio-row input[type="radio"] { margin: 0; cursor: pointer; }

.live-valid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0;
}
.live-valid-row .lvr-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

ul.checks { list-style: none; padding: 0; margin: 0; font-size: 14px; }
ul.checks li { padding: 6px 0; color: var(--text-muted); }
ul.checks li::before { content: '○ '; color: var(--text-muted); font-weight: 700; }
ul.checks li.ok { color: var(--success); }
ul.checks li.ok::before { content: '✓ '; }
ul.checks li.err { color: var(--error); }
ul.checks li.err::before { content: '✗ '; }
ul.checks li.skip { color: var(--text-muted); }
ul.checks li.skip::before { content: '· '; }

.row-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.row-actions form.inline { display: inline-block; }

pre.raw-json {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 10px;
  font-size: 12px;
  overflow: auto;
  max-height: 320px;
  color: var(--text);
}

/* ── Audit log table: la cella "Dati" e' compatta (l'iconcina apre la modale) ── */
.audit-table td:nth-child(3) {
  width: 60px;
  text-align: center;
}
.audit-data-btn {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
}

/* ── Modale generica (riusata per audit JSON) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head strong { color: #fff; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }
.modal-head .icon-btn { width: 30px; height: 30px; font-size: 18px; }
.modal-json {
  padding: 18px 20px;
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow: auto;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
body.modal-open { overflow: hidden; }

/* ── LOGIN admin ── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 80px);
}
.card-login { max-width: 380px; padding: 36px; text-align: center; }
.card-login .brand-mark {
  font-family: var(--font-title);
  letter-spacing: 1.5px;
  font-size: 13px;
  color: var(--purple);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.card-login h1 {
  font-family: var(--font-title);
  font-size: 24px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 18px;
  color: #fff;
}

@media (max-width: 1080px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .preview { position: static; max-height: none; }
  .page-stage { min-height: 60vh; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > .btn, .form-grid > p { grid-column: span 1; }
}
@media (max-width: 640px) {
  header.topbar { padding: 0; height: 60px; }
  .brand { font-size: 18px; letter-spacing: 1.5px; }
  .brand-sub { font-size: 11px; letter-spacing: 1.5px; }
  .card { padding: 22px 18px; }
}

/* =================== Homepage centrata (form pubblico) ==================== */
.card-form--center { text-align: center; }
.card-form--center .field { text-align: center; }
.card-form--center .field > label { display: block; }
.card-form--center details { text-align: center; }
.card-form--center details > summary { text-align: center; }
.card-form--center details ol {
  list-style-position: inside;
  padding-left: 0;
  margin-left: 0;
}
.card-form--center .lead {
  margin-bottom: 40px;
}
.card-form--center .form .field + .field {
  margin-top: 28px;
}

/* =================== File input custom (label come bottone) ===============
   Specificita' alta per battere `.field label` (0,1,1) che imporrebbe
   display:block + uppercase + color text-muted. */
.file-input-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.form .field label.file-btn {
  display: inline-block;
  background: var(--purple);
  color: #fff;
  padding: 12px 32px;
  border-radius: 100px;
  font-weight: 700;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  margin: 0;
  cursor: pointer;
  transition: background .12s;
  width: auto;
}
.form .field label.file-btn:hover { background: var(--purple-dark); }
.file-input-hidden:focus + label.file-btn {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}
.file-name {
  margin-top: 12px;
  color: var(--text);
  font-size: 14px;
  word-break: break-all;
}
.file-name.has-file { color: var(--success); font-weight: 600; }
.file-hint {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

/* =================== CF input segmentato (16 caselle) =====================
   IMPORTANTE: le regole sopra `.form input[type="text"]` (specificita' 0,2,1)
   impongono padding/font ad ogni input dentro .form. Per vincerle uso
   `.form .cf-grid .cf-cell` (specificita' 0,3,0) che batte la prima.
   Altrimenti il padding del form clippa il glifo (problema visto in prod). */
.cf-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
}
.form .cf-grid .cf-cell {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  /* line-height = height: centra perfettamente il glifo nel content box,
     non dipende da padding del browser. Funziona perche' i CF italiani
     usano solo lettere maiuscole + cifre 0-9 (nessun descender). */
  line-height: 44px;
  padding: 0;
  margin: 0;
  text-align: center;
  font-family: 'JetBrains Mono', 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 22px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  transition: border-color .12s, background .12s, box-shadow .12s;
  caret-color: var(--purple);
  -webkit-appearance: none;
     -moz-appearance: textfield;
          appearance: none;
}
.form .cf-grid .cf-cell:focus {
  outline: none;
  border-color: var(--purple);
  background: rgba(142,112,212,0.08);
  box-shadow: 0 0 0 2px rgba(142,112,212,0.25);
}
.form .cf-grid .cf-cell.cf-cell--ok {
  border-color: rgba(74,222,128,0.5);
  background: rgba(74,222,128,0.08);
}
.form .cf-grid .cf-cell.cf-cell--err {
  border-color: rgba(252,104,104,0.55);
  background: rgba(252,104,104,0.08);
}
.form .cf-grid .cf-cell.cf-cell--ok:focus  { box-shadow: 0 0 0 2px rgba(74,222,128,0.25); }
.form .cf-grid .cf-cell.cf-cell--err:focus { box-shadow: 0 0 0 2px rgba(252,104,104,0.25); }

.cf-hint { color: var(--text-muted); font-size: 12px; }
.cf-hint--ok  { color: var(--success); }
.cf-hint--err { color: var(--error); }

@media (max-width: 720px) {
  .cf-grid { gap: 3px; }
  .form .cf-grid .cf-cell { height: 38px; line-height: 38px; font-size: 17px; border-radius: 6px; }
}
@media (max-width: 480px) {
  /* Riduco padding container/card per dare spazio alla cf-grid che ha
     comunque 16 caselle in larghezza. Senza, le celle sono ~13px e i
     glifi vengono tagliati. */
  body.public .container { padding: 0 12px; }
  .card { padding: 18px 12px; }
  .cf-grid { gap: 2px; }
  .form .cf-grid .cf-cell { height: 34px; line-height: 34px; font-size: 16px; border-width: 1px; border-radius: 5px; }
}
@media (max-width: 360px) {
  .form .cf-grid .cf-cell { height: 30px; line-height: 30px; font-size: 14px; }
}

/* =================== Progress panel (SSE live checklist) =================== */
.progress-panel {
  margin-top: 24px;
  padding: 22px 22px 18px;
  background: rgba(142, 112, 212, 0.06);
  border: 1px solid rgba(142, 112, 212, 0.25);
  border-radius: 14px;
}
.progress-panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}
.progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-muted);
  transition: color .15s ease, opacity .15s ease;
}
.progress-step .progress-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  position: relative;
}
.progress-step.pending { opacity: 0.55; }
.progress-step.pending .progress-icon::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.6;
}
.progress-step.running { color: var(--text); }
.progress-step.running .progress-icon {
  border-color: var(--purple);
  background: rgba(142, 112, 212, 0.12);
}
.progress-step.running .progress-icon::before {
  content: '';
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(142, 112, 212, 0.25);
  border-top-color: var(--purple);
  animation: progress-spin 0.7s linear infinite;
}
.progress-step.done { color: var(--text); }
.progress-step.done .progress-icon {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--success);
}
.progress-step.done .progress-icon::before {
  content: '';
  width: 6px; height: 11px;
  border-right: 2px solid var(--success);
  border-bottom: 2px solid var(--success);
  transform: rotate(45deg);
  margin-bottom: 3px;
}
.progress-step.skipped { color: var(--text-muted); opacity: 0.7; }
.progress-step.skipped .progress-icon {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
}
.progress-step.skipped .progress-icon::before {
  content: '';
  width: 10px; height: 2px;
  background: var(--text-muted);
}
.progress-step.error { color: var(--error); }
.progress-step.error .progress-icon {
  background: rgba(252,104,104,0.18);
  border-color: rgba(252,104,104,0.4);
}
.progress-step.error .progress-icon::before {
  content: '\00d7';
  color: var(--error);
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}
@keyframes progress-spin {
  to { transform: rotate(360deg); }
}

/* Disabled buttons (post-click) — sostituisce il default browser greyed */
button[disabled],
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ====================================================================== */
/* Hub clienti — landing con 2 tile cliccabili                             */
/* ====================================================================== */
.hub-card { max-width: 720px; margin: 0 auto; }
.hub-title {
  font-family: 'Anton', sans-serif;
  font-size: 28px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.hub-lead { color: var(--text-muted); margin: 0 0 24px; }
.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.hub-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 20px 18px;
  border-radius: 16px;
  border: 1px solid rgba(142, 112, 212, 0.25);
  background: rgba(142, 112, 212, 0.06);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  min-height: 168px;
}
.hub-tile:hover {
  background: rgba(142, 112, 212, 0.14);
  border-color: rgba(142, 112, 212, 0.55);
}
.hub-tile:active { transform: translateY(1px); }
.hub-tile__title {
  font-family: 'Anton', sans-serif;
  font-size: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.hub-tile__desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted);
  flex: 1;
}
.hub-tile__cta {
  margin-top: auto;
  color: var(--purple);
  font-weight: 600;
  font-size: 14px;
}
@media (max-width: 540px) {
  .hub-grid { grid-template-columns: 1fr; }
  .hub-tile { min-height: 0; }
}

/* ====================================================================== */
/* Sospensioni — card riepilogo abbonamento + form scelta                  */
/* ====================================================================== */
.susp-summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 18px;
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  margin: 12px 0 24px;
  font-size: 14px;
}
.susp-summary dt {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: center;
}
.susp-summary dd { margin: 0; color: var(--text); }
.susp-summary dd strong { color: var(--text); }
.susp-discount-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(74,222,128,0.15);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}
.susp-section { margin: 24px 0 8px; }
.susp-section h3 {
  font-family: 'Anton', sans-serif;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 16px;
}
.susp-radio-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.susp-radio-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.susp-radio-list label:has(input:checked) {
  background: rgba(142, 112, 212, 0.12);
  border-color: rgba(142, 112, 212, 0.45);
}
.susp-radio-list label.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.susp-radio-list input[type="radio"] { margin-top: 3px; }
.susp-radio-list .opt-title { font-weight: 600; }
.susp-radio-list .opt-desc { color: var(--text-muted); font-size: 13px; }
.susp-radio-list .opt-price { color: var(--purple); font-weight: 700; font-size: 14px; }

/* OTP — 6 caselle uniformi (riusa pattern .cf-cell ma 6 invece di 16) */
.otp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
}
.otp-cell {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  padding: 14px 0;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}
.otp-cell:focus {
  outline: none;
  border-color: var(--purple);
  background: rgba(142,112,212,0.10);
}

/* Sospensione admin — banner stato richiesta */
.susp-status-banner {
  padding: 14px 16px;
  border-radius: 12px;
  margin: 0 0 16px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.susp-status-banner.is-submitted {
  background: rgba(232,144,0,0.12);
  border: 1px solid rgba(232,144,0,0.35);
  color: #e89000;
}
.susp-status-banner.is-executed {
  background: rgba(74,222,128,0.12);
  border: 1px solid rgba(74,222,128,0.35);
  color: var(--success);
}
.susp-status-banner.is-rejected,
.susp-status-banner.is-cancelled {
  background: rgba(252,104,104,0.10);
  border: 1px solid rgba(252,104,104,0.30);
  color: var(--error);
}
