/*
 * Pannello di redazione di CertaStampa — foglio di stile unico, senza compilazione.
 *
 * Nasce dal pannello di GoriGo, modello di riferimento per il menu a icone e
 * per i campi: pensato prima per il telefono, menu a striscia di icone,
 * tabelle che diventano una scheda per riga, aree di tocco di almeno 44 px.
 * I colori sono quelli del giornale: nero, rosso del logo, grigi neutri.
 */

:root {
  --bg: #F4F4F2;
  --surface: #FFFFFF;
  --text: #111111;
  --muted: #555555;
  --brand: #E00404;
  --brand-dark: #B80303;
  --brand-soft: #FBD5D5;
  --ok: #15803D;
  --ok-soft: #DCFCE7;
  --warn: #92400E;
  --warn-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --line: #E2E2DE;
  --line-strong: #C9C9C4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 4px 16px rgba(31, 36, 48, .06);
  --tap: 44px;
  --sidebar: 260px;
  --sidebar-rail: 72px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); font-size: 16px; line-height: 1.5; min-height: 100vh; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
[x-cloak] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---- struttura ------------------------------------------------------ */

.skip { position: absolute; left: -999px; top: 8px; background: var(--text); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 6px 12px; min-height: 60px;
}
.topbar .logo img { height: 38px; width: auto; }
.topbar .spacer { flex: 1; }
.topbar .zone { font-size: .8rem; color: var(--muted); text-align: right; line-height: 1.2; }

.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border: 0; background: transparent; border-radius: 10px; cursor: pointer;
}
.menu-toggle svg { width: 26px; height: 26px; }

/* Chiusa è una striscia di sole icone (con tooltip al passaggio del mouse),
   sempre visibile e sempre raggiungibile col dito o con Tab: non nasconde
   nulla, mostra solo meno testo. Aperta si allarga sopra il contenuto, che
   non si sposta: la striscia di icone gli ha già fatto posto in permanenza. */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-rail); z-index: 50;
  background: var(--text); color: #fff; overflow-y: auto; overflow-x: hidden;
  transition: width .2s ease;
  padding: 12px 4px 96px;
}
.sidebar.open { width: min(86vw, var(--sidebar)); padding: 12px 10px 96px; }

/* Il pulsante tondo che apre e chiude il menu: in basso a sinistra, sopra la sidebar. */
.menu-basso {
  position: fixed; left: 16px; bottom: 16px; z-index: 60; width: 52px; height: 52px; border-radius: 50%;
  border: 0; cursor: pointer; background: var(--text); color: #fff; font-size: 1.5rem; line-height: 1;
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.menu-basso:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; }

/* Il tooltip delle icone: niente transizione, deve comparire sul colpo, non
   al ritmo del tooltip nativo del browser. `left` è fisso perché compare
   solo a sidebar chiusa, sempre alla stessa distanza dalla striscia. */
.icon-tooltip {
  position: fixed; left: calc(var(--sidebar-rail) + 10px); transform: translateY(-50%); z-index: 80;
  background: var(--text); color: #fff; padding: 7px 12px; border-radius: 8px;
  font-size: .85rem; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow); pointer-events: none;
}
.sidebar .brand { display: flex; align-items: center; justify-content: center; padding: 4px 2px 14px; }
.sidebar.open .brand { justify-content: space-between; padding: 4px 6px 14px; }
.sidebar .brand .brand-full { display: none; height: 34px; width: auto; }
.sidebar.open .brand .brand-full { display: block; }
.sidebar .brand .brand-icon { display: block; height: 34px; width: 34px; }
.sidebar.open .brand .brand-icon { display: none; }
.sidebar .brand .close-menu { display: none; }
.sidebar.open .brand .close-menu { display: inline-flex; }

/* Il testo resta nella pagina per chi usa un lettore di schermo (la
   raggruppa comunque per gruppo di voci): è solo l'occhio a non vederlo
   finché il menu non si apre, con la stessa tecnica di «visually-hidden». */
