/* ==========================================================================
   IBANWAY SMP - design system
   Accento rosso IBANWAY #C8102E, neutri grigio-blu, font di sistema, dark mode
   automatica (prefers-color-scheme). Nessuno stile inline: la CSP lo vieta.
   ========================================================================== */

/* --- Token ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Brand */
  --brand: #C8102E;
  --brand-hover: #A60D26;
  --brand-active: #8C0B20;
  --brand-fg: #B00E28;            /* rosso per testo su sfondo chiaro (AA) */
  --brand-soft: #FCEBEE;
  --brand-ring: rgba(200, 16, 46, .35);

  /* Neutri grigio-blu */
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-sunken: #EEF1F5;
  --border: #DDE2EA;
  --border-strong: #C5CCD8;
  --fg: #172033;
  --fg-muted: #525E73;            /* 6.4:1 su bianco */
  --fg-subtle: #7C879A;           /* icone dei campi, testi accessori */
  --sidebar-bg: #111827;
  --sidebar-fg: #C9D1DE;
  --sidebar-fg-strong: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(200, 16, 46, .18);
  --sidebar-border: rgba(255, 255, 255, .08);

  /* Semantici */
  --ok: #15803D;
  --ok-soft: #E8F6EE;
  --ko: #C81E1E;
  --ko-soft: #FDECEC;
  --warn: #A15C07;
  --warn-soft: #FEF4E2;
  --info: #1D5FB8;
  --info-soft: #E8F0FB;
  --busy: #6D3FC0;
  --busy-soft: #F1ECFB;

  /* Spaziatura (scala 4 px) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* Tipografia */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Forme */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --control-h: 38px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --focus: 0 0 0 3px var(--brand-ring);
  --sidebar-w: 256px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand-fg: #FF6B81;
    --brand-soft: rgba(200, 16, 46, .16);
    --brand-ring: rgba(255, 107, 129, .45);

    --bg: #0C1119;
    --surface: #141B26;
    --surface-2: #18202C;
    --surface-sunken: #0F151E;
    --border: #253041;
    --border-strong: #354257;
    --fg: #E6EAF1;
    --fg-muted: #A3AEC0;
    --fg-subtle: #7D899C;
    --sidebar-bg: #0A0F16;
    --sidebar-fg: #AEB8C8;
    --sidebar-border: rgba(255, 255, 255, .06);

    --ok: #4ADE80;
    --ok-soft: rgba(74, 222, 128, .12);
    --ko: #F87171;
    --ko-soft: rgba(248, 113, 113, .13);
    --warn: #FBBF24;
    --warn-soft: rgba(251, 191, 36, .12);
    --info: #60A5FA;
    --info-soft: rgba(96, 165, 250, .13);
    --busy: #B79BF5;
    --busy-soft: rgba(183, 155, 245, .14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }
a { color: var(--brand-fg); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
small { font-size: var(--text-sm); }
code, kbd, pre { font-family: var(--font-mono); font-size: .92em; }
code { padding: 0 .35em; border-radius: 4px; background: var(--surface-sunken); line-height: 1; vertical-align: baseline;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }
img, svg { vertical-align: middle; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
main:focus { outline: none; }

.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;
}
.skip-link {
  position: absolute; left: var(--s-3); top: -60px; z-index: 100;
  padding: var(--s-2) var(--s-3); border-radius: var(--radius);
  background: var(--brand); color: #fff; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--s-3); }

.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }

/* --- Icone ------------------------------------------------------------------ */
.icon {
  width: 16px; height: 16px; flex: none;
  stroke: currentColor; fill: none;
}
/* Marchi dei servizi (brands.svg): pieni, monocromi, leggermente più piccoli del riquadro Lucide. */
.icon.icon-brand { fill: currentColor; stroke: none; padding: 1px; }
.icon.icon-14 { width: 14px; height: 14px; }
.icon.icon-16 { width: 16px; height: 16px; }
.icon.icon-18 { width: 18px; height: 18px; }
.icon.icon-20 { width: 20px; height: 20px; }
.icon.icon-24 { width: 24px; height: 24px; }

/* --- Layout con barra laterale ----------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0;
  display: flex; flex-direction: column;
  width: var(--sidebar-w); height: 100vh; flex: none;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-4) var(--s-3);
}
.brand {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 5px;
  color: inherit; text-decoration: none; border-radius: var(--radius-sm);
}
.brand:focus-visible { outline: 2px solid #FF8597; outline-offset: 4px; }
/* Logo IBANWAY bianco (knockout): sempre su fondo scuro (barra laterale o riquadro del marchio). */
.brand-logo { display: block; height: 30px; width: auto; max-width: 100%; }
.brand-sub {
  font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--sidebar-fg); opacity: .8; line-height: 1.2;
}
.sidebar .sidebar-close { display: none; color: var(--sidebar-fg); }

.sidebar-nav { flex: 1; padding: var(--s-2) var(--s-3) var(--s-4); }
.nav, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav > li + li { margin-top: 2px; }
.nav-link {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 38px; padding: 7px var(--s-3);
  border-radius: var(--radius);
  color: var(--sidebar-fg); text-decoration: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-link .icon { width: 17px; height: 17px; opacity: .85; }
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.nav-link.is-active { color: var(--sidebar-fg-strong); }
a.nav-link.is-active { background: var(--sidebar-active); box-shadow: inset 3px 0 0 var(--brand); }
a.nav-link.is-active .icon { opacity: 1; color: #FF8597; }
.nav-link:focus-visible { outline: 2px solid #FF8597; outline-offset: -2px; }
.nav-link.is-disabled { cursor: default; opacity: .55; }
.nav-link.is-disabled:hover { background: transparent; color: var(--sidebar-fg); }
.nav-soon {
  margin-left: auto; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--sidebar-border); font-size: 10.5px; font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase;
}
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-caret { margin-left: auto; transition: transform .2s var(--ease); }
.nav-group[open] > summary .nav-caret { transform: rotate(180deg); }
.nav-sub { margin: 2px 0 var(--s-2) 20px; padding-left: var(--s-2); border-left: 1px solid var(--sidebar-border); }
.nav-sub .nav-link { min-height: 34px; padding: 6px var(--s-3); font-size: 13.5px; }
.nav-sub .nav-link .icon { width: 15px; height: 15px; }
.sidebar-foot { padding: var(--s-3) var(--s-4) var(--s-4); border-top: 1px solid var(--sidebar-border); }
.role-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--sidebar-fg);
}
.role-chip .icon { width: 14px; height: 14px; }
.role-chip.is-super .icon { color: #FF8597; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 60px; padding: var(--s-2) var(--s-6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .nav-toggle { display: none; }
.topbar-title { flex: 1; min-width: 0; font-weight: 600; color: var(--fg-muted); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: var(--s-3); }
.avatar {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-fg);
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { font-size: 14px; font-weight: 600; }
.user-meta small { font-size: 12px; color: var(--fg-muted); }
.logout-form { margin: 0; }

.content {
  flex: 1; width: 100%; max-width: 1280px;
  padding: var(--s-6) var(--s-6) var(--s-7);
}

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(8, 12, 20, .5);
}

/* --- Layout semplice (accesso, attivazione, errori senza login) --------------------- */
.layout-plain { min-height: 100vh; background:
  radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.plain { display: flex; justify-content: center; min-height: 100vh; padding: var(--s-7) var(--s-4); }
.plain-inner { width: 100%; max-width: 440px; }
.brand-plain {
  display: flex; align-items: center; gap: 8px; margin: 0 0 var(--s-5); padding: var(--s-5) var(--s-4);
  background: var(--sidebar-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  border-bottom: 3px solid var(--brand);
}
.brand-plain .brand-logo { height: 36px; }
.plain-foot { margin-top: var(--s-5); text-align: center; font-size: var(--text-xs); color: var(--fg-subtle); }
.auth-card { padding: var(--s-6); }
.auth-card h1 { font-size: var(--text-xl); margin-bottom: var(--s-2); }
.auth-step {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 var(--s-2);
  font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-fg);
}
.auth-step .icon { width: 14px; height: 14px; }
.auth-lead { margin: 0 0 var(--s-5); color: var(--fg-muted); font-size: 14.5px; }
.auth-alert { margin-bottom: var(--s-4); }
.auth-form .form-actions { margin-top: var(--s-5); }
.auth-note { margin: var(--s-5) 0 0; font-size: 13.5px; color: var(--fg-muted); text-align: center; }
.auth-who { margin: var(--s-3) 0 var(--s-5); padding: var(--s-3) var(--s-4);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius, 8px); }
.auth-steps { margin: var(--s-3) 0 var(--s-4); padding-left: 1.3em; color: var(--fg-muted); font-size: 14px; }
.auth-steps li + li { margin-top: 4px; }
.qr-box {
  display: flex; justify-content: center; margin: 0 auto var(--s-3); padding: var(--s-3);
  width: fit-content; background: #fff; border: 1px solid var(--border); border-radius: var(--radius, 8px);
}
.qr-box svg { display: block; }
.totp-manual { margin: 0 0 var(--s-5); font-size: 13.5px; color: var(--fg-muted); text-align: center; }
.totp-secret { display: inline-block; margin-top: 6px; padding: 4px 8px; font-size: 14px;
  letter-spacing: .08em; word-break: break-all; user-select: all; color: var(--fg); }

/* --- Intestazione di pagina ---------------------------------------------------------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: var(--s-4); margin-bottom: var(--s-5);
}
.page-heading { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.page-icon {
  display: inline-grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand-fg);
}
.page-icon .icon { width: 20px; height: 20px; }
.page-subtitle { margin: 2px 0 0; color: var(--fg-muted); font-size: 14px; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* --- Card ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s-5);
}
.card + .card { margin-top: var(--s-4); }
.content > :where(.card, form, section, .card-grid, .table-wrap) + :where(.card, form, section, .card-grid, .table-wrap) { margin-top: var(--s-4); }
.card-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card-grid > .card + .card { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.card-head h2 { display: flex; align-items: center; gap: var(--s-2); font-size: 15.5px; }
.card-head h2 .icon { color: var(--fg-subtle); width: 17px; height: 17px; }
.card-desc { margin: calc(-1 * var(--s-3)) 0 var(--s-4); color: var(--fg-muted); font-size: 14px; }
.card-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  margin-top: var(--s-4);
}
.card-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-2);
  margin: var(--s-5) calc(-1 * var(--s-5)) calc(-1 * var(--s-5));
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.stat { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--fg-muted); }

/* --- Bottoni --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control-h); padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease),
              color .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-primary:active:not(:disabled) { background: var(--brand-active); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--fg-subtle); }
.btn-danger { background: var(--ko); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-danger-quiet { background: transparent; color: var(--ko); border-color: color-mix(in srgb, var(--ko) 40%, transparent); }
.btn-danger-quiet:hover:not(:disabled) { background: var(--ko-soft); border-color: var(--ko); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); color: var(--fg); }
.btn-sm { min-height: 32px; padding: 0 var(--s-3); font-size: 13px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--fg-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--fg); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.icon-btn .icon { width: 18px; height: 18px; }

/* --- Form (regole grafiche: più campi per riga, larghezza = contenuto) --------------- */
.form-section + .form-section { margin-top: var(--s-5); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.form-section-title {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-3);
  font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-muted);
}
.form-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-start; }
.form-row + .form-row { margin-top: var(--s-4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-top: var(--s-5); }

.field { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%; }
.field.grow { flex-grow: 1; }
.field > label, .label-row > label {
  font-size: 13.5px; font-weight: 600; color: var(--fg);
}
.req { color: var(--brand-fg); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }

/* Larghezze di riferimento (decisione 9) */
.w-email { width: 320px; }
.w-time { width: 120px; }
.w-num { width: 110px; }
.w-host { width: 260px; }
.w-port { width: 110px; }
.w-long { width: 380px; }
.w-name { width: 220px; }
.w-date { width: 170px; }
.w-full { width: 100%; flex-basis: 100%; }

.control { position: relative; }
.control-row { display: flex; gap: var(--s-2); align-items: center; }
.control-row > .control { flex: 1; min-width: 0; }
.control .control-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--fg-subtle); pointer-events: none;
}
.control.is-textarea .control-icon { top: 12px; transform: none; }

/* :where() azzera la specificità, così .control.has-icon può aggiungere il padding per l'icona */
input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])),
select, textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit; font-size: 14.5px; line-height: 1.4;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.control.has-icon input, .control.has-icon select, .control.has-icon textarea { padding-left: 34px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--fg-subtle); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--fg-subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled, input[readonly], textarea[readonly] {
  background: var(--surface-sunken); color: var(--fg-muted); cursor: not-allowed;
}
input[type="time"], input[type="number"], input[data-amount] { font-variant-numeric: tabular-nums; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C879A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--ko); }
.field.has-error input:focus, .field.has-error textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ko) 30%, transparent); }
.field-help { margin: 0; font-size: 12.5px; color: var(--fg-muted); }
.field-error { margin: 0; font-size: 13px; }

.secret-state {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--fg-subtle); font-family: var(--font-mono);
}
.secret-state .icon { width: 13px; height: 13px; }
.secret-state.is-set { color: var(--ok); }

/* Opzione allineata (macro option/checkbox/radio): casella | icona + etichetta; suggerimento sotto il testo. */
.check { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 2px var(--s-2); }
.check > input { margin-top: 1px; }
.check-label { display: inline-flex; align-items: flex-start; gap: 6px; min-width: 0; font-size: 14px; line-height: 20px; cursor: pointer; }
.check-label .check-icon { width: 15px; height: 15px; margin-top: 2.5px; color: var(--fg-subtle); }
.check-note { font-family: var(--font-mono); font-size: 12px; color: var(--fg-subtle); }
.check .field-help { grid-column: 2; margin: 0; padding-left: 21px; }
.check.is-disabled .check-label { cursor: default; color: var(--fg-muted); }
.option-tiles { gap: var(--s-2) var(--s-3); }
.option-tiles .check { flex: 1 1 200px; align-self: stretch; align-content: start; padding: 10px var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.option-tiles .check:has(input:checked) { border-color: var(--border-strong); background: var(--surface); }
.option-tiles .check-label { font-weight: 600; }
.option-note { display: flex; align-items: center; gap: 6px; margin: var(--s-3) 0 0; font-size: 13px; color: var(--fg-muted); }
.option-note .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.card-note { display: flex; align-items: flex-start; gap: var(--s-2); }
.card-note > .icon { width: 15px; height: 15px; margin-top: 3px; color: var(--fg-subtle); }
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; margin: 0; flex: none;
  accent-color: var(--brand); cursor: pointer;
}
.check-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.check-row .check { min-width: 64px; }
.check-list { display: flex; flex-direction: column; gap: var(--s-3); border: 0; padding: 0; margin: 0 0 var(--s-3); min-width: 0; }

