/* ACi.DO - foglio di stile unico (nuova grafica MIG-004, direzione A "Plancia").
   Ordine: caratteri, token e componenti, barra di caricamento, pagine pubbliche. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2) format("woff2");
}

/* ================================================================
   NUOVA GRAFICA (MIG-004, direzione A «Plancia»): token e componenti.
   Regole: nessun codice colore nei componenti, tutto passa dalle variabili.
   ================================================================ */

:root {
  --font: "Atkinson Hyperlegible Next", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-code: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --fs: 14px; --h1: 1.5rem; --h2: 1.125rem; --h3: .9375rem;
  --bg: #F1F5F9; --surface: #FFFFFF; --surface-2: #F8FAFC; --border: #E2E8F0; --border-strong: #CBD5E1;
  --text: #0F172A; --muted: #64748B;
  --primary: #1D4ED8; --primary-hover: #1E40AF; --on-primary: #FFFFFF; --primary-bg: #DBEAFE; --primary-text: #1E3A8A;
  --link: #1D4ED8; --focus: #F59E0B;
  --acido: #B4E000; --accent: #B4E000; --accent-bg: #F3FAD6; --accent-text: #3F5A00; --accent-border: #D6EC7A;
  --ok: #15803D; --ok-bg: #DCFCE7; --warn: #B45309; --warn-bg: #FEF3C7; --danger: #B91C1C; --danger-bg: #FEE2E2;
  --sidebar: #0F172A; --sidebar-text: #CBD5E1; --sidebar-hover: #1E293B; --sidebar-group: #64748B; --sidebar-muted: #94A3B8;
  --code-mark: #E3F39E;
  --lock-bg: #C5D3CC; --lock-text: #4B6358; --lock-surface: #EEF3F0;
  --text-2: #475569; --text-3: #334155; --surface-3: #F6F8FB; --acido-hover: #C6EE1A;
  /* il verde acido non è mai colore di testo su fondo chiaro: qui solo su fondo scuro (--acido-su-scuro) o come segno decorativo (--acido-deco) */
  --acido-su-scuro: var(--acido); --acido-deco: var(--acido);
  --r: 6px; --r-card: 8px; --ctl: 34px; --cell-y: 7px; --cell-x: 10px; --gap: 16px; --card-pad: 16px;
  --th-bg: var(--surface-2); --row-hover: var(--surface-2); --side: 236px;
  --shadow: rgba(15, 23, 42, .14); --scrim: rgba(15, 23, 42, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.45; color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--link); }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; }
h1 { font-size: var(--h1); } h2 { font-size: var(--h2); } h3 { font-size: var(--h3); }
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { vertical-align: -3px; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
input, select { height: var(--ctl); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); min-width: 0; width: 100%; }
/* freccia dei selettori disegnata con due sfumature: la CSP ammette immagini solo dallo stesso sito, quindi niente data: URI */
select { padding-right: 28px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input::placeholder { color: var(--muted); }
input:disabled, select:disabled { background-color: var(--surface-2); color: var(--muted); }

/* pulsanti */
.btn { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl); padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn.icon { width: var(--ctl); padding: 0; justify-content: center; border-color: transparent; background: transparent; }
.btn.icon:hover { background: var(--surface-2); border-color: var(--border); }
.btn.small { height: 28px; padding: 0 10px; font-size: .875rem; }
.btn.right { margin-left: auto; }
.btn.is-busy, .btn[aria-busy="true"] { opacity: .7; cursor: wait; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* badge, punti, testi secondari */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.6; border: 1px solid transparent; vertical-align: middle; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge.alias { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-border); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.role-super { background: var(--primary); color: var(--on-primary); }
.badge.role-admin { background: var(--primary-bg); color: var(--primary-text); }
.badge.role-user { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-right: 6px; }
.dot.on { background: var(--ok); }
.muted { color: var(--muted); }
.sub { font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.cat { display: inline-block; font-size: .75rem; padding: 0 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); }
.cat.none { border: 0; background: none; color: var(--muted); }
.hint { font-size: .8125rem; color: var(--muted); }
.hint.inline { display: inline; }
.lead { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: var(--gap); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .875rem; color: var(--muted); display: flex; gap: 8px; margin-bottom: 8px; }

/* messaggi di esito */
.flash { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; margin-bottom: var(--gap); border-radius: var(--r); border: 1px solid transparent; font-size: var(--fs); }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.flash.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); font-weight: 600; }
.flash .ic { margin-top: 2px; }

/* barra strumenti, filtri */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar select { width: auto; }
.search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 420px; }
.search .ic { position: absolute; left: 10px; color: var(--muted); }
.search input { padding-left: 32px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: var(--ctl); padding: 0 6px 0 10px; border: 1px solid var(--primary); color: var(--primary-text); background: var(--primary-bg); border-radius: 999px; font-size: .875rem; }
.chip button, .chip a { border: 0; background: none; display: inline-flex; padding: 2px; border-radius: 50%; cursor: pointer; color: inherit; }
.count { margin-left: auto; color: var(--muted); font-size: .875rem; white-space: nowrap; }

