/* campclip · pagina di controllo. Prima il telefono, poi gli schermi larghi. Nessuna risorsa esterna.
 *
 * Sistema di disegno: colori, forme, ombre e caratteri sono variabili (`--…`) qui sotto; il tema scuro
 * cambia solo le variabili. Titoli e numeri grandi in Poppins (servito da /static/fonts/, licenza OFL),
 * il testo con i caratteri del sistema. Icone: sprite SVG in `templates/_icons.html`.
 */

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Poppins";
  src: url("/static/fonts/Poppins-Black.ttf") format("truetype");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* --- variabili: tema chiaro --- */
:root {
  color-scheme: light;
  /* superfici */
  --bg: #eceae6;
  --surface: #ffffff;
  --surface-2: #f4f3f0;
  --surface-3: #e9e8e4;
  --line: #e2e0db;
  /* testo */
  --text: #141414;
  --muted: #6a6966;
  /* azioni: pulsante principale quasi nero, un solo colore d'accento per numeri e link */
  --primary: #111111;
  --primary-text: #ffffff;
  --accent: #0f7282;
  --accent-bright: #1b9aaa;
  --accent-soft: #ddeff1;
  --focus: #1b9aaa;
  /* stati, tenui */
  --ok: #1b6e45;
  --ok-bg: #e3f1e8;
  --warn: #8a5300;
  --warn-bg: #fbefd9;
  --warn-bar: #d99a2b;
  --ko: #b42318;
  --ko-bg: #fbe9e7;
  --danger: #b42318;
  --danger-text: #ffffff;
  --switch-off: #8c8a86;
  /* scheda grande della Home */
  --hero-1: #1c2a2d;
  --hero-2: #0f1314;
  --hero-glow: rgba(27, 154, 170, 0.55);
  /* ruoli che cambiano tra telefono e schermo largo */
  --card: var(--surface);
  --card-2: var(--surface-2);
  --field: var(--surface-2);
  /* forma */
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 8px 24px rgba(20, 20, 20, 0.06);
  --shadow-lg: 0 2px 4px rgba(20, 20, 20, 0.04), 0 16px 40px rgba(20, 20, 20, 0.1);
  /* caratteri e scala: 12 / 14 / 16 / 20 / 28 / 36 */
  --font-display: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fs-2xl: 36px;
  /* misure */
  --gutter: 16px;
  --tabbar: 72px;
  /* spaziature: una sola scala per margini e distanze (4 · 8 · 12 · 16 · 24 · 32 · 48) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  /* colori delle piattaforme (marchi): uguali nei due temi */
  --yt: #ff0033;
  --yt-2: #c4001f;
  --ig-grad: linear-gradient(45deg, #feda75 0%, #fa7e1e 22%, #d62976 50%, #962fbf 75%, #4f5bd5 100%);
  --tt: #010101;
  --tt-cyan: #25f4ee;
  --tt-pink: #fe2c55;
  --row: var(--surface);
}

/* --- variabili: tema scuro --- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e0e0f;
    --surface: #19191b;
    --surface-2: #222225;
    --surface-3: #2c2c30;
    --line: #2e2e33;
    --text: #f2f1ee;
    --muted: #a6a49f;
    --primary: #f2f1ee;
    --primary-text: #111111;
    --accent: #5cc8d3;
    --accent-bright: #4fc3cf;
    --accent-soft: #123238;
    --focus: #5cc8d3;
    --ok: #79d6a2;
    --ok-bg: #15291d;
    --warn: #f1b866;
    --warn-bg: #2f2513;
    --warn-bar: #e0a33e;
    --ko: #ff9189;
    --ko-bg: #3a1b19;
    --danger: #c2392f;
    --danger-text: #ffffff;
    --switch-off: #8f8d88;
    --hero-1: #17282b;
    --hero-2: #0c1011;
    --hero-glow: rgba(79, 195, 207, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

/* --- base --- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  /* Indirizzi, impronte e percorsi lunghi vanno a capo invece di uscire dallo schermo. */
  overflow-wrap: anywhere;
}

img, video { max-width: 100%; height: auto; }

h1, h2, h3, legend { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); line-height: 1.15; margin: 4px 0 16px; }
h2 { font-size: var(--fs-md); line-height: 1.3; margin: 0 0 10px; }
h3 { font-size: var(--fs-sm); line-height: 1.3; margin: 18px 0 8px; }

p { margin: 0 0 10px; }

a { color: var(--accent); font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 3px; }

code, pre { font: 0.85rem/1.45 var(--font-mono); }
pre {
  white-space: pre-wrap; word-break: break-word; margin: 6px 0 0;
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--card-2);
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.small { font-size: var(--fs-sm); }
.muted, .note { color: var(--muted); }
/* Testo per i lettori di schermo, nascosto alla vista. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.note { margin: -8px 0 16px; }

/* --- icone (sprite in templates/_icons.html) --- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: 0 0 auto; vertical-align: -4px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon.sm { width: 16px; height: 16px; vertical-align: -3px; }
.icon.lg { width: 24px; height: 24px; }

.logo { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 9px; }
.logo-bg { fill: var(--primary); }
.logo-c { fill: none; stroke: var(--primary-text); stroke-width: 3.2; stroke-linecap: round; }
.logo-play { fill: var(--accent-bright); }

/* --- struttura: barra in alto, contenuto, barra delle schede in basso (telefono) --- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 4px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  font: 700 var(--fs-lg)/1 var(--font-display); letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}

main {
  padding: 8px var(--gutter) calc(var(--tabbar) + 32px + env(safe-area-inset-bottom, 0px));
  max-width: 760px; margin: 0 auto;
}

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(20, 20, 20, 0.06);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
}
.nav-brand, .nav-logout { display: none; }
.nav-list { list-style: none; margin: 0 auto; padding: 0; display: flex; max-width: 560px; }
.nav-item { flex: 1 1 0; min-width: 0; }
.nav-item.nav-side { display: none; }
.nav-item a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 56px; padding: 4px 2px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: var(--fs-xs); font-weight: 600; line-height: 1.2;
  text-decoration: none; text-align: center;
}
.nav-ico {
  display: grid; place-items: center; width: 56px; height: 32px; max-width: 100%;
  border-radius: var(--pill); transition: background-color 0.2s, color 0.2s;
}
.nav-item.is-active a { color: var(--text); }
.nav-item.is-active .nav-ico { background: var(--primary); color: var(--primary-text); }

/* Interruttore generale acceso: avviso in cima a ogni pagina. */
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 8px var(--gutter) 0; padding: 12px 16px; border-radius: var(--radius);
  font-weight: 600;
}
.banner > span { flex: 1 1 auto; min-width: 0; }
.banner .icon { margin-top: 2px; }
.banner.danger { background: var(--ko-bg); color: var(--ko); }
.banner a { color: inherit; }