/* Calendario: una riga per giorno della settimana (attivo + orari propri, vuoti = predefiniti) */
.day-rows { display: flex; flex-direction: column; }
.day-row { padding: var(--s-3) 0 var(--s-3) var(--s-3); border-left: 3px solid transparent; }
.day-row + .day-row { border-top: 1px solid var(--border); }
.day-row.is-custom { border-left-color: var(--brand); background: var(--surface-2); }
.day-name { flex: 0 0 auto; width: 120px; padding-bottom: 9px; }
.day-reset { justify-content: flex-end; }

@media (max-width: 760px) {
  .field, .field.grow { flex: 1 1 100%; width: 100%; }
  .control-row { flex-wrap: wrap; }
  .day-name { width: 100%; padding-bottom: 0; }
}

/* --- Esiti OK/KO: check o x dentro un cerchio ------------------------------------- */
.iw-ok, .iw-warn, .iw-ko { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.iw-ok { color: var(--ok); }
.iw-warn { color: var(--warn); }
.iw-ko { color: var(--ko); }
.iw-off { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--fg-muted); }
.iw-off .icon { width: 18px; height: 18px; }
.iw-ok .icon, .iw-warn .icon, .iw-ko .icon { width: 18px; height: 18px; }
.field-error .iw-ko .icon { width: 15px; height: 15px; }

/* --- Badge di stato --------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 20px; white-space: nowrap;
  border: 1px solid transparent;
}
.badge .icon { width: 13px; height: 13px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--ko-soft); color: var(--ko); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-busy { background: var(--busy-soft); color: var(--busy); }
.badge-busy .icon { animation: pulse 1.6s ease-in-out infinite; }
.badge-muted { background: var(--surface-sunken); color: var(--fg-muted); border-color: var(--border); }
.badge-brand { background: var(--brand-soft); color: var(--brand-fg); }

/* --- Messaggi flash ----------------------------------------------------------------- */
.flash-area:not(:has(.flash)) { display: none; }
.flash-area { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-5); }
.flash {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-2) var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
  animation: flash-in .25s var(--ease);
}
.flash p { flex: 1; margin: 0; padding-top: 1px; font-size: 14.5px; }
.flash > .iw-ok, .flash > .iw-ko, .flash > .icon { margin-top: 2px; }
.flash .flash-icon { width: 18px; height: 18px; }
.flash-close { width: 28px; height: 28px; margin-top: -3px; }
.flash-close .icon { width: 16px; height: 16px; }
.flash-ok { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 60%, var(--surface)); }
.flash-ko { border-left-color: var(--ko); background: color-mix(in srgb, var(--ko-soft) 60%, var(--surface)); }
.flash-warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-soft) 60%, var(--surface)); }
.flash-warn .flash-icon { color: var(--warn); }
.flash-info { border-left-color: var(--info); background: color-mix(in srgb, var(--info-soft) 60%, var(--surface)); }
.flash-info .flash-icon { color: var(--info); }

/* --- Tabelle --------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px var(--s-4); text-align: left; vertical-align: middle; }
.table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-muted);
  white-space: nowrap;
}
.table tbody tr + tr td { border-top: 1px solid var(--border); }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table-empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--fg-muted); }

/* --- Stati vuoti ed errori ----------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: var(--s-7) var(--s-4); text-align: center; color: var(--fg-muted);
}
.empty .icon { width: 28px; height: 28px; color: var(--fg-subtle); }

.error-page {
  max-width: 520px; margin: var(--s-7) auto; padding: var(--s-6);
  text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.error-page.is-plain { margin-top: 0; }
.error-icon {
  display: inline-grid; place-items: center;
  width: 52px; height: 52px; margin-bottom: var(--s-3); border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-fg);
}
.error-icon .icon { width: 24px; height: 24px; }
.error-code { margin: 0 0 var(--s-1); font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-subtle); }
.error-page h1 { font-size: var(--text-xl); margin-bottom: var(--s-2); }
.error-message { color: var(--fg-muted); }
.error-actions { margin-top: var(--s-5); display: flex; justify-content: center; gap: var(--s-2); }

/* --- Varie ----------------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); margin: 0; font-size: 14px; }
.kv dt { color: var(--fg-muted); }
.kv dd { margin: 0; }
.stack > * + * { margin-top: var(--s-4); }
.inline { display: inline-flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* HTMX: indicatori di caricamento (stili inclusi qui perché la CSP blocca quelli iniettati) */
.htmx-indicator { opacity: 0; transition: opacity .2s var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.htmx-request.btn, .htmx-request .btn[type="submit"] { opacity: .7; pointer-events: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* --- Responsive ------------------------------------------------------------------ */
@media (max-width: 1024px) {
  .topbar { padding: var(--s-2) var(--s-4); }
  .content { padding: var(--s-5) var(--s-4) var(--s-6); }
  .topbar .nav-toggle { display: inline-grid; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s var(--ease), visibility .25s;
    visibility: hidden;
    box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .sidebar .sidebar-close { display: inline-grid; }
  .sidebar .sidebar-close:hover { background: var(--sidebar-hover); color: #fff; }
  .nav-open { overflow: hidden; }
}
@media (max-width: 640px) {
  h1 { font-size: var(--text-xl); }
  .user-meta, .hide-sm { display: none; }
  .card { padding: var(--s-4); }
  .card-foot { margin: var(--s-4) calc(-1 * var(--s-4)) calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4); }
  .page-header { align-items: flex-start; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: var(--s-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .topbar, .flash-close, .page-actions, .form-actions { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}

/* --- Setup ----------------------------------------------------------------------- */
.setup-card { display: flex; flex-direction: column; gap: var(--s-2); color: inherit; text-decoration: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.setup-card:hover { border-color: var(--fg-subtle); box-shadow: var(--shadow-sm); }
.setup-card:focus-visible { outline: none; box-shadow: var(--focus); }
.setup-card-head { display: flex; align-items: center; gap: var(--s-3); }
.setup-card-title { font-weight: 650; font-size: 15.5px; flex: 1; }
.setup-card-summary { color: var(--fg-muted); font-size: 13.5px; }
.setup-card-go { display: inline-flex; align-items: center; gap: 4px; margin-top: auto; font-size: 13px; font-weight: 600; color: var(--brand-fg); }
.setup-card-go .icon { width: 14px; height: 14px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.readonly-value { display: flex; align-items: center; gap: var(--s-2); margin: 0; min-height: var(--control-h);
  padding: 0 11px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--fg-muted); font-size: 14.5px; }
.readonly-value .icon { width: 15px; height: 15px; color: var(--fg-subtle); flex: none; }
.form-note { margin-top: var(--s-4); }
.prompt-preview { margin: 0; padding: var(--s-3) var(--s-4); background: var(--surface-sunken); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.example-item { padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--radius); }
.example-item .form-actions { margin-top: var(--s-3); }
.example-item.is-new { border-style: dashed; }
.inline-result { margin: 0; font-size: 14px; }
.inline-form { display: inline; }
.table tr.is-inactive td { color: var(--fg-muted); }
.table tr.is-editing td { background: var(--surface-2); }
.pillar-desc { max-width: 420px; color: var(--fg-muted); }
.test-result { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font-size: 14px; }
.test-result .test-service { color: var(--fg-subtle); }
.status-list { display: grid; gap: var(--s-2); margin: 0 0 var(--s-4); padding: 0; list-style: none; font-size: 14px; }
.status-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.live-state { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 650; }
.warn-text { color: var(--warn); }
.test-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-4); }
.test-busy { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg-muted); }
.test-busy .icon { width: 15px; height: 15px; animation: spin 1s linear infinite; }
.test-result .subtle { margin-left: var(--s-2); }
.w-price { width: 150px; }
.card-head .badge { flex: none; }
.connect-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-4); }
.test-busy.htmx-indicator { display: none; }
.test-busy.htmx-indicator.htmx-request { display: inline-flex; }
.card-pair { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); align-items: start; }
.card-pair > .card + .card { margin-top: 0; }
.content > .card-pair + *, .content > * + .card-pair { margin-top: var(--s-4); }
.form-actions .test-row { margin-top: 0; }
@media (max-width: 760px) { .card-pair { grid-template-columns: 1fr; } }

/* --- Dashboard e bozze (Task W7) ------------------------------------------------------- */
.form-row-end { align-items: flex-end; }
.field-button, .field-check { justify-content: flex-end; min-height: var(--control-h); }
.field-check { padding-bottom: 8px; }
.w-status { width: 240px; }
.nowrap { white-space: nowrap; }
.card-flush { padding: 0; overflow: hidden; }
.card-head-pad { padding: var(--s-4) var(--s-5) 0; }
.card-flush > .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.card-flush > .table-empty { margin: 0; }
.filter-bar { padding-top: var(--s-4); padding-bottom: var(--s-4); }

.dash-card { display: flex; flex-direction: column; gap: var(--s-1); }
.dash-card .card-head { margin-bottom: var(--s-2); }
.dash-main { margin: 0; font-size: var(--text-lg); font-weight: 650; }
.dash-sub { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: var(--s-1) 0 0; }
.dash-note { margin: var(--s-1) 0 0; font-size: 13.5px; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; }
.dash-note.warn-text { color: var(--warn); }
.dash-note .icon { width: 15px; height: 15px; flex: none; }
.dash-list { margin: var(--s-2) 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13.5px; }
.dash-errors li { display: flex; gap: var(--s-2); min-width: 0; }
.clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { margin: 0; }
.stat-ko { color: var(--ko); }
.stat-unit { font-size: 14px; font-weight: 600; color: var(--fg-muted); letter-spacing: 0; }
.stat-label { margin: 0; }
.cost-split { list-style: none; margin: var(--s-3) 0 0; padding: var(--s-2) 0 0; border-top: 1px solid var(--border);
  display: grid; gap: 6px; font-size: 13.5px; }
.cost-split li { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.cost-split .cost-logo { color: var(--fg-muted); }
.cost-name { flex: 1; min-width: 0; font-weight: 600; }
.cost-name small { display: block; font-weight: 400; color: var(--fg-subtle); font-size: 12px; line-height: 1.3; }
.cost-amount { font-weight: 650; white-space: nowrap; }
.cost-amount .stat-unit { font-size: 11.5px; }

.channel-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--fg-muted); }
.channel-tag .icon { width: 14px; height: 14px; color: var(--fg-subtle); }

.queue-wrap { margin: 0; }
.queue th, .queue td { padding: 8px var(--s-4); }
.queue tbody th { font-weight: 500; text-align: left; }
.queue-day { white-space: nowrap; }
.queue tr.is-today th, .queue tr.is-today td { background: var(--brand-soft); }
.queue tr.is-off th { color: var(--fg-muted); }
.queue-off { font-size: 12px; margin-left: var(--s-1); }
.queue-cell { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; color: inherit; border-radius: var(--radius-sm); }
.queue-cell:hover .queue-id { color: var(--brand-fg); text-decoration: underline; }
.queue-id { font-size: 13px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border); background: var(--surface-2); }
.pager-info { font-size: 13.5px; color: var(--fg-muted); }
.topic-cell { max-width: 360px; }

/* dettaglio bozza */
.draft-status-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-bottom: var(--s-4); font-size: 14px; }
.draft-status-row .icon { width: 15px; height: 15px; }
.draft-error { margin-bottom: var(--s-4); }
.draft-error p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.draft-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.content > .draft-layout + .card, .content > .card + .card-pair { margin-top: var(--s-4); }
@media (max-width: 1100px) { .draft-layout { grid-template-columns: minmax(0, 1fr); } }
.preview-card > .card-head { flex-wrap: wrap; }

.busy-box { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); padding: var(--s-3) var(--s-4);
  border: 1px solid color-mix(in srgb, var(--busy) 30%, transparent); border-radius: var(--radius-lg);
  background: var(--busy-soft); color: var(--busy); }
.busy-title { margin: 0; font-weight: 650; }
.busy-text { margin: 0; font-size: 13.5px; color: var(--fg-muted); }

.char-count { margin: 6px 0 0; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--fg-muted); }
.card-head .char-count { margin: 0; }
.char-count.is-ok { color: var(--ok); }
.char-count.is-out { color: var(--warn); }
.warn-list { margin: var(--s-3) 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }

