/* Custom Styling Overrides per Rivaluta.it - Stile Premium WebApp */
    :root {
      --primary: #10b981;
      --primary-dark: #059669;
      --secondary: #0f172a;
      --background: #f8fafc;
      --text-main: #334155;
      --text-muted: #64748b;
      --card-bg: #ffffff;
      --border-color: #e2e8f0;
    }

    body {
      background-color: var(--background) !important;
      font-family: 'Inter', sans-serif !important;
      color: var(--text-main);
    }

    h1, h2, h3, h4, h5 {
      font-family: 'Poppins', sans-serif !important;
      color: var(--secondary);
      font-weight: 700;
    }

    h1 {
      font-size: 2.5rem;
      line-height: 1.2;
      border-left: 6px solid var(--primary);
      padding-left: 1rem;
      margin-bottom: 2rem;
    }

    h2 {
      font-size: 1.75rem;
      margin-bottom: 1.25rem;
    }

    p {
      line-height: 1.6;
      font-size: 1.05rem;
    }

    /* Stile della card contenitrice principale */
    .app-card {
      background: var(--card-bg);
      border: 1px solid var(--border-color);
      border-radius: 16px;
      box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
      padding: 2.5rem;
      margin-bottom: 2.5rem;
    }

    /* Formula Box stile calcolatore */
    .formula-display {
      background: #f1f5f9;
      border-radius: 12px;
      padding: 1.25rem;
      border-left: 4px solid var(--primary);
      font-family: 'Courier New', Courier, monospace;
      font-size: 1.15rem;
      font-weight: 700;
      color: var(--secondary);
      margin: 1.5rem 0;
    }

    /* Esempio dinamico in evidenza */
    .example-alert-box {
      background: #f0fdf4;
      border: 1px solid #bbf7d0;
      border-radius: 12px;
      padding: 1.5rem;
      margin-bottom: 2rem;
    }

    /* Form Fields modernizzati */
    .modern-input {
      border-radius: 10px !important;
      padding: 0.75rem 1rem !important;
      border: 2px solid var(--border-color) !important;
      font-weight: 500;
      font-size: 1.05rem !important;
      transition: all 0.2s ease-in-out !important;
    }

    .modern-input:focus {
      border-color: var(--primary) !important;
      box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15) !important;
      outline: none !important;
    }

    .input-group-text {
      border-radius: 0 10px 10px 0 !important;
      border: 2px solid var(--border-color) !important;
      border-left: none !important;
      background-color: #f1f5f9 !important;
      font-weight: 600;
    }

    /* Pulsante principale - Riscritto per prevenire tagli su Mobile */
    .btn-emerald {
      background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
      color: white !important;
      font-weight: 600;
      border-radius: 10px;
      padding: 0.75rem 1.5rem;
      border: none;
      transition: all 0.2s ease;
      font-size: 1.05rem;
      white-space: normal !important; /* Forza l'andata a capo intelligente invece di tagliare il testo */
      line-height: 1.3;               /* Ottimizza l'altezza di riga in modalità multi-riga */
      word-wrap: break-word;          /* Spezza le parole se superano il contenitore */
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .btn-emerald:hover {
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
      transform: translateY(-1px);
    }

    .btn-emerald:active {
      transform: translateY(1px);
    }

    /* Tabella riepilogo moderna */
    .table-modern {
      border-collapse: separate;
      border-spacing: 0;
      width: 100%;
      border: 1px solid var(--border-color);
      border-radius: 12px;
      overflow: hidden;
      margin: 1.5rem 0;
    }

    .table-modern th {
      background-color: var(--secondary) !important;
      color: #ffffff !important;
      font-weight: 600;
      padding: 1rem;
      border: none;
    }

    .table-modern td {
      padding: 1rem;
      background: #ffffff;
      border-bottom: 1px solid var(--border-color);
      font-size: 1.05rem;
    }

    .table-modern tr:last-child td {
      border-bottom: none;
    }

    /* Lista ordinata custom */
    .step-list {
      padding-left: 1.5rem;
    }

    .step-list li {
      margin-bottom: 0.75rem;
      font-size: 1.05rem;
    }

    /* Griglia delle risorse correlate per una UX eccellente */
    .resource-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 1.25rem;
      margin-top: 1.5rem;
    }

    .resource-card {
      background: var(--card-bg);
      border: 1px solid var(--border-color);
      border-radius: 12px;
      padding: 1.25rem;
      text-decoration: none !important;
      transition: all 0.2s ease;
      display: flex;
      flex-direction: column;
      height: 100%;
    }

    .resource-card:hover {
      border-color: var(--primary);
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.08);
      transform: translateY(-2px);
    }

    .resource-card h4 {
      font-size: 1.1rem;
      margin-bottom: 0.5rem;
      color: var(--secondary);
    }

    .resource-card p {
      font-size: 0.95rem;
      color: var(--text-muted);
      margin-bottom: 0;
    }

    /* Pill badge per tabella risultati */
    .badge-pill {
      display: inline-block;
      padding: 6px 16px;
      font-size: 0.8rem;
      font-weight: 700;
      border-radius: 20px;
      text-transform: uppercase;
      text-align: center;
    }

    .badge-aumento {
      background-color: #d1fae5;
      color: #065f46;
    }

    .badge-diminuzione {
      background-color: #fee2e2;
      color: #991b1b;
    }

    .calc-history-card {
      scroll-margin-top: 1rem;
    }

    .history-toolbar,
    .history-actions {
      display: inline-flex;
      gap: 0.5rem;
      justify-content: center;
      white-space: nowrap;
    }

    .history-icon-btn {
      align-items: center;
      background: #ffffff;
      border: 1px solid var(--border-color);
      border-radius: 10px;
      color: var(--secondary);
      display: inline-flex;
      height: 40px;
      justify-content: center;
      padding: 0;
      transition: all 0.18s ease;
      width: 40px;
    }

    .history-icon-btn:hover,
    .history-icon-btn:focus {
      border-color: var(--primary);
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.12);
      color: var(--primary-dark);
      outline: none;
      transform: translateY(-1px);
    }

    .history-icon-btn.danger:hover,
    .history-icon-btn.danger:focus {
      border-color: #fecaca;
      box-shadow: 0 4px 12px rgba(220, 38, 38, 0.12);
      color: #b91c1c;
    }

    .history-empty {
      background: #f8fafc;
      border: 1px dashed var(--border-color);
      border-radius: 12px;
      color: var(--text-muted);
      font-weight: 600;
      padding: 1rem;
      text-align: center;
    }

    .history-table td,
    .history-table th {
      vertical-align: middle;
    }

    .history-result-badge {
      border-radius: 999px;
      display: inline-flex;
      font-size: 0.75rem;
      font-weight: 800;
      letter-spacing: 0.02em;
      padding: 0.35rem 0.65rem;
      text-transform: uppercase;
    }

    .history-result-badge.up {
      background: #d1fae5;
      color: #065f46;
    }

    .history-result-badge.down {
      background: #fee2e2;
      color: #991b1b;
    }

    .history-result-badge.flat {
      background: #dbeafe;
      color: #1d4ed8;
    }

    /* --- ADATTAMENTO STRUTTURALE MOBILE (Media Queries) --- */
    @media (max-width: 576px) {
      h1 {
        font-size: 1.75rem !important;
        padding-left: 0.75rem !important;
        margin-bottom: 1.5rem !important;
        border-left-width: 5px !important;
      }
      h2 {
        font-size: 1.4rem !important;
        margin-bottom: 1rem !important;
      }
      p {
        font-size: 1rem !important;
      }
      .app-card {
        padding: 1.25rem !important;
        margin-bottom: 1.5rem !important;
        border-radius: 12px !important;
      }
      .btn-emerald {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
      }
      .formula-display {
        font-size: 1rem !important;
        padding: 1rem !important;
      }
      .example-alert-box {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
      }
      .history-toolbar {
        justify-content: flex-start;
      }
      .history-icon-btn {
        height: 38px;
        width: 38px;
      }
    }