.nav-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.sidebar.open .nav-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }

/* L'intestazione di un gruppo è anche il suo interruttore: un tocco apre o
   chiude le voci sotto (tranne «Lavoro», che parte già aperto). Nella
   striscia di icone l'interruttore non serve — le icone si vedono comunque
   tutte — e l'intestazione torna a essere la sottile riga divisoria di prima. */
.nav-group {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; align-items: center; justify-content: center; width: 100%;
  margin: 14px 10px 4px; height: 1px; background: rgba(255, 255, 255, .14); padding: 0; font-size: 0;
}
.nav-group:first-child { margin-top: 0; }
.nav-group:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sidebar.open .nav-group {
  margin: 14px 0 4px; padding: 6px 10px; height: auto; background: none; justify-content: space-between;
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: #9AA1B2;
}
.nav-caret { display: none; width: 16px; height: 16px; flex: none; transition: transform .15s ease; }
.sidebar.open .nav-caret { display: block; }
.nav-caret.open { transform: rotate(90deg); }
.nav a, .nav button {
  display: flex; align-items: center; justify-content: center; gap: 0; width: 100%;
  min-height: var(--tap); padding: 10px 4px; border-radius: 10px;
  color: #E9EBF1; text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer; text-align: left;
}
.sidebar.open .nav a, .sidebar.open .nav button { justify-content: flex-start; gap: 12px; padding: 10px 12px; }
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, .08); }
.nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav .ico { width: 24px; text-align: center; font-size: 1.1rem; flex: none; }

.main { padding: 16px 16px 96px; max-width: 1240px; margin: 0 auto; }

/* La striscia di icone è sempre lì: topbar e contenuto le fanno posto in
   permanenza, così quando il menu si apre non li sposta (si apre sopra). */
.topbar, .main-wrap { margin-left: var(--sidebar-rail); }

@media (min-width: 1024px) {
  .main { padding: 28px 32px 96px; }
}

/* ---- intestazione di pagina ---------------------------------------- */

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; flex: 1 1 240px; }
.page-head .sub { flex-basis: 100%; color: var(--muted); margin: -6px 0 0; }
.breadcrumb { font-size: .9rem; margin-bottom: 6px; }
.breadcrumb a { text-decoration: none; display: inline-flex; min-height: 32px; align-items: center; }