/* anteprima in stile feed */
.preview { max-width: 555px; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 8px; }
.preview-avatar { display: inline-grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%;
  background: #0A66C2; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.preview-facebook .preview-avatar { width: 40px; height: 40px; font-size: 15px; background: #1877F2; }
.preview-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.preview-name { font-size: 14px; font-weight: 650; color: var(--fg); }
.preview-sub { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--fg-muted); }
.preview-sub .icon { width: 12px; height: 12px; }
.preview-text { padding: 0 16px 12px; font-size: 14px; line-height: 1.45; color: var(--fg); overflow-wrap: anywhere; }
.preview-facebook .preview-text { font-size: 15px; }
.hashtag { color: #0A66C2; font-weight: 600; }
.preview-facebook .hashtag { color: #1877F2; font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .hashtag { color: #71B7FB; }
  .preview-facebook .hashtag { color: #5AA7FF; }
}
.preview-media { margin: 0; aspect-ratio: 4 / 5; background: var(--surface-sunken); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.preview-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.preview-actions { display: flex; justify-content: space-around; gap: var(--s-2); padding: 6px 8px; color: var(--fg-muted); font-size: 13px; font-weight: 600; }
.preview-actions span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; }
.preview-actions .icon { width: 16px; height: 16px; }
/* anteprima in stile Instagram */
.preview-instagram .preview-avatar { width: 32px; height: 32px; font-size: 13px; background: #C13584; }
.preview-instagram .preview-head { padding: 10px 12px; }
.preview-instagram .preview-media { border-top: 0; }
.preview-instagram .preview-actions { justify-content: flex-start; gap: var(--s-1); padding: 6px 8px 0; }
.preview-instagram .preview-actions .icon { width: 22px; height: 22px; }
.preview-instagram .preview-actions .preview-save { margin-left: auto; }
.preview-instagram .preview-text { padding-top: 8px; font-size: 14px; }
.preview-instagram .preview-text .preview-name { margin-right: 4px; }
.preview-instagram .hashtag { color: #00376B; font-weight: 500; }
.preview-instagram .preview-more { color: var(--fg-muted); }
.preview-instagram .preview-missing { margin: 0; padding: var(--s-4); background: var(--surface-sunken); }
.preview-checks { margin: 0; padding: var(--s-2) var(--s-3) var(--s-3); list-style: none; display: flex; flex-wrap: wrap;
  gap: var(--s-1) var(--s-3); font-size: 13px; border-top: 1px solid var(--border); }
.preview-checks .preview-checks-note { flex-basis: 100%; }
.preview-full { margin: 0 var(--s-3) var(--s-3); font-size: 13px; color: var(--fg-muted); }
.preview-full > summary { cursor: pointer; }
.preview-full .preview-text { padding: var(--s-2) 0 0; color: var(--fg); }
.approve-blockers { margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--border);
  border-left: 3px solid var(--warn); border-radius: var(--radius); background: var(--surface-2); }
.approve-blockers-title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; font-weight: 650; }
.approve-blockers-title .icon, .approve-blockers .warn-line .icon { width: 15px; height: 15px; color: var(--warn); }
.approve-blockers .warn-list { margin-top: var(--s-2); }
.approve-blockers .warn-line { display: flex; align-items: center; gap: 6px; }
@media (prefers-color-scheme: dark) {
  .preview-instagram .hashtag { color: #E0F1FF; }
}
@media (max-width: 480px) {
  .preview-actions { flex-wrap: wrap; justify-content: space-between; gap: 0; font-size: 12px; }
  .preview-actions span { padding: 6px 4px; gap: 4px; }
  .preview-actions .icon { width: 14px; height: 14px; }
}

/* azioni */
.action-buttons { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-3); }
.action-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.action-panel + .action-panel { margin-top: var(--s-2); }
.action-panel > summary { display: flex; align-items: center; gap: var(--s-2); padding: 10px var(--s-3); cursor: pointer;
  font-size: 14px; font-weight: 600; list-style: none; border-radius: var(--radius); }
.action-panel > summary::-webkit-details-marker { display: none; }
.action-panel > summary .icon { width: 16px; height: 16px; color: var(--fg-subtle); }
.action-panel > summary:focus-visible { outline: none; box-shadow: var(--focus); }
.action-panel > summary:hover { background: var(--surface-sunken); }
.action-panel[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.action-panel > form { padding: var(--s-3); }
.action-panel .form-actions { margin-top: var(--s-3); }
.retry-form { display: grid; gap: var(--s-2); justify-items: start; }
.action-panel + .retry-form, .action-buttons + .retry-form { margin-top: var(--s-4); }

.source-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.source-list a { display: inline-flex; align-items: flex-start; gap: 6px; overflow-wrap: anywhere; }
.source-list .icon { width: 14px; height: 14px; flex: none; margin-top: 4px; }
.prompt-card > summary { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; font-weight: 650; font-size: 15.5px; list-style: none; }
.prompt-card > summary::-webkit-details-marker { display: none; }
.prompt-card > summary .icon { width: 17px; height: 17px; color: var(--fg-subtle); }
.prompt-card[open] > summary { margin-bottom: var(--s-3); }

.version-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--s-3); }
.version-item + .version-item { padding-top: var(--s-3); border-top: 1px solid var(--border); }
.version-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); font-size: 14px; }
.version-what { flex: 1; min-width: 200px; color: var(--fg-muted); overflow-wrap: anywhere; }
.version-cost { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.version-cost .icon { width: 14px; height: 14px; }
.diff { margin: var(--s-2) 0 0; padding: var(--s-2) 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; overflow: auto; }
.diff > span { display: block; padding: 0 var(--s-3) 0 calc(var(--s-3) + 14px); position: relative; }
.diff > span::before { position: absolute; left: var(--s-2); color: var(--fg-subtle); }
.diff .diff-add { background: var(--ok-soft); }
.diff .diff-add::before { content: "+"; color: var(--ok); }
.diff .diff-del { background: var(--ko-soft); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ko) 50%, transparent); }
.diff .diff-del::before { content: "\2212"; color: var(--ko); }
.diff .diff-gap { color: var(--fg-subtle); }
.event-msg { max-width: 520px; font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
.table tr.event-error td { background: color-mix(in srgb, var(--ko-soft) 60%, transparent); }
@media (max-width: 760px) {
  .field-button, .field-check { min-height: 0; }
  .pager { padding: var(--s-3) var(--s-4); }
  .card-head-pad { padding: var(--s-4) var(--s-4) 0; }
}

/* --- Log (Task W8) --- */
.tabs {
  display: flex; flex-wrap: wrap; gap: var(--s-1);
  margin-bottom: var(--s-4); border-bottom: 1px solid var(--border);
}
.tab {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4); margin-bottom: -1px;
  border-bottom: 2px solid transparent; color: var(--fg-muted); font-weight: 500; text-decoration: none;
}
.tab .icon { width: 16px; height: 16px; }
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--brand-fg); border-bottom-color: var(--brand); }
.expand { max-width: 560px; }
.expand > summary { cursor: pointer; font-size: 13px; overflow-wrap: anywhere; list-style: none; }
.expand > summary::-webkit-details-marker { display: none; }
.expand-more { color: var(--brand-fg); font-weight: 500; white-space: nowrap; }
.expand[open] > summary { display: none; }
.log-table td { vertical-align: top; }

/* --- Utenti (Task W8) --- */
.w-role { width: 200px; }
.role-form { display: inline-flex; align-items: center; gap: var(--s-1); }
.select-sm { width: auto; min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13.5px; }
.issued-link { border-color: var(--ok); }
.issued-link .card-head h2 { display: flex; align-items: center; gap: var(--s-2); overflow-wrap: anywhere; }
.issued-link input[readonly] { cursor: text; color: var(--fg); background: var(--surface-2); }
.uncertain-warning { margin-bottom: var(--s-4); }
.uncertain-warning p { margin: 0; }
.action-buttons .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ack-form { margin-bottom: var(--s-4); }
.ack-form .inline { gap: var(--s-3); }

/* Pubblicazione simulata (piattaforma in prova): avviso e «Riporta in bozza» */
.simulated-notice { margin-bottom: var(--s-3); }
.simulated-notice p { margin: 0; }
.simulated-notice code { overflow-wrap: anywhere; }
.reopen-form { display: grid; gap: var(--s-2); justify-items: start; margin-bottom: var(--s-4); }
.sim-mark { margin-left: var(--s-1); font-size: 12.5px; white-space: nowrap; }

/* Task B1: scarto con motivo, apprendimento */
.pre-line { white-space: pre-line; }
.card-desc-pad { margin: var(--s-2) var(--s-5) var(--s-4); }
.table tr.is-excluded td { color: var(--fg-muted); }
.table tr.is-excluded .event-msg { text-decoration: line-through; text-decoration-color: var(--border-strong, var(--border)); }
@media (max-width: 760px) { .card-desc-pad { margin: var(--s-2) var(--s-4) var(--s-4); } }

/* --- Galleria immagini (Task B2) -------------------------------------------------------- */
.w-src { width: 170px; }
.upload-panel { margin-bottom: var(--s-4); }
.upload-panel .check { margin-top: var(--s-3); }
.content > .filter-bar + .card { margin-top: var(--s-4); }
.gallery-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.gallery-item { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; }
.gallery-item.is-current { border-color: var(--info); box-shadow: 0 0 0 1px var(--info); }
.gallery-thumb { display: block; aspect-ratio: 4 / 5; background: var(--surface-sunken); }
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb:focus-visible { outline: 2px solid var(--accent, #C8102E); outline-offset: -2px; }
.gallery-missing { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  height: 100%; font-size: 13px; color: var(--fg-muted); }
.gallery-missing .icon { width: 22px; height: 22px; color: var(--fg-subtle); }
.gallery-meta { display: flex; flex-direction: column; gap: 6px; padding: var(--s-2) var(--s-3) var(--s-3); font-size: 13px; }
.gallery-meta p { margin: 0; }
.gallery-alt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; }
.gallery-info { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.gallery-topic { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-pick { margin-top: 2px; }
.gallery-full { margin: 0; }
.gallery-full img { display: block; width: 100%; height: auto; max-height: 78vh; object-fit: contain;
  border-radius: var(--radius); background: var(--surface-sunken); }
.gallery-detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .gallery-detail { grid-template-columns: minmax(0, 1fr); } }
.pick-help { margin: 0 0 var(--s-4); }
.action-link { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-2);
  padding: 10px var(--s-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.action-link .field-help { margin: 0; }
@media (max-width: 480px) { .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); } }

/* --- Articoli di blog (WordPress) --- */
.channel-tag.channel-wp .icon { color: var(--fg-subtle); }
.preview-article { max-width: 720px; padding: var(--s-4) var(--s-5) var(--s-5); }
.article-head { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.article-site { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-2); margin: 0; font-size: 13px;
  font-weight: 600; color: var(--fg-muted); }
.article-site .icon { width: 14px; height: 14px; color: var(--fg-subtle); }
.article-site .mono { font-weight: 400; overflow-wrap: anywhere; }
.article-title { margin: 0; font-size: 24px; line-height: 1.25; color: var(--fg); }
.article-excerpt { margin: 0; font-size: 14px; color: var(--fg); }
.article-taxonomy { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.article-media { margin: 0 0 var(--s-4); }
.article-media img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: cover;
  border-radius: var(--radius); background: var(--surface-sunken); }
.article-media figcaption { margin-top: 4px; font-size: 12px; }
.article-body { font-size: 15px; line-height: 1.65; color: var(--fg); overflow-wrap: anywhere; }
.article-body h2 { margin: var(--s-5) 0 var(--s-2); font-size: 19px; line-height: 1.3; }
.article-body h3 { margin: var(--s-4) 0 var(--s-2); font-size: 16px; }
.article-body p, .article-body ul, .article-body ol { margin: 0 0 var(--s-3); }
.article-body ul, .article-body ol { padding-left: 1.4em; }
.article-body blockquote { margin: 0 0 var(--s-3); padding-left: var(--s-3); border-left: 3px solid var(--border);
  color: var(--fg-muted); }
.article-body a { color: var(--brand-fg); }
/* scheda «Blog WordPress» */
.blog-card > form > .field-help { margin: 0; }
.blog-sites { margin: var(--s-3) 0 0; padding: 0; list-style: none; }
.blog-site { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px var(--s-4);
  min-height: 44px; padding: var(--s-2) 0; border-top: 1px solid var(--border); }
.blog-site:last-child { border-bottom: 1px solid var(--border); }
.blog-site > .check { flex: 1 1 auto; }
.blog-site > .check .check-label { font-weight: 600; }
.blog-site-name { display: inline-flex; align-items: center; gap: 6px; padding-left: 26px; font-size: 14px; font-weight: 600; }
.blog-site-name .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.blog-site-status { margin-left: auto; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-2); font-size: 13px; }
.blog-site-status > a { display: inline-flex; align-items: center; gap: 6px; }
.blog-site-status > .icon, .blog-site-status > a .icon { width: 14px; height: 14px; }
.blog-site-status > a .icon, .blog-site-status.subtle .icon { color: var(--fg-subtle); }
.blog-card .card-note { margin: 0; font-size: 14px; }
.icon.spin { animation: spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .icon.spin { animation: none; } }
.help-card summary { display: flex; align-items: center; gap: var(--s-2); cursor: pointer; font-weight: 600; }
.help-steps { margin: var(--s-3) 0; padding-left: 1.4em; display: grid; gap: 4px; font-size: 14px; }
@media (max-width: 760px) { .preview-article { padding: var(--s-3); } .article-title { font-size: 20px; } }

/* Task C1: regole permanenti */
.table td.rule-text { width: 55%; min-width: 260px; }