/* tabelle */
.table-wrap { overflow-x: auto; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.tbl { width: 100%; border-collapse: collapse; table-layout: auto; }
.tbl.links, .tbl.users { table-layout: fixed; }
.tbl.users .col-company { width: 150px; } .tbl.users .col-company .sub { font-size: .8125rem; color: var(--muted); }
.tbl.users .col-company a { font-weight: 600; overflow-wrap: anywhere; }
.tbl .grp th { background: var(--th-bg); color: var(--text); font-size: .875rem; position: static; padding-top: 8px; padding-bottom: 8px; }
.tbl .grp th a { font-weight: 600; }
.tbl.users .col-role { width: 100px; } .tbl.users .col-bool { width: 56px; } .tbl.users .col-num { width: 84px; white-space: nowrap; }
.tbl.users .col-doms { width: 150px; } .tbl.users .col-links { width: 56px; } .tbl.users .col-last { width: 104px; white-space: nowrap; } .tbl.users .col-act { width: 150px; }
.tbl th, .tbl td { text-align: left; vertical-align: middle; padding: var(--cell-y) var(--cell-x); border-bottom: 1px solid var(--border); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl th { font-size: .8125rem; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--th-bg); position: sticky; top: 0; z-index: 1; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tr.is-off td { color: var(--muted); }
.tbl tr.is-off .avatar { opacity: .6; }
.sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; font-weight: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; text-decoration: none; }
.sort.active { color: var(--text); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .55; }
.row-actions form { margin: 0; display: inline-flex; }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
.tbl tr.is-sel td { background: var(--primary-bg); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .ic { color: var(--border-strong); }
.empty p { color: var(--text); font-weight: 600; }
.tbl td.empty-cell { padding: 0; border-bottom: 0; }

/* paginazione */
.pager { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; font-size: .875rem; color: var(--muted); }
.pager label { display: flex; align-items: center; gap: 6px; }
.pager select { width: auto; height: 30px; }
.pager .pages { margin-left: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager .pages a { padding: 4px 8px; border-radius: var(--r); text-decoration: none; color: var(--text); }
.pager .pages a:hover { background: var(--surface); }
.pager .pages a.cur { background: var(--primary); color: var(--on-primary); }
.pager .pages a[aria-disabled=true] { color: var(--muted); pointer-events: none; }
.pager .gap { padding: 4px 2px; }

/* moduli */
.form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form.stack { flex-direction: column; align-items: stretch; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.field.grow { flex: 1 1 280px; }
.field.act { flex-direction: row; gap: 8px; align-items: center; }
.field label, .field .label { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.form .hint { flex-basis: 100%; }
/* casella di spunta con la sua etichetta sulla stessa riga (le regole globali di input danno larghezza 100% e altezza del controllo) */
.check, .field label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; min-height: var(--ctl); font-size: var(--fs); font-weight: 500; color: var(--text); cursor: pointer; }
.check input[type=checkbox] { width: auto; height: auto; flex: none; margin: 0; padding: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; height: var(--ctl); font-weight: 500 !important; color: var(--text) !important; font-size: var(--fs) !important; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; margin: 0; padding: 0; border: 0; cursor: pointer; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: left .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { left: 18px; }
.switch.lock input:checked { background: var(--lock-bg); }
.switch.lock .state { display: inline-flex; align-items: center; gap: 5px; color: var(--lock-text); font-weight: 500; }
.switch.is-unlocked input, .switch.is-unlocked input:checked { background: var(--danger); }
.switch.is-unlocked .state { color: var(--danger); font-weight: 700; }
.badge.locked { background: var(--lock-surface); color: var(--lock-text); border-color: var(--lock-bg); }
.badge.unlocked { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); font-weight: 700; }
.badge .ic { vertical-align: -2px; }
.th-sub { display: block; font-size: .6875rem; font-weight: 500; color: var(--muted); }
.lock-summary { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 var(--gap); padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--lock-bg); background: var(--lock-surface); color: var(--lock-text); font-size: var(--fs); }
.lock-summary.is-exc { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.lock-summary ul { margin: 4px 0 0; padding-left: 18px; }
.lock-summary .ic { margin-top: 2px; flex: none; }
.unlock-txt { color: var(--danger); font-weight: 700; }
tr.is-unlock td { background: var(--danger-bg); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
.changed { border-color: var(--warn) !important; box-shadow: 0 0 0 3px var(--warn-bg); }
.unsaved { display: flex; align-items: center; gap: 6px; font-size: .875rem; color: var(--warn); background: var(--warn-bg); padding: 8px 10px; border-radius: var(--r); flex-basis: 100%; }
.req { font-weight: 500; color: var(--muted); font-size: .75rem; margin-left: 4px; }
.field-error { font-size: .8125rem; color: var(--danger); font-weight: 600; }
.has-error .pills { padding: 6px; border: 1px solid var(--danger); border-radius: var(--r); background: var(--danger-bg); }

/* selettore dei domini (pillole) e domini nella tabella */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { position: relative; display: inline-flex; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-block; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: .875rem; cursor: pointer; background: var(--surface); user-select: none; }
.pill input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pill input:checked + span::before { content: "✓ "; font-size: .8em; }
.pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.doms { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.dom { display: inline-block; font-size: .75rem; padding: 0 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dom.all { color: var(--muted); }
.dom.more { background: transparent; }

/* utente: avatar, email, nome */
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user > div { min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-bg); color: var(--primary-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.col-user strong { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-user .sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.col-user .sub .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.col-user .sub .badge { flex: none; }
code { font-family: var(--font-code); font-size: .9em; background: var(--surface-2); padding: 0 4px; border-radius: 3px; }
.env { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); background: var(--warn-bg); padding: 2px 8px; border-radius: 999px; }

/* il codice breve: il tratto di evidenziatore giallo sotto le lettere (il segno distintivo) */
.code { font-family: var(--font-code); font-weight: 700; font-size: 1.0625rem; color: var(--text); text-decoration: none; letter-spacing: .01em; }
/* evidenziatore solo dove il codice è il contenuto (dettaglio, «Link creato», QR, pagina intermedia), mai nelle tabelle */
.code.big, .flash .code, .linkbox .code { background: linear-gradient(transparent 56%, var(--code-mark) 56%, var(--code-mark) 92%, transparent 92%); padding: 0 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.code.big { font-size: 2.25rem; }

/* schede, indicatori, periodo, grafici, dettaglio (per i gruppi successivi) */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--card-pad); margin-bottom: var(--gap); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.kpi { position: relative; display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.kpi .k { font-size: .8125rem; color: var(--muted); }
.kpi strong { font-size: 1.75rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: .75rem; color: var(--muted); }
.period { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r); overflow: hidden; flex-wrap: wrap; }
.period button { border: 0; background: var(--surface); padding: 0 12px; height: 32px; cursor: pointer; border-right: 1px solid var(--border); }
.period button:last-child { border-right: 0; }
.period button[aria-pressed=true] { background: var(--primary); color: var(--on-primary); }

/* ---- struttura delle pagine dell'area riservata ---- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side); flex: none; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: var(--on-primary); font-weight: 800; font-size: 1.125rem; text-decoration: none; letter-spacing: .02em; }
.brand .mark { width: 30px; height: 30px; border-radius: 7px; background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sidebar nav { flex: 1; overflow: auto; }
.sidebar ul { list-style: none; margin: 0; padding: 6px 10px; }
.sidebar .grp { font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-group); padding: 14px 10px 4px; font-weight: 700; }
.sidebar li a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--sidebar-text); text-decoration: none; font-weight: 500; }
.sidebar li a:hover { background: var(--sidebar-hover); color: var(--on-primary); }
.sidebar li a[aria-current=page] { background: var(--primary); color: var(--on-primary); }
.side-foot { border-top: 1px solid var(--sidebar-hover); padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-size: .8125rem; }
.side-foot .me { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; }
.side-foot .me > div { min-width: 0; }
.side-foot strong { display: block; color: var(--on-primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot span { color: var(--sidebar-muted); }
.side-foot form { margin: 0; }
.side-foot .btn.icon { color: var(--sidebar-text); }
.side-foot .btn.icon:hover { background: var(--sidebar-hover); border-color: var(--sidebar-hover); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 52px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 5; }
.topbar .menu { display: none; }
.topbar .search { max-width: 520px; }
.topbar .env { margin-left: auto; }
.content { padding: 20px 24px 40px; max-width: 1800px; }
.backdrop { display: none; position: fixed; inset: 0; background: var(--scrim); z-index: 20; }

/* pannello laterale (creazione e modifica) */
.with-drawer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.with-drawer.closed { grid-template-columns: minmax(0, 1fr); }
.drawer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; position: sticky; top: 72px; box-shadow: 0 8px 24px var(--shadow); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 1rem; overflow-wrap: anywhere; }
.drawer .form { flex-direction: column; align-items: stretch; }
.drawer .field { min-width: 0; flex: none; }
.drawer .field.act { flex-direction: row; flex-wrap: wrap; }
.drawer .switch { height: 30px; }
.drawer-foot { margin-top: 12px; font-size: .875rem; }
@media (min-width: 1101px) {
  .with-drawer:not(.closed) .tbl.links .col-tot, .with-drawer:not(.closed) .tbl.links .col-date,
  .with-drawer:not(.closed) .tbl.users .col-last, .with-drawer:not(.closed) .tbl.users .col-links,
  .with-drawer:not(.closed) .tbl.users .col-bool, .with-drawer:not(.closed) .tbl.users .col-num { display: none; }
  .with-drawer:not(.closed) .tbl.links .col-code { width: 160px; }
}

/* dettaglio (gruppo 2) */
.detail-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.detail-side .card { margin-bottom: 16px; }
.detail-side .form { flex-direction: column; align-items: stretch; }
.detail-side .field { flex: none; }
.detail-side .field.act { flex-direction: row; }

@media (max-width: 1600px) {
  .tbl.users .col-act { width: 84px; }
  .row-actions .btn.small .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .row-actions .btn.small { width: var(--ctl); padding: 0; justify-content: center; border-color: transparent; background: transparent; }
}
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .with-drawer, .with-drawer.closed { grid-template-columns: minmax(0, 1fr); }
  .drawer { position: fixed; right: 0; top: 0; height: 100vh; width: min(420px, 100vw); z-index: 25; overflow-y: auto; border-radius: 0; box-shadow: 0 0 40px var(--shadow); }
  .backdrop:not([hidden]) { display: block; }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; visibility: hidden; transform: translateX(-100%); transition: transform .18s ease, visibility .18s; }
  .nav-open .sidebar { visibility: visible; transform: none; }
  .topbar { padding: 0 12px; }
  .topbar .menu { display: inline-flex; }
  .content { padding: 14px 12px 32px; }
  .search.global { max-width: none; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-actions { opacity: 1; }
  .toolbar select { flex: 1 1 45%; }
  .count { margin-left: 0; flex-basis: 100%; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; justify-content: center; }
  .pager .pages { margin-left: 0; }
  /* tabelle -> schede: una riga per elemento, campi secondari con etichetta */
  .table-wrap { border-radius: var(--r); }
  .tbl.users { table-layout: auto; display: block; width: 100%; }
  .tbl.users thead, .tbl.users .col-last, .tbl.users .col-links { display: none; }
  .tbl.users tbody { display: block; }
  .tbl.users tr { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .tbl.users tr:last-child { border-bottom: 0; }
  .tbl.users td { display: block; padding: 0; border: 0; width: auto !important; text-align: left; }
  .tbl.users .col-user { flex: 1 1 calc(100% - 100px); order: 1; min-width: 0; }
  .tbl.users .col-act { order: 2; }
  .tbl.users .col-doms { order: 4; flex-basis: 100%; }
  .tbl.users .col-doms::before { content: "Domini: "; color: var(--muted); font-size: .8125rem; }
  .tbl.users .col-role, .tbl.users .col-bool, .tbl.users .col-num { order: 3; font-size: .8125rem; display: inline-flex; align-items: center; gap: 4px; }
  .tbl.users td.col-bool:nth-of-type(3)::before { content: "Attivo: "; color: var(--muted); }
  .tbl.users td.col-bool:nth-of-type(4)::before { content: "Alias: "; color: var(--muted); }
  .tbl.users td.col-num:nth-of-type(5)::before { content: "Min. "; color: var(--muted); }
  .tbl.users td.col-num:nth-of-type(6)::before { content: "Limite 24 h: "; color: var(--muted); }
  .tbl.users td.empty-cell { flex-basis: 100%; }
  .row-actions .btn.small { width: auto; padding: 0 10px; border-color: var(--border-strong); background: var(--surface); }
  .row-actions .btn.small .lbl { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .empty { padding: 28px 12px; }
}

/* ---- I miei link (gruppo 2): tabella, pannello con schede, messaggio di creazione, copia ---- */
.tbl.links .col-code { width: 190px; } .tbl.links .col-30 { width: 96px; } .tbl.links .col-tot { width: 84px; }
.tbl.links .col-date { width: 112px; } .tbl.links .col-state { width: 92px; } .tbl.links .col-act { width: 118px; }
.tbl.links th:first-child, .tbl.links td:first-child, .tbl.users th:first-child, .tbl.users td:first-child { padding-left: 12px; }
.col-code, .col-dest { white-space: nowrap; }
.col-dest .sub { white-space: normal; }
.tbl.links .col-code .code { vertical-align: baseline; }
.dest { color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.dest:hover { text-decoration: underline; color: var(--link); }
.tbl tr.is-off .code { opacity: .65; }
.tbl tr.is-new td { background: var(--ok-bg); }
.tbl tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.tbl.links .col-state .badge { min-width: 56px; text-align: center; }
.flash span { min-width: 0; overflow-wrap: anywhere; }
.flash .btn { margin-left: auto; flex: none; }
.drawer .tabs-row { display: flex; gap: 4px; margin: -4px 0 14px; border-bottom: 1px solid var(--border); }
.tab { padding: 8px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.drawer [hidden], .field[hidden] { display: none !important; }
[data-copy] { position: relative; }
[data-copy].copied::after { content: "Copiato"; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); font-size: .75rem; font-weight: 600; line-height: 1.4; padding: 2px 8px; border-radius: 4px; white-space: nowrap; z-index: 6; pointer-events: none; }
.brand .mark svg { display: block; width: 30px; height: 30px; }

/* ---- dettaglio link (gruppo 2) ---- */
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.card > h3, .card-head h3 { font-size: var(--h3); }
.card > h3 { margin-bottom: 10px; }
.linkbox .short { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.linkbox .pre { color: var(--muted); font-size: 1.125rem; overflow-wrap: anywhere; }
.linkbox .btns { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: .875rem; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.qrbox { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.qr { border: 1px solid var(--border); border-radius: var(--r); flex: none; background: var(--surface); image-rendering: pixelated; }
.qr-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-direction: column; }
.qrbox .hint { flex-basis: 100%; }
.detail-main > .card:first-child { margin-top: 0; }
.period a { display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; height: 32px; text-decoration: none; color: var(--text); background: var(--surface); border-right: 1px solid var(--border); font-size: .875rem; }
.period a:last-child { border-right: 0; }
.period a:hover { background: var(--surface-2); }
.period a[aria-current="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart text { fill: var(--muted); font-family: var(--font); font-size: 12px; }
.chart .bar { fill: var(--primary); }
.chart .bar2 { fill: var(--accent); }
.legend { font-size: .8125rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; display: inline-block; border-radius: 2px; background: var(--primary); }
.legend i.l2 { background: var(--accent); margin-left: 6px; }
.chart-card details { margin-top: 10px; }
.chart-card summary, .card summary { cursor: pointer; color: var(--link); font-size: .875rem; }
.chart-card details .table-wrap { margin-top: 8px; max-height: 320px; overflow: auto; }
.tbl.mini th, .tbl.mini td { padding: 6px 8px; font-size: .875rem; }
.tbl.mini td.col-share { width: 26%; min-width: 64px; }
.tbl.mini tbody tr:last-child td { border-bottom: 0; }
.stat-card h3 { margin-bottom: 6px; }
.stat-card .tbl td:first-child { overflow-wrap: break-word; min-width: 7rem; }
svg.share { display: block; width: 100%; height: 8px; }
.share .bg { fill: var(--border); }
.share .fill { fill: var(--primary); }
.export { margin: 12px 0; }
.detail-main > .hint { margin-top: 4px; }

/* ---- statistiche personali e del portale (gruppo 3) ---- */
.content > .hint { margin: 4px 0 var(--gap); }
.tbl.top { table-layout: fixed; }
.tbl.top .col-code { width: 200px; } .tbl.top .col-clic, .tbl.top .col-qr { width: 76px; } .tbl.top .col-tot { width: 90px; }
.tbl.top th:first-child, .tbl.top td:first-child { padding-left: 12px; }
.tbl.top td.col-code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .empty { padding: 24px 16px; }
.stat-card .meta { margin-top: 2px; }

/* ---- tentativi falliti: report del portale e link disattivati dell'utente ---- */
.tbl.tent .col-tot { width: 96px; }
.tbl.tent .col-last, .tbl.tent .col-dom, .tbl.tent .col-reason { white-space: nowrap; }
.tbl.tent th:first-child, .tbl.tent td:first-child { padding-left: 12px; }
.dead-card { min-width: 0; }
.dead-card .meta { margin-bottom: 8px; }
.dead-card .dest { max-width: 100%; }

@media (max-width: 1100px) {
  .tbl.links .col-code { width: 170px; }
}
@media (max-width: 640px) {
  .period { width: 100%; }
  .period a { flex: 1 1 auto; border-bottom: 1px solid var(--border); }
  /* l'elenco dei link diventa una pila di schede: codice e stato, destinazione, clic 30 gg e azioni */
  .tbl.links { table-layout: auto; display: block; width: 100%; }
  .tbl.links thead, .tbl.links .col-tot, .tbl.links .col-date { display: none; }
  .tbl.links tbody { display: block; }
  .tbl.links tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center; }
  .tbl.links tr:last-child { border-bottom: 0; }
  .tbl.links td { display: block; padding: 0; border: 0; width: auto !important; text-align: left; min-width: 0; }
  .tbl.links th:first-child, .tbl.links td:first-child { padding-left: 0; }
  .tbl.links .col-code { grid-column: 1; grid-row: 1; }
  .tbl.links .col-state { grid-column: 2; grid-row: 1; justify-self: end; }
  .tbl.links .col-dest { grid-column: 1 / -1; grid-row: 2; }
  .tbl.links .col-dest .sub { display: inline; margin-left: 6px; }
  .tbl.links .col-30 { grid-column: 1; grid-row: 3; font-size: .8125rem; color: var(--muted); text-align: left; }
  .tbl.links .col-30::before { content: "Clic 30 gg: "; }
  .tbl.links .col-act { grid-column: 2; grid-row: 3; }
  .tbl.links td.empty-cell { grid-column: 1 / -1; }
  /* i link più cliccati diventano schede: codice e totale, destinazione, clic e QR */
  .tbl.top { table-layout: auto; display: block; width: 100%; }
  .tbl.top thead { display: none; }
  .tbl.top tbody { display: block; }
  .tbl.top tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center; }
  .tbl.top tr:last-child { border-bottom: 0; }
  .tbl.top td { display: block; padding: 0; border: 0; width: auto !important; min-width: 0; }
  .tbl.top th:first-child, .tbl.top td:first-child { padding-left: 0; }
  .tbl.top .col-code { grid-column: 1; grid-row: 1; }
  .tbl.top .col-tot { grid-column: 2; grid-row: 1; }
  .tbl.top .col-tot::after { content: " visite"; font-weight: 400; color: var(--muted); font-size: .8125rem; }
  .tbl.top .col-dest { grid-column: 1 / -1; grid-row: 2; }
  .tbl.top .col-clic, .tbl.top .col-qr { font-size: .8125rem; color: var(--muted); grid-row: 3; }
  .tbl.top .col-clic { grid-column: 1; text-align: left; }
  .tbl.top .col-qr { grid-column: 2; }
  .tbl.top .col-clic::before { content: "Clic: "; }
  .tbl.top .col-qr::before { content: "QR: "; }
  .linkbox .pre { font-size: 1rem; }
  .code.big { font-size: 1.875rem; }
  .flash { flex-wrap: wrap; }
  .flash .btn { margin-left: 26px; }
}

/* ---- categorie, parole riservate, blocchi, chiavi API (gruppo 4) ---- */
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-primary); }
.btn.danger:hover { background: var(--danger); opacity: .9; }
.tbl.cats, .tbl.reserved, .tbl.keys { table-layout: fixed; }
.tbl.cats th:first-child, .tbl.cats td:first-child, .tbl.reserved th:first-child, .tbl.reserved td:first-child,
.tbl.blocks th:first-child, .tbl.blocks td:first-child, .tbl.keys th:first-child, .tbl.keys td:first-child { padding-left: 12px; }
.tbl.cats .col-num { width: 96px; } .tbl.cats .col-act { width: 96px; }
.tbl.cats .col-name strong, .tbl.reserved .col-word strong { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl.reserved .col-word { width: 200px; } .tbl.reserved .col-where { width: 210px; } .tbl.reserved .col-date { width: 112px; } .tbl.reserved .col-act { width: 120px; }
.tbl.reserved .col-note { overflow-wrap: anywhere; }
.tbl.reserved .col-word strong { display: inline-block; max-width: 100%; vertical-align: middle; }
.tbl.blocks .col-dom { width: 230px; }
.tbl.blocks th.col-type { white-space: normal; }
.tbl.blocks td.col-type { white-space: nowrap; }
.tbl.blocks .col-dom strong { font-weight: 600; }
.swform { margin: 0; display: block; }
.switch .state { white-space: nowrap; }
.stack-gap { margin-top: var(--gap); }
.intro { margin: 0 0 12px; max-width: 90ch; }
.foot-note { margin-top: 10px; }
.card.narrow { max-width: 640px; }
.card .table-wrap { background: var(--surface); }
.card > .hint { margin-top: 10px; }
.tbl.reserved .col-where .dom { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.flags .badge { border-radius: 12px; }
.tbl.mini td code { font-size: .875rem; }
@media (min-width: 1101px) {
  .with-drawer:not(.closed) .tbl.reserved .col-date, .with-drawer:not(.closed) .tbl.reserved .col-note { display: none; }
}

/* chiavi API: tabella a tutta larghezza e righe dell'estensione che si aprono */
.tbl.keys td { vertical-align: top; }
.tbl.keys .col-user { width: 230px; } .tbl.keys .col-key { width: 170px; } .tbl.keys .col-bool { width: 76px; }
.tbl.keys .col-when { width: 170px; } .tbl.keys .col-limit { width: 128px; }
.tbl.keys .col-key, .tbl.keys .col-when { overflow-wrap: anywhere; }
.tbl.keys .col-user .user { align-items: flex-start; }
.tbl.keys .col-user .sub { display: block; }
.tbl.keys .col-user .sub .nm { white-space: normal; }
.tbl.keys .col-user strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.flags .badge { white-space: normal; }
.kdoms { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.warnline { color: var(--warn); font-weight: 600; margin-bottom: 6px; }
.tbl.keys .rule { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); font-size: .875rem; }
.keys-card .card-head { margin-bottom: 10px; }
.extlist { border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.ext-head, .ext > summary { display: grid; grid-template-columns: minmax(0, 1fr) 110px 160px 180px; gap: 12px; align-items: center; padding: 8px 12px; }
.ext-head { font-size: .8125rem; color: var(--muted); font-weight: 600; background: var(--th-bg); border-bottom: 1px solid var(--border); }
.ext { border-bottom: 1px solid var(--border); }
.ext:last-child { border-bottom: 0; }
.ext > summary { cursor: pointer; list-style: none; color: var(--text); font-size: var(--fs); }
.ext > summary::-webkit-details-marker { display: none; }
.ext > summary:hover { background: var(--row-hover); }
.ext-user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ext-user::before { content: "›"; flex: none; width: 12px; color: var(--muted); font-size: 1.25rem; line-height: 1; transition: transform .12s; }
.ext[open] .ext-user::before { transform: rotate(90deg); }
.ext-user .user { min-width: 0; }
.ext-user .user strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ext .table-wrap { margin: 0 12px 12px; }
.extlist > .empty { padding: 28px 12px; }

@media (max-width: 1100px) {
  .tbl.keys .col-user { width: 200px; } .tbl.keys .col-key { width: 140px; } .tbl.keys .col-when { width: 140px; }
  .ext-head, .ext > summary { grid-template-columns: minmax(0, 1fr) 90px 140px 150px; }
}
@media (max-width: 640px) {
  /* tabelle a schede: la prima cella in grande, le altre con la loro etichetta */
  .tbl.cards { table-layout: auto; display: block; width: 100%; }
  .tbl.cards thead { display: none; }
  .tbl.cards tbody { display: block; }
  .tbl.cards tr { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .tbl.cards tr:last-child { border-bottom: 0; }
  .tbl.cards td { display: block; padding: 0 !important; border: 0; width: auto !important; text-align: left; min-width: 0; font-size: .875rem; }
  .tbl.cards td:first-child { flex: 1 1 100%; font-size: var(--fs); }
  .tbl.cards td[data-label]:not(:first-child)::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8125rem; }
  .tbl.cards td.col-act { margin-left: auto; }
  .tbl.cards td.col-rule, .tbl.cards td.col-user, .tbl.cards td.col-type { flex: 1 1 100%; }
  .tbl.cards td.col-type { white-space: normal; }
  .tbl.cards td.num { text-align: left; }
  .tbl.cards td.empty-cell { flex-basis: 100%; }
  .tbl.keys td.col-rule::before { display: block; }
  .tbl.blocks tr { gap: 8px 14px; }
  .tbl.blocks td.col-dom { padding-bottom: 4px !important; }
  .ext-head { display: none; }
  .ext > summary { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .ext-user { grid-column: 1 / -1; }
  .ext > summary > [data-label] { font-size: .875rem; }
  .ext > summary > [data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8125rem; }
}

/* attesa: barra sottile in alto mentre una pagina si carica o un modulo viene inviato (script in app.js) */
.wait-bar { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 1000; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .1s; }
html.waiting .wait-bar { opacity: 1; }
.wait-bar::before { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--primary); animation: wait-slide 1.1s ease-in-out infinite; }
@keyframes wait-slide { from { left: -40%; } to { left: 100%; } }
html.waiting { cursor: progress; }
.wait-msg { position: fixed; bottom: 16px; right: 16px; z-index: 1000; max-width: min(360px, calc(100vw - 24px)); padding: 10px 14px; background: var(--text); color: #fff; border-radius: 6px; font-size: var(--fs); }
.wait-msg:empty { display: none; }
button:disabled, button[aria-disabled="true"] { cursor: progress; opacity: .75; }
button.busy:not(.link)::after { content: ""; display: inline-block; width: 1em; height: 1em; margin-left: 8px; vertical-align: -0.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: wait-spin .8s linear infinite; }
@keyframes wait-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  /* barra ferma e piena, niente rotellina: restano il testo "…" del pulsante e la barra */
  .wait-bar::before { left: 0; width: 100%; opacity: .8; }
  button.busy::after { display: none; }
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  button:active, .btn:active { transform: none; }
}


/* ================================================================
   PAGINE PUBBLICHE (accesso, password, inviti, home dei domini, non trovato, pagina intermedia).
   Nessuna barra laterale: logo in alto, una colonna centrata (420 px per i moduli, 720 px per i testi), piè con ABIRK SA.
   Stessi token e stessi componenti (.field, .btn, .flash) dell'area riservata. Nessun codice colore: tutto passa dalle variabili.
   ================================================================ */
.pub { min-height: 100vh; display: flex; flex-direction: column; }
.pub-top { padding: 20px 24px 0; }
.pub-logo, .pub-logo-v { display: inline-block; line-height: 0; border-radius: var(--r); }
.pub-logo svg { height: 40px; width: auto; max-width: 100%; display: block; }
.pub-logo-v { align-self: center; margin-bottom: 20px; }
.pub-logo-v svg { height: 112px; width: auto; display: block; }
.pub-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: clamp(24px, 9vh, 88px) 16px 40px; }
.pub-col { width: 100%; display: flex; flex-direction: column; min-width: 0; }
.pub-col.form { max-width: 420px; }
.pub-col.text { max-width: 720px; }
.pub-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 28px; min-width: 0; }
.pub-card h1 { margin-bottom: 8px; overflow-wrap: anywhere; }
.pub-card .lead { margin: 0 0 20px; max-width: none; }
.pub-card .flash { margin-bottom: 16px; }
/* moduli: controlli da 40 px per il tocco */
.pub-card .form.stack { gap: 16px; }
.pub-card input, .pub-card .btn { height: 40px; }
.pub-card .btn { justify-content: center; }
.pub-card .form .btn.primary { width: 100%; }
.pub-card .forgot { margin: -6px 0 0; font-size: .875rem; text-align: right; }
.pub-card .alt-login { margin: 14px 0 0; text-align: center; }
.pub-card .alt-login .btn { width: 100%; justify-content: center; }
.pub-card .pub-alt { margin-top: 20px; font-size: .875rem; text-align: center; }
.pub-card .pub-actions { margin-top: 20px; }
.pub-card .pub-actions .btn { height: auto; min-height: 40px; padding-top: 6px; padding-bottom: 6px; white-space: normal; text-align: center; }
.pub-card .rules { font-size: .8125rem; color: var(--muted); margin-bottom: 16px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.pub-card .rules ul { margin: 4px 0 0; padding-left: 18px; }
.pub-card .rules li + li { margin-top: 2px; }
.pub-card .code { background: linear-gradient(transparent 56%, var(--code-mark) 56%, var(--code-mark) 92%, transparent 92%); padding: 0 3px; }
/* pagina intermedia */
.pub-card .kicker { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.pub-card .dest-box { margin: 4px 0 20px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); font-size: 1.0625rem; overflow-wrap: anywhere; word-break: break-word; }
.pub-card .dest-box a { color: var(--text); text-decoration: none; }
.pub-card .dest-box a:hover .d-host { background: var(--primary-bg); }
.pub-card .d-pre, .pub-card .d-rest { color: var(--muted); }
.pub-card .d-host { color: var(--primary-text); background: var(--primary-bg); border-radius: 4px; padding: 0 4px; font-weight: 700; }
.pub-card .count-line { display: flex; align-items: baseline; gap: 10px; font-size: 1.125rem; color: var(--muted); }
.pub-card .count-down { font-size: 3.5rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); min-width: 2ch; text-align: center; }
.pub-card .ad-slot { margin-top: 24px; min-height: 120px; border: 1px dashed var(--border-strong); border-radius: var(--r); background: var(--surface-2); }
.pub-card .cookie-note { margin-top: 10px; }
.pub-foot { text-align: center; font-size: .8125rem; color: var(--text); padding: 16px 16px 24px; }
@media (max-width: 640px) {
  .pub-top { padding: 16px 16px 0; }
  .pub-logo svg { height: 34px; }
  .pub-main { padding-top: 24px; }
  .pub-card { padding: 20px 16px; }
  .pub-card .count-down { font-size: 3rem; }
  .pub-logo-v svg { height: 92px; }
}

/* ===== Home pubblica di ogni dominio (MIG-014) ===== */
html { scroll-behavior: smooth; }
body.pub-site { background: var(--surface); line-height: 1.5; font-size: 1rem; }
.pub-site .ic { vertical-align: -4px; flex: none; }
.pub-site .btn { height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 700; gap: 8px; }
.pub-site .btn.small { height: 36px; padding: 0 14px; font-size: .9375rem; }
.pub-wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
/* testata: fondo bianco pieno, semi-trasparente con sfocatura dove il browser la sa fare */
.pub-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .pub-head { background: rgba(255, 255, 255, .9); -webkit-backdrop-filter: saturate(1.4) blur(8px); backdrop-filter: saturate(1.4) blur(8px); }
}
.pub-head .pub-wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.pub-marca { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; border-radius: var(--r); }
.pub-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; }
.pub-dot { color: var(--acido-deco); }
.pub-nav { display: flex; gap: 22px; align-items: center; }
.pub-nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.pub-nav a:hover { color: var(--text); }
/* eroe */
.pub-hero { position: relative; overflow: hidden; background: radial-gradient(900px 420px at 85% -10%, rgba(180, 224, 0, .22), transparent 60%), radial-gradient(700px 400px at -10% 110%, rgba(29, 78, 216, .10), transparent 60%), linear-gradient(180deg, var(--surface) 0%, var(--surface-3) 100%); }
.pub-hero .pub-wrap > * { min-width: 0; }
.pub-hero .pub-wrap { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 48px; align-items: center; padding-top: 72px; padding-bottom: 72px; }
.pub-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 999px; padding: 4px 12px; max-width: 100%; overflow-wrap: anywhere; }
.pub-hero h1 { font-size: clamp(2rem, 7vw, 3.5rem); overflow-wrap: anywhere; line-height: 1.05; letter-spacing: -.03em; margin: 18px 0 16px; }
.pub-acid { background: linear-gradient(transparent 58%, var(--code-mark) 58%, var(--code-mark) 92%, transparent 92%); padding: 0 .1em; }
.pub-lead { font-size: 1.25rem; color: var(--text-3); max-width: 52ch; margin: 0 0 28px; overflow-wrap: anywhere; }
.pub-cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pub-note { font-size: .9375rem; color: var(--text-2); margin: 14px 0 0; }
/* scheda dimostrativa: link lungo, link breve, QR */
.pub-demo { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px -24px rgba(15, 23, 42, .35); padding: 22px; }
.pub-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.pub-lbl { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); width: 72px; flex: none; }
.pub-long { font-family: ui-monospace, Consolas, monospace; font-size: .875rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; flex: 1; min-width: 0; }
.pub-short { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 2px; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
.pub-pre { color: var(--text-2); font-weight: 600; font-size: 1.25rem; }
.pub-code { background: linear-gradient(transparent 56%, var(--code-mark) 56%, var(--code-mark) 92%, transparent 92%); padding: 0 4px; }
.pub-arrow { display: flex; align-items: center; justify-content: center; color: var(--acido-deco); margin: -2px 0 -2px 72px; }
.pub-meta { display: flex; gap: 16px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .875rem; color: var(--text-2); flex-wrap: wrap; }
.pub-qr { width: 64px; height: 64px; flex: none; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.pub-beuta { position: absolute; right: -12px; top: -22px; line-height: 0; }
/* sezioni */
.pub-section { padding: 64px 0; scroll-margin-top: 64px; }
.pub-section.alt { background: var(--surface-3); }
.pub-section h2 { font-size: 1.875rem; letter-spacing: -.02em; margin: 0 0 8px; }
.pub-sub { color: var(--text-2); font-size: 1.0625rem; margin: 0 0 32px; max-width: 60ch; }
.pub-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; counter-reset: pubstep; }
.pub-step { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; position: relative; }
.pub-step::before { counter-increment: pubstep; content: counter(pubstep); display: inline-flex; width: 34px; height: 34px; border-radius: 50%; background: var(--text); color: var(--acido-su-scuro); font-weight: 700; align-items: center; justify-content: center; margin-bottom: 12px; }
.pub-step h3 { margin: 0 0 6px; font-size: 1.125rem; }
.pub-step p { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }
.pub-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pub-feature { display: flex; gap: 14px; padding: 18px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.pub-feature .ic { color: var(--primary); width: 24px; height: 24px; margin-top: 2px; }
.pub-feature > div { min-width: 0; }
.pub-feature h3 { margin: 0 0 4px; font-size: 1.0625rem; overflow-wrap: anywhere; }
.pub-feature p { margin: 0; color: var(--text-2); font-size: .9375rem; }
.pub-band { background: var(--text); color: var(--surface); padding: 56px 0; }
.pub-band .pub-wrap { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.pub-band h2 { margin: 0 0 6px; font-size: 1.75rem; letter-spacing: -.02em; }
.pub-band p { margin: 0; color: var(--border-strong); max-width: 56ch; }
.pub-site .pub-band .btn { background: var(--acido-su-scuro); border-color: var(--acido-su-scuro); color: var(--text); }
.pub-site .pub-band .btn:hover { background: var(--acido-hover); }
.pub-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--text-2); font-size: .875rem; }
.pub-footer .pub-wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.pub-footer a { color: var(--text-2); }
@media (max-width: 900px) {
  .pub-hero .pub-wrap { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 40px; padding-bottom: 48px; }
  .pub-steps, .pub-features { grid-template-columns: minmax(0, 1fr); }
  .pub-nav { display: none; }
  .pub-section { padding: 44px 0; }
}
@media (max-width: 640px) {
  .pub-wrap { padding: 0 16px; }
  .pub-demo { padding: 16px; }
  .pub-lbl { display: none; }
  .pub-arrow { margin-left: 0; }
  .pub-beuta { right: -4px; top: -26px; }
  .pub-cta .btn { flex: 1 1 100%; justify-content: center; }
  .pub-band .btn { width: 100%; justify-content: center; }
  .pub-short { font-size: 1.5rem; }
}

/* ===== Privacy e Cookie (MIG-014): testo in colonna leggibile ===== */
.pub-doc { max-width: 760px; margin: 0 auto; padding: 48px 0 72px; color: var(--text-3); font-size: 1.0625rem; line-height: 1.65; overflow-wrap: anywhere; }
.pub-doc h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); letter-spacing: -.02em; line-height: 1.15; color: var(--text); margin: 0 0 24px; }
.pub-doc h2 { font-size: 1.375rem; letter-spacing: -.01em; color: var(--text); margin: 40px 0 12px; }
.pub-doc h3 { font-size: 1.125rem; color: var(--text); margin: 28px 0 8px; }
.pub-doc p { margin: 0 0 16px; }
.pub-doc ul { margin: 0 0 16px; padding-left: 22px; }
.pub-doc li + li { margin-top: 8px; }
.pub-doc a { color: var(--primary); }
@media (max-width: 640px) {
  .pub-doc { padding: 28px 0 48px; font-size: 1rem; }
  .pub-doc h2 { margin-top: 32px; }
}

/* ===== Beuta animata (marchio): stati quieta / bollente / fatto ===== */
.anim-beuta { display: inline-block; vertical-align: middle; color: var(--text); }
.anim-beuta .liquido .onda { fill: var(--acido); }
.anim-beuta .bolle-dentro circle { fill: var(--surface); opacity: .9; }
.anim-beuta .bolle-fuori circle { fill: var(--acido); }
.anim-beuta .bolle-dentro .b2, .anim-beuta .bolle-dentro .b3, .anim-beuta .bolle-dentro .b4 { opacity: 0; }
.anim-beuta.is-quieta .bolle-dentro .b1 { animation: beuta-sale 4s ease-in infinite; }
.anim-beuta.is-bollente .liquido { animation: beuta-onda .9s linear infinite; }
.anim-beuta.is-bollente .bolle-dentro circle { opacity: .9; animation: beuta-sale 1.2s ease-in infinite; }
.anim-beuta.is-bollente .bolle-dentro .b2 { animation-delay: .3s; } .anim-beuta.is-bollente .bolle-dentro .b3 { animation-delay: .6s; } .anim-beuta.is-bollente .bolle-dentro .b4 { animation-delay: .9s; }
.anim-beuta.is-bollente .bolle-fuori circle { animation: beuta-pulsa 1.2s ease-in-out infinite; }
.anim-beuta.is-bollente .bolle-fuori .f2 { animation-delay: .4s; } .anim-beuta.is-bollente .bolle-fuori .f3 { animation-delay: .8s; }
.anim-beuta.is-fatto .bolle-fuori circle { transform-origin: center; transform-box: fill-box; animation: beuta-scoppia .9s ease-out 1 forwards; }
.anim-beuta.is-fatto .bolle-fuori .f2 { animation-delay: .12s; } .anim-beuta.is-fatto .bolle-fuori .f3 { animation-delay: .24s; }
.anim-beuta.is-fatto .bolle-dentro circle { opacity: 0; }
@keyframes beuta-onda { from { transform: translateX(0); } to { transform: translateX(-16px); } }
@keyframes beuta-sale { 0% { transform: translateY(0); opacity: .9; } 80% { opacity: .9; } 100% { transform: translateY(-14px); opacity: 0; } }
@keyframes beuta-pulsa { 0%, 100% { opacity: .35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@keyframes beuta-scoppia { 0% { transform: scale(1); opacity: 1; } 60% { transform: scale(1.9); opacity: .6; } 100% { transform: scale(2.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .anim-beuta * { animation: none !important; }
}

/* ===== Link non trovato (MIG-014): stessa testata e piè della home ===== */
.pub-404 { min-height: calc(100vh - 64px - 86px); display: flex; align-items: center; background: radial-gradient(800px 400px at 90% -10%, rgba(180, 224, 0, .18), transparent 60%), linear-gradient(180deg, var(--surface) 0%, var(--surface-3) 100%); }
.pub-404 .pub-wrap { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; padding-top: 56px; padding-bottom: 56px; }
.pub-404 .pub-wrap > * { min-width: 0; }
.pub-404 h1 { font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.03em; line-height: 1.05; margin: 14px 0 12px; overflow-wrap: anywhere; }
.pub-addr { font-family: ui-monospace, Consolas, monospace; font-size: 1.125rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: inline-flex; align-items: baseline; max-width: 100%; margin: 0; overflow-wrap: anywhere; }
.pub-addr-pre { color: var(--text-2); }
.pub-addr-code { background: linear-gradient(transparent 56%, var(--danger-bg) 56%, var(--danger-bg) 92%, transparent 92%); color: var(--danger); font-weight: 700; padding: 0 3px; }
.pub-tips { margin: 18px 0 24px; padding: 0; list-style: none; display: grid; gap: 10px; }
.pub-tips li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-3); }
.pub-tips .ic { color: var(--primary); margin-top: 3px; }
.pub-404-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 50px -24px rgba(15, 23, 42, .35); padding: 28px; text-align: center; line-height: 0; }
.pub-404-card p { color: var(--text-2); margin: 10px 0 0; line-height: 1.5; }
@media (max-width: 900px) {
  .pub-404 .pub-wrap { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .pub-404-card { order: -1; padding: 20px; }
}

/* ---- link su più domini (PR link-multidominio) ---- */
.tbl.links .col-code .doms { display: flex; gap: 4px; flex-wrap: wrap; white-space: normal; margin-top: 3px; }
.dom i { font-style: normal; font-weight: 600; }
.dom.off { color: var(--muted); background: transparent; border-style: dashed; text-decoration: line-through; text-decoration-color: var(--muted); }
.dom.off i { text-decoration: none; display: inline-block; }
.badge.part { background: var(--warn-bg); color: var(--warn); }
/* D55: stati del codice. Le etichette lunghe («Programmato dal 12/03 14:30») vanno a capo invece di allargare la pagina. */
.badge.wait { background: var(--primary-bg); color: var(--primary-text); border-color: var(--accent-border); }
.badge.sched { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-border); }
.badge.wait, .badge.sched { white-space: normal; max-width: 100%; border-radius: 12px; text-align: center; }
.dom.off.wait { text-decoration: none; border-style: solid; }
.tbl.links .col-state .badge.sched { min-width: 0; }
.tbl.links .col-user { width: 170px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.partials { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.partials li { display: flex; justify-content: space-between; gap: 12px; }
.linkbox .doms { display: flex; gap: 4px; flex-wrap: wrap; }
.domain-card .card-head { margin-bottom: 8px; }
.domain-card .btns form { display: inline-flex; }
.domain-card .hint { margin: 4px 0; }
.domain-nav { margin: 0 0 12px; max-width: 100%; overflow-x: auto; }
.card-head .period { max-width: 100%; }
.dompick .pills { margin-bottom: 6px; }

/* ---- domini dei clienti (tappa 6, passo 6): home personalizzata e «Non trovato» ----
   Il colore arriva da /static/colori/<hex>.css (--cust, --cust-ink, --cust-text, con contrasto AA); senza colore valgono quelli del portale. */
.cust { --c: var(--cust, var(--primary)); --c-ink: var(--cust-ink, var(--on-primary)); --c-text: var(--cust-text, var(--primary-text)); background: var(--surface); color: var(--text); }
.cust-site { background: var(--surface); margin: 0; }
.cust-wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.cust-head { background: var(--surface); border-bottom: 3px solid var(--c); }
.cust-head .cust-wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.cust-brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.cust-logo { display: block; max-height: 40px; width: auto; max-width: 200px; }
.cust-mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; background: var(--c); color: var(--c-ink); font-weight: 700; }
.cust-name { font-weight: 700; font-size: 1.125rem; overflow-wrap: anywhere; }
.cust-nav { display: flex; align-items: center; gap: 16px; }
.cust-link { color: var(--c-text); font-weight: 600; text-decoration: underline; }
.cust .btn.cust-btn { background: var(--c); border-color: var(--c); color: var(--c-ink); }
.cust .btn.cust-btn:hover { filter: brightness(.92); background: var(--c); }
.cust-main { min-height: 50vh; }
.cust-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 64px; padding-bottom: 64px; }
.cust-hero h1 { font-size: clamp(2rem, 6vw, 3rem); line-height: 1.1; letter-spacing: -.02em; margin: 0; overflow-wrap: anywhere; }
.cust-phrase { font-size: 1.1875rem; color: var(--text-3); max-width: 56ch; margin: 0; overflow-wrap: anywhere; }
.cust-label { font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-text); }
.cust-card { border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 12px; padding: 16px 20px; background: var(--surface-2); max-width: 100%; }
.cust-addr { margin: 6px 0 0; font-size: 1.5rem; font-weight: 700; overflow-wrap: anywhere; }
.cust-addr-pre { color: var(--text-2); font-weight: 600; }
.cust-addr-code { border-bottom: 3px solid var(--c); }
.cust-foot { border-top: 1px solid var(--border); background: var(--surface-2); font-size: .875rem; color: var(--text-2); }
.cust-foot .cust-wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 16px; }
.cust-foot a { color: var(--c-text); }
.cust-preview { border: 1px solid var(--border-strong); border-radius: var(--r-card); overflow: hidden; margin: 8px 0 16px; }
.cust-preview .cust-main { min-height: 0; }
.cust-preview .cust-hero { padding-top: 32px; padding-bottom: 32px; }
.cust-preview .cust-hero h1 { font-size: 1.75rem; }
.dns-rec { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 4px 12px; align-items: baseline; margin: 6px 0; }
.dns-rec code { overflow-wrap: anywhere; user-select: all; }
.color-sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border-strong); vertical-align: -2px; }
/* ---- barre di consumo dei limiti (tappa 6, passo 2) ---- */
.usebars { display: grid; gap: 10px; margin: 8px 0 14px; }
.usebar-head { display: flex; justify-content: space-between; gap: 12px; font-size: .875rem; }
.usebar progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 4px; background: var(--border); overflow: hidden; }
.usebar progress::-webkit-progress-bar { background: var(--border); border-radius: 4px; }
.usebar progress::-webkit-progress-value { background: var(--ok); border-radius: 4px; }
.usebar progress::-moz-progress-bar { background: var(--ok); border-radius: 4px; }
.usebar.warn progress::-webkit-progress-value { background: var(--warn); }
.usebar.warn progress::-moz-progress-bar { background: var(--warn); }
.usebar.full progress::-webkit-progress-value { background: var(--danger); }
.usebar.full progress::-moz-progress-bar { background: var(--danger); }
.usebar .hint { margin: 2px 0 0; }
.usebars.compact { gap: 6px; }

