/* registry: SCAFFOLD
 * intent: full migration classi globali ratiofy.css decommissioning E1-E5 16 cluster tier-based
 * cabling_task: T#POST33-2
 * expires: 2026-06-26
 *
 * Ratiofy globals — classi globali decommissionate da ratiofy.css legacy
 * verso design system v4 (system.css token + components.css widget v4 + globals.css classi shared).
 *
 * Order CSS atteso (post-E5 decommissioning ratiofy.css):
 *   system.css → globals.css → components.css → page-specific
 *
 * Order CSS durante E1-E4 (dual-load, ratiofy.css ancora attivo):
 *   ratiofy.css → system.css → components.css → globals.css → page-specific
 *
 * Wave plan: 18 sub-fasi (PHASE 0 + E1.1-E1.5 TIER1 + E2.1-E2.4 TIER2 + E3.1-E3.7 TIER3 + E4 + E5)
 * Sub-fasi attualmente migrate qui:
 *   - E1.1 .btn family + runtime classes (.hidden, .visible) — sessione 52
 *   - E1.2 app-layout shell + responsive overrides — sessione 52
 *   - E1.3 sidebar family + responsive + dark + mobile off-canvas — sessione 52
 *   - E1.4 .card + .stat-card cluster + responsive + dark clone parziale — sessione 52
 *   - E1.5 form-* + button[type=submit] default + dark composito completo ricomposto — sessione 52
 *         (sostituisce dark clone parziale E1.4: .card+.stat-card → ora incluso nel composito E1.5)
 *   - E2.1 .alert family (base + .visible + -error/-success/-info/-warning) — sessione 52
 *   - E2.2 .spinner + .spinner-lg + @keyframes spin + @keyframes skeleton-pulse + .skeleton-block
 *         + .loading-overlay + .loading-text + .skeleton + @keyframes shimmer
 *         + .skeleton-text/.skeleton-title/.skeleton-card + .skeleton-line* + .skeleton-row — sessione 52
 *   - E2.3 .search-container + .search-input + .search-icon + .autocomplete-dropdown family
 *         (base + .open + .autocomplete-item* + dark override) — sessione 52
 *   - E2.4 .data-source-badge (D10 transparency) + .badge-xbrl / .badge-ai / .badge-benchmark /
 *         .badge-calculated — dark parity via token chain (system.css ridichiarazione dark)
 *         TIER2 CHIUSO (4/4 sub-fasi E2.1-E2.4 completate) — sessione 52
 *   - E3.1 .viewpoint-* cluster (7 selettori core + @media 768 scope-puro) + NEW :focus-visible
 *         WCAG 2.4.7 — dark parity via token chain (--color-bg, --color-border-light,
 *         --color-text-muted, --color-bg-card, --color-text-secondary, --color-primary,
 *         --color-text-inverse, --overlay-navy-04, --color-border)
 *   - E3.2 .score-circle cluster (5 selettori) + .score-* text (6) + .score-bg-* (6)
 *         + @media 768 scope-puro — token --score-* legacy hex light-only.
 *         Dark contrast risk documentato: rimedio deferred E5.0.5 alias system.css.
 *   - E3.3 .flag-item family (5 base + 5 .flag-severity-* + 5 .flag-icon-*) — dark parity
 *         via token chain (--flag-{critical,high,medium,low,info} dark-aware system.css L221-230)
 *   - E3.4 .section-info-btn + .info-tooltip + dark override + NEW :focus-visible WCAG 2.4.7.
 *         Token migration: TODO 1551 box-shadow rgba hardcoded → var(--shadow-tooltip) PHASE 0
 *   - E3.5 .section-title + ::before + dark override (background var(--ai))
 *   - E3.6 .traffic-light + .tl-{dot,green,yellow,red} + .lights-grid + .light-item* +
 *         @media 768 .lights-grid + dark override .light-item — token --score-* legacy
 *   - E3.7 .btn-gov-{approfondisci,external,actions,analyze,search} + .gov-view-{toggle,btn}
 *         + NEW :focus-visible WCAG 2.4.7 (gap critic). TIER3 7/7 chiuso.
 *   - E1.6 body.auth-page + .auth-{card,logo*,title,subtitle,footer} + responsive @768
 *         + dark .auth-card + .auth-logo__wordmark light/dark — risolve fallback 692/696.
 *         Cluster auth aggiunto post-discovery pre-E5: 54 classi residue ratiofy.css NON
 *         in scope POST33-2 originale 16 cluster. Sub-fase aggiuntiva user-approved.
 *   - E1.7 utility cluster (post-discovery) — sparse helpers (user-chip, info-popup,
 *         trend-card-values, activity-card-docs-panel) + text/font/spacing/flex/grid
 *         utilities + divider + empty-state + company-preview + progress-section +
 *         @media 768 grid-2/grid-3 scope-puro. ~37 classi.
 *   - E1.8 base resets element selectors: html / body / a / a:hover / img,svg /
 *         button,input,select,textarea / h1-h6 / p — chiude migrazione ratiofy.css.
 *
 * Token chain: globals.css referenzia token da ratiofy.css :root durante dual-load.
 * Token migration sweep (verso system.css) deferred a E5.0.5 prima decommissioning.
 */

