      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      :root {
        --primary: #4CAFA0;
        --primary-dark: #3d9e90;
        --primary-light: #7ecdc0;
        --primary-gradient: linear-gradient(135deg, #7ecdc0 0%, #4CAFA0 100%);
        --success: #10b981;
        --warning: #f4a261;
        --danger: #e76f7a;
        --gray: #999;
        --light-gray: #eee;
        --bg: linear-gradient(135deg, #54B4A5 0%, #eaeafc 80%);
        --card-bg: #ffffff;
        --text-primary: #1F2937;
        --text-secondary: #6B7280;
        --text-muted: #6B7280;
        --border-color: #eee;
        --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
        --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);
        --section-title-color: #3A8C80;
        --btn-active: #3A8C80;
        --macro-carbs: #F4A261;
        --macro-protein: #4CAFA0;
        --macro-fats: #E76F51;
        --macro-alcohol: #8B5E83;
        --macro-alcohol-dark: #6F4768;
        --app-footer-height: 50px;
        --app-mobile-nav-offset: 0px;
      }
      html {
        height: 100%;
        overflow: hidden;
      }
      body {
        font-family: 'Inter', system-ui, -apple-system, sans-serif;
        background: var(--bg);
        background-attachment: fixed;
        color: var(--text-primary);
        line-height: 1.5;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }
      /* ==========================================
        HEADER - Clean Minimal Style
        ========================================== */
      .header {
        background: white;
        color: var(--text-primary);
        padding: 0.5rem 1rem;
        position: sticky;
        top: 0;
        z-index: 9999;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
      }

      /* Logo Section (sinistra) */
      .header-logo-section {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
      }

      .header-symbol-svg {
        width: 32px;
        height: 36px;
        display: block;
      }

      /* Logo testo (centro) */
      .header-logo-center {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 6px;
      }

      .header-text-svg {
        height: 25px;
        width: auto;
        display: block;
      }

      /* Header Actions (destra) */
      .header-actions {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
      }

      .btn-header-profile {
        all: unset;
        cursor: pointer;
        width: 45px;
        height: 45px;
        border-radius: 50%;
        background: white;
        border: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        transition: background 0.2s ease, border-color 0.2s ease;
      }

      .btn-header-profile:hover {
        background: #f0f0f0;
        border-color: #ddd;
      }

      .btn-header-profile:active {
        background: #e8e8e8;
      }

      .btn-logo {
        all: unset;
        display: flex;
        align-items: center;
        cursor: pointer;
      }

      /* Bottone "Chiedi a Yumii" */
      .btn-ask-yumii {
        all: unset;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 999px;
        padding: 6px 14px 6px 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.08);
        white-space: nowrap;
        transition: box-shadow 0.2s ease, border-color 0.2s ease;
      }

      .btn-ask-yumii:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.13);
        border-color: #c8c8c8;
      }

      .btn-ask-yumii:active {
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      }

      .btn-ask-yumii img {
        width: 26px;
        height: 29px;
        display: block;
        flex-shrink: 0;
      }

      .btn-ask-yumii .ask-yumii-label {
        font-size: 0.875rem;
        font-weight: 400;
        color: #444;
        line-height: 1;
      }

      .ask-yumii-brand {
        font-weight: 700;
        color: #1F2937;
      }

      .ask-yumii-br { display: none; }
      .ask-yumii-wrap { position: relative; display: flex; align-items: center; }
      .ask-yumii-popup { display: none; }

      /* Desktop: label sempre visibile, una riga */
      @media (min-width: 768px) {
        .ask-yumii-popup { display: none !important; }
      }

      /* Mobile: nascondi label nel bottone, mostra popup al click */
      @media (max-width: 767px) {
        .btn-ask-yumii { padding: 6px 8px; }
        .btn-ask-yumii .ask-yumii-label { display: none; }
        .ask-yumii-popup {
          position: absolute;
          left: calc(100% + 6px);
          top: 50%;
          transform: translateY(-50%);
          background: white;
          border: 1px solid #e0e0e0;
          border-radius: 12px;
          padding: 8px 14px;
          box-shadow: 0 2px 8px rgba(0,0,0,0.12);
          white-space: nowrap;
          font-family: inherit;
          font-size: 0.75rem;
          font-weight: 400;
          color: #444;
          cursor: pointer;
          z-index: 10;
          line-height: 1.3;
        }
        .ask-yumii-popup .ask-yumii-br { display: block; }
        .ask-yumii-popup.show { display: block; }
      }

      /* ==========================================
        CALENDAR - Modern Grid Design
        ========================================== */

      .cal-nav-arrow {
        display: none;
      }

      .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 0.75rem;
        padding: 1rem 0;
      }

      .calendar-day-header {
        text-align: center;
        font-weight: 600;
        font-size: 0.875rem;
        color: var(--primary);
        padding: 0.75rem 0.5rem;
        background: rgba(76, 175, 160, 0.06);
        border-radius: 8px;
        letter-spacing: 0.5px;
      }

      .calendar-day {
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 0.75rem 0.5rem;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;
        min-height: 100px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }

      .calendar-day:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow);
      }

      .calendar-day.has-meals {
        border-color: var(--primary);
        background: #f8fcfb;
      }

      .calendar-day.empty {
        opacity: 0.3;
        cursor: pointer;
      }

      .calendar-day.empty:hover {
        opacity: 0.6;
        transform: translateY(-2px);
      }

      .calendar-day-number {
        font-weight: 700;
        font-size: 1.125rem;
        color: #2d3748;
        margin-bottom: 0.5rem;
      }

      .calendar-day.has-meals .calendar-day-number {
        color: #4CAFA0;
      }

      .calendar-day.today {
        border-color: #4CAFA0;
        box-shadow: 0 0 0 2px rgba(76, 175, 160, 0.3);
      }

      .calendar-day.today .calendar-day-number {
        background: #4CAFA0;
        color: white;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
      }

      .calendar-day-calories {
        font-size: 0.8125rem;
        font-weight: 600;
        color: #4a5568;
        margin: 0.25rem 0;
      }

      .calendar-day-status {
        font-size: 0.6875rem;
        font-weight: 600;
        line-height: 1.4;
        margin-top: 0.25rem;
      }

      .calendar-day-status .macro-protein { color: var(--macro-protein); }
      .calendar-day-status .macro-carbs { color: var(--macro-carbs) }
      .calendar-day-status .macro-fats { color: var(--macro-fats); }

      /* Status Badge (in alto a destra) */
      .calendar-status-badge {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      }

      .calendar-status-badge.good {
        background: #10b981;
      }

      .calendar-status-badge.warning {
        background: #f4a261;
      }

      .calendar-status-badge.bad {
        background: #e76f7a;
      }

      /* Mobile Calendar - Ottimizzato */
      @media (max-width: 768px) {
        /* Container card calendario */
        #calendarView .card {
          padding: 0.75rem 0.5rem !important;
        }

        /* Header con bottoni frecce */
        #calendarView .card > div:first-child {
          display: flex !important;
          align-items: center !important;
          justify-content: space-between !important;
          gap: 0.5rem !important;
          margin-bottom: 0.75rem !important;
        }

        /* Bottoni frecce — solo icona su mobile */
        .cal-nav-btn {
          width: 36px !important;
          height: 36px !important;
          min-width: 36px !important;
          padding: 0 !important;
          border-radius: 10px !important;
          display: inline-flex !important;
          align-items: center !important;
          justify-content: center !important;
        }

        .cal-nav-label {
          display: none !important;
        }

        .cal-nav-arrow {
          display: inline !important;
          font-size: 1.125rem !important;
          line-height: 1 !important;
        }

        /* Titolo mese centrato */
        #calendarView h2#calendarTitle {
          flex: 1 !important;
          text-align: center !important;
          margin: 0 !important;
          font-size: 1.0625rem !important;
          font-weight: 700 !important;
        }

        /* Grid calendario */
        .calendar-grid {
          gap: 3px !important;
          padding: 0.25rem 0 !important;
          width: 100% !important;
        }

        /* Headers giorni */
        .calendar-day-header {
          font-size: 0.625rem !important;
          padding: 0.3rem 0 !important;
          min-width: 0 !important;
        }

        /* Card giorni */
        .calendar-day {
          min-height: 52px !important;
          padding: 4px 2px !important;
          min-width: 0 !important;
          border-radius: 8px !important;
        }

        .calendar-day-number {
          font-size: 0.8125rem !important;
          margin-bottom: 2px !important;
        }

        .calendar-day.today .calendar-day-number {
          width: 22px !important;
          height: 22px !important;
          font-size: 0.6875rem !important;
        }

        .calendar-day-calories {
          font-size: 0.5625rem !important;
          margin: 1px 0 !important;
          line-height: 1.1 !important;
        }

        /* Nasconde i dettagli macro su mobile — mostra solo calorie */
        .calendar-day-status {
          display: none !important;
        }

        /* Status badge più piccolo */
        .calendar-status-badge {
          width: 14px !important;
          height: 14px !important;
          font-size: 0.5rem !important;
          top: 2px !important;
          right: 2px !important;
        }
      }

      /* Mobile Responsive */
      @media (max-width: 768px) {
        .header {
          padding: 0.75rem 1rem;
        }

        .header-symbol-svg {
          width: 28px;
          height: 32px;
        }

        .btn-ask-yumii {
          padding: 5px 7px 5px 7px;
        }
      }

      .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 1rem;
      }

      /* ==========================================
        UPLOAD & FEATURE BUTTONS - Appealing Design
        ========================================== */

      /* Upload Photo Area */
      .upload-photo-area {
        border: 2px dashed #ddd;
        border-radius: 16px;
        padding: 2.5rem 2rem;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s ease;
        background: white;
      }

      .upload-photo-area:hover {
        border-color: var(--primary);
        background: rgba(76, 175, 160, 0.03);
      }

      .upload-icon {
        font-size: 3rem;
        margin-bottom: 1rem;
        display: flex;
        justify-content: center;
      }

      .upload-text {
        font-size: 1.125rem;
        font-weight: 600;
        color: #2d3748;
        margin-bottom: 0.5rem;
      }

      .upload-subtext {
        font-size: 0.875rem;
        color: #718096;
      }

      /* Feature Buttons (Barcode, I Miei Prodotti, etc.) */
      .feature-button {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.25rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 16px;
        cursor: pointer;
        transition: all 0.2s ease;
        margin: 0.75rem 0;
        text-align: left;
      }

      .feature-button:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow);
      }

      .feature-button-icon {
        font-size: 2rem;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(76, 175, 160, 0.1);
        border-radius: 12px;
        flex-shrink: 0;
      }

      .feature-button-content {
        flex: 1;
      }

      .feature-button-title {
        font-size: 1.0625rem;
        font-weight: 700;
        color: #2d3748;
        margin-bottom: 0.25rem;
      }

      .feature-button-subtitle {
        font-size: 0.875rem;
        color: #718096;
        font-weight: 500;
      }

      .feature-button-arrow {
        font-size: 1.5rem;
        color: #cbd5e0;
        transition: all 0.3s ease;
        flex-shrink: 0;
      }

      .feature-button:hover .feature-button-arrow {
        color: var(--primary);
      }

      /* Mobile Responsive */
      @media (max-width: 768px) {
        .upload-photo-area {
          padding: 2rem 1rem;
        }

        .upload-icon {
          font-size: 3rem;
        }

        .feature-button {
          padding: 1rem 1.25rem;
        }

        .feature-button-icon {
          font-size: 2rem;
          width: 50px;
          height: 50px;
        }

        .feature-button-title {
          font-size: 1rem;
        }

        .feature-button-subtitle {
          font-size: 0.8125rem;
        }
      }

      /* ==========================================
        CARDS & LAYOUTS - Modern Design
        ========================================== */

      /* Base Card Style */
      .card {
        background: white;
        border-radius: 20px;
        padding: 1.5rem;
        margin-bottom: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
        transition: box-shadow 0.2s ease;
      }

      .card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
      }

      .card-title {
        font-size: 1.125rem;
        font-weight: 600;
        margin-bottom: 1rem;
        text-align: center;
      }

      /* Daily Summary Card */
      .daily-summary {
        background: white;
      }

      /* Macros Grid */
      .macros-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 1rem;
      }

      /* Individual Macro Cards */
      .macro-card {
        text-align: center;
        padding: 1rem;
        background: white;
        border-radius: 12px;
        border: 1px solid var(--border-color);
      }

      .macro-value {
        font-size: 1.75rem;
        font-weight: 700;
        margin: 0.5rem 0;
        color: var(--primary);
      }

      /* Progress Bars */
      .progress-bar {
        width: 100%;
        height: 8px;
        background: #e8e8e8;
        border-radius: 8px;
        overflow: hidden;
        margin-top: 0.75rem;
      }

      .progress-fill {
        height: 100%;
        border-radius: 8px;
        transition: width 0.5s ease;
      }

      .progress-fill.success {
        background: var(--primary);
      }

      .progress-fill.warning {
        background: var(--warning);
      }

      .progress-fill.danger {
        background: var(--danger);
      }

      /* ==========================================
        MEAL CARDS - Final Polish
        ========================================== */

      /* Meal Card Emoji */
      .meal-card .meal-card-header span[style*="font-size: 1.5rem"] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(76, 175, 160, 0.08);
        border-radius: 10px;
      }

      /* Meal Time & Date Styling */
      .meal-card .text-gray {
        font-weight: 500;
        color: var(--text-muted);
      }

      /* Calorie Badge */
      .meal-card-header > div:last-child > div:last-child {
        padding: 0.375rem 0.75rem;
        background: rgba(76, 175, 160, 0.08);
        border-radius: 8px;
        font-weight: 600;
        font-size: 0.875rem;
        color: var(--primary);
      }

      /* Empty State Styling */
      .meals-list .text-center.text-gray {
        padding: 3rem 1rem;
        background: #fafafa;
        border-radius: 12px;
        border: 1px dashed #ddd;
        font-size: 0.9375rem;
        font-weight: 500;
        color: var(--text-muted);
      }

      /* Meal Card Loading State */
      .meal-card.loading {
        pointer-events: none;
        opacity: 0.6;
      }

      /* Mobile Meal Cards */
      @media (max-width: 768px) {
        .meal-card {
          padding: 1rem;
        }

        .meal-card .meal-card-header span[style*="font-size: 1.5rem"] {
          width: 40px;
          height: 40px;
          font-size: 1.25rem !important;
        }

        .meal-card-header {
          flex-direction: column;
          gap: 0.75rem;
          align-items: flex-start !important;
        }

        .meal-card-header > div {
          width: 100%;
        }

        .meal-card-header > div:last-child {
          justify-content: space-between !important;
        }
      }

      .meal-card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
      }

      .meal-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.75rem;
      }

      /* Macros Display in Cards */
      .macros-display {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        margin: 0.75rem 0;
      }

      .macro-item {
        font-weight: 600;
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
        background: rgba(76, 175, 160, 0.08);
        border-radius: 6px;
        transition: all 0.2s ease;
      }

      .macro-item:hover {
        background: rgba(76, 175, 160, 0.15);
        transform: scale(1.05);
      }

      /* Mobile Responsive */
      @media (max-width: 768px) {
        .card {
          padding: 1.25rem;
          border-radius: 12px;
        }

        .macros-grid {
          grid-template-columns: 1fr;
          gap: 0.75rem;
        }

        .macro-card {
          padding: 1rem;
        }

        .macro-value {
          font-size: 1.75rem;
        }

        .meal-card {
          padding: 1rem;
        }

        .meal-card:hover {
          transform: translateX(4px);
        }
      }

      /* ==========================================
        FORMS & INPUTS - Modern Design
        ========================================== */

      /* Form Group Container */
      .form-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1.25rem;
        position: relative;
      }

      /* Form Labels — allineate allo stile profile-section-title */
      .form-label {
        font-weight: 600;
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        transition: color 0.2s ease;
        display: flex;
        align-items: center;
        gap: 0.25rem;
      }

      .form-sub-label {
        font-size: 12px;
        color: var(--text-muted);      
        transition: color 0.2s ease;
        align-items: center;
        gap: 0.25rem;
        background: rgba(76, 175, 160, 0.08);
        border-radius: 10px;
        padding: 0.55rem 0.875rem;
        margin-bottom: 10px;
      }

      .form-group:focus-within .form-label {
        color: var(--primary);
      }

      /* Base Input Styles — leggermente ridotti */
      .form-input,
      .form-select,
      .form-textarea {
        width: 100%;
        padding: 0.55rem 0.875rem;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        font-size: 0.9rem;
        font-family: inherit;
        color: var(--text-primary);
        background: white;
        transition: border-color 0.2s ease;
      }

      /* Focus States */
      .form-input:focus,
      .form-select:focus,
      .form-textarea:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(76, 175, 160, 0.1);
      }

      /* Focus - Label Color Change */
      .form-group:focus-within .form-label {
        color: var(--primary);
      }

      /* Textarea Specific */
      .form-textarea {
        resize: vertical;
        min-height: 100px;
        line-height: 1.6;
      }

      /* Placeholder Styling */
      .form-input::placeholder,
      .form-select::placeholder,
      .form-textarea::placeholder {
        color: #a0aec0;
        opacity: 1;
      }

      .form-input:focus::placeholder,
      .form-select:focus::placeholder,
      .form-textarea:focus::placeholder {
        opacity: 0.6;
      }

      /* Select Arrow Styling — freccia teal */
      .form-select {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235bb5a6' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.875rem center;
        background-size: 11px;
        padding-right: 2.5rem;
        cursor: pointer;
      }

      /* Custom dropdown per Obiettivo (wrap su due righe alla parentesi) */
      .custom-select { position: relative; width: 100%; }
      .custom-select > select.goal-select {
        position: absolute; inset: 0; width: 100%; height: 100%;
        opacity: 0; pointer-events: none; margin: 0;
      }
      .custom-select-trigger {
        width: 100%;
        padding: 0.75rem 2.5rem 0.75rem 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        font-size: 1rem;
        font-family: inherit;
        background: white;
        cursor: pointer;
        text-align: left;
        line-height: 1.25;
        min-height: 3.4rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: stretch;
        position: relative;
        color: #1f2937;
      }
      .custom-select-trigger::after {
        content: "";
        position: absolute;
        right: 0.875rem; top: 50%;
        width: 11px; height: 8px;
        transform: translateY(-50%);
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235bb5a6' d='M6 8L0 0h12z'/%3E%3C/svg%3E") no-repeat center / contain;
      }
      .custom-select.open .custom-select-trigger,
      .custom-select-trigger:focus {
        outline: none;
        border-color: #5bb5a6;
        box-shadow: 0 0 0 3px rgba(91, 181, 166, 0.12);
      }
      .custom-select-label-main { display: block; font-weight: 500; }
      .custom-select-label-sub { display: block; font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
      .custom-select-trigger > .custom-select-label-main,
      .custom-select-trigger > .custom-select-label-sub { flex: 0 0 100%; }
      .custom-select-options {
        position: absolute;
        top: calc(100% + 4px); left: 0; right: 0;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.08);
        z-index: 50;
        max-height: 320px;
        overflow-y: auto;
        display: none;
      }
      .custom-select.open .custom-select-options { display: block; }
      .custom-select-option {
        padding: 0.65rem 1rem;
        cursor: pointer;
        line-height: 1.3;
      }
      .custom-select-option + .custom-select-option { border-top: 1px solid #f3f4f6; }
      .custom-select-option:hover,
      .custom-select-option.selected { background: rgba(91, 181, 166, 0.08); }

      .form-select:focus {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%234aa396' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
      }

      /* Date and Time Inputs */
      input[type="date"],
      input[type="time"] {
        cursor: pointer;
      }

      input[type="date"]::-webkit-calendar-picker-indicator,
      input[type="time"]::-webkit-calendar-picker-indicator {
        cursor: pointer;
        filter: opacity(0.6);
        transition: filter 0.2s ease;
      }

      input[type="date"]:hover::-webkit-calendar-picker-indicator,
      input[type="time"]:hover::-webkit-calendar-picker-indicator {
        filter: opacity(1);
      }

      /* Number Input Arrows */
      input[type="number"]::-webkit-inner-spin-button,
      input[type="number"]::-webkit-outer-spin-button {
        opacity: 0.6;
        transition: opacity 0.2s ease;
      }

      input[type="number"]:hover::-webkit-inner-spin-button,
      input[type="number"]:hover::-webkit-outer-spin-button {
        opacity: 1;
      }

      /* Disabled State */
      .form-input:disabled,
      .form-select:disabled,
      .form-textarea:disabled {
        background: #f5f5f5;
        color: #a0aec0;
        cursor: not-allowed;
        border-color: #e2e8f0;
        box-shadow: none;
      }

      /* Error State - Shake Animation */
      .form-input.error,
      .form-select.error,
      .form-textarea.error {
        border-color: #ef4444;
        animation: shake 0.4s ease;
      }

      @keyframes shake {
        0%,
        100% {
          transform: translateX(0);
        }
        10%,
        30%,
        50%,
        70%,
        90% {
          transform: translateX(-5px);
        }
        20%,
        40%,
        60%,
        80% {
          transform: translateX(5px);
        }
      }

      .form-input.error:focus,
      .form-select.error:focus,
      .form-textarea.error:focus {
        box-shadow:
          0 0 0 3px rgba(245, 101, 101, 0.1),
          0 2px 8px rgba(245, 101, 101, 0.15);
      }

      /* Success State */
      .form-input.success,
      .form-select.success,
      .form-textarea.success {
        border-color: #10b981;
      }

      .form-input.success:focus,
      .form-select.success:focus,
      .form-textarea.success:focus {
        box-shadow:
          0 0 0 3px rgba(72, 187, 120, 0.1),
          0 2px 8px rgba(72, 187, 120, 0.15);
      }

      /* Input with Icon Support */
      .form-input-with-icon {
        position: relative;
      }

      .form-input-with-icon input {
        padding-left: 2.75rem;
      }

      .form-input-icon {
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        color: #a0aec0;
        font-size: 1.125rem;
        pointer-events: none;
        transition: color 0.2s ease;
      }

      .form-input-with-icon input:focus ~ .form-input-icon {
        color: #4CAFA0;
      }

      /* Helper Text */
      .form-helper-text {
        font-size: 0.8125rem;
        color: #718096;
        margin-top: 0.25rem;
      }

      .form-helper-text.error {
        color: #ef4444;
      }

      .form-helper-text.success {
        color: #10b981;
      }

      /* File Input Custom Styling */
      input[type="file"] {
        padding: 0.75rem;
      }

      input[type="file"]::file-selector-button {
        background: var(--primary);
        color: white;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 6px;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s ease;
        margin-right: 1rem;
      }

      input[type="file"]::file-selector-button:hover {
        background: var(--primary-dark);
      }

      /* Mobile Responsive */
      @media (max-width: 768px) {
        .form-input,
        .form-select,
        .form-textarea {
          padding: 0.75rem 0.875rem;
          font-size: 16px; /* Prevent zoom on iOS */
        }

        .form-textarea {
          min-height: 80px;
        }
      }

      .images-preview-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 1rem;
      }
      .image-preview-item {
        position: relative;
        width: 80px;
        height: 80px;
        border-radius: 8px;
        overflow: hidden;
        flex-shrink: 0;
      }
      .image-preview-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      .remove-image-btn {
        position: absolute;
        top: -4px;
        right: -4px;
        background: var(--danger);
        color: white;
        border: 2px solid white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        cursor: pointer;
        font-weight: bold;
        font-size: 12px;
        line-height: 1;
      }

      /* ==========================================
        BUTTONS - Modern Design System
        ========================================== */

      /* Base Button Styles */
      .btn {
        padding: 0.75rem 1.5rem;
        border: none;
        border-radius: 10px;
        font-size: 0.9375rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        font-family: inherit;
        white-space: nowrap;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
        min-height: 40px;
      }

      /* Primary Button */
      .btn-primary {
        background: var(--primary);
        color: white;
        border: none;
      }

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

      .btn-primary:active {
        background: var(--btn-active);
      }

      .btn-primary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
      }

      /* Primary Loading State */
      .btn-primary.loading {
        pointer-events: none;
      }

      .btn-primary.loading::after {
        content: "";
        width: 16px;
        height: 16px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top-color: white;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
        margin-left: 0.5rem;
      }

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

      /* Secondary Button */
      .btn-secondary {
        background: white;
        color: var(--primary);
        border: 1px solid var(--primary);
      }

      .btn-secondary:hover {
        background: rgba(76, 175, 160, 0.08);
      }

      .btn-secondary:active {
        background: var(--btn-active);
        color: white;
        border-color: var(--btn-active);
      }

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

      .btn-secondary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
      }

      /* Fix bottoni calendario senza classe .btn */
      button.btn-secondary {
        padding: 0.75rem 1.25rem;
        border-radius: 10px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        white-space: nowrap;
      }

      /* Tertiary Button (Ghost) */
      .btn-tertiary {
        background: transparent;
        color: var(--primary);
        border: none;
      }

      .btn-tertiary:hover {
        background: rgba(76, 175, 160, 0.08);
      }

      .btn-tertiary:active {
        background: rgba(58, 140, 128, 0.15);
        color: var(--btn-active);
      }

      .btn-tertiary:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
      }

      /* Danger Button */
      .btn-danger {
        background: var(--danger);
        color: white;
        border: none;
      }

      .btn-danger:hover {
        background: #d45a65;
      }

      .btn-danger:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
      }

      /* Success Button */
      .btn-success {
        background: #10b981;
        color: white;
        border: none;
      }

      .btn-success:hover {
        background: #059669;
      }

      /* Icon Buttons */
      .btn-icon {
        background: transparent;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        width: 36px;
        height: 36px;
        min-width: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 1rem;
        padding: 0;
        transition: all 0.2s ease;
        color: var(--text-secondary);
      }

      .btn-icon:hover {
        background: #f5f5f5;
        border-color: #ddd;
        color: var(--primary);
      }

      .btn-icon:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        pointer-events: none;
      }

      /* Button Sizes */
      .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        border-radius: 8px;
      }

      .btn-lg {
        padding: 1rem 2rem;
        font-size: 1.125rem;
        border-radius: 12px;
      }

      /* Button with Icon */
      .btn-with-icon {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
      }

      .btn-icon-only {
        padding: 0.875rem;
        min-width: 44px;
      }

      /* Full Width Button */
      .btn-block {
        width: 100%;
        display: flex;
      }

      /* Button Group */
      .btn-group {
        display: inline-flex;
        gap: 0.5rem;
      }

      .btn-group .btn {
        border-radius: 10px;
      }

      /* Tab Buttons */
      .tabs {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0 8px;
        background: white;
        border-radius: 12px;
        box-shadow: 0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
        height: 68px;
        overflow: visible;
        margin-bottom: 1rem;
      }

      .tabs .tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        border: none;
        background: none !important;
        cursor: pointer;
        padding: 0.5rem;
        transition: color 0.2s;
        color: #94a3b8;
        gap: 2px;
        font-size: inherit;
        font-weight: inherit;
        white-space: nowrap;
      }

      .tabs .tab:hover {
        background: none !important;
        color: var(--primary);
      }

      .tabs .tab:disabled,
      .tabs .tab.is-disabled {
        color: #cbd5e1;
        cursor: not-allowed;
        opacity: 0.55;
      }

      .tabs .tab:disabled:hover,
      .tabs .tab.is-disabled:hover {
        background: none !important;
        color: #cbd5e1;
      }

      .tabs .tab.active {
        background: none !important;
        color: var(--primary-dark) !important;
      }

      .tabs .tab.active .tab-icon-wrap::after {
        content: '';
        display: block;
        position: absolute;
        bottom: -20px;
        left: 50%;
        transform: translateX(-50%);
        width: 28px;
        height: 3px;
        border-radius: 999px;
        background: var(--primary);
      }

      .tabs .tab .label {
        font-size: 0.6rem;
        font-weight: 500;
        letter-spacing: 0.01em;
      }

      .tabs .tab-center {
        flex: 0 0 60px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: var(--primary-gradient) !important;
        color: white !important;
        margin: 0 4px;
        position: relative;
        top: -22px;
        box-shadow: 0 4px 16px rgba(76,175,160,0.45), 0 1px 4px rgba(76,175,160,0.3);
        padding: 0;
        transition: box-shadow 0.2s, transform 0.15s;
      }

      .tabs .tab-center:hover {
        background: var(--primary-gradient) !important;
        box-shadow: 0 6px 20px rgba(76,175,160,0.55);
        color: white !important;
      }

      .tabs .tab-center:active {
        background: var(--btn-active) !important;
        transform: translateY(1px);
        box-shadow: 0 2px 10px rgba(76,175,160,0.35);
      }

      .tabs .tab-center .tab-icon-wrap {
        background: none !important;
        padding: 0 !important;
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }

      /* Portion Buttons */
      .portion-btn {
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
        color: var(--text-primary);
      }

      .portion-btn:hover {
        border-color: var(--primary);
        background: rgba(76, 175, 160, 0.06);
      }

      .portion-btn.selected {
        border-color: var(--primary);
        background: var(--primary);
        color: white;
      }

      /* Loading Spinner for any button */
      .btn.loading {
        pointer-events: none;
        opacity: 0.7;
      }

      .btn.loading::after {
        content: "";
        width: 14px;
        height: 14px;
        border: 2px solid currentColor;
        border-top-color: transparent;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
        margin-left: 0.5rem;
      }

      /* Mobile Touch Targets */
      @media (max-width: 768px) {
        .btn {
          min-height: 40px;
          padding: 0.75rem 1.25rem;
        }

        .btn-icon {
          width: 44px;
          height: 44px;
          min-width: 44px;
          font-size: 1.125rem;
        }

        .tab {
          padding: 0.625rem 1.25rem;
          font-size: 0.875rem;
        }
      }

      /* High Contrast Focus for Accessibility */
      .btn:focus-visible {
        outline: 2px solid #4CAFA0;
        outline-offset: 2px;
      }

      /* ==========================================
        MODALS & OVERLAYS - Modern Design
        ========================================== */

      /* Modal Backdrop */
      .modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.35);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 10000;
        overflow-y: auto;
        padding: 1rem;
        opacity: 0;
        transition: opacity 0.2s ease;
      }

      /* Modal Z-index Hierarchy */
      #barcodeModal {
        z-index: 10001;
      }

      #productModal {
        z-index: 10002;
      }

      #createRecipeModal {
        z-index: 10000;
      }

      #mealTypeChooserModal {
        z-index: 10003;
      }

      #addMealChooserModal {
        z-index: 10003;
      }

      #addElementModal {
        z-index: 10004;
      }

      #subscriptionModal {
        z-index: 10010;
      }

      /* Input panel visibility inside addElementModal */
      .elem-input-panel { display: none; }
      .elem-input-panel.active { display: block; }

      /* Modal Show State - Fade In */
      .modal.show {
        display: flex !important;
        align-items: center;
        justify-content: center;
        opacity: 1;
        animation: fadeIn 0.3s ease;
      }

      @keyframes fadeIn {
        from {
          opacity: 0;
        }
        to {
          opacity: 1;
        }
      }

      /* Modal Content Container */
      .modal-content {
        background: #F7F7F7;
        border-radius: 20px;
        max-width: 800px;
        width: 90%;
        max-height: 90vh;
        overflow-y: auto;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
        transform: translateY(10px);
        opacity: 0;
        transition: all 0.2s ease;
        position: relative;
      }

      /* Modal Content Show */
      .modal.show .modal-content {
        transform: translateY(0);
        opacity: 1;
      }

      /* Logout dialog compatto */
      .logout-dialog {
        background: #f7f7f7;
        border-radius: 20px;
        width: min(320px, 88vw);
        padding: 28px 24px 20px;
        box-shadow: 0 8px 40px rgba(0,0,0,0.15);
        text-align: center;
        transform: translateY(8px);
        opacity: 0;
        transition: all 0.2s ease;
      }

      .modal.show .logout-dialog {
        transform: translateY(0);
        opacity: 1;
      }

      .logout-dialog-icon {
        font-size: 32px;
        margin-bottom: 12px;
      }

      .logout-dialog-title {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 25px;
      }

      .logout-dialog-msg {
        font-size: 13px;
        color: var(--text-muted);
        margin-bottom: 22px;
      }

      .logout-dialog-actions {
        display: flex;
        gap: 10px;
      }

      .logout-btn-cancel,
      .logout-btn-confirm {
        flex: 1;
        padding: 10px 0;
        border-radius: 12px;
        border: none;
        font-family: inherit;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.15s ease;
      }

      .logout-btn-cancel {
        background: #f0f0f0;
        color: var(--text-secondary);
      }

      .logout-btn-cancel:hover { background: #e4e4e4; }

      .logout-btn-confirm {
        background: var(--danger);
        color: white;
      }

      .logout-btn-confirm:hover { background: #d45f6a; }

      #warningModal.photo-only-prompt .logout-dialog {
        width: min(460px, 92vw);
      }

      #warningModal.photo-only-prompt .logout-dialog-actions {
        flex-wrap: nowrap;
      }

      #warningModal.photo-only-prompt .logout-btn-cancel,
      #warningModal.photo-only-prompt .logout-btn-confirm {
        padding: 10px 14px;
        white-space: nowrap;
      }

      #warningModal.photo-only-prompt .logout-btn-confirm {
        background: var(--primary);
      }

      #warningModal.photo-only-prompt .logout-btn-confirm:hover {
        background: var(--primary-dark);
      }

      @media (max-width: 360px) {
        #warningModal.photo-only-prompt .logout-dialog {
          width: calc(100vw - 20px);
          padding-left: 16px;
          padding-right: 16px;
        }

        #warningModal.photo-only-prompt .logout-dialog-actions {
          gap: 8px;
        }

        #warningModal.photo-only-prompt .logout-btn-cancel,
        #warningModal.photo-only-prompt .logout-btn-confirm {
          padding-left: 8px;
          padding-right: 8px;
          font-size: 12px;
        }
      }

      /* =============================================
         RECIPES GRID
         ============================================= */
      .recipes-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
      }
      @media (min-width: 768px) {
        .recipes-grid {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 1rem;
        }
      }
      .recipe-card {
        background: white;
        border-radius: 16px;
        border: 1px solid var(--light-gray);
        padding: 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.625rem;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
      }
      .recipe-card-name {
        font-size: 0.9375rem;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0;
      }
      .recipe-card-chips {
        display: flex;
        gap: 0.375rem;
        flex-wrap: wrap;
      }
      .recipe-card-chip {
        font-size: 0.6875rem;
        font-weight: 600;
        padding: 3px 8px;
        border-radius: 8px;
        background: rgba(76,175,160,0.1);
        color: var(--primary-dark);
      }
      .recipe-card-servings-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
      }
      .recipe-card-srv-btn {
        background: none;
        border: none;
        cursor: pointer;
        font-size: 0.8125rem;
        font-weight: 700;
        line-height: 1;
        padding: 0 3px;
        color: var(--primary-dark);
        display: flex;
        align-items: center;
      }
      .recipe-card-srv-btn:hover { color: var(--primary); }
      .recipe-card-srv-count {
        font-size: 0.75rem;
        font-weight: 700;
        min-width: 14px;
        text-align: center;
        color: var(--primary-dark);
      }
      .recipe-card-tabs {
        display: flex;
        border-bottom: 1px solid var(--light-gray);
        gap: 0;
      }
      .recipe-card-tab {
        flex: 1;
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        margin-bottom: -1px;
        padding: 5px 0;
        font-family: inherit;
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        cursor: pointer;
        color: var(--gray);
        transition: color 0.15s, border-color 0.15s;
      }
      .recipe-card-tab--active {
        color: var(--primary-dark);
        border-bottom-color: var(--primary);
      }
      .recipe-card-macros {
        display: grid;
        grid-template-columns: repeat(4,1fr);
        gap: 0.375rem;
        text-align: center;
      }
      .recipe-card-macro--cal .recipe-card-macro-value {
        font-size: 0.875rem;
        display: flex;
        align-items: baseline;
        gap: 4px;
        flex-wrap: nowrap;
        min-width: 0;
        white-space: nowrap;
      }
      .recipe-card-macro--cal .recipe-card-macro-value img {
        align-self: center;
        flex-shrink: 0;
      }
      .recipe-card-macro--cal .recipe-card-macro-value > span:last-child {
        font-size: 0.5rem !important;
        flex-shrink: 0;
      }
      @media (max-width: 380px) {
        .recipe-card-macro--cal .recipe-card-macro-value {
          font-size: 0.8125rem;
          gap: 2px;
        }
        .recipe-card-macro--cal .recipe-card-macro-value img {
          height: 14px !important;
          padding-right: 0 !important;
        }
        .recipe-card-macros {
          gap: 0.25rem;
        }
        .recipe-card-macro {
          padding: 6px 2px;
        }
        .recipe-card-macro-label,
        .recipe-card-macro-label-cal {
          padding-left: 3px;
        }
        .recipe-card-macro-value {
          padding-left: 3px;
        }
      }
      .recipe-card-macro--cal .recipe-card-macro-label-cal {
        color: var(--primary);
      }
      .recipe-card-macro {
        background: #f7f7f7;
        border-radius: 8px;
        padding: 6px 4px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
      }
      .recipe-card-macro--cal {
        border: 2.5px solid var(--primary) !important;
        background: rgba(76, 175, 160, 0.08) !important;
      }

      .recipe-card-macro.carbs   { background: rgba(244, 162, 97, 0.12); border: 1px solid rgba(244, 162, 97, 0.3); }
      .recipe-card-macro.protein { background: rgba(76, 175, 160, 0.12); border: 1px solid rgba(76, 175, 160, 0.3); }
      .recipe-card-macro.fats    { background: rgba(231, 111, 81, 0.12); border: 1px solid rgba(231, 111, 81, 0.3); }

      .recipe-card-macro.carbs   .recipe-card-macro-label { color: #c4692a; }
      .recipe-card-macro.protein .recipe-card-macro-label { color: #3d9e90; }
      .recipe-card-macro.fats    .recipe-card-macro-label { color: #b84e2a; }

      .recipe-ingredients-list .recipe-card-macros,
      .recipe-card-macros.recipe-ingredients-list {
        grid-template-columns: repeat(3, 1fr);
      }
      .recipe-ingredients-list .recipe-card-macro.carbs,
      .recipe-ingredients-list .recipe-card-macro.protein,
      .recipe-ingredients-list .recipe-card-macro.fats,
      .recipe-card-macros.recipe-ingredients-list .recipe-card-macro.carbs,
      .recipe-card-macros.recipe-ingredients-list .recipe-card-macro.protein,
      .recipe-card-macros.recipe-ingredients-list .recipe-card-macro.fats {
        background: transparent;
        border: none;
      }
      .recipe-ingredients-list .recipe-card-macro .recipe-card-macro-label,
      .recipe-card-macros.recipe-ingredients-list .recipe-card-macro-label {
        color: #2d3748 !important;
        font-weight: 700;
      }
      .recipe-ingredients-list .recipe-card-macro .recipe-card-macro-value,
      .recipe-card-macros.recipe-ingredients-list .recipe-card-macro-value {
        color: #2d3748 !important;
        font-weight: 400;
      }
      .recipe-card-macro-label {
        font-size: 0.625rem;
        color: var(--gray);
        margin-bottom: 2px;
        text-align: left;
        padding-left: 5px;
      }
      .recipe-card-macro-label-cal {
        font-size: 0.625rem;
        color: black;
        font-weight: bold;
        margin-bottom: 2px;
        text-align: left;
        padding-left: 5px;
      }
      .recipe-card-macro-value {
        font-size: 0.8125rem;
        font-weight: 700;
        text-align: left;
        padding-left: 5px;
      }
      .recipe-card-ingredients {
        font-size: 0.75rem;
        color: var(--text-secondary);
        line-height: 1.4;
      }
      .recipe-card-ingredients strong {
        color: var(--text-primary);
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
      }
      .recipe-card-ing-ul {
        list-style: none;
        margin: 4px 0 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 3px;
      }
      .recipe-card-ing-ul li {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.75rem;
        color: var(--text-secondary);
      }
      .recipe-card-ing-ul li::before {
        content: '';
        display: inline-block;
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: var(--primary);
        opacity: 0.5;
        flex-shrink: 0;
      }
      .recipe-card-ing-name {
        flex: 1;
        color: var(--text-primary);
        font-weight: 500;
      }
      .recipe-card-ing-qty {
        font-size: 0.6875rem;
        color: var(--gray);
        white-space: nowrap;
      }
      .recipe-card-actions {
        display: flex;
        gap: 0.375rem;
        margin-top: auto;
        padding-top: 0.5rem;
        border-top: 1px solid var(--light-gray);
      }
      .recipe-card-btn {
        flex: 1;
        padding: 6px 0;
        border: none;
        border-radius: 8px;
        font-family: inherit;
        font-size: 0.6875rem;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.15s ease;
        background: #f0f0f0;
        color: var(--text-secondary);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
      }
      .recipe-card-btn:hover { background: #e4e4e4; }
      .recipe-card-btn--danger {
        color: var(--danger);
      }
      .recipe-card-btn--danger:hover { background: #fde8e8; }

      /* =============================================
         ADD MEAL CHOOSER (compact centered dialog)
         ============================================= */
      .meal-chooser-dialog {
        background: #f7f7f7;
        border-radius: 20px;
        width: min(360px, 92vw);
        padding: 20px 20px 16px;
        box-shadow: 0 8px 40px rgba(0,0,0,0.15);
        transform: translateY(8px);
        opacity: 0;
        transition: all 0.2s ease;
      }

      .modal.show .meal-chooser-dialog {
        transform: translateY(0);
        opacity: 1;
      }

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

      .meal-chooser-title {
        font-size: 15px;
        font-weight: 700;
        color: var(--text-primary);
      }

      .meal-chooser-subtitle {
        font-size: 12px;
        color: var(--gray);
        font-weight: 500;
      }

      .meal-chooser-close {
        background: rgba(0,0,0,0.05);
        border: none;
        border-radius: 8px;
        font-size: 1.25rem;
        cursor: pointer;
        color: #718096;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s;
        flex-shrink: 0;
      }

      .meal-chooser-close:hover { background: rgba(0,0,0,0.08); }

      .meal-chooser-options {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 12px;
      }

      .meal-chooser-option {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 11px 14px;
        background: white;
        border: 1.5px solid var(--border-color);
        border-radius: 14px;
        cursor: pointer;
        transition: all 0.15s ease;
        text-align: left;
        width: 100%;
      }

      .meal-chooser-option:hover {
        border-color: var(--primary);
        background: rgba(76, 175, 160, 0.04);
      }

      .meal-chooser-option:active {
        transform: scale(0.98);
      }

      .meal-chooser-option-icon {
        font-size: 1.4rem;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(76, 175, 160, 0.1);
        border-radius: 10px;
        flex-shrink: 0;
      }

      .meal-chooser-option-body {
        flex: 1;
      }

      .meal-chooser-option-title {
        font-size: 0.9375rem;
        font-weight: 700;
        color: #2d3748;
        line-height: 1.2;
      }

      .meal-chooser-option-desc {
        font-size: 0.78125rem;
        color: #718096;
        margin-top: 2px;
      }

      .meal-chooser-option-arrow {
        font-size: 1rem;
        color: #cbd5e0;
        flex-shrink: 0;
        transition: color 0.15s;
      }

      .meal-chooser-option:hover .meal-chooser-option-arrow {
        color: var(--primary);
      }

      /* =============================================
         ADD MEAL MODAL — unified form modal
         ============================================= */
      #addMealModal .modal-content {
        max-width: 540px;
      }

      .add-meal-type-locked {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        background: rgba(76, 175, 160, 0.08);
        border: 1.5px solid rgba(76, 175, 160, 0.3);
        border-radius: 12px;
        font-size: 0.9375rem;
        font-weight: 600;
        color: var(--primary-dark);
        margin-bottom: 1rem;
      }

      .add-meal-type-locked .lock-icon {
        font-size: 0.75rem;
        opacity: 0.6;
      }

      #mealTypeLockedLabel {
        display: flex;
        align-items: center;
        gap: 6px;
      }

      #mealTypeLockedLabel img {
        width: 20px;
        height: 20px;
        object-fit: contain;
        flex-shrink: 0;
      }

      .meal-mode-panel {
        display: none;
      }

      .meal-mode-panel.active {
        display: block;
      }

      /* Add meal modal — analyzing state */
      .add-meal-analyzing {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 2.5rem 1rem;
        gap: 0.75rem;
      }

      .add-meal-analyzing .loader {
        width: 36px;
        height: 36px;
        border-width: 3px;
      }

      .add-meal-analyzing-text {
        font-size: 1rem;
        font-weight: 700;
        color: #2d3748;
        margin: 0;
      }

      .add-meal-analyzing-sub {
        font-size: 0.875rem;
        color: var(--gray);
        margin: 0;
      }

      /* Add meal modal — result panel */
      .add-meal-result {
        padding: 0.25rem 0 0.5rem;
      }

      .add-meal-result-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1rem;
        padding: 0.875rem 1rem;
        background: rgba(76, 175, 160, 0.06);
        border: 1.5px solid rgba(76, 175, 160, 0.2);
        border-radius: 14px;
      }

      .add-meal-result-emoji {
        font-size: 2rem;
        flex-shrink: 0;
      }

      .add-meal-result-title {
        font-size: 1.0625rem;
        font-weight: 700;
        color: #2d3748;
        line-height: 1.2;
      }

      .add-meal-result-time {
        font-size: 0.8125rem;
        color: var(--gray);
        margin-top: 2px;
      }

      .add-meal-result-macros {
        display: flex;
        gap: 0.5rem;
        margin-bottom: 1rem;
        flex-wrap: wrap;
      }

      .add-meal-macro-pill {
        flex: 1;
        min-width: calc(50% - 0.25rem);
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 0.625rem 0.875rem;
        background: white;
        border: 1.5px solid var(--border-color);
        border-radius: 12px;
        font-size: 0.875rem;
      }

      .add-meal-macro-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
      }

      .add-meal-macro-label {
        color: var(--gray);
        font-size: 0.8125rem;
        flex-shrink: 0;
      }

      .add-meal-macro-value {
        font-weight: 700;
        color: #2d3748;
        margin-left: auto;
      }

      .add-meal-macro-unit {
        color: var(--gray);
        font-size: 0.75rem;
      }

      .add-meal-macro-kcal {
        border-color: rgba(76, 175, 160, 0.3);
        min-width: 100%;
        flex: none;
        justify-content: center;
      }

      .add-meal-macro-kcal .add-meal-macro-value {
        font-size: 1.125rem;
        color: var(--primary-dark);
        margin-left: 0;
        margin-right: 4px;
      }

      .add-meal-result-items {
        display: flex;
        flex-wrap: wrap;
        gap: 0.375rem;
        margin-bottom: 0.75rem;
      }

      .add-meal-result-notes {
        margin-bottom: 0.75rem;
        display: none;
      }

      .add-meal-result-notes:not(:empty) {
        display: block;
      }

      .notes-expander {
        margin-top: 0.5rem;
      }

      .notes-expander-summary {
        align-items: center;
        color: var(--gray);
        cursor: pointer;
        display: flex;
        font-size: 0.8125rem;
        font-weight: 700;
        gap: 0.375rem;
        letter-spacing: 0.06em;
        line-height: 1.3;
        list-style: none;
        padding: 0.375rem 0;
        text-transform: uppercase;
        user-select: none;
      }

      .notes-expander-summary::-webkit-details-marker {
        display: none;
      }

      .notes-expander-body {
        padding: 0.625rem 0 0.25rem;
      }

      .notes-expander-body,
      .portion-notes {
        overflow-wrap: anywhere;
        word-break: normal;
      }

      .portion-notes {
        color: var(--text-primary);
        font-size: 0.8125rem;
        line-height: 1.5;
      }

      .portion-note-section {
        margin-bottom: 0.75rem;
      }

      .portion-note-section-title {
        color: var(--gray);
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        margin-bottom: 0.375rem;
        text-transform: uppercase;
      }

      .portion-note-item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.04);
        padding: 0.3rem 0 0.3rem 0.5rem;
      }

      .portion-note-item:last-child {
        border-bottom: 0;
      }

      .portion-note-item-row,
      .portion-note-dish-row {
        align-items: baseline;
        display: flex;
        gap: 0.5rem;
        justify-content: space-between;
      }

      .portion-note-item-name,
      .portion-note-text {
        color: var(--text-primary);
        min-width: 0;
      }

      .portion-note-item-amount {
        color: var(--text-secondary);
        flex-shrink: 0;
        font-weight: 600;
        white-space: nowrap;
      }

      .portion-note-item-info {
        color: var(--text-muted);
        font-size: 0.6875rem;
        line-height: 1.45;
        margin-top: 0.125rem;
      }

      .portion-note-dish {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        margin-top: 0.375rem;
        padding: 0.625rem 0 0.25rem;
      }

      .portion-note-dish-name {
        color: var(--text-primary);
        font-size: 0.875rem;
        font-weight: 700;
        min-width: 0;
        text-transform: uppercase;
      }

      .portion-note-dish-info {
        color: var(--text-muted);
        flex-shrink: 0;
        font-size: 0.6875rem;
        white-space: nowrap;
      }

      .portion-note-detail {
        color: var(--text-secondary);
        font-size: 0.8125rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
      }

      .portion-note-more-summary {
        color: var(--primary);
        cursor: pointer;
        font-size: 0.8125rem;
        font-weight: 600;
        line-height: 1.35;
        list-style: none;
        padding: 0.375rem 0;
        user-select: none;
      }

      .portion-note-more-summary::-webkit-details-marker {
        display: none;
      }

      .portion-note-unit {
        white-space: nowrap;
      }

      .portion-note-fallback {
        white-space: pre-wrap;
      }

      details[open] .expander-chevron {
        transform: rotate(180deg);
      }

      .notes-expander .expander-chevron {
        transition: transform 0.2s;
        flex-shrink: 0;
      }

      .add-meal-result-info {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        font-size: 0.8rem;
        color: var(--gray);
        padding: 0.5rem 0.75rem;
        background: #fffbeb;
        border: 1px solid #fde68a;
        border-radius: 10px;
        margin-bottom: 0.5rem;
        line-height: 1.4;
      }

      /* Portions +/- buttons */
      .amt-btn {
        width: 34px; height: 34px;
        border-radius: 50%;
        border: 1.5px solid var(--border-color);
        background: #fff;
        font-size: 1.125rem; font-weight: 600;
        color: var(--primary);
        cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        transition: all 0.15s;
      }
      .amt-btn:hover { background: rgba(76,175,160,0.08); border-color: var(--primary); }
      .amt-btn:active { transform: scale(0.92); }

      /* Result summary element chips */
      .result-element-chip {
        display: inline-flex; align-items: center; gap: 0.375rem;
        padding: 0.3rem 0.625rem;
        background: rgba(76,175,160,0.1);
        border-radius: 8px;
        font-size: 0.8125rem; color: #2d3748;
        margin-bottom: 0.25rem; margin-right: 0.25rem;
      }
      .result-element-chip img {
        width: 22px; height: 22px; border-radius: 4px; object-fit: cover;
      }

      /* Modal toast (inside modal, below header) */
      .modal-toast {
        position: absolute;
        top: 4.5rem;
        left: 50%;
        transform: translateX(-50%) translateY(-8px);
        background: #2d3748;
        color: #fff;
        padding: 0.5rem 1.125rem;
        border-radius: 20px;
        font-size: 0.8125rem;
        font-weight: 500;
        white-space: nowrap;
        z-index: 10010;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s, transform 0.2s;
        box-shadow: 0 4px 16px rgba(0,0,0,0.18);
      }
      .modal-toast.toast-success { background: #3d9970; }
      .modal-toast.toast-error   { background: #e76f7a; }
      .modal-toast.toast-show {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
        pointer-events: auto;
      }

      /* Improved element card */
      .meal-element-card {
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        overflow: hidden;
        position: relative;
      }
      .meal-element-thumb {
        width: 44px; height: 44px;
        border-radius: 8px;
        flex-shrink: 0;
      }
      .meal-element-name {
        font-weight: 600; font-size: 0.875rem; color: #2d3748;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        margin-bottom: 2px;
      }
      .meal-element-body { flex: 1; min-width: 0; }
      .meal-element-card-top {
        display: flex; align-items: center; gap: 0.625rem;
        padding: 0.625rem 0.75rem;
      }
      .meal-element-card-macros {
        display: grid; grid-template-columns: repeat(4,1fr);
        gap: 0; border-top: 1px solid var(--border-color);
        background: #fafafa;
      }
      .meal-element-card-macro-cell {
        text-align: center;
        padding: 0.375rem 0.25rem;
        font-size: 0.75rem;
      }
      .meal-element-card-macro-cell + .meal-element-card-macro-cell {
        border-left: 1px solid var(--border-color);
      }
      .meal-element-card-macro-label { color: var(--gray); font-size: 0.6875rem; }
      .meal-element-card-macro-val   { font-weight: 700; color: #2d3748; font-size: 0.8125rem; }
.meal-element-action-btn {
        flex: 1; padding: 0.3rem 0;
        border: none; border-radius: 6px; cursor: pointer;
        font-size: 0.75rem; font-weight: 500;
        background: rgba(76,175,160,0.08); color: var(--primary);
        transition: background 0.15s;
      }
      .meal-element-action-btn:hover { background: rgba(76,175,160,0.18); }
      .meal-element-action-btn.remove-btn { color: #e76f7a; background: rgba(231,111,122,0.07); }
      .meal-element-action-btn.remove-btn:hover { background: rgba(231,111,122,0.15); }

      /* Editable macro input in result panel */
      .macro-editable-input {
        width: 100%; max-width: 70px;
        border: none; border-bottom: 1.5px solid var(--border-color);
        background: transparent;
        text-align: right;
        font-weight: 700;
        font-size: inherit;
        color: #2d3748;
        outline: none;
        padding: 0;
        text-align: left;
      }
      .macro-editable-input:focus { border-bottom-color: var(--primary); }

      /* Modal Header */
      .modal-header {
        padding: 1.25rem 1.5rem;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        background: #F7F7F7;
        border-radius: 20px 20px 0 0;
        position: sticky;
        top: 0;
        z-index: 10;
      }

      .modal-header h2 {
        font-size: 1.25rem;
        font-weight: 700;
        color: #1a202c;
        letter-spacing: -0.025em;
        margin: 0;
      }

      /* Modal Body */
      .modal-body {
        padding: 1.5rem;
        overflow-y: auto;
        overflow-x: hidden;
      }

      /* Modal Close Button */
      .modal-close {
        background: white;
        border: none;
        border-radius: 8px;
        font-size: 1.5rem;
        cursor: pointer;
        color: #718096;
        padding: 0;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        line-height: 1;
      }

      @media (hover: hover) and (pointer: fine) {
        .modal-close:hover {
          background: rgba(0, 0, 0, 0.08);
          color: var(--text-primary);
        }
      }

      .modal-close:active {
        background: rgba(0, 0, 0, 0.1);
      }

      /* Modal Footer (if needed) */
      .modal-footer {
        padding: 1rem 1.5rem;
        border-top: 1px solid #e2e8f0;
        background: #fafbfc;
        border-radius: 0 0 16px 16px;
        display: flex;
        gap: 0.75rem;
        justify-content: flex-end;
      }

      /* Premium-gated elements (locked for free users) */
      .premium-only {
        position: relative;
      }
      .premium-locked {
        border: 2px solid #e89b2d !important;
        opacity: 0.7;
        pointer-events: none;
        cursor: not-allowed;
        margin-top: 18px;
      }
      /* Compensa lo spazio extra della chip anche sull'elemento successivo
         così il gap tra card resta uniforme quando la chip sporge */
      .premium-locked + * {
        margin-top: 18px;
      }
      .premium-locked::after {
        content: "";
      }
      /* Blur sui contenuti dei grafici premium quando bloccati (titolo escluso) */
      .premium-locked[data-premium-feature^="chart-"] > *:not(.premium-chip):not(h2) {
        filter: blur(6px);
        -webkit-filter: blur(6px);
      }
      .premium-chip {
        position: absolute;
        top: -10px;
        right: 12px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 3px 8px;
        border-radius: 999px;
        background: linear-gradient(135deg, #f6c457, #e89b2d);
        color: #3a2500;
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        line-height: 1;
        pointer-events: none;
        z-index: 2;
      }
      .premium-chip svg {
        width: 12px;
        height: 12px;
        fill: #3a2500;
        stroke: #3a2500;
      }

      /* Subscription Crown Button (profile header) */
      .subscription-crown-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        border: none;
        background: transparent;
        color: #a0aec0;
        cursor: pointer;
        border-radius: 50%;
        transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
      }
      .subscription-crown-btn:hover {
        background: rgba(0, 0, 0, 0.05);
      }
      .subscription-crown-btn:active {
        transform: scale(0.94);
      }
      .subscription-crown-btn.is-premium {
        color: #e89b2d;
      }
      .subscription-crown-btn.is-premium svg {
        fill: #f6c457;
      }

      /* Subscription Plan Cards (non clickabili — usano il bottone "Scegli") */
      .subscription-plan-card {
        display: flex;
        align-items: center;
        gap: 1rem;
        width: 100%;
        text-align: left;
        padding: 1rem 1.25rem;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        background: #fff;
        font-family: inherit;
        transition: border-color 0.15s ease, background 0.15s ease;
      }
      .subscription-plan-card.selected {
        border-color: var(--primary, #3d9970);
        background: #f0faf5;
      }
      .subscription-plan-info {
        flex: 1;
        min-width: 0;
      }
      .subscription-plan-choose {
        flex-shrink: 0;
        padding: 0.55rem 1.1rem;
        border: none;
        border-radius: 8px;
        background: var(--primary, #3d9970);
        color: #fff;
        font-weight: 600;
        font-size: 0.9rem;
        cursor: pointer;
        font-family: inherit;
        transition: background 0.15s ease, transform 0.1s ease;
      }
      .subscription-plan-choose:hover {
        background: #2f7d57;
      }
      .subscription-plan-choose:active {
        transform: scale(0.96);
      }
      .subscription-premium-card .subscription-plan-choose {
        background: #e89b2d;
      }
      .subscription-premium-card .subscription-plan-choose:hover {
        background: #c97f1a;
      }
      .subscription-plan-title {
        font-weight: 700;
        font-size: 1.05rem;
        color: #1a202c;
      }
      .subscription-plan-price {
        font-size: 0.95rem;
        color: var(--primary, #3d9970);
        font-weight: 600;
        margin-top: 0.15rem;
      }
      .subscription-plan-desc {
        font-size: 0.85rem;
        color: var(--gray, #718096);
        margin-top: 0.35rem;
      }
      .subscription-premium-card .subscription-plan-card {
        background: #fff;
        border-color: #e2e8f0;
      }
      .subscription-premium-card .subscription-plan-card.selected {
        border-color: var(--primary, #3d9970);
        background: #f0faf5;
      }
      .subscription-premium-card .subscription-plan-price {
        color: #e89b2d;
      }

      /* Yumii Premium Card (raggruppa piani Mensile e Annuale) */
      .subscription-premium-card {
        border: 2px solid transparent;
        background: #fdf6e3;
        border-radius: 14px;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
      }
      .subscription-premium-card.is-premium-active {
        border-color: #e89b2d;
      }
      .subscription-premium-header {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      .subscription-premium-title {
        font-weight: 700;
        font-size: 1.05rem;
        color: #e89b2d;
        letter-spacing: 0.02em;
      }
      .subscription-premium-plans {
        display: flex;
        flex-direction: column;
        gap: 0.6rem;
      }
      .subscription-premium-benefits {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
      }
      .subscription-premium-benefits-title {
        font-weight: 700;
        font-size: 0.95rem;
        color: #1a202c;
      }
      .subscription-premium-benefits-list {
        list-style: none;
        margin: 0;
        padding: 0 1rem;
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
      }
      .subscription-premium-benefits-list li {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0;
      }
      .subscription-premium-benefits-list .benefit-icon {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        color: #e89b2d;
        margin-top: 0.1rem;
      }
      .subscription-premium-benefits-list .benefit-text {
        display: flex;
        flex-direction: column;
        gap: 0.1rem;
      }
      .subscription-premium-benefits-list .benefit-title {
        font-size: 0.8rem;
        font-weight: 600;
        color: #1a202c;
      }
      .subscription-premium-benefits-list .benefit-subtitle {
        font-size: 0.7rem;
        color: #718096;
        line-height: 1.3;
      }

      /* Scrollbar Styling for Modal Content */
      .modal-content::-webkit-scrollbar {
        width: 8px;
      }

      .modal-content::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
      }

      .modal-content::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 10px;
      }

      .modal-content::-webkit-scrollbar-thumb:hover {
        background: #a0aec0;
      }

      /* Mobile Full Screen Modals */
      @media (max-width: 768px) {
        .modal {
          padding: 0;
        }

        .modal-content {
          width: 100%;
          max-width: 100%;
          height: 100%;
          max-height: 100%;
          border-radius: 0;
          margin: 0;
        }

        .modal-header {
          border-radius: 0;
          padding: 1rem;
        }

        .modal-header h2 {
          font-size: 1.125rem;
        }

        .modal-body {
          padding: 1rem;
        }

        .modal-close {
          width: 40px;
          height: 40px;
        }

        /* Mobile Animation - Slide from Bottom */
        .modal.show .modal-content {
          animation: modalSlideFromBottom 0.4s ease;
        }

        @keyframes modalSlideFromBottom {
          from {
            transform: translateY(100%);
            opacity: 0;
          }
          to {
            transform: translateY(0);
            opacity: 1;
          }
        }
      }

      /* Prevent Body Scroll when Modal Open */
      body.modal-open {
        overflow: hidden;
      }

      /* Modal Sizes */
      .modal-content.modal-sm {
        max-width: 400px;
      }

      .modal-content.modal-md {
        max-width: 600px;
      }

      .modal-content.modal-lg {
        max-width: 900px;
      }

      .modal-content.modal-xl {
        max-width: 1200px;
      }

      /* Loading State in Modal */
      .modal-loading {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 3rem;
        color: #4CAFA0;
      }

      .modal-loading::after {
        content: "";
        width: 40px;
        height: 40px;
        border: 4px solid rgba(76, 175, 160, 0.2);
        border-top-color: #4CAFA0;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
      }

      /* Alert/Message Box in Modals */
      .modal-alert {
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 1rem;
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        animation: slideDown 0.3s ease;
      }

      .modal-alert.info {
        background: rgba(59, 130, 246, 0.1);
        border-left: 3px solid #3b82f6;
        color: #1e40af;
      }

      .modal-alert.success {
        background: rgba(72, 187, 120, 0.1);
        border-left: 3px solid #10b981;
        color: #22543d;
      }

      .modal-alert.warning {
        background: rgba(246, 173, 85, 0.1);
        border-left: 3px solid #f59e0b;
        color: #7c2d12;
      }

      .modal-alert.error {
        background: rgba(245, 101, 101, 0.1);
        border-left: 3px solid #ef4444;
        color: #742a2a;
      }

      @keyframes slideDown {
        from {
          transform: translateY(-10px);
          opacity: 0;
        }
        to {
          transform: translateY(0);
          opacity: 1;
        }
      }

      /* Overlay Backdrop Click Hint */
      .modal::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
      }

      /* Fix for createRecipeModal specific styling — mobile only */
      @media (max-width: 767px) {
        #createRecipeModal.show {
          display: flex !important;
          align-items: stretch;
          justify-content: center;
          padding: 0;
        }

        #createRecipeModal .modal-content {
          min-width: auto;
          max-width: 600px;
          width: 100%;
          max-height: none;
          border-radius: 0;
          margin: 0 auto;
        }
      }

      /* Desktop: createRecipeModal as proper centered modal */
      @media (min-width: 768px) {
        #createRecipeModal.show {
          display: flex !important;
          align-items: center;
          justify-content: center;
          padding: 2rem;
        }

        #createRecipeModal .modal-content {
          max-width: 600px;
          width: 100%;
          max-height: 90vh;
          border-radius: 20px;
          overflow-y: auto;
        }
      }

      .image-gallery {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
        margin: 1rem 0;
      }
      .gallery-image {
        width: 100%;
        aspect-ratio: 1;
        object-fit: cover;
        border-radius: 8px;
        cursor: pointer;
      }
      .gallery-image:hover {
        opacity: 0.8;
      }


      .alert {
        padding: 1rem;
        border-radius: 8px;
        margin-bottom: 1rem;
        background: #E8F5F3;
      }
      .alert-error {
        background: #E8F5F3;
        color: #c53030;
        border: 1px solid #fc8181;
      }
      .alert-warning {
        background: #E8F5F3;
        color: #7c5e00;
        border: 1px solid #f59e0b;
      }
      .alert-success {
        background: #E8F5F3;
        color: #2f855a;
        border: 1px solid #9ae6b4;
      }

      .hidden {
        display: none;
      }
      .text-center {
        text-align: center;
      }
      .text-gray {
        color: var(--gray);
      }
      .mt-1 {
        margin-top: 1rem;
      }

      .loader {
        display: inline-block;
        width: 20px;
        height: 20px;
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-top-color: var(--primary);
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
      }
      @keyframes spin {
        to {
          transform: rotate(360deg);
        }
      }

      @media (max-width: 768px) {
        .container {
          padding: 0.5rem;
        }
        .card {
          padding: 1rem;
        }
        .macros-grid {
          grid-template-columns: repeat(2, 1fr);
        }
        .header-actions {
          flex-direction: row;
          align-items: center;
        }
      }
      .barcode-tab {
        flex: 1;
        padding: 0.75rem 0.5rem;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--gray);
        cursor: pointer;
        transition: color 0.2s, border-color 0.2s;
      }
      .barcode-tab.active {
        color: var(--primary);
        border-bottom-color: var(--primary);
      }
      .barcode-tab:hover:not(.active) {
        color: var(--text);
      }

      .search-result-item {
        display: flex;
        gap: 1rem;
        padding: 0.75rem;
        border: 2px solid var(--light-gray);
        border-radius: 8px;
        margin-bottom: 0.5rem;
        cursor: pointer;
        transition: all 0.2s;
      }
      .search-result-item:hover {
        border-color: var(--primary);
        background: rgba(76, 175, 160, 0.04);
      }
      .search-result-image {
        width: 80px;
        height: 80px;
        object-fit: cover;
        border-radius: 8px;
        background: var(--light-gray);
      }
      .search-result-info {
        flex: 1;
      }
      .search-result-name {
        font-weight: 600;
        color: #2d3748;
        margin-bottom: 0.25rem;
      }
      .search-result-brand {
        font-size: 0.875rem;
        color: var(--gray);
        margin-bottom: 0.25rem;
      }
      .search-result-kcal {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--primary);
        margin-bottom: 0.4rem;
      }
      .search-result-macros {
        display: flex;
        gap: 1.5rem;
        font-size: 0.75rem;
      }
      .search-result-macro-col {
        display: flex;
        flex-direction: column;
      }
      .search-result-macro-label {
        color: var(--gray);
        font-size: 0.7rem;
      }
      .search-result-macro-value {
        font-weight: 600;
        color: #2d3748;
      }
      /* ==========================================
                PRODUCT MODAL STYLES (MFP-like)
        ========================================== */

      /* Slider personalizzato */
      input[type="range"] {
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        height: 8px;
        border-radius: 5px;
        background: linear-gradient(to right, #4CAFA0 0%, #4CAFA0 20%, #e2e8f0 20%, #e2e8f0 100%);
        outline: none;
        transition: background 0.3s;
      }

      input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #4CAFA0;
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        transition: all 0.2s;
      }

      input[type="range"]::-webkit-slider-thumb:hover {
        transform: scale(1.1);
        background: #3d9e90;
      }

      input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #4CAFA0;
        cursor: pointer;
        border: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        transition: all 0.2s;
      }

      input[type="range"]::-moz-range-thumb:hover {
        transform: scale(1.1);
        background: #3d9e90;
      }

      /* Bottoni Porzioni Standard */
      .portion-btn {
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
      }

      .portion-btn:hover {
        border-color: var(--primary);
        background: rgba(76, 175, 160, 0.06);
      }

      /* Anteprima Calcoli - Numeri Animati */
      #calcCalories,
      #calcCarbs,
      #calcProtein,
      #calcFats {
        transition: all 0.3s ease;
      }

      @keyframes pulse-number {
        0%,
        100% {
          transform: scale(1);
        }
        50% {
          transform: scale(1.05);
        }
      }

      .number-changed {
        animation: pulse-number 0.3s ease-in-out;
      }

      /* Product Image Placeholder */
      #productImage[src=""],
      #productImage:not([src]) {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--light-gray);
        color: var(--gray);
        font-size: 2rem;
      }

      #productImage[src=""]::before {
        content: "📦";
      }

      /* Input Number - Rimuovi frecce su Chrome/Edge */
      input[type="number"]::-webkit-inner-spin-button,
      input[type="number"]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
      }

      /* Input Number - Firefox */
      input[type="number"] {
        -moz-appearance: textfield;
      }

      /* Mobile: Input più grandi */
      @media (max-width: 768px) {
        #productQuantity {
          font-size: 1.25rem;
          padding: 1rem;
          text-align: center;
          font-weight: 600;
        }

        #productSlider {
          height: 10px;
        }

        input[type="range"]::-webkit-slider-thumb {
          width: 28px;
          height: 28px;
        }

        input[type="range"]::-moz-range-thumb {
          width: 28px;
          height: 28px;
        }
      }

      /* Animazione Apertura Modal */
      #productModal.show .modal-content {
        animation: slideUpFadeIn 0.3s ease-out;
      }

      @keyframes slideUpFadeIn {
        from {
          opacity: 0;
          transform: translateY(20px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      /* ==========================================
        MEAL ITEMS LIST STYLES
        ========================================== */

      /* Container principale */
      #mealItemsContainer {
        background: #f5f5f5;
        border-radius: 12px;
        padding: 1rem;
        border: 2px dashed #cbd5e0;
      }

      /* Singolo elemento pasto */
      .meal-item {
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.75rem;
        transition: all 0.2s ease;
        position: relative;
      }

      .meal-item:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow);
      }

      /* Badge tipo elemento */
      .item-type-badge {
        /* ✅ NON più absolute - inline normale */
        padding: 0.25rem 0.5rem;
        border-radius: 6px;
        font-size: 0.625rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        white-space: nowrap;
        flex-shrink: 0;
      }

      .item-type-badge.product {
        background: #4CAFA015;
        color: #4CAFA0;
      }

      .item-type-badge.dish {
        background: #10b98115;
        color: #10b981;
      }

      /* Bottoni icona */
      .btn-icon {
        background: transparent;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 0.875rem;
        transition: all 0.2s;
        padding: 0;
      }

      .btn-icon:hover {
        background: #f5f5f5;
        border-color: #cbd5e0;
        transform: scale(1.1);
      }

      .btn-icon:active {
        transform: scale(0.95);
      }

      /* Thumbnail immagine piatto */
      .item-thumbnail {
        width: 60px;
        height: 60px;
        border-radius: 8px;
        object-fit: cover;
        border: 2px solid #e2e8f0;
      }

      /* Animazione aggiunta elemento */
      @keyframes slideInFromRight {
        from {
          opacity: 0;
          transform: translateX(20px);
        }
        to {
          opacity: 1;
          transform: translateX(0);
        }
      }

      .meal-item.new {
        animation: slideInFromRight 0.3s ease-out;
      }

      /* Animazione rimozione elemento */
      @keyframes slideOutToRight {
        from {
          opacity: 1;
          transform: translateX(0);
        }
        to {
          opacity: 0;
          transform: translateX(20px);
        }
      }

      .meal-item.removing {
        animation: slideOutToRight 0.3s ease-out;
      }

      /* Badge contatore */
      #itemsCount {
        animation: pulse 0.3s ease-in-out;
      }

      @keyframes pulse {
        0%,
        100% {
          transform: scale(1);
        }
        50% {
          transform: scale(1.1);
        }
      }

      /* Totale parziale */
      #partialTotal {
        border-left: 4px solid #4CAFA0;
      }

      /* Mobile responsive */
      @media (max-width: 768px) {
        .meal-item {
          padding: 0.5rem;
        }

        .btn-icon {
          width: 28px;
          height: 28px;
          font-size: 0.75rem;
        }

        .item-thumbnail {
          width: 50px;
          height: 50px;
        }

        #mealItemsContainer {
          padding: 0.75rem;
        }
      }



      /* ✅ NUOVO: Style per toggle grafici */
      .charts-view-toggle button {
        transition: all 0.2s;
      }

      .charts-view-toggle button.active {
        background: var(--primary);
        color: white;
      }

      .charts-view-toggle button:not(.active) {
        background: #f5f5f5;
        color: #6B7280;
      }

      .charts-view-toggle button:not(.active):hover {
        background: #e0e0e0;
      }

      /* Trends view responsive */
      @media (max-width: 640px) {
        #caloriesStats {
          grid-template-columns: repeat(2, 1fr) !important;
        }
        #macrosStats {
          grid-template-columns: 1fr !important;
          gap: 1.25rem !important;
        }
      }

      /* ========================================
        CHAT YUMII STYLES (v2.8)
        ======================================== */

      /* Layout container */
      .app-container {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        position: relative;
      }

      .chat-sidebar {
        width: 350px;
        min-width: 320px;
        max-width: 400px;
        background: white;
        border-right: 1px solid var(--light-gray);
        display: flex;
        flex-direction: column;
        transition: margin-left 0.3s ease;
      }

      .chat-sidebar.collapsed {
        margin-left: -350px;
      }

      .chat-header {
        padding: 1rem 1rem 0.75rem;
        border-bottom: 1px solid var(--light-gray);
        background: white;
        color: var(--text-dark);
        flex-shrink: 0;
      }

      .chat-collapse-btn {
        background: rgba(76, 175, 160, 0.08);
        border: 1px solid var(--light-gray);
        color: var(--primary);
        padding: 0.25rem 0.5rem;
        border-radius: 8px;
        cursor: pointer;
        font-size: 1rem;
        transition: all 0.2s;
      }

      .chat-collapse-btn:hover {
        background: rgba(76, 175, 160, 0.15);
      }

      .chat-web-search-form {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        height: 40px;
        margin-top: 0.875rem;
        padding: 0 0.5rem 0 0.875rem;
        background: white;
        border: 1px solid #d7dee8;
        border-radius: 16px;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
      }

      .chat-web-search-form:focus-within {
        border-color: rgba(76, 175, 160, 0.7);
        box-shadow: 0 0 0 3px rgba(76, 175, 160, 0.12);
      }

      .chat-web-search-input {
        min-width: 0;
        flex: 1;
        height: 100%;
        border: 0;
        outline: 0;
        background: transparent;
        color: var(--text-dark);
        font-family: 'Inter', system-ui, -apple-system, sans-serif;
        font-size: 0.9rem;
        line-height: 1;
      }

      .chat-web-search-input::placeholder {
        color: #64748b;
        opacity: 1;
      }

      .chat-web-search-input::-webkit-search-cancel-button {
        -webkit-appearance: none;
      }

      .chat-web-search-submit {
        width: 30px;
        height: 30px;
        border: 0;
        border-radius: 9px;
        background: transparent;
        color: #94a3b8;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: background 0.2s, color 0.2s;
      }

      .chat-web-search-submit:hover {
        background: rgba(76, 175, 160, 0.1);
        color: var(--primary-dark);
      }

      .chat-web-search-submit:active {
        transform: scale(0.96);
      }

      .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        padding-bottom: 3rem;
        background: #f8fcfb;
      }

      .chat-message {
        display: flex;
        gap: 0.75rem;
        margin-bottom: 1rem;
        animation: slideIn 0.3s ease;
      }

      @keyframes slideIn {
        from {
          opacity: 0;
          transform: translateY(10px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .chat-message.user {
        flex-direction: row-reverse;
      }

      .message-avatar {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        flex-shrink: 0;
      }

      .message-avatar img {
        width: 22px;
        height: 22px;
      }

      .chat-message.user .message-avatar {
        border-radius: 50%;
        background: white;
        border: 1px solid var(--light-gray);
        overflow: hidden;
      }

      .chat-message.user .message-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
      }

      .chat-message.user .message-avatar .chat-user-fallback {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--gray);
      }

      .message-content {
        flex: 1;
        max-width: 75%;
        min-width: 0;
      }

      /* I messaggi dell'assistente con tabelle si espandono a tutta larghezza */
      .chat-message.assistant .message-content {
        max-width: 100%;
      }

      .message-text {
        background: white;
        padding: 0.75rem 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        line-height: 1.5;
        word-wrap: break-word;
        font-family: 'Inter', system-ui, -apple-system, sans-serif;
        font-size: 0.9rem;
        color: var(--text-dark);
      }

      .chat-message.user .message-text {
        background: var(--primary);
        color: white;
      }

      .message-time {
        font-size: 0.625rem;
        margin-top: 0.25rem;
        padding-left: 0.5rem;
      }

      .chat-message .message-text p {
        margin: 0 0 0.35em 0;
      }
      .chat-message .message-text p:last-child {
        margin-bottom: 0;
      }
      .chat-message .message-text ul,
      .chat-message .message-text ol {
        margin: 0.25em 0 0.35em 1.25em;
        padding: 0;
      }
      .chat-message .message-text li {
        margin-bottom: 0.15em;
      }
      .chat-message .message-text code {
        background: rgba(0,0,0,0.08);
        border-radius: 3px;
        padding: 0.1em 0.3em;
        font-size: 0.85em;
        font-family: monospace;
      }
      .chat-message.user .message-text code {
        background: rgba(255,255,255,0.2);
      }
      .chat-message .message-text .md-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0.4em 0;
        border-radius: 6px;
      }
      .chat-message .message-text .md-table {
        border-collapse: collapse;
        width: 100%;
        min-width: 360px;
        font-size: 0.78rem;
        margin: 0;
      }
      .chat-message .message-text .md-table td,
      .chat-message .message-text .md-table th {
        border: 1px solid rgba(0,0,0,0.15);
        padding: 0.3em 0.5em;
        text-align: left;
      }
      .chat-message .message-text .md-table thead td {
        background: rgba(0,0,0,0.06);
        font-weight: 600;
      }
      .chat-message.user .message-text .md-table td,
      .chat-message.user .message-text .md-table th {
        border-color: rgba(255,255,255,0.3);
      }
      .chat-message.user .message-text .md-table thead td {
        background: rgba(255,255,255,0.15);
      }

      .chat-typing {
        display: flex;
        gap: 0.75rem;
        padding: 0 1rem 1rem 1rem;
        align-items: center;
      }

      .typing-dots {
        display: flex;
        gap: 0.25rem;
        padding: 0.75rem 1rem;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
      }

      .typing-dots span {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--gray);
        animation: bounce 1.4s infinite;
      }

      .typing-dots span:nth-child(2) {
        animation-delay: 0.2s;
      }

      .typing-dots span:nth-child(3) {
        animation-delay: 0.4s;
      }

      @keyframes bounce {
        0%,
        60%,
        100% {
          transform: translateY(0);
        }
        30% {
          transform: translateY(-10px);
        }
      }

      .chat-input-container {
        padding: 0.75rem 1rem;
        border-top: 1px solid var(--light-gray);
        background: white;
        display: flex;
        gap: 0.5rem;
        flex-shrink: 0;
      }

      .chat-input {
        flex: 1;
        padding: 0.625rem 0.75rem;
        border: 1px solid #e0e0e0;
        border-radius: 18px;
        font-size: 0.875rem;
        font-family: 'Inter', system-ui, -apple-system, sans-serif;
        background: #f8fcfb;
        resize: none;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        line-height: 1.4;
        max-height: 160px;
        min-height: 40px;
      }

      .chat-input::-webkit-scrollbar {
        display: none;
      }

      .chat-input:focus {
        outline: none;
        border-color: var(--primary);
        background: white;
      }

      .chat-send-btn {
        background: var(--primary);
        color: white;
        border: none;
        width: 38px;
        height: 38px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 1.1rem;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
      }

      .chat-send-btn:hover {
        background: var(--primary-dark);
        transform: scale(1.05);
      }

      .chat-send-btn:active {
        transform: scale(0.95);
      }

      /* Main Content Area */
      .main-content {
        flex: 1;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        background: var(--bg);
        background-attachment: fixed;
        position: relative;
        display: flex;
        flex-direction: column;
      }

      .main-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
      }

      .main-scroll > .container {
        width: 100%;
      }

      .app-footer {
        flex-shrink: 0;
        min-height: var(--app-footer-height);
        padding: 0.875rem 1rem;
        background: rgba(255, 255, 255, 0.88);
        border-top: 1px solid rgba(76, 175, 160, 0.18);
        box-shadow: 0 -1px 10px rgba(31, 41, 55, 0.04);
      }

      .app-footer-inner {
        width: 100%;
        max-width: 1200px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem 1.5rem;
        flex-wrap: wrap;
      }

      .app-footer-links {
        display: flex;
        align-items: center;
        gap: 1.25rem;
        flex-wrap: wrap;
      }

      .app-footer-links a {
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 0.8125rem;
        font-weight: 500;
        transition: color 0.2s ease;
      }

      .app-footer-links a:hover {
        color: var(--primary-dark);
      }

      .app-footer-copy {
        margin: 0;
        color: var(--text-muted);
        font-size: 0.75rem;
        line-height: 1.4;
      }

      #discoverView {
        position: relative;
        z-index: 1;
        overflow-y: visible;
        background: #fff;
        border-radius: 12px;
        background-clip: padding-box;
        box-sizing: border-box;
        padding: 0 0.875rem 1.5rem;
        -webkit-overflow-scrolling: touch;
      }

      .discover-inner {
        width: 100%;
        max-width: 980px;
        margin: 0 auto;
        padding: 0.875rem 0 1rem;
      }

      .discover-list {
        display: flex;
        flex-direction: column;
      }

      .discover-post {
        padding: 0 0 2rem;
        margin: 0 0 2rem;
        border-bottom: 1px solid #d1d5db;
      }

      .discover-post:last-child {
        border-bottom: 0;
        margin-bottom: 0;
      }

      .discover-post-image-link {
        display: block;
        color: inherit;
        text-decoration: none;
      }

      .discover-post-image {
        display: block;
        width: 100%;
        aspect-ratio: 2.58 / 1;
        max-height: 340px;
        object-fit: cover;
        border-radius: 6px;
        background: var(--light-gray);
      }

      .discover-post-title {
        margin: 0.875rem 0 0;
        color: #1F2937;
        font-family: inherit;
        font-size: 0.875rem;
        line-height: 1.35;
        font-weight: 700;
        letter-spacing: 0;
      }

      .discover-post-title-link {
        color: inherit;
        text-decoration: none;
      }

      .discover-post-title-link:hover {
        text-decoration: underline;
      }

      .discover-post-image-link:focus-visible,
      .discover-post-title-link:focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: 3px;
        border-radius: 6px;
      }

      .discover-post-meta {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        margin-top: 0.75rem;
        color: #4b5563;
        font-family: inherit;
        font-size: 0.875rem;
        line-height: 1.35;
      }

      .discover-post-meta::before {
        content: "";
        width: 13px;
        height: 13px;
        flex: 0 0 13px;
        background: currentColor;
        -webkit-mask: 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='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4'/%3E%3Cpath d='M16 2v4'/%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M3 10h18'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: 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='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4'/%3E%3Cpath d='M16 2v4'/%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M3 10h18'/%3E%3C/svg%3E") center / contain no-repeat;
      }

      .discover-post-excerpt {
        margin: 0.875rem 0 0;
        color: #444;
        font-family: inherit;
        font-size: 0.875rem;
        line-height: 1.45;
      }

      .discover-state {
        min-height: 45vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        padding: 2rem 1rem;
        color: var(--text-secondary);
        text-align: center;
      }

      .discover-state.hidden {
        display: none !important;
      }

      .discover-state p {
        margin: 0;
        font-family: inherit;
        font-size: 0.875rem;
        line-height: 1.5;
      }

      .discover-retry-btn {
        border: 1px solid var(--primary);
        border-radius: 8px;
        background: #fff;
        color: var(--primary-dark);
        font-family: inherit;
        font-size: 0.875rem;
        font-weight: 700;
        padding: 0.55rem 1rem;
        cursor: pointer;
      }

      .discover-retry-btn:hover {
        background: var(--primary-light);
      }

      @media (min-width: 768px) {
        #discoverView {
          padding-top: 1rem;
          padding-left: 1rem;
          padding-right: 1rem;
        }

        .discover-inner {
          padding-top: 0;
        }

        .discover-post {
          padding-bottom: 2.5rem;
          margin-bottom: 2.5rem;
        }
      }

      .main-content.expanded {
        margin-left: 0;
      }

      /* Mobile Chat Modal */
      .mobile-chat-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 10000; /* ✅ Sopra header (9999) */
        flex-direction: column;
      }

      .mobile-chat-modal.open {
        display: flex;
      }

      /* ✅ DESKTOP: Floating window stile Render/Intercom */
      @media (min-width: 768px) {
        .mobile-chat-modal {
          top: auto;
          left: auto;
          right: 20px;
          bottom: 100px; /* Sopra floating button */
          width: 400px;
          max-width: calc(100vw - 40px);
          height: 600px;
          max-height: calc(100vh - 140px);
          border-radius: 12px;
          box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
          border: 1px solid var(--light-gray);
        }

        /* NON nascondere header/floating-button su desktop */
        body:has(.mobile-chat-modal.open) .header,
        body:has(.mobile-chat-modal.open) .floating-chat-button {
          display: flex !important; /* Resta visibile */
        }

        /* ✅ Tab-bar SEMPRE nascosta su desktop (è solo mobile) */
        body:has(.mobile-chat-modal.open) .tab-bar {
          display: none !important;
        }
      }

      /* MOBILE: Nasconde tutto quando chat è aperta */
      @media (max-width: 767px) {
        body:has(.mobile-chat-modal.open) .header {
          display: none !important;
        }

        body:has(.mobile-chat-modal.open) .tab-bar {
          display: none !important;
        }

        body:has(.mobile-chat-modal.open) .floating-chat-button {
          display: none !important;
        }
      }

      .mobile-chat-header {
        padding: 1rem;
        background: white;
        color: var(--text-dark);
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
        border-bottom: 1px solid var(--light-gray);
      }

      /* ✅ DESKTOP: Header con border-radius top per floating window */
      @media (min-width: 768px) {
        .mobile-chat-header {
          border-radius: 12px 12px 0 0;
        }
      }

      .mobile-chat-close {
        background: rgba(76, 175, 160, 0.08);
        border: 1px solid var(--light-gray);
        color: var(--gray);
        font-size: 1.25rem;
        font-weight: 400;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
      }

      .mobile-chat-close:hover {
        background: rgba(76, 175, 160, 0.15);
        transform: scale(1.05);
      }

      .mobile-chat-close:active {
        transform: scale(0.95);
      }

      .mobile-chat-web-search-form {
        margin: 0.75rem 1rem 0.25rem;
        flex-shrink: 0;
      }

      .mobile-chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        padding-bottom: 3rem;
        background: linear-gradient(135deg, #54B4A5 0%, #eaeafc 80%);
      }

      .mobile-chat-input-container {
        padding: 1rem;
        border-top: 1px solid var(--light-gray);
        background: white;
        display: flex;
        gap: 0.5rem;
        flex-shrink: 0;
      }

      /* Responsive */
      @media (max-width: 768px) {
        .chat-sidebar {
          display: none !important;
        }

        .chat-expand-btn {
          display: none; /* ← AGGIUNGI QUESTA RIGA */
        }

        .chat-fab {
          display: flex;
          align-items: center;
          justify-content: center;
        }

        .main-content {
          width: 100%;
        }

        .app-container {
          height: auto;
        }
      }

      .chat-expand-btn {
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        background: var(--primary-gradient);
        color: white;
        border: none;
        padding: 1rem 0.5rem;
        border-radius: 0 8px 8px 0;
        cursor: pointer;
        font-size: 1.25rem;
        z-index: 200;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
        transition: all 0.3s;
        display: block; /* ← AGGIUNTO: visibile di default */
      }

      .chat-expand-btn:hover {
        padding-left: 0.75rem;
      }

      /* FASE 5 - DASHBOARD COMPATTA */
      .date-selector {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0rem 0rem 0.5rem 0em;
        margin-bottom: 0px;
      }

      .date-arrow {
        border: none;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        font-size: 1.125rem;
        cursor: pointer;
        transition: background 0.2s ease;
      }

      .date-arrow:hover {
        background: #e8e8e8;
      }

      .date-current {
        flex: 1;
        color: white;
        border: none;
        padding: 0.75rem 1.5rem;
        border-radius: 12px;
        font-weight: 800;
        font-size: 1.25rem;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
      }

      .dashboard-compact {
        background: white;
        border-radius: 20px;
        padding: 1.5rem 1.25rem 1.25rem;
        margin-bottom: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        align-items: center;
      }

      .calorie-ring-container {
        position: relative;
        width: 180px;
        height: 180px;
        margin-bottom: 0.5rem;
      }

      .calorie-text {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
      }

      .calorie-current {
        font-size: 2rem;
        font-weight: 700;
        color: var(--text-primary);
        line-height: 1;
      }

      .calorie-separator {
        font-size: 1.1rem;
        color: #94a3b8;
        margin: 2px 0;
      }

      .calorie-target {
        font-size: 1.1rem;
        font-weight: 600;
        color: #64748b;
      }

      .calorie-label {
        font-size: 0.75rem;
        color: black;
        margin-top: 2px;
        text-transform: uppercase;
      }

      #dashboardProgressCircle {
        transition: stroke-dashoffset 0.6s ease;
      }

      #dashboardExcessCircle {
        transition: stroke-dashoffset 0.6s ease, opacity 0.4s ease;
      }

      /* Macro pills row */
      .macro-pills {
        display: flex;
        gap: 8px;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
      }

      .macro-pill {
        flex: 1;
        background: #f8f8f8;
        border-radius: 12px;
        padding: 8px 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        min-width: 0;
      }

      .macro-pill-name {
        font-size: 13px;
        color: var(--text-primary);
        white-space: nowrap;
        line-height: 1;
        font-weight: 700;
      }

      .macro-pill-values {
        display: flex;
        align-items: baseline;
        gap: 2px;
      }

      .macro-pill-value {
        font-size: 12px;
        color: var(--text-muted);
        line-height: 1;
      }

      .macro-pill-goal {
        font-size: 12px;
        color: var(--text-muted);
        line-height: 1;
      }

      .macro-pill-bar-track {
        width: 100%;
        height: 5px;
        background: #e8e8e8;
        border-radius: 2px;
        margin-top: 5px;
        overflow: hidden;
      }

      .macro-pill-bar-fill {
        height: 100%;
        border-radius: 2px;
        transition: width 0.6s ease;
        width: 0%;
      }
      .macro-pill-bar-fill.carbs   { background: var(--macro-carbs); }
      .macro-pill-bar-fill.protein { background: var(--macro-protein); }
      .macro-pill-bar-fill.fats    { background: var(--macro-fats); }

      .macro-pill.carbs   { background: rgba(244, 162, 97, 0.12); border: 1px solid rgba(244, 162, 97, 0.3); }
      .macro-pill.protein { background: rgba(76, 175, 160, 0.12); border: 1px solid rgba(76, 175, 160, 0.3); }
      .macro-pill.fats    { background: rgba(231, 111, 81, 0.12); border: 1px solid rgba(231, 111, 81, 0.3); }

      .macro-pill.carbs   .macro-pill-name { color: #c4692a; }
      .macro-pill.protein .macro-pill-name { color: #3d9e90; }
      .macro-pill.fats    .macro-pill-name { color: #b84e2a; }

      .macro-pill.carbs   .macro-pill-bar-track { background: rgba(244, 162, 97, 0.2); }
      .macro-pill.protein .macro-pill-bar-track { background: rgba(76, 175, 160, 0.2); }
      .macro-pill.fats    .macro-pill-bar-track { background: rgba(231, 111, 81, 0.2); }

      .calorie-card {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        width: 100%;
        gap: 8px;
      }

      .calorie-side-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        flex: 1;
        background: none;
        border: none;
        padding: 0;
        font-family: inherit;
        cursor: default;
      }

      button.calorie-side-stat {
        cursor: pointer;
      }

      .calorie-side-label {
        font-size: 11px;
        color: black;
        letter-spacing: 0.04em;
        text-transform: uppercase;
      }

      .calorie-side-value {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-primary);
      }

      /* ==========================================
        PROFILE & SETTINGS VIEWS
        ========================================== */

      /* Base card condivisa — stesso padding di .card */
      .profile-section-card,
      .settings-section-card {
        background: white;
        border-radius: 20px;
        padding: 1.5rem;
        margin-bottom: 12px;
        box-shadow: var(--shadow);
      }

      @media (max-width: 768px) {
        .profile-section-card,
        .settings-section-card {
          padding: 1.25rem;
          border-radius: 12px;
        }
      }

      @media (max-width: 480px) {
        .profile-section-card,
        .settings-section-card {
          padding: 1rem;
          border-radius: 12px;
        }
      }

      .profile-section-title {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
      }

      /* Header dentro la prima card */
      .profile-header-row {
        display: flex;
        align-items: center;
        gap: 14px;
        margin-bottom: 20px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--border-color);
      }

      .profile-avatar {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: white;
        border: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        flex-shrink: 0;
        overflow: hidden;
        position: relative;
      }
      .profile-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
      }
      .profile-avatar .profile-avatar-fallback {
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .profile-header-info {
        flex: 1;
        min-width: 0;
      }

      .profile-header-name {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .profile-header-sub {
        font-size: 12px;
        color: var(--text-muted);
        margin-top: 1px;
      }

      .btn-sm {
        padding: 6px 10px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
        white-space: nowrap;
      }

      /* Griglia dati anagrafici 3 colonne */
      .profile-data-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        margin-bottom: 0;
      }

      .profile-data-item {
        display: flex;
        flex-direction: column;
        gap: 2px;
      }

      .profile-data-label {
        font-size: 11px;
        color: var(--text-muted);
      }

      .profile-data-value {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
      }

      /* Riga singola label + valore */
      .profile-row-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-top: 1px solid var(--border-color);
      }

      .profile-row-item:last-child {
        padding-bottom: 0;
      }

      /* Metabolismo: 3 metriche in riga */
      .profile-metric-grid {
        display: flex;
        align-items: center;
      }

      .profile-metric {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
      }

      .profile-metric--primary .profile-metric-value {
        color: var(--primary);
      }

      .profile-metric-value {
        font-size: 22px;
        font-weight: 700;
        color: var(--text-primary);
        line-height: 1;
      }

      .profile-metric-label {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-secondary);
      }

      .profile-metric-sub {
        font-size: 10px;
        color: var(--text-muted);
      }

      .profile-metric-divider {
        width: 1px;
        height: 40px;
        background: var(--border-color);
        flex-shrink: 0;
      }

      /* Macro pillole */
      .profile-macro-row {
        display: flex;
        gap: 8px;
        margin-bottom: 0;
        padding-top: 12px;
      }

      .profile-macro-item {
        flex: 1;
        background: #f8f8f8;
        border-radius: 12px;
        padding: 10px 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
      }

      .profile-macro-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
      }

      .profile-macro-name {
        font-size: 10px;
        color: var(--text-muted);
        text-align: center;
      }

      .profile-macro-value {
        font-size: 15px;
        font-weight: 700;
        color: var(--text-primary);
        text-align: center;
      }

      .profile-macro-value--sm {
        font-size: 12px;
        font-weight: 600;
      }

      .profile-macro-sub {
        font-size: 9px;
        color: var(--text-muted);
        text-align: center;
      }

      .profile-macro-item--primary .profile-macro-value {
        color: var(--primary);
      }

      .profile-macro-item--bmr .profile-macro-value {
        color: #3498db;
      }

      .profile-macro-item--tdee .profile-macro-value {
        color: #f39c12;
      }

      /* Profile modal calc section */
      .profile-calc-section {
        background: #f8f8f8;
        border-radius: 14px;
        padding: 1rem;
        margin-top: 1.25rem;
      }

      /* Settings */
      .settings-section-card {
        padding-bottom: 4px;
      }

      .settings-row-btn {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 0  ;
        background: none;
        border: none;
        border-top: 1px solid var(--border-color);
        cursor: pointer;
        font-family: inherit;
        font-size: 15px;
        color: var(--text-primary);
        text-align: left;
      }

      .settings-row-btn:first-of-type {
        border-top: none;
      }

      .settings-row-icon {
        font-size: 18px;
        width: 24px;
        text-align: center;
        flex-shrink: 0;
      }

      .settings-row-label {
        flex: 1;
        font-weight: 500;
      }

      .settings-row-arrow {
        font-size: 18px;
        color: var(--text-muted);
      }

      .settings-row-btn--danger .settings-row-label {
        color: var(--danger);
      }

      .settings-row-link {
        text-decoration: none;
      }

      .mobile-settings-links-card {
        display: none;
      }

      /* Settings row con gating premium: chip inline, nessuna bordatura */
      .settings-row-btn.premium-locked {
        border: none !important;
        border-top: 1px solid var(--border-color) !important;
        margin-top: 0;
        opacity: 1;
      }
      .settings-row-btn.premium-locked:first-of-type {
        border-top: none !important;
      }
      .settings-row-btn.premium-locked + * {
        margin-top: 0;
      }
      .settings-row-btn.premium-locked > .premium-chip {
        position: static;
        top: auto;
        right: auto;
        margin-left: auto;
        align-self: center;
        order: 2;
      }

      /* Settings: riga info (non cliccabile) */
      .settings-row-info {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 0;
        border-top: none;
        font-family: inherit;
        font-size: 15px;
        color: var(--text-primary);
      }

      .settings-row-version {
        margin-left: auto;
        font-size: 13px;
        font-weight: 600;
        color: var(--primary);
      }

      .legal-history-list {
        display: grid;
        gap: 14px;
      }

      .legal-history-empty,
      .legal-history-loading {
        color: var(--text-muted);
        font-size: 0.9375rem;
        padding: 0.25rem 0;
      }

      .legal-history-group {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
      }

      .legal-history-group-title {
        padding: 12px 14px;
        background: #f8fafc;
        color: var(--text-primary);
        font-size: 0.875rem;
        font-weight: 700;
      }

      .legal-history-item {
        display: grid;
        gap: 8px;
        padding: 12px 14px;
        border-top: 1px solid var(--border-color);
      }

      .legal-history-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 14px;
        color: var(--text-muted);
        font-size: 0.8125rem;
      }

      .legal-history-link {
        color: var(--primary);
        font-size: 0.875rem;
        font-weight: 700;
        text-decoration: none;
      }

      .legal-history-link:hover {
        text-decoration: underline;
      }

      /* Export modal */
      .export-modal-group {
        padding: 1rem 1.5rem 0.25rem;
      }

      .export-modal-group + .export-modal-group {
        border-top: 1px solid var(--border-color);
      }

      .export-modal-section-title {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        margin-bottom: 4px;
      }

      .export-modal-row {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 13px 0;
        background: none;
        border: none;
        border-top: 1px solid var(--border-color);
        cursor: pointer;
        font-family: inherit;
        font-size: 15px;
        color: var(--text-primary);
        text-align: left;
      }

      .export-modal-row:first-of-type {
        border-top: none;
      }

      .export-modal-row:hover .export-modal-label {
        color: var(--primary);
      }

      .export-modal-icon {
        font-size: 18px;
        width: 24px;
        text-align: center;
        flex-shrink: 0;
      }

      .export-modal-label {
        flex: 1;
        font-weight: 500;
        transition: color 0.15s ease;
      }

      .export-field {
        margin-bottom: 1rem;
      }
      .export-field-label {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        margin-bottom: 6px;
      }
      .export-segmented {
        display: flex;
        gap: 6px;
        background: var(--background, #f4f4f5);
        border-radius: 10px;
        padding: 4px;
      }
      .export-segment {
        flex: 1;
        padding: 8px 10px;
        border: none;
        background: transparent;
        font-family: inherit;
        font-size: 14px;
        font-weight: 500;
        color: var(--text-muted);
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
      }
      .export-segment.is-active {
        background: #fff;
        color: var(--text-primary);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
      }
      .export-submit-btn {
        width: 100%;
        margin-top: 0.5rem;
      }
      .export-segmented--wrap {
        flex-wrap: wrap;
      }
      .export-segmented--wrap .export-segment {
        flex: 1 1 calc(50% - 6px);
      }
      .export-custom-range {
        display: flex;
        gap: 8px;
        margin-top: 8px;
      }
      .export-custom-field {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
      }
      .export-custom-field label {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
      }
      .export-custom-field input[type="date"] {
        padding: 8px 10px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        font-family: inherit;
        font-size: 14px;
        color: var(--text-primary);
        background: #fff;
      }

      /* Legacy bar styles (kept for other uses) */
      .macro-bars {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1.5rem;
      }

      .macro-bar-item {
        background: #fafafa;
        padding: 0.875rem;
        border-radius: 10px;
      }

      .macro-bar-header {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
      }

      .macro-icon { font-size: 1.25rem; }
      .macro-name { font-weight: 600; color: #334155; }

      .macro-value {
        margin-left: auto;
        font-weight: 600;
        font-size: 0.875rem;
        color: #64748b;
      }

      .macro-bar-track {
        height: 8px;
        background: #f1f5f9;
        border-radius: 4px;
        overflow: hidden;
      }

      .macro-bar-fill {
        height: 100%;
        border-radius: 4px;
        transition: width 0.6s ease;
      }

      .macro-bar-fill.carbs   { background: var(--macro-carbs); }
      .macro-bar-fill.protein { background: var(--macro-protein); }
      .macro-bar-fill.fats    { background: var(--macro-fats); }

      /* ==========================================
        MEAL TYPE GRID - Home Page
        ========================================== */
      .meal-type-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
      }

      .meal-type-btn {
        background: white;
        border-radius: 16px;
        padding: 14px 18px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 1px 6px rgba(0,0,0,0.04);
        cursor: pointer;
        transition: box-shadow 0.15s ease;
        user-select: none;
      }

      .meal-type-btn:hover {
        box-shadow: 0 2px 12px rgba(0,0,0,0.08);
      }

      .meal-type-btn-left {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
        min-width: 0;
      }

      .meal-type-icon {
        width: 50px;
        height: 50px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        flex-shrink: 0;
      }

      .meal-type-icon.colazione { background: #fff3e0; }
      .meal-type-icon.pranzo { background: #e8f5e9; }
      .meal-type-icon.cena { background: #e3f2fd; }
      .meal-type-icon.snack { background: #fce4ec; }

      .meal-type-info {
        display: flex;
        flex-direction: column;
        min-width: 0;
      }

      .meal-type-name {
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary);
      }

      .meal-type-subtitle {
        font-size: 12px;
        color: var(--text-muted);
        margin-top: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .meal-type-btn-right {
        display: flex;
        align-items: center;
        gap: 10px;
      }

      .meal-type-kcal {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary);
      }

      .meal-type-add {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        font-size: 18px;
        display: flex;
        align-items: baseline;
        justify-content: center;
        cursor: pointer;
        transition: background 0.2s ease;
        flex-shrink: 0;
      }

      .meal-type-add:hover {
        background: var(--primary-dark);
      }

      /* ==========================================
        HYDRATION CARD
        ========================================== */
      .hydration-card {
        background: white;
        border-radius: 16px;
        padding: 16px 18px;
        box-shadow: 0 1px 6px rgba(0,0,0,0.04);
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
      }

      .hydration-title {
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary);
      }

      .hydration-glasses {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: flex-end;
      }

      @media (max-width: 768px) {
        .hydration-glasses {
          display: grid;
          grid-template-columns: repeat(8, 36px);
          justify-content: center;
          gap: 8px;
        }
      }

      .hydration-glass {
        width: 36px;
        height: 44px;
        cursor: pointer;
        transition: transform 0.15s;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .hydration-glass:hover {
        transform: scale(1.15);
      }

      .hydration-glass:active {
        transform: scale(0.9);
      }

      .hydration-glass img {
        width: 36px;
        height: 44px;
        object-fit: contain;
      }

      .hydration-glass-add {
        position: relative;
      }

      .hydration-glass-add .hydration-plus {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 20px;
        font-weight: 700;
        color: #42a5f5;
        pointer-events: none;
        line-height: 1;
      }

      .hydration-total {
        font-size: 20px;
        font-weight: 600;
        color: #2196F3;
        display: flex;
        align-items: baseline;
        gap: 6px;
      }

      .hydration-water-label {
        font-size: 17px;
        font-weight: 600;
        color: var(--text-muted);
      }

      .hydration-primary {
        font-size: 20px;
        font-weight: 700;
      }

      .hydration-secondary {
        font-size: 14px;
        font-weight: 600;
        color: #5f9fce;
      }

      @media (max-width: 768px) {
        .hydration-total {
          font-size: 25px;
          font-weight: 700;
          flex-direction: column;
          align-items: center;
          gap: 2px;
          text-align: center;
        }

        .hydration-water-label {
          font-size: 13px;
          font-weight: 600;
        }

        .hydration-primary {
          font-size: 25px;
        }

        .hydration-secondary {
          font-size: 14px;
        }
      }

      /* ==========================================
        NOTES CARD
        ========================================== */
      .notes-card {
        background: white;
        border-radius: 16px;
        padding: 16px 18px;
        box-shadow: 0 1px 6px rgba(0,0,0,0.04);
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
      }

      .notes-card-header {
        display: flex;
        align-items: center;
        gap: 10px;
      }

      .notes-card-header img {
        width: 30px;
        height: 30px;
        object-fit: contain;
      }

      .notes-card-titles {
        flex: 1;
      }

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

      .notes-card-subtitle {
        font-size: 12px;
        color: var(--text-muted);
        margin-top: 2px;
      }

      .notes-add-btn {
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 10px;
        padding: 8px 18px;
        font-family: inherit;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.15s;
      }

      .notes-add-btn:hover {
        background: var(--primary-dark);
      }

      .notes-content-text {
        font-size: 14px;
        color: var(--text-secondary);
        line-height: 1.5;
        white-space: pre-wrap;
        cursor: pointer;
        padding: 8px 10px;
        border-radius: 10px;
        background: #f8f8f8;
        transition: background 0.15s;
      }

      .notes-content-text:hover {
        background: #f0f0f0;
      }

      .notes-modal-textarea {
        width: 100%;
        min-height: 120px;
        border: 1.5px solid #e0e0e0;
        border-radius: 12px;
        padding: 12px;
        font-family: inherit;
        font-size: 14px;
        color: var(--text-primary);
        resize: vertical;
        outline: none;
        transition: border-color 0.2s;
        box-sizing: border-box;
        margin-bottom: 4px;
      }

      .notes-modal-textarea:focus {
        border-color: var(--primary);
      }

      .notes-modal-charcount {
        font-size: 11px;
        color: var(--text-muted);
        text-align: right;
        margin-bottom: 12px;
      }

      /* ==========================================
        MEAL TYPE DETAIL VIEW
        ========================================== */
      .meal-type-detail-card {
        padding-bottom: 1rem;
      }

      .meal-type-detail-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 0;
        margin-bottom: 12px;
      }

      .meal-type-back-btn {
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px;
        color: var(--text-primary);
        display: flex;
        align-items: center;
      }

      .meal-type-detail-title {
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
      }

      .meal-type-totals-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1px;
        background: var(--border-color);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        overflow: hidden;
        margin-bottom: 20px;
      }

      .meal-type-total-cell {
        background: white;
        padding: 14px 12px;
        text-align: center;
      }

      .meal-type-total-value-cal    { color: var(--primary); font-size: 20px; font-weight: 700;}
      .meal-type-total-value-carb   { color: #c4692a; font-size: 20px; font-weight: 700; }
      .meal-type-total-value-protein { color: #3d9e90; font-size: 20px; font-weight: 700; }
      .meal-type-total-value-fats    { color: #b84e2a; font-size: 20px; font-weight: 700; } 

      .meal-type-total-label {
        font-size: 12px;
        margin-top: 2px;
        color:black
      }

      .meal-type-items-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 16px;
      }

      /* Card-button per ogni pasto nella lista tipologia */
      .meal-type-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        background: white;
        border: 1.5px solid var(--border-color);
        border-radius: 14px;
        cursor: pointer;
        transition: border-color 0.15s, box-shadow 0.15s;
        text-align: left;
        width: 100%;
      }

      .meal-type-item:hover {
        border-color: var(--primary);
        box-shadow: 0 2px 8px rgba(76,175,160,0.1);
      }

      .meal-type-item:active {
        transform: scale(0.985);
      }

      .meal-type-item-thumb {
        width: 48px;
        height: 48px;
        border-radius: 10px;
        object-fit: cover;
        flex-shrink: 0;
      }

      .meal-type-item-thumb-placeholder {
        width: 48px;
        height: 48px;
        border-radius: 10px;
        background: rgba(76,175,160,0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        flex-shrink: 0;
      }

      .meal-type-item-info {
        flex: 1;
        min-width: 0;
      }

      .meal-type-item-name {
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .meal-type-item-desc {
        font-size: 12px;
        color: var(--text-muted);
        margin-top: 1px;
      }

      .meal-type-item-right {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        flex-shrink: 0;
      }

      .meal-type-item-kcal {
        font-size: 14px;
        font-weight: 700;
        color: var(--primary-dark);
      }

      .meal-type-item-kcal-label {
        font-size: 11px;
        color: var(--text-muted);
      }

      .meal-type-item-arrow {
        color: #ccc;
        font-size: 16px;
      }

      /* Modal pasto ridisegnata */
      .meal-modal-macros {
        background: white;
        border-radius: 14px;
        padding: 14px 16px;
        margin-bottom: 1rem;
      }

      .meal-modal-kcal-row {
        display: flex;
        align-items: baseline;
        gap: 0.375rem;
        margin-bottom: 0.75rem;
      }

      .meal-modal-kcal-label {
        font-size: 0.9375rem;
        color: var(--primary);
        font-weight: 800;
      }

      .meal-modal-kcal-value {
        font-size: 0.9375rem;
        font-weight: 800;
        color: var(--primary-dark);
      }

      .meal-modal-kcal-unit {
        font-size: 0.8125rem;
        color: var(--primary);
        margin-left: 2px;
      }

      .meal-modal-macros-row {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
      }

      .meal-modal-macro-cell {
        background: white;
        border-radius: 10px;
        padding: 8px 10px;
        text-align: left;
      }

      .meal-modal-macro-cell.carbs   { background: rgba(244, 162, 97, 0.12); border: 1px solid rgba(244, 162, 97, 0.3); }
      .meal-modal-macro-cell.protein { background: rgba(76, 175, 160, 0.12); border: 1px solid rgba(76, 175, 160, 0.3); }
      .meal-modal-macro-cell.fats    { background: rgba(231, 111, 81, 0.12); border: 1px solid rgba(231, 111, 81, 0.3); }
      .meal-modal-macro-cell.alcohol { grid-column: 1 / -1; background: rgba(139, 94, 131, 0.12); border: 1px solid rgba(139, 94, 131, 0.3); }

      .meal-modal-macro-cell.carbs   .meal-modal-macro-label { color: #c4692a; }
      .meal-modal-macro-cell.protein .meal-modal-macro-label { color: #3d9e90; }
      .meal-modal-macro-cell.fats    .meal-modal-macro-label { color: #b84e2a; }
      .meal-modal-macro-cell.alcohol .meal-modal-macro-label { color: var(--macro-alcohol-dark); }

      .meal-modal-macro-label {
        font-size: 0.75rem;
        color: var(--gray);
        margin-bottom: 3px;
      }

      .meal-modal-macro-value {
        font-size: 0.9375rem;
        font-weight: 700;
      }

      .meal-modal-macro-unit {
        font-size: 0.6875rem;
        color: var(--gray);
      }

      .meal-item-macros .meal-modal-macro-cell {
        background: transparent;
        border: none;
      }
      .meal-item-macros .meal-modal-macro-cell.alcohol {
        background: rgba(139, 94, 131, 0.12);
        border: 1px solid rgba(139, 94, 131, 0.3);
      }
      .meal-item-macros .meal-modal-macro-label {
        color: #2d3748;
        font-weight: 700;
      }
      .meal-item-macros .meal-modal-macro-cell.alcohol .meal-modal-macro-label {
        color: var(--macro-alcohol-dark);
      }
      .meal-item-macros .meal-modal-macro-value {
        color: #2d3748;
        font-weight: 400;
      }
      .meal-item-macros .meal-modal-macro-cell.alcohol .meal-modal-macro-value {
        color: var(--macro-alcohol);
        font-weight: 700;
      }
      .meal-item-macros .meal-modal-macro-unit {
        color: #2d3748;
      }

      .meal-modal-section-title {
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--gray);
        margin: 1rem 0 0.5rem;
      }

      .meal-modal-items-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
      }

      .meal-modal-item-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        background: rgba(76,175,160,0.1);
        border-radius: 10px;
        font-size: 0.875rem;
        color: #2d3748;
        font-weight: 500;
      }

      .portion-notes-items {
        display: flex;
        flex-direction: column;
        gap: 8px;
      }

      .portion-notes-item {
        border-radius: 10px;
        overflow: hidden;
      }

      .portion-notes-item-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
        padding: 8px 12px 6px;
      }

      .portion-notes-item-name {
        font-size: 0.875rem;
        font-weight: 600;
        color: #2d3748;
        flex: 1;
      }

      .portion-notes-item-sub {
        font-size: 0.75rem;
        font-weight: 400;
        color: var(--gray);
        display: block;
        margin-top: 1px;
      }

      .portion-notes-item-dosage {
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--primary);
        white-space: nowrap;
        padding-top: 1px;
      }

      .portion-notes-item-macros {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        border-top: 1px solid rgba(76,175,160,0.15);
        padding: 5px 12px 7px;
        gap: 4px;
      }

      .portion-notes-macro {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1px;
      }

      .portion-notes-macro-label {
        font-size: 0.625rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--gray);
      }

      .portion-notes-macro-value {
        font-size: 0.8125rem;
        font-weight: 600;
      }

      .portion-notes-summary {
        font-size: 0.8rem;
        color: var(--text-secondary);
        padding: 12px 4px 2px;
        line-height: 1.4;
      }

      .meal-modal-images-single {
        display: flex;
        justify-content: center;
        margin-bottom: 1rem;
      }

      .meal-modal-images-single img {
        max-width: 100%;
        max-height: 260px;
        width: auto;
        border-radius: 14px;
        object-fit: cover;
      }

      .meal-modal-images-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
        margin-bottom: 1rem;
      }

      .meal-modal-images-grid img {
        width: 100%;
        aspect-ratio: 1;
        object-fit: cover;
        border-radius: 10px;
      }

      .meal-type-empty {
        text-align: center;
        padding: 2rem 1rem;
        color: var(--text-muted);
        font-size: 14px;
      }

      .btn-add-meal-big {
        width: 100%;
        background: var(--primary);
        color: white;
        border: none;
        padding: 1rem;
        border-radius: 12px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.2s ease;
      }

      .btn-add-meal-big:hover {
        background: var(--primary-dark);
      }

      /* ===== FASE 6 - CARD VERTICALI + SWIPE ===== */

      .meal-card-vertical {
        background: white;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        margin-bottom: 1rem;
        transition:
          transform 0.2s,
          box-shadow 0.2s;
      }

      .meal-card-vertical:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
      }

      .meal-swipe-wrapper {
        position: relative;
        overflow: hidden;
      }

      .meal-swipe-content {
        position: relative;
        transition: transform 0.3s ease;
        cursor: grab;
      }

      .meal-swipe-content:active {
        cursor: grabbing;
      }

      .swipe-actions-left,
      .swipe-actions-right {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 80px;
        display: flex;
        opacity: 0;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
      }

      .swipe-actions-left {
        left: 0;
        background: #3b82f6;
      }

      .swipe-actions-right {
        right: 0;
        background: #e76f7a;
      }

      .meal-image-container {
        position: relative;
        width: 100%;
        aspect-ratio: 16/9;
        overflow: hidden;
      }

      .meal-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
      }

      .meal-image-placeholder {
        width: 100%;
        height: 150px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f8fcfb;
        font-size: 4rem;
      }

      @media (min-width: 768px) {
        .meal-image-placeholder {
          display: none;
        }
      }

      .meal-card-body {
        padding: 1rem;
      }

      .meal-card-header-vertical {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
      }

      .meal-type-time {
        flex: 1;
      }

      .meal-type-name {
        font-weight: 600;
        font-size: 1.125rem;
        color: #1e293b;
      }

      .meal-time-date {
        font-size: 0.875rem;
        color: #64748b;
      }

      .meal-calories-large {
        text-align: center;
        margin: 1rem 0;
      }

      .calories-number {
        font-size: 2.5rem;
        font-weight: 700;
        color: #4CAFA0;
        line-height: 1;
      }

      .calories-label {
        font-size: 0.875rem;
        color: #64748b;
        margin-top: 0.25rem;
      }

      .meal-macros-badges {
        display: flex;
        gap: 0.5rem;
        justify-content: center;
        margin-bottom: 1rem;
      }

      .macro-badge {
        padding: 0.5rem 1rem;
        border-radius: 12px;
        font-weight: 600;
        font-size: 0.875rem;
      }

      .macro-badge.carbs {
        background: rgba(244, 162, 97, 0.15);
        color: #c4692a;
      }

      .macro-badge.protein {
        background: #d1fae5;
        color: #065f46;
      }

      .macro-badge.fats {
        background: rgba(231, 111, 81, 0.15);
        color: #b84e2a;
      }

      .meal-description {
        font-size: 0.875rem;
        color: #64748b;
        line-height: 1.5;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }

      .meal-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid #f1f5f9;
      }

      .btn-meal-action {
        flex: 1;
        padding: 0.5rem;
        border: none;
        border-radius: 8px;
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
      }

      .btn-meal-duplicate {
        background: #f1f5f9;
        color: #475569;
      }

      .btn-meal-duplicate:hover {
        background: #e2e8f0;
      }

      /* ===== FASE 7 - TAB BAR + FLOATING CHAT ===== */

      /* Tab Bar Container */
      .tab-bar {
        position: fixed;
        bottom: max(12px, env(safe-area-inset-bottom));
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
        height: 68px;
        background: white;
        border-radius: 12px;
        border: none;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0 8px;
        z-index: 9999;
        overflow: visible;
        box-shadow: 0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
      }

      /* Tab Item (bottom nav) */
      .tab-bar .tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        border: none;
        background: none !important;
        cursor: pointer;
        padding: 0.5rem;
        transition: color 0.2s;
        color: #94a3b8;
        gap: 2px;
      }

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

      .tab-bar .tab:disabled,
      .tab-bar .tab.is-disabled {
        color: #cbd5e1;
        cursor: not-allowed;
        opacity: 0.55;
      }

      .tab-bar .tab:disabled:hover,
      .tab-bar .tab.is-disabled:hover {
        color: #cbd5e1;
      }

      .tab-bar .tab.active {
        background: none !important;
        color: var(--primary-dark) !important;
      }

      .tab-bar .tab.active .tab-icon-wrap::after {
        content: '';
        display: block;
        position: absolute;
        bottom: -20px;
        left: 50%;
        transform: translateX(-50%);
        width: 28px;
        height: 3px;
        border-radius: 999px;
        background: var(--primary);
      }

      /* Tab Icon wrapper */
      .tab-icon-wrap {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
      }

      /* Tab Label */
      .tab-bar .tab .label {
        font-size: 0.6rem;
        font-weight: 500;
        letter-spacing: 0.01em;
      }

      /* Tab Centrale (Aggiungi) */
      .tab-bar .tab-center {
        flex: 0 0 60px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: var(--primary-gradient) !important;
        color: white !important;
        margin: 0 4px;
        position: relative;
        top: -22px;
        box-shadow: 0 4px 16px rgba(76,175,160,0.45), 0 1px 4px rgba(76,175,160,0.3);
        padding: 0;
        transition: box-shadow 0.2s, transform 0.15s;
      }

      .tab-bar .tab-center:hover {
        box-shadow: 0 6px 20px rgba(76,175,160,0.55);
      }

      .tab-bar .tab-center:active {
        background: var(--btn-active) !important;
        transform: translateY(1px);
        box-shadow: 0 2px 10px rgba(76,175,160,0.35);
      }

      .tab-bar .tab-center .tab-icon-wrap {
        background: none !important;
        padding: 0 !important;
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }

      .tab-bar .tab-center .label {
        display: none;
      }

      /* Floating Chat Button */
      .floating-chat-button {
        position: fixed;
        bottom: 100px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: var(--primary);
        border-radius: 50%;
        box-shadow: 0 2px 12px rgba(76, 175, 160, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 1000;
        border: none;
        transition: all 0.2s ease;
      }

      .floating-chat-button:hover {
        background: var(--primary-dark);
        box-shadow: 0 4px 16px rgba(76, 175, 160, 0.4);
      }

      /* Main Content - Spazio per Tab Bar */
      .main-content {
        padding-bottom: var(--app-mobile-nav-offset);
      }

      /* Mobile */
      @media (max-width: 767px) {
        :root {
          --app-footer-height: 0px;
          --app-mobile-nav-offset: 92px;
        }

        .header {
          padding: 0.4rem 0.75rem;
        }

        .header-title {
          font-size: 1.25rem;
        }

        .header-subtitle {
          font-size: 0.8125rem;
        }

        .btn-header {
          padding: 0.35rem 0.6rem;
          font-size: 0.75rem;
          gap: 0.35rem;
        }

        .btn-header-text {
          display: none;
        }

        .btn-header-icon {
          font-size: 1.1rem;
        }

        .tabs {
          display: none !important;
        }

        .main-content {
          padding-bottom: var(--app-mobile-nav-offset) !important;
        }

        .app-footer {
          display: none;
        }

        .mobile-settings-links-card {
          display: block;
        }

        .app-footer-inner {
          justify-content: center;
          text-align: center;
          gap: 0.25rem;
        }

        .app-footer-links {
          justify-content: center;
          gap: 0.25rem 0.75rem;
        }

        .app-footer-links a {
          font-size: 0.72rem;
          line-height: 1.2;
        }

        .app-footer-copy {
          width: 100%;
          font-size: 0.65rem;
          line-height: 1.2;
        }

        .modal .modal-content {
          padding-bottom: 100px !important;
        }

        #productModal .modal-content,
        #recipeDetailModal .modal-content {
          margin-top: 80px !important;
        }

        #myProductsList {
          max-height: calc(100vh - 280px) !important;
          overflow-y: auto;
        }
      }

      @media (min-width: 768px) {
        .tab-bar {
          display: none;
        }

        .floating-chat-button {
          display: flex; /* ✅ Visibile su desktop */
          bottom: calc(var(--app-footer-height) + 22px);
        }

        /* ✅ Nascondi freccia laterale e sidebar chat su desktop */
        .chat-expand-btn,
        .chat-sidebar {
          display: none !important;
        }

        .app-container {
          height: auto;
        }

        .main-content {
          overflow: hidden;
          min-height: 0;
          padding-bottom: 0;
        }
      }

      /* Animazione transizione view */
      .view-transition {
        animation: fadeIn 0.3s ease;
      }

      @keyframes fadeIn {
        from {
          opacity: 0;
          transform: translateY(10px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }

      /* ✅ SKELETON LOADER - Animazione caricamento */
      .skeleton {
        background: linear-gradient(90deg, #f0f0f0 0%, #e8e8e8 20%, #f0f0f0 40%, #f0f0f0 100%);
        background-size: 200% 100%;
        animation: shimmer 1.5s ease-in-out infinite;
        border-radius: 8px;
      }

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

      .skeleton-circle {
        width: 200px;
        height: 200px;
        border-radius: 50%;
        margin: 2rem auto;
      }

      .skeleton-bar {
        height: 60px;
        margin-bottom: 1rem;
        border-radius: 12px;
      }

      .skeleton-meal {
        height: 180px;
        margin-bottom: 1rem;
        border-radius: 16px;
      }

      .skeleton-text {
        height: 20px;
        margin-bottom: 0.5rem;
        border-radius: 4px;
      }

      .skeleton-text.short {
        width: 60%;
      }

      /* ============================================
        BARCODE SCANNER STYLES
        ============================================ */
      #barcodeScannerContainer {
        width: 100% !important;
        max-width: 500px;
        margin: 0 auto;
        background: #000;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
      }

      @media (max-width: 600px) {
        #barcodeScannerContainer {
          max-width: 100%;
          max-height: 60vh;
          border-radius: 6px;
        }
      }

      /* Video: fill container width, let aspect-ratio determine height */
      #barcodeScannerContainer video {
        width: 100% !important;
        height: auto !important;
        object-fit: contain;
        display: block;
      }

      @media (max-width: 600px) {
        #barcodeScannerContainer video {
          height: 100% !important;
          object-fit: cover;
        }
      }

      /* Rimuovi eventuali padding/margini aggiunti dalla libreria */
      #barcodeScannerContainer > div {
        padding: 0 !important;
      }