/* Chiavi API (tappa 6, passo 5): chiave appena creata, rotazione, azioni */
.card.issued { border-color: var(--ok); background: var(--ok-bg); }
.issued-key { display: block; padding: 10px 12px; margin: 8px 0; font-family: ui-monospace, Consolas, monospace; font-size: .9375rem; word-break: break-all; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); user-select: all; }
.rotation { margin-top: 10px; padding: 10px 12px; background: var(--warn-bg); border-radius: var(--r); }
.key-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }

/* Statistiche avanzate (F2) */
.chart.heat text { font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: .875rem; }
.chip:hover { border-color: var(--primary); }
.excl { color: var(--muted); margin-left: 4px; }
.copy-field { width: 100%; margin-top: 6px; font-family: monospace; }
table.live td, table.live th { white-space: nowrap; }
@media print {
  .sidebar, .topbar, .noprint, nav.period, .flash, #filtri, #tempo-reale, #pubbliche, #report { display: none !important; }
  .main, .content { margin: 0 !important; padding: 0 !important; }
  .card { break-inside: avoid; box-shadow: none; }
  details > :not(summary) { display: none; }
}

/* Sicurezza (F1): verifica in due passaggi e codici di recupero */
.qr-box { width: 220px; max-width: 100%; margin: 12px auto; padding: 8px; background: white; border: 1px solid var(--border-strong); border-radius: var(--r); }
.qr-box svg { display: block; width: 100%; height: auto; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin: 12px 0; padding: 12px; list-style: none; font-family: ui-monospace, Consolas, monospace; font-size: .9375rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); user-select: all; }