/* === E1.1 Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  color: var(--color-text-inverse);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.btn-upgrade {
  background: var(--color-text-inverse);
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}
.btn-upgrade:hover:not(:disabled) {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.btn-delete-account {
  background: var(--color-text-inverse);
  border: 2px solid var(--flag-high);
  color: var(--flag-high);
  font-weight: 600;
}
.btn-delete-account:hover:not(:disabled) {
  background: var(--flag-high);
  color: var(--color-text-inverse);
}

.btn-danger {
  background: var(--flag-high);
  color: var(--color-text-inverse);
}

.btn-danger:hover:not(:disabled) {
  background: var(--flag-critical);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1.5px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-full { width: 100%; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--font-size-xs); }
.btn-lg { padding: 0.875rem 1.75rem; font-size: var(--font-size-base); }

/* === E1.1 Runtime classes (visibility) === */

.hidden  { display: none !important; }
.visible { display: block !important; }

/* === E1.2 App Layout Shell === */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  z-index: 50;
}

.page-header-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.page-body {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--container-max);
  width: 100%;
}

#sidebar-placeholder {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-primary-dark);
  flex-shrink: 0;
  transition: width var(--transition-slow);
}
[data-sidebar="collapsed"] #sidebar-placeholder {
  width: var(--sidebar-width-collapsed);
}

@media (max-width: 1024px) {
  .page-body { padding: var(--space-6); }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: row; }
  .main-content { margin-left: 0; }
  .page-body { padding: var(--space-4); }
  .page-header {
    padding: var(--space-3) var(--space-4);
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .page-header-actions { flex-wrap: wrap; gap: var(--space-2); }
}

@media (max-width: 768px) {
  /* display:none would hide the position:fixed sidebar inside it (CSS spec).
     Use width:0 instead to collapse layout space while keeping the sidebar rendered. */
  #sidebar-placeholder { width: 0; min-height: 0; overflow: hidden; }
}

@media (max-width: 600px) {
  .page-header {
    padding: var(--space-3) var(--space-3);
    height: auto;
    min-height: var(--header-height);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .page-header-title {
    font-size: var(--font-size-base);
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .page-header-actions { flex-wrap: wrap; gap: var(--space-2); }
  .page-header-actions .btn,
  .page-header-actions button { font-size: var(--font-size-xs); padding: 6px 10px; }
}

@media (max-width: 480px) {
  .page-header-title { font-size: var(--font-size-sm); max-width: 100%; }
}

/* === E1.3 Sidebar Family === */
/* Estratto da ratiofy.css cluster sidebar (210-617 + 1781-1855).
   Selettori identici, token migration applicata:
   - .sidebar-badge rgba green → var(--sidebar-badge-success-{bg,border})
   - .sidebar-toggle-btn:focus-visible → var(--color-primary-light) puro
   Dark sidebar override: nessuna regola sidebar nel blocco [data-theme="dark"] ratiofy.css.
   Sidebar è sempre dark navy indipendente dal theme.
   Session 52 — POST33-2 E1.3. */

/* Sidebar core base */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: visible;
}

.sidebar-scroll-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--overlay-white-10);
  text-decoration: none;
}

.sidebar-logo img,
.sidebar-logo svg {
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Full wordmark — default visible, sidebar expanded (v3.3 B2) */
/* Sidebar bg e' sempre navy scuro indipendente dal theme: logo fisso chiaro. */
.sidebar-logo__wordmark {
  width: 140px;
  height: auto;
  color: var(--sidebar-ink);
  display: block;
}

/* Mark only — hidden by default, shown when sidebar collapsed */
.sidebar-logo__mark {
  width: 32px;
  height: 32px;
  color: var(--sidebar-ink);
  display: none;
}

[data-sidebar="collapsed"] .sidebar-logo__wordmark { display: none; }
[data-sidebar="collapsed"] .sidebar-logo__mark { display: block; }

.sidebar-logo-text {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text-inverse);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: var(--space-4) var(--space-4);
}

.sidebar-nav-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--overlay-white-45);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--overlay-white-75);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-bottom: var(--space-1);
  cursor: pointer;
  text-decoration: none;
}

.sidebar-link:hover {
  background: var(--overlay-white-10);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--overlay-white-18);
  color: var(--color-text-inverse);
  font-weight: 600;
  border-left: 3px solid var(--overlay-white-80);
  padding-left: calc(var(--space-4) - 3px);
}

.sidebar-link .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Sidebar is always dark navy (regardless of page data-theme) → buttons
   need explicit light text. Override v4 .btn that would make bg=var(--surface). */
.sidebar-footer .sidebar-theme-toggle,
.sidebar-footer .sidebar-logout-btn {
  background: transparent !important;
  color: rgba(255,255,255,0.85) !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md, 10px);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition-fast, 150ms) ease-out;
  font-family: inherit;
}

.sidebar-footer .sidebar-theme-toggle:hover,
.sidebar-footer .sidebar-logout-btn:hover {
  background: rgba(255,255,255,0.08) !important;
  color: rgba(255,255,255,1) !important;
}

.sidebar-footer .sidebar-theme-toggle__icon {
  font-size: 14px;
  line-height: 1;
}