/* ---- schede e griglie ---------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
/* Senza questo un elemento della griglia non si restringe sotto il suo contenuto e sborda a 360 px. */
.grid > * { min-width: 0; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .layout-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.span-all { grid-column: 1 / -1; }

.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: .85rem; color: var(--muted); }
.kpi .value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.kpi .hint { font-size: .8rem; color: var(--muted); }
.kpi.accent { background: var(--text); color: #fff; border-color: var(--text); }
.kpi.accent .label, .kpi.accent .hint { color: #C9CEDA; }

/* ---- pulsanti ------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
.btn-primary { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-primary:hover { background: #8F0202; border-color: #8F0202; }
.btn-danger { color: var(--danger); border-color: #F3B4B4; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
/* Il verde di WhatsApp, con il testo scuro: in bianco su questo verde non si leggerebbe (contrasto sotto WCAG AA). */
.btn-whatsapp { background: #25D366; border-color: #25D366; color: #0B1F14; }
.btn-whatsapp:hover { background: #1EBE5A; border-color: #1EBE5A; }
.btn-sm { min-height: var(--tap); padding: 6px 12px; font-size: .9rem; }
.btn-icon { width: var(--tap); padding: 0; }
.btn-block { width: 100%; white-space: normal; text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-actions {
  position: sticky; bottom: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end;
  background: rgba(244, 244, 242, .96); padding: 12px 0; margin-top: 8px; border-top: 1px solid var(--line);
}
@media (max-width: 639px) { .form-actions .btn { flex: 1 1 auto; } }

/* ---- moduli -------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .field .label { font-weight: 600; font-size: .95rem; }
.field .help { font-size: .85rem; color: var(--muted); }
.field .error { font-size: .88rem; color: var(--danger); font-weight: 600; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel],
input[type=date], input[type=time], input[type=datetime-local], input[type=month], input[type=search], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--text);
  font: inherit; font-size: 16px; /* 16 px: iOS non ingrandisce la pagina al tocco */
}
textarea { min-height: 110px; resize: vertical; }
/* il bordo e il padding sono già uguali agli altri campi: qui si toglie solo la "chrome"
   nativa del browser (freccia e sfondo propri) e si ridisegna la freccia a tinta unita.
   Colore della freccia in tinta fissa (non var()): dentro un data-URI le variabili CSS
   non si risolvono; corrisponde a --muted */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 40px; line-height: 1.3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23555555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px;
}
select:-moz-focusring { color: transparent; text-shadow: 0 0 0 var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--brand-dark); outline: 2px solid var(--brand-soft); }
.is-invalid { border-color: var(--danger) !important; }
.input-group { display: flex; align-items: stretch; }
.input-group input { flex: 1 1 auto; min-width: 0; width: auto; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .suffix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 10px 10px 0; background: #EFEFEC; color: var(--muted); }

/* interruttore acceso/spento: tutta la riga è area di tocco */
.switch { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; width: 50px; height: 30px; border-radius: 30px; background: #BDBDB8; position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--brand); outline-offset: 2px; }
.switch .text small { display: block; font-weight: 400; color: var(--muted); }

/* caselle a scelta multipla come «pillole» grandi */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-flex; align-items: center; min-height: var(--tap); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--text); color: #fff; border-color: var(--text); }
.chip input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

.checklist { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.check:hover { background: #F4F4F2; }
.check input { width: 22px; height: 22px; accent-color: var(--brand-dark); flex: none; }

.disclaimer { border-left: 4px solid var(--brand); background: #FDEDED; padding: 12px 14px; border-radius: 8px; font-size: .92rem; margin-bottom: 14px; }

/* immagine con anteprima */
.image-field { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.image-field .preview { width: 110px; height: 110px; border-radius: 12px; border: 1px dashed var(--line-strong); background: #F4F4F2 center / cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; text-align: center; overflow: hidden; flex: none; }
.image-field .preview.wide { width: 200px; height: 110px; }
.image-field .preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field .controls { flex: 1 1 200px; display: flex; flex-direction: column; gap: 8px; }
input[type=file] { font: inherit; max-width: 100%; min-height: var(--tap); }

/* ---- avvisi -------------------------------------------------------- */

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; }
.alert-ok { background: var(--ok-soft); border-color: #86EFAC; color: #14532D; }
.alert-info { background: #EEF4FF; border-color: #B9D0FF; color: #1E3A8A; }
.alert-error { background: var(--danger-soft); border-color: #FCA5A5; color: #7F1D1D; }
.alert-warn { background: var(--warn-soft); border-color: #FCD34D; color: var(--warn); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #ECECE8; color: var(--text); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: #14532D; }
.badge-off { background: #EEE; color: #555; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: #7F1D1D; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* ---- tabelle: da scrivania a schede ------------------------------- */

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 16px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 12px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #F7F7F5; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.right, table.list th.right { text-align: right; }
table.list .row-title { font-weight: 700; text-decoration: none; color: var(--text); }
table.list .row-title:hover { color: var(--brand-dark); }
table.list tfoot td { font-weight: 800; background: #F7F7F5; }
table.list th.cell-select { width: 1%; }
table.list td.cell-select { width: 1%; padding: 0; }
/* La casella sta sola nella cella, senza testo accanto che allarghi l'area di
   tocco da sé (a differenza di «Tutti» nella barra, che ha la parola vicino):
   l'etichetta (vuota, solo lo screen reader la sente) viene allargata a
   un quadrato di almeno 44×44 px, con la casella al centro. */
table.list td.cell-select label.check { min-width: var(--tap); min-height: var(--tap); justify-content: center; padding: 4px; border-radius: 0; }

/* Sotto i 1200 px (telefono, tablet, portatile piccolo col menu fisso) ogni riga diventa una scheda, e ogni dato si porta dietro
   la sua etichetta (attributo data-label): niente scorrimento orizzontale. */
@media (max-width: 1199px) {
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tfoot, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.list tr:last-child { border-bottom: 0; }
  table.list td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.list td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; flex: none; max-width: 45%; }
  table.list td.cell-main { display: block; text-align: left; font-size: 1.05rem; padding-bottom: 6px; }
  table.list td.cell-main::before, table.list td.cell-actions::before, table.list td.cell-select::before { content: none; }
  table.list td.cell-actions { justify-content: flex-start; padding-top: 10px; }
  table.list td.cell-select { display: flex; justify-content: flex-start; align-items: center; min-height: var(--tap); padding-bottom: 0; }
  table.list td.right { text-align: right; }
}

/* ---- selezione multipla --------------------------------------------- */

.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 14px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.bulk-bar .bulk-all { margin: 0; }
.bulk-bar .actions { margin-left: auto; }

/* ---- pagine e righe per pagina --------------------------------------- */

.list-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.per-page-label { display: flex; align-items: center; gap: 8px; min-height: var(--tap); }
.per-page-label select { width: auto; min-width: 70px; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 2.4rem; }

/* ---- filtri -------------------------------------------------------- */

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; flex: 1 1 160px; }
.filters .btn { flex: none; }


.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 18px 0; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; text-decoration: none; color: var(--text); }
.pagination .current { background: var(--text); color: #fff; border-color: var(--text); }
.pagination .disabled { opacity: .45; }

/* ---- schede di navigazione interne (tab) --------------------------- */
.tabs.tabs-wrap { flex-wrap: wrap; overflow: visible; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; scrollbar-width: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px; border-radius: 999px; text-decoration: none; color: var(--text); background: #fff; border: 1px solid var(--line); font-weight: 600; }
.tabs a.active { background: var(--text); color: #fff; border-color: var(--text); }

/* barre delle statistiche: niente librerie di grafici */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding-top: 8px; }
.bars .bar { flex: 1 1 0; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar:hover { background: var(--brand-dark); }
.bars-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 6px; }
.split { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.split:last-child { border-bottom: 0; }
.split > .num { white-space: nowrap; }
.split.total { font-weight: 800; border-top: 2px solid var(--text); border-bottom: 0; margin-top: 4px; padding-top: 10px; }
.meter { height: 10px; background: #E8E8E4; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--brand); }

/* ---- modali ---------------------------------------------------------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { margin-bottom: 14px; }
.modal-body ul { padding-left: 20px; margin: 6px 0; }

.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--brand-dark); border-radius: 50%; margin: 4px auto 14px; animation: ggspin .8s linear infinite; }
@keyframes ggspin { to { transform: rotate(360deg); } }

/* ---- accesso ------------------------------------------------------- */

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(circle at 20% 10%, #FBD5D5, transparent 55%), var(--bg); }
.auth .box { width: 100%; max-width: 400px; }

.auth .logo { display: block; margin: 0 auto 18px; width: 260px; }
.auth .claim { text-align: center; color: var(--muted); margin-bottom: 20px; font-family: "Courier New", monospace; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; }



input[readonly], select:disabled { background-color: #F1F1EF; color: var(--muted); cursor: not-allowed; }
.switch input:disabled + .track, .switch input:disabled ~ .text { opacity: .55; }

/* ---- stampa -------------------------------------------------------- */

@media print {
  .sidebar, .menu-basso, .topbar, .form-actions, .actions, .filters, .no-print { display: none !important; }
  .topbar, .main-wrap { margin: 0 !important; }
  body { background: #fff; }
}
/* ---- CertaStampa ------------------------------------------------------ */

/* Il nastro nero e rosso sotto la barra in alto, come sul sito. */
.topbar { border-bottom: 0; box-shadow: inset 0 -4px 0 #E00404, inset 0 -8px 0 #111111; padding-bottom: 14px; }
.sidebar .brand .brand-icon { width: 40px; height: 40px; border-radius: 9px; display: block; }
.sidebar .brand .brand-full { color: #fff; font: 700 1.25rem "Courier New", monospace; letter-spacing: -.02em; height: auto; }
.sidebar .brand .brand-full span { color: #FF6B61; }
.topbar .logo img { height: 30px; }
.stamp { display: inline-block; font: 700 .78rem/1 "Courier New", monospace; letter-spacing: .12em; text-transform: uppercase; padding: 5px 8px 4px; border: 2px solid currentColor; color: var(--brand); transform: rotate(-2deg); }
table.list td form.inline-toggle { display: inline-block; margin: 0; }
.badge-btn { display: inline-flex; align-items: center; min-height: var(--tap); min-width: var(--tap); padding: 0; border: 0; background: none; cursor: pointer; font: inherit; }
.badge-btn:hover .badge { filter: brightness(.95); box-shadow: 0 0 0 2px currentColor; }
.badge-btn:focus-visible { outline: 3px solid var(--accent, #E00404); outline-offset: 2px; }
/* Ordine delle campagne: simbolo da trascinare (solo dove c'è un mouse) e frecce su/giù, sempre. */
table.list td.cell-order { white-space: nowrap; width: 1%; }
table.list td.cell-order form { display: inline-block; margin: 0; }
.btn-order { min-width: var(--tap); padding: 6px 8px; }
.drag-handle { display: none; cursor: grab; font-size: 1.3rem; line-height: 1; padding: 0 8px; color: var(--muted); user-select: none; }
@media (hover: hover) and (pointer: fine) { .drag-handle { display: inline-block; } }
tr.is-dragging { opacity: .45; }
tr.drop-before { box-shadow: inset 0 3px 0 var(--accent, #E00404); }
tr.drop-after { box-shadow: inset 0 -3px 0 var(--accent, #E00404); }
@media (max-width: 1199px) { table.list td.cell-order { display: flex; justify-content: flex-start; gap: 6px; width: 100%; } table.list td.cell-order::before { content: none; } }

/* Scelta delle campagne da accoppiare: ogni voce ha l'anteprima, e quelle scelte sono evidenziate. */
.rot-list { display: grid; gap: 8px; margin: 10px 0; }
.rot-item { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.rot-item input { flex: none; width: 22px; height: 22px; }
.rot-item.is-on { background: #FDECEC; border-color: #E00404; box-shadow: inset 4px 0 0 #E00404; }
.rot-item.is-blocked { opacity: .55; cursor: not-allowed; }
.rot-item[hidden] { display: none; }
.rot-thumb { flex: none; width: 96px; height: 40px; display: grid; place-items: center; background: #ECECE8; border-radius: 4px; overflow: hidden; }
.rot-thumb img { width: 100%; height: 100%; object-fit: contain; }
.rot-text { min-width: 0; }
tr.is-companion { background: #FAFAF7; }
tr.is-companion td.cell-main .campaign-cell { padding-left: 22px; border-left: 3px solid var(--accent, #E00404); }
.rotation-order { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.rotation-order form { display: inline-block; margin: 0; }
.badge-rot { background: #FDECEC; color: #8A1111; }
/* Elenco delle campagne: a sinistra l'anteprima del banner com'è sul sito (intero, senza ritagli). */
.campaign-cell { display: flex; align-items: center; gap: 12px; }
.campaign-thumb { flex: none; width: 112px; height: 64px; display: grid; place-items: center; overflow: hidden; background: #ECECE8; border-radius: 6px; }
.campaign-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-sm { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; background: #ECECE8; flex: none; }
.title-cell { display: flex; gap: 12px; align-items: center; min-width: 0; }
.title-cell .row-title { overflow-wrap: anywhere; }
.status-pubblicato { background: var(--ok-soft); color: #14532D; }
.status-programmato { background: #E0E7FF; color: #3730A3; }
.status-revisione { background: var(--warn-soft); color: var(--warn); }
.status-bozza { background: #ECECE8; color: #444; }
.editor-wrap { border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.editor-wrap textarea { border: 0; min-height: 420px; }
.flags { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.media-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.media-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.media-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #ECECE8; }
.media-item .media-body { padding: 8px 10px; font-size: .82rem; display: flex; flex-direction: column; gap: 6px; }
.media-item .media-body input { min-height: 40px; font-size: .8rem; padding: 6px 8px; }
.key-preview { width: 48px; height: 48px; border-radius: 50%; background: #111; color: #fff; display: inline-grid; place-items: center; font: 700 1.3rem "Courier New", monospace; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #E00404; flex: none; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; }
.story-line { border-left: 3px solid var(--brand); margin: 6px 0 0 8px; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; }
.story-line .item { position: relative; }
.story-line .item::before { content: ""; position: absolute; left: -27px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); }
.story-line .item.current::before { background: var(--brand); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem; overflow-wrap: anywhere; }
/* Il campo per scegliere un file ha una larghezza sua che a 360 px non ci sta: lo si costringe nella scheda. */
.image-field .controls { min-width: 0; }
input[type=file] { width: 100%; }
@media (max-width: 479px) {
  .image-field .preview.wide { width: 100%; }
  .topbar .zone { display: none; }
}

/* ---- contatore di caratteri sotto i campi con un limite ------------- */
.char-counter { align-self: flex-end; margin-top: -2px; font-size: .78rem; line-height: 1.2; color: var(--muted); font-variant-numeric: tabular-nums; }
.char-counter.is-near { color: var(--warn); font-weight: 700; }
.char-counter.is-full { color: var(--danger); font-weight: 700; }

/* ---- stella «in evidenza» nella lista degli articoli --------------- */
.star { width: var(--tap); height: var(--tap); border: 0; border-radius: 10px; background: transparent; cursor: pointer; display: inline-grid; place-items: center; color: #B4B4AE; padding: 0; }
.star svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.star:hover { color: var(--brand); background: #F4F4F2; }
.star.is-on { color: var(--brand); }
.star.is-on svg { fill: currentColor; }
/* In evidenza ma oltre il limite dello slideshow: stella piena ma spenta, che aspetta il suo turno. */
.star.is-waiting { color: #C9A227; }
.star.is-waiting svg { fill: #F3E3A4; }
.cell-feature form { margin: 0; }
table.list th.cell-feature-head { white-space: nowrap; }
@media (max-width: 1199px) { table.list td.cell-feature { align-items: center; } }

/* ---- accesso e recupero della password ------------------------------ */
.auth .logo { filter: none; }
.auth-links { text-align: center; margin: 14px 0 0; font-size: .95rem; }
.auth-links a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---- galleria fotografica nel modulo dell'articolo ------------------ */
.gallery-admin { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.gallery-admin-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #FAFAF8; }
.gallery-admin-item img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; flex: none; background: #ECECE8; }
.gallery-admin-fields { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.gallery-admin-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 479px) { .gallery-admin-item { flex-direction: column; } .gallery-admin-item img { width: 100%; height: auto; aspect-ratio: 4 / 3; } }

/* Accesso con passkey: sotto il modulo di accesso, e il riquadro del profilo. */
.auth-passkey { margin-top: 14px; }
.auth-passkey[hidden], .auth-passkey [hidden] { display: none; }