/* ---- «i» di spiegazione (src/portal/help.ts): testo al mouse, alla tastiera e al tocco ---- */
.lab { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field > .lab { align-self: flex-start; }
.tip { position: relative; display: inline-flex; vertical-align: middle; margin-left: 4px; font-weight: 400; white-space: normal; text-align: left; }
.lab .tip { margin-left: 0; }
.tip-btn { width: 18px; height: 18px; min-width: 18px; padding: 0; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface); color: var(--primary-text); font: italic 700 .75rem/1 var(--font); cursor: help; display: inline-flex; align-items: center; justify-content: center; }
.tip-btn:hover, .tip.open .tip-btn { background: var(--primary-bg); border-color: var(--primary); }
.tip-text { position: fixed; z-index: 40; left: auto; top: auto; margin-top: 6px; width: 280px; max-width: calc(100vw - 24px); padding: 8px 10px; border-radius: var(--r); background: var(--text); color: var(--surface); font-size: .8125rem; font-weight: 400; line-height: 1.4; box-shadow: 0 4px 14px var(--shadow); visibility: hidden; opacity: 0; pointer-events: none; }
.tip-js .tip-text { left: 12px; top: 0; margin-top: 0; }
.tip:hover .tip-text, .tip.open .tip-text, .tip-btn:focus-visible ~ .tip-text { visibility: visible; opacity: 1; }
.tip-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 480px) { .tip-text { width: calc(100vw - 24px); } }
.kpi > .tip { position: absolute; top: 10px; right: 10px; margin: 0; }