/* Collapsed sidebar: hide text, show only icon */
[data-sidebar="collapsed"] .sidebar-footer .sidebar-link-text { display: none; }
[data-sidebar="collapsed"] .sidebar-footer .sidebar-theme-toggle,
[data-sidebar="collapsed"] .sidebar-footer .sidebar-logout-btn {
  padding: 0.5rem;
  justify-content: center;
}

/* ─── Sidebar user info (credits / plan / badges) ─────────── */
.sidebar-user-info {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-user-credits {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  line-height: 1.4;
}

.sidebar-credits-icon {
  font-size: 1rem;
  color: var(--color-accent);
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-user-role {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-user-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

.sidebar-badge {
  /* Sidebar è sempre dark navy — contrast sufficiente (WCAG AA) con verde
     chiaro. In dark theme resta lo stesso (sidebar già scura). */
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  /* TOKEN MIGRATION POST33-2 E1.3: rgba green → token (PHASE 0 commit f5385e7) */
  background: var(--sidebar-badge-success-bg);
  color: var(--badge-accent-light); /* contrast 7.1:1 vs #1E3A5F sidebar bg */
  border: 1px solid var(--sidebar-badge-success-border);
  line-height: 1.6;
}

/* ─── Report Section Nav (left sidebar, report page only) ─── */
.sidebar-section-nav {
  padding: 0.75rem 0;
  border-top: 1px solid var(--overlay-white-10);
  overflow: hidden;
}

.sidebar-section-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem var(--space-4) 0.4rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.45);
}

.sidebar-section-nav-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 0.6rem;
  padding: 0;
  line-height: 1;
  transition: color var(--transition-fast);
}

.sidebar-section-nav-toggle:hover {
  color: rgba(255,255,255,0.8);
}

.sidebar-section-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.sidebar-section-nav-list .report-nav-item {
  margin: 0;
}

.sidebar-section-nav-list .report-nav-link {
  display: block;
  padding: 0.35rem var(--space-4) 0.35rem calc(var(--space-4) + 4px);
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section-nav-list .report-nav-link:hover {
  color: var(--color-text-inverse);
  background: var(--overlay-white-10);
  border-left-color: var(--overlay-white-45);
  text-decoration: none;
}

.sidebar-section-nav-list .report-nav-link.active {
  color: var(--color-text-inverse);
  background: var(--sidebar-nav-active-bg);
  border-left-color: var(--sidebar-nav-active-accent);
  font-weight: 600;
}

/* Intestazioni capitolo nel pannello Naviga */
.sidebar-section-nav-list .report-nav-chapter {
  padding: 0.5rem var(--space-4) 0.15rem;
  font-size: 0.60rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: rgba(255,255,255,0.28);
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: 0.2rem;
  list-style: none;
  pointer-events: none;
  user-select: none;
}

.sidebar-section-nav-list .report-nav-chapter:first-child {
  border-top: none;
  margin-top: 0;
}

.sidebar-section-nav.collapsed .sidebar-section-nav-list {
  display: none;
}

/* Sidebar collapse behaviour — UI Platform S2.3 (branch ratiofy-v3.3-ui-platform).
   Attivato quando <html data-sidebar="collapsed"> (impostato da sidebar.js + anti-FOUC).
   prefers-reduced-motion rispettato (transizione disabilitata). */
.sidebar { transition: width var(--transition-slow); }
[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-width-collapsed); }
[data-sidebar="collapsed"] .sidebar-logo { justify-content: center; padding: var(--space-4) 0 var(--space-4); gap: 0; }
[data-sidebar="collapsed"] .sidebar-logo-text,
[data-sidebar="collapsed"] .sidebar-nav-label,
[data-sidebar="collapsed"] .sidebar-link-text,
[data-sidebar="collapsed"] .sidebar-user-info,
[data-sidebar="collapsed"] .sidebar-user-credits,
[data-sidebar="collapsed"] .sidebar-user-role,
[data-sidebar="collapsed"] .sidebar-user-badges,
[data-sidebar="collapsed"] .sidebar-footer .btn > *:not(svg):not(.nav-icon) {
  display: none;
}
[data-sidebar="collapsed"] .sidebar-nav { padding: var(--space-2); }

/* Collapsed link: square 48x48 tap target, icon centered, text hidden explicitly.
   width/height fissi invece di font-size:0 hack per evitare race con .nav-icon sizing. */
[data-sidebar="collapsed"] .sidebar-link {
  width: 48px;
  height: 48px;
  margin-left: auto;
  margin-right: auto;
  padding: var(--space-3);
  gap: 0;
  justify-content: center;
  overflow: hidden;
}

[data-sidebar="collapsed"] .sidebar-link .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 1;
}

[data-sidebar="collapsed"] .sidebar-link-text { display: none; }
[data-sidebar="collapsed"] .sidebar-link.active { border-left: 0; padding-left: var(--space-3); }
[data-sidebar="collapsed"] .sidebar-footer { padding: var(--space-2); }
[data-sidebar="collapsed"] .sidebar-footer .btn { padding: var(--space-2); justify-content: center; }