/* --- Assistente in chat (Task C2) ------------------------------------------------ */
.assistant-layout { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
@media (max-width: 900px) { .assistant-layout { grid-template-columns: minmax(0, 1fr); } .assistant-layout .thread-card { order: 2; } }
.thread-list { list-style: none; margin: 0; padding: 0 0 var(--s-2); max-height: 70vh; overflow-y: auto; }
.thread-link { display: flex; align-items: flex-start; gap: var(--s-2); padding: var(--s-2) var(--s-4); color: var(--fg); text-decoration: none; border-left: 3px solid transparent; }
.thread-link:hover { background: var(--surface-2); }
.thread-link.is-active { background: var(--brand-soft); border-left-color: var(--brand); }
.thread-link > .icon { flex: none; width: 15px; height: 15px; margin-top: 4px; color: var(--fg-subtle); }
.thread-text { display: flex; flex-direction: column; min-width: 0; }
.thread-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.thread-text small { color: var(--fg-muted); font-size: 12px; }
.thread-draft { margin: 0 0 var(--s-2); }
.chat-anchor { scroll-margin-top: var(--s-4); }
.chat-panel .card-head { justify-content: space-between; }
.chat-cost { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chat-cost .icon { width: 14px; height: 14px; }
.chat-log { display: flex; flex-direction: column; gap: var(--s-3); max-height: 60vh; overflow-y: auto; padding: var(--s-1) 2px var(--s-3); overscroll-behavior: contain; }
.chat-empty { display: flex; gap: var(--s-2); margin: 0; padding: var(--s-3); border-radius: var(--radius); background: var(--surface-2); color: var(--fg-muted); font-size: 14px; }
.chat-empty .icon { flex: none; width: 16px; height: 16px; margin-top: 3px; color: var(--fg-subtle); }
.chat-msg { max-width: 92%; padding: var(--s-2) var(--s-3); border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.chat-user { align-self: flex-end; background: var(--surface-sunken); border-color: transparent; }
.chat-assistant { align-self: flex-start; }
.chat-msg.is-error { border-color: color-mix(in srgb, var(--ko) 35%, transparent); background: var(--ko-soft); }
.chat-msg.is-pending { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--busy); background: var(--busy-soft); border-color: color-mix(in srgb, var(--busy) 30%, transparent); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: 2px; font-size: 12px; color: var(--fg-muted); }
.chat-who { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.chat-who .icon { width: 13px; height: 13px; color: var(--fg-subtle); }
.chat-time { font-size: 12px; color: var(--fg-subtle); font-variant-numeric: tabular-nums; }
.chat-body { overflow-wrap: anywhere; }
.chat-body p { margin: 0; }
.chat-body p + p, .chat-body p + ul, .chat-body ul + p { margin-top: var(--s-2); }
.chat-body ul { margin: 0; padding-left: 1.2em; }
.chat-done { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.chat-done .iw-ok .icon { width: 15px; height: 15px; }
.chat-note { display: flex; align-items: flex-start; gap: var(--s-2); align-self: center; max-width: 95%; padding: 6px var(--s-3); border-radius: var(--radius); background: var(--info-soft); color: var(--fg); font-size: 13px; }
.chat-note .icon { flex: none; width: 14px; height: 14px; margin-top: 3px; color: var(--info); }
.chat-note .chat-time { margin-left: auto; padding-left: var(--s-2); }
.proposal-card { margin-top: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--brand); border-radius: var(--radius); background: var(--surface-2); }
.proposal-card.is-accepted { border-left-color: var(--ok); }
.proposal-card.is-rejected, .proposal-card.is-expired { border-left-color: var(--border-strong); opacity: .8; }
.proposal-title { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: 13px; font-weight: 600; }
.proposal-title .icon { flex: none; width: 15px; height: 15px; margin-top: 2px; color: var(--fg-subtle); }
.proposal-text { margin: 4px 0 0; }
.proposal-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.proposal-state { display: flex; align-items: center; gap: 4px; margin: var(--s-2) 0 0; font-size: 13px; color: var(--fg-muted); }
.proposal-state .icon { width: 15px; height: 15px; }
.chat-form { margin-top: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--border); }
.chat-send { margin-top: var(--s-2); justify-content: flex-end; }
.proposal-excerpt { margin: 6px 0 0; padding: 6px var(--s-3); border-left: 2px solid var(--border-strong); color: var(--fg-muted); font-size: 13px; white-space: pre-line; }
.proposal-link { margin: 6px 0 0; font-size: 13px; }
.proposal-link a { display: inline-flex; align-items: center; gap: 4px; }
.proposal-link .icon { width: 14px; height: 14px; }

/* --- Promemoria e link utili (Setup › Collegamenti dei canali, Siti WordPress) ------------------ */
.reminders { margin-top: var(--s-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.reminders > summary { display: flex; align-items: center; gap: var(--s-2); padding: 9px var(--s-3); cursor: pointer;
  list-style: none; font-size: 13.5px; font-weight: 600; color: var(--fg-muted); border-radius: var(--radius); }
.reminders > summary::-webkit-details-marker { display: none; }
.reminders > summary .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.reminders > summary:hover { background: var(--surface-sunken); }
.reminders > summary:focus-visible { outline: none; box-shadow: var(--focus); }
.reminders-caret { margin-left: auto; transition: transform .2s var(--ease); }
.reminders[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.reminders[open] .reminders-caret { transform: rotate(180deg); }
.reminders-list { margin: 0; padding: var(--s-3) var(--s-3) var(--s-3) 2.1em; display: grid; gap: 6px; font-size: 13.5px;
  color: var(--fg-muted); }
.reminders-list li { overflow-wrap: anywhere; }
.reminders-body { padding: var(--s-3); display: grid; gap: var(--s-3); }
.reminders-body > .reminders-list { padding: 0 0 0 1.5em; }
.reminders-body .form-row { margin: 0; }
.reminders-list strong { color: var(--fg); font-weight: 600; }
.ext-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.ext-link .icon { width: 13px; height: 13px; }
.muted-note { color: var(--fg-subtle); font-size: 12.5px; }

/* --- Card affiancate della stessa altezza --------------------------------------------------- */
.card-pair, .card-grid { align-items: stretch; }
.card-pair.draft-layout, .card-pair.gallery-detail { align-items: start; }
.card-pair > .card, .card-grid > .card { display: flex; flex-direction: column; min-width: 0; }
.card-pair > .card > .card-head, .card-grid > .card > .card-head { flex: none; }
.card-grow { flex: 1; display: flex; flex-direction: column; }
.card-grow > .form-actions:last-child { margin-top: auto; padding-top: var(--s-4); }
.card-end { margin-top: auto; padding-top: var(--s-2); }
.setup-section { margin-top: var(--s-6); }
.section-head { margin-bottom: var(--s-4); }
.section-head h2 { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-lg); }
.section-head h2 .icon { color: var(--fg-subtle); }
.section-sub { margin: 4px 0 0; color: var(--fg-muted); font-size: 14px; }
.wp-edit { margin-top: var(--s-4); }
.wp-delete { padding: 0 var(--s-3) var(--s-3); margin: 0; }

/* --- Griglia etichetta/valore (card dei siti WordPress) ------------------------------------------ */
.info-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 10px var(--s-4); margin: 0;
  font-size: 14px; line-height: 22px; }
.info-grid dt { display: flex; align-items: center; gap: var(--s-2); color: var(--fg-muted); }
.info-grid dt .icon { width: 15px; height: 15px; flex: none; color: var(--fg-subtle); }
.info-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.info-grid .ext-link { display: inline; }
.info-grid .ext-link .icon { margin-left: 4px; vertical-align: -1px; }
.info-grid :is(.iw-ok, .iw-ko) { display: inline-flex; align-items: center; gap: 6px; }
.info-grid :is(.iw-ok, .iw-ko) .icon { width: 16px; height: 16px; flex: none; }
.info-grid :is(.iw-ok, .iw-ko) { font-weight: 400; }
.info-grid :is(.iw-ok, .iw-ko) > span { color: var(--fg); }
@media (max-width: 760px) {
  .info-grid { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .info-grid dd { padding-left: 23px; }
  .info-grid dd + dt { margin-top: var(--s-2); }
}

/* --- Avvisi dentro le card ------------------------------------------------------------------ */
.alert { display: flex; align-items: flex-start; gap: var(--s-2); padding: 10px var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px; line-height: 20px; }
.alert > .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); margin-bottom: var(--s-4); align-items: center; flex-wrap: wrap; }
.alert-info > .icon { color: var(--info); margin-top: 0; }
.alert-info > p { flex: 1 1 28ch; }
.alert-info > .btn { flex: none; }
.alert p { margin: 0; min-width: 0; }
.alert-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-warning > .icon { color: var(--warn); }

/* --- Esito del test di un sito WordPress: sotto le azioni, a tutta larghezza ---------------------- */
.wp-test-result { display: grid; gap: var(--s-3); margin-top: var(--s-3); min-width: 0; }
.wp-test-result:empty { display: none; }
.wp-test-line { display: flex; align-items: flex-start; gap: var(--s-2); margin: 0; font-size: 14px; line-height: 22px; }
.wp-test-line > :is(.iw-ok, .iw-ko) { display: inline-flex; flex: none; height: 22px; align-items: center; }
.wp-test-line > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.wp-test-result .wp-categories { margin-top: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: var(--s-3); list-style: none; }
.chip-list .badge { white-space: normal; }
.chip-more { margin: 0; padding: 0 var(--s-3) var(--s-3); font-size: 13px; }
.wp-card-end > .reminders { margin-top: var(--s-2); }
/* «Aggiungi sito» ha l'altezza del suo contenuto; se divide la riga con un sito (numero di siti dispari), anche
   quel sito resta alla sua altezza, così aprendo «Nuovo sito» la card accanto non si allunga a vuoto. */
.card-pair > .wp-new, .card-pair > .wp-site:nth-child(odd):has(+ .wp-new) { align-self: start; }
.profile-urn { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-subtle);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-brand { margin-left: auto; align-self: flex-start; color: var(--fg-subtle); display: inline-flex; }
.th-label { display: inline-flex; align-items: center; gap: 6px; }
.th-label .icon { width: 14px; height: 14px; color: var(--fg-subtle); }

/* --- Setup › Memoria: schede del contesto su autore e azienda ----------------------------------- */
.memory-list { display: grid; gap: var(--s-4); }
.memory-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s-5);
  min-width: 0;
}
.memory-card.is-excluded { background: var(--surface-2); }
.memory-card.is-excluded .memory-text { color: var(--fg-muted); }
.memory-card.is-editing { border-color: var(--brand-fg, var(--border-strong, var(--border))); }
.memory-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
  margin: var(--s-2) 0 var(--s-3); font-size: 13px;
}
.memory-meta .subtle { display: inline-flex; align-items: center; gap: 6px; }
.memory-meta .icon { width: 14px; height: 14px; color: var(--fg-subtle); }
.memory-text { font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.memory-card > details.memory-text { max-width: none; }
.memory-card > details.memory-text > summary { font-size: 14px; line-height: 22px; }
.memory-card .check-list a { display: inline-flex; align-items: center; gap: 6px; }

/* --- Spunti: elenco a schede (niente tabella, niente scorrimento orizzontale) ------------------- */
/* Aggiunta: due colonne sul desktop, una sola sotto i 760px; textarea e nota della stessa altezza. */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4);
  align-items: start; }
.form-grid-2 > .field { width: 100%; min-width: 0; }
.add-hint { margin: var(--s-3) 0 0; font-size: 13px; color: var(--fg-muted); }
.add-hint > .icon { margin-top: 2px; }
@media (max-width: 760px) { .form-grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Intestazione dell'elenco: titolo a sinistra, filtro compatto a destra. */
.list-head { align-items: flex-end; flex-wrap: wrap; gap: var(--s-3) var(--s-4); }
.list-title { min-width: 0; }
.list-sub { margin: 2px 0 0; color: var(--fg-muted); font-size: 13.5px; }
.list-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2) var(--s-3); margin-left: auto; }
.w-filter { width: 170px; }

/* Righe-scheda. */
.source-rows { list-style: none; margin: 0; padding: 0; }
.source-row { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0;
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }
.source-row:hover { background: var(--surface-2); }

.source-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2) var(--s-3);
  flex-wrap: wrap; min-width: 0; }
.source-title { display: flex; align-items: flex-start; gap: 6px; min-width: 0; flex: 1 1 260px;
  font-size: 15px; font-weight: 650; line-height: 20px; }
.source-title > .icon { flex: none; width: 15px; height: 15px; margin-top: 3px; color: var(--fg-subtle); }
.source-title > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-width: 0; overflow-wrap: anywhere; }
.source-title.is-plain { color: var(--fg-muted); font-weight: 600; }
.source-badges { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); flex: none; }

.source-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-2); margin: 0;
  font-size: 13px; color: var(--fg-muted); min-width: 0; }
.source-meta .source-domain { font-weight: 600; overflow-wrap: anywhere; }
.source-meta .source-sep { color: var(--fg-subtle); }
.source-meta a { font-weight: 600; }
.source-error { margin: 0; font-size: 13px; }
.source-error .iw-ko { align-items: flex-start; }
.source-error .iw-ko .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.source-error .iw-ko > span { min-width: 0; overflow-wrap: anywhere; }

/* Avviso sulla scheda (lettura non riuscita, problema segnalato): spiegazione, dettaglio e le azioni
   utili lì accanto. */
.source-alert { font-size: 13.5px; }
.source-alert .alert-body { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; flex: 1 1 auto; }
.source-alert p { overflow-wrap: anywhere; }
.source-alert-detail { color: var(--fg-muted); font-size: 13px; }
.source-alert .source-actions { margin-top: 0; }

.source-note, .source-note-full { display: flex; align-items: flex-start; gap: 6px; margin: 0;
  font-size: 13.5px; font-style: italic; line-height: 20px; color: var(--fg-muted); min-width: 0; }
.source-note > .icon, .source-note > summary > .icon, .source-note-full > .icon {
  flex: none; width: 14px; height: 14px; margin-top: 3px; color: var(--fg-subtle); }
.source-note-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-width: 0; overflow-wrap: anywhere; }
.source-note-full > span { min-width: 0; overflow-wrap: anywhere; }
details.source-note { display: block; max-width: none; }
details.source-note > summary { display: flex; align-items: flex-start; gap: 6px; min-width: 0;
  font-size: 13.5px; font-style: italic; line-height: 20px; color: var(--fg-muted); cursor: pointer; }
details.source-note > summary .source-note-text { flex: 1 1 auto; }
details.source-note > summary .expand-more { flex: none; font-style: normal; }

/* Azioni: «Crea bozza» in evidenza, il resto sottotono; il pannello si apre a tutta riga. */
.source-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-1); }
.source-actions > form { margin: 0; }
.source-draft { min-width: 0; }
.source-draft > summary { width: max-content; max-width: 100%; list-style: none; }
.source-draft > summary::-webkit-details-marker { display: none; }
.source-draft[open] { flex: 1 1 100%; }
.source-draft[open] > summary { margin-bottom: var(--s-2); }
.source-draft-form { padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); }
.source-draft-form .form-row { min-width: 0; }

/* Pannelli in riga «Modifica link» e «Segnala problema»: stessa meccanica di «Crea bozza». */
.source-panel { min-width: 0; }
.source-panel > summary { width: max-content; max-width: 100%; list-style: none; }
.source-panel > summary::-webkit-details-marker { display: none; }
.source-panel[open] { flex: 1 1 100%; }
.source-panel[open] > summary { margin-bottom: var(--s-2); }
.source-panel-form { padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); }
.source-panel-form .form-row { min-width: 0; }
.source-panel-form .form-actions { margin-top: var(--s-3); }
.source-assign { list-style: none; padding: 0 var(--s-3) var(--s-3); border-bottom: 1px solid var(--border); }
.source-panel-hint { display: flex; align-items: flex-start; gap: 6px; margin: var(--s-2) 0 0;
  font-size: 12.5px; color: var(--fg-muted); min-width: 0; }