/* Campagne (F4): campi UTM, anteprima, QR personalizzato */
details.utm { border: 1px solid var(--border-strong); border-radius: var(--r); padding: 8px 12px; background: var(--surface); }
details.utm > summary { cursor: pointer; font-weight: 600; }
details.utm[open] > summary { margin-bottom: 12px; }
.utm-preview { display: block; padding: 8px 10px; border: 1px dashed var(--border-strong); border-radius: var(--r); word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: .8125rem; }
input[type="color"] { width: 64px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); cursor: pointer; }
/* ---- pagine link-in-bio (F6): pagina pubblica e anteprima; il colore arriva da --cust (classe .cust) ---- */
.bio { min-height: 100vh; display: flex; flex-direction: column; }
.bio-main { flex: 1; }
.bio-col { max-width: 480px; margin: 0 auto; padding: 40px 20px 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.bio-logo { display: block; max-height: 64px; width: auto; max-width: 220px; }
.bio-mark { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: var(--c); color: var(--c-ink); font-weight: 700; font-size: 1.5rem; }
.bio-title { font-size: 1.5rem; line-height: 1.2; margin: 4px 0 0; overflow-wrap: anywhere; }
.bio-phrase { color: var(--text-3); margin: 0; overflow-wrap: anywhere; }
.bio-list { list-style: none; margin: 16px 0 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.bio-btn { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; border-radius: 12px; background: var(--c); color: var(--c-ink); text-decoration: none; font-weight: 600; text-align: left; }
.bio-btn:hover { filter: brightness(.92); }
.bio-btn:focus-visible { outline: 3px solid var(--c-text); outline-offset: 2px; }
.bio-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; color: var(--c-ink); }
.bio-ico .bio-svg { width: 100%; height: 100%; display: block; }
.bio-detected { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; }
.bio-detected .bio-ico { width: 24px; height: 24px; color: var(--text-2); }
.bio-text { flex: 1; overflow-wrap: anywhere; }
.bio-foot { padding: 16px; text-align: center; font-size: .875rem; color: var(--text-2); }
.bio-preview .bio { min-height: 0; }
.bio-preview .bio-col { padding-top: 24px; }
.bio-rows .bio-row { display: grid; grid-template-columns: 2.5rem 1fr 1fr 9rem auto; gap: 8px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--border); }
.bio-rows .bio-row .field { margin: 0; }
@media (max-width: 720px) { .bio-rows .bio-row { grid-template-columns: 1fr; } }