/* Pagina di accesso e "sei offline": un riquadro al centro. */
body:not(.app) main {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding-bottom: 32px;
}

/* --- titoli di pagina --- */
.head-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 16px; }
.head-row h1 { margin: 0 auto 0 0; }
.eyebrow {
  margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
/* Ritorno alla pagina sopra: testo piccolo con la freccia, niente riquadro. */
.crumbs { margin: 0 0 var(--s-2); }
.crumbs a {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 4px 0;
  color: var(--muted); font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.crumbs a::before {
  content: ""; width: 16px; height: 16px; background: currentColor; transform: rotate(180deg);
  -webkit-mask: var(--mask-chevron) center / contain no-repeat; mask: var(--mask-chevron) center / contain no-repeat;
}
@media (hover: hover) { .crumbs a:hover { color: var(--text); } }

/* --- schede --- */
.card {
  background: var(--card); border-radius: var(--radius-lg); padding: 20px;
  margin: 0 0 16px; box-shadow: var(--shadow); min-width: 0;
}
.card > :last-child { margin-bottom: 0; }
.card.narrow { max-width: 420px; width: 100%; margin: 24px auto; }
.card.warn { background: var(--warn-bg); box-shadow: none; }
.card.warn h2 { color: var(--warn); }
.kill.on { background: var(--ko-bg); box-shadow: inset 0 0 0 2px var(--ko); }
.kill.off { box-shadow: var(--shadow); }

.card-head { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.card-head h2 { margin: 0; flex: 1 1 auto; min-width: 0; }
.card-ico {
  display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 50%; background: var(--card-2); color: var(--text);
}
.card-foot { margin: 14px 0 0; }
.more-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; text-decoration: none; }

.subcard { background: var(--card-2); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 10px; }

/* Griglia della Home: una colonna sul telefono. */
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin: 0 0 16px; }
.grid > * { margin: 0; }

/* --- scheda grande in cima alla Home: la cosa più urgente --- */
.hero {
  position: relative; overflow: hidden; color: #ffffff;
  border-radius: var(--radius-lg); padding: 20px;
  background:
    radial-gradient(120% 90% at 100% 0%, var(--hero-glow), transparent 60%),
    radial-gradient(90% 70% at 0% 100%, rgba(27, 154, 170, 0.18), transparent 65%),
    linear-gradient(160deg, var(--hero-1), var(--hero-2));
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px; min-height: 240px;
}
.hero a { color: #ffffff; }
.hero :focus-visible { outline-color: #ffffff; }
.hero .eyebrow { color: rgba(255, 255, 255, 0.72); margin: 0; }
.hero-title { font-size: var(--fs-xl); line-height: 1.15; margin: 2px 0 0; color: #ffffff; }
.hero-text { margin: 0; color: rgba(255, 255, 255, 0.82); }
.hero-focus { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.hero-focus .countdown {
  margin: 0; font: 700 var(--fs-2xl)/1.05 var(--font-display); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; overflow-wrap: normal;
}
.hero-meta { margin: 0; color: rgba(255, 255, 255, 0.82); font-size: var(--fs-sm); }
.hero-meta strong { color: #ffffff; }
.hero-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.hero-list li { border-bottom: 1px solid rgba(255, 255, 255, 0.14); }
.hero-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px 0; font-weight: 400; text-decoration: none;
}
.hero-list .countdown { font: 700 var(--fs-sm)/1.2 var(--font-display); white-space: nowrap; overflow-wrap: normal; }
.hero-note { margin: 0; font-size: var(--fs-sm); color: rgba(255, 255, 255, 0.82); }
.hero-alert {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(255, 145, 137, 0.18); color: #ffffff; font-size: var(--fs-sm); font-weight: 600;
}

/* Pastiglie trasparenti sopra la scheda grande ("● Live", numeri di oggi). */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border-radius: var(--pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.2;
  background: rgba(255, 255, 255, 0.14); color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); flex: 0 0 auto; }
.chip.live .dot { background: #5ee0a0; box-shadow: 0 0 0 3px rgba(94, 224, 160, 0.25); }
.chip.alert { background: rgba(255, 145, 137, 0.22); border-color: rgba(255, 145, 137, 0.4); }

/* --- etichette di stato --- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
  padding: 5px 10px; border-radius: var(--pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.25;
  background: var(--card-2); color: var(--muted);
}
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.ko { background: var(--ko-bg); color: var(--ko); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto;
}
.tag.status-rules_draft, .tag.status-joined_pending_brief { background: var(--warn-bg); color: var(--warn); }
.tag.status-ready, .tag.status-producing { background: var(--ok-bg); color: var(--ok); }
.tag.status-excluded, .tag.status-paused { background: var(--ko-bg); color: var(--ko); }

/* --- messaggi --- */
.msg {
  display: block; padding: 12px 16px 12px 44px; border-radius: var(--radius); margin: 0 0 14px;
  position: relative; background: var(--card-2); font-weight: 500;
}
.msg::before {
  content: ""; position: absolute; left: 16px; top: 14px; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: var(--mask-info) center / contain no-repeat; mask: var(--mask-info) center / contain no-repeat;
}
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.ok::before { -webkit-mask-image: var(--mask-check); mask-image: var(--mask-check); }
.msg.error { background: var(--ko-bg); color: var(--ko); }
.msg.error::before { -webkit-mask-image: var(--mask-alert); mask-image: var(--mask-alert); }
.msg a { color: inherit; }
.msg ul { margin: 6px 0 0; padding-left: 18px; }

.empty {
  margin: 0 0 10px; padding: 16px; border-radius: var(--radius); text-align: center;
  background: var(--card-2); color: var(--muted);
}
main > .empty { background: var(--card); padding: 32px 20px; box-shadow: var(--shadow); }

.error-text { color: var(--ko); margin: 6px 0 0; font-size: var(--fs-sm); }
pre.error-text { background: var(--ko-bg); }

/* --- elenchi --- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.list > li:first-child { border-top: 0; padding-top: 2px; }
.list li > * { margin-right: 6px; }
.list .actions { margin-right: 0; }

/* Elenco di voci che portano a una pagina, con la freccia a destra. */
.menu { list-style: none; margin: 0; padding: 0; }
.menu > li + li { border-top: 1px solid var(--line); }
.menu a, .menu button {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 2px;
  color: var(--text); font-weight: 600; text-decoration: none; text-align: left;
  background: none; border-radius: 0; box-shadow: none;
}
.menu a::after {
  content: ""; width: 18px; height: 18px; margin-left: auto; flex: 0 0 auto; background: var(--muted);
  -webkit-mask: var(--mask-chevron) center / contain no-repeat; mask: var(--mask-chevron) center / contain no-repeat;
}
.menu-ico {
  display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 14px; background: var(--card-2); color: var(--text);
}
.menu-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-text small { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; }

.checks { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks li {
  position: relative; padding: 10px 14px 10px 32px; border-radius: 14px;
  background: var(--card-2); font-size: var(--fs-sm);
}
.checks li::before {
  content: ""; position: absolute; left: 14px; top: 17px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.checks li.ok::before { background: var(--ok); }
.checks li.ko { background: var(--ko-bg); color: var(--ko); }
.checks li.ko::before { background: var(--ko); }
.checks li .meter { margin-top: 8px; }

.level-error { box-shadow: inset 3px 0 0 var(--ko); padding-left: 12px !important; }
.level-warning { box-shadow: inset 3px 0 0 var(--warn-bar); padding-left: 12px !important; }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 10px 0 0; font-size: var(--fs-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.rates { list-style: none; margin: 6px 0; padding: 0; font-size: var(--fs-sm); }
.rates li { padding: 3px 0; }
.count { display: inline-block; min-width: 2.5ch; font: 700 var(--fs-md)/1.2 var(--font-display); color: var(--accent); }

/* --- numeri: pastiglie, terne, numeri grandi --- */
.stats {
  list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stats > li:last-child:nth-child(odd) { grid-column: 1 / -1; }
.stat { background: var(--card-2); border-radius: 16px; padding: 12px 14px; min-width: 0; }
.stat a { display: block; color: inherit; text-decoration: none; font-weight: 400; }
.stat-num {
  display: block; font: 700 var(--fs-xl)/1.15 var(--font-display); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; overflow-wrap: normal;
}
.stat-label { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; overflow-wrap: normal; }
.stat.warn { background: var(--warn-bg); }
.stat.warn .stat-num { color: var(--warn); }
.stat.ko { background: var(--ko-bg); }
.stat.ko .stat-num { color: var(--ko); }

.big-label { margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.big-num {
  margin: 2px 0 8px; font: 700 var(--fs-2xl)/1.1 var(--font-display); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; overflow-wrap: normal;
}

.pills { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  padding: 6px 14px 6px 6px; border-radius: var(--pill); background: var(--card-2);
}
.pill-ico {
  display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: 50%; background: var(--card); color: var(--text);
}
.pill-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pill-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.pill-value { font: 700 var(--fs-sm)/1.3 var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: normal; }

/* Tre numeri in fila: etichetta sopra, valore sotto nel colore d'accento. */
.trio {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin: 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.trio > div { min-width: 0; }
.trio dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.trio dd {
  margin: 2px 0 0; font: 700 var(--fs-md)/1.2 var(--font-display); color: var(--accent);
  font-variant-numeric: tabular-nums; overflow-wrap: normal;
}
.trio .pre, .trio .unit { font: 600 var(--fs-xs)/1.2 var(--font-body); }

/* Barra di avanzamento (spesa AI, credito). Le varianti stanno sul contenitore `.meter`. */
progress {
  display: block; width: 100%; height: 10px; margin: 8px 0 10px;
  -webkit-appearance: none; appearance: none; border: 0; border-radius: var(--pill);
  background: var(--surface-3); color: var(--accent-bright); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: var(--pill); }
progress::-webkit-progress-value { background: var(--accent-bright); border-radius: var(--pill); }
progress::-moz-progress-bar { background: var(--accent-bright); border-radius: var(--pill); }
.meter.warn progress::-webkit-progress-value { background: var(--warn-bar); }
.meter.warn progress::-moz-progress-bar { background: var(--warn-bar); }
.meter.ko progress::-webkit-progress-value { background: var(--ko); }
.meter.ko progress::-moz-progress-bar { background: var(--ko); }
.meter-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 0; }
.meter-value { font: 700 var(--fs-xl)/1.15 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: normal; }
.meter-pct { margin-left: auto; font: 700 var(--fs-sm)/1.2 var(--font-display); color: var(--accent); }

.countdown { font-weight: 700; font-variant-numeric: tabular-nums; }
p.countdown { font: 700 var(--fs-2xl)/1.1 var(--font-display); margin: 0 0 6px; letter-spacing: -0.02em; overflow-wrap: normal; }

/* --- pulsanti --- */
button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; max-width: 100%; padding: 12px 20px;
  border: 0; border-radius: var(--pill);
  background: var(--card-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
  font: 600 15px/1.2 var(--font-body); text-align: center; text-decoration: none;
  cursor: pointer; transition: background-color 0.15s, box-shadow 0.15s, transform 0.1s, opacity 0.15s;
}
button:active, a.button:active { transform: scale(0.98); }
button.primary, a.button.primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 6px 16px rgba(17, 17, 17, 0.18); }
a.button.ig, button.ig { background: var(--ig-grad); color: #ffffff; box-shadow: 0 6px 16px rgba(214, 41, 118, 0.28); }
a.button.ig:hover { filter: brightness(1.06); }
button.danger { background: var(--danger); color: var(--danger-text); box-shadow: none; }
a.button.light { background: #ffffff; color: #111111; box-shadow: none; }
button.wide, a.button.wide { display: flex; width: 100%; }
button.wide { margin-top: 12px; }
button.link {
  min-height: 44px; padding: 0 4px; background: none; box-shadow: none; border-radius: 6px;
  color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
@media (hover: hover) {
  button:hover:not(:disabled), a.button:hover { background-color: var(--surface-3); }
  button.primary:hover:not(:disabled), a.button.primary:hover { background-color: var(--primary); opacity: 0.88; }
  button.danger:hover:not(:disabled) { background-color: var(--danger); opacity: 0.9; }
  a.button.light:hover { background-color: #ffffff; opacity: 0.9; }
  button.link:hover { background: none; }
}

/* Pulsante tondo con sola icona (aprire una campagna, uscire). */
.icon-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; min-height: 48px; padding: 0;
  flex: 0 0 auto; border-radius: 50%; background: var(--primary); color: var(--primary-text);
  box-shadow: 0 6px 16px rgba(17, 17, 17, 0.2); text-decoration: none;
}
.icon-btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
form.inline { display: inline; }

/* --- moduli --- */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: var(--fs-md); margin-bottom: 12px; padding: 0; }
.field { margin: 0 0 16px; }

label, .label { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: 6px; }
label.sub { font-weight: 500; margin-top: 8px; color: var(--muted); }

input[type="text"], input[type="password"], input[type="url"], input[type="number"],
input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; color: var(--text); background: var(--field);
  border: 1.5px solid transparent; border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-bright); box-shadow: 0 0 0 4px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; line-height: 1.45; }
textarea.code { font: 0.85rem/1.45 var(--font-mono); min-height: 50vh; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 44px; cursor: pointer;
  background-image: var(--img-select); background-repeat: no-repeat; background-position: right 14px center;
  background-size: 18px 18px;
}
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--ko); }
input[type="file"] {
  width: 100%; font: inherit; font-size: var(--fs-sm); padding: 14px; border-radius: 14px;
  background: var(--field); border: 1.5px dashed var(--line); color: var(--muted);
}
input[type="file"]::file-selector-button {
  font: 600 var(--fs-sm) var(--font-body); margin-right: 12px; padding: 10px 16px; border: 0;
  border-radius: var(--pill); background: var(--primary); color: var(--primary-text); cursor: pointer;
}

/* Caselle: quadrati arrotondati, segno di spunta disegnato. Restano caselle vere. */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; display: inline-grid; place-content: center;
  width: 24px; height: 24px; margin: 0; flex: 0 0 auto; cursor: pointer;
  border: 2px solid var(--switch-off); border-radius: 8px; background: var(--surface);
  transition: background-color 0.15s, border-color 0.15s;
}
input[type="checkbox"]::before {
  content: ""; width: 14px; height: 14px; background: var(--primary-text); transform: scale(0);
  transition: transform 0.12s;
  -webkit-mask: var(--mask-check) center / contain no-repeat; mask: var(--mask-check) center / contain no-repeat;
}
input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:disabled { opacity: 0.45; cursor: not-allowed; }
input[type="checkbox"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

label.check {
  display: flex; gap: 12px; align-items: center; min-height: 44px; margin: 0;
  font-size: var(--fs-md); font-weight: 600; cursor: pointer;
}

/* Interruttore (sì / no) per le impostazioni: una casella con il ruolo "switch". */
label.switch { justify-content: space-between; gap: 16px; }
label.switch input[type="checkbox"] {
  position: relative; display: block; width: 52px; height: 32px;
  border: 2px solid var(--switch-off); border-radius: var(--pill); background: var(--surface-3);
}
label.switch input[type="checkbox"]::before {
  position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--switch-off); transform: none; -webkit-mask: none; mask: none;
  transition: transform 0.18s, width 0.18s, height 0.18s, top 0.18s, background-color 0.18s;
}
label.switch input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
label.switch input[type="checkbox"]:checked::before {
  top: 2px; width: 24px; height: 24px; background: var(--surface); transform: translateX(20px);
}

/* Nicchie dell'account: caselle due per riga, larghe metà schermo anche sul telefono. */
.choices { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices li { min-width: 0; }
.choices label.check {
  height: 100%; padding: 10px 12px; border-radius: 14px; background: var(--field);
  font-size: var(--fs-sm); box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow 0.15s, background-color 0.15s;
}
.choices label.check:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.options { list-style: none; margin: 0 0 8px; padding: 0; }
.options li { padding: 8px 0; border-top: 1px solid var(--line); }
.options li:first-child { border-top: 0; }
.fit-reasons { color: var(--ko); margin: 4px 0 0; font-size: var(--fs-sm); }

/* --- sezioni apribili --- */
details > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 8px 0; cursor: pointer; font-weight: 600; list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: ""; width: 18px; height: 18px; flex: 0 0 auto; background: var(--muted); transition: transform 0.2s;
  -webkit-mask: var(--mask-chevron) center / contain no-repeat; mask: var(--mask-chevron) center / contain no-repeat;
}
details[open] > summary::after { transform: rotate(90deg); }
details.card > summary { padding: 0; }
.brief-text { max-height: 60vh; overflow: auto; }
.upload { margin-top: 14px; }
.upload button { margin-top: 12px; }
.links .link-url { overflow-wrap: anywhere; word-break: break-word; font-size: var(--fs-sm); }

/* --- regole con la frase del brief accanto --- */
.rules { list-style: none; margin: 0; padding: 0; }
.rule { padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.rule:first-child { border-top: 0; }
.rule .path { font-weight: 600; }
.rule .value { margin: 4px 0; color: var(--muted); }
.evidence {
  margin: 6px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent-bright); background: var(--card-2);
  border-radius: 0 10px 10px 0; font-size: var(--fs-sm);
}
.evidence.missing { border-left-color: var(--ko); color: var(--ko); }

/* --- tessere delle campagne: una colonna sul telefono, più colonne se c'è spazio --- */
.tiles {
  list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.tile {
  display: flex; flex-direction: column; min-width: 0; padding: 8px;
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.media {
  position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 18px; background: var(--surface-3);
}
.media-img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Senza immagine: sfumatura e iniziali. Quattro varianti fisse (niente stili in linea). */
.media-ph {
  display: grid; place-items: center; width: 100%; height: 100%;
  font: 900 var(--fs-2xl)/1 var(--font-display); letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.92);
  background: linear-gradient(135deg, #1b9aaa, #0f3d47);
}
.media-ph.ph-1 { background: linear-gradient(135deg, #3b3a36, #121212); }
.media-ph.ph-2 { background: linear-gradient(135deg, #c7835a, #5b2f1d); }
.media-ph.ph-3 { background: linear-gradient(135deg, #6c7d5b, #24301c); }
.media-chips { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.media-chips .tag {
  background: rgba(255, 255, 255, 0.92); color: #141414;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.media-chips .tag.status-ready, .media-chips .tag.status-producing { color: #1b6e45; }
.media-chips .tag.status-rules_draft, .media-chips .tag.status-joined_pending_brief { color: #8a5300; }
.media-chips .tag.status-excluded, .media-chips .tag.status-paused, .media-chips .tag.ko { color: #b42318; }

.tile-body { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; padding: 14px 10px 6px; min-width: 0; }
.tile-title { margin: 0; font-size: var(--fs-lg); line-height: 1.2; }
.tile-title a { color: var(--text); text-decoration: none; font-weight: 700; }
.tile-sub { display: flex; align-items: center; gap: 6px; margin: -6px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.tile-more > summary { min-height: 44px; padding: 0; color: var(--muted); font-size: var(--fs-sm); }
.tile-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: auto; }
.price-label { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.price { display: block; font: 700 var(--fs-xl)/1.15 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: normal; }

/* Testata della campagna: immagine grande, titolo, agenzia, stato. */
.cover { margin: 0 0 16px; }
.cover .media { aspect-ratio: 16 / 8; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.cover h1 { margin: 16px 0 4px; }
.cover-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; color: var(--muted); }
.cover .trio { margin-top: 14px; }
.cover-price { margin: 12px 0 0; }

/* --- Revisione: video grande e arrotondato --- */
.review-video {
  display: block; width: 100%; max-width: 360px; margin: 0 auto; aspect-ratio: 9 / 16;
  border-radius: var(--radius); background: #000000; object-fit: contain;
}
.subcard > p:last-child, .subcard > pre:last-child { margin-bottom: 0; }
.subcard pre, .subcard input, .subcard textarea, .subcard select { background: var(--card); }
fieldset.subcard { margin-bottom: 12px; }
.card.narrow .card-ico { margin-bottom: 12px; }
.login .brand { margin-bottom: 8px; }

/* --- elenchi di schede: compiti, account --- */
.stack { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.stack > .card { margin: 0; }
.task-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.task-due { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.task-title { font-size: var(--fs-md); margin: 0 0 6px; }
.task .actions { margin-top: 14px; }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%;
  background: var(--primary); color: var(--primary-text); font: 700 var(--fs-md)/1 var(--font-display);
}

/* --- pagina "Altro" --- */
.more-out { margin-top: 8px; }

/* --- Statistiche: schermate in fila, campi due per riga, quote del pubblico come barre --- */
.shots { list-style: none; margin: 0 0 16px; padding: 0 0 4px; display: flex; gap: 10px; overflow-x: auto; }
.shots li { flex: 0 0 auto; }
.shots img {
  display: block; width: 90px; height: auto; aspect-ratio: 9 / 20; object-fit: cover; object-position: top;
  border-radius: 14px; background: var(--surface-3); box-shadow: var(--shadow);
}
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.form-grid .field { min-width: 0; }
.bars { list-style: none; margin: 0 0 12px; padding: 0; }
.bars li { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 8px; }
.bars .meter { flex: 1 0 100%; }
.bars progress { margin: 4px 0 8px; height: 8px; }
.bar-label { font-size: var(--fs-sm); font-weight: 600; }
.bar-value { font: 700 var(--fs-sm)/1.3 var(--font-display); font-variant-numeric: tabular-nums; }

/* --- schermi larghi: barra laterale sottile, contenuto in una tela bianca --- */
@media (min-width: 720px) {
  .stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .stats > li:last-child:nth-child(odd) { grid-column: auto; }
}

@media (min-width: 900px) {
  /* Dentro la tela bianca le schede diventano grigie (solo con il menu: accesso e "offline" restano bianche). */
  body.app {
    --card: var(--surface-2);
    --card-2: var(--surface);
    --field: var(--surface);
    padding: 20px;
  }
  .app .shell {
    display: grid; grid-template-columns: 96px minmax(0, 1fr);
    max-width: 1440px; min-height: calc(100vh - 40px); margin: 0 auto;
    background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  }
  .top { display: none; }
  .nav {
    position: sticky; top: 20px; align-self: start; height: calc(100vh - 40px);
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 24px 0; background: none; border: 0; box-shadow: none; overflow-y: auto;
  }
  .nav-brand { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; }
  .nav-brand .logo { width: 44px; height: 44px; border-radius: 12px; }
  .nav-list { flex-direction: column; gap: 4px; margin: 8px 0 0; max-width: none; }
  .nav-item.nav-side { display: block; }
  .nav-item.nav-tab { display: none; }
  .nav-item a { width: 88px; min-height: 64px; padding: 4px 0; font-size: 11px; gap: 3px; }
  .nav-label { white-space: nowrap; overflow-wrap: normal; letter-spacing: -0.01em; }
  .nav-ico { width: 44px; height: 44px; border-radius: 50%; }
  .nav-logout { display: block; margin-top: auto; }
  .nav-logout .icon-btn { box-shadow: none; }
  .canvas { min-width: 0; }
  .banner { margin: 24px 40px 0; }
  main { max-width: 1280px; margin: 0 auto; padding: 32px 40px 48px; }
  h1 { font-size: var(--fs-2xl); }
  .app .card, .app .kill.off { box-shadow: none; }
  .app main > .empty { box-shadow: none; }
  .tile { box-shadow: var(--shadow-lg); background: var(--surface); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
  .hero { min-height: 300px; padding: 28px; }
  .hero-title { font-size: var(--fs-2xl); }
  .review-video { position: sticky; top: 24px; }
  .page-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .page-grid > * { margin: 0; }
  .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cover { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: end; }
  .cover h1 { margin-top: 0; }
}

@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid > .hero.span-2 { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- disegni piccoli usati come maschere (stesso colore del testo) --- */
:root {
  --mask-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9.5 6 6 6-6 6'/%3E%3C/svg%3E");
  --mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --mask-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5'/%3E%3Cpath d='M12 16.5h.01'/%3E%3C/svg%3E");
  --mask-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5'/%3E%3Cpath d='M12 7.5h.01'/%3E%3C/svg%3E");
  --img-select: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c8a86' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* --- campagna guidata (issue #3, sezione 5): fasi, «Adesso», domande, regole in parole semplici --- */
.now-step { border: 2px solid var(--accent-bright); margin-bottom: 14px; }
.now-step h2 { margin: 2px 0 6px; }
.now-step .or { text-align: center; color: var(--muted); margin: 10px 0 4px; font-size: 0.85rem; }
.blocker { border-left: 4px solid var(--ko); margin-bottom: 14px; }
.todo { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.todo li { display: flex; gap: 8px; align-items: flex-start; }
.todo .tag { flex: none; }
.msg.warn-msg { background: var(--warn-bg); color: var(--warn); }
.checklist { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.checklist li > span { margin-right: 8px; }
.stack-gap { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.question h3 { margin: 4px 0; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.choice form { margin: 0; }
.rule-group { margin: 16px 0 4px; font-size: 1rem; }
.plain-rules { list-style: none; padding: 0; margin: 0; }
.plain-rules li { border-top: 1px solid var(--line); padding: 8px 0; }
.plain-text { margin: 0; font-weight: 600; }
.plain-quote { margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); border-left: 3px solid var(--accent-soft); padding-left: 8px; font-style: italic; }
.plain-quote.source { font-style: normal; }
.technical { margin-top: 12px; }
.sticky-action { position: sticky; bottom: 0; background: var(--card); padding: 10px 0 4px; }
details.card > summary { font-weight: 700; }
.link-problem { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; margin-top: 10px; }
.link-problem form { margin: 0; flex: none; }
.link-problem .link-url { word-break: break-all; }

/* ==========================================================================================================
 * Sistema di disegno comune (dalla pagina Campagne): testate, barre di comandi, schede a segmenti, righe
 * delle pubblicazioni, marchi delle piattaforme, schede dei profili, sezioni apribili, aiuti «?».
 * Tutte le pagine usano questi pezzi; le classi più vecchie qui sopra restano per le pagine minori.
 * ======================================================================================================= */

/* --- testata della pagina: titolo, una riga sotto, azioni a destra --- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-4); margin: 0 0 var(--s-5); }
.page-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.page-head h1 { margin: 0; }
.page-sub { margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--fs-sm); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* --- titolo di sezione con il numero accanto --- */
.section { margin: 0 0 var(--s-6); }
.section-head { display: flex; align-items: center; gap: var(--s-2) var(--s-3); flex-wrap: wrap; margin: 0 0 var(--s-3); }
.section-head h2 { margin: 0; font-size: var(--fs-lg); }
.section-head .more-link { margin-left: auto; font-size: var(--fs-sm); }
.badge {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 8px;
  border-radius: var(--pill); background: var(--card-2); color: var(--muted);
  font: 700 var(--fs-xs)/1 var(--font-body); font-variant-numeric: tabular-nums;
}
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ko { background: var(--ko-bg); color: var(--ko); }

/* --- pulsanti piccoli e barra dei comandi --- */
button.sm, a.button.sm { min-height: 40px; padding: 8px 14px; font-size: var(--fs-sm); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-5); }
.toolbar form { margin: 0; }
button.ghost, a.button.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
button.danger-soft, a.button.danger-soft { background: var(--ko-bg); color: var(--ko); box-shadow: none; }
@media (hover: hover) {
  button.danger-soft:hover:not(:disabled) { background: var(--ko-bg); opacity: 0.85; }
}
/* Interruttore disegnato dentro un pulsante (prova a secco): puntino che scorre. */
.knob {
  position: relative; display: inline-block; width: 30px; height: 18px; flex: 0 0 auto;
  border-radius: var(--pill); background: var(--switch-off); transition: background-color 0.15s;
}
.knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); transition: transform 0.15s;
}
.knob.on { background: var(--warn-bar); }
.knob.on::after { transform: translateX(12px); }

/* --- numeri chiave (come le tessere delle campagne, quattro in fila) --- */
.kpis {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4);
  margin: var(--s-4) 0 0; padding: var(--s-3) 0 0; border-top: 1px solid var(--line);
}
.kpis > div { min-width: 0; }
.kpis dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.kpis dd {
  margin: 2px 0 0; font: 700 var(--fs-lg)/1.2 var(--font-display); color: var(--accent);
  font-variant-numeric: tabular-nums; overflow-wrap: normal;
}
.kpis .pre, .kpis .unit { font: 600 var(--fs-xs)/1.2 var(--font-body); }
.kpis .strong dd { color: var(--text); }

/* --- testata della campagna: immagine, titolo, numeri --- */
.camp-head { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); margin: 0 0 var(--s-5); }
.camp-head .media { aspect-ratio: 16 / 8; border-radius: var(--radius-lg); }
.camp-head h1 { margin: 0 0 var(--s-2); }
.camp-info { min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; }

/* --- fasi della campagna: barra sottile, il passo di adesso in evidenza --- */
.steps { list-style: none; display: flex; gap: var(--s-2); margin: 0 0 var(--s-3); padding: 0; }
/* `display: block`: lo stato "todo" della guida è anche il nome della classe `.todo` (elenco in colonna). */
.steps li { display: block; flex: 1 1 0; min-width: 0; margin: 0; padding: 0; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.steps li::before { content: ""; display: block; height: 4px; margin: 0 0 6px; border-radius: 4px; background: var(--line); }
.steps li.done::before { background: var(--ok); }
.steps li.now::before { background: var(--accent-bright); }
.steps li.now { color: var(--text); }

.next {
  display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); align-items: center;
  border-radius: var(--radius-lg); padding: var(--s-4) var(--s-5); margin: 0 0 var(--s-4);
  background: var(--card); box-shadow: inset 0 0 0 2px var(--accent-bright);
}
.next h2 { margin: 2px 0 2px; font-size: var(--fs-lg); }
.next p { margin: 0; }
.next .eyebrow { color: var(--accent); margin: 0; }
.next-text { color: var(--muted); font-size: var(--fs-sm); }
.next-forms { display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); }
.next-forms .upload { margin: 0; }
.next .small a { font-weight: 600; }
.inline-field { display: flex; gap: var(--s-2); align-items: stretch; }
.inline-field input { flex: 1 1 auto; min-width: 0; }
.inline-field button { flex: 0 0 auto; margin: 0; }

/* Avvisi compatti in cima (pausa, esclusione, prova a secco). */
.alerts { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-4); }
.alerts .msg { margin: 0; }

/* --- schede a segmenti (filtro delle pubblicazioni): link veri, niente JavaScript --- */
.seg {
  display: flex; gap: 4px; margin: 0 0 var(--s-4); padding: 4px; overflow-x: auto;
  border-radius: var(--pill); background: var(--card); scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg a {
  display: inline-flex; align-items: center; gap: 8px; flex: 1 0 auto; justify-content: center;
  min-height: 40px; padding: 6px 14px; border-radius: var(--pill); white-space: nowrap; overflow-wrap: normal;
  color: var(--muted); font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.seg-n { font-variant-numeric: tabular-nums; opacity: 0.75; }
.seg a[aria-current="page"] { background: var(--primary); color: var(--primary-text); }
.seg a[aria-current="page"] .seg-n { opacity: 1; }
@media (hover: hover) { .seg a:hover:not([aria-current="page"]) { color: var(--text); } }

/* --- righe delle pubblicazioni: copertina verticale, titolo, piattaforma, stato, numeri --- */
.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .pubs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pub {
  position: relative; display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: var(--s-3);
  align-items: center; min-width: 0; padding: 8px 12px 8px 8px; border-radius: 18px; background: var(--row);
  box-shadow: var(--shadow); transition: box-shadow 0.15s;
}
.pub-thumb {
  position: relative; display: grid; place-items: center; width: 54px; aspect-ratio: 9 / 16; overflow: hidden;
  border-radius: 10px; color: var(--muted);
  background: linear-gradient(160deg, var(--surface-3), var(--card-2));
}
.pub-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pub-thumb .dur {
  position: absolute; right: 3px; bottom: 3px; padding: 1px 4px; border-radius: 5px;
  background: rgba(0, 0, 0, 0.66); color: #ffffff; font: 600 10px/1.3 var(--font-body);
  font-variant-numeric: tabular-nums; overflow-wrap: normal;
}
.pub-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pub-title {
  margin: 0; font-weight: 600; font-size: var(--fs-sm); line-height: 1.3; overflow-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pub-title a, .pub-title span { color: var(--text); font-weight: 600; text-decoration: none; }
.pub-title .untitled { color: var(--muted); font-weight: 500; }
/* Tutta la riga apre la pagina della riga; gli altri link stanno sopra. */
.pub-link::after { content: ""; position: absolute; inset: 0; border-radius: 18px; }
.pub a:not(.pub-link), .pub form, .pub button { position: relative; z-index: 1; }
.pub-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0;
  color: var(--muted); font-size: var(--fs-xs); font-weight: 600;
}
.pub-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.pub-tags .tag { padding: 3px 9px; }
.pub-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.views {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; overflow-wrap: normal;
  font: 700 var(--fs-sm)/1.2 var(--font-display); font-variant-numeric: tabular-nums;
}
.views .icon { color: var(--muted); }
.open-link {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--card-2); color: var(--text);
}
@media (hover: hover) {
  .pub:hover { box-shadow: var(--shadow-lg); }
  .open-link:hover { background: var(--surface-3); }
}
.pubs-more { display: flex; justify-content: center; margin: var(--s-4) 0 0; }

/* --- marchi delle piattaforme: quadratino nel colore del social, simbolo bianco --- */
.plat {
  display: inline-grid; place-items: center; width: 20px; height: 20px; flex: 0 0 auto; border-radius: 6px;
  color: #ffffff; background: var(--surface-3); vertical-align: middle;
}
.plat .icon { width: 13px; height: 13px; vertical-align: 0; }
.plat.lg { width: 36px; height: 36px; border-radius: 11px; }
.plat.lg .icon { width: 22px; height: 22px; }
.plat-youtube { background: var(--yt); }
.plat-instagram { background: var(--ig-grad); }
.plat-tiktok { background: var(--tt); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.plat-tiktok .icon { filter: drop-shadow(-1px -1px 0 var(--tt-cyan)) drop-shadow(1px 1px 0 var(--tt-pink)); }

/* --- sezioni apribili: icona, titolo, conteggio a destra, freccia --- */
details.fold { padding: 0; }
details.fold > summary { min-height: 64px; padding: 12px 20px; gap: var(--s-3); justify-content: flex-start; }
.fold-title { flex: 1 1 auto; min-width: 110px; font: 700 var(--fs-md)/1.3 var(--font-display); overflow-wrap: normal; }
.fold-meta { flex: 0 1 auto; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; text-align: right; overflow-wrap: normal; }
.fold-meta.ko { color: var(--ko); }
.fold-meta.warn { color: var(--warn); }
.fold-body { padding: 0 20px 20px; }
.fold-body > :last-child { margin-bottom: 0; }
details.fold .card-ico { width: 36px; height: 36px; }
.folds { display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); margin: 0 0 var(--s-4); align-items: start; }
.folds > .card { margin: 0; }

/* --- aiuto «?»: si apre al tocco, testo breve --- */
.hint { position: relative; display: inline-block; vertical-align: middle; font-weight: 400; }
.hint > summary {
  display: inline-grid; place-items: center; width: 22px; height: 22px; min-height: 0; padding: 0;
  border-radius: 50%; background: var(--card-2); color: var(--muted);
  font: 700 12px/1 var(--font-body); box-shadow: inset 0 0 0 1px var(--line);
}
.hint > summary::after { display: none; }
.hint[open] > summary { background: var(--primary); color: var(--primary-text); }
.hint > :not(summary) {
  position: absolute; z-index: 20; top: 28px; left: -12px; width: min(300px, 78vw); margin: 0;
  padding: 10px 12px; border-radius: 12px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line); font: 400 var(--fs-sm)/1.45 var(--font-body);
}
.hint.end > :not(summary) { left: auto; right: -12px; }

/* --- stato vuoto: icona tenue e una frase --- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2); text-align: center;
  padding: var(--s-6) var(--s-4); border-radius: var(--radius-lg); background: var(--card); color: var(--muted);
}
.empty-state .icon { width: 28px; height: 28px; }
.empty-state p { margin: 0; max-width: 46ch; }
.empty-state strong { color: var(--text); font-family: var(--font-display); }

/* --- elenco compatto a righe (account adatti, sorgenti, letture, coda) --- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li {
  display: flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: 10px 0;
  border-top: 1px solid var(--line); min-width: 0;
}
.rows > li:first-child { border-top: 0; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; }
.row-title a { color: var(--text); text-decoration: none; }
@media (hover: hover) { .row-title a:hover { text-decoration: underline; } }
.row-sub { color: var(--muted); font-size: var(--fs-sm); }
.row-side { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s-2); }
.rows > li > .tag, .row-side .tag { flex: 0 0 auto; white-space: nowrap; overflow-wrap: normal; }
.rows > li > a.button, .rows > li > form, .row-side .button { flex: 0 0 auto; white-space: nowrap; overflow-wrap: normal; }
.rows > li > .plat { align-self: flex-start; margin-top: 2px; }
.row-main .actions { margin-top: var(--s-2); }
.rows form { margin: 0; }

/* --- account: una scheda per profilo, nel colore della piattaforma --- */
.profiles {
  list-style: none; margin: 0 0 var(--s-5); padding: 0; display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}
.profile {
  position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border-radius: var(--radius-lg); background: var(--row); box-shadow: var(--shadow-lg);
}
.profile-band {
  display: flex; align-items: flex-start; gap: 10px; height: 76px; padding: 12px 12px 0 14px;
  color: #ffffff; background: var(--surface-3);
}
.p-youtube .profile-band { background: linear-gradient(135deg, var(--yt), var(--yt-2)); }
.p-instagram .profile-band { background: var(--ig-grad); }
.p-tiktok .profile-band {
  background:
    radial-gradient(80% 140% at 0% 0%, rgba(37, 244, 238, 0.35), transparent 60%),
    radial-gradient(80% 140% at 100% 100%, rgba(254, 44, 85, 0.4), transparent 60%),
    var(--tt);
}
.profile-band .plat { width: 32px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, 0.2); box-shadow: none; }
.profile-band .plat .icon { width: 19px; height: 19px; }
/* Il logo di YouTube vero: rettangolo bianco, triangolo rosso. */
.p-youtube .profile-band .plat { background: #ffffff; color: var(--yt); }
.profile-band form { margin: 0; }
.profile-net { flex: 1 1 auto; font: 700 var(--fs-sm)/32px var(--font-body); letter-spacing: 0.01em; }
.profile-band .icon-btn { width: 36px; height: 36px; min-height: 36px; color: #ffffff; background: rgba(0, 0, 0, 0.2); box-shadow: none; }
.profile-band .icon-btn:focus-visible { outline-color: #ffffff; }
.profile-body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); padding: 0 var(--s-4) var(--s-4); flex: 1 1 auto; }
.profile-top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-2); width: 100%; }
.profile-avatar {
  display: grid; place-items: center; width: 72px; height: 72px; margin-top: -36px; flex: 0 0 auto;
  border-radius: 50%; object-fit: cover; background: var(--surface-3); color: var(--text);
  font: 700 var(--fs-xl)/1 var(--font-display); box-shadow: 0 0 0 4px var(--row);
}
.profile-name { margin: 2px 0 0; font-size: var(--fs-lg); line-height: 1.2; }
.profile-name a { color: var(--text); text-decoration: none; }
.profile-handle { margin: -6px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.profile-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); width: 100%;
  margin: var(--s-1) 0 0; padding: var(--s-3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.profile-stats > div { min-width: 0; }
.profile-stats dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.profile-stats dd { margin: 2px 0 0; font: 700 var(--fs-md)/1.2 var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: normal; }
.profile-note { margin: 0; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.profile-note.ko { color: var(--ko); }
.profile-foot { margin-top: auto; width: 100%; padding-top: var(--s-1); }
.profile-foot form { margin: 0; }
.profile-foot .button, .profile-foot button { width: 100%; }

/* Collega un profilo: due riquadri compatti (Google, Instagram). */
.connect { display: grid; gap: var(--s-3); grid-template-columns: minmax(0, 1fr); margin: 0 0 var(--s-5); }
.connect > .card { margin: 0; display: flex; flex-direction: column; }
.connect-head { display: flex; align-items: center; gap: var(--s-3); margin: 0 0 var(--s-3); }
.connect-head h2 { margin: 0; }
.connect-head p { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.connect details { margin-top: var(--s-1); }
.connect details > summary { min-height: 40px; padding: 4px 0; color: var(--muted); font-size: var(--fs-sm); }
.connect .actions { margin-top: auto; padding-top: var(--s-2); }
.safe-note { display: flex; align-items: center; gap: 8px; margin: var(--s-3) 0 0; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.safe-note .icon { color: var(--ok); }

/* Righe con un aiuto «?» dentro: sono `div` (un `details` dentro un `p` lo spezzerebbe). */
div.muted.small { margin: 0 0 10px; font-size: var(--fs-sm); }

/* Compiti, statistiche del post, Home: piccoli pezzi delle testate. */
.task-camp { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.task-camp a { color: var(--muted); text-decoration: none; }
@media (hover: hover) { .task-camp a:hover { color: var(--text); text-decoration: underline; } }
.post-head { align-items: center; }
.post-head > div { flex: 1 1 220px; min-width: 0; }
.subcard.best { display: flex; align-items: flex-start; gap: 10px; }
.subcard.best .plat { margin-top: 2px; }

/* Pagina dell'account: scheda del profilo a sinistra, collegamento e campagne a destra. */
.account-layout { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); margin: 0 0 var(--s-4); align-items: start; }
.account-side > .card:last-child { margin-bottom: 0; }
.card-head .plat.lg { width: 40px; height: 40px; }

/* --- revisione: video e decisione --- */
.review-card { padding: 16px; }
.clip-grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
.review-card .review-video { max-width: 280px; }
.review-top { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-3); }
.review-top h2 { margin: 0; font-size: var(--fs-lg); }
.review-top h2 a { color: var(--text); text-decoration: none; }
.facts-row { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.facts-row .figure { padding: 10px 12px; }
.facts-row .figure b { font-size: var(--fs-md); }
.screen-texts { margin: 0 0 var(--s-3); padding: 12px 14px; border-radius: 14px; background: var(--card-2); }
details.captions { margin: 0 0 var(--s-2); }
details.captions > summary { justify-content: flex-start; }
details.captions > summary::after { margin-left: auto; }
.caption { padding: 10px 0; border-top: 1px solid var(--line); }
.caption-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.caption pre { margin: 0; }
legend .plat { margin-right: 6px; }
.verdict { display: grid; gap: var(--s-2); grid-template-columns: minmax(0, 1fr); margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.verdict form { margin: 0; }
.reject-row { display: flex; gap: var(--s-2); }
.reject-row input { flex: 1 1 auto; min-width: 0; }
.reject-row button { flex: 0 0 auto; }

/* --- elenchi cliccabili con il marchio della piattaforma (statistiche, sessione, compiti) --- */
.list-card { padding: 6px 20px; }
.menu .plat { width: 32px; height: 32px; border-radius: 10px; }
.menu .plat .icon { width: 18px; height: 18px; }
.menu-side { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex: 0 0 auto; }
.menu-side small { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }

/* Numeri in fila dentro una scheda (Statistiche, Sistema, Sessione). */
.figure-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-3); list-style: none; padding: 0; }
.figure { background: var(--card); border-radius: 16px; padding: 12px 14px; min-width: 0; }
.card .figure { background: var(--card-2); }
.figure b { display: block; font: 700 var(--fs-xl)/1.15 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: normal; }
.figure span { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.figure.warn { background: var(--warn-bg); }
.figure.warn b { color: var(--warn); }
.figure.ko { background: var(--ko-bg); }
.figure.ko b { color: var(--ko); }

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .connect { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .next { grid-template-columns: minmax(0, 1fr) auto; }
  .next.has-forms { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 900px) {
  .app { --row: var(--surface-2); }
  .app .pub, .app .profile { box-shadow: none; }
  .camp-head { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--s-6); align-items: stretch; }
  .camp-head .media { aspect-ratio: 16 / 9; }
  .folds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .folds > .wide { grid-column: 1 / -1; }
  .next-forms.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .account-layout > .profile { position: sticky; top: 24px; }
  .clip-grid { grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
  .clip-grid .review-video { position: sticky; top: 24px; }
  /* Una sezione aperta prende tutta la riga: niente buchi accanto. */
  .folds > details[open] { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  /* Le quattro schede in due righe: tutte visibili senza scorrere. */
  .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 22px; }
  .seg a { padding: 6px 10px; }
  .toolbar { gap: 6px; }
}
@media (min-width: 900px) and (hover: hover) {
  .app .pub:hover { box-shadow: inset 0 0 0 1px var(--line); }
}