.source-panel-hint > .icon { flex: none; width: 14px; height: 14px; margin-top: 2px; color: var(--fg-subtle); }
.source-panel-hint > span { min-width: 0; overflow-wrap: anywhere; }

.card-flush > .table-empty { margin: 0; }
.card-flush > .source-rows + .pager { margin-top: 0; }
@media (max-width: 760px) {
  .source-row { padding: var(--s-4); }
  .list-filter { margin-left: 0; width: 100%; }
  .list-filter .field { flex: 1 1 140px; width: auto; }
  .list-filter .field-button { flex: 0 0 auto; }
}

/* Collegamento manuale Facebook: pannello richiudibile, aperto da solo quando il collegamento non è
   a posto (vedi setup/accounts.html) */
.manual-token { display: block; margin: 12px 0; }
.manual-token-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem;
  font-weight: 600; cursor: pointer; list-style: none; }
.manual-token-title::-webkit-details-marker { display: none; }
.manual-token-title .reminders-caret { margin-left: auto; transition: transform .15s ease; }
.manual-token[open] .manual-token-title { margin-bottom: 6px; }
.manual-token[open] .manual-token-title .reminders-caret { transform: rotate(180deg); }
.manual-token .reminders-body { padding: 0; }
.manual-token .reminders-list { margin: 8px 0 12px 18px; }

/* KPI: grafici a barre disegnati dal server (niente JS, niente stili inline: solo classi) */
.chart { margin: 0; }
.chart-svg { display: block; width: 100%; height: 180px; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-bar { fill: var(--brand); }
.chart-bar-cost { fill: var(--info); }
.chart-value { fill: var(--fg-muted); font-size: 11px; font-weight: 600; }
.chart-label { fill: var(--fg-subtle); font-size: 11px; }
.chart-caption { margin-top: var(--s-2); font-size: 12.5px; color: var(--fg-muted); }

.kpi-range { display: flex; align-items: center; gap: 6px; margin: 0 0 0 auto; align-self: center;
  font-size: 12.5px; color: var(--fg-muted); }
.kpi-range .icon { width: 14px; height: 14px; flex: none; color: var(--fg-subtle); }
.table-note { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border); font-size: 12.5px; color: var(--fg-muted); }
.table-note .icon { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--fg-subtle); }
@media (max-width: 760px) {
  .kpi-range { margin-left: 0; }
  .chart-svg { height: 150px; }
}

/* --- Canali ---------------------------------------------------------------------------------------- */
.channel-list { list-style: none; margin: 0; padding: 0; display: grid; }
.channel-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-4); padding: 10px 0;
  border-top: 1px solid var(--border); font-size: 14px; }
.channel-line:first-child { border-top: 0; padding-top: 0; }
.channel-name { display: inline-flex; align-items: center; gap: var(--s-2); min-width: 180px; font-weight: 600; }
.channel-meta { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-muted); }
.channel-meta .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.channel-meta :is(.iw-ok, .iw-ko) { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.channel-meta :is(.iw-ok, .iw-ko) .icon { width: 16px; height: 16px; }
.channel-link { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.channel-link .icon { width: 14px; height: 14px; }
.channel-section { margin-top: var(--s-6); }
.channel-card { min-width: 0; }
.channel-card + .channel-card { margin-top: var(--s-4); }
.card-pair > .channel-card + .channel-card { margin-top: 0; }
.channel-section > .card-pair + .channel-new { margin-top: var(--s-4); }
.channel-days { border: 0; margin: 0; padding: 0; }
.channel-days > legend { padding: 0; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--fg); }
.channel-days-list { display: flex; flex-wrap: wrap; gap: 4px var(--s-4); }
.channel-delete { margin: var(--s-4) 0 0; }
.w-chars { width: 140px; }

/* --- Form unico di Spunti: miniature delle immagini e righe informative delle schede --- */
.compose-card .form-row { min-width: 0; }
.compose-card .form-row > .field { min-width: 0; max-width: 100%; }
.compose-card input[type="file"] { max-width: 100%; }
.compose-alert { margin-bottom: var(--s-3); }
.compose-previews { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-3); }
.compose-previews:empty { display: none; }
.compose-thumb { margin: 0; width: 148px; max-width: 100%; display: flex; flex-direction: column; gap: 6px;
  align-items: flex-start; }
.compose-thumb img { width: 148px; max-width: 100%; height: 108px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); }
.compose-thumb figcaption { font-size: 12px; color: var(--fg-muted); max-width: 100%; overflow-wrap: anywhere; }
.compose-status { margin: var(--s-2) 0 0; font-size: 13px; color: var(--fg-muted); }
.compose-status:empty { display: none; }
.compose-status.is-out { color: var(--warn); }
.source-extra { display: flex; align-items: flex-start; gap: var(--s-2); margin: var(--s-2) 0 0; font-size: 13px;
  color: var(--fg-muted); }
.source-extra > .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--fg-subtle); flex: none; }
@media (max-width: 480px) { .compose-thumb { width: calc(50% - var(--s-3)); } .compose-thumb img { width: 100%; } }

/* Canali per gruppo: gruppi → marchi → presenze */
.channels-summary { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-4); color: var(--fg-muted); }
.channels-summary-item strong { color: var(--fg); }
.group-block { margin-top: var(--s-6); }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-3); }
.group-head h2 { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-lg); margin: 0; }
.group-head h2 .icon { color: var(--fg-subtle); }
.group-count { color: var(--fg-muted); font-size: 13px; }
.brand-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
.brand-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-3) var(--s-4); }
.brand-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-2); }
.brand-name { font-weight: 650; }
.presence-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.presence { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-3); padding-top: var(--s-2); border-top: 1px solid var(--border); }
.presence:first-child { border-top: 0; padding-top: 0; }
.presence-name { display: inline-flex; align-items: center; gap: var(--s-2); min-width: 190px; }
.presence-name .icon { width: 16px; height: 16px; color: var(--fg-subtle); }
.presence-detail { color: var(--fg-muted); font-size: 13px; }
.presence-actions { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); margin-left: auto; }

/* Dashboard: panoramica dello stato dei canali */
.overview { margin-bottom: var(--s-6); }
.overview-counters { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-3); }
.overview-counter a { display: flex; flex-direction: column; min-width: 110px; padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--fg); text-decoration: none; }
.overview-counter strong { font-size: var(--text-lg); }
.overview-counter span { color: var(--fg-muted); font-size: 13px; }
.overview-counter.is-zero strong { color: var(--fg-subtle); }
.overview-group { margin-top: var(--s-3); }
.overview-group h3 { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); font-size: 14px; }
.overview-group h3 .icon { color: var(--fg-subtle); }
.overview-brands { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.overview-brand { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-4); padding: var(--s-2) 0; border-top: 1px solid var(--border); }
.overview-brand-name { font-weight: 650; min-width: 190px; }
.overview-chip { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); }
.overview-chip-name { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--fg-muted); font-size: 13px; }
/* colonne per tipo di canale: stessa larghezza su ogni riga. In ogni cella il tipo sta sopra e lo stato con le
   bozze sotto (anche a capo): niente testo che si sovrappone alla colonna accanto, qualunque sia la lunghezza */
.overview-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.overview-chip + .overview-chip { margin-top: var(--s-2); }
.overview-chip-state { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-2); }
.overview-chip-name { min-width: 0; max-width: 100%; }
.overview-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overview-slot { min-width: 0; }
@media (max-width: 999px) {
  /* tablet e telefono: il nome del marchio ha la sua riga, sotto un tipo di canale accanto all'altro (a capo se manca spazio) */
  .overview-brand { align-items: flex-start; }
  .overview-brand-name { flex: 1 0 100%; min-width: 0; }
  .overview-slot { flex: 1 1 11rem; }
  .overview-slot:empty { display: none; }
}
@media (min-width: 1000px) {
  .overview-brand { display: grid; align-items: start; gap: 6px var(--s-4); }
  .overview-cols-1 { grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr); }
  .overview-cols-2 { grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(0, 2fr)); }
  .overview-cols-3 { grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(0, 1.5fr)); }
  .overview-cols-4 { grid-template-columns: minmax(180px, 1fr) repeat(4, minmax(0, 1.2fr)); }
}
.overview-draft { font-size: 13px; }

/* Gestione Canali: icona di stato di ogni presenza (elenco) e scheda del marchio */
.brand-head { justify-content: flex-start; }
.brand-head .channel-link { margin-left: auto; }
.presence-icons { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.presence-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--fg); font-size: 13px; text-decoration: none; background: var(--surface); }
.presence-chip:hover { border-color: var(--border-strong, var(--fg-subtle)); }
.presence-chip > .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.presence-chip .iw-ok .icon, .presence-chip .iw-warn .icon, .presence-chip .iw-ko .icon { width: 16px; height: 16px; }
.presence-chip.is-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.presence-chip.is-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.presence-chip.is-ko { border-color: color-mix(in srgb, var(--ko) 45%, var(--border)); }
.tabs .tab .iw-ok, .tabs .tab .iw-warn, .tabs .tab .iw-ko { margin-left: var(--s-1); }
.tabs .tab .iw-ok .icon, .tabs .tab .iw-warn .icon, .tabs .tab .iw-ko .icon { width: 16px; height: 16px; }
.status-reason { margin: 0 0 var(--s-3); color: var(--fg-muted); }
.check-hint { color: var(--fg-muted); font-size: 13px; }
.brand-owner-form { display: block; }
@media (min-width: 761px) {
  .channels-summary-item + .channels-summary-item::before { content: "·"; margin-right: var(--s-4); color: var(--fg-subtle); }
}
.channels-summary-item { display: inline-flex; align-items: center; gap: 6px; }
.channels-summary-item .iw-ok .icon, .channels-summary-item .iw-warn .icon, .channels-summary-item .iw-ko .icon { width: 16px; height: 16px; }
.brand-row { min-width: 0; }
.brand-reason { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; font-size: 13px; color: var(--fg-muted); min-width: 0; }
.brand-reason > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.brand-reason-more { color: var(--fg-subtle); }
/* Collegamento dentro il marchio (tappa 1b): pulsanti, scelta di Meta filtrata sul marchio */
.channel-actions { gap: var(--s-2) var(--s-3); }
.channel-actions .muted { font-size: 13px; }
.meta-others { margin-bottom: var(--s-4); }
.meta-others-body { display: grid; gap: var(--s-3); padding: var(--s-3); }
.trash-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); margin-bottom: var(--s-4); }