/* ================================================================
   Tappa 7, passo 10: grafica e impaginazione (regole nuove e mirate)
   ================================================================ */

/* testi lunghi senza uscire dalla scheda; esempi di codice che scorrono dentro il loro riquadro */
.card p, .card li, .card dd, .flash span { overflow-wrap: anywhere; }
pre { max-width: 100%; overflow-x: auto; margin: 8px 0 16px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); font-size: .8125rem; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
.issued-key { display: block; max-width: 100%; overflow-wrap: anywhere; word-break: break-all; margin-bottom: 8px; }
.card code { overflow-wrap: anywhere; }

/* righe di campi e pulsanti allineati */
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.form .actions, .rot-foot .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field.act { align-self: flex-start; }
.form > .field.act { margin-top: 4px; }
.form.stack > .field { min-width: 0; }
.radio-row { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields-grid .span-all { grid-column: 1 / -1; }

/* pagina del link: schede in basso a tutta larghezza, in griglia */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; margin-top: var(--gap); }
.tiles > .card { margin-bottom: 0; min-width: 0; }
.tiles .field.act { align-self: flex-start; }
.tiles h3 { margin-bottom: 8px; }
.tiles .hint { margin: 0 0 10px; }
@media (min-width: 1700px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .tiles { grid-template-columns: minmax(0, 1fr); } }
.detail-side .card:last-child { margin-bottom: 0; }