/* Collapsed: hide language switcher + section-nav (no space for text widgets). */
[data-sidebar="collapsed"] #sidebar-lang-switcher,
[data-sidebar="collapsed"] .sidebar-lang-switcher,
[data-sidebar="collapsed"] .sidebar-section-nav {
  display: none;
}
[data-sidebar="collapsed"] .sidebar-scroll-area { padding: 0; }

/* Toggle button (iniettato da sidebar.js, non nel partial HTML per evitare
   mod a _partials/sidebar.html di scope condiviso v3.2).
   Fix W1.3 (24/04): z-index alzato sopra .sidebar-scroll-area + .page-header sticky,
   top allineato al centro logo, ombra più marcata per leggibilità su banda navy. */
.sidebar-toggle-btn {
  position: absolute;
  top: var(--space-6);
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow-md);
  z-index: 110;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.sidebar-toggle-btn:hover { background: var(--color-bg); color: var(--color-text); }

.sidebar-toggle-btn:focus-visible {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 2px;
}

.sidebar-toggle-btn svg { width: 14px; height: 14px; transition: transform var(--transition-slow); }
[data-sidebar="collapsed"] .sidebar-toggle-btn svg { transform: rotate(180deg); }

/* Mobile: sidebar slides as off-canvas — toggle button non ha senso (hamburger .sidebar-toggle
   gestisce mobile). Evita che il pulsante finisca fuori viewport su left edge. */
@media (max-width: 768px) {
  .sidebar-toggle-btn { display: none; }
}

/* Link text wrapper (iniettato da sidebar.js su ogni .sidebar-link text-node). */
.sidebar-link-text { transition: opacity var(--transition-fast); }

/* Reduced motion: no animations. */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .app-layout > .main-content,
  .sidebar-toggle-btn svg,
  .sidebar-link-text { transition: none !important; }
}

/* ── Sidebar hamburger toggle — visible only on mobile ───────────────────── */
/* Hidden on desktop; shown via @media below */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  margin-right: var(--space-3);
}

.sidebar-toggle:hover { background: var(--color-bg-secondary); }

/* ── Sidebar overlay backdrop (mobile) ───────────────────────────────────── */
/* Hidden by default; shown when sidebar is open on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-black-45);
  z-index: 999;
}

.sidebar-overlay.visible { display: block; }

/* Sidebar mobile off-canvas — override solo regole .sidebar/.sidebar.open/.sidebar-toggle.
   Layout rules (.app-layout, .main-content, .page-body, ecc.) già in E1.2. */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 260px;
    --header-height: 56px;
  }

  /* Sidebar collapses off-screen; slides in when .open is added */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
  }

  .sidebar.open { transform: translateX(0); }

  /* Hamburger button shown on mobile */
  .sidebar-toggle { display: flex; }
}

/* === E1.4 Card + Stat-card === */

/* --- Card --- */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

/* Category card shadow */
.category-card { box-shadow: var(--shadow-sm); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.card-subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* --- Stats grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-primary);
}

.stat-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Responsive — @media (max-width: 768px): only .stat-value + .stats-grid extracted.
   Other selectors (.app-layout, .main-content, .page-body, .page-header, .auth-card,
   .grid-3, .grid-2, .viewpoint-selector, .lights-grid) belong to other clusters
   (E1.2 shell, E1.5 form) and are NOT migrated here. */
@media (max-width: 768px) {
  .stat-value { font-size: var(--font-size-2xl); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Responsive — @media (max-width: 1024px): only .stats-grid extracted.
   .page-body already migrated in E1.2. */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === E1.5 Form Elements + Submit + Dark Composite === */
/* Estratto da ratiofy.css cluster form (L915-1033) + dark composito (L1967-1980).
   Selettori identici a ratiofy.css eccetto fallback 979 (#006FEE rimosso, var(--color-primary) PURO).
   Token RGBA verbatim (rgba 30,58,95,0.12 e rgba 231,76,60,0.12) — tokenizzazione deferred E5.
   Dark CLONE parziale E1.4 (.card+.stat-card subset) rimosso — ora incluso nel composito completo.
   Session 52 — POST33-2 E1.5. */

/* Submit button default style */
button[type="submit"]:not([class]) {
  width: 100%;
  padding: 0.75rem;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}
button[type="submit"]:not([class]):hover {
  background: var(--color-primary-hover);
}

/* --- Form elements --- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  line-height: 1.5;
}

.form-input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.12);
}

/* WCAG 2.4.7 — keyboard focus visible (H10 fix 20260425FIX1)
   Compensa l'`outline:none` globale (riga 953) per utenti tastiera.
   :focus-visible è valido solo per focus da Tab, non per click mouse.
   TOKEN MIGRATION E1.5: fallback hex #006FEE rimosso — var(--color-primary) PURO
   (system.css sempre disponibile durante dual-load, safety-net non necessario). */
.form-input:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.form-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

.form-input.error,
input.error {
  border-color: var(--flag-high);
  box-shadow: 0 0 0 3px rgba(231,76,60,0.12);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--flag-high);
  margin-top: var(--space-1);
  display: none;
}

.form-error.visible { display: block; }

/* Password input wrapper for show/hide toggle */
.input-password-wrap {
  position: relative;
}

.input-password-wrap input {
  padding-right: 2.5rem;
}

.btn-password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1rem;
  padding: 0;
  line-height: 1;
}

