  /* ═══════════════════════════════════════════════════════════════════════════════
   ANTI-FLASH: nasconde login area se sessione già attiva (class aggiunta dall'inline script <head>)
   ═══════════════════════════════════════════════════════════════════════════════ */
  .sigo-auth-ok #sigo-login-area { display: none !important; }
  .sigo-auth-ok #sigo-app-content { display: block !important; }

  /* ═══════════════════════════════════════════════════════════════════════════════
   CSS VARIABLES - DESIGN TOKENS
   ═══════════════════════════════════════════════════════════════════════════════ */

  :root {
    /* Colori primari */
    --primary: #1976d2;
    --primary-light: #42a5f5;
    --primary-dark: #1565c0;
    --primary-bg: rgba(25, 118, 210, 0.08);

    /* Colori secondari */
    --secondary: #424242;
    --secondary-light: #616161;
    --secondary-dark: #212121;

    /* Colori semantici */
    --success: #388e3c;
    --success-light: #4caf50;
    --success-bg: rgba(56, 142, 60, 0.08);

    --warning: #f57c00;
    --warning-light: #ff9800;
    --warning-bg: rgba(245, 124, 0, 0.08);

    --error: #d32f2f;
    --error-light: #f44336;
    --error-bg: rgba(211, 47, 47, 0.08);

    --info: #0288d1;
    --info-light: #03a9f4;
    --info-bg: rgba(2, 136, 209, 0.08);

    /* Colori stati intervento */
    --stato-in-lavorazione: #4fc3f7;
    --stato-da-contabilizzare: #ff9800;
    --stato-contabilizzato: #e91e63;
    --stato-completato: #4caf50;
    --stato-da-fatturare: #ffc107;
    --stato-fatturato: #9c27b0;
    --stato-annullato: #f44336;

    /* Grigi */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Background e superfici */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f7fa;
    --bg-tertiary: #eef2f6;

    /* Testo */
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-disabled: #9e9e9e;
    --text-hint: #bdbdbd;
    --text-inverse: #ffffff;

    /* Bordi */
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    --border-dark: #bdbdbd;

    /* Ombre */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transizioni */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;

    /* Font */
    --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace;

    /* Font sizes */
    --text-xs: 0.75rem;
    /* 12px */
    --text-sm: 0.875rem;
    /* 14px */
    --text-base: 1rem;
    /* 16px */
    --text-lg: 1.125rem;
    /* 18px */
    --text-xl: 1.25rem;
    /* 20px */
    --text-2xl: 1.5rem;
    /* 24px */
    --text-3xl: 1.875rem;
    /* 30px */

    /* Line heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Sidebar width */
    --sidebar-width: 380px;

    /* Input (default chiaro) */
    --input-bg: #ffffff;
    --input-border: #e0e0e0;
    --input-focus-border: #1976d2;
    --input-text: #212121;
    --input-placeholder: #9ca3af;
    --input-focus-bg: #ffffff;

    /* Accent (default chiaro) */
    --accent: #1976d2;
    --accent-hover: #1565c0;
    --accent-blue: #1976d2;
    --accent-green: #388e3c;
    --accent-yellow: #f57c00;
    --accent-orange: #f57c00;
    --accent-red: #d32f2f;
    --accent-purple: #7c3aed;
    --accent-cyan: #06b6d4;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   SISTEMA TEMI - Chiaro, Medio, Scuro
   ═══════════════════════════════════════════════════════════════════════════════ */

  /* TEMA CHIARO (default - già definito in :root) */
  [data-theme="chiaro"] {
    /* Colori primari */
    --primary: #1976d2;
    --primary-light: #42a5f5;
    --primary-dark: #1565c0;
    --primary-bg: rgba(25, 118, 210, 0.08);

    /* Grigi */
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Background e superfici */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f7fa;
    --bg-tertiary: #eef2f6;
    --bg-dark: #1e293b;
    --bg-card: #ffffff;
    --bg-sidebar: #f8fafc;

    /* Testo */
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-disabled: #9e9e9e;
    --text-hint: #bdbdbd;
    --text-inverse: #ffffff;

    /* Bordi */
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    --border-dark: #bdbdbd;

    /* Ombre */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

    /* Input */
    --input-bg: #ffffff;
    --input-border: #e0e0e0;
    --input-focus-border: #1976d2;
    --input-text: #212121;
    --input-placeholder: #9ca3af;
    --input-focus-bg: #ffffff;

    /* Accent (alias per compatibilita' dashboard/pianificazione) */
    --accent: #1976d2;
    --accent-hover: #1565c0;
    --accent-blue: #1976d2;
    --accent-green: #388e3c;
    --accent-yellow: #f57c00;
    --accent-orange: #f57c00;
    --accent-red: #d32f2f;
    --accent-purple: #7c3aed;
    --accent-cyan: #06b6d4;

    /* Header */
    --header-bg: #1976d2;
    --header-text: #ffffff;
  }

  /* TEMA MEDIO (grigio) */
  [data-theme="medio"] {
    /* Colori primari */
    --primary: #60a5fa;
    --primary-light: #93c5fd;
    --primary-dark: #3b82f6;
    --primary-bg: rgba(96, 165, 250, 0.15);

    /* Grigi invertiti per tema medio */
    --gray-50: #374151;
    --gray-100: #4b5563;
    --gray-200: #6b7280;
    --gray-300: #9ca3af;
    --gray-400: #d1d5db;
    --gray-500: #e5e7eb;
    --gray-600: #f3f4f6;
    --gray-700: #f9fafb;
    --gray-800: #ffffff;
    --gray-900: #ffffff;

    /* Background e superfici */
    --bg-primary: #4b5563;
    --bg-secondary: #374151;
    --bg-tertiary: #1f2937;
    --bg-dark: #111827;
    --bg-card: #4b5563;
    --bg-sidebar: #374151;

    /* Testo */
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-disabled: #9ca3af;
    --text-hint: #6b7280;
    --text-inverse: #111827;

    /* Bordi */
    --border-color: #6b7280;
    --border-light: #4b5563;
    --border-dark: #9ca3af;

    /* Ombre */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.2);

    /* Input */
    --input-bg: #374151;
    --input-border: #6b7280;
    --input-focus-border: #60a5fa;
    --input-text: #f9fafb;
    --input-placeholder: #9ca3af;
    --input-focus-bg: #4b5563;

    /* Accent (alias per compatibilita' dashboard/pianificazione) */
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-blue: #60a5fa;
    --accent-green: #34d399;
    --accent-yellow: #fbbf24;
    --accent-orange: #fbbf24;
    --accent-red: #f87171;
    --accent-purple: #a78bfa;
    --accent-cyan: #22d3ee;

    /* Colori semantici adattati */
    --success: #34d399;
    --success-light: #6ee7b7;
    --success-bg: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: #fde68a;
    --warning-bg: rgba(251, 191, 36, 0.15);
    --error: #f87171;
    --error-light: #fca5a5;
    --error-bg: rgba(248, 113, 113, 0.15);

    /* Header */
    --header-bg: #1f2937;
    --header-text: #f9fafb;
  }

  /* TEMA SCURO (blu notte) */
  [data-theme="scuro"] {
    /* Colori primari */
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --primary-bg: rgba(59, 130, 246, 0.15);

    /* Grigi invertiti per tema scuro */
    --gray-50: #1e293b;
    --gray-100: #334155;
    --gray-200: #475569;
    --gray-300: #64748b;
    --gray-400: #94a3b8;
    --gray-500: #cbd5e1;
    --gray-600: #e2e8f0;
    --gray-700: #f1f5f9;
    --gray-800: #f8fafc;
    --gray-900: #ffffff;

    /* Background e superfici */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-dark: #020617;
    --bg-card: #1e293b;
    --bg-sidebar: #1a2332;

    /* Testo */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-disabled: #64748b;
    --text-hint: #475569;
    --text-inverse: #0f172a;

    /* Bordi */
    --border-color: #334155;
    --border-light: #1e293b;
    --border-dark: #475569;

    /* Ombre */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.4);

    /* Input */
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-focus-border: #3b82f6;
    --input-text: #f1f5f9;
    --input-placeholder: #64748b;
    --input-focus-bg: #334155;

    /* Accent (alias per compatibilita' dashboard/pianificazione) */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-yellow: #eab308;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;

    /* Header */
    --header-bg: #0f172a;
    --header-text: #f1f5f9;

    /* Colori semantici adattati */
    --success: #22c55e;
    --success-light: #4ade80;
    --success-bg: rgba(34, 197, 94, 0.15);

    --warning: #eab308;
    --warning-light: #facc15;
    --warning-bg: rgba(234, 179, 8, 0.15);

    --error: #ef4444;
    --error-light: #f87171;
    --error-bg: rgba(239, 68, 68, 0.15);

    --info: #06b6d4;
    --info-light: #22d3ee;
    --info-bg: rgba(6, 182, 212, 0.15);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   RESET E BASE
   ═══════════════════════════════════════════════════════════════════════════════ */

  *,
  *::before,
  *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    font-family: var(--font-family);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════════ */

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

  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  h3 {
    font-size: var(--text-xl);
  }

  h4 {
    font-size: var(--text-lg);
  }

  h5 {
    font-size: var(--text-base);
  }

  h6 {
    font-size: var(--text-sm);
  }

  p {
    margin-bottom: var(--space-md);
  }

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

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

  small {
    font-size: var(--text-xs);
    color: var(--text-secondary);
  }

  code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════════ */

  .container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
  }

  .sidebar-container {
    width: var(--sidebar-width);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
  }

  .page-container {
    min-height: 100vh;
    padding: var(--space-lg);
  }

  .flex {
    display: flex;
  }

  .flex-col {
    flex-direction: column;
  }

  .flex-wrap {
    flex-wrap: wrap;
  }

  .items-center {
    align-items: center;
  }

  .items-start {
    align-items: flex-start;
  }

  .items-end {
    align-items: flex-end;
  }

  .justify-center {
    justify-content: center;
  }

  .justify-between {
    justify-content: space-between;
  }

  .justify-end {
    justify-content: flex-end;
  }

  .gap-xs {
    gap: var(--space-xs);
  }

  .gap-sm {
    gap: var(--space-sm);
  }

  .gap-md {
    gap: var(--space-md);
  }

  .gap-lg {
    gap: var(--space-lg);
  }

  .grid {
    display: grid;
  }

  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   CARD
   ═══════════════════════════════════════════════════════════════════════════════ */

  .card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

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

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

  .card-body {
    padding: var(--space-lg);
  }

  .card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: var(--gray-50);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════════ */

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

  .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

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

  .btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
  }

  .btn-secondary {
    background: var(--gray-200);
    color: var(--text-primary);
  }

  .btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
  }

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

  .btn-success:hover:not(:disabled) {
    background: var(--success-light);
  }

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

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

  .btn-error:hover:not(:disabled) {
    background: var(--error-light);
  }

  .btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
  }

  .btn-outline:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-400);
  }

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

  .btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--text-primary);
  }

  .btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
  }

  .btn-lg {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-base);
  }

  .btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
  }

  .btn-icon.btn-sm {
    width: 28px;
    height: 28px;
  }

  .btn-block {
    width: 100%;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════════════════ */

  .form-group {
    margin-bottom: var(--space-md);
  }

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

  .form-label.required::after {
    content: ' *';
    color: var(--error);
  }

  .form-control {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  }

  .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
  }

  .form-control:disabled {
    background: var(--gray-100);
    color: var(--text-disabled);
    cursor: not-allowed;
  }

  .form-control.is-invalid {
    border-color: var(--error);
  }

  .form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--error-bg);
  }

  .form-control.is-valid {
    border-color: var(--success);
  }

  textarea.form-control {
    min-height: 100px;
    resize: vertical;
  }

  select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23757575' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }

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

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

  /* Checkbox e Radio */
  .form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
  }

  .form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
  }

  .form-check-label {
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
  }

  /* Input group */
  .input-group {
    display: flex;
    align-items: stretch;
  }

  .input-group .form-control {
    flex: 1;
    border-radius: 0;
  }

  .input-group .form-control:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
  }

  .input-group .form-control:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
  }

  .input-group-text {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--gray-100);
    border: 1px solid var(--border-color);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   BADGES E TAGS
   ═══════════════════════════════════════════════════════════════════════════════ */

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius-full);
    white-space: nowrap;
  }

  .badge-primary {
    background: var(--primary-bg);
    color: var(--primary);
  }

  .badge-success {
    background: var(--success-bg);
    color: var(--success);
  }

  .badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
  }

  .badge-error {
    background: var(--error-bg);
    color: var(--error);
  }

  .badge-info {
    background: var(--info-bg);
    color: var(--info);
  }

  .badge-gray {
    background: var(--gray-200);
    color: var(--gray-700);
  }

  /* Badge stati intervento */
  .badge-in-lavorazione {
    background: rgba(79, 195, 247, 0.15);
    color: #0277bd;
  }

  .badge-da-contabilizzare {
    background: rgba(255, 152, 0, 0.15);
    color: #e65100;
  }

  .badge-contabilizzato {
    background: rgba(233, 30, 99, 0.15);
    color: #c2185b;
  }

  .badge-completato {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
  }

  .badge-annullato {
    background: rgba(244, 67, 54, 0.15);
    color: #c62828;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════════ */

  .table-container {
    overflow-x: auto;
  }

  .table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
  }

  .table th,
  .table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
  }

  .table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--gray-50);
    white-space: nowrap;
  }

  .table tbody tr:hover {
    background: var(--gray-50);
  }

  .table-striped tbody tr:nth-child(odd) {
    background: var(--gray-50);
  }

  .table-compact th,
  .table-compact td {
    padding: var(--space-xs) var(--space-sm);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   LIST
   ═══════════════════════════════════════════════════════════════════════════════ */

  .list {
    list-style: none;
  }

  .list-item {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
  }

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

  .list-item:hover {
    background: var(--gray-50);
  }

  .list-item-clickable {
    cursor: pointer;
  }

  .list-item-active {
    background: var(--primary-bg);
    border-left: 3px solid var(--primary);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   ALERT / TOAST
   ═══════════════════════════════════════════════════════════════════════════════ */

  .alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(56, 142, 60, 0.2);
  }

  .alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 124, 0, 0.2);
  }

  .alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(211, 47, 47, 0.2);
  }

  .alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(2, 136, 209, 0.2);
  }

  /* Toast container */
  .toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  .toast {
    padding: var(--space-md) var(--space-lg);
    background: var(--gray-900);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
  }

  .toast-success {
    background: var(--success);
  }

  .toast-error {
    background: var(--error);
  }

  @keyframes slideIn {
    from {
      transform: translateX(100%);
      opacity: 0;
    }

    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */

  .modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }

  .modal-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
  }

  .modal-backdrop.show .modal {
    transform: scale(1);
  }

  .modal-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
  }

  .modal-close {
    background: none;
    border: none;
    font-size: var(--text-xl);
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
  }

  .modal-close:hover {
    color: var(--text-primary);
  }

  .modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
  }

  .modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
  }

  /* Modal Form Styles */
  .form-modal {
    min-width: 400px;
  }

  .form-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }

  .modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    padding-top: var(--space-md);
  }

  .modal-actions .mr-auto {
    margin-right: auto;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   LOADING / SPINNER
   ═══════════════════════════════════════════════════════════════════════════════ */

  .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  .spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
  }

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

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

  .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
  }

  .skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
  }

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

    100% {
      background-position: -200% 0;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════════════════════ */

  .tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: var(--space-xs);
  }

  .tab {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -1px;
  }

  .tab:hover {
    color: var(--text-primary);
    background: var(--gray-50);
  }

  .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
  }

  .tab-content {
    display: none;
    padding: var(--space-md) 0;
  }

  .tab-content.active {
    display: block;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════════════════════ */

  .empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-secondary);
  }

  .empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-md);
    opacity: 0.5;
  }

  .empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
  }

  .empty-state-text {
    font-size: var(--text-sm);
    margin-bottom: var(--space-lg);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════════ */

  /* Spacing */
  .m-0 {
    margin: 0;
  }

  .m-xs {
    margin: var(--space-xs);
  }

  .m-sm {
    margin: var(--space-sm);
  }

  .m-md {
    margin: var(--space-md);
  }

  .m-lg {
    margin: var(--space-lg);
  }

  .mt-0 {
    margin-top: 0;
  }

  .mt-xs {
    margin-top: var(--space-xs);
  }

  .mt-sm {
    margin-top: var(--space-sm);
  }

  .mt-md {
    margin-top: var(--space-md);
  }

  .mt-lg {
    margin-top: var(--space-lg);
  }

  .mb-0 {
    margin-bottom: 0;
  }

  .mb-xs {
    margin-bottom: var(--space-xs);
  }

  .mb-sm {
    margin-bottom: var(--space-sm);
  }

  .mb-md {
    margin-bottom: var(--space-md);
  }

  .mb-lg {
    margin-bottom: var(--space-lg);
  }

  .p-0 {
    padding: 0;
  }

  .p-xs {
    padding: var(--space-xs);
  }

  .p-sm {
    padding: var(--space-sm);
  }

  .p-md {
    padding: var(--space-md);
  }

  .p-lg {
    padding: var(--space-lg);
  }

  /* Text */
  .text-center {
    text-align: center;
  }

  .text-left {
    text-align: left;
  }

  .text-right {
    text-align: right;
  }

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

  .text-secondary {
    color: var(--text-secondary);
  }

  .text-muted {
    color: var(--text-hint);
  }

  .text-success {
    color: var(--success);
  }

  .text-warning {
    color: var(--warning);
  }

  .text-error {
    color: var(--error);
  }

  .font-normal {
    font-weight: 400;
  }

  .font-medium {
    font-weight: 500;
  }

  .font-semibold {
    font-weight: 600;
  }

  .font-bold {
    font-weight: 700;
  }

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

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

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

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

  .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Display */
  .hidden {
    display: none !important;
  }

  .block {
    display: block;
  }

  .inline {
    display: inline;
  }

  .inline-block {
    display: inline-block;
  }

  /* Width/Height */
  .w-full {
    width: 100%;
  }

  .h-full {
    height: 100%;
  }

  /* Overflow */
  .overflow-hidden {
    overflow: hidden;
  }

  .overflow-auto {
    overflow: auto;
  }

  .overflow-y-auto {
    overflow-y: auto;
  }

  /* Position */
  .relative {
    position: relative;
  }

  .absolute {
    position: absolute;
  }

  .fixed {
    position: fixed;
  }

  .sticky {
    position: sticky;
  }

  /* Cursor */
  .cursor-pointer {
    cursor: pointer;
  }

  .cursor-not-allowed {
    cursor: not-allowed;
  }

  /* Border */
  .border {
    border: 1px solid var(--border-color);
  }

  .border-top {
    border-top: 1px solid var(--border-color);
  }

  .border-bottom {
    border-bottom: 1px solid var(--border-color);
  }

  .rounded {
    border-radius: var(--radius-md);
  }

  .rounded-lg {
    border-radius: var(--radius-lg);
  }

  .rounded-full {
    border-radius: var(--radius-full);
  }

  /* Shadow */
  .shadow-sm {
    box-shadow: var(--shadow-sm);
  }

  .shadow-md {
    box-shadow: var(--shadow-md);
  }

  .shadow-lg {
    box-shadow: var(--shadow-lg);
  }

  /* Background */
  .bg-white {
    background: var(--bg-primary);
  }

  .bg-gray {
    background: var(--bg-secondary);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   SCROLLBAR CUSTOM
   ═══════════════════════════════════════════════════════════════════════════════ */

  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--gray-100);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */

  .fade-in {
    animation: fadeIn 0.3s ease;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  .slide-up {
    animation: slideUp 0.3s ease;
  }

  @keyframes slideUp {
    from {
      transform: translateY(20px);
      opacity: 0;
    }

    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

  @media print {
    .no-print {
      display: none !important;
    }

    body {
      background: white;
    }

    .card {
      box-shadow: none;
      border: 1px solid var(--gray-300);
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
     TOP BAR STANDARD (legacy - mantenuto per retrocompatibilità)
   ═══════════════════════════════════════════════════════════════════════════════ */

  .top-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .top-bar-logo {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    background: #fff;
  }

  .top-bar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
  }

  .top-bar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
  }

  .top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .top-bar .user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
  }

  .top-bar .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
  }

  .top-bar .user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
  }

  .top-bar .top-btn {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
  }

  .top-bar .top-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
  }

  @media (max-width: 768px) {
    .top-bar {
      padding: 10px 16px;
    }

    .top-bar .user-name {
      display: none;
    }

    .top-bar-center {
      display: none;
    }
  }

  /* User badge condiviso (usato anche da .top-bar e legacy) */
  .user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
  }

  .user-badge .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
  }

  .user-badge .user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   APP HEADER - Barra superiore UNICA per tutta l'applicazione
   ═══════════════════════════════════════════════════════════════════════════════ */

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

  .app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .app-header-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
  }

  .app-header-logo img {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    background: #fff;
  }

  .app-header-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: #3b82f6;
    /* Azzurro fisso come richiesto */
    letter-spacing: 0.5px;
  }

  .app-header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
  }

  .app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .app-header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
    padding-right: 12px;
    border-right: 1px solid var(--border-color);
  }

  .app-header-btn {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .app-header-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    transform: translateY(-1px);
  }

  .app-header-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
  }

  .app-header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
  }

  .app-header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary, #3b82f6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
  }

  .app-header-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
  }

  /* App Toolbar - Barra secondaria (es: Pianificazione, KPI) */
  .app-toolbar {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    position: sticky;
    top: 56px;
    /* 56px = altezza navbar nav.js */
    z-index: 90;
  }

  .app-toolbar h1 {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
  }

  .app-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  /* Responsive */
  @media (max-width: 768px) {
    .app-header {
      padding: 10px 16px;
    }

    .app-header-center {
      display: none;
    }

    .app-header-username {
      display: none;
    }

    .app-header-nav {
      gap: 2px;
      margin-right: 4px;
      padding-right: 8px;
    }

    .app-header-btn {
      padding: 6px 10px;
      font-size: 0.9rem;
    }

    .app-toolbar {
      padding: 0.5rem 1rem;
      flex-direction: column;
      align-items: flex-start;
    }

    .app-toolbar-controls {
      width: 100%;
      justify-content: flex-start;
    }
  }

  @media (max-width: 480px) {
    .app-header-nav {
      border-right: none;
      padding-right: 0;
    }

    .app-header-user {
      display: none;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   APP FOOTER - Barra inferiore comune a tutte le pagine
   ═══════════════════════════════════════════════════════════════════════════════ */

  .app-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-secondary);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
  }

  .app-footer .footer-separator {
    color: var(--border-color);
  }

  .app-footer .footer-version {
    font-weight: 600;
    color: var(--primary);
  }

  .app-footer .footer-env {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 600;
  }

  .app-footer .footer-env.development {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
  }

  .app-footer .footer-env.production {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
  }

  .app-footer .footer-author {
    color: var(--text-hint);
  }

  .app-footer a {
    color: var(--primary);
    text-decoration: none;
  }

  .app-footer a:hover {
    text-decoration: underline;
  }

  /* Spazio per il footer fisso */
  .has-footer {
    padding-bottom: 50px;
  }

  @media (max-width: 768px) {
    .app-footer {
      padding: 10px 16px;
      font-size: 0.65rem;
    }

    .app-footer .footer-author {
      display: none;
    }
  }

  @media (max-width: 480px) {

    .app-footer .footer-separator:last-of-type,
    .app-footer .footer-env {
      display: none;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   SEZIONI COLLAPSIBILI - Mobile First Form
   ═══════════════════════════════════════════════════════════════════════════════ */

  .section-collapsible {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-normal);
  }

  .section-collapsible.section-highlight {
    box-shadow: 0 0 0 2px var(--primary), var(--shadow-md);
  }

  .section-header-collapsible {
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
    border-bottom: 1px solid transparent;
  }

  .section-header-collapsible:hover {
    background: var(--gray-50);
  }

  .section-header-collapsible:active {
    background: var(--gray-100);
  }

  .section-collapsible.expanded .section-header-collapsible {
    border-bottom-color: var(--border-light);
  }

  /* Icona sezione con indicatore stato */
  .section-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
    flex-shrink: 0;
  }

  /* Stati indicatore sezione */
  .section-icon.empty {
    background: var(--gray-100);
    color: var(--gray-400);
  }

  .section-icon.filled {
    color: white;
  }

  .section-icon.filled.color-blue {
    background: var(--primary);
  }

  .section-icon.filled.color-green {
    background: var(--success);
  }

  .section-icon.filled.color-orange {
    background: var(--warning);
  }

  .section-icon.filled.color-purple {
    background: #9c27b0;
  }

  .section-icon.filled.color-red {
    background: var(--error);
  }

  .section-icon.filled.color-cyan {
    background: #00bcd4;
  }

  .section-icon.filled.color-pink {
    background: #e91e63;
  }

  .section-icon.filled.color-teal {
    background: #009688;
  }

  .section-title {
    flex: 1;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
  }

  .section-badge {
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 500;
  }

  .section-badge.has-content {
    background: var(--success-bg);
    color: var(--success);
  }

  .section-badge.required {
    background: var(--error-bg);
    color: var(--error);
  }

  .section-toggle {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
  }

  .section-collapsible.expanded .section-toggle {
    transform: rotate(180deg);
  }

  /* Corpo sezione collapsibile */
  .section-body-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal) ease-out;
  }

  .section-collapsible.expanded .section-body-collapsible {
    max-height: 5000px;
    overflow: visible;
    transition: max-height var(--transition-slow) ease-in;
  }

  .section-content {
    padding: var(--space-lg);
  }

  /* Validazione visiva sezione */
  .section-collapsible.has-error .section-header-collapsible {
    background: var(--error-bg);
  }

  .section-collapsible.has-error .section-icon {
    background: var(--error);
    color: white;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   TAB BAR MOBILE - Barra navigazione fissa in basso
   ═══════════════════════════════════════════════════════════════════════════════ */

  .tab-bar-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: var(--z-fixed);
    padding: 0 var(--space-xs);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }

  .tab-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-xs);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    min-width: 0;
    text-decoration: none;
  }

  .tab-bar-item:hover {
    color: var(--text-primary);
    background: var(--gray-50);
  }

  .tab-bar-item.active {
    color: var(--primary);
  }

  .tab-bar-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
    position: relative;
  }

  /* Indicatore stato nella tab bar */
  .tab-bar-item.filled .tab-bar-icon {
    background: var(--primary-bg);
  }

  .tab-bar-item.filled.color-blue .tab-bar-icon {
    background: rgba(25, 118, 210, 0.15);
    color: var(--primary);
  }

  .tab-bar-item.filled.color-green .tab-bar-icon {
    background: rgba(56, 142, 60, 0.15);
    color: var(--success);
  }

  .tab-bar-item.filled.color-orange .tab-bar-icon {
    background: rgba(245, 124, 0, 0.15);
    color: var(--warning);
  }

  .tab-bar-item.filled.color-purple .tab-bar-icon {
    background: rgba(156, 39, 176, 0.15);
    color: #9c27b0;
  }

  .tab-bar-item.filled.color-red .tab-bar-icon {
    background: rgba(211, 47, 47, 0.15);
    color: var(--error);
  }

  .tab-bar-item.filled.color-cyan .tab-bar-icon {
    background: rgba(0, 188, 212, 0.15);
    color: #00bcd4;
  }

  .tab-bar-item.filled.color-pink .tab-bar-icon {
    background: rgba(233, 30, 99, 0.15);
    color: #e91e63;
  }

  /* Dot indicator per contenuto */
  .tab-bar-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg-primary);
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
  }

  .tab-bar-item.filled .tab-bar-dot {
    opacity: 1;
    transform: scale(1);
  }

  .tab-bar-label {
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* Pulsante salva speciale */
  .tab-bar-item.save-btn {
    background: var(--primary);
    color: white;
    border-radius: var(--radius-md);
    margin: var(--space-xs);
    flex: 0 0 auto;
    min-width: 56px;
  }

  .tab-bar-item.save-btn:hover {
    background: var(--primary-dark);
  }

  .tab-bar-item.save-btn .tab-bar-icon {
    background: transparent;
  }

  /* Menu overflow per altre sezioni */
  .tab-bar-more {
    position: relative;
  }

  .tab-bar-more-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    margin-bottom: var(--space-sm);
  }

  .tab-bar-more-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .tab-bar-more-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-size: var(--text-sm);
  }

  .tab-bar-more-item:hover {
    background: var(--gray-50);
  }

  .tab-bar-more-item .section-icon {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  /* Spazio per la tab bar nel contenuto */
  .has-tab-bar {
    padding-bottom: 80px;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   FORM PAGE MOBILE - Layout ottimizzato per smartphone
   ═══════════════════════════════════════════════════════════════════════════════ */

  .form-page-mobile {
    min-height: 100vh;
    background: var(--bg-secondary);
  }

  .form-page-mobile .form-header-mobile {
    background: var(--bg-primary);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
  }

  .form-page-mobile .form-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
  }

  .form-page-mobile .form-header-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
  }

  .form-page-mobile .form-header-title h1 {
    font-size: var(--text-lg);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .form-page-mobile .form-content {
    padding: var(--space-md);
    max-width: 900px;
    margin: 0 auto;
  }

  /* Responsive breakpoints */
  @media (max-width: 768px) {
    .tab-bar-mobile {
      height: 56px;
    }

    .tab-bar-icon {
      width: 24px;
      height: 24px;
      font-size: 1rem;
    }

    .tab-bar-label {
      font-size: 9px;
    }

    .tab-bar-item.save-btn {
      min-width: 48px;
    }

    .section-header-collapsible {
      padding: var(--space-sm) var(--space-md);
    }

    .section-icon {
      width: 28px;
      height: 28px;
      font-size: 0.9rem;
    }

    .section-title {
      font-size: var(--text-sm);
    }

    .section-content {
      padding: var(--space-md);
    }

    .form-page-mobile .form-content {
      padding: var(--space-sm);
    }
  }

  @media (max-width: 480px) {
    .tab-bar-label {
      display: none;
    }

    .tab-bar-item {
      padding: var(--space-sm);
    }

    .tab-bar-icon {
      width: 32px;
      height: 32px;
      font-size: 1.2rem;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   CANVAS FIRMA - Stili per firma digitale
   ═══════════════════════════════════════════════════════════════════════════════ */

  .signature-container {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    background: var(--gray-50);
    transition: border-color var(--transition-fast);
  }

  .signature-container:hover {
    border-color: var(--gray-400);
  }

  .signature-container.has-signature {
    border-style: solid;
    border-color: var(--success);
    background: var(--success-bg);
  }

  .signature-canvas {
    width: 100%;
    height: 150px;
    background: white;
    border-radius: var(--radius-sm);
    cursor: crosshair;
    touch-action: none;
  }

  .signature-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    display: block;
  }

  .signature-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    justify-content: flex-end;
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   CHECKBOX GROUP - Griglia checkbox per tipi intervento/collaudo
   ═══════════════════════════════════════════════════════════════════════════════ */

  .checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-sm);
  }

  .checkbox-card {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .checkbox-card:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
  }

  .checkbox-card.checked {
    background: var(--primary-bg);
    border-color: var(--primary);
  }

  .checkbox-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
  }

  .checkbox-card-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   DATE ORARI ROW - Riga per inserimento data/orari tempo impiegato
   ═══════════════════════════════════════════════════════════════════════════════ */

  .date-orari-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr auto;
    gap: var(--space-sm);
    align-items: end;
    padding: var(--space-sm);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
  }

  .date-orari-row .form-group {
    margin-bottom: 0;
  }

  .date-orari-row .form-label {
    font-size: var(--text-xs);
    margin-bottom: 2px;
  }

  .date-orari-row .btn-remove {
    margin-bottom: 4px;
  }

  @media (max-width: 768px) {
    .date-orari-row {
      grid-template-columns: 1fr 1fr;
      gap: var(--space-xs);
    }

    .date-orari-row .btn-remove {
      grid-column: span 2;
      justify-self: end;
    }
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   VALIDAZIONE REAL-TIME - Feedback visivo campi
   ═══════════════════════════════════════════════════════════════════════════════ */

  .form-control.validating {
    border-color: var(--info);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' stroke='%230288d1' stroke-width='2' fill='none' stroke-dasharray='30' stroke-dashoffset='0'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='1s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
  }

  .form-control.field-valid {
    border-color: var(--success);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23388e3c' stroke-width='2'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
  }

  .form-control.field-invalid {
    border-color: var(--error);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23d32f2f' stroke-width='2'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
  }

  .validation-message {
    font-size: var(--text-xs);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  .validation-message.error {
    color: var(--error);
  }

  .validation-message.warning {
    color: var(--warning);
  }

  .validation-message.success {
    color: var(--success);
  }

  /* ═══════════════════════════════════════════════════════════════════════════════
   UTILITY RESPONSIVE GLOBALI
   ═══════════════════════════════════════════════════════════════════════════════ */

  /* Tabelle scrollabili su mobile */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Touch-friendly: area tap minima per mobile */
  @media (max-width: 768px) {

    .btn,
    button,
    a.btn {
      min-height: 44px;
      min-width: 44px;
    }

    input,
    select,
    textarea {
      font-size: 16px !important;
      /* Previene zoom su iOS */
    }

    /* Card e sezioni: meno padding su mobile */
    .card-body,
    .section-body {
      padding: var(--space-md);
    }

    /* Modali fullscreen su mobile */
    .modal-backdrop .modal {
      width: 95vw !important;
      max-height: 90vh;
      margin: 5vh auto;
    }

    /* Toast: larghezza piena su mobile */
    .toast-container {
      left: var(--space-sm);
      right: var(--space-sm);
    }
  }

  @media (max-width: 480px) {

    /* Stack orizzontale → verticale su small */
    .flex-row-mobile {
      flex-direction: column !important;
    }

    /* Nasconde elementi non essenziali su small */
    .hide-small {
      display: none !important;
    }
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }

  /* Accessibilità: focus visibile per navigazione da tastiera */
  *:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }

  /* Selezione testo */
  ::selection {
    background: var(--primary-bg);
    color: var(--text-primary);
  }

  /* Scrollbar personalizzata (WebKit) - definita sopra in SCROLLBAR CUSTOM */