/* pagina Regole */
.flow ol { margin: 8px 0 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: 4px; }
.flow .flow-end { color: var(--muted); }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.rules-grid > .card { margin-bottom: 0; min-width: 0; }
.rules-grid > .wide { grid-column: 1 / -1; }
.rule-card .rule-sub { margin: 2px 0 12px; }
.rule-card h4 { font-size: var(--h3); margin: 0 0 8px; }
.rule-card .form, .rule-card .field + .field { margin-top: 10px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.cols-2 > div > .field + .field, .cols-2 .rule-row + .rule-row { margin-top: 10px; }
.rule-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: end; margin-bottom: 10px; }
.rot { display: flex; flex-direction: column; gap: 8px; }
.rot-head, .rot-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 120px 160px; gap: 12px; align-items: center; }
.rot-head { color: var(--muted); font-size: .8125rem; font-weight: 600; }
.rot-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: .75rem; font-weight: 700; color: var(--text-3); }
.rot-pct input { text-align: right; }
.rot-bar svg.share { width: 100%; height: 10px; display: block; }
.rot-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }
.rot-total { font-size: 1rem; padding: 4px 10px; border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--surface-2); }
.rot-total.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.rot-total.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.rot-total.ok::before { content: "\2713  "; }
.rot-total.warn::before { content: "!  "; font-weight: 700; }
@media (max-width: 1000px) {
  .rules-grid, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .fields-grid { grid-template-columns: minmax(0, 1fr); }
  .rule-row { grid-template-columns: 90px minmax(0, 1fr); }
  .rot-head { display: none; }
  .rot-row { grid-template-columns: 28px minmax(0, 1fr) 90px; }
  .rot-row .rot-bar { grid-column: 2 / -1; }
}