.btn-password-toggle:hover { color: var(--color-text); }

/* Dark composito completo — ratiofy.css L1967-1980 (verbatim, tutti i selettori).
   Sostituisce dark CLONE parziale E1.4 (.card+.stat-card subset — rimosso).
   Incluso: .page-header + .card + .stat-card + .form-input + input types + select + textarea. */
[data-theme="dark"] .page-header,
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .form-input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface);
  color: var(--ink-900);
  border-color: var(--border);
}

/* === E2.1 Alert family ===
   Source: ratiofy.css L1036-1048 (COPY VERBATIM — no token changes)
   5 selectors: .alert base + .alert.visible + .alert-{error,success,info,warning}

   Dark parity via token chain (NO explicit [data-theme="dark"] override needed):
   - --color-danger-bg/text:  light → ratiofy.css :root L81-82,  dark → system.css L325-326
   - --color-success-bg/text: light → system.css L117-118,       dark → system.css L233-234 + L300-301
   - --color-warning-bg/text: light → system.css L119-120,       dark → system.css L235-236 + L304-305
   - --color-info-bg/text:    light → system.css L123-124,       dark → system.css L239-240 + L306-307
   Token chain auto-repunta in dark mode — [data-theme="dark"] block non necessario. */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
  display: none;
}

.alert.visible { display: block; }
.alert-error   { background: var(--color-danger-bg); color: var(--color-danger-text); border: 1px solid var(--color-danger-bg); }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); border: 1px solid var(--color-success-bg); }
.alert-info    { background: var(--color-info-bg); color: var(--color-info-text); border: 1px solid var(--color-info-bg); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid var(--color-warning-bg); }

/* === E2.2 Loading + Skeleton + Spinner ===
   Source: ratiofy.css L1373-1389 (spinner), L1392-1395 + L1412-1417 (skeleton-pulse + skeleton-block),
           L1577-1590 (loading-overlay + loading-text), L1592-1620 (skeleton shimmer family)
   COPY VERBATIM — selectors and properties identical to ratiofy.css.

   Dark parity via token chain (NO explicit [data-theme="dark"] override needed):
   - --color-border:        light → ratiofy.css :root + system.css L74,  dark → system.css L196
   - --color-primary:       light → ratiofy.css :root + system.css L49,  dark → system.css L1960 [data-theme=dark]
   - --color-border-light:  alias --border-soft,  system.css L75 (light) / L197 (dark)
   - --color-border-strong: alias --ink-400,       system.css L68 (light) / L190 (dark)
   - --color-bg:            alias --paper,         system.css L58 (light) / L180 (dark)
   - --color-text-muted:    alias --ink-500,       system.css L67 (light) / L189 (dark)
   - --radius-{sm,full,lg}, --space-*, --font-size-sm: theme-invariant

   Shimmer gradient:   linear-gradient(90deg, --color-bg 25%, --color-border-light 50%, --color-bg 75%)
   Skeleton-block gradient: linear-gradient(90deg, --color-border-light 25%, --color-border-strong 50%, --color-border-light 75%)
   Both gradients auto-repunta in dark (bg=#13131c paper, border-light=rgba(46,46,58,0.6) border-soft).

   NOT migrated here (out of scope E2.2):
   - .trend-card-values (L1397-1401)       → utility T3 cluster
   - .activity-card-docs-panel (L1404-1410) → utility T3 cluster (uses --color-bg-subtle, separate token)
   - .btn-gov-approfondisci (L1420+)        → gov-view E3.7 cluster */

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Skeleton-block (pulse animation) --- */
@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-block {
  background: linear-gradient(90deg, var(--color-border-light) 25%, var(--color-border-strong) 50%, var(--color-border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
}

/* --- Loading overlay + text --- */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16);
  text-align: center;
}

.loading-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* --- Skeleton shimmer family --- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg) 25%,
    var(--color-border-light) 50%,
    var(--color-bg) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  display: block;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 1em; margin-bottom: var(--space-2); }
.skeleton-title { height: 1.5em; width: 60%; margin-bottom: var(--space-3); }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); }