/* Logo del marchio (scheda del marchio): anteprima su fondo neutro, così si vede anche un logo bianco */
.brand-logo-box { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: flex-start; }
.brand-logo-preview { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: var(--s-2); width: 220px; min-height: 120px; padding: var(--s-3); border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-sunken); color: var(--fg-subtle); font-size: 13px; text-align: center; }
.brand-logo-preview img { display: block; max-width: 100%; max-height: 160px; object-fit: contain; }
.brand-logo-preview.is-empty { flex-direction: column; }
.brand-logo-info { flex: 1 1 320px; min-width: 0; }
.brand-logo-form { margin: var(--s-3) 0 0; display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: flex-end; }
/* tre varianti del logo: riquadri che vanno a capo (tablet e telefono); lo sfondo dell'anteprima dice a che serve */
.brand-logo-variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-4); margin-top: var(--s-3); }
.brand-logo-variant { min-width: 0; padding: var(--s-3); border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.brand-logo-variant h3 { margin: 0 0 var(--s-2); font-size: 14px; }
.brand-logo-variant .brand-logo-preview { width: 100%; box-sizing: border-box; }
.brand-logo-preview.is-dark { background: #14181f; border-color: #3a4352; color: #aab2c0; }
.brand-logo-preview.is-light { background: #f4f5f7; border-color: #c9ced8; color: #5b6472; }
.brand-logo-preview.is-checker { background-color: #fff; color: #5b6472;
  background-image: linear-gradient(45deg, #e3e6ec 25%, transparent 25%, transparent 75%, #e3e6ec 75%),
                   linear-gradient(45deg, #e3e6ec 25%, transparent 25%, transparent 75%, #e3e6ec 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.logo-variant-note { display: inline-flex; align-items: center; gap: var(--s-1); }
/* Immagini dei post: modalità del marchio (Illustrazione / Foto) */
.image-mode-box { max-width: 720px; }
.image-mode-form { margin: var(--s-3) 0 0; }
.image-mode-choices { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin: 0 0 var(--s-3); padding: 0; border: 0; min-width: 0; }
.image-mode-choices .check { flex: 1 1 260px; }
.image-mode-facts { list-style: none; margin: var(--s-3) 0 var(--s-2); padding: 0; display: grid; gap: var(--s-1); }
.gallery-brand .badge { max-width: 100%; }
.gallery-brand .badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Responsive tablet e telefono -------------------------------------------------------
   Le tabelle (.table-stack, marcate da app.js) sotto i 900px (tablet in verticale incluso) diventano elenchi di schede:
   una scheda per riga, ogni valore preceduto dall'etichetta della sua colonna. Così niente
   colonne strozzate o scorrimento laterale per leggere un record. */
@media (max-width: 900px) {
  .table-wrap:has(> .table-stack) { overflow-x: visible; }
  .card-flush > .table-wrap:has(> .table-stack) { border: 0; background: transparent; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-stack tbody tr { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); }
  .table-stack tbody tr:first-child { border-top: 0; }
  .table-stack tbody tr:hover td { background: transparent; }
  .table-stack tbody tr + tr td { border-top: 0; }
  .table-stack td[data-label] {
    display: grid; grid-template-columns: minmax(5.5rem, 32%) minmax(0, 1fr);
    gap: var(--s-3); align-items: baseline; justify-items: start; padding: 5px 0; text-align: left;
    overflow-wrap: anywhere;
  }
  .table-stack td[data-label]::before {
    content: attr(data-label); color: var(--fg-muted); font-size: 12px; font-weight: 650;
    letter-spacing: .03em; text-transform: uppercase;
  }
  .table-stack td.num { text-align: left; }
  .table .table-stack td.rule-text, .table-stack td.rule-text { width: 100%; min-width: 0; }
  .table-stack td > * { min-width: 0; max-width: 100%; }
  .table-stack td.is-void { display: none; }
  .table-stack td.actions { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: var(--s-2); padding-top: var(--s-2); }
  .table-stack td.actions::before { display: none; }
  .table-stack td.nowrap { white-space: normal; }
  .table-stack .topic-cell, .table-stack .event-msg { max-width: none; }
  .table-stack .table-empty { padding: var(--s-5) var(--s-3); }
  .table-wrap:has(> .table-stack) tbody tr td.table-empty { display: block; }
}

/* intestazioni di scheda e badge lunghi: vanno a capo invece di uscire dalla scheda */
.card-head { flex-wrap: wrap; }
.card-head .badge { flex: 0 1 auto; max-width: 100%; white-space: normal; text-align: left; }
.role-form { flex-wrap: wrap; }

/* telefono: i campi corti (orari, numeri, date, caratteri) stanno in due per riga invece di uno a tutta larghezza */
@media (max-width: 760px) {
  .field.w-time, .field.w-num, .field.w-port, .field.w-date, .field.w-chars, .field.w-price, .field.w-filter {
    flex: 1 1 calc(50% - 8px); width: auto; min-width: 0;
  }
}

/* tocchi comodi (≥ 40px) per i collegamenti isolati: elenchi di link, chip, voci di coda */
@media (max-width: 1024px) {
  .ext-link, .presence-chip, .channel-link, .overview-draft, .queue-cell,
  .table-stack td > a, .dash-card li > a, .dash-card p > a {
    display: inline-flex; align-items: center; min-height: 40px;
  }
  .info-grid .ext-link { display: inline-flex; }
  .presence-chip { min-height: 36px; }
  .btn-sm, .select-sm { min-height: 40px; }
  .page-actions .btn, .form-actions .btn { min-height: 44px; }
}

/* Dashboard, Stato dei canali: stacco ben visibile tra un titolare/gruppo e il successivo.
   Ogni gruppo ha l'intestazione su una fascia con barra del colore del marchio; dal secondo in poi
   c'è più aria sopra e una linea marcata, così non si confondono i marchi di gruppi diversi. */
.overview-group h3 {
  padding: var(--s-2) var(--s-3); margin-bottom: var(--s-3);
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); font-size: 14.5px;
}
.overview-group + .overview-group { margin-top: var(--s-7); padding-top: var(--s-5); border-top: 2px solid var(--border-strong, var(--border)); }

/* menu a cassetto: voci alte quanto basta per il dito */
@media (max-width: 1024px) {
  .sidebar .nav-link { min-height: 44px; }
  .sidebar .nav-sub .nav-link { min-height: 40px; }
}

/* --- Foto in blocco: esito del caricamento e griglia delle note --- */
.upload-results { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: var(--s-1); font-size: 13px; }
.upload-results li { min-width: 0; overflow-wrap: anywhere; }
.upload-summary { margin: 0 0 var(--s-3); font-weight: 600; }
.gallery-note { margin: 0; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-form { margin: 0; }
.notes-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.notes-item { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-start; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.notes-thumb { flex: 0 0 120px; display: block; aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden; background: var(--surface-sunken); }
.notes-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.notes-thumb:focus-visible { outline: 2px solid var(--accent, #C8102E); outline-offset: 2px; }
.notes-fields { flex: 1 1 220px; min-width: 0; display: grid; gap: var(--s-3); }
.notes-fields .field { width: 100%; }
.notes-id { margin: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; font-size: 13px; }
@media (max-width: 480px) { .notes-thumb { flex-basis: 88px; } .notes-fields { flex-basis: 100%; } }

/* --- Foto finite: avviso in Dashboard --- */
.actions-alert { margin-bottom: var(--s-4); }
.actions-alert.has-err { border-color: var(--ko); }
.actions-alert.has-warn { border-color: var(--warn, #b45309); }
.action-list { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: var(--s-3); }
.action-item { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-4); align-items: center; justify-content: space-between; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.action-text { flex: 1 1 280px; min-width: 0; }
.action-text p { margin: 0; overflow-wrap: anywhere; }
.photo-holds { border-color: var(--warn, #b45309); margin-bottom: var(--s-4); }
.photo-hold-list { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: var(--s-3); }
.photo-hold { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-4); align-items: center; justify-content: space-between; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.photo-hold-text { flex: 1 1 280px; min-width: 0; }
.photo-hold-text p { margin: 0; overflow-wrap: anywhere; }
.photo-hold-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.photo-hold-actions form { margin: 0; }
@media (max-width: 480px) { .photo-hold-actions, .photo-hold-actions form, .photo-hold-actions .btn { width: 100%; } }

/* --- Scheda del canale a sezioni (rilascio 2, 2026-10-21) --- */
.section-nav {
  display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4);
  position: sticky; top: var(--topbar-h, 60px); z-index: 5; padding: var(--s-2) 0; background: var(--bg);
}
.section-nav a {
  display: inline-flex; align-items: center; gap: var(--s-1); padding: 4px var(--s-3);
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--fg-muted); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.section-nav a .icon { width: 14px; height: 14px; color: var(--fg-subtle); }
.section-nav a:hover { color: var(--fg); border-color: var(--border-strong); }
.channel-card[id^="sezione-"], span[id^="sezione-"] { scroll-margin-top: 128px; }      /* intestazione fissa + barra delle sezioni */
.card-pad { padding: var(--s-4); }
.card-flush .section-sub { padding: var(--s-4) var(--s-4) 0; display: flex; align-items: center; gap: var(--s-2); }
.card .section-sub { display: flex; align-items: center; gap: var(--s-2); }
.card .section-sub .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.inline-edit { display: inline-block; vertical-align: middle; max-width: 100%; }
.inline-edit > summary { list-style: none; cursor: pointer; display: inline-flex; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] { display: block; margin-top: var(--s-2); }
.moved-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.moved-card .card-desc { margin-bottom: var(--s-3); }
@media (max-width: 760px) {
  .section-nav { position: static; flex-wrap: nowrap; overflow-x: auto; padding-bottom: var(--s-2); }
  .channel-card[id^="sezione-"], span[id^="sezione-"] { scroll-margin-top: 72px; }
}
.rules-in-channel th:nth-child(2), .rules-in-channel td:nth-child(2) { display: none; }   /* il canale è quello della scheda */

/* --- Scheda del canale: sezioni numerate, stato e interruttore (0.18.0, 2026-10-21) --- */
.sez-num {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px;
  border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.section-nav a .sez-num { width: 18px; height: 18px; font-size: 11px; }
.section-nav a.is-na { opacity: .6; }
.sez-sub { margin-left: 30px; }
.canale-stato { font-size: 14px; }
.canale-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-3); }
.switch-form { display: inline-flex; align-items: center; gap: var(--s-2); margin: 0; }
.switch {
  position: relative; display: inline-block; flex: none; width: 38px; height: 22px; padding: 0; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-sunken);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--fg-muted); transition: transform .15s ease;
}
.switch[aria-checked="true"] { background: var(--ok-soft); border-color: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--ok); }
.switch:disabled { cursor: not-allowed; opacity: .55; }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--fg); }
.switch-label .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.page-note { margin: 0 0 var(--s-3); }
.card-tight .card-desc { margin: 0 0 var(--s-3); font-size: 13.5px; }
.form-save { justify-content: flex-start; }
.form-save > .btn:last-child { margin-left: auto; }

/* --- «Salva tutto il canale» (0.19.0) --- */
.savebar {
  position: sticky; bottom: 0; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4);
  margin-top: var(--s-4); padding: var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius, 10px); box-shadow: 0 -4px 14px rgb(0 0 0 / 8%);
}
.savebar-state { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 600; font-size: 14px; }
.savebar-state .icon { width: 16px; height: 16px; color: var(--fg-subtle); }
.savebar[data-dirty="1"] .savebar-state .icon, .savebar[data-rejected="1"] .savebar-state .icon { color: var(--warn); }
.savebar-hint { color: var(--fg-muted); font-size: 13px; flex: 1 1 24ch; }
.savebar .btn { margin-left: auto; }
.card-fields { min-width: 0; }
.alert-error { background: var(--ko-soft); border-color: color-mix(in srgb, var(--ko) 30%, transparent); margin-bottom: var(--s-4); }
.alert-error > .icon { color: var(--ko); }
.save-errors { margin: var(--s-2) 0 0; padding: 0; list-style: none; display: grid; gap: var(--s-1); }
.save-errors li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
@media (max-width: 760px) { .savebar-hint { display: none; } .savebar .btn { width: 100%; } }
.savebar-form { display: contents; }   /* il modulo non crea un riquadro: la barra resta fissata in basso alla colonna */

/* --- Foto del marchio nella scheda del canale (0.20.0) --- */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1);
  min-height: 120px; padding: var(--s-4); text-align: center; cursor: pointer; color: var(--fg-muted);
  border: 2px dashed var(--border-strong); border-radius: var(--radius, 10px); background: var(--surface-sunken);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); color: var(--fg); }
.dropzone > .icon { width: 26px; height: 26px; color: var(--fg-subtle); }
.dropzone-text { font-size: 15px; color: var(--fg); }
.dropzone-help { font-size: 13px; }
.dropzone-chosen { font-size: 13px; font-weight: 600; color: var(--fg); min-height: 1em; }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-form .form-actions { margin-top: var(--s-3); }

/* Spunti per gruppo e canale (0.21.0): fisarmoniche dei gruppi con dentro i canali, e scelta dei canali con i check. */
.source-groups { display: flex; flex-direction: column; }
.source-group { border-top: 1px solid var(--border); }
.source-group > summary { list-style: none; cursor: pointer; }
.source-group > summary::-webkit-details-marker { display: none; }
.source-group-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) var(--s-3);
  padding: var(--s-3) var(--s-5); font-size: 15px; font-weight: 650; }
.source-group-head:hover { background: var(--surface-2); }
.source-group-head > .icon { flex: none; width: 16px; height: 16px; color: var(--fg-subtle); }
.source-group-name { min-width: 0; overflow-wrap: anywhere; }
.source-group-head .nav-caret { margin-left: auto; }
.source-group[open] > .source-group-head .nav-caret { transform: rotate(180deg); }
.source-channel { padding-bottom: var(--s-2); }
.source-channel > h3 { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); margin: 0;
  padding: var(--s-2) var(--s-5); font-size: 13.5px; font-weight: 600; color: var(--fg-muted); background: var(--surface-2); }
.source-channel > h3 > .icon { flex: none; width: 15px; height: 15px; color: var(--fg-subtle); }
.source-channel > .table-empty, .source-channel > .card-note { margin: var(--s-3) var(--s-5); }
.channel-picker { border: 1px solid var(--border); border-radius: var(--radius, 8px); padding: var(--s-3) var(--s-4) var(--s-4);
  margin: var(--s-4) 0 0; min-width: 0; }