.rule-card .field, .tiles .field, .fields-grid .field { min-width: 0; }
.fields-grid { align-items: start; }
.rot-row .field { margin: 0; }
.rot-row input { width: 100%; }
.stat-card, .chart-card { min-width: 0; }
.stat-card { overflow-x: auto; }
.check input[type=radio] { width: auto; height: auto; flex: none; margin: 0; padding: 0; }

/* webhook: moduli a griglia, spiegazioni in un riquadro che si apre */
fieldset.events { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; min-width: 0; margin: 0; padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--r); }
fieldset.events > legend { padding: 0 6px; }
.field.narrow { max-width: 420px; }
details.doc > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.doc > summary::-webkit-details-marker { display: none; }
details.doc > summary::before { content: "\25B8"; color: var(--muted); }
details.doc[open] > summary::before { content: "\25BE"; }
details.doc > summary h3 { margin: 0; }
details.doc[open] > summary { margin-bottom: 12px; }
details.doc > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.check-row { min-width: 0; }
@media (max-width: 800px) { fieldset.events { grid-template-columns: minmax(0, 1fr); } }

.kv { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: 6px 16px; font-size: .875rem; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.btns form { display: inline-flex; margin: 0; }
.grid-2 > .card { min-width: 0; }
.dns-rec { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) 5rem minmax(0, 1.4fr); gap: 8px; align-items: center; padding: 3px 0; }
@media (max-width: 700px) { .dns-rec { grid-template-columns: 4.5rem minmax(0, 1fr); } }
.tiles > .wide { grid-column: 1 / -1; }
.tiles.stack-gap { margin-top: var(--gap); }

/* moduli semplici dentro una scheda a tutta larghezza: i campi non si allungano oltre una misura leggibile */
.content > .card .form.stack > .field > :is(input:not([type=checkbox]):not([type=radio]), select),
.stack-gap > .card .form.stack > .field > :is(input:not([type=checkbox]):not([type=radio]), select) { max-width: 640px; }
.content > .card .form.stack > .field > input[type=file],
.stack-gap > .card .form.stack > .field > input[type=file] { max-width: 640px; }

/* tabelle: intestazioni che vanno a capo e moduli di riga compatti */
.tbl.users th { white-space: normal; line-height: 1.2; vertical-align: bottom; }
.tbl td .form { gap: 8px 12px; align-items: center; }
.tbl td .form select { width: auto; min-width: 150px; flex: 1 1 150px; }
.tbl td .form .btn { flex: none; }
/* codici in uscita dopo un downgrade (tappa 7, passo 5, D56) */
.exit-banner a { font-weight: 600; text-decoration: underline; color: inherit; }
form.inline { display: inline; }
td.act form.inline { margin-right: 6px; }
.exit-list label.check { display: block; margin: 2px 0; }

/* Selettore della lingua (IT / EN) */
.lang-switch { display: inline-flex; gap: 2px; margin: 0; }
.lang-btn { font: inherit; font-size: .75rem; font-weight: 600; line-height: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; cursor: pointer; min-height: 28px; }
.lang-btn[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.side-foot { flex-wrap: wrap; }
.side-foot .lang-btn { color: var(--sidebar-text); border-color: var(--sidebar-hover); }
.side-foot .lang-btn[aria-current="true"] { background: var(--sidebar-hover); color: var(--on-primary); }
.legal-note { flex-basis: 100%; font-size: .8125rem; opacity: .85; }