/* Skeleton rows — imitano righe tabella risultati */
.skeleton-line { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-row  { height: 44px; margin-bottom: 4px; border-radius: 4px; }

/* === UX-103-1 W2: Section state helpers (loading / empty / error) === */
/* Used by RatifySectionState helper (report-section-state.js).        */

.section-loading {
  padding: var(--space-4, 1rem) var(--space-5, 1.25rem);
}
.section-loading-text {
  margin-top: var(--space-3, 0.75rem);
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--color-text-muted, #6b7280);
  text-align: center;
}
.section-empty {
  padding: var(--space-6, 1.5rem) var(--space-4, 1rem);
  text-align: center;
  color: var(--color-text-muted, #6b7280);
}
.section-empty-text {
  margin: 0;
  font-size: var(--font-size-sm, 0.875rem);
}
.section-error {
  padding: var(--space-4, 1rem);
  background: var(--color-warning-bg, #fef3c7);
  border-radius: var(--radius, 6px);
  color: var(--color-warning-fg, #92400e);
  text-align: center;
}
.section-error-text {
  margin: 0;
  font-size: var(--font-size-sm, 0.875rem);
}

/* === E2.3 Search + Autocomplete === */

/* Search bar */
.search-container {
  position: relative;
}

/* Sess 92 BUG-92-1 fix: bump specificity con `input.search-input` e `.search-container .search-icon`.
   `input[type="search"]` selector in `.form-input` rule (riga 886) ha specificity (0,0,1,1) =
   maggiore di `.search-input` (0,0,1,0) → padding-left collassava a 0.875rem (default form-input)
   anziché 2.75rem → testo "fer" sovrapposto a icona lente. Pattern stesso applicato a height + font-size. */
input.search-input {
  padding-left: 2.75rem;
  padding-right: var(--space-4);
  height: 48px;
  font-size: var(--font-size-base);
}

.search-container .search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}

.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border-light);
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.focused {
  background: var(--overlay-navy-05);
}

.autocomplete-item-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

.autocomplete-item-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

.autocomplete-item-fc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: monospace;
}

/* Dark override — Autocomplete / dropdown */
[data-theme="dark"] .autocomplete-dropdown { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .autocomplete-item:hover,
[data-theme="dark"] .autocomplete-item.focused { background: var(--surface-alt); }

/* === E2.4 Data source badges === */
/*
 * D10 — AI transparency: badge che identificano l'origine di ogni dato mostrato.
 *
 * Dark parity: token chain via system.css — NO override [data-theme="dark"] esplicito necessario.
 * Tutti i token referenziati sono dark-aware:
 *   --color-ai-bg / --color-ai-text      light: ratiofy.css L87-88,
 *                                         dark:  system.css L331-332 (oklch)
 *   --color-info-bg / --color-info-text   light: system.css L123-124,
 *                                         dark:  system.css L239-240 + L306-307
 *   --color-success-bg / -text            light: system.css L117-118,
 *                                         dark:  system.css L233-234 + L300-301
 *   --color-warning-bg / -text            light: system.css L119-120,
 *                                         dark:  system.css L235-236 + L304-305
 * Token chain gestisce dark mode automaticamente alla ridichiarazione in system.css.
 */

.data-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-xbrl       { background: var(--color-info-bg); color: var(--color-info-text); border: 1px solid var(--color-info-bg); }
.badge-ai         { background: var(--color-ai-bg); color: var(--color-ai-text); border: 1px solid var(--color-ai-bg); }
.badge-benchmark  { background: var(--color-success-bg); color: var(--color-success-text); border: 1px solid var(--color-success-bg); }
.badge-calculated { background: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid var(--color-warning-bg); }

/* === E3.1 ViewPoint === */
/*
 * D4 — ViewPoint strip: sticky sotto l'header durante lo scroll, selettore prospettiva.
 *
 * Dark parity: token chain via system.css — NO override [data-theme="dark"] esplicito necessario.
 * Tutti i token referenziati sono dark-aware:
 *   --color-bg              light: ratiofy.css :root, dark: system.css L297
 *   --color-border-light    light: ratiofy.css :root, dark: system.css (border light override)
 *   --color-text-muted      light: ratiofy.css :root, dark: system.css L289
 *   --color-bg-card         light: ratiofy.css :root, dark: system.css L295
 *   --color-text-secondary  light: ratiofy.css :root, dark: system.css L288
 *   --color-primary         light: ratiofy.css :root, dark: system.css L280
 *   --color-text-inverse    light: ratiofy.css :root, dark: system.css L291
 *   --overlay-navy-04       light: ratiofy.css :root, dark: system.css overlay override
 *   --color-border          light: ratiofy.css :root, dark: system.css L293
 * Token chain gestisce dark mode automaticamente alla ridichiarazione in system.css.
 */

.viewpoint-strip {
  position: sticky;
  top: var(--header-height);
  z-index: 40;
  background: var(--color-bg);
  padding: var(--space-2) 0;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.viewpoint-strip-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.viewpoint-selector {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) 0;
}

.viewpoint-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.viewpoint-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--overlay-navy-04);
}

.viewpoint-btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

/* WCAG 2.4.7 focus-visible NEW (POST33-2 E3.1 — gap critic) */
.viewpoint-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Locked lenses — disabilitate (solo Consulente attiva per ora). */
.viewpoint-btn--locked,
.viewpoint-btn--locked:hover {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  background: var(--color-bg-card);
}

.viewpoint-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-right: var(--space-2);
  align-self: center;
}

@media (max-width: 768px) {
  .viewpoint-selector {
    flex-wrap: wrap;
    gap: var(--space-2);
    overflow: visible;
  }
}

/* === E3.2 Score circle + score colors === */
/*
 * Token --score-* legacy ratiofy.css :root, hex hardcoded light-only.
 * Dark mode contrast risk: rimedio in E5.0.5 token migration sweep system.css
 * con alias `--score-excellent: var(--ottimo)` ecc. per dark-aware re-pointing automatico.
 */

/* Score circle */
.score-circle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
}

.score-circle svg { position: absolute; top: 0; left: 0; }

.score-circle-inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.score-number {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  line-height: 1;
}

.score-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Score color classes — allineate a SCORE_BANDS in utils.js */
.score-excellent  { color: var(--score-excellent); }
.score-good       { color: var(--score-good);      }
.score-sufficient { color: var(--score-sufficient); }
.score-critical   { color: var(--score-critical);   }
.score-grave      { color: var(--score-grave);      }
.score-insolvency { color: var(--score-insolvency); }