.channel-picker.has-error { border-color: var(--danger, #c0392b); }
.channel-picker > legend { display: inline-flex; align-items: center; gap: 6px; padding: 0 var(--s-2); font-size: 14px; font-weight: 650; }
.channel-picker > legend > .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.channel-picker > .field-help { margin: 0 0 var(--s-3); }
/* Un riquadro per gruppo: intestazione con il check «tutti», sotto i canali incolonnati in una griglia a colonne uguali. */
.channel-group { margin-top: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius, 8px); overflow: hidden; }
.channel-group:first-of-type { margin-top: 0; }
.channel-group > .check { padding: var(--s-2) var(--s-3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.channel-group > .check .check-label { font-weight: 650; font-size: 14px; }
.channel-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0; margin: 0; }
.channel-list .check { min-width: 0; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.channel-list .check:hover { background: var(--surface-2); }
.channel-list .check-label { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.channel-list .check-text, .channel-group > .check .check-text { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-list .check-note, .channel-group > .check .check-note { margin-left: auto; flex: none; white-space: nowrap; font-family: inherit; }
.channel-list .check { min-height: 44px; align-items: center; }
.channel-list .check-label .check-icon { margin-top: 0; }
.channel-list .check.is-off .check-text { color: var(--fg-muted); font-weight: 400; }
.channel-list .check.is-off .check-icon { color: var(--fg-subtle); }
.channel-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 var(--s-3); font-size: 13px; color: var(--fg-muted); }
.compose-card .form-row + .form-row, .compose-card .channel-picker { margin-top: var(--s-4); }
@media (max-width: 760px) {
  .source-group-head { padding: var(--s-3) var(--s-4); }
  .source-channel > h3 { padding: var(--s-2) var(--s-4); }
  .channel-list { grid-template-columns: 1fr; }
  .channel-list .check { border-right: 0; }
}

/* Scheda del blog (0.25.0): sezione 2 compatta, azioni del sito su una riga. */
.channel-site .form-row { margin-top: var(--s-3); }
.site-actions { border-top: 0; padding: var(--s-3) 0 0; }
.site-actions .site-delete { margin-left: auto; }

/* Sezioni della scheda del canale più compatte (0.26.0): meno vuoti, stati vuoti su una riga, azioni allineate ai campi. */
.channel-card .memory-list .empty { padding: var(--s-3) var(--s-4); flex-direction: row; justify-content: center; }
.channel-card .memory-list .empty .icon { width: 18px; height: 18px; }
.rules-empty { margin: 0; padding: var(--s-2) var(--s-5) var(--s-3); color: var(--fg-muted); font-size: 14px; }
.channel-card .dropzone { min-height: 84px; padding: var(--s-3); }
.channel-card .field-help { margin-top: 2px; }
.channel-card .form-row + .form-row { margin-top: var(--s-3); }
.channel-card .empty { padding: var(--s-3) var(--s-4); flex-direction: row; justify-content: center; }
.channel-card .empty .icon { width: 18px; height: 18px; }
.check-inline { display: inline-flex; align-items: center; gap: var(--s-2); font-size: 14px; cursor: pointer; }

/* Gestione Canali: i pulsanti dei canali stanno sempre nelle stesse quattro colonne (Facebook, Instagram, LinkedIn, Sito web),
   verdi se il canale è attivo e rossi se non lo è. */
.brand-head .brand-name { flex: 0 0 190px; min-width: 0; overflow-wrap: anywhere; }
.presence-grid { display: grid; grid-template-columns: repeat(4, 148px); gap: var(--s-2) var(--s-3); }
.presence-slot { display: flex; flex-wrap: wrap; gap: var(--s-1); min-height: 30px; min-width: 0; }
.presence-slot .presence-chip { width: 100%; justify-content: space-between; }
.presence-chip.is-on { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.presence-chip.is-off { color: var(--ko); background: var(--ko-soft); border-color: color-mix(in srgb, var(--ko) 55%, var(--border)); }
.presence-chip.is-on > .icon, .presence-chip.is-off > .icon { color: inherit; }
@media (max-width: 1000px) { .presence-grid { grid-template-columns: repeat(2, 148px); } }
@media (max-width: 760px) { .brand-head .brand-name { flex-basis: 100%; } .presence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; } }

/* Immagini e foto (sezione 8): modalità, foto e logo sembrano un'unica card a tre blocchi; il riquadro di caricamento e il pulsante
   stanno sulla stessa riga. */
#sezione-immagini > section.card { margin-top: 0; }
#sezione-immagini > section.card:not(:last-child) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-style: dashed; }
#sezione-immagini > section.card:not(:first-child) { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
#sezione-immagini .dropzone-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); }
#sezione-immagini .dropzone-form .dropzone { flex: 1 1 320px; }
#sezione-immagini .dropzone-form .form-actions { margin: 0; }

/* Caricamento di foto una alla volta: contatore, barra e esito per foto */
.upload-progress { display: grid; gap: var(--s-2); margin-top: var(--s-3); }
.upload-progress[hidden] { display: none; }
.upload-progress-line { margin: 0; font-size: 13px; }
.upload-progress progress { width: 100%; height: 8px; }
.upload-progress .upload-results { max-height: 260px; overflow-y: auto; }

/* Galleria: selezione di più foto ed etichette */
.gallery-item { position: relative; }
.gallery-select { position: absolute; top: 6px; left: 6px; z-index: 1; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--fg-subtle); cursor: pointer; }
.gallery-select:hover { border-color: var(--info); }
.gallery-select-mark { display: flex; }
.gallery-select-mark .icon { width: 16px; height: 16px; opacity: 0; }
.gallery-select input:checked + .gallery-select-mark .icon { opacity: 1; color: var(--info); }
.gallery-select input:focus-visible + .gallery-select-mark { outline: 2px solid var(--info); border-radius: 50%; }
.gallery-item.is-selected { border-color: var(--info); box-shadow: 0 0 0 2px var(--info); }
.gallery-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-size: 12px; line-height: 1.5; padding: 0 8px; border-radius: 999px; background: var(--surface-sunken);
  color: var(--fg-muted); text-decoration: none; border: 1px solid var(--border); }
a.chip:hover { color: var(--fg); border-color: var(--border-strong, var(--border)); }
.select-bar { position: sticky; top: 68px; z-index: 10; margin: var(--s-3) 0; padding: var(--s-3); background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: var(--s-2); }
.select-bar.is-active { background: var(--surface); border-color: var(--info); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.select-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.select-count { font-size: 14px; white-space: nowrap; }
.select-hint { flex: 1 1 280px; min-width: 0; font-size: 13px; color: var(--fg-muted); }
.select-hint.is-error { color: var(--danger, #c0392b); font-weight: 600; }

/* Galleria: un marchio per volta, divisi per Gruppo */
.brand-tabs { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4); }
.brand-tabs-group { min-width: 0; }
.brand-tabs-title { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; font-weight: 650; color: var(--fg-muted); }
.brand-tabs-title .icon { width: 14px; height: 14px; }
.brand-tabs-list { display: flex; flex-wrap: wrap; gap: 6px; }
.brand-tab { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13px; color: var(--fg); text-decoration: none; background: var(--surface); }
.brand-tab:hover { border-color: var(--border-strong, var(--border)); background: var(--surface-2); }
.brand-tab.is-active { border-color: var(--info); background: var(--surface-sunken); font-weight: 650; box-shadow: 0 0 0 1px var(--info); }
.brand-tab-count { font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* Serie da galleria */
.series-photos { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: grid; }
.series-photo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-2) 0; border-top: 1px solid var(--border); font-size: 14px; }
.series-photo.is-past { color: var(--fg-muted); }
.series-photo-n { flex: none; width: 24px; text-align: right; font-variant-numeric: tabular-nums; color: var(--fg-muted); }
.series-photo img { flex: none; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.series-photo-missing { flex: none; display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; color: var(--danger, #c0392b); }
.series-photo-name { flex: 1 1 180px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.series-photo-actions { display: inline-flex; gap: 4px; margin-left: auto; }
.series-photo-article { flex: none; margin-left: auto; }
.series-photo-article + .series-photo-actions { margin-left: 0; }
.series-brief { margin: 0 0 var(--s-3); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Finestra di conferma (app.js: data-confirm): al posto del confirm() del browser. */
.confirm { width: min(440px, calc(100vw - 2 * var(--s-4))); padding: var(--s-5); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg); }
.confirm::backdrop { background: rgba(12, 17, 25, .55); }
.confirm-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.confirm-head h2 { margin: 0; font-size: var(--text-lg); }
.confirm-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); }
.confirm-mark .icon { width: 19px; height: 19px; }
.confirm-danger .confirm-mark { background: var(--ko-soft); color: var(--ko); }
.confirm-text { margin: 0 0 var(--s-5); color: var(--fg-muted); font-size: var(--text-base); line-height: 1.5; overflow-wrap: anywhere; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }

/* Galleria (2026-10-26): numero dell'immagine, cestino, numeri di pagina, motivo nella conferma */
.gallery-num { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fg-muted); text-decoration: none; }
.gallery-num:hover { color: var(--brand-fg); text-decoration: underline; }
.gallery-trash { margin: var(--s-1) 0 0; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-1); }
.pager-num { min-width: 32px; height: 32px; padding: 0 var(--s-2); display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg); background: var(--surface); text-decoration: none;
  font-size: 13.5px; font-variant-numeric: tabular-nums; }
a.pager-num:hover { border-color: var(--fg-subtle); background: var(--surface-2); }
.pager-num.is-current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager-gap { padding: 0 var(--s-1); color: var(--fg-subtle); }
.pager-pages .pager-info { margin-left: var(--s-2); }
.confirm-reason { display: grid; gap: var(--s-1); margin: calc(-1 * var(--s-3)) 0 var(--s-5); font-size: var(--text-sm); color: var(--fg-muted); }
.confirm-reason[hidden] { display: none; }

/* Pulsanti della stessa misura (2026-10-26): le azioni di una bozza e quelle sotto ogni immagine */
.action-buttons > .btn, .action-buttons .inline-form, .action-buttons .inline-form .btn, .action-link .btn { width: 100%; justify-content: center; min-height: 44px; }
.action-link { flex-direction: column; align-items: stretch; }
.action-panel > summary { min-height: 44px; }
.gallery-pick, .gallery-trash { width: 100%; }
.gallery-pick .btn, .gallery-trash .btn { width: 100%; justify-content: center; }

.rule-proposal > form { padding: var(--s-3); display: grid; gap: var(--s-2); }
.rule-proposal h3 { display: flex; align-items: center; gap: var(--s-2); margin: 0; font-size: var(--text-base); }
.rule-proposal h3 .icon { width: 16px; height: 16px; color: var(--warn); }
.rule-proposal .field-help { margin: 0; }
.form-actions-equal { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.form-actions-equal .btn { width: 100%; justify-content: center; }

/* Scheda del canale come backoffice (2026-10-26): linguetta «Perché non esce?», voci di memoria compatte, moduli e pulsanti allineati */
.why-panel { margin: 0 0 var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.why-panel.is-blocked { border-color: color-mix(in srgb, var(--ko) 45%, var(--border)); }
.why-panel > summary { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); cursor: pointer; list-style: none; border-radius: var(--radius-lg); }
.why-panel > summary::-webkit-details-marker { display: none; }
.why-panel > summary:hover { background: var(--surface-2); }
.why-panel > summary:focus-visible { outline: none; box-shadow: var(--focus); }
.why-panel > summary > .icon { width: 18px; height: 18px; color: var(--fg-subtle); flex: none; }
.why-title { font-weight: 600; }
.why-chevron { margin-left: auto; transition: transform .15s ease; }
.why-panel[open] .why-chevron { transform: rotate(180deg); }
.why-body { padding: 0 var(--s-4) var(--s-4); border-top: 1px solid var(--border); }
.why-body .card-desc { margin: var(--s-3) 0; }
.why-body .status-list { margin-bottom: 0; }
@media (max-width: 760px) { .why-panel > summary { flex-wrap: wrap; } .why-chevron { margin-left: 0; } }

.channel-card .form-row + .form-row { margin-top: var(--s-3); }
.channel-card .add-form { border-top: 1px solid var(--border); margin-top: var(--s-4); padding: var(--s-4) 0 0; }
.channel-card .add-form .section-sub { margin: 0 0 var(--s-3); display: flex; align-items: center; gap: var(--s-2); }
.form-actions-split { justify-content: space-between; margin-top: var(--s-3); }
.form-actions-split .option { margin: 0; }
.import-box { padding: var(--s-3) 0 0; }
.import-box > summary { list-style: none; width: fit-content; }
.import-box > summary::-webkit-details-marker { display: none; }

.memory-list { gap: var(--s-3); }
.memory-card { padding: var(--s-4); }
.memory-card > .card-head h2 { font-size: var(--text-base); }
.memory-meta { margin: var(--s-1) 0 var(--s-2); gap: var(--s-1) var(--s-3); }
.memory-card .card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); margin-top: var(--s-3);
  padding-top: var(--s-3); border-top: 1px solid var(--border); }
.memory-card .card-actions .inline-form { display: inline-flex; }
.memory-card .card-actions > form:last-child { margin-left: auto; }

/* Documenti lunghi con titoli resi (2026-10-26) */
.doc-text { font-size: 14px; line-height: 22px; overflow-wrap: anywhere; }
.doc-text p, .doc-text ul { margin: 0 0 var(--s-2); }
.doc-text ul { padding-left: var(--s-5); }
.doc-text .doc-h { margin: var(--s-3) 0 var(--s-1); font-size: 14px; font-weight: 600; }
.doc-expand { max-width: 100%; }
.doc-expand > summary { font-size: 13px; color: var(--fg-muted); }
.doc-expand[open] > summary { display: none; }
.pillar-desc { max-width: 520px; }
.photo-ops { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-3); padding: var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: 13.5px; }
.photo-ops .photo-ops-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.photo-ops .btn { margin-left: auto; }

.config-box > summary { list-style: none; cursor: pointer; display: flex; align-items: center; }
.config-box > summary::-webkit-details-marker { display: none; }
.config-box > summary h2 { display: flex; align-items: center; gap: var(--s-2); margin: 0; font-size: 15.5px; }
.config-box[open] > summary { margin-bottom: var(--s-3); }
.plain-list { margin: 0; padding-left: var(--s-4); }
.draft-error-tech { margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font: 12px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.save-scope { margin-left: var(--s-2); font-weight: 500; }

/* Campi lunghi in coppia: due colonne di pari larghezza che vanno a capo da sole (2026-10-26) */
.form-row.pair > .field { flex: 1 1 320px; width: auto; min-width: min(260px, 100%); }
.form-row.pair > .field.w-long, .form-row.pair > .field.w-name { width: auto; }
.channel-card .form-row { gap: var(--s-3) var(--s-4); }
.channel-card .form-row + .form-section { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }

/* Scheda del canale, sezioni restanti (2026-10-26): interruttori in un gruppo, calendario, pulsanti a destra */
.switch-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); align-items: center; margin-top: var(--s-3); }
.form-actions-end { justify-content: flex-end; margin-top: var(--s-3); }
.calendar-row { align-items: flex-start; }
.calendar-row > .channel-days { flex: 1 1 320px; min-width: 0; }
.channel-card .card-head { gap: var(--s-2); flex-wrap: wrap; }
.channel-card .info-grid { margin-bottom: var(--s-3); }
.channel-card .channel-line { padding-top: var(--s-2); }

/* KPI: ambito e definizione di ogni indicatore (2026-10-26) */
.kpi-scope { display: flex; gap: var(--s-2); align-items: flex-start; margin: 0 0 var(--s-4); color: var(--fg-muted); font-size: 13.5px; }
.kpi-scope .icon { width: 15px; height: 15px; margin-top: 3px; flex: none; color: var(--fg-subtle); }
.kpi-def { margin-top: var(--s-3); border-top: 1px solid var(--border); padding-top: var(--s-2); font-size: 13px; }
.kpi-def > summary { display: inline-flex; align-items: center; gap: var(--s-1); cursor: pointer; color: var(--fg-muted); list-style: none; }
.kpi-def > summary::-webkit-details-marker { display: none; }
.kpi-def > summary .icon { width: 14px; height: 14px; color: var(--fg-subtle); }
.kpi-def[open] > summary { margin-bottom: var(--s-2); }
.kpi-def .kv { margin: 0; }

/* Scheda del canale a cinque aree (2026-10-26) */
.area-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); margin: 0 0 var(--s-3);
  position: sticky; top: var(--topbar-h, 60px); z-index: 6; padding: var(--s-2) 0; background: var(--bg); }
.area-tab { display: grid; grid-template-columns: auto 1fr; column-gap: var(--s-2); row-gap: 2px; align-items: center; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg-muted); text-decoration: none; }
.area-tab .icon { grid-row: 1 / span 2; width: 18px; height: 18px; color: var(--fg-subtle); }
.area-tab .area-name { font-weight: 600; font-size: 14px; color: var(--fg); }
.area-tab .area-sub { font-size: 11.5px; line-height: 1.3; color: var(--fg-subtle); }
.area-tab:hover { border-color: var(--border-strong); }
.area-tab.is-active { border-color: var(--brand); box-shadow: inset 0 -3px 0 var(--brand); background: var(--brand-soft); }
.area-tab.is-active .icon { color: var(--brand-fg); }
.area-tab:focus-visible { outline: none; box-shadow: var(--focus); }
.section-nav { position: static; }
.has-areas .section-nav a[hidden] { display: none; }
@media (max-width: 1100px) { .area-tabs { grid-template-columns: repeat(5, minmax(150px, 1fr)); overflow-x: auto; } .area-tab .area-sub { display: none; } }
@media (max-width: 760px) { .area-tabs { position: static; } }