.score-bg-excellent  { background: var(--score-excellent); }
.score-bg-good       { background: var(--score-good); }
.score-bg-sufficient { background: var(--score-sufficient); }
.score-bg-critical   { background: var(--score-critical); }
.score-bg-grave      { background: var(--score-grave); }
.score-bg-insolvency { background: var(--score-insolvency); }

@media (max-width: 768px) {
  .score-circle { width: 90px; height: 90px; }
}

/* === E3.3 Flag-item family ===
 * Dark parity via token chain: --flag-{critical,high,medium,low,info} dark-aware
 * via system.css L221-230 (oklch desaturate dark). NO override esplicito necessario.
 * Consumer JS-only: report-flags.js / report-ratios.js / report-docs.js / utils.js
 * (innerHTML build con classe runtime).
 */
.flag-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
}

.flag-item-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  color: white;
  margin-top: 2px;
}

.flag-item-body { flex: 1; min-width: 0; }

.flag-item-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

.flag-item-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.flag-severity-critical { border-left: 3px solid var(--flag-critical); }
.flag-severity-high     { border-left: 3px solid var(--flag-high);     }
.flag-severity-medium   { border-left: 3px solid var(--flag-medium);   }
.flag-severity-low      { border-left: 3px solid var(--flag-low);      }
.flag-severity-info     { border-left: 3px solid var(--flag-info);     }

.flag-icon-critical { background: var(--flag-critical); }
.flag-icon-high     { background: var(--flag-high);     }
.flag-icon-medium   { background: var(--flag-medium);   }
.flag-icon-low      { background: var(--flag-low);      }
.flag-icon-info     { background: var(--flag-info);     }

/* === E3.4 Section info button + tooltip ===
 * Bottone "?" informativo + tooltip absolute. Consumer report.html + report.js.
 * Token migration: TODO 1551 box-shadow rgba(0,0,0,0.13) hardcoded → var(--shadow-tooltip)
 *   (PHASE 0 token system.css L183 light + L302 dark intensificato 0.45).
 * NEW :focus-visible WCAG 2.4.7 (gap critic round 1).
 * Dark override esplicito: tooltip background/text/border re-pointing system.css token.
 */
.section-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--color-info-bg);
  color: var(--color-primary);
  border: 1px solid var(--color-info-bg);
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  position: relative;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  font-style: normal;
  line-height: 1.6;
  z-index: 10;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.section-info-btn:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
/* WCAG 2.4.7 focus-visible NEW (POST33-2 E3.4 — gap critic) */
.section-info-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.section-info-btn .info-tooltip {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  min-width: 280px;
  max-width: 340px;
  background: var(--color-text-inverse);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--color-text-dark);
  z-index: 300;
  box-shadow: var(--shadow-tooltip);
  text-align: left;
  font-weight: 400;
  font-style: normal;
  pointer-events: none;
  white-space: normal;
}
.section-info-btn .info-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: var(--color-text-inverse);
  border-top: 1px solid var(--color-border-strong);
  border-left: 1px solid var(--color-border-strong);
  transform: rotate(45deg);
  z-index: 1;
}
.section-info-btn:hover .info-tooltip,
.section-info-btn.open .info-tooltip {
  display: block;
}

[data-theme="dark"] .section-info-btn .info-tooltip {
  background: var(--surface);
  color: var(--ink-900);
  border-color: var(--border);
}
[data-theme="dark"] .section-info-btn .info-tooltip::before {
  background: var(--surface);
  border-top-color: var(--border);
  border-left-color: var(--border);
}

/* === E3.5 Section title ===
 * Heading section con bullet ::before (4px navy bar). Dark override re-points ::before
 * background a var(--ai) (purple accent — distintivo report sezioni AI-generated).
 */
.section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.2em;
  background: var(--color-primary);
  border-radius: var(--radius-full);
}

[data-theme="dark"] .section-title::before { background: var(--ai); }

/* === E3.6 Traffic light indicators ===
 * Consumer JS-only utils.js (getScoreColor builds runtime). Dot color usa --score-*
 * legacy ratiofy.css :root (light hex hardcoded — same dark contrast risk di E3.2,
 * rimedio E5.0.5 alias). Dark override esplicito per .light-item background.
 */