/* Regole del canale: stessa riga di margine (24px) per titoli, tabella, elenco vuoto e modulo; respiro sopra ogni sottotitolo */
#sezione-regole .section-sub { padding: var(--s-5) var(--s-5) var(--s-2); margin: 0; }
#sezione-regole .table th:first-child, #sezione-regole .table td:first-child { padding-left: var(--s-5); }
#sezione-regole .table th:last-child, #sezione-regole .table td:last-child { padding-right: var(--s-5); }
#sezione-regole .rules-empty { padding: 0 var(--s-5) var(--s-3); }
#sezione-regole > form.card-pad { padding: var(--s-4) var(--s-5) var(--s-5); }
@media (max-width: 760px) {
  #sezione-regole .section-sub { padding-inline: var(--s-4); }
  #sezione-regole .table th:first-child, #sezione-regole .table td:first-child { padding-left: var(--s-4); }
  #sezione-regole .table th:last-child, #sezione-regole .table td:last-child { padding-right: var(--s-4); }
  #sezione-regole .rules-empty { padding-inline: var(--s-4); }
  #sezione-regole > form.card-pad { padding-inline: var(--s-4); }
}

/* Orologio in alto (ora di Roma con GMT) */
.topbar-clock { display: inline-flex; align-items: center; gap: var(--s-2); margin-left: auto; margin-right: var(--s-4); color: var(--fg-muted); font-size: 14px; white-space: nowrap; }
.topbar-clock .icon { width: 15px; height: 15px; color: var(--fg-subtle); }
.topbar-clock time { font-variant-numeric: tabular-nums; color: var(--fg); font-weight: 600; }
.topbar-clock .clock-gmt { font-size: 12px; padding: 1px 6px; border-radius: 999px; background: var(--bg-muted, rgba(0,0,0,.06)); }
@media (max-width: 760px) { .topbar-clock { margin-right: var(--s-2); } .topbar-clock .clock-gmt { display: none; } }

/* Calendario: linguette dei canali e settimana a ore */
.cal-tabs { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: var(--s-2); margin-bottom: var(--s-4); }
.cal-tab { display: inline-flex; align-items: center; gap: var(--s-2); padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface, #fff); color: var(--fg-muted); text-decoration: none; white-space: nowrap; font-size: 14px; }
.cal-tab .icon { width: 15px; height: 15px; }
.cal-tab:hover { color: var(--fg); border-color: var(--fg-subtle); }
.cal-tab.is-active { color: var(--brand, #c8102e); border-color: var(--brand, #c8102e); background: var(--brand-soft, rgba(200,16,46,.07)); font-weight: 600; }
.cal-week { margin-top: var(--s-4); }
.cal-nav { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); list-style: none; margin: 0; padding: var(--s-2) var(--s-5) var(--s-3); font-size: 13px; color: var(--fg-muted); }
.cal-legend li { display: inline-flex; align-items: center; gap: 6px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-table th, .cal-table td { vertical-align: top; padding: 6px 8px; }
.cal-table thead th { text-align: center; }
.cal-table thead th small { display: block; font-weight: 400; color: var(--fg-subtle); font-size: 11px; }
.cal-table .cal-hour { width: 56px; color: var(--fg-subtle); font-weight: 400; font-size: 12px; text-align: right; white-space: nowrap; }
.cal-table td { min-width: 118px; border-left: 1px solid var(--border); }
.cal-table td.is-today, .cal-table th.is-today { background: var(--brand-soft, rgba(200,16,46,.05)); }
.cal-table td.is-off, .cal-table th.is-off { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0,0,0,.035) 6px 12px); color: var(--fg-subtle); }
.cal-ev { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: 2px 0; padding: 3px 6px; border-radius: 6px; border-left: 3px solid var(--c, #888); background: color-mix(in srgb, var(--c, #888) 10%, transparent); color: var(--fg); text-decoration: none; font-size: 12px; line-height: 1.3; }
a.cal-ev:hover { background: color-mix(in srgb, var(--c, #888) 20%, transparent); }
.cal-ev .cal-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-ev .cal-what { display: inline-flex; align-items: center; gap: 3px; color: var(--fg-muted); }
.cal-ev .cal-what .icon { width: 12px; height: 12px; }
.cal-ev .cal-ch { font-weight: 600; }
.cal-ev .cal-title { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-muted); }
.cal-ev.cal-promemoria { opacity: .75; }
.cal-c0 { --c: #c8102e; } .cal-c1 { --c: #2563eb; } .cal-c2 { --c: #059669; } .cal-c3 { --c: #d97706; }
.cal-c4 { --c: #7c3aed; } .cal-c5 { --c: #0891b2; } .cal-c6 { --c: #db2777; } .cal-c7 { --c: #4b5563; }
.cal-dot.cal-c0, .cal-dot.cal-c1, .cal-dot.cal-c2, .cal-dot.cal-c3, .cal-dot.cal-c4, .cal-dot.cal-c5, .cal-dot.cal-c6, .cal-dot.cal-c7 { background: var(--c); }

/* Dashboard: settimana compatta */
.week-strip-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s-2); list-style: none; margin: 0; padding: 0 var(--s-4) var(--s-4); }
.week-strip-days > li > a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: var(--s-3, 12px); border: 1px solid var(--border); border-radius: 10px; color: var(--fg); text-decoration: none; font-size: 13px; }
.week-strip-days > li.is-today > a { border-color: var(--brand); background: var(--brand-soft); }
.week-strip-days > li > a:hover { border-color: var(--fg-subtle); }
.week-strip-exits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.week-strip-exits li { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.week-strip-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.week-strip-none { font-size: 12px; }
@media (max-width: 760px) { .week-strip-days { grid-template-columns: 1fr; } }

/* Breadcrumb in alto: casetta (Home) e percorso della pagina */
.breadcrumb ol { display: flex; align-items: center; flex-wrap: nowrap; gap: 2px; margin: 0; padding: 0; list-style: none; min-width: 0; }
.breadcrumb li { display: inline-flex; align-items: center; gap: 2px; min-width: 0; white-space: nowrap; }
.breadcrumb li:last-child { overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.breadcrumb a { color: var(--fg-muted); text-decoration: none; border-radius: 6px; padding: 2px 4px; }
.breadcrumb a:hover { color: var(--brand-fg); background: var(--brand-soft); }
.breadcrumb .crumb-home { display: inline-flex; align-items: center; }
.breadcrumb .crumb-home .icon { width: 17px; height: 17px; }
.breadcrumb .crumb-sep { width: 14px; height: 14px; color: var(--fg-subtle); flex: none; }
@media (max-width: 760px) { .breadcrumb li:not(:first-child):not(:last-child) { display: none; } }

/* Spunti (0.43.0): elenco piatto con schede di stato, selezione multipla, etichette dei canali e menu «Altro» */
.source-add { margin-bottom: var(--s-4); }
.source-add > summary { list-style: none; cursor: pointer; width: max-content; max-width: 100%; }
.source-add > summary::-webkit-details-marker { display: none; }
.source-add[open] > summary { margin-bottom: var(--s-3); }
.source-tabs .cal-tab .badge { margin-left: 2px; }
.source-tabs .cal-tab.is-empty:not(.is-active) { opacity: .6; }
.source-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 60px; z-index: 10; }
.source-bulk-all { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.source-bulk-count { font-size: 13px; color: var(--fg-muted); }
.source-bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-left: auto; }
.source-bulk:not(.has-selection) .source-bulk-actions { opacity: .5; }
.source-bulk-assign { position: relative; }
.source-bulk-assign > summary { list-style: none; cursor: pointer; }
.source-bulk-assign > summary::-webkit-details-marker { display: none; }
.source-bulk-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: min(640px, 92vw); max-height: 70vh; overflow: auto;
  padding: var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.source-check { flex: none; width: 17px; height: 17px; margin-top: 3px; accent-color: var(--brand); cursor: pointer; }
.source-head { align-items: flex-start; }
.source-by { color: var(--fg-subtle); overflow-wrap: anywhere; }
.source-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.source-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg); }
.source-chip .chip-state { font-size: 11.5px; color: var(--fg-muted); }
.source-chip.chip-prossimo { border-color: var(--info); background: var(--info-soft); }
.source-chip.chip-prossimo .chip-state { color: var(--info); font-weight: 600; }
.source-chip.chip-usato { background: var(--ok-soft, #E8F5EC); }
.source-chip.chip-usato .chip-state { color: var(--ok, #1a7f37); }
.source-chip.chip-inattivo, .source-chip.chip-scaduto, .source-chip.chip-eliminato { opacity: .7; border-style: dashed; }
.source-chip.chip-none { border-style: dashed; color: var(--fg-muted); }
.source-menu { position: relative; }
.source-menu > summary { list-style: none; cursor: pointer; }
.source-menu > summary::-webkit-details-marker { display: none; }
.source-menu-pop { position: absolute; left: 0; top: calc(100% + 4px); z-index: 25; min-width: 230px; max-width: min(380px, 88vw);
  display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: var(--s-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.source-menu-pop > form { margin: 0; }
.source-menu-pop .btn { width: 100%; justify-content: flex-start; }
.source-menu-pop .source-panel[open] { flex: none; }
.source-assign-panel[open] { flex: 1 1 100%; }
@media (max-width: 760px) { .source-bulk { padding: var(--s-3) var(--s-4); top: 56px; } .source-bulk-actions { margin-left: 0; } }

/* Spunti (0.43.1): gruppi di canali a fisarmonica, chiusi di default, con la testata di un colore per gruppo */
.channel-group > .group-bar { display: flex; align-items: center; gap: var(--s-3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.channel-group > .group-bar > .check { flex: 1 1 auto; min-width: 0; align-items: center; background: transparent; border-bottom: 0; }
.channel-group > .group-bar .check-label { align-items: center; }
.channel-group > .group-bar .check-label .check-icon { margin-top: 0; }
.channel-group > .group-bar .check-label { font-weight: 650; font-size: 14px; }
.channel-group > .group-bar .check-text { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-group > .group-bar .check-note { margin-left: auto; flex: none; white-space: nowrap; font-family: inherit; }
.group-picked { font-size: 12.5px; color: var(--fg-muted); white-space: nowrap; }
.group-fold { flex: none; display: inline-flex; align-items: center; justify-content: center; align-self: stretch; width: 44px; border: 0;
  background: transparent; color: var(--fg-muted); cursor: pointer; }
.group-fold:hover { background: var(--surface-3, rgba(0,0,0,.06)); color: var(--fg); }
.group-fold .nav-caret { transition: transform .15s; }
.channel-group.is-collapsed .group-fold .nav-caret { transform: rotate(-90deg); }
.channel-group.is-collapsed > .group-bar { border-bottom: 0; }
.channel-group.is-collapsed > .channel-list { display: none; }

/* Spunti (0.43.1): intestazione dell'elenco in colonna (titolo, filtro su una riga, barra di selezione) e menu «Altro» dentro la riga,
   così sull'ultima scheda non viene tagliato dal riquadro e la pagina scrolla. */
.source-card .list-head { flex-direction: column; align-items: stretch; gap: var(--s-3); }
.source-card .list-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); width: 100%; margin: 0; }
.source-card .list-filter .field { margin: 0; }
.source-card .list-filter .grow { flex: 1 1 260px; }
.source-card .list-filter .field-button { margin-left: auto; }
.source-bulk { position: static; }
.source-bulk-count { margin-right: auto; }
.source-actions .source-menu[open] { flex: 1 1 100%; }
.source-menu-pop { position: static; margin-top: var(--s-2); flex-direction: row; flex-wrap: wrap; max-width: none; box-shadow: none; background: var(--surface-2); }
.source-menu-pop .btn { width: auto; }
@media (max-width: 760px) { .source-bulk { top: auto; } }

/* Spunti (0.43.2): filtro per canali a fisarmonica e anteprima dello spunto sotto la riga */
.source-card .list-filter details.filter-channels { flex: 0 0 auto; }
.source-card .list-filter details.filter-channels[open] { flex: 1 1 100%; order: 3; }
.filter-channels > summary { list-style: none; cursor: pointer; width: max-content; }
.filter-channels > summary::-webkit-details-marker { display: none; }
.filter-channels[open] > summary { margin-bottom: var(--s-3); }
.source-card .list-filter .field-button { order: 2; margin-left: 0; }
.source-preview[open], .source-assign-panel[open] { flex: 1 1 100%; }
.source-preview-body { display: grid; gap: var(--s-2); margin: var(--s-3) 0; padding: var(--s-3) var(--s-4); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius); }
.source-preview-meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); margin: 0; font-size: 13px; color: var(--fg-muted); }
.source-preview-meta > div { display: flex; gap: 6px; }
.source-preview-meta dt { font-weight: 600; } .source-preview-meta dd { margin: 0; overflow-wrap: anywhere; }
.source-preview-title { margin: 0; font-weight: 650; }
.source-preview-text { margin: 0; white-space: pre-line; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.source-preview-text.is-empty, .source-preview-more { color: var(--fg-muted); font-size: 13px; margin: 0; }
.source-preview-note { display: flex; gap: 8px; margin: 0; font-size: 13.5px; }

/* Spunti (0.43.3): canali suggeriti nell'anteprima */
.source-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding-top: var(--s-2); border-top: 1px dashed var(--border); }
.source-suggest-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.source-suggest .source-preview-more { flex: 1 1 100%; }

/* KPI (0.44.0): follower e crescita per canale */
.kpi-growth { margin-bottom: var(--s-5); }
.kpi-growth .spark { width: 120px; height: 30px; color: var(--brand); display: block; }
.kpi-growth .delta-up { color: var(--success, #1a7f4b); font-weight: 600; }
.kpi-growth .delta-down { color: var(--danger, #b42318); font-weight: 600; }
.kpi-growth .card-pad, .kpi-growth > .kpi-def { margin: var(--s-3) var(--s-5); }

/* KPI (0.44.1): engagement e CTR per canale */
.kpi-engagement { margin-bottom: var(--s-5); }
.kpi-engagement .card-pad, .kpi-engagement > .kpi-def { margin: var(--s-3) var(--s-5); }