.traffic-light {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.tl-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.tl-green  { background: var(--score-excellent); }
.tl-yellow { background: var(--score-sufficient); }
.tl-red    { background: var(--score-critical); }

.lights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.light-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.light-item .tl-dot {
  width: 16px;
  height: 16px;
}

.light-item-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

@media (max-width: 768px) {
  .lights-grid { grid-template-columns: repeat(3, 1fr); }
}

[data-theme="dark"] .light-item { background: var(--surface-alt); }

/* === E3.7 Governance buttons + view toggle ===
 * Consumer: report.html + report-governance.js (JS innerHTML build).
 * NEW :focus-visible WCAG 2.4.7 per .btn-gov-* e .gov-view-btn (gap critic round 1).
 * Dark parity via token chain: --color-info-bg/--color-primary/--color-text-inverse/
 * --color-bg-alt/--color-text-secondary/--color-border/--color-border-strong/
 * --surface-alt tutti dark-aware via system.css [data-theme=dark].
 */
.btn-gov-approfondisci {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--color-info-bg);
  color: var(--color-primary);
  border: 1px solid var(--color-info-bg);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.btn-gov-approfondisci:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.btn-gov-external {
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn-gov-external:hover {
  background: var(--color-border);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.btn-gov-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.btn-gov-analyze {
  background: var(--color-info-bg);
  color: var(--color-primary);
  border-color: var(--color-info-bg);
}
.btn-gov-analyze:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.btn-gov-search {
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.btn-gov-search:hover {
  background: var(--color-border);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

/* Disabled state — applied to [Dettagli][Cerca web] when entity not actionable
 * (PF no-CF, PG no-CF, name missing). Coherent across registry-extended + governance tables. */
.btn-gov-detail--disabled,
.btn-gov-detail--disabled:hover,
.btn-gov-search.btn-gov-detail--disabled,
.btn-gov-search.btn-gov-detail--disabled:hover,
.btn-gov-analyze.btn-gov-detail--disabled,
.btn-gov-analyze.btn-gov-detail--disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  pointer-events: none;
}

.gov-view-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.gov-view-btn {
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--color-border-strong);
  background: var(--surface-alt);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.gov-view-btn:hover {
  background: var(--color-info-bg);
  color: var(--color-primary);
  border-color: var(--color-info-bg);
}
.gov-view-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* WCAG 2.4.7 focus-visible NEW (POST33-2 E3.7 — gap critic) */
.btn-gov-approfondisci:focus-visible,
.btn-gov-external:focus-visible,
.btn-gov-analyze:focus-visible,
.btn-gov-search:focus-visible,
.gov-view-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* === E1.6 Auth layout (centered card, no sidebar) ===
 * Pages: login, register, forgot-password, reset-password, verify.
 * Token migrations: fallback 692 (.auth-logo__wordmark light) + fallback 696 (dark)
 * rimossi (var() PURO). Tutti i token sono in system.css post E5.0.5 sweep.
 */
body.auth-page {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 40%, var(--navy-600) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
}

.auth-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-10) var(--space-12);
  width: 100%;
  max-width: 440px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
  margin-bottom: var(--space-8);
}

.auth-logo img,
.auth-logo svg {
  width: 40px;
  height: 40px;
}

.auth-logo__wordmark {
  width: 180px;
  height: auto;
  color: var(--color-primary);
  display: block;
}

[data-theme="dark"] .auth-logo__wordmark {
  color: var(--ink-50);
}

.auth-logo-text {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  text-align: center;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--font-size-sm);
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.auth-footer {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-6);
}

.auth-footer a {
  color: var(--color-primary);
  font-weight: 500;
}

@media (max-width: 768px) {
  .auth-card {
    padding: var(--space-8) var(--space-6);
    border-radius: var(--radius-lg);
  }
}

[data-theme="dark"] .auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
}

/* === E1.7 Utility cluster === */

/* --- Sparse helpers --- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.info-popup { max-width: 280px; }
@media (max-width: 768px) { .info-popup { max-width: 240px; } }

.trend-card-values {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.activity-card-docs-panel {
  padding: 10px 12px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

/* --- Text color utilities --- */

.text-muted     { color: var(--color-text-muted) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-primary   { color: var(--color-primary) !important; }
.text-success   { color: var(--score-excellent) !important; }
.text-warning   { color: var(--score-sufficient) !important; }
.text-danger    { color: var(--score-critical) !important; }

/* --- Text size utilities --- */

.text-xs   { font-size: var(--font-size-xs); }
.text-sm   { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg   { font-size: var(--font-size-lg); }

/* --- Font weight utilities --- */

.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

/* --- Spacing utilities --- */

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* --- Flex utilities --- */

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

/* --- Grid utilities --- */

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }

/* --- Layout utilities --- */

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

.empty-state {
  text-align: center;
  padding: var(--space-16);
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state-text {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
}

.company-preview {
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: none;
}

.company-preview.visible { display: block; }

.company-preview-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.company-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.company-preview-item {}
.company-preview-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.company-preview-value {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

.progress-section {
  display: none;
  padding: var(--space-6);
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  text-align: center;
}
.progress-section.visible { display: block; }

.progress-bar-wrap {
  background: var(--color-bg);
  border-radius: var(--radius-full);
  height: 12px;
  overflow: hidden;
  margin: var(--space-4) 0;
}

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  width: 0%;
}

.progress-status {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* --- @media 768 grid-2/grid-3 scope-puro --- */

@media (max-width: 768px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* === E1.8 Base resets (element selectors) ===
 * Reset di base elementi html (html, body, a, img, svg, button/input/select/textarea,
 * h1-h6, p). Migrate da ratiofy.css L157-197. system.css ha alcuni reset (* box-sizing,
 * body) ma manca questo set completo. Senza, base typography break post-decommissioning.
 * NOTA: system.css body declaration (font-family/color/background/margin/antialiased)
 * resta valida; questo block estende con line-height/min-height/overflow-x.
 */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

img, svg { display: block; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

p { line-height: 1.7; color: var(--color-text-secondary); }
