{"id":14569,"date":"2026-10-22T23:40:55","date_gmt":"2026-10-22T12:40:55","guid":{"rendered":"https:\/\/groundreportindia.org\/monthly\/?p=14569"},"modified":"2026-10-23T04:58:04","modified_gmt":"2026-10-22T17:58:04","slug":"metabolicguide","status":"publish","type":"post","link":"https:\/\/groundreportindia.org\/monthly\/csr\/2026\/10\/metabolicguide\/","title":{"rendered":"Metabolic Health Wellness Engine"},"content":{"rendered":"<p>      MetabolicGuide | Science-Based Nutrition &amp; Metabolic Lifestyle Tracker  <!-- Tailwind CSS CDN -->  [tcb-script src=&#8221;https:\/\/cdn.tailwindcss.com&#8221;][\/tcb-script]  <!-- Google Fonts: Inter -->        <!-- React 18 & Babel Standalone for Single-File WordPress Execution -->  [tcb-script src=&#8221;https:\/\/unpkg.com\/react@18\/umd\/react.production.min.js&#8221; crossorigin=&#8221;&#8221;][\/tcb-script]  [tcb-script src=&#8221;https:\/\/unpkg.com\/react-dom@18\/umd\/react-dom.production.min.js&#8221; crossorigin=&#8221;&#8221;][\/tcb-script]  [tcb-script src=&#8221;https:\/\/unpkg.com\/@babel\/standalone\/babel.min.js&#8221;][\/tcb-script]      [tcb-script type=&#8221;module&#8221;]    import { initializeApp } from &#8220;https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-app.js&#8221;;    import {      getAuth,      signInAnonymously,      signInWithCustomToken,      onAuthStateChanged    } from &#8220;https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-auth.js&#8221;;    import {      getFirestore,      doc,      setDoc,      getDoc,      deleteDoc,      onSnapshot    } from &#8220;https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-firestore.js&#8221;;    \/\/ ============================================================================    \/\/ STEP FOR GROUNDREPORTINDIA.ORG:    \/\/ Paste your 6 Firebase configuration keys inside CUSTOM_FIREBASE_CONFIG below    \/\/ once you create your free project at https:\/\/console.firebase.google.com\/    \/\/ ============================================================================    const CUSTOM_FIREBASE_CONFIG = {      apiKey: &#8220;AIzaSyBLtqWwDVpMcZiDjeCWHUpmjVSQQO1Tpj8&#8221;,      authDomain: &#8220;metabolicrx-gri.firebaseapp.com&#8221;,      projectId: &#8220;metabolicrx-gri&#8221;,      storageBucket: &#8220;metabolicrx-gri.firebasestorage.app&#8221;,      messagingSenderId: &#8220;540547307341&#8221;,      appId: &#8220;1:540547307341:web:4d616282c8e844dbc6c904&#8221;    };    \/\/ Automatic Environment Detection (Works here in Preview AND on groundreportindia.org)    let activeConfig = null;    let usingCustomProject = false;    if (CUSTOM_FIREBASE_CONFIG.apiKey &amp;&amp; CUSTOM_FIREBASE_CONFIG.projectId) {      activeConfig = CUSTOM_FIREBASE_CONFIG;      usingCustomProject = true;    } else if (typeof __firebase_config !== &#8220;undefined&#8221; &amp;&amp; __firebase_config) {      try {        activeConfig = JSON.parse(__firebase_config);      } catch (e) {        console.error(&#8220;Failed to parse environment Firebase config:&#8221;, e);      }    }    const appId = usingCustomProject      ? &#8220;metabolicrx-gri-prod&#8221;      : (typeof __app_id !== &#8220;undefined&#8221; &amp;&amp; __app_id ? __app_id : &#8220;metabolicrx-gri-prod&#8221;);    window.__METABOLIC_CLOUD__ = {      isConfigured: Boolean(activeConfig &amp;&amp; activeConfig.apiKey),      usingCustomProject,      appId,      initializeApp,      getAuth,      signInAnonymously,      signInWithCustomToken,      onAuthStateChanged,      getFirestore,      doc,      setDoc,      getDoc,      deleteDoc,      onSnapshot,      activeConfig,      cachedApp: null    };    window.__METABOLIC_CLOUD_READY__ = true;    window.dispatchEvent(new Event(&#8220;metabolic-cloud-ready&#8221;));  [\/tcb-script]  [tcb-script type=&#8221;text\/babel&#8221;]    const { useState, useEffect, useMemo, useRef } = React;    \/\/ Safe numeric coercion helper: prevents NaN, Infinity, booleans, arrays, or empty-string comparison bugs    const toValidNum = (val) =&gt; {      if (val === &#8221; || val === null || typeof val === &#8216;undefined&#8217; || typeof val === &#8216;boolean&#8217; || typeof val === &#8216;object&#8217;) return null;      const n = Number(val);      return Number.isFinite(n) &amp;&amp; n &gt; 0 ? n : null;    };    \/\/ Safe non-negative numeric coercion with fallback (for sliders, counts, and macro totals)    const toSafeFloat = (val, fallback = 0, min = 0, max = 100000) =&gt; {      if (val === &#8221; || val === null || typeof val === &#8216;undefined&#8217; || typeof val === &#8216;boolean&#8217; || typeof val === &#8216;object&#8217;) return fallback;      const n = Number(val);      if (!Number.isFinite(n)) return fallback;      return Math.min(max, Math.max(min, n));    };    \/\/ Safe string coercion helper with max length cap    const toSafeStr = (val, fallback = &#8221;, maxLen = 120) =&gt; {      if (val === null || typeof val === &#8216;undefined&#8217; || typeof val === &#8216;object&#8217; || typeof val === &#8216;boolean&#8217;) return fallback;      return String(val).slice(0, maxLen);    };    \/\/ Safe input sanitizer for numeric fields (allows smooth decimal\/intermediate typing while blocking negatives, NaN &amp; scientific notation)    const parseInputNum = (rawVal, min = 0, max = 2000) =&gt; {      if (rawVal === &#8221; || rawVal === null || typeof rawVal === &#8216;undefined&#8217; || typeof rawVal === &#8216;boolean&#8217; || typeof rawVal === &#8216;object&#8217;) return &#8221;;      const str = String(rawVal).trim();      if (str === &#8221; || str.startsWith(&#8216;-&#8216;) || \/[eE+]\/.test(str)) return &#8221;;      if (!\/^d*.?d*$\/.test(str)) return &#8221;;      const n = Number(str);      if (!Number.isFinite(n) || n &lt; 0) return &#8221;;      if (n &gt; max) return String(max);      return str;    };    \/\/ Single centralized food scaling helper (eliminates duplicate scaling logic between Inspector and Food Logger)    const scaleFoodItem = (baseFood, servings = 1) =&gt; {      const mult = toSafeFloat(servings, 1, 0.01, 25);      const scale = (val, dec = 1) =&gt; +((Number(val) || 0) * mult).toFixed(dec);      const cal = Math.round((baseFood.cal || 0) * mult);      const pro = scale(baseFood.pro, 1);      const carb = scale(baseFood.carb, 1);      const fiber = scale(baseFood.fiber, 1);      const netCarb = Math.max(0, +(carb &#8211; fiber).toFixed(1));      return {        &#8230;baseFood,        mult: +mult.toFixed(3),        servings: +mult.toFixed(2),        cal,        pro,        carb,        fiber,        netCarb,        fat: scale(baseFood.fat, 1),        sfa: scale(baseFood.sfa, 1),        mufa: scale(baseFood.mufa, 1),        pufa: scale(baseFood.pufa, 1),        leucine: scale(baseFood.leucine, 2),        omega3: scale(baseFood.omega3, 2),        mg: Math.round((baseFood.mg || 0) * mult),        k: Math.round((baseFood.k || 0) * mult),        ca: Math.round((baseFood.ca || 0) * mult),        fe: scale(baseFood.fe, 1),        zn: scale(baseFood.zn, 1),        choline: Math.round((baseFood.choline || 0) * mult),        vitC: Math.round((baseFood.vitC || 0) * mult),        vitA: Math.round((baseFood.vitA || 0) * mult),        vitD: Math.round((baseFood.vitD || 0) * mult),        b12: scale(baseFood.b12, 1),        folate: Math.round((baseFood.folate || 0) * mult),        glycemicLoad: Math.round((baseFood.glycemicLoad || 0) * mult)      };    };    \/\/ Clean numeric formatter for %DV and nutrient deficits (avoids trailing .00 on integers)    const formatNutrientVal = (val) =&gt; {      const n = Number(val);      if (!Number.isFinite(n)) return &#8216;0&#8217;;      return Number.isInteger(n) ? String(n) : String(+n.toFixed(2));    };    \/\/ Deep clone helper for safe state snapshotting (prevents nested object\/array reference mutation)    const deepCloneState = (obj) =&gt; {      try {        return JSON.parse(JSON.stringify(obj));      } catch (e) {        return obj;      }    };    \/\/ Safe localStorage fallback helpers (so users never lose data if offline or if adblockers block Firebase)    const LOCAL_BACKUP_KEY = &#8216;metabolicrx_gri_local_vault_v1&#8217;;    const saveLocalBackup = (dataObj) =&gt; {      try {        window.localStorage.setItem(LOCAL_BACKUP_KEY, JSON.stringify(dataObj));      } catch (e) {        \/\/ Ignore Safari private browsing \/ storage quota errors      }    };    const loadLocalBackup = () =&gt; {      try {        const raw = window.localStorage.getItem(LOCAL_BACKUP_KEY);        return raw ? JSON.parse(raw) : null;      } catch (e) {        return null;      }    };    const clearLocalBackup = () =&gt; {      try {        window.localStorage.removeItem(LOCAL_BACKUP_KEY);      } catch (e) {        \/\/ Ignore storage errors      }    };    \/\/ Unique ID generator to prevent duplicate React keys on rapid clicks    let uidCounter = 0;    const makeUniqueId = () =&gt; `${Date.now()}-${++uidCounter}`;    \/\/ React Error Boundary so any unexpected browser\/DOM extension error never white-screens the page    class ClinicalErrorBoundary extends React.Component {      constructor(props) {        super(props);        this.state = { hasError: false, errorMsg: &#8221; };      }      static getDerivedStateFromError(error) {        return { hasError: true, errorMsg: error?.message || &#8216;Unexpected rendering error&#8217; };      }      componentDidCatch(error, info) {        console.error(&#8220;MetabolicGuide Boundary Caught:&#8221;, error, info);      }      render() {        if (this.state.hasError) {          return (            &lt;div className=&#8221;min-h-screen bg-slate-50 flex items-center justify-center p-6&#8243;&gt;              &lt;div className=&#8221;bg-white rounded-2xl max-w-md w-full p-6 shadow-xl border border-rose-200 space-y-4 text-center&#8221;&gt;                &lt;div className=&#8221;text-base font-bold text-slate-900&#8243;&gt;Display Recovery Mode&lt;\/div&gt;                &lt;p className=&#8221;text-xs text-slate-600&#8243;&gt;                  A browser extension or corrupted input interrupted the view ({this.state.errorMsg}).                &lt;\/p&gt;                &lt;button                  type=&#8221;button&#8221;                  onClick={() =&gt; this.setState({ hasError: false, errorMsg: &#8221; })}                  className=&#8221;px-4 py-2 rounded-xl bg-teal-600 text-white text-xs font-semibold hover:bg-teal-700&#8243;                &gt;                  Reload MetabolicGuide Dashboard                &lt;\/button&gt;              &lt;\/div&gt;            &lt;\/div&gt;          );        }        return this.props.children;      }    }    \/\/ Clean, zero-dependency inline SVG icons    const Icon = ({ name, className = &#8220;w-5 h-5&#8243; }) =&gt; {      const paths = {        activity: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M22 12h-4l-3 9L9 3l-3 9H2&#8243; \/&gt;,        heart: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z&#8221; \/&gt;,        droplet: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M12 2.69l5.66 5.66a8 8 0 11-11.31 0z&#8221; \/&gt;,        sun: (          &lt;&gt;            &lt;circle cx=&#8221;12&#8243; cy=&#8221;12&#8243; r=&#8221;4&#8243; strokeWidth=&#8221;2&#8243; \/&gt;            &lt;path strokeLinecap=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41&#8243; \/&gt;          &lt;\/&gt;        ),        moon: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z&#8221; \/&gt;,        utensils: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M3 2v7c0 1.1.9 2 2 2h4a2 2 0 002-2V2M7 2v20m14-7V2a5 5 0 00-5 5v6c0 1.1.9 2 2 2h3zm0 0v7&#8243; \/&gt;,        clock: (          &lt;&gt;            &lt;circle cx=&#8221;12&#8243; cy=&#8221;12&#8243; r=&#8221;10&#8243; strokeWidth=&#8221;2&#8243; \/&gt;            &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M12 6v6l4 2&#8243; \/&gt;          &lt;\/&gt;        ),        trendingDown: (          &lt;&gt;            &lt;polyline strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; points=&#8221;23 18 13.5 8.5 8.5 13.5 1 6&#8243; \/&gt;            &lt;polyline strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; points=&#8221;17 18 23 18 23 12&#8243; \/&gt;          &lt;\/&gt;        ),        info: (          &lt;&gt;            &lt;circle cx=&#8221;12&#8243; cy=&#8221;12&#8243; r=&#8221;10&#8243; strokeWidth=&#8221;2&#8243; \/&gt;            &lt;line x1=&#8221;12&#8243; y1=&#8221;16&#8243; x2=&#8221;12&#8243; y2=&#8221;12&#8243; strokeWidth=&#8221;2&#8243; strokeLinecap=&#8221;round&#8221; \/&gt;            &lt;line x1=&#8221;12&#8243; y1=&#8221;8&#8243; x2=&#8221;12.01&#8243; y2=&#8221;8&#8243; strokeWidth=&#8221;2&#8243; strokeLinecap=&#8221;round&#8221; \/&gt;          &lt;\/&gt;        ),        alert: (          &lt;&gt;            &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z&#8221; \/&gt;            &lt;line x1=&#8221;12&#8243; y1=&#8221;9&#8243; x2=&#8221;12&#8243; y2=&#8221;13&#8243; strokeWidth=&#8221;2&#8243; strokeLinecap=&#8221;round&#8221; \/&gt;            &lt;line x1=&#8221;12&#8243; y1=&#8221;17&#8243; x2=&#8221;12.01&#8243; y2=&#8221;17&#8243; strokeWidth=&#8221;2&#8243; strokeLinecap=&#8221;round&#8221; \/&gt;          &lt;\/&gt;        ),        check: (          &lt;&gt;            &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M22 11.08V12a10 10 0 11-5.93-9.14&#8243; \/&gt;            &lt;polyline strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; points=&#8221;22 4 12 14.01 9 11.01&#8243; \/&gt;          &lt;\/&gt;        ),        flame: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M8.5 14.5A2.5 2.5 0 0011 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 11-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 002.5 2.5z&#8221; \/&gt;,        shield: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z&#8221; \/&gt;,        brain: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M9.5 2A2.5 2.5 0 0112 4.5v15a2.5 2.5 0 01-4.96.44 2.5 2.5 0 01-2.96-3.08 3 3 0 01-.34-5.58 2.5 2.5 0 011.32-4.24 2.5 2.5 0 013.44-2.04zM14.5 2A2.5 2.5 0 0012 4.5v15a2.5 2.5 0 004.96.44 2.5 2.5 0 002.96-3.08 3 3 0 00.34-5.58 2.5 2.5 0 00-1.32-4.24 2.5 2.5 0 00-3.44-2.04z&#8221; \/&gt;,        plus: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M12 5v14M5 12h14&#8243; \/&gt;,        trash: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2&#8243; \/&gt;,        cloud: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M17.5 19H9a7 7 0 116.71-9h1.79a4.5 4.5 0 110 9z&#8221; \/&gt;,        download: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3&#8243; \/&gt;,        printer: (          &lt;&gt;            &lt;polyline strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; points=&#8221;6 9 6 2 18 2 18 9&#8243; \/&gt;            &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2&#8243; \/&gt;            &lt;rect x=&#8221;6&#8243; y=&#8221;14&#8243; width=&#8221;12&#8243; height=&#8221;8&#8243; strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; \/&gt;          &lt;\/&gt;        ),        upload: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12&#8243; \/&gt;,        footprints: &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 11-4 0zm10 4v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C8.63 6 8 7.8 8 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 104 0z&#8221; \/&gt;,        userCheck: (          &lt;&gt;            &lt;path strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; d=&#8221;M16 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2&#8243; \/&gt;            &lt;circle cx=&#8221;8.5&#8243; cy=&#8221;7&#8243; r=&#8221;4&#8243; strokeWidth=&#8221;2&#8243; \/&gt;            &lt;polyline strokeLinecap=&#8221;round&#8221; strokeLinejoin=&#8221;round&#8221; strokeWidth=&#8221;2&#8243; points=&#8221;17 11 19 13 23 9&#8243; \/&gt;          &lt;\/&gt;        )      };      return (        &lt;svg viewBox=&#8221;0 0 24 24&#8243; fill=&#8221;none&#8221; stroke=&#8221;currentColor&#8221; className={className}&gt;          {paths[name] || paths.activity}        &lt;\/svg&gt;      );    };    const CLINICAL_TOOLTIPS = {      homaIr: &#8220;HOMA-IR (Homeostatic Model Assessment for Insulin Resistance) is calculated as (Fasting Insulin \u00d7 Fasting Glucose) \/ 405. Optimal is &lt; 1.0. Above 1.9 indicates early insulin resistance; &gt; 2.9 indicates significant resistance.&#8221;,      whr: &#8220;Waist-to-Hip Ratio (WHR) is a superior predictor of visceral adiposity and cardiovascular risk compared to BMI. WHO cutoffs for abdominal obesity are &gt;0.90 for men and &gt;0.85 for women.&#8221;,      mealSequencing: &#8220;Consuming dietary fiber (vegetables) or protein\/fat first, eating starches\/sugars later, and finishing with whole lemon (skin, seeds, and juice\u2014rich in citric acid, pectin fiber, and citrus polyphenols like eriocitrin &amp; hesperidin) slows gastric emptying, inhibits salivary\/pancreatic alpha-amylase, and reduces postprandial glucose spikes by up to 73%.&#8221;,      resistantStarch: &#8220;Cooking and cooling starches (rice, potatoes, oats) for 12-24 hours at 4\u00b0C triggers &#8216;retrogradation&#8217;, converting digestible amylose into Type 3 Resistant Starch (RS3), which bypasses small intestine digestion and feeds butyrate-producing colonic bacteria.&#8221;,      cookingOils: &#8220;Industrial seed oils high in linoleic acid (soybean, sunflower, corn, safflower) are prone to lipid peroxidation when heated, generating 4-HNE which induces mitochondrial oxidative stress and hepatic insulin resistance. Prefer A2 Ghee, Butter, Coconut Oil, or Extra Virgin Olive Oil.&#8221;,      grazing: &#8220;Every meal or caloric snack triggers an insulin wave taking 3\u20135 hours to return to baseline. Frequent snacking (&#8216;grazing&#8217;) keeps insulin chronically elevated, locking adipose tissue in lipogenesis (fat storage) and downregulating insulin receptors.&#8221;,      postMealWalk: &#8220;Skeletal muscle contraction during a 10\u201315 minute brisk walk immediately after a meal translocates GLUT4 receptors to the cell membrane via an AMPK-dependent, insulin-independent pathway, soaking up blood glucose without requiring extra pancreatic insulin.&#8221;,      circadianEating: &#8220;Melatonin binds to MT1\/MT2 receptors on pancreatic beta-cells, suppressing insulin secretion at night. Eating within 3 hours of sleep causes prolonged nocturnal hyperglycemia and impairs hepatic autophagy.&#8221;,      waterRO: &#8220;Reverse Osmosis (RO) strips water of essential divalent cations (Magnesium, Calcium). Drinking demineralized water increases urinary electrolyte excretion. Always remineralize RO water with trace mineral drops, rock salt (Sendha Namak), or choose natural spring\/mineral water.&#8221;,      cortisol: &#8220;Psychological stress activates the HPA axis, releasing cortisol. Cortisol stimulates hepatic gluconeogenesis (creating new glucose from protein) and directly antagonizes insulin signaling in skeletal muscle.&#8221;    };    const FOOD_DATABASE = [      \/\/ &#8212; VEGETABLES &amp; LEAFY GREENS &#8212;      {        id: &#8216;f1&#8217;, name: &#8216;Steamed Broccoli &amp; Extra Virgin Olive Oil (150g)&#8217;, category: &#8216;Vegetables &amp; Greens&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 110, pro: 3, carb: 7, fiber: 4, fat: 8, sfa: 1, mufa: 6, pufa: 1,        mg: 25, k: 316, ca: 47, fe: 0.7, zn: 0.4, vitC: 89, vitA: 31, vitD: 0, b12: 0, folate: 63, choline: 40, leucine: 0.1, omega3: 0.1, glycemicLoad: 2      },      {        id: &#8216;f14&#8217;, name: &#8216;Moringa, Palak (Spinach) &amp; Methi Greens Stir-Fry (150g)&#8217;, category: &#8216;Vegetables &amp; Greens&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 95, pro: 5.2, carb: 9, fiber: 5.5, fat: 4.5, sfa: 0.6, mufa: 3.1, pufa: 0.5,        mg: 135, k: 720, ca: 290, fe: 4.9, zn: 1.1, vitC: 65, vitA: 620, vitD: 0, b12: 0, folate: 210, choline: 42, leucine: 0.35, omega3: 0.25, glycemicLoad: 1      },      {        id: &#8216;f16&#8217;, name: &#8216;Bitter Gourd (Karela) &amp; Onion Saut\u00e9 (150g)&#8217;, category: &#8216;Vegetables &amp; Greens&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 68, pro: 2.1, carb: 8, fiber: 4.2, fat: 3.2, sfa: 0.5, mufa: 2.1, pufa: 0.4,        mg: 38, k: 440, ca: 32, fe: 1.1, zn: 0.9, vitC: 78, vitA: 48, vitD: 0, b12: 0, folate: 92, choline: 24, leucine: 0.12, omega3: 0.05, glycemicLoad: 1      },      {        id: &#8216;f17&#8217;, name: &#8216;Okra (Bhindi), Bell Peppers &amp; Garlic (150g)&#8217;, category: &#8216;Vegetables &amp; Greens&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 75, pro: 2.8, carb: 10, fiber: 4.8, fat: 3.0, sfa: 0.4, mufa: 2.0, pufa: 0.4,        mg: 62, k: 380, ca: 95, fe: 0.9, zn: 0.7, vitC: 95, vitA: 85, vitD: 0, b12: 0, folate: 88, choline: 28, leucine: 0.15, omega3: 0.04, glycemicLoad: 2      },      {        id: &#8216;f18&#8217;, name: &#8216;Cauliflower, Cabbage &amp; Turmeric Roast (150g)&#8217;, category: &#8216;Vegetables &amp; Greens&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 82, pro: 2.9, carb: 8.5, fiber: 4.0, fat: 4.2, sfa: 0.6, mufa: 2.8, pufa: 0.5,        mg: 26, k: 410, ca: 45, fe: 0.8, zn: 0.5, vitC: 68, vitA: 12, vitD: 0, b12: 0, folate: 75, choline: 65, leucine: 0.16, omega3: 0.08, glycemicLoad: 2      },      \/\/ &#8212; GRAINS, MILLETS &amp; STARCHES (RS3 &amp; LOW GI) &#8212;      {        id: &#8216;f2&#8217;, name: &#8216;Cooled &amp; Reheated White Rice (RS3 Retrograded, 150g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 190, pro: 4, carb: 42, fiber: 4.5, fat: 0.4, sfa: 0.1, mufa: 0.1, pufa: 0.1,        mg: 19, k: 55, ca: 16, fe: 0.4, zn: 0.8, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 9, choline: 3, leucine: 0.3, omega3: 0, glycemicLoad: 14, isRS: true      },      {        id: &#8216;f3&#8217;, name: &#8216;Freshly Cooked Piping Hot White Rice (150g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 205, pro: 4.3, carb: 45, fiber: 0.6, fat: 0.4, sfa: 0.1, mufa: 0.1, pufa: 0.1,        mg: 19, k: 55, ca: 16, fe: 0.4, zn: 0.8, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 9, choline: 3, leucine: 0.3, omega3: 0, glycemicLoad: 33, isRS: false      },      {        id: &#8216;f11&#8217;, name: &#8216;Boiled &amp; Cooled Potato (12-24h at 4\u00b0C &#8211; RS3 Retrograded, 150g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 115, pro: 3.1, carb: 26, fiber: 4.8, fat: 0.2, sfa: 0.05, mufa: 0.01, pufa: 0.08,        mg: 34, k: 640, ca: 18, fe: 1.2, zn: 0.5, vitC: 19, vitA: 2, vitD: 0, b12: 0, folate: 24, choline: 22, leucine: 0.2, omega3: 0.02, glycemicLoad: 11, isRS: true      },      {        id: &#8216;f12&#8217;, name: &#8216;Freshly Boiled \/ Mashed Piping Hot Potato (150g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 130, pro: 3.1, carb: 30, fiber: 2.2, fat: 0.2, sfa: 0.05, mufa: 0.01, pufa: 0.08,        mg: 34, k: 640, ca: 18, fe: 1.2, zn: 0.5, vitC: 19, vitA: 2, vitD: 0, b12: 0, folate: 24, choline: 22, leucine: 0.2, omega3: 0.02, glycemicLoad: 26, isRS: false      },      {        id: &#8216;f19&#8217;, name: &#8216;Ragi (Finger Millet) \/ Jowar Bhakri or Porridge (120g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 160, pro: 5.2, carb: 32, fiber: 5.6, fat: 1.1, sfa: 0.2, mufa: 0.3, pufa: 0.4,        mg: 78, k: 290, ca: 195, fe: 2.4, zn: 1.3, vitC: 0, vitA: 4, vitD: 0, b12: 0, folate: 28, choline: 18, leucine: 0.48, omega3: 0.04, glycemicLoad: 10      },      {        id: &#8216;f20&#8217;, name: &#8216;Cooked Quinoa &amp; Amaranth (Rajgira) Bowl (150g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 180, pro: 6.8, carb: 31, fiber: 4.5, fat: 2.8, sfa: 0.3, mufa: 0.8, pufa: 1.4,        mg: 98, k: 318, ca: 42, fe: 2.8, zn: 1.6, vitC: 0, vitA: 1, vitD: 0, b12: 0, folate: 65, choline: 44, leucine: 0.42, omega3: 0.12, glycemicLoad: 9      },      {        id: &#8216;f21&#8217;, name: &#8216;Steel-Cut Oats (Soaked\/Cooled Overnight RS3, 150g)&#8217;, category: &#8216;Grains, Millets &amp; Starches&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 155, pro: 5.5, carb: 27, fiber: 4.8, fat: 2.6, sfa: 0.4, mufa: 0.8, pufa: 1.0,        mg: 66, k: 170, ca: 24, fe: 1.9, zn: 1.5, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 22, choline: 16, leucine: 0.4, omega3: 0.05, glycemicLoad: 8, isRS: true      },      \/\/ &#8212; FRUITS &amp; CITRUS POLYPHENOLS &#8212;      {        id: &#8216;f10&#8217;, name: &#8216;Whole Lemon with Skin, Seeds &amp; Juice (1 Medium)&#8217;, category: &#8216;Fruits &amp; Berries&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 22, pro: 1.2, carb: 11, fiber: 5.1, fat: 0.3, sfa: 0.04, mufa: 0.01, pufa: 0.09,        mg: 14, k: 150, ca: 65, fe: 0.8, zn: 0.1, vitC: 84, vitA: 3, vitD: 0, b12: 0, folate: 18, choline: 6, leucine: 0.05, omega3: 0.02, glycemicLoad: 1      },      {        id: &#8216;f9&#8217;, name: &#8216;Avocado, Cucumber &amp; Hemp Seed Salad (150g)&#8217;, category: &#8216;Fruits &amp; Berries&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 290, pro: 8, carb: 11, fiber: 8, fat: 25, sfa: 3.5, mufa: 14, pufa: 6.5,        mg: 140, k: 680, ca: 35, fe: 2.1, zn: 1.9, vitC: 18, vitA: 45, vitD: 0, b12: 0, folate: 110, choline: 35, leucine: 0.5, omega3: 1.5, glycemicLoad: 1      },      {        id: &#8216;f22&#8217;, name: &#8216;Guava (Amrood &#8211; Whole with Seeds, 1 Medium 120g)&#8217;, category: &#8216;Fruits &amp; Berries&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 82, pro: 3.1, carb: 17, fiber: 6.5, fat: 1.1, sfa: 0.3, mufa: 0.1, pufa: 0.5,        mg: 26, k: 500, ca: 22, fe: 0.4, zn: 0.3, vitC: 250, vitA: 38, vitD: 0, b12: 0, folate: 58, choline: 12, leucine: 0.18, omega3: 0.08, glycemicLoad: 4      },      {        id: &#8216;f23&#8217;, name: &#8216;Blueberries, Blackberries &amp; Jamun (100g)&#8217;, category: &#8216;Fruits &amp; Berries&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 52, pro: 1.1, carb: 12, fiber: 4.5, fat: 0.4, sfa: 0.02, mufa: 0.05, pufa: 0.2,        mg: 16, k: 140, ca: 20, fe: 0.5, zn: 0.4, vitC: 24, vitA: 12, vitD: 0, b12: 0, folate: 22, choline: 8, leucine: 0.06, omega3: 0.06, glycemicLoad: 3      },      {        id: &#8216;f24&#8217;, name: &#8216;Pomegranate Arils (Anar with Seeds, 100g)&#8217;, category: &#8216;Fruits &amp; Berries&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 83, pro: 1.7, carb: 18, fiber: 4.0, fat: 1.2, sfa: 0.1, mufa: 0.1, pufa: 0.1,        mg: 12, k: 236, ca: 10, fe: 0.3, zn: 0.35, vitC: 10, vitA: 0, vitD: 0, b12: 0, folate: 38, choline: 8, leucine: 0.08, omega3: 0.04, glycemicLoad: 5      },      {        id: &#8216;f25&#8217;, name: &#8216;Green Apple with Skin &amp; Cinnamon (1 Medium)&#8217;, category: &#8216;Fruits &amp; Berries&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 88, pro: 0.5, carb: 22, fiber: 4.4, fat: 0.3, sfa: 0.05, mufa: 0.01, pufa: 0.09,        mg: 9, k: 195, ca: 11, fe: 0.2, zn: 0.1, vitC: 8, vitA: 5, vitD: 0, b12: 0, folate: 5, choline: 6, leucine: 0.03, omega3: 0.02, glycemicLoad: 6      },      \/\/ &#8212; NUTS, SEEDS &amp; HEALTHY OILS &#8212;      {        id: &#8216;f8&#8217;, name: &#8216;Soaked Almonds, Walnuts &amp; Mixed Nuts (30g)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 185, pro: 6.5, carb: 5, fiber: 3.2, fat: 16.5, sfa: 1.5, mufa: 7, pufa: 7.5,        mg: 110, k: 220, ca: 65, fe: 1.9, zn: 1.8, vitC: 0.5, vitA: 2, vitD: 0, b12: 0, folate: 22, choline: 18, leucine: 0.45, omega3: 1.2, glycemicLoad: 1      },      {        id: &#8216;f26&#8217;, name: &#8216;Pumpkin Seeds (Pepitas &#8211; Raw\/Soaked, 30g)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 170, pro: 9.0, carb: 3.2, fiber: 1.8, fat: 14.5, sfa: 2.5, mufa: 4.5, pufa: 6.2,        mg: 168, k: 240, ca: 15, fe: 2.5, zn: 2.3, vitC: 0.5, vitA: 1, vitD: 0, b12: 0, folate: 17, choline: 19, leucine: 0.72, omega3: 0.05, glycemicLoad: 1      },      {        id: &#8216;f27&#8217;, name: &#8216;Chia Seeds (Soaked in Water, 2 Tbsp \/ 28g)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 138, pro: 4.7, carb: 12, fiber: 9.8, fat: 8.7, sfa: 0.9, mufa: 0.7, pufa: 6.7,        mg: 95, k: 115, ca: 179, fe: 2.2, zn: 1.3, vitC: 0.5, vitA: 2, vitD: 0, b12: 0, folate: 14, choline: 20, leucine: 0.39, omega3: 5.0, glycemicLoad: 1      },      {        id: &#8216;f28&#8217;, name: &#8216;Ground Flaxseeds (Alsi, 2 Tbsp \/ 20g)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 110, pro: 3.8, carb: 6, fiber: 5.6, fat: 8.5, sfa: 0.7, mufa: 1.5, pufa: 5.7,        mg: 78, k: 162, ca: 52, fe: 1.2, zn: 0.9, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 18, choline: 16, leucine: 0.25, omega3: 4.5, glycemicLoad: 0      },      {        id: &#8216;f29&#8217;, name: &#8216;Extra Virgin Olive Oil (Cold-Pressed, 1 Tbsp \/ 14g)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 119, pro: 0, carb: 0, fiber: 0, fat: 13.5, sfa: 1.9, mufa: 9.9, pufa: 1.4,        mg: 0, k: 0, ca: 0, fe: 0.1, zn: 0, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 0, choline: 0, leucine: 0, omega3: 0.1, glycemicLoad: 0      },      {        id: &#8216;f30&#8217;, name: &#8216;A2 Cultured Ghee \/ Clarified Butter (1 Tbsp \/ 14g)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 125, pro: 0, carb: 0, fiber: 0, fat: 14, sfa: 8.8, mufa: 4.0, pufa: 0.5,        mg: 0, k: 0, ca: 0, fe: 0, zn: 0, vitC: 0, vitA: 120, vitD: 15, b12: 0, folate: 0, choline: 3, leucine: 0, omega3: 0.2, glycemicLoad: 0      },      {        id: &#8216;f15&#8217;, name: &#8216;Nutritional Yeast (Plant B12) &amp; Sesame Tahini (2 Tbsp)&#8217;, category: &#8216;Nuts, Seeds &amp; Oils&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 130, pro: 9, carb: 6, fiber: 4, fat: 8, sfa: 1.1, mufa: 3.0, pufa: 3.5,        mg: 65, k: 310, ca: 140, fe: 2.6, zn: 2.8, vitC: 0, vitA: 0, vitD: 40, b12: 2.4, folate: 160, choline: 38, leucine: 0.65, omega3: 0.05, glycemicLoad: 1      },      \/\/ &#8212; PROTEINS, LEGUMES &amp; DAIRY &#8212;      {        id: &#8216;f7&#8217;, name: &#8216;Sprouted Moong Dal &amp; Spinach Bowl (180g)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 185, pro: 13, carb: 30, fiber: 8.5, fat: 1.2, sfa: 0.2, mufa: 0.3, pufa: 0.5,        mg: 95, k: 540, ca: 85, fe: 3.8, zn: 1.7, vitC: 28, vitA: 280, vitD: 0, b12: 0, folate: 190, choline: 55, leucine: 0.9, omega3: 0.1, glycemicLoad: 8      },      {        id: &#8216;f31&#8217;, name: &#8216;Kala Chana (Black Chickpeas) &amp; Tofu\/Soy Chunks (150g)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 225, pro: 17.5, carb: 24, fiber: 7.8, fat: 5.5, sfa: 0.8, mufa: 1.3, pufa: 3.0,        mg: 88, k: 420, ca: 210, fe: 3.6, zn: 1.9, vitC: 3, vitA: 12, vitD: 0, b12: 0, folate: 175, choline: 95, leucine: 1.35, omega3: 0.3, glycemicLoad: 6      },      {        id: &#8216;f6&#8217;, name: &#8216;Paneer \/ Indian Cottage Cheese (100g)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 265, pro: 18, carb: 3, fiber: 0, fat: 20, sfa: 13, mufa: 5, pufa: 0.8,        mg: 22, k: 105, ca: 480, fe: 0.4, zn: 2.1, vitC: 0, vitA: 195, vitD: 15, b12: 0.8, folate: 15, choline: 45, leucine: 1.8, omega3: 0.15, glycemicLoad: 1      },      {        id: &#8216;f13&#8217;, name: &#8216;A2 Curd \/ Greek Yogurt with Flax &amp; Chia Seeds (150g)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 165, pro: 12, carb: 8, fiber: 3.5, fat: 9.5, sfa: 4.2, mufa: 2.1, pufa: 2.8,        mg: 55, k: 260, ca: 240, fe: 0.9, zn: 1.4, vitC: 1, vitA: 45, vitD: 10, b12: 0.9, folate: 18, choline: 32, leucine: 1.2, omega3: 1.8, glycemicLoad: 2      },      {        id: &#8216;f4&#8217;, name: &#8216;Pasture-Raised Whole Eggs (2 Large)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;ovo&#8217;, &#8216;omni&#8217;],        cal: 145, pro: 12.6, carb: 0.8, fiber: 0, fat: 10, sfa: 3.2, mufa: 3.8, pufa: 1.4,        mg: 12, k: 138, ca: 56, fe: 1.8, zn: 1.3, vitC: 0, vitA: 160, vitD: 82, b12: 1.1, folate: 47, choline: 294, leucine: 1.1, omega3: 0.22, glycemicLoad: 0      },      {        id: &#8216;f5&#8217;, name: &#8216;Wild-Caught Salmon \/ Mackerel Fillet (150g)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;omni&#8217;],        cal: 280, pro: 34, carb: 0, fiber: 0, fat: 15, sfa: 3, mufa: 5, pufa: 6,        mg: 45, k: 620, ca: 20, fe: 1.2, zn: 0.9, vitC: 0, vitA: 50, vitD: 650, b12: 4.8, folate: 40, choline: 135, leucine: 2.8, omega3: 2.6, glycemicLoad: 0      },      {        id: &#8216;f32&#8217;, name: &#8216;Free-Range Chicken Breast &amp; Herbs (150g)&#8217;, category: &#8216;Proteins, Legumes &amp; Dairy&#8217;, diet: [&#8216;omni&#8217;],        cal: 245, pro: 45, carb: 0, fiber: 0, fat: 5.4, sfa: 1.5, mufa: 1.8, pufa: 1.1,        mg: 42, k: 490, ca: 22, fe: 1.5, zn: 1.6, vitC: 0, vitA: 14, vitD: 12, b12: 0.6, folate: 9, choline: 130, leucine: 3.4, omega3: 0.1, glycemicLoad: 0      }    ];    \/\/ Evidence-based Daily Value (DV) reference targets for metabolic &amp; endocrine health    const DAILY_VALUE_TARGETS = {      pro: { label: &#8216;Protein&#8217;, unit: &#8216;g&#8217;, dv: 90, role: &#8216;Skeletal muscle GLUT4 sink &amp; satiety&#8217; },      fiber: { label: &#8216;Dietary Fiber&#8217;, unit: &#8216;g&#8217;, dv: 35, role: &#8216;Duodenal viscous mesh &amp; butyrate synthesis&#8217; },      leucine: { label: &#8216;Leucine (Essential Amino)&#8217;, unit: &#8216;g&#8217;, dv: 7.5, role: &#8216;Triggers muscle protein synthesis (2.5g\/meal)&#8217; },      omega3: { label: &#8216;Omega-3 Fatty Acids&#8217;, unit: &#8216;g&#8217;, dv: 2.0, role: &#8216;Resolves hepatic &amp; vascular inflammation&#8217; },      mg: { label: &#8216;Magnesium (Mg)&#8217;, unit: &#8216;mg&#8217;, dv: 420, role: &#8216;Intracellular insulin receptor tyrosine kinase cofactor&#8217; },      k: { label: &#8216;Potassium (K)&#8217;, unit: &#8216;mg&#8217;, dv: 3500, role: &#8216;Endothelial vasodilation &amp; sodium excretion (BP)&#8217; },      ca: { label: &#8216;Calcium (Ca)&#8217;, unit: &#8216;mg&#8217;, dv: 1000, role: &#8216;Pancreatic beta-cell insulin exocytosis signaling&#8217; },      fe: { label: &#8216;Iron (Fe)&#8217;, unit: &#8216;mg&#8217;, dv: 18, role: &#8216;Mitochondrial electron transport &amp; hemoglobin&#8217; },      zn: { label: &#8216;Zinc (Zn)&#8217;, unit: &#8216;mg&#8217;, dv: 11, role: &#8216;Crystallizes &amp; packages insulin hexamers in pancreas&#8217; },      choline: { label: &#8216;Choline (Hepatic)&#8217;, unit: &#8216;mg&#8217;, dv: 550, role: &#8216;Exports trapped liver fat (VLDL) to reverse NAFLD&#8217; },      vitC: { label: &#8216;Vitamin C&#8217;, unit: &#8216;mg&#8217;, dv: 90, role: &#8216;Endothelial nitric oxide protection &amp; iron absorption&#8217; },      vitA: { label: &#8216;Vitamin A (RAE)&#8217;, unit: &#8216;mcg&#8217;, dv: 900, role: &#8216;Retinoid X receptor signaling &amp; immune barrier&#8217; },      vitD: { label: &#8216;Vitamin D3 (Food)&#8217;, unit: &#8216;IU&#8217;, dv: 600, role: &#8216;Modulates insulin gene expression &amp; immunity&#8217; },      b12: { label: &#8216;Vitamin B12&#8217;, unit: &#8216;mcg&#8217;, dv: 2.4, role: &#8216;Myelin integrity, homocysteine clearance &amp; energy&#8217; },      folate: { label: &#8216;Folate (Vitamin B9)&#8217;, unit: &#8216;mcg&#8217;, dv: 400, role: &#8216;Methylation cycle &amp; endothelial homocysteine control&#8217; }    };    const DEFAULT_PROFILE = {      alias: &#8221;,      age: &#8221;,      gender: &#8216;male&#8217;,      weightKg: &#8221;,      heightCm: &#8221;,      bodyFatPct: &#8221;,      waistCm: &#8221;,      hipCm: &#8221;,      neckCm: &#8221;,      dietPreference: &#8216;lacto&#8217;,      activityMultiplier: 1.375,      hba1c: &#8221;,      fastingInsulin: &#8221;,      fastingGlucose: &#8221;,      systolicBP: &#8221;,      diastolicBP: &#8221;,      alt: &#8221;,      ast: &#8221;,      ggt: &#8221;,      triglycerides: &#8221;,      hdl: &#8221;    };    const DEFAULT_NUTRITION = {      loggedFoods: [],      mealSequence: &#8216;fiber-protein-carb&#8217;,      cookingFat: &#8216;ghee&#8217;,      snackingCount: 0,      starchPrepMethod: &#8216;cooled-reheated&#8217;,      waterLogs: []    };    const DEFAULT_FASTING = {      protocol: &#8217;16:8&#8242;,      fastingType: &#8216;water-electrolyte&#8217;,      currentFastHours: 0,      wakeTime: &#8221;,      firstMealTime: &#8221;,      lastMealTime: &#8221;,      sleepTime: &#8221;,      mealsPerDay: 2    };    const DEFAULT_ACTIVITY = {      workouts: [],      postMealWalks: {        breakfastWalk: false,        breakfastWalkMins: 15,        breakfastWalkPace: &#8216;brisk&#8217;,        lunchWalk: false,        lunchWalkMins: 20,        lunchWalkPace: &#8216;brisk&#8217;,        dinnerWalk: false,        dinnerWalkMins: 30,        dinnerWalkPace: &#8216;normal&#8217;      },      dailySteps: 0    };    const DEFAULT_LIFESTYLE = {      sunlightTimeOfDay: &#8216;Morning (07:00 &#8211; 09:00 AM)&#8217;,      sunlightDurationMin: 0,      skinExposurePct: 25,      sleepHours: 0,      sleepQuality: 5,      wakingGlucose: &#8221;,      stressScore: 5    };    const Tooltip = ({ text }) =&gt; {      const [open, setOpen] = useState(false);      return (        &lt;span className=&#8221;relative inline-block ml-1.5 align-middle&#8221;&gt;          &lt;button            type=&#8221;button&#8221;            onMouseEnter={() =&gt; setOpen(true)}            onMouseLeave={() =&gt; setOpen(false)}            onClick={() =&gt; setOpen(!open)}            className=&#8221;text-teal-600 hover:text-teal-500 hover:bg-teal-50 p-0.5 rounded-full focus:outline-none transition-colors&#8221;            aria-label=&#8221;Scientific Explanation&#8221;          &gt;            &lt;Icon name=&#8221;info&#8221; className=&#8221;w-4 h-4&#8243; \/&gt;          &lt;\/button&gt;          {open &amp;&amp; (            &lt;div className=&#8221;absolute z-50 bottom-full left-1\/2 -translate-x-1\/2 mb-2 w-72 p-3.5 bg-white text-slate-700 text-xs leading-relaxed rounded-xl shadow-xl border border-teal-200 pointer-events-none&#8221;&gt;              &lt;div className=&#8221;font-bold text-teal-700 mb-1 flex items-center gap-1 border-b border-teal-100 pb-1&#8243;&gt;                &lt;span&gt;Scientific Mechanism&lt;\/span&gt;              &lt;\/div&gt;              {text}            &lt;\/div&gt;          )}        &lt;\/span&gt;      );    };    const StatusBadge = ({ status, label }) =&gt; {      const colors = {        optimal: &#8216;bg-emerald-50 text-emerald-700 border-emerald-200&#8217;,        warning: &#8216;bg-amber-50 text-amber-700 border-amber-200&#8217;,        critical: &#8216;bg-rose-50 text-rose-700 border-rose-200&#8217;,        info: &#8216;bg-sky-50 text-sky-700 border-sky-200&#8217;      };      return (        &lt;span className={`px-2.5 py-0.5 text-xs font-semibold rounded-full border ${colors[status] || colors.info}`}&gt;          {label}        &lt;\/span&gt;      );    };    function App() {      const [activeTab, setActiveTab] = useState(&#8216;profile&#8217;);      const [toastMessage, setToastMessage] = useState(null);      const [confirmResetModal, setConfirmResetModal] = useState(false);      const [activeSampleMode, setActiveSampleMode] = useState(null); \/\/ null | &#8216;high-risk&#8217; | &#8216;reversing&#8217;      \/\/ Core Clinical States      const [profile, setProfile] = useState(DEFAULT_PROFILE);      const [nutrition, setNutrition] = useState(DEFAULT_NUTRITION);      const [fasting, setFasting] = useState(DEFAULT_FASTING);      const [activity, setActivity] = useState(DEFAULT_ACTIVITY);      const [lifestyle, setLifestyle] = useState(DEFAULT_LIFESTYLE);      \/\/ Cloud Storage Sync States (Option 5.1)      const [cloudUser, setCloudUser] = useState(null);      const [cloudStatus, setCloudStatus] = useState(&#8216;connecting&#8217;); \/\/ &#8216;connecting&#8217; | &#8216;synced&#8217; | &#8216;saving&#8217; | &#8216;unconfigured&#8217; | &#8216;error&#8217;      const [initialCloudLoadComplete, setInitialCloudLoadComplete] = useState(false);      const dbRef = useRef(null);      const appIdRef = useRef(&#8216;metabolicrx-gri-prod&#8217;);      const saveTimeoutRef = useRef(null);      const toastTimeoutRef = useRef(null);      const applyTimeoutRef = useRef(null);      const fileInputRef = useRef(null);      const isApplyingRemoteUpdateRef = useRef(false);      const isMountedRef = useRef(true);      const activeSampleModeRef = useRef(null);      const lastSavedJsonRef = useRef(&#8221;);      const preSampleSnapshotRef = useRef(null);      \/\/ Keep activeSampleModeRef in sync with state so async Firestore listeners always read current mode      useEffect(() =&gt; {        activeSampleModeRef.current = activeSampleMode;      }, [activeSampleMode]);      const sanitizeIncomingPayload = (data) =&gt; {        if (!data || typeof data !== &#8216;object&#8217;) return null;        const rawProfile = data.profile &amp;&amp; typeof data.profile === &#8216;object&#8217; ? data.profile : {};        const validDiets = [&#8216;vegan&#8217;, &#8216;lacto&#8217;, &#8216;ovo&#8217;, &#8216;omni&#8217;];        const validGenders = [&#8216;male&#8217;, &#8216;female&#8217;];        const mergedProfile = {          &#8230;DEFAULT_PROFILE,          alias: toSafeStr(rawProfile.alias, &#8221;, 40),          age: parseInputNum(rawProfile.age, 0, 120),          gender: validGenders.includes(rawProfile.gender) ? rawProfile.gender : &#8216;male&#8217;,          weightKg: parseInputNum(rawProfile.weightKg, 0, 400),          heightCm: parseInputNum(rawProfile.heightCm, 0, 260),          bodyFatPct: parseInputNum(rawProfile.bodyFatPct, 0, 75),          waistCm: parseInputNum(rawProfile.waistCm, 0, 250),          hipCm: parseInputNum(rawProfile.hipCm, 0, 250),          neckCm: parseInputNum(rawProfile.neckCm, 0, 80),          dietPreference: validDiets.includes(rawProfile.dietPreference) ? rawProfile.dietPreference : &#8216;lacto&#8217;,          activityMultiplier: toSafeFloat(rawProfile.activityMultiplier, 1.375, 1.0, 2.5),          hba1c: parseInputNum(rawProfile.hba1c, 0, 25),          fastingInsulin: parseInputNum(rawProfile.fastingInsulin, 0, 300),          fastingGlucose: parseInputNum(rawProfile.fastingGlucose, 0, 600),          systolicBP: parseInputNum(rawProfile.systolicBP, 0, 300),          diastolicBP: parseInputNum(rawProfile.diastolicBP, 0, 200),          alt: parseInputNum(rawProfile.alt, 0, 1000),          ast: parseInputNum(rawProfile.ast, 0, 1000),          ggt: parseInputNum(rawProfile.ggt, 0, 1000),          triglycerides: parseInputNum(rawProfile.triglycerides, 0, 1500),          hdl: parseInputNum(rawProfile.hdl, 0, 200)        };        const rawNutrition = data.nutrition &amp;&amp; typeof data.nutrition === &#8216;object&#8217; ? data.nutrition : {};        const sanitizeFoodItem = (item, idx) =&gt; {          if (!item || typeof item !== &#8216;object&#8217;) return null;          return {            id: toSafeStr(item.id, `custom-${idx}`, 40),            instanceId: toSafeStr(item.instanceId, makeUniqueId(), 60),            name: toSafeStr(item.name, &#8216;Logged Food Item&#8217;, 100),            category: toSafeStr(item.category, &#8216;Whole Food&#8217;, 50),            servings: toSafeFloat(item.servings, 1, 0.01, 25),            cal: toSafeFloat(item.cal, 0, 0, 5000),            pro: toSafeFloat(item.pro, 0, 0, 500),            carb: toSafeFloat(item.carb, 0, 0, 500),            fiber: toSafeFloat(item.fiber, 0, 0, 200),            fat: toSafeFloat(item.fat, 0, 0, 500),            sfa: toSafeFloat(item.sfa, 0, 0, 200),            mufa: toSafeFloat(item.mufa, 0, 0, 200),            pufa: toSafeFloat(item.pufa, 0, 0, 200),            mg: toSafeFloat(item.mg, 0, 0, 5000),            k: toSafeFloat(item.k, 0, 0, 10000),            ca: toSafeFloat(item.ca, 0, 0, 5000),            fe: toSafeFloat(item.fe, 0, 0, 200),            zn: toSafeFloat(item.zn, 0, 0, 200),            vitC: toSafeFloat(item.vitC, 0, 0, 5000),            vitA: toSafeFloat(item.vitA, 0, 0, 10000),            vitD: toSafeFloat(item.vitD, 0, 0, 10000),            b12: toSafeFloat(item.b12, 0, 0, 500),            folate: toSafeFloat(item.folate, 0, 0, 5000),            choline: toSafeFloat(item.choline, 0, 0, 5000),            leucine: toSafeFloat(item.leucine, 0, 0, 100),            omega3: toSafeFloat(item.omega3, 0, 0, 100),            glycemicLoad: toSafeFloat(item.glycemicLoad, 0, 0, 200)          };        };        const sanitizeWaterItem = (w) =&gt; {          if (!w || typeof w !== &#8216;object&#8217;) return null;          return {            id: toSafeStr(w.id, makeUniqueId(), 60),            timing: toSafeStr(w.timing, &#8216;Morning Waking&#8217;, 50),            amountMl: toSafeFloat(w.amountMl, 250, 10, 5000),            source: toSafeStr(w.source, &#8216;Natural Mineral Water&#8217;, 60)          };        };        const mergedNutrition = {          &#8230;DEFAULT_NUTRITION,          mealSequence: toSafeStr(rawNutrition.mealSequence, DEFAULT_NUTRITION.mealSequence, 40),          cookingFat: toSafeStr(rawNutrition.cookingFat, DEFAULT_NUTRITION.cookingFat, 40),          snackingCount: Math.round(toSafeFloat(rawNutrition.snackingCount, 0, 0, 10)),          starchPrepMethod: toSafeStr(rawNutrition.starchPrepMethod, DEFAULT_NUTRITION.starchPrepMethod, 40),          loggedFoods: Array.isArray(rawNutrition.loggedFoods)            ? rawNutrition.loggedFoods.slice(0, 150).map(sanitizeFoodItem).filter(Boolean)            : [],          waterLogs: Array.isArray(rawNutrition.waterLogs)            ? rawNutrition.waterLogs.slice(0, 150).map(sanitizeWaterItem).filter(Boolean)            : []        };        const rawFasting = data.fasting &amp;&amp; typeof data.fasting === &#8216;object&#8217; ? data.fasting : {};        const mergedFasting = {          &#8230;DEFAULT_FASTING,          protocol: toSafeStr(rawFasting.protocol, DEFAULT_FASTING.protocol, 40),          fastingType: toSafeStr(rawFasting.fastingType, DEFAULT_FASTING.fastingType, 40),          currentFastHours: toSafeFloat(rawFasting.currentFastHours, 0, 0, 48),          wakeTime: toSafeStr(rawFasting.wakeTime, &#8221;, 10),          firstMealTime: toSafeStr(rawFasting.firstMealTime, &#8221;, 10),          lastMealTime: toSafeStr(rawFasting.lastMealTime, &#8221;, 10),          sleepTime: toSafeStr(rawFasting.sleepTime, &#8221;, 10),          mealsPerDay: Math.round(toSafeFloat(rawFasting.mealsPerDay, 2, 1, 10))        };        const rawActivity = data.activity &amp;&amp; typeof data.activity === &#8216;object&#8217; ? data.activity : {};        const sanitizeWorkoutItem = (w) =&gt; {          if (!w || typeof w !== &#8216;object&#8217;) return null;          return {            id: toSafeStr(w.id, makeUniqueId(), 60),            type: toSafeStr(w.type, &#8216;Resistance Training (Hypertrophy)&#8217;, 80),            intensity: toSafeStr(w.intensity, &#8216;Moderate (RPE 7)&#8217;, 40),            durationMin: Math.round(toSafeFloat(w.durationMin, 30, 1, 600)),            fastedState: Boolean(w.fastedState),            preWorkoutNutrition: toSafeStr(w.preWorkoutNutrition, &#8221;, 120),            intraWorkoutHydration: toSafeStr(w.intraWorkoutHydration, &#8221;, 120),            postWorkoutNutrition: toSafeStr(w.postWorkoutNutrition, &#8221;, 120)          };        };        const validPaces = [&#8216;slow&#8217;, &#8216;normal&#8217;, &#8216;brisk&#8217;];        const mergedActivity = {          &#8230;DEFAULT_ACTIVITY,          dailySteps: Math.round(toSafeFloat(rawActivity.dailySteps, 0, 0, 100000)),          workouts: Array.isArray(rawActivity.workouts)            ? rawActivity.workouts.slice(0, 100).map(sanitizeWorkoutItem).filter(Boolean)            : [],          postMealWalks: {            breakfastWalk: Boolean(rawActivity?.postMealWalks?.breakfastWalk),            breakfastWalkMins: Math.round(toSafeFloat(rawActivity?.postMealWalks?.breakfastWalkMins, 15, 5, 120)),            breakfastWalkPace: validPaces.includes(rawActivity?.postMealWalks?.breakfastWalkPace) ? rawActivity.postMealWalks.breakfastWalkPace : &#8216;brisk&#8217;,            lunchWalk: Boolean(rawActivity?.postMealWalks?.lunchWalk),            lunchWalkMins: Math.round(toSafeFloat(rawActivity?.postMealWalks?.lunchWalkMins, 20, 5, 120)),            lunchWalkPace: validPaces.includes(rawActivity?.postMealWalks?.lunchWalkPace) ? rawActivity.postMealWalks.lunchWalkPace : &#8216;brisk&#8217;,            dinnerWalk: Boolean(rawActivity?.postMealWalks?.dinnerWalk),            dinnerWalkMins: Math.round(toSafeFloat(rawActivity?.postMealWalks?.dinnerWalkMins, 30, 5, 120)),            dinnerWalkPace: validPaces.includes(rawActivity?.postMealWalks?.dinnerWalkPace) ? rawActivity.postMealWalks.dinnerWalkPace : &#8216;normal&#8217;          }        };        const rawLifestyle = data.lifestyle &amp;&amp; typeof data.lifestyle === &#8216;object&#8217; ? data.lifestyle : {};        const mergedLifestyle = {          &#8230;DEFAULT_LIFESTYLE,          sunlightTimeOfDay: toSafeStr(rawLifestyle.sunlightTimeOfDay, DEFAULT_LIFESTYLE.sunlightTimeOfDay, 60),          sunlightDurationMin: toSafeFloat(rawLifestyle.sunlightDurationMin, 0, 0, 60),          skinExposurePct: toSafeFloat(rawLifestyle.skinExposurePct, 10, 0, 100),          sleepHours: toSafeFloat(rawLifestyle.sleepHours, 0, 0, 10),          sleepQuality: toSafeFloat(rawLifestyle.sleepQuality, 5, 1, 10),          wakingGlucose: parseInputNum(rawLifestyle.wakingGlucose, 0, 600),          stressScore: toSafeFloat(rawLifestyle.stressScore, 5, 1, 10)        };        return {          profile: mergedProfile,          nutrition: mergedNutrition,          fasting: mergedFasting,          activity: mergedActivity,          lifestyle: mergedLifestyle        };      };      const applyIncomingData = (data) =&gt; {        const sanitized = sanitizeIncomingPayload(data);        if (!sanitized) return;        \/\/ If user is currently previewing a Sample Demo Profile, update their background restore snapshot        \/\/ and local backup without clobbering the active sample view        const serialized = JSON.stringify(sanitized);        lastSavedJsonRef.current = serialized;        saveLocalBackup(sanitized);        if (activeSampleModeRef.current !== null) {          preSampleSnapshotRef.current = deepCloneState(sanitized);          return;        }        isApplyingRemoteUpdateRef.current = true;        setProfile(sanitized.profile);        setNutrition(sanitized.nutrition);        setFasting(sanitized.fasting);        setActivity(sanitized.activity);        setLifestyle(sanitized.lifestyle);        if (applyTimeoutRef.current) clearTimeout(applyTimeoutRef.current);        applyTimeoutRef.current = setTimeout(() =&gt; {          isApplyingRemoteUpdateRef.current = false;        }, 60);      };      const triggerToast = (msg) =&gt; {        if (!isMountedRef.current) return;        setToastMessage(msg);        if (toastTimeoutRef.current) clearTimeout(toastTimeoutRef.current);        toastTimeoutRef.current = setTimeout(() =&gt; {          if (isMountedRef.current) setToastMessage(null);        }, 3200);      };      \/\/ Cleanup timers on unmount      useEffect(() =&gt; {        isMountedRef.current = true;        return () =&gt; {          isMountedRef.current = false;          if (toastTimeoutRef.current) clearTimeout(toastTimeoutRef.current);          if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);          if (applyTimeoutRef.current) clearTimeout(applyTimeoutRef.current);        };      }, []);      \/\/ 1. Initialize Local Fallback + Firebase Authentication &amp; Real-time Private Vault Listener      useEffect(() =&gt; {        let unsubscribeSnapshot = null;        let unsubscribeAuth = null;        \/\/ Immediately hydrate from local backup first so offline\/ad-blocked users never lose progress        const cachedLocal = loadLocalBackup();        if (cachedLocal) {          applyIncomingData(cachedLocal);        }        const initCloud = async () =&gt; {          const cloud = window.__METABOLIC_CLOUD__;          if (!cloud || !cloud.isConfigured) {            if (isMountedRef.current) {              setCloudStatus(&#8216;unconfigured&#8217;);              setInitialCloudLoadComplete(true);            }            return;          }          try {            \/\/ Singleton guard: prevents duplicate-app crash if React re-mounts or hot-reloads            const app = cloud.cachedApp || cloud.initializeApp(cloud.activeConfig);            cloud.cachedApp = app;            const auth = cloud.getAuth(app);            const db = cloud.getFirestore(app);            dbRef.current = db;            appIdRef.current = cloud.appId;            \/\/ Register Auth listener BEFORE signing in to avoid any missed state transitions            unsubscribeAuth = cloud.onAuthStateChanged(auth, (user) =&gt; {              if (!user || !isMountedRef.current) return;              setCloudUser(user);              if (unsubscribeSnapshot) {                unsubscribeSnapshot();                unsubscribeSnapshot = null;              }              \/\/ Rule 1: Strict private user path              const userDocRef = cloud.doc(                db,                &#8216;artifacts&#8217;,                cloud.appId,                &#8216;users&#8217;,                user.uid,                &#8216;metabolicData&#8217;,                &#8216;dailyState&#8217;              );              unsubscribeSnapshot = cloud.onSnapshot(                userDocRef,                (snapshot) =&gt; {                  if (!isMountedRef.current) return;                  \/\/ Ignore local latency-compensation echoes while user is actively typing                  if (snapshot.metadata &amp;&amp; snapshot.metadata.hasPendingWrites) {                    return;                  }                  if (snapshot.exists()) {                    applyIncomingData(snapshot.data() || {});                  } else {                    \/\/ If cloud doc is empty but user has local data (and not in sample mode), immediately sync local backup to cloud                    const existingLocal = loadLocalBackup();                    const sanitizedLocal = existingLocal ? sanitizeIncomingPayload(existingLocal) : null;                    if (sanitizedLocal &amp;&amp; activeSampleModeRef.current === null) {                      lastSavedJsonRef.current = JSON.stringify(sanitizedLocal);                      cloud.setDoc(                        userDocRef,                        { &#8230;sanitizedLocal, updatedAt: new Date().toISOString() },                        { merge: true }                      ).catch(e =&gt; console.warn(&#8220;Initial local-to-cloud sync deferred:&#8221;, e));                    }                  }                  setCloudStatus(&#8216;synced&#8217;);                  setInitialCloudLoadComplete(true);                },                (err) =&gt; {                  console.warn(&#8220;Firestore Listener Fallback (Using Local Vault):&#8221;, err?.code || err);                  if (isMountedRef.current) {                    setCloudStatus(&#8216;unconfigured&#8217;);                    setInitialCloudLoadComplete(true);                  }                }              );            });            \/\/ Rule 3: Authenticate FIRST before any Firestore operation.            if (!cloud.usingCustomProject &amp;&amp; typeof __initial_auth_token !== &#8216;undefined&#8217; &amp;&amp; __initial_auth_token) {              try {                await cloud.signInWithCustomToken(auth, __initial_auth_token);              } catch (tokenErr) {                await cloud.signInAnonymously(auth);              }            } else {              await cloud.signInAnonymously(auth);            }          } catch (err) {            console.warn(&#8220;Cloud Auth Fallback (Using Local Vault):&#8221;, err?.code || err);            if (isMountedRef.current) {              setCloudStatus(&#8216;unconfigured&#8217;);              setInitialCloudLoadComplete(true);            }          }        };        if (window.__METABOLIC_CLOUD__) {          initCloud();        } else {          window.addEventListener(&#8216;metabolic-cloud-ready&#8217;, initCloud, { once: true });        }        return () =&gt; {          window.removeEventListener(&#8216;metabolic-cloud-ready&#8217;, initCloud);          if (unsubscribeSnapshot) unsubscribeSnapshot();          if (unsubscribeAuth) unsubscribeAuth();        };      }, []);      \/\/ 2. Debounced Auto-Save to Local Vault &amp; Cloud Whenever User Updates Any Metric      useEffect(() =&gt; {        if (!initialCloudLoadComplete) return;        if (isApplyingRemoteUpdateRef.current) return;        \/\/ CRITICAL PROTECTION: Never overwrite the user&#8217;s Cloud Vault or Local Backup while viewing a Sample Demo Profile        if (activeSampleMode !== null || activeSampleModeRef.current !== null) return;        const payloadObj = {          profile,          nutrition,          fasting,          activity,          lifestyle        };        const currentPayloadJson = JSON.stringify(payloadObj);        \/\/ Prevent redundant write loops if data hasn&#8217;t changed        if (currentPayloadJson === lastSavedJsonRef.current) return;        \/\/ Always save to local browser fallback immediately        saveLocalBackup(payloadObj);        const cloud = window.__METABOLIC_CLOUD__;        if (!cloud || !cloud.isConfigured || !cloudUser || !dbRef.current) {          lastSavedJsonRef.current = currentPayloadJson;          return;        }        setCloudStatus(&#8216;saving&#8217;);        if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);        saveTimeoutRef.current = setTimeout(async () =&gt; {          if (!isMountedRef.current || activeSampleModeRef.current !== null) return;          try {            lastSavedJsonRef.current = currentPayloadJson;            const userDocRef = cloud.doc(              dbRef.current,              &#8216;artifacts&#8217;,              appIdRef.current,              &#8216;users&#8217;,              cloudUser.uid,              &#8216;metabolicData&#8217;,              &#8216;dailyState&#8217;            );            await cloud.setDoc(              userDocRef,              {                &#8230;payloadObj,                updatedAt: new Date().toISOString()              },              { merge: true }            );            if (isMountedRef.current) setCloudStatus(&#8216;synced&#8217;);          } catch (err) {            console.error(&#8220;Auto-save failed:&#8221;, err);            if (isMountedRef.current) setCloudStatus(&#8216;error&#8217;);          }        }, 700);        return () =&gt; {          if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);        };      }, [profile, nutrition, fasting, activity, lifestyle, cloudUser, initialCloudLoadComplete, activeSampleMode]);      \/\/ 3. Privacy Safeguard: 1-Click Wipe Cloud Record &amp; Reset      const handleDeleteCloudData = async () =&gt; {        try {          if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);          activeSampleModeRef.current = null;          setActiveSampleMode(null);          preSampleSnapshotRef.current = null;          clearLocalBackup();          const cloud = window.__METABOLIC_CLOUD__;          if (cloud &amp;&amp; cloud.isConfigured &amp;&amp; cloudUser &amp;&amp; dbRef.current) {            const userDocRef = cloud.doc(              dbRef.current,              &#8216;artifacts&#8217;,              appIdRef.current,              &#8216;users&#8217;,              cloudUser.uid,              &#8216;metabolicData&#8217;,              &#8216;dailyState&#8217;            );            await cloud.deleteDoc(userDocRef);          }          lastSavedJsonRef.current = JSON.stringify({            profile: DEFAULT_PROFILE,            nutrition: DEFAULT_NUTRITION,            fasting: DEFAULT_FASTING,            activity: DEFAULT_ACTIVITY,            lifestyle: DEFAULT_LIFESTYLE          });          setProfile(DEFAULT_PROFILE);          setNutrition(DEFAULT_NUTRITION);          setFasting(DEFAULT_FASTING);          setActivity(DEFAULT_ACTIVITY);          setLifestyle(DEFAULT_LIFESTYLE);          setConfirmResetModal(false);          triggerToast(&#8216;All cloud &amp; local records permanently erased.&#8217;);        } catch (err) {          console.error(&#8220;Delete failed:&#8221;, err);          triggerToast(&#8216;Local data cleared; cloud reset completed.&#8217;);        }      };      \/\/ 4. Privacy Safeguard: Export JSON Backup      const handleExportBackup = () =&gt; {        const safeAlias = String(profile.alias || &#8216;backup&#8217;).replace(\/[^a-zA-Z0-9_-]\/g, &#8216;_&#8217;);        const payload = {          exportedFrom: &#8216;groundreportindia.org &#8211; MetabolicGuide&#8217;,          exportedAt: new Date().toISOString(),          profile,          nutrition,          fasting,          activity,          lifestyle        };        const blob = new Blob([JSON.stringify(payload, null, 2)], { type: &#8216;application\/json&#8217; });        const url = URL.createObjectURL(blob);        const a = document.createElement(&#8216;a&#8217;);        a.href = url;        a.download = `metabolicguide-${safeAlias}.json`;        document.body.appendChild(a);        a.click();        document.body.removeChild(a);        URL.revokeObjectURL(url);        triggerToast(&#8216;Downloaded personal JSON health backup&#8217;);      };      \/\/ 4b. Restore Personal JSON Backup      const handleImportBackup = (e) =&gt; {        const file = e.target.files &amp;&amp; e.target.files[0];        if (!file) return;        const reader = new FileReader();        reader.onload = (event) =&gt; {          try {            const parsed = JSON.parse(String(event.target?.result || &#8216;{}&#8217;));            if (!parsed || typeof parsed !== &#8216;object&#8217; || (!parsed.profile &amp;&amp; !parsed.nutrition)) {              triggerToast(&#8216;Invalid backup file format.&#8217;);              return;            }            \/\/ Exit Sample Mode first so imported data applies directly to the user&#8217;s active profile &amp; syncs to Cloud            if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);            activeSampleModeRef.current = null;            setActiveSampleMode(null);            preSampleSnapshotRef.current = null;            applyIncomingData(parsed);            \/\/ Force cloud sync of imported backup            lastSavedJsonRef.current = &#8221;;            triggerToast(&#8216;Successfully restored personal JSON health backup!&#8217;);          } catch (err) {            console.error(&#8220;Backup import failed:&#8221;, err);            triggerToast(&#8216;Could not read JSON backup file.&#8217;);          } finally {            if (fileInputRef.current) fileInputRef.current.value = &#8221;;          }        };        reader.readAsText(file);      };      \/\/ 5. Clinical PDF Report Generator (Vector Print-to-PDF)      const handleDownloadPDF = () =&gt; {        try {          \/\/ If embedded inside a WordPress iframe, ensure print targets the active window          window.focus();          window.print();        } catch (err) {          console.error(&#8220;Print error:&#8221;, err);          triggerToast(&#8216;Press Ctrl+P (or Cmd+P on Mac) to save as PDF.&#8217;);        }      };      const clinicalMetrics = useMemo(() =&gt; {        const weight = toValidNum(profile.weightKg) || 0;        const height = toValidNum(profile.heightCm) || 0;        const age = toValidNum(profile.age) || 0;        const waist = toValidNum(profile.waistCm) || 0;        const hip = toValidNum(profile.hipCm) || 0;        const insulin = toValidNum(profile.fastingInsulin) || 0;        const glucose = toValidNum(profile.fastingGlucose) || 0;        const hba1cVal = toValidNum(profile.hba1c);        const sysBP = toValidNum(profile.systolicBP);        const diaBP = toValidNum(profile.diastolicBP);        const tg = toValidNum(profile.triglycerides) || 0;        const hdl = toValidNum(profile.hdl) || 0;        const alt = toValidNum(profile.alt);        const ast = toValidNum(profile.ast);        const activityMult = toValidNum(profile.activityMultiplier) || 1.375;        const heightM = height \/ 100;        const bmi = weight &gt; 0 &amp;&amp; heightM &gt; 0 ? +(weight \/ (heightM * heightM)).toFixed(1) : null;        const whr = waist &gt; 0 &amp;&amp; hip &gt; 0 ? +(waist \/ hip).toFixed(2) : null;        const whtr = waist &gt; 0 &amp;&amp; height &gt; 0 ? +(waist \/ height).toFixed(2) : null;        const homaIr = insulin &gt; 0 &amp;&amp; glucose &gt; 0 ? +((insulin * glucose) \/ 405).toFixed(2) : null;        const tgHdlRatio = tg &gt; 0 &amp;&amp; hdl &gt; 0 ? +(tg \/ hdl).toFixed(2) : null;        const astAltRatio = ast !== null &amp;&amp; alt !== null &amp;&amp; alt &gt; 0 ? +(ast \/ alt).toFixed(2) : null;        const bmr = weight &gt; 0 &amp;&amp; height &gt; 0 &amp;&amp; age &gt; 0          ? (profile.gender === &#8216;male&#8217;              ? Math.round(10 * weight + 6.25 * height &#8211; 5 * age + 5)              : Math.round(10 * weight + 6.25 * height &#8211; 5 * age &#8211; 161))          : 0;        const tdee = bmr &gt; 0 ? Math.round(bmr * activityMult) : 0;        const targetCalories = tdee &gt; 0 ? Math.round(tdee * 0.85) : 0;        const baseGlucose = glucose &gt; 0 ? glucose : 95;        let peakDelta = 55;        const walks = activity?.postMealWalks || DEFAULT_ACTIVITY.postMealWalks;        const calcWalkBenefit = (enabled, mins, pace) =&gt; {          if (!enabled) return 0;          const durFactor = Math.min(2.0, (toSafeFloat(mins, 15, 5, 120) \/ 15));          const paceMult = pace === &#8216;brisk&#8217; ? 1.25 : pace === &#8216;normal&#8217; ? 1.0 : 0.75;          return Math.round(7 * durFactor * paceMult);        };        const totalWalkReduction =          calcWalkBenefit(walks.breakfastWalk, walks.breakfastWalkMins, walks.breakfastWalkPace) +          calcWalkBenefit(walks.lunchWalk, walks.lunchWalkMins, walks.lunchWalkPace) +          calcWalkBenefit(walks.dinnerWalk, walks.dinnerWalkMins, walks.dinnerWalkPace);        const totalPostMealWalkMins =          (walks.breakfastWalk ? toSafeFloat(walks.breakfastWalkMins, 15, 5, 120) : 0) +          (walks.lunchWalk ? toSafeFloat(walks.lunchWalkMins, 20, 5, 120) : 0) +          (walks.dinnerWalk ? toSafeFloat(walks.dinnerWalkMins, 30, 5, 120) : 0);        const optimalSequences = [          &#8216;fiber-protein-carb&#8217;,          &#8216;protein-fiber-carb-lemon&#8217;,          &#8216;fiber-protein-carb-lemon&#8217;,          &#8216;lemon-fiber-protein-carb&#8217;        ];        if (optimalSequences.includes(nutrition.mealSequence)) peakDelta -= 24;        if (nutrition.mealSequence === &#8216;carb-first&#8217;) peakDelta += 18;        if ([&#8216;cooled-reheated&#8217;, &#8216;potato-cooled-rs3&#8217;, &#8216;vinegar-added&#8217;, &#8216;green-banana-legume&#8217;].includes(nutrition.starchPrepMethod)) peakDelta -= 14;        peakDelta -= Math.min(24, totalWalkReduction);        if (Number(lifestyle.sleepHours) &gt; 0 &amp;&amp; Number(lifestyle.sleepHours) &lt; 6.5) peakDelta += 12;        if (Number(lifestyle.stressScore) &gt;= 7) peakDelta += 10;        peakDelta = Math.max(12, peakDelta);        const glucoseCurve = [          { min: 0, optimized: baseGlucose, unoptimized: baseGlucose },          { min: 30, optimized: Math.round(baseGlucose + peakDelta * 0.75), unoptimized: Math.round(baseGlucose + 52) },          { min: 60, optimized: Math.round(baseGlucose + peakDelta), unoptimized: Math.round(baseGlucose + 68) },          { min: 90, optimized: Math.round(baseGlucose + peakDelta * 0.55), unoptimized: Math.round(baseGlucose + 48) },          { min: 120, optimized: Math.round(baseGlucose + peakDelta * 0.15), unoptimized: Math.round(baseGlucose + 29) }        ];        const parseTimeToMins = (t) =&gt; {          if (typeof t !== &#8216;string&#8217; || !t.includes(&#8216;:&#8217;)) return null;          const parts = t.trim().split(&#8216;:&#8217;);          if (parts.length &lt; 2) return null;          if (parts[0].trim() === &#8221; || parts[1].trim() === &#8221;) return null;          const h = Number(parts[0]);          const m = Number(parts[1]);          if (!Number.isInteger(h) || !Number.isInteger(m) || h &lt; 0 || h &gt; 23 || m &lt; 0 || m &gt; 59) return null;          return h * 60 + m;        };        const wakeMins = parseTimeToMins(fasting.wakeTime);        const firstMealMins = parseTimeToMins(fasting.firstMealTime);        const lastMealMins = parseTimeToMins(fasting.lastMealTime);        const sleepMins = parseTimeToMins(fasting.sleepTime);        const morningGapHours = wakeMins !== null &amp;&amp; firstMealMins !== null          ? +(((firstMealMins &#8211; wakeMins + 1440) % 1440) \/ 60).toFixed(1)          : null;        const eveningGapHours = sleepMins !== null &amp;&amp; lastMealMins !== null          ? +(((sleepMins &#8211; lastMealMins + 1440) % 1440) \/ 60).toFixed(1)          : null;        let reversalScore = 65;        if (homaIr !== null) {          if (homaIr &lt; 1.5) reversalScore += 10;          else if (homaIr &gt; 2.5) reversalScore -= 8;        }        if (optimalSequences.includes(nutrition.mealSequence)) reversalScore += 8;        if (nutrition.cookingFat === &#8216;refined-seed&#8217;) reversalScore -= 12;        else reversalScore += 5;        if (Number(nutrition.snackingCount) === 0) reversalScore += 8;        else if (Number(nutrition.snackingCount) &gt;= 3) reversalScore -= 10;        if (eveningGapHours !== null &amp;&amp; eveningGapHours &gt;= 3) reversalScore += 7;        if (walks.dinnerWalk) reversalScore += Math.min(10, Math.round(totalPostMealWalkMins \/ 5));        if (Number(lifestyle.stressScore) &lt;= 4 &amp;&amp; Number(lifestyle.sleepHours) &gt;= 7) reversalScore += 6;        reversalScore = Math.min(99, Math.max(25, reversalScore));        return {          bmi, whr, whtr, homaIr, tgHdlRatio, astAltRatio,          hba1cVal, sysBP, diaBP, altVal: alt, astVal: ast,          bmr, tdee, targetCalories, glucoseCurve,          morningGapHours, eveningGapHours, reversalScore,          totalPostMealWalkMins, totalWalkReduction        };      }, [profile, nutrition, fasting, activity, lifestyle]);      const nutritionTotals = useMemo(() =&gt; {        const safeFoods = Array.isArray(nutrition?.loggedFoods) ? nutrition.loggedFoods : [];        const safeWater = Array.isArray(nutrition?.waterLogs) ? nutrition.waterLogs : [];        const totals = safeFoods.reduce(          (acc, item) =&gt; ({            cal: Math.round(acc.cal + (Number(item?.cal) || 0)),            pro: +(acc.pro + (Number(item?.pro) || 0)).toFixed(1),            carb: +(acc.carb + (Number(item?.carb) || 0)).toFixed(1),            fiber: +(acc.fiber + (Number(item?.fiber) || 0)).toFixed(1),            fat: +(acc.fat + (Number(item?.fat) || 0)).toFixed(1),            sfa: +(acc.sfa + (Number(item?.sfa) || 0)).toFixed(1),            mufa: +(acc.mufa + (Number(item?.mufa) || 0)).toFixed(1),            pufa: +(acc.pufa + (Number(item?.pufa) || 0)).toFixed(1),            mg: Math.round(acc.mg + (Number(item?.mg) || 0)),            k: Math.round(acc.k + (Number(item?.k) || 0)),            ca: Math.round(acc.ca + (Number(item?.ca) || 0)),            fe: +(acc.fe + (Number(item?.fe) || 0)).toFixed(1),            zn: +(acc.zn + (Number(item?.zn) || 0)).toFixed(1),            vitC: Math.round(acc.vitC + (Number(item?.vitC) || 0)),            vitA: Math.round(acc.vitA + (Number(item?.vitA) || 0)),            vitD: Math.round(acc.vitD + (Number(item?.vitD) || 0)),            b12: +(acc.b12 + (Number(item?.b12) || 0)).toFixed(1),            folate: Math.round(acc.folate + (Number(item?.folate) || 0)),            choline: Math.round(acc.choline + (Number(item?.choline) || 0)),            leucine: +(acc.leucine + (Number(item?.leucine) || 0)).toFixed(2),            omega3: +(acc.omega3 + (Number(item?.omega3) || 0)).toFixed(2),            glycemicLoad: Math.round(acc.glycemicLoad + (Number(item?.glycemicLoad) || 0))          }),          { cal: 0, pro: 0, carb: 0, fiber: 0, fat: 0, sfa: 0, mufa: 0, pufa: 0, mg: 0, k: 0, ca: 0, fe: 0, zn: 0, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 0, choline: 0, leucine: 0, omega3: 0, glycemicLoad: 0 }        );        const totalWaterMl = safeWater.reduce((sum, w) =&gt; sum + (Number(w?.amountMl) || 0), 0);        const hasPlainROWarning = safeWater.some(w =&gt; w?.source === &#8216;Plain RO (Unmineralized)&#8217;);        \/\/ Calculate % Daily Value (%DV) achieved for each key nutrient        const weightNum = toValidNum(profile.weightKg);        const dynamicProTarget = weightNum ? Math.round(weightNum * 1.2) : DAILY_VALUE_TARGETS.pro.dv;        const dvProgress = Object.entries(DAILY_VALUE_TARGETS).map(([key, meta]) =&gt; {          const target = key === &#8216;pro&#8217; ? dynamicProTarget : meta.dv;          const current = Number(totals[key]) || 0;          const pct = target &gt; 0 ? Math.min(200, Math.round((current \/ target) * 100)) : 0;          return { key, &#8230;meta, target, current, pct };        });        \/\/ Smart Diet-Compatible Food Recommendations for any nutrient below 60% DV        const activeDiet = toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20);        const compatibleFoods = FOOD_DATABASE.filter(f =&gt; f.diet.includes(activeDiet));        const lackingNutrients = dvProgress          .filter(n =&gt; n.pct &lt; 60)          .sort((a, b) =&gt; a.pct &#8211; b.pct)          .slice(0, 4)          .map(gap =&gt; {            const bestFoods = [&#8230;compatibleFoods]              .filter(f =&gt; (Number(f[gap.key]) || 0) &gt; 0)              .sort((a, b) =&gt; (Number(b[gap.key]) || 0) &#8211; (Number(a[gap.key]) || 0))              .slice(0, 2);            return { &#8230;gap, bestFoods };          });        return {          &#8230;totals,          netCarbs: Math.max(0, +(totals.carb &#8211; totals.fiber).toFixed(1)),          totalWaterMl,          hasPlainROWarning,          dynamicProTarget,          dvProgress,          lackingNutrients        };      }, [nutrition, profile.weightKg, profile.dietPreference]);      \/\/ Interactive Single-Food Nutrient &amp; %DV Inspector State      const [inspectorCategory, setInspectorCategory] = useState(&#8216;All&#8217;);      const [inspectorSearch, setInspectorSearch] = useState(&#8221;);      const [inspectorFoodId, setInspectorFoodId] = useState(&#8216;f11&#8217;);      const [inspectorPortionMode, setInspectorPortionMode] = useState(&#8216;servings&#8217;); \/\/ &#8216;servings&#8217; | &#8216;grams&#8217;      const [inspectorServings, setInspectorServings] = useState(1);      const [inspectorGrams, setInspectorGrams] = useState(150);      \/\/ Extract default gram weight from a food&#8217;s name (e.g., &#8220;(150g)&#8221; -&gt; 150, &#8220;(28g)&#8221; -&gt; 28, fallback 100g)      const getBaseGrams = (foodObj) =&gt; {        if (!foodObj || typeof foodObj.name !== &#8216;string&#8217;) return 100;        const match = foodObj.name.match(\/(d+)s*gb\/i);        return match ? Math.max(5, Number(match[1])) : 100;      };      const filteredInspectorFoods = useMemo(() =&gt; {        const q = inspectorSearch.trim().toLowerCase();        return FOOD_DATABASE.filter(f =&gt; {          const matchesCat = inspectorCategory === &#8216;All&#8217; || f.category === inspectorCategory;          const matchesSearch = !q || f.name.toLowerCase().includes(q) || f.category.toLowerCase().includes(q);          return matchesCat &amp;&amp; matchesSearch;        });      }, [inspectorCategory, inspectorSearch]);      const inspectedFoodMetrics = useMemo(() =&gt; {        const baseFood = FOOD_DATABASE.find(f =&gt; f.id === inspectorFoodId) || FOOD_DATABASE[0];        const baseGrams = getBaseGrams(baseFood);        const effectiveServings = inspectorPortionMode === &#8216;grams&#8217;          ? toSafeFloat(inspectorGrams, baseGrams, 5, 2000) \/ baseGrams          : toSafeFloat(inspectorServings, 1, 0.25, 10);        const effectiveGrams = Math.round(baseGrams * effectiveServings);        return {          baseFood,          baseGrams,          effectiveGrams,          effectiveServings: +effectiveServings.toFixed(2),          &#8230;scaleFoodItem(baseFood, effectiveServings)        };      }, [inspectorFoodId, inspectorPortionMode, inspectorServings, inspectorGrams]);      const addFoodToLog = (foodId, customServings = 1, customLabel = null) =&gt; {        const food = FOOD_DATABASE.find(f =&gt; f.id === foodId);        if (!food) return;        const scaled = scaleFoodItem(food, customServings);        const baseNameClean = food.name.split(&#8216;(&#8216;)[0].trim();        const displayTitle = customLabel          ? `${baseNameClean} (${customLabel})`          : (scaled.mult === 1 ? food.name : `${food.name} (${scaled.mult}x serving)`);        const scaledFood = {          &#8230;scaled,          instanceId: makeUniqueId(),          name: displayTitle        };        setNutrition(prev =&gt; {          const existing = Array.isArray(prev.loggedFoods) ? prev.loggedFoods : [];          if (existing.length &gt;= 150) return prev;          return {            &#8230;prev,            loggedFoods: [&#8230;existing, scaledFood]          };        });        triggerToast(`Added ${scaledFood.name}`);      };      const removeFoodFromLog = (instanceId) =&gt; {        setNutrition(prev =&gt; ({          &#8230;prev,          loggedFoods: (Array.isArray(prev.loggedFoods) ? prev.loggedFoods : []).filter(f =&gt; f.instanceId !== instanceId)        }));      };      const [newWater, setNewWater] = useState({ timing: &#8216;Morning Waking&#8217;, amountMl: &#8216;350&#8217;, source: &#8216;Natural Mineral Water&#8217; });      const addWaterLog = (e, quickAmountMl = null) =&gt; {        if (e &amp;&amp; e.preventDefault) e.preventDefault();        const amt = toValidNum(quickAmountMl !== null ? quickAmountMl : newWater.amountMl);        if (!amt) {          triggerToast(&#8216;Please select or enter a water volume in ml&#8217;);          return;        }        const clampedAmt = Math.min(5000, Math.round(amt));        setNutrition(prev =&gt; {          const existing = Array.isArray(prev.waterLogs) ? prev.waterLogs : [];          return {            &#8230;prev,            waterLogs: [&#8230;existing.slice(-149), { &#8230;newWater, id: makeUniqueId(), amountMl: clampedAmt }]          };        });        triggerToast(`Logged ${clampedAmt}ml (${newWater.source})`);      };      const removeWaterFromLog = (waterId) =&gt; {        setNutrition(prev =&gt; ({          &#8230;prev,          waterLogs: (Array.isArray(prev.waterLogs) ? prev.waterLogs : []).filter(w =&gt; w.id !== waterId)        }));      };      const [newWorkout, setNewWorkout] = useState({        type: &#8216;Resistance Training (Hypertrophy)&#8217;,        intensity: &#8216;Moderate (RPE 7)&#8217;,        durationMin: &#8221;,        fastedState: true,        preWorkoutNutrition: &#8216;Mineral Water + Pinch of Sendha Salt \/ Black Coffee&#8217;,        intraWorkoutHydration: &#8216;400ml Mineral \/ Electrolyte Water&#8217;,        postWorkoutNutrition: &#8216;High-Leucine Protein + Whole Food Carbs within 45m&#8217;      });      const addWorkoutLog = (e) =&gt; {        e.preventDefault();        const dur = Math.min(600, Math.round(toValidNum(newWorkout.durationMin) || 30));        setActivity(prev =&gt; {          const existing = Array.isArray(prev.workouts) ? prev.workouts : [];          return {            &#8230;prev,            workouts: [&#8230;existing.slice(-99), { &#8230;newWorkout, id: makeUniqueId(), durationMin: dur }]          };        });        setNewWorkout(prev =&gt; ({ &#8230;prev, durationMin: &#8221; }));        triggerToast(`Logged ${newWorkout.type} (${dur} mins)`);      };      const removeWorkoutFromLog = (workoutId) =&gt; {        setActivity(prev =&gt; ({          &#8230;prev,          workouts: (Array.isArray(prev.workouts) ? prev.workouts : []).filter(w =&gt; w.id !== workoutId)        }));      };      const loadClinicalPreset = (presetType) =&gt; {        \/\/ Deep-clone the user&#8217;s real inputs before entering Sample Mode so nested objects\/arrays are never mutated        if (activeSampleMode === null &amp;&amp; activeSampleModeRef.current === null) {          preSampleSnapshotRef.current = deepCloneState({            profile,            nutrition,            fasting,            activity,            lifestyle          });        }        if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);        activeSampleModeRef.current = presetType;        setActiveSampleMode(presetType);        if (presetType === &#8216;reversing&#8217;) {          setProfile(p =&gt; ({            &#8230;p, alias: &#8216;SAMPLE: Optimal Demo&#8217;, age: &#8217;42&#8217;, weightKg: &#8217;74&#8217;, heightCm: &#8216;174&#8217;, bodyFatPct: &#8216;18.5&#8217;, neckCm: &#8217;37&#8217;,            hba1c: &#8216;5.3&#8217;, fastingInsulin: &#8216;4.8&#8217;, fastingGlucose: &#8217;84&#8217;, systolicBP: &#8216;116&#8217;, diastolicBP: &#8217;74&#8217;,            alt: &#8217;21&#8217;, ast: &#8217;20&#8217;, ggt: &#8217;19&#8217;, triglycerides: &#8217;82&#8217;, hdl: &#8217;58&#8217;, waistCm: &#8217;84&#8217;, hipCm: &#8217;98&#8217;          }));          setNutrition(n =&gt; ({            &#8230;n, mealSequence: &#8216;fiber-protein-carb&#8217;, cookingFat: &#8216;ghee&#8217;, snackingCount: 0,            starchPrepMethod: &#8216;cooled-reheated&#8217;          }));          setFasting(f =&gt; ({ &#8230;f, protocol: &#8217;18:6&#8242;, currentFastHours: 18, mealsPerDay: 2, wakeTime: &#8217;06:30&#8242;, firstMealTime: &#8217;11:30&#8242;, lastMealTime: &#8217;18:00&#8242;, sleepTime: &#8217;22:15&#8242; }));          setActivity(a =&gt; ({            &#8230;a,            postMealWalks: {              breakfastWalk: true, breakfastWalkMins: 15, breakfastWalkPace: &#8216;brisk&#8217;,              lunchWalk: true, lunchWalkMins: 20, lunchWalkPace: &#8216;brisk&#8217;,              dinnerWalk: true, dinnerWalkMins: 30, dinnerWalkPace: &#8216;brisk&#8217;            },            dailySteps: 9500          }));          setLifestyle(l =&gt; ({ &#8230;l, sleepHours: 8, stressScore: 2, wakingGlucose: &#8217;84&#8217;, sunlightDurationMin: 25, skinExposurePct: 40 }));          triggerToast(&#8216;Viewing Optimal Sample (Cloud Sync Paused)&#8217;);        } else {          setProfile(p =&gt; ({            &#8230;p, alias: &#8216;SAMPLE: High-Risk Demo&#8217;, age: &#8217;48&#8217;, weightKg: &#8217;92&#8217;, heightCm: &#8216;172&#8217;, bodyFatPct: &#8216;29.5&#8217;, neckCm: &#8217;41&#8217;,            hba1c: &#8216;6.8&#8217;, fastingInsulin: &#8216;22.4&#8217;, fastingGlucose: &#8216;128&#8217;, systolicBP: &#8216;142&#8217;, diastolicBP: &#8217;92&#8217;,            alt: &#8217;64&#8217;, ast: &#8217;48&#8217;, ggt: &#8217;55&#8217;, triglycerides: &#8216;240&#8217;, hdl: &#8217;34&#8217;, waistCm: &#8216;104&#8217;, hipCm: &#8216;100&#8217;          }));          setNutrition(n =&gt; ({            &#8230;n, mealSequence: &#8216;carb-first&#8217;, cookingFat: &#8216;refined-seed&#8217;, snackingCount: 3,            starchPrepMethod: &#8216;pressure-cooked-hot&#8217;          }));          setFasting(f =&gt; ({ &#8230;f, protocol: &#8217;14:10&#8242;, currentFastHours: 11, mealsPerDay: 4, wakeTime: &#8217;07:00&#8242;, firstMealTime: &#8217;07:30&#8242;, lastMealTime: &#8217;21:45&#8242;, sleepTime: &#8217;23:00&#8242; }));          setActivity(a =&gt; ({            &#8230;a,            postMealWalks: {              breakfastWalk: false, breakfastWalkMins: 15, breakfastWalkPace: &#8216;slow&#8217;,              lunchWalk: false, lunchWalkMins: 15, lunchWalkPace: &#8216;slow&#8217;,              dinnerWalk: false, dinnerWalkMins: 15, dinnerWalkPace: &#8216;slow&#8217;            },            dailySteps: 3200          }));          setLifestyle(l =&gt; ({ &#8230;l, sleepHours: 5.5, stressScore: 8, wakingGlucose: &#8216;128&#8217;, sunlightDurationMin: 5, skinExposurePct: 10 }));          triggerToast(&#8216;Viewing High-Risk Sample (Cloud Sync Paused)&#8217;);        }      };      const exitSampleModeAndRestore = () =&gt; {        if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);        activeSampleModeRef.current = null;        if (preSampleSnapshotRef.current) {          const snap = deepCloneState(preSampleSnapshotRef.current);          const restoredPayload = {            profile: snap.profile || DEFAULT_PROFILE,            nutrition: snap.nutrition || DEFAULT_NUTRITION,            fasting: snap.fasting || DEFAULT_FASTING,            activity: snap.activity || DEFAULT_ACTIVITY,            lifestyle: snap.lifestyle || DEFAULT_LIFESTYLE          };          lastSavedJsonRef.current = JSON.stringify(restoredPayload);          setProfile(restoredPayload.profile);          setNutrition(restoredPayload.nutrition);          setFasting(restoredPayload.fasting);          setActivity(restoredPayload.activity);          setLifestyle(restoredPayload.lifestyle);          preSampleSnapshotRef.current = null;        } else {          const defaultPayload = {            profile: DEFAULT_PROFILE,            nutrition: DEFAULT_NUTRITION,            fasting: DEFAULT_FASTING,            activity: DEFAULT_ACTIVITY,            lifestyle: DEFAULT_LIFESTYLE          };          lastSavedJsonRef.current = JSON.stringify(defaultPayload);          setProfile(DEFAULT_PROFILE);          setNutrition(DEFAULT_NUTRITION);          setFasting(DEFAULT_FASTING);          setActivity(DEFAULT_ACTIVITY);          setLifestyle(DEFAULT_LIFESTYLE);        }        setActiveSampleMode(null);        triggerToast(&#8216;Exited Sample Mode \u2014 Ready for your personal data!&#8217;);      };      return (        &lt;div className=&#8221;min-h-screen bg-slate-50 text-slate-800 font-sans pb-16&#8243;&gt;          &lt;div className=&#8221;no-print&#8221;&gt;            {\/* Toast Notification *\/}            {toastMessage &amp;&amp; (              &lt;div className=&#8221;fixed bottom-5 right-5 z-50 flex items-center gap-2.5 bg-slate-900 text-white px-4 py-3 rounded-xl shadow-2xl border border-teal-500\/40&#8243;&gt;                &lt;Icon name=&#8221;check&#8221; className=&#8221;w-5 h-5 text-teal-400 shrink-0&#8243; \/&gt;                &lt;span className=&#8221;text-sm font-medium&#8221;&gt;{toastMessage}&lt;\/span&gt;              &lt;\/div&gt;            )}            {\/* Confirm Delete Cloud Data Modal *\/}            {confirmResetModal &amp;&amp; (              &lt;div className=&#8221;fixed inset-0 z-50 bg-slate-950\/70 backdrop-blur-sm flex items-center justify-center p-4&#8243;&gt;                &lt;div className=&#8221;bg-white rounded-2xl max-w-md w-full p-6 shadow-2xl border border-slate-200 space-y-4&#8243;&gt;                  &lt;div className=&#8221;flex items-center gap-2.5 text-rose-600 font-bold text-base&#8221;&gt;                    &lt;Icon name=&#8221;alert&#8221; className=&#8221;w-6 h-6&#8243; \/&gt;                    &lt;span&gt;Permanently Erase Cloud &amp; Local Data?&lt;\/span&gt;                  &lt;\/div&gt;                  &lt;p className=&#8221;text-xs text-slate-600 leading-relaxed&#8221;&gt;                    This will permanently delete your private health vault from both the cloud database and this browser, resetting all biomarkers and logs to blank.                  &lt;\/p&gt;                  &lt;div className=&#8221;flex items-center justify-end gap-2 pt-2&#8243;&gt;                    &lt;button                      type=&#8221;button&#8221;                      onClick={() =&gt; setConfirmResetModal(false)}                      className=&#8221;px-4 py-2 rounded-xl text-xs font-semibold bg-slate-100 text-slate-700 hover:bg-slate-200&#8243;                    &gt;                      Cancel                    &lt;\/button&gt;                    &lt;button                      type=&#8221;button&#8221;                      onClick={handleDeleteCloudData}                      className=&#8221;px-4 py-2 rounded-xl text-xs font-semibold bg-rose-600 text-white hover:bg-rose-700&#8243;                    &gt;                      Yes, Erase My Cloud Data                    &lt;\/button&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              &lt;\/div&gt;            )}            {\/* Top Header *\/}            &lt;header className=&#8221;bg-gradient-to-r from-slate-900 via-teal-950 to-slate-900 text-white border-b border-teal-800\/50 sticky top-0 z-30 shadow-md&#8221;&gt;              &lt;div className=&#8221;max-w-7xl mx-auto px-4 sm:px-6 py-3.5 flex flex-wrap items-center justify-between gap-4&#8243;&gt;                &lt;div className=&#8221;flex items-center gap-3&#8243;&gt;                  &lt;div className=&#8221;w-10 h-10 rounded-xl bg-teal-500\/20 border border-teal-400\/40 flex items-center justify-center text-teal-300&#8243;&gt;                    &lt;Icon name=&#8221;activity&#8221; className=&#8221;w-6 h-6&#8243; \/&gt;                  &lt;\/div&gt;                  &lt;div&gt;                    &lt;div className=&#8221;flex flex-wrap items-center gap-2&#8243;&gt;                      &lt;h1 className=&#8221;text-lg sm:text-xl font-bold tracking-tight text-white&#8221;&gt;MetabolicGuide&lt;\/h1&gt;                      &lt;span className=&#8221;text-[11px] uppercase tracking-wider px-2 py-0.5 rounded bg-teal-500\/20 text-teal-300 border border-teal-400\/30 font-semibold&#8221;&gt;                        GroundReportIndia Wellness Guide                      &lt;\/span&gt;                    &lt;\/div&gt;                    &lt;p className=&#8221;text-xs text-slate-300 hidden sm:block&#8221;&gt;                      Science-Based Nutrition &amp; Lifestyle Tracker for Insulin Sensitivity, Blood Sugar, Liver &amp; Heart Health                    &lt;\/p&gt;                  &lt;\/div&gt;                &lt;\/div&gt;                {\/* Cloud Sync Status + Privacy Actions + Wellness Score *\/}                &lt;div className=&#8221;flex flex-wrap items-center gap-2&#8243;&gt;                  {\/* Live Cloud Vault Pill *\/}                  &lt;div className=&#8221;flex items-center gap-1.5 bg-slate-800\/90 px-3 py-1.5 rounded-xl border border-slate-700 text-xs&#8221;&gt;                    &lt;Icon                      name=&#8221;cloud&#8221;                      className={`w-4 h-4 ${                        activeSampleMode !== null                          ? &#8216;text-amber-400&#8217;                          : cloudStatus === &#8216;synced&#8217;                          ? &#8216;text-emerald-400&#8217;                          : cloudStatus === &#8216;saving&#8217;                          ? &#8216;text-amber-400 animate-pulse&#8217;                          : &#8216;text-slate-400&#8217;                      }`}                    \/&gt;                    &lt;span className=&#8221;font-semibold text-slate-200&#8243;&gt;                      {activeSampleMode !== null                        ? &#8216;Sample Mode (Cloud Paused)&#8217;                        : cloudStatus === &#8216;synced&#8217;                        ? &#8216;Cloud Vault Synced&#8217;                        : cloudStatus === &#8216;saving&#8217;                        ? &#8216;Saving to Cloud&#8230;&#8217;                        : cloudStatus === &#8216;connecting&#8217;                        ? &#8216;Connecting Vault&#8230;&#8217;                        : cloudStatus === &#8216;unconfigured&#8217;                        ? &#8216;Local Backup Active&#8217;                        : &#8216;Local Vault Active&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                  {\/* Privacy Controls: PDF Report, Export\/Import JSON &amp; Wipe Cloud Data *\/}                  &lt;button                    type=&#8221;button&#8221;                    onClick={handleDownloadPDF}                    className=&#8221;flex items-center gap-1.5 bg-teal-600 hover:bg-teal-500 text-white px-3 py-1.5 rounded-xl border border-teal-400\/50 text-xs font-semibold shadow-sm transition&#8221;                    title=&#8221;Download Personal Summary Report (PDF)&#8221;                  &gt;                    &lt;Icon name=&#8221;printer&#8221; className=&#8221;w-3.5 h-3.5 text-white&#8221; \/&gt;                    &lt;span&gt;PDF Summary&lt;\/span&gt;                  &lt;\/button&gt;                  &lt;button                    type=&#8221;button&#8221;                    onClick={handleExportBackup}                    className=&#8221;flex items-center gap-1 bg-slate-800 hover:bg-teal-800 text-slate-100 px-2.5 py-1.5 rounded-xl border border-slate-600 text-xs font-medium transition&#8221;                    title=&#8221;Export Personal Backup (JSON)&#8221;                  &gt;                    &lt;Icon name=&#8221;download&#8221; className=&#8221;w-3.5 h-3.5 text-teal-400&#8243; \/&gt;                    &lt;span className=&#8221;hidden md:inline&#8221;&gt;Export&lt;\/span&gt;                  &lt;\/button&gt;                  &lt;button                    type=&#8221;button&#8221;                    onClick={() =&gt; fileInputRef.current &amp;&amp; fileInputRef.current.click()}                    className=&#8221;flex items-center gap-1 bg-slate-800 hover:bg-teal-800 text-slate-100 px-2.5 py-1.5 rounded-xl border border-slate-600 text-xs font-medium transition&#8221;                    title=&#8221;Restore Personal Backup (JSON)&#8221;                  &gt;                    &lt;Icon name=&#8221;upload&#8221; className=&#8221;w-3.5 h-3.5 text-sky-400&#8243; \/&gt;                    &lt;span className=&#8221;hidden md:inline&#8221;&gt;Import&lt;\/span&gt;                  &lt;\/button&gt;                  &lt;input                    ref={fileInputRef}                    type=&#8221;file&#8221;                    accept=&#8221;.json,application\/json&#8221;                    onChange={handleImportBackup}                    className=&#8221;hidden&#8221;                  \/&gt;                  &lt;button                    type=&#8221;button&#8221;                    onClick={() =&gt; setConfirmResetModal(true)}                    className=&#8221;flex items-center gap-1 bg-rose-900\/80 hover:bg-rose-700 text-rose-100 px-2.5 py-1.5 rounded-xl border border-rose-700\/60 text-xs font-medium transition&#8221;                    title=&#8221;Delete My Cloud Data&#8221;                  &gt;                    &lt;Icon name=&#8221;trash&#8221; className=&#8221;w-3.5 h-3.5 text-rose-300&#8243; \/&gt;                    &lt;span className=&#8221;hidden md:inline&#8221;&gt;Reset Vault&lt;\/span&gt;                  &lt;\/button&gt;                  {\/* Wellness Score Badge *\/}                  &lt;div className=&#8221;flex items-center gap-2 bg-teal-900\/60 border border-teal-500\/40 px-3 py-1 rounded-xl&#8221;&gt;                    &lt;div className=&#8221;text-right&#8221;&gt;                      &lt;div className=&#8221;text-[10px] uppercase tracking-wider text-teal-300 font-semibold&#8221;&gt;Metabolic Score&lt;\/div&gt;                      &lt;div className=&#8221;text-sm font-bold text-white&#8221;&gt;{clinicalMetrics.reversalScore}\/100&lt;\/div&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;w-7 h-7 rounded-lg bg-teal-500 text-slate-950 font-extrabold flex items-center justify-center text-xs&#8221;&gt;                      {clinicalMetrics.reversalScore &gt;= 75 ? &#8216;A&#8217; : clinicalMetrics.reversalScore &gt;= 55 ? &#8216;B&#8217; : &#8216;C&#8217;}                    &lt;\/div&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              &lt;\/div&gt;              {\/* Biomarker Ribbon *\/}              &lt;div className=&#8221;bg-slate-900\/80 border-t border-slate-800\/80&#8243;&gt;                &lt;div className=&#8221;max-w-7xl mx-auto px-4 sm:px-6 py-2 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 text-xs&#8221;&gt;                  &lt;div className=&#8221;flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60&#8243;&gt;                    &lt;span className=&#8221;text-slate-400&#8243;&gt;HOMA-IR:&lt;\/span&gt;                    &lt;span className={`font-bold ${clinicalMetrics.homaIr === null ? &#8216;text-slate-400&#8217; : clinicalMetrics.homaIr &lt; 1.5 ? &#8216;text-emerald-400&#8217; : clinicalMetrics.homaIr &lt; 2.5 ? &#8216;text-amber-400&#8217; : &#8216;text-rose-400&#8217;}`}&gt;                      {clinicalMetrics.homaIr !== null ? `${clinicalMetrics.homaIr} ${clinicalMetrics.homaIr &lt; 1.5 ? &#8216;(Sensitive)&#8217; : &#8216;(Resistant)&#8217;}` : &#8216;\u2014&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60&#8243;&gt;                    &lt;span className=&#8221;text-slate-400&#8243;&gt;HbA1c:&lt;\/span&gt;                    &lt;span className={`font-bold ${clinicalMetrics.hba1cVal === null ? &#8216;text-slate-400&#8217; : clinicalMetrics.hba1cVal &lt; 5.7 ? &#8216;text-emerald-400&#8217; : clinicalMetrics.hba1cVal &lt; 6.5 ? &#8216;text-amber-400&#8217; : &#8216;text-rose-400&#8217;}`}&gt;                      {clinicalMetrics.hba1cVal !== null ? `${clinicalMetrics.hba1cVal}%` : &#8216;\u2014&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60&#8243;&gt;                    &lt;span className=&#8221;text-slate-400&#8243;&gt;TG:HDL Ratio:&lt;\/span&gt;                    &lt;span className={`font-bold ${clinicalMetrics.tgHdlRatio === null ? &#8216;text-slate-400&#8217; : clinicalMetrics.tgHdlRatio &lt; 2.0 ? &#8216;text-emerald-400&#8217; : &#8216;text-rose-400&#8217;}`}&gt;                      {clinicalMetrics.tgHdlRatio !== null ? clinicalMetrics.tgHdlRatio : &#8216;\u2014&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60&#8243;&gt;                    &lt;span className=&#8221;text-slate-400&#8243;&gt;Waist-to-Hip:&lt;\/span&gt;                    &lt;span className={`font-bold ${clinicalMetrics.whr === null ? &#8216;text-slate-400&#8217; : (profile.gender === &#8216;male&#8217; ? clinicalMetrics.whr &lt; 0.9 : clinicalMetrics.whr &lt; 0.85) ? &#8216;text-emerald-400&#8217; : &#8216;text-amber-400&#8217;}`}&gt;                      {clinicalMetrics.whr !== null ? clinicalMetrics.whr : &#8216;\u2014&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60&#8243;&gt;                    &lt;span className=&#8221;text-slate-400&#8243;&gt;Liver ALT:&lt;\/span&gt;                    &lt;span className={`font-bold ${clinicalMetrics.altVal === null ? &#8216;text-slate-400&#8217; : clinicalMetrics.altVal &lt;= 30 ? &#8216;text-emerald-400&#8217; : &#8216;text-amber-400&#8217;}`}&gt;                      {clinicalMetrics.altVal !== null ? `${clinicalMetrics.altVal} U\/L` : &#8216;\u2014&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60&#8243;&gt;                    &lt;span className=&#8221;text-slate-400&#8243;&gt;BP:&lt;\/span&gt;                    &lt;span className={`font-bold ${clinicalMetrics.sysBP === null || clinicalMetrics.diaBP === null ? &#8216;text-slate-400&#8217; : clinicalMetrics.sysBP &lt;= 120 &amp;&amp; clinicalMetrics.diaBP &lt;= 80 ? &#8216;text-emerald-400&#8217; : &#8216;text-amber-400&#8217;}`}&gt;                      {clinicalMetrics.sysBP !== null &amp;&amp; clinicalMetrics.diaBP !== null ? `${clinicalMetrics.sysBP}\/${clinicalMetrics.diaBP}` : &#8216;\u2014&#8217;}                    &lt;\/span&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              &lt;\/div&gt;            &lt;\/header&gt;            {\/* Navigation Tabs *\/}            &lt;div className=&#8221;max-w-7xl mx-auto px-4 sm:px-6 pt-5&#8243;&gt;              &lt;div className=&#8221;flex flex-wrap items-center justify-between gap-2 mb-3&#8243;&gt;                &lt;nav className=&#8221;flex flex-wrap gap-1.5 bg-white p-1.5 rounded-2xl shadow-sm border border-slate-200 flex-1&#8243;&gt;                  {[                    { id: &#8216;profile&#8217;, label: &#8216;1. Profile &amp; Biomarkers&#8217;, icon: &#8216;userCheck&#8217; },                    { id: &#8216;nutrition&#8217;, label: &#8216;2. Nutrition, Sequencing &amp; RS3&#8217;, icon: &#8216;utensils&#8217; },                    { id: &#8216;fasting&#8217;, label: &#8216;3. Fasting &amp; Circadian&#8217;, icon: &#8216;clock&#8217; },                    { id: &#8216;activity&#8217;, label: &#8216;4. Exercise &amp; Walk&#8217;, icon: &#8216;footprints&#8217; },                    { id: &#8216;lifestyle&#8217;, label: &#8216;5. Sunlight, Sleep &amp; Stress&#8217;, icon: &#8216;sun&#8217; },                    { id: &#8216;insights&#8217;, label: &#8216;6. Science-Based Action Guide&#8217;, icon: &#8216;brain&#8217; }                  ].map(tab =&gt; {                    const active = activeTab === tab.id;                    return (                      &lt;button                        key={tab.id}                        type=&#8221;button&#8221;                        onClick={() =&gt; setActiveTab(tab.id)}                        className={`flex items-center gap-2 px-3 py-2 rounded-xl text-xs sm:text-sm font-semibold transition-all flex-1 sm:flex-initial justify-center ${                          active                            ? &#8216;bg-teal-600 text-white shadow-sm&#8217;                            : &#8216;text-slate-600 hover:bg-teal-50 hover:text-teal-800&#8217;                        }`}                      &gt;                        &lt;Icon name={tab.icon} className=&#8221;w-4 h-4 shrink-0&#8243; \/&gt;                        &lt;span&gt;{tab.label}&lt;\/span&gt;                      &lt;\/button&gt;                    );                  })}                &lt;\/nav&gt;                {\/* Quick Demo Presets *\/}                &lt;div className=&#8221;flex items-center gap-1.5 bg-white px-3 py-2 rounded-2xl border border-slate-200 text-xs shadow-sm&#8221;&gt;                  &lt;span className=&#8221;text-slate-500 font-medium&#8221;&gt;Preview Demo Only:&lt;\/span&gt;                  &lt;button                    type=&#8221;button&#8221;                    onClick={() =&gt; loadClinicalPreset(&#8216;high-risk&#8217;)}                    className={`px-2 py-1 rounded-lg font-semibold transition ${                      activeSampleMode === &#8216;high-risk&#8217;                        ? &#8216;bg-rose-600 text-white&#8217;                        : &#8216;bg-rose-50 text-rose-700 hover:bg-rose-100&#8217;                    }`}                  &gt;                    High-Risk Sample                  &lt;\/button&gt;                  &lt;button                    type=&#8221;button&#8221;                    onClick={() =&gt; loadClinicalPreset(&#8216;reversing&#8217;)}                    className={`px-2 py-1 rounded-lg font-semibold transition ${                      activeSampleMode === &#8216;reversing&#8217;                        ? &#8216;bg-emerald-600 text-white&#8217;                        : &#8216;bg-emerald-50 text-emerald-700 hover:bg-emerald-100&#8217;                    }`}                  &gt;                    Optimal Sample                  &lt;\/button&gt;                  {activeSampleMode !== null &amp;&amp; (                    &lt;button                      type=&#8221;button&#8221;                      onClick={exitSampleModeAndRestore}                      className=&#8221;px-2.5 py-1 rounded-lg bg-amber-500 hover:bg-amber-600 text-white font-bold shadow-sm transition&#8221;                    &gt;                      \u2715 Exit Sample                    &lt;\/button&gt;                  )}                &lt;\/div&gt;              &lt;\/div&gt;              {\/* High-Visibility Sample Mode Protection Banner *\/}              {activeSampleMode !== null &amp;&amp; (                &lt;div className=&#8221;mb-3 p-3.5 rounded-2xl bg-amber-50 border-2 border-amber-400 shadow-sm flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3&#8243;&gt;                  &lt;div className=&#8221;flex items-start sm:items-center gap-2.5 text-xs text-amber-950&#8243;&gt;                    &lt;Icon name=&#8221;alert&#8221; className=&#8221;w-5 h-5 text-amber-600 shrink-0 mt-0.5 sm:mt-0&#8243; \/&gt;                    &lt;div&gt;                      &lt;span className=&#8221;font-extrabold uppercase tracking-wide text-amber-900 block sm:inline mr-1.5&#8243;&gt;                        Sample Demo Mode Active (Not Saved to Cloud):                      &lt;\/span&gt;                      &lt;span&gt;                        You are viewing example numbers ({activeSampleMode === &#8216;high-risk&#8217; ? &#8216;High-Risk Sample&#8217; : &#8216;Optimal Sample&#8217;}). Your personal Cloud Vault has &lt;strong&gt;not&lt;\/strong&gt; been overwritten.                      &lt;\/span&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  &lt;button                    type=&#8221;button&#8221;                    onClick={exitSampleModeAndRestore}                    className=&#8221;px-4 py-2 rounded-xl bg-amber-600 hover:bg-amber-700 text-white text-xs font-bold shrink-0 shadow-sm transition&#8221;                  &gt;                    Exit Sample &amp;amp; Enter My Own Data                  &lt;\/button&gt;                &lt;\/div&gt;              )}            &lt;\/div&gt;            &lt;main className=&#8221;max-w-7xl mx-auto px-4 sm:px-6 py-4&#8243;&gt;              {activeTab === &#8216;profile&#8217; &amp;&amp; (                &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-3 gap-6&#8243;&gt;                  {\/* Anthropometrics &amp; Pseudonymous Alias *\/}                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200&#8243;&gt;                    &lt;div className=&#8221;flex items-center justify-between mb-4&#8243;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2&#8243;&gt;                        &lt;Icon name=&#8221;userCheck&#8221; className=&#8221;w-5 h-5 text-teal-600&#8243; \/&gt;                        Pseudonymous Profile &amp; Biometrics                      &lt;\/h2&gt;                      &lt;StatusBadge                        status={clinicalMetrics.whr === null ? &#8216;info&#8217; : clinicalMetrics.whr &gt; (profile.gender === &#8216;male&#8217; ? 0.9 : 0.85) ? &#8216;warning&#8217; : &#8216;optimal&#8217;}                        label={clinicalMetrics.whr !== null ? `WHR: ${clinicalMetrics.whr}` : &#8216;WHR: \u2014&#8217;}                      \/&gt;                    &lt;\/div&gt;                      &lt;div className=&#8221;space-y-3.5 text-sm&#8221;&gt;                      &lt;div&gt;                        &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;                          Profile Alias \/ Nickname (Privacy-Safe: Do Not Use Legal Name)                        &lt;\/label&gt;                        &lt;input                          type=&#8221;text&#8221;                          maxLength={40}                          value={profile.alias}                          onChange={e =&gt; setProfile({ &#8230;profile, alias: e.target.value.slice(0, 40) })}                          placeholder=&#8221;e.g., Reader-01&#8243;                          className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 focus:outline-none&#8221;                        \/&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Age (Years)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;1&#8243;                            max=&#8221;120&#8243;                            value={profile.age}                            onChange={e =&gt; setProfile({ &#8230;profile, age: parseInputNum(e.target.value, 0, 120) })}                            placeholder=&#8221;e.g., 40&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Biological Sex&lt;\/label&gt;                          &lt;select                            value={profile.gender}                            onChange={e =&gt; setProfile({ &#8230;profile, gender: e.target.value })}                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300 bg-white&#8221;                          &gt;                            &lt;option value=&#8221;male&#8221;&gt;Male&lt;\/option&gt;                            &lt;option value=&#8221;female&#8221;&gt;Female&lt;\/option&gt;                          &lt;\/select&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Weight (kg)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;1&#8243;                            max=&#8221;400&#8243;                            step=&#8221;0.5&#8243;                            value={profile.weightKg}                            onChange={e =&gt; setProfile({ &#8230;profile, weightKg: parseInputNum(e.target.value, 0, 400) })}                            placeholder=&#8221;e.g., 75&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Height (cm)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;50&#8243;                            max=&#8221;260&#8243;                            value={profile.heightCm}                            onChange={e =&gt; setProfile({ &#8230;profile, heightCm: parseInputNum(e.target.value, 0, 260) })}                            placeholder=&#8221;e.g., 170&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Waist Circumference (cm)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;30&#8243;                            max=&#8221;250&#8243;                            value={profile.waistCm}                            onChange={e =&gt; setProfile({ &#8230;profile, waistCm: parseInputNum(e.target.value, 0, 250) })}                            placeholder=&#8221;e.g., 88&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;                            Hip Circumference (cm) &lt;Tooltip text={CLINICAL_TOOLTIPS.whr} \/&gt;                          &lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;30&#8243;                            max=&#8221;250&#8243;                            value={profile.hipCm}                            onChange={e =&gt; setProfile({ &#8230;profile, hipCm: parseInputNum(e.target.value, 0, 250) })}                            placeholder=&#8221;e.g., 98&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Body Fat (%)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;2&#8243;                            max=&#8221;75&#8243;                            step=&#8221;0.5&#8243;                            value={profile.bodyFatPct}                            onChange={e =&gt; setProfile({ &#8230;profile, bodyFatPct: parseInputNum(e.target.value, 0, 75) })}                            placeholder=&#8221;Optional&#8221;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Neck (cm)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;15&#8243;                            max=&#8221;80&#8243;                            value={profile.neckCm}                            onChange={e =&gt; setProfile({ &#8230;profile, neckCm: parseInputNum(e.target.value, 0, 80) })}                            placeholder=&#8221;Optional&#8221;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;pt-2 border-t border-slate-100&#8243;&gt;                        &lt;label className=&#8221;block text-xs font-semibold text-slate-700 mb-1&#8243;&gt;Primary Dietary Preference&lt;\/label&gt;                        &lt;select                          value={profile.dietPreference}                          onChange={e =&gt; setProfile({ &#8230;profile, dietPreference: e.target.value })}                          className=&#8221;w-full px-3 py-2.5 rounded-xl border border-teal-300 bg-teal-50\/50 text-slate-900 font-medium&#8221;                        &gt;                          &lt;option value=&#8221;vegan&#8221;&gt;Pure Vegetarian (Vegan &#8211; Plant Only)&lt;\/option&gt;                          &lt;option value=&#8221;lacto&#8221;&gt;Vegetarian Lacto (Plants, Dairy &amp;amp; Honey)&lt;\/option&gt;                          &lt;option value=&#8221;ovo&#8221;&gt;Vegetarian Ovo-Lacto (Plants, Dairy, Honey &amp;amp; Egg)&lt;\/option&gt;                          &lt;option value=&#8221;omni&#8221;&gt;Meat, Fish, Eggs, Dairy &amp;amp; Plants (Omnivore)&lt;\/option&gt;                        &lt;\/select&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  {\/* Glycemic &amp; Endocrine Baselines *\/}                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200&#8243;&gt;                    &lt;div className=&#8221;flex items-center justify-between mb-4&#8243;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2&#8243;&gt;                        &lt;Icon name=&#8221;droplet&#8221; className=&#8221;w-5 h-5 text-rose-600&#8243; \/&gt;                        Endocrine &amp; Glycemic Labs                      &lt;\/h2&gt;                      &lt;StatusBadge                        status={clinicalMetrics.homaIr === null ? &#8216;info&#8217; : clinicalMetrics.homaIr &lt; 1.5 ? &#8216;optimal&#8217; : clinicalMetrics.homaIr &lt; 2.9 ? &#8216;warning&#8217; : &#8216;critical&#8217;}                        label={clinicalMetrics.homaIr !== null ? `HOMA-IR: ${clinicalMetrics.homaIr}` : &#8216;HOMA-IR: \u2014&#8217;}                      \/&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;space-y-3.5 text-sm&#8221;&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;HbA1c (%)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;3&#8243;                            max=&#8221;25&#8243;                            step=&#8221;0.1&#8243;                            value={profile.hba1c}                            onChange={e =&gt; setProfile({ &#8230;profile, hba1c: parseInputNum(e.target.value, 0, 25) })}                            placeholder=&#8221;e.g., 5.6&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                          &lt;span className=&#8221;text-[11px] text-slate-400&#8243;&gt;Optimal: &amp;lt;5.4%&lt;\/span&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;                            Fasting Insulin (\u03bcIU\/mL) &lt;Tooltip text={CLINICAL_TOOLTIPS.homaIr} \/&gt;                          &lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;0.5&#8243;                            max=&#8221;300&#8243;                            step=&#8221;0.5&#8243;                            value={profile.fastingInsulin}                            onChange={e =&gt; setProfile({ &#8230;profile, fastingInsulin: parseInputNum(e.target.value, 0, 300) })}                            placeholder=&#8221;e.g., 6.0&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                          &lt;span className=&#8221;text-[11px] text-slate-400&#8243;&gt;Optimal: 2 &#8211; 6 \u03bcIU\/mL&lt;\/span&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Fasting Glucose (mg\/dL)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;30&#8243;                            max=&#8221;600&#8243;                            value={profile.fastingGlucose}                            onChange={e =&gt; setProfile({ &#8230;profile, fastingGlucose: parseInputNum(e.target.value, 0, 600) })}                            placeholder=&#8221;e.g., 90&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Triglycerides (mg\/dL)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;20&#8243;                            max=&#8221;1500&#8243;                            value={profile.triglycerides}                            onChange={e =&gt; setProfile({ &#8230;profile, triglycerides: parseInputNum(e.target.value, 0, 1500) })}                            placeholder=&#8221;e.g., 110&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;HDL Cholesterol (mg\/dL)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;10&#8243;                            max=&#8221;200&#8243;                            value={profile.hdl}                            onChange={e =&gt; setProfile({ &#8230;profile, hdl: parseInputNum(e.target.value, 0, 200) })}                            placeholder=&#8221;e.g., 50&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div className=&#8221;bg-slate-50 p-2.5 rounded-xl border border-slate-200 flex flex-col justify-center&#8221;&gt;                          &lt;span className=&#8221;text-[11px] text-slate-500 font-medium&#8221;&gt;Calculated HOMA-IR&lt;\/span&gt;                          &lt;span className=&#8221;text-lg font-extrabold text-slate-900&#8243;&gt;                            {clinicalMetrics.homaIr !== null ? clinicalMetrics.homaIr : &#8216;\u2014&#8217;}                          &lt;\/span&gt;                          &lt;span className=&#8221;text-[11px] text-teal-700 font-medium&#8221;&gt;                            {clinicalMetrics.homaIr === null                              ? &#8216;Enter Insulin &amp; Glucose&#8217;                              : clinicalMetrics.homaIr &lt; 1.5                              ? &#8216;Insulin Sensitive&#8217;                              : &#8216;Insulin Resistant&#8217;}                          &lt;\/span&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;p-3.5 rounded-xl bg-teal-50\/70 border border-teal-200 text-xs text-slate-700 space-y-1&#8243;&gt;                        &lt;div className=&#8221;font-bold text-teal-900&#8243;&gt;Early Detection Insight:&lt;\/div&gt;                        &lt;p&gt;                          Fasting glucose is the last marker to rise before Type 2 Diabetes. Tracking &lt;strong&gt;HOMA-IR ({clinicalMetrics.homaIr !== null ? clinicalMetrics.homaIr : &#8216;\u2014&#8217;})&lt;\/strong&gt; and &lt;strong&gt;TG:HDL ratio ({clinicalMetrics.tgHdlRatio !== null ? clinicalMetrics.tgHdlRatio : &#8216;\u2014&#8217;})&lt;\/strong&gt; reveals hyperinsulinemia up to a decade earlier.                        &lt;\/p&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  {\/* Cardiovascular &amp; Hepatic (NAFLD) Panel *\/}                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200&#8243;&gt;                    &lt;div className=&#8221;flex items-center justify-between mb-4&#8243;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2&#8243;&gt;                        &lt;Icon name=&#8221;heart&#8221; className=&#8221;w-5 h-5 text-indigo-600&#8243; \/&gt;                        Cardiovascular &amp; Hepatic (NAFLD)                      &lt;\/h2&gt;                      &lt;StatusBadge                        status={clinicalMetrics.altVal === null &amp;&amp; clinicalMetrics.sysBP === null ? &#8216;info&#8217; : (clinicalMetrics.altVal === null || clinicalMetrics.altVal &lt;= 30) &amp;&amp; (clinicalMetrics.sysBP === null || clinicalMetrics.sysBP &lt;= 125) ? &#8216;optimal&#8217; : &#8216;warning&#8217;}                        label={clinicalMetrics.altVal === null &amp;&amp; clinicalMetrics.sysBP === null ? &#8216;Enter Labs&#8217; : clinicalMetrics.altVal !== null &amp;&amp; clinicalMetrics.altVal &gt; 35 ? &#8216;Elevated ALT&#8217; : &#8216;Hepatic Stable&#8217;}                      \/&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;space-y-3.5 text-sm&#8221;&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-3&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Systolic BP (mmHg)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;50&#8243;                            max=&#8221;300&#8243;                            value={profile.systolicBP}                            onChange={e =&gt; setProfile({ &#8230;profile, systolicBP: parseInputNum(e.target.value, 0, 300) })}                            placeholder=&#8221;e.g., 120&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;Diastolic BP (mmHg)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;30&#8243;                            max=&#8221;200&#8243;                            value={profile.diastolicBP}                            onChange={e =&gt; setProfile({ &#8230;profile, diastolicBP: parseInputNum(e.target.value, 0, 200) })}                            placeholder=&#8221;e.g., 80&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-3 gap-2.5&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;ALT (U\/L)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;1&#8243;                            max=&#8221;1000&#8243;                            value={profile.alt}                            onChange={e =&gt; setProfile({ &#8230;profile, alt: parseInputNum(e.target.value, 0, 1000) })}                            placeholder=&#8221;e.g., 25&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;AST (U\/L)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;1&#8243;                            max=&#8221;1000&#8243;                            value={profile.ast}                            onChange={e =&gt; setProfile({ &#8230;profile, ast: parseInputNum(e.target.value, 0, 1000) })}                            placeholder=&#8221;e.g., 22&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block text-xs font-semibold text-slate-600 mb-1&#8243;&gt;GGT (U\/L)&lt;\/label&gt;                          &lt;input                            type=&#8221;number&#8221;                            min=&#8221;1&#8243;                            max=&#8221;1000&#8243;                            value={profile.ggt}                            onChange={e =&gt; setProfile({ &#8230;profile, ggt: parseInputNum(e.target.value, 0, 1000) })}                            placeholder=&#8221;e.g., 20&#8243;                            className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300&#8243;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-2.5 pt-2&#8243;&gt;                        &lt;div className=&#8221;p-3 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                          &lt;div className=&#8221;text-[11px] text-slate-500&#8243;&gt;Waist-to-Height Ratio&lt;\/div&gt;                          &lt;div className=&#8221;text-base font-bold text-slate-900&#8243;&gt;                            {clinicalMetrics.whtr !== null ? clinicalMetrics.whtr : &#8216;\u2014&#8217;}                          &lt;\/div&gt;                          &lt;div className=&#8221;text-[11px] text-slate-500&#8243;&gt;Target: &amp;lt; 0.50&lt;\/div&gt;                        &lt;\/div&gt;                        &lt;div className=&#8221;p-3 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                          &lt;div className=&#8221;text-[11px] text-slate-500&#8243;&gt;Target Caloric Intake&lt;\/div&gt;                          &lt;div className=&#8221;text-base font-bold text-teal-700&#8243;&gt;                            {clinicalMetrics.targetCalories &gt; 0 ? `${clinicalMetrics.targetCalories} kcal` : &#8216;\u2014&#8217;}                          &lt;\/div&gt;                          &lt;div className=&#8221;text-[11px] text-slate-500&#8243;&gt;                            TDEE: {clinicalMetrics.tdee &gt; 0 ? `${clinicalMetrics.tdee} kcal` : &#8216;Enter Weight\/Height&#8217;}                          &lt;\/div&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  {\/* Explicit Calculate, Save &amp; Action Bar for User Confidence *\/}                  &lt;div className=&#8221;lg:col-span-3 bg-teal-50\/90 border border-teal-200 rounded-2xl p-4 flex flex-col sm:flex-row items-center justify-between gap-4 shadow-sm&#8221;&gt;                    &lt;div className=&#8221;flex items-center gap-3&#8243;&gt;                      &lt;div className=&#8221;w-9 h-9 rounded-xl bg-teal-600 text-white flex items-center justify-center shrink-0&#8243;&gt;                        &lt;Icon name=&#8221;check&#8221; className=&#8221;w-5 h-5&#8243; \/&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;text-xs text-slate-700&#8243;&gt;                        &lt;span className=&#8221;font-bold text-slate-900 block&#8221;&gt;Live Auto-Calculation &amp; Cloud Sync Active&lt;\/span&gt;                        Your biomarkers (HOMA-IR, WHR, TG:HDL, BMR\/TDEE) calculate automatically as you type, or click the button to confirm &amp; save manually.                      &lt;\/div&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;flex flex-wrap items-center gap-2.5 shrink-0 w-full sm:w-auto justify-end&#8221;&gt;                      &lt;button                        type=&#8221;button&#8221;                        onClick={() =&gt; triggerToast(&#8216;Biomarkers calculated &amp; saved to your vault!&#8217;)}                        className=&#8221;px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-500 text-white text-xs font-bold shadow-sm transition flex items-center gap-1.5&#8243;                      &gt;                        &lt;Icon name=&#8221;check&#8221; className=&#8221;w-4 h-4&#8243; \/&gt;                        &lt;span&gt;Calculate &amp;amp; Save Profile&lt;\/span&gt;                      &lt;\/button&gt;                      &lt;button                        type=&#8221;button&#8221;                        onClick={() =&gt; setActiveTab(&#8216;insights&#8217;)}                        className=&#8221;px-4 py-2.5 rounded-xl bg-white hover:bg-teal-100 text-teal-800 border border-teal-300 text-xs font-bold transition&#8221;                      &gt;                        View Action Guide \u2192                      &lt;\/button&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              )}              {\/* TAB 2: NUTRITION, SEQUENCING &amp; RS3 *\/}              {activeTab === &#8216;nutrition&#8217; &amp;&amp; (                &lt;div className=&#8221;space-y-6&#8243;&gt;                  &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-3 gap-6&#8243;&gt;                    {\/* Meal Sequencing *\/}                    &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200&#8243;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2 mb-2&#8243;&gt;                        &lt;Icon name=&#8221;trendingDown&#8221; className=&#8221;w-5 h-5 text-teal-600&#8243; \/&gt;                        Meal Sequencing                        &lt;Tooltip text={CLINICAL_TOOLTIPS.mealSequencing} \/&gt;                      &lt;\/h2&gt;                      &lt;div className=&#8221;space-y-2 mb-4 max-h-64 overflow-y-auto pr-1&#8243;&gt;                        {[                          { id: &#8216;fiber-protein-carb&#8217;, title: &#8216;1. Fiber\/Veg \u2192 2. Protein\/Fat \u2192 3. Carbs Last&#8217;, desc: &#8216;Forms viscous fiber matrix; flattens post-meal glucose spike by up to 73%.&#8217; },                          { id: &#8216;protein-fiber-carb-lemon&#8217;, title: &#8216;1. Protein\/Fat \u2192 2. Fiber\/Veg \u2192 3. Carbs \u2192 4. Whole Lemon (Skin, Seeds &amp; Juice)&#8217;, desc: &#8216;Stimulates early GLP-1\/GIP incretins; whole lemon pectin, citric acid &amp; polyphenols blunt starch digestion.&#8217; },                          { id: &#8216;fiber-protein-carb-lemon&#8217;, title: &#8216;1. Fiber\/Veg \u2192 2. Protein\/Fat \u2192 3. Carbs \u2192 4. Whole Lemon (Skin, Seeds &amp; Juice)&#8217;, desc: &#8216;Combines duodenal fiber mesh with citrus alpha-amylase inhibition &amp; eriocitrin liver support.&#8217; },                          { id: &#8216;lemon-fiber-protein-carb&#8217;, title: &#8216;1. Whole Lemon (Skin, Seeds &amp; Juice) \u2192 2. Fiber\/Veg \u2192 3. Protein\/Fat \u2192 4. Carbs&#8217;, desc: &#8216;Pre-meal citric acid &amp; citrus bioflavonoids prime gastric pH and slow starch breakdown.&#8217; },                          { id: &#8216;mixed&#8217;, title: &#8216;Mixed Thali \/ Bowl Eaten Together&#8217;, desc: &#8216;Moderate gastric emptying and standard glucose response.&#8217; },                          { id: &#8216;carb-first&#8217;, title: &#8216;Carbs\/Rice\/Bread First on Empty Stomach&#8217;, desc: &#8216;Rapid glucose excursion &amp; reactive insulin surge.&#8217; }                        ].map(seq =&gt; (                          &lt;button                            key={seq.id}                            type=&#8221;button&#8221;                            onClick={() =&gt; setNutrition({ &#8230;nutrition, mealSequence: seq.id })}                            className={`w-full text-left p-2.5 rounded-xl border transition ${                              nutrition.mealSequence === seq.id                                ? &#8216;bg-teal-50 border-teal-500 ring-1 ring-teal-500&#8217;                                : &#8216;border-slate-200 hover:bg-teal-50\/60 hover:border-teal-300&#8217;                            }`}                          &gt;                            &lt;div className=&#8221;text-xs font-bold text-slate-900&#8243;&gt;{seq.title}&lt;\/div&gt;                            &lt;div className=&#8221;text-[11px] text-slate-600&#8243;&gt;{seq.desc}&lt;\/div&gt;                          &lt;\/button&gt;                        ))}                      &lt;\/div&gt;                      {\/* Simulated Glucose Curve *\/}                      &lt;div className=&#8221;bg-slate-900 text-white p-3.5 rounded-xl&#8221;&gt;                        &lt;div className=&#8221;flex justify-between text-xs mb-2&#8243;&gt;                          &lt;span className=&#8221;font-semibold text-teal-300&#8243;&gt;2-Hour Post-Meal Glucose Curve&lt;\/span&gt;                          &lt;span className=&#8221;text-[11px] text-slate-400&#8243;&gt;Peak: {clinicalMetrics.glucoseCurve[2].optimized} mg\/dL&lt;\/span&gt;                        &lt;\/div&gt;                        &lt;svg viewBox=&#8221;0 0 260 90&#8243; className=&#8221;w-full h-20 overflow-visible&#8221;&gt;                          &lt;line x1=&#8221;0&#8243; y1=&#8221;20&#8243; x2=&#8221;260&#8243; y2=&#8221;20&#8243; stroke=&#8221;#334155&#8243; strokeDasharray=&#8221;3 3&#8243; strokeWidth=&#8221;1&#8243; \/&gt;                          &lt;polyline                            fill=&#8221;none&#8221;                            stroke=&#8221;#f43f5e&#8221;                            strokeWidth=&#8221;1.8&#8243;                            strokeDasharray=&#8221;4 3&#8243;                            points={clinicalMetrics.glucoseCurve.map((pt, idx) =&gt; `${idx * 62},${Math.min(88, Math.max(5, 85 &#8211; (pt.unoptimized &#8211; 70) * 0.65))}`).join(&#8216; &#8216;)}                          \/&gt;                          &lt;polyline                            fill=&#8221;none&#8221;                            stroke=&#8221;#2dd4bf&#8221;                            strokeWidth=&#8221;2.5&#8243;                            points={clinicalMetrics.glucoseCurve.map((pt, idx) =&gt; `${idx * 62},${Math.min(88, Math.max(5, 85 &#8211; (pt.optimized &#8211; 70) * 0.65))}`).join(&#8216; &#8216;)}                          \/&gt;                        &lt;\/svg&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                    {\/* Resistant Starch RS3 Module *\/}                    &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200&#8243;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2 mb-2&#8243;&gt;                        &lt;Icon name=&#8221;flame&#8221; className=&#8221;w-5 h-5 text-amber-500&#8243; \/&gt;                        Resistant Starch (RS3) Prep (Rice &amp;amp; Potato)                        &lt;Tooltip text={CLINICAL_TOOLTIPS.resistantStarch} \/&gt;                      &lt;\/h2&gt;                      &lt;div className=&#8221;space-y-2 mb-3 max-h-64 overflow-y-auto pr-1&#8243;&gt;                        {[                          { id: &#8216;cooled-reheated&#8217;, label: &#8216;Rice: Cooked \u2192 Cooled 12-24h at 4\u00b0C \u2192 Reheated&#8217;, badge: &#8216;-35% GI Spike&#8217;, good: true },                          { id: &#8216;potato-cooled-rs3&#8217;, label: &#8216;Potato: Boiled \u2192 Cooled 12-24h at 4\u00b0C (Potato Salad \/ Gently Reheated)&#8217;, badge: &#8216;-40% GI \/ High RS3&#8217;, good: true },                          { id: &#8216;vinegar-added&#8217;, label: &#8216;Rice\/Potato Paired with Whole Lemon (Skin, Seeds &amp; Juice) \/ ACV + A2 Ghee&#8217;, badge: &#8216;-30% Spike&#8217;, good: true },                          { id: &#8216;green-banana-legume&#8217;, label: &#8216;Raw Green Banana \/ Sprouted Lentils \/ Cooled Oats (RS2 + RS3)&#8217;, badge: &#8216;Prebiotic Butyrate&#8217;, good: true },                          { id: &#8216;fermented&#8217;, label: &#8216;Fermented Batter \/ Sprouted Legumes &amp; Millets&#8217;, badge: &#8216;Low GI&#8217;, good: true },                          { id: &#8216;pressure-cooked-hot&#8217;, label: &#8216;Freshly Boiled\/Mashed Piping Hot Potato or Rice&#8217;, badge: &#8216;High Spike&#8217;, good: false }                        ].map(m =&gt; (                          &lt;button                            key={m.id}                            type=&#8221;button&#8221;                            onClick={() =&gt; setNutrition({ &#8230;nutrition, starchPrepMethod: m.id })}                            className={`w-full text-left p-2.5 rounded-xl border flex items-center justify-between gap-2 transition ${                              nutrition.starchPrepMethod === m.id                                ? &#8216;bg-amber-50 border-amber-500&#8217;                                : &#8216;border-slate-200 hover:bg-amber-50\/50 hover:border-amber-300&#8217;                            }`}                          &gt;                            &lt;span className=&#8221;text-xs font-medium text-slate-800&#8243;&gt;{m.label}&lt;\/span&gt;                            &lt;span className={`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 ${m.good ? &#8216;bg-emerald-100 text-emerald-800&#8217; : &#8216;bg-rose-100 text-rose-800&#8217;}`}&gt;                              {m.badge}                            &lt;\/span&gt;                          &lt;\/button&gt;                        ))}                      &lt;\/div&gt;                      &lt;p className=&#8221;text-[11px] text-slate-600 bg-amber-50\/60 p-2.5 rounded-xl border border-amber-200\/80&#8243;&gt;                        &lt;strong&gt;Potato RS3 Tip:&lt;\/strong&gt; Freshly boiled hot potatoes have a high Glycemic Index (~78\u201385). Refrigerating boiled potatoes at 4\u00b0C for 12\u201324 hours retrogrades gelatinized starch into &lt;strong&gt;Type 3 Resistant Starch (RS3)&lt;\/strong&gt;, cutting the glycemic load by ~40% while feeding colonic butyrate bacteria.                      &lt;\/p&gt;                    &lt;\/div&gt;                    {\/* Cooking Oils &amp; Grazing *\/}                    &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-4&#8243;&gt;                      &lt;div&gt;                        &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2 mb-2&#8243;&gt;                          Cooking Lipids &amp; Grazing                          &lt;Tooltip text={CLINICAL_TOOLTIPS.cookingOils} \/&gt;                        &lt;\/h2&gt;                        &lt;select                          value={nutrition.cookingFat}                          onChange={e =&gt; setNutrition({ &#8230;nutrition, cookingFat: e.target.value })}                          className=&#8221;w-full px-3 py-2.5 rounded-xl border border-slate-300 text-xs font-semibold bg-white&#8221;                        &gt;                          &lt;option value=&#8221;ghee&#8221;&gt;A2 Cultured Ghee \/ Clarified Butter&lt;\/option&gt;                          &lt;option value=&#8221;cold-pressed&#8221;&gt;Cold-Pressed Coconut \/ Mustard \/ Olive Oil&lt;\/option&gt;                          &lt;option value=&#8221;butter&#8221;&gt;Grass-Fed Butter&lt;\/option&gt;                          &lt;option value=&#8221;refined-seed&#8221;&gt;Refined Seed Oils (Soybean, Sunflower, Canola)&lt;\/option&gt;                        &lt;\/select&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;pt-3 border-t border-slate-200&#8243;&gt;                        &lt;div className=&#8221;flex items-center justify-between mb-2&#8243;&gt;                          &lt;span className=&#8221;text-xs font-bold text-slate-800 flex items-center&#8221;&gt;                            Daily Snacking \/ Grazing &lt;Tooltip text={CLINICAL_TOOLTIPS.grazing} \/&gt;                          &lt;\/span&gt;                          &lt;StatusBadge                            status={nutrition.snackingCount === 0 ? &#8216;optimal&#8217; : nutrition.snackingCount === 1 ? &#8216;warning&#8217; : &#8216;critical&#8217;}                            label={`${nutrition.snackingCount} Snacks`}                          \/&gt;                        &lt;\/div&gt;                        &lt;div className=&#8221;grid grid-cols-4 gap-1.5&#8243;&gt;                          {[0, 1, 2, 3].map(cnt =&gt; (                            &lt;button                              key={cnt}                              type=&#8221;button&#8221;                              onClick={() =&gt; setNutrition({ &#8230;nutrition, snackingCount: cnt })}                              className={`py-1.5 rounded-xl text-xs font-bold border transition ${                                nutrition.snackingCount === cnt                                  ? &#8216;bg-teal-600 text-white border-teal-600&#8217;                                  : &#8216;bg-slate-50 text-slate-700 border-slate-200 hover:bg-slate-100&#8217;                              }`}                            &gt;                              {cnt === 3 ? &#8216;3+&#8217; : cnt}                            &lt;\/button&gt;                          ))}                        &lt;\/div&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                    {\/* Diet-Filtered Food Logger &amp; Hydration *\/}                  &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-12 gap-6&#8243;&gt;                    &lt;div className=&#8221;lg:col-span-7 bg-white rounded-2xl p-6 shadow-sm border border-slate-200&#8243;&gt;                      &lt;h3 className=&#8221;text-sm font-bold text-slate-900 mb-3&#8243;&gt;                        Quick-Add Whole Foods ({toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20).toUpperCase()})                      &lt;\/h3&gt;                      &lt;div className=&#8221;flex flex-wrap gap-2 mb-4&#8243;&gt;                        {FOOD_DATABASE.filter(f =&gt; f.diet.includes(toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20))).map(food =&gt; (                          &lt;button                            key={food.id}                            type=&#8221;button&#8221;                            onClick={() =&gt; addFoodToLog(food.id)}                            className=&#8221;flex items-center gap-1 px-3 py-1.5 rounded-xl text-xs font-semibold bg-teal-50 text-teal-800 border border-teal-200 hover:bg-teal-100&#8243;                          &gt;                            &lt;Icon name=&#8221;plus&#8221; className=&#8221;w-3.5 h-3.5&#8243; \/&gt;                            {food.name}                          &lt;\/button&gt;                        ))}                      &lt;\/div&gt;                      &lt;div className=&#8221;space-y-2 max-h-60 overflow-y-auto&#8221;&gt;                        {nutrition.loggedFoods.length === 0 ? (                          &lt;div className=&#8221;p-4 rounded-xl bg-slate-50 border border-dashed border-slate-300 text-center text-xs text-slate-500&#8243;&gt;                            No foods logged yet. Click any food item above to add it to your daily nutrition log.                          &lt;\/div&gt;                        ) : (                          nutrition.loggedFoods.map((item, idx) =&gt; {                            if (!item || typeof item !== &#8216;object&#8217;) return null;                            const safeCarb = toSafeFloat(item.carb, 0);                            const safeFiber = toSafeFloat(item.fiber, 0);                            const netCarbStr = Math.max(0, safeCarb &#8211; safeFiber).toFixed(1);                            return (                              &lt;div key={item.instanceId || idx} className=&#8221;flex items-center justify-between p-2.5 rounded-xl bg-slate-50 border border-slate-200 text-xs&#8221;&gt;                                &lt;div&gt;                                  &lt;div className=&#8221;font-bold text-slate-900&#8243;&gt;{toSafeStr(item.name, &#8216;Food Item&#8217;)}&lt;\/div&gt;                                  &lt;div className=&#8221;text-slate-500&#8243;&gt;                                    {toSafeFloat(item.cal, 0)} kcal \u2022 Pro: {toSafeFloat(item.pro, 0)}g \u2022 Net Carb: {netCarbStr}g \u2022 Fiber: {safeFiber}g \u2022 Choline: {toSafeFloat(item.choline, 0)}mg                                  &lt;\/div&gt;                                &lt;\/div&gt;                                &lt;button type=&#8221;button&#8221; onClick={() =&gt; removeFoodFromLog(item.instanceId)} className=&#8221;text-slate-400 hover:text-rose-600 p-1&#8243;&gt;                                  &lt;Icon name=&#8221;trash&#8221; className=&#8221;w-4 h-4&#8243; \/&gt;                                &lt;\/button&gt;                              &lt;\/div&gt;                            );                          })                        )}                      &lt;\/div&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;lg:col-span-5 bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3 text-xs&#8221;&gt;                      &lt;div className=&#8221;flex justify-between items-center&#8221;&gt;                        &lt;h3 className=&#8221;text-sm font-bold text-slate-900&#8243;&gt;Macro, Amino &amp; Mineral Totals&lt;\/h3&gt;                        &lt;span className=&#8221;font-bold text-teal-700&#8243;&gt;                          {nutritionTotals.cal} \/ {clinicalMetrics.targetCalories &gt; 0 ? clinicalMetrics.targetCalories : &#8216;\u2014&#8217;} kcal                        &lt;\/span&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 gap-2.5&#8243;&gt;                        &lt;div className=&#8221;p-2.5 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                          &lt;div className=&#8221;text-slate-500&#8243;&gt;Protein &amp; Leucine&lt;\/div&gt;                          &lt;div className=&#8221;text-sm font-bold text-slate-900&#8243;&gt;{nutritionTotals.pro}g Pro ({nutritionTotals.leucine}g Leu)&lt;\/div&gt;                        &lt;\/div&gt;                        &lt;div className=&#8221;p-2.5 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                          &lt;div className=&#8221;text-slate-500&#8243;&gt;Net Carbs &amp; Fiber&lt;\/div&gt;                          &lt;div className=&#8221;text-sm font-bold text-slate-900&#8243;&gt;{nutritionTotals.netCarbs}g Net ({nutritionTotals.fiber}g Fiber)&lt;\/div&gt;                        &lt;\/div&gt;                        &lt;div className=&#8221;p-2.5 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                          &lt;div className=&#8221;text-slate-500&#8243;&gt;Magnesium &amp; Potassium&lt;\/div&gt;                          &lt;div className=&#8221;text-sm font-bold text-slate-900&#8243;&gt;Mg: {nutritionTotals.mg}mg \u2022 K: {nutritionTotals.k}mg&lt;\/div&gt;                        &lt;\/div&gt;                        &lt;div className=&#8221;p-2.5 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                          &lt;div className=&#8221;text-slate-500&#8243;&gt;Hepatic Choline&lt;\/div&gt;                          &lt;div className=&#8221;text-sm font-bold text-slate-900&#8243;&gt;{nutritionTotals.choline} \/ 550 mg&lt;\/div&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      {\/* Upgraded Flexible Water &amp; Mineralization Logger *\/}                      &lt;form onSubmit={(e) =&gt; addWaterLog(e)} className=&#8221;pt-3 border-t border-slate-200 space-y-2.5&#8243;&gt;                        &lt;div className=&#8221;flex flex-wrap items-center justify-between gap-1&#8243;&gt;                          &lt;span className=&#8221;font-bold text-slate-900 flex items-center gap-1&#8243;&gt;                            &lt;span&gt;Hydration &amp;amp; Mineral Water Tracker&lt;\/span&gt;                            &lt;Tooltip text={CLINICAL_TOOLTIPS.waterRO} \/&gt;                          &lt;\/span&gt;                          &lt;span className=&#8221;px-2.5 py-0.5 rounded-full bg-sky-50 text-sky-800 border border-sky-200 font-bold text-[11px]&#8221;&gt;                            Today: {nutritionTotals.totalWaterMl} ml ({(nutritionTotals.totalWaterMl \/ 1000).toFixed(2)} L)                          &lt;\/span&gt;                        &lt;\/div&gt;                        {nutritionTotals.hasPlainROWarning &amp;&amp; (                          &lt;div className=&#8221;p-2 rounded-lg bg-amber-50 border border-amber-200 text-[11px] text-amber-900 font-medium&#8221;&gt;                            &#x26a0;&#xfe0f; &lt;strong&gt;Low-TDS RO Alert:&lt;\/strong&gt; Plain RO water lacks Magnesium &amp;amp; Calcium. Add a pinch of Sendha Namak (rock salt) or choose Natural Mineral Water.                          &lt;\/div&gt;                        )}                        {\/* Step 1: Timing &amp; Water Mineralization Source *\/}                        &lt;div className=&#8221;grid grid-cols-1 sm:grid-cols-2 gap-2&#8243;&gt;                          &lt;div&gt;                            &lt;label className=&#8221;block text-[10px] font-semibold text-slate-500 mb-0.5&#8243;&gt;1. Drinking Window&lt;\/label&gt;                            &lt;select                              value={newWater.timing}                              onChange={e =&gt; setNewWater({ &#8230;newWater, timing: e.target.value })}                              className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-slate-300 bg-white font-medium text-slate-800&#8243;                            &gt;                              &lt;option value=&#8221;Morning Waking&#8221;&gt;Morning Waking (Cellular Rehydration)&lt;\/option&gt;                              &lt;option value=&#8221;30m Before Meal&#8221;&gt;30m Before Meal (Primes Digestion)&lt;\/option&gt;                              &lt;option value=&#8221;Between Meals&#8221;&gt;Between Meals (Baseline Hydration)&lt;\/option&gt;                              &lt;option value=&#8221;Pre-Workout&#8221;&gt;Pre-Workout (30m Prior)&lt;\/option&gt;                              &lt;option value=&#8221;Intra-Workout&#8221;&gt;Intra-Workout Sipping&lt;\/option&gt;                              &lt;option value=&#8221;Post-Workout&#8221;&gt;Post-Workout Electrolyte Replenishment&lt;\/option&gt;                              &lt;option value=&#8221;Evening Sip&#8221;&gt;Evening (2h Before Sleep)&lt;\/option&gt;                            &lt;\/select&gt;                          &lt;\/div&gt;                          &lt;div&gt;                            &lt;label className=&#8221;block text-[10px] font-semibold text-slate-500 mb-0.5&#8243;&gt;2. Water Source &amp;amp; Mineral Profile&lt;\/label&gt;                            &lt;select                              value={newWater.source}                              onChange={e =&gt; setNewWater({ &#8230;newWater, source: e.target.value })}                              className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-sky-300 bg-sky-50\/40 font-semibold text-slate-900&#8243;                            &gt;                              &lt;option value=&#8221;Natural Mineral Water&#8221;&gt;Natural Spring \/ Mineral Water (Ca, Mg, Bicarbonates)&lt;\/option&gt;                              &lt;option value=&#8221;Sparkling Mineral Water&#8221;&gt;Sparkling Natural Mineral Water&lt;\/option&gt;                              &lt;option value=&#8221;RO + Sendha Salt &amp; Lemon&#8221;&gt;Remineralized RO + Sendha Rock Salt &amp;amp; Lemon&lt;\/option&gt;                              &lt;option value=&#8221;RO + Trace Mineral Drops&#8221;&gt;RO + Ionic Trace Mineral Drops (Mg\/K\/Zn)&lt;\/option&gt;                              &lt;option value=&#8221;Clay Pot (Matka) Mineralized&#8221;&gt;Alkaline Clay Pot (Matka) Water&lt;\/option&gt;                              &lt;option value=&#8221;Copper Vessel Morning Water&#8221;&gt;Copper Vessel (Tamra Jal) Water&lt;\/option&gt;                              &lt;option value=&#8221;Electrolyte Infused&#8221;&gt;Unsweetened Electrolyte Water (Na\/K\/Mg)&lt;\/option&gt;                              &lt;option value=&#8221;Plain RO (Unmineralized)&#8221;&gt;Plain RO Water (Unmineralized \/ Low TDS)&lt;\/option&gt;                            &lt;\/select&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                        {\/* Step 2: Flexible 1-Click Volume Presets + Custom ml Input *\/}                        &lt;div&gt;                          &lt;label className=&#8221;block text-[10px] font-semibold text-slate-500 mb-1&#8243;&gt;                            3. Select Flexible Water Amount (Click a preset or type custom ml):                          &lt;\/label&gt;                          &lt;div className=&#8221;flex flex-wrap gap-1 mb-2&#8243;&gt;                            {[                              { ml: 150, label: &#8216;150ml (Small Cup)&#8217; },                              { ml: 250, label: &#8216;250ml (1 Glass)&#8217; },                              { ml: 350, label: &#8216;350ml (Mug)&#8217; },                              { ml: 500, label: &#8216;500ml (Bottle)&#8217; },                              { ml: 750, label: &#8216;750ml (Flask)&#8217; },                              { ml: 1000, label: &#8216;1000ml (1 Litre)&#8217; }                            ].map(preset =&gt; (                              &lt;button                                key={preset.ml}                                type=&#8221;button&#8221;                                onClick={() =&gt; setNewWater({ &#8230;newWater, amountMl: String(preset.ml) })}                                className={`px-2 py-1 rounded-lg text-[11px] font-bold border transition ${                                  Number(newWater.amountMl) === preset.ml                                    ? &#8216;bg-sky-600 text-white border-sky-600 shadow-sm&#8217;                                    : &#8216;bg-white text-slate-700 border-slate-300 hover:bg-sky-50&#8217;                                }`}                              &gt;                                {preset.label}                              &lt;\/button&gt;                            ))}                          &lt;\/div&gt;                          &lt;div className=&#8221;flex gap-2&#8243;&gt;                            &lt;div className=&#8221;relative flex-1&#8243;&gt;                              &lt;input                                type=&#8221;number&#8221;                                min=&#8221;10&#8243;                                max=&#8221;5000&#8243;                                step=&#8221;10&#8243;                                value={newWater.amountMl}                                onChange={e =&gt; setNewWater({ &#8230;newWater, amountMl: parseInputNum(e.target.value, 0, 5000) })}                                placeholder=&#8221;Custom ml (e.g. 400)&#8221;                                className=&#8221;w-full px-3 py-1.5 rounded-lg border border-slate-300 bg-white font-semibold text-slate-900&#8243;                              \/&gt;                              &lt;span className=&#8221;absolute right-2.5 top-1\/2 -translate-y-1\/2 text-[10px] text-slate-400 font-semibold&#8221;&gt;ml&lt;\/span&gt;                            &lt;\/div&gt;                            &lt;button                              type=&#8221;submit&#8221;                              className=&#8221;bg-sky-600 hover:bg-sky-700 text-white font-bold rounded-lg px-4 py-1.5 shadow-sm transition shrink-0&#8243;                            &gt;                              + Log {newWater.amountMl || 0} ml Water                            &lt;\/button&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                        {nutrition.waterLogs.length &gt; 0 &amp;&amp; (                          &lt;div className=&#8221;space-y-1.5 max-h-32 overflow-y-auto pt-1&#8243;&gt;                            {nutrition.waterLogs.map(w =&gt; (                              &lt;div key={w.id} className=&#8221;flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-sky-50\/60 border border-sky-100 text-[11px]&#8221;&gt;                                &lt;span className=&#8221;font-medium text-slate-700&#8243;&gt;                                  {w.timing}: &lt;strong&gt;{w.amountMl} ml&lt;\/strong&gt; &lt;span className=&#8221;text-sky-800&#8243;&gt;({w.source})&lt;\/span&gt;                                &lt;\/span&gt;                                &lt;button                                  type=&#8221;button&#8221;                                  onClick={() =&gt; removeWaterFromLog(w.id)}                                  className=&#8221;text-slate-400 hover:text-rose-600&#8243;                                  title=&#8221;Remove water entry&#8221;                                &gt;                                  &lt;Icon name=&#8221;trash&#8221; className=&#8221;w-3.5 h-3.5&#8243; \/&gt;                                &lt;\/button&gt;                              &lt;\/div&gt;                            ))}                          &lt;\/div&gt;                        )}                      &lt;\/form&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  {\/* Redesigned, Crystal-Clear Food Macro, Micro, Mineral &amp; Vitamin %DV Calculator &amp; Decision Guide *\/}                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border-2 border-teal-200\/80 space-y-6&#8243;&gt;                    {\/* Clear Header with 3-Step Visual Workflow *\/}                    &lt;div className=&#8221;flex flex-col md:flex-row md:items-center justify-between gap-3 border-b border-slate-200 pb-4&#8243;&gt;                      &lt;div&gt;                        &lt;div className=&#8221;inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full bg-teal-100 text-teal-800 text-[11px] font-bold uppercase tracking-wide mb-1&#8243;&gt;                          Interactive Nutrition Decision Engine                        &lt;\/div&gt;                        &lt;h3 className=&#8221;text-base sm:text-lg font-extrabold text-slate-900 flex items-center gap-2&#8243;&gt;                          &lt;Icon name=&#8221;utensils&#8221; className=&#8221;w-5 h-5 text-teal-600&#8243; \/&gt;                          Food Macro, Micro, Mineral &amp;amp; Vitamin %DV Calculator &amp;amp; Meal Planner                        &lt;\/h3&gt;                        &lt;p className=&#8221;text-xs text-slate-600 mt-0.5&#8243;&gt;                          Follow the &lt;strong&gt;3 simple steps below&lt;\/strong&gt; to inspect any food by exact grams or servings, see its % Daily Value (%DV) impact, and get smart recommendations to complete your daily nutrition.                        &lt;\/p&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;flex flex-wrap items-center gap-2 shrink-0&#8243;&gt;                        &lt;StatusBadge                          status=&#8221;info&#8221;                          label={`Diet: ${toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20).toUpperCase()}`}                        \/&gt;                        &lt;StatusBadge                          status={nutritionTotals.lackingNutrients.length === 0 ? &#8216;optimal&#8217; : &#8216;warning&#8217;}                          label={nutritionTotals.lackingNutrients.length === 0 ? &#8216;All Key Nutrients &gt;60% DV&#8217; : `${nutritionTotals.lackingNutrients.length} Nutrient Gaps Detected`}                        \/&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                    {\/* =====================================================================                        STEP 1: CHOOSE A FOOD &amp; FLEXIBLE AMOUNT (GRAMS OR SERVINGS)                       ===================================================================== *\/}                    &lt;div className=&#8221;bg-teal-50\/40 rounded-2xl p-5 border border-teal-200 space-y-4&#8243;&gt;                      &lt;div className=&#8221;flex flex-wrap items-center justify-between gap-2&#8243;&gt;                        &lt;div className=&#8221;text-xs sm:text-sm font-extrabold text-teal-950 flex items-center gap-2&#8243;&gt;                          &lt;span className=&#8221;w-6 h-6 rounded-full bg-teal-700 text-white flex items-center justify-center text-xs&#8221;&gt;1&lt;\/span&gt;                          &lt;span&gt;Step 1: Inspect Any Food Item &amp;amp; Choose Your Exact Portion (Grams or Servings)&lt;\/span&gt;                        &lt;\/div&gt;                        &lt;span className=&#8221;text-[11px] font-semibold text-teal-800 bg-white px-2.5 py-1 rounded-lg border border-teal-200&#8243;&gt;                          Showing {filteredInspectorFoods.length} of {FOOD_DATABASE.length} Whole Foods                        &lt;\/span&gt;                      &lt;\/div&gt;                      {\/* Category Pills + Quick Search Filter *\/}                      &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-12 gap-3 items-center&#8221;&gt;                        &lt;div className=&#8221;lg:col-span-8 flex flex-wrap gap-1.5&#8243;&gt;                          {[                            { id: &#8216;All&#8217;, label: &#8216;All Foods (32)&#8217; },                            { id: &#8216;Vegetables &amp; Greens&#8217;, label: &#8216;&#x1f96c; Vegetables &amp; Greens&#8217; },                            { id: &#8216;Grains, Millets &amp; Starches&#8217;, label: &#8216;&#x1f33e; Grains, Millets &amp; RS3 Potato\/Rice&#8217; },                            { id: &#8216;Fruits &amp; Berries&#8217;, label: &#8216;&#x1f34b; Fruits &amp; Berries&#8217; },                            { id: &#8216;Nuts, Seeds &amp; Oils&#8217;, label: &#8216;&#x1f330; Nuts, Chia, Pumpkin Seeds &amp; Oils&#8217; },                            { id: &#8216;Proteins, Legumes &amp; Dairy&#8217;, label: &#8216;&#x1fad8; Proteins, Dal, Paneer &amp; Eggs&#8217; }                          ].map(cat =&gt; (                            &lt;button                              key={cat.id}                              type=&#8221;button&#8221;                              onClick={() =&gt; {                                setInspectorCategory(cat.id);                                const matching = cat.id === &#8216;All&#8217; ? FOOD_DATABASE : FOOD_DATABASE.filter(f =&gt; f.category === cat.id);                                if (matching.length &gt; 0 &amp;&amp; !matching.some(f =&gt; f.id === inspectorFoodId)) {                                  const nextFood = matching[0];                                  setInspectorFoodId(nextFood.id);                                  setInspectorGrams(getBaseGrams(nextFood));                                }                              }}                              className={`px-3 py-1.5 rounded-xl text-xs font-bold border transition ${                                inspectorCategory === cat.id                                  ? &#8216;bg-teal-700 text-white border-teal-700 shadow-sm&#8217;                                  : &#8216;bg-white text-slate-700 border-teal-200 hover:bg-teal-100\/70&#8217;                              }`}                            &gt;                              {cat.label}                            &lt;\/button&gt;                          ))}                        &lt;\/div&gt;                        &lt;div className=&#8221;lg:col-span-4&#8243;&gt;                          &lt;input                            type=&#8221;text&#8221;                            value={inspectorSearch}                            onChange={e =&gt; setInspectorSearch(e.target.value)}                            placeholder=&#8221;&#x1f50d; Search food (e.g. chia, potato, olive oil, ragi)&#8230;&#8221;                            className=&#8221;w-full px-3 py-1.5 rounded-xl border border-teal-300 bg-white text-xs font-medium text-slate-800 focus:ring-2 focus:ring-teal-500 focus:outline-none&#8221;                          \/&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      {\/* Food Dropdown + Flexible Portion Mode (Grams vs Servings) *\/}                      &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-12 gap-4 bg-white p-4 rounded-xl border border-teal-200\/80 items-end&#8221;&gt;                        &lt;div className=&#8221;lg:col-span-5&#8243;&gt;                          &lt;label className=&#8221;block text-xs font-bold text-slate-800 mb-1&#8243;&gt;                            Select Food to Inspect:                          &lt;\/label&gt;                          &lt;select                            value={inspectorFoodId}                            onChange={e =&gt; {                              const nextId = e.target.value;                              setInspectorFoodId(nextId);                              const found = FOOD_DATABASE.find(f =&gt; f.id === nextId);                              if (found) setInspectorGrams(getBaseGrams(found));                            }}                            className=&#8221;w-full px-3 py-2.5 rounded-xl border border-slate-300 bg-slate-50\/70 text-xs font-bold text-slate-900&#8243;                          &gt;                            {(filteredInspectorFoods.length &gt; 0 ? filteredInspectorFoods : FOOD_DATABASE).map(f =&gt; (                              &lt;option key={f.id} value={f.id}&gt;                                {f.name} \u2014 [{f.category}] {f.diet.includes(toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20)) ? &#8216;\u2713 Fits Diet&#8217; : &#8221;}                              &lt;\/option&gt;                            ))}                          &lt;\/select&gt;                        &lt;\/div&gt;                        {\/* Portion Mode Toggle + Quick Presets *\/}                        &lt;div className=&#8221;lg:col-span-5 space-y-1.5&#8243;&gt;                          &lt;div className=&#8221;flex items-center justify-between&#8221;&gt;                            &lt;span className=&#8221;text-xs font-bold text-slate-800&#8243;&gt;                              Flexible Amount ({inspectedFoodMetrics.effectiveGrams}g \/ {inspectedFoodMetrics.effectiveServings}x):                            &lt;\/span&gt;                            &lt;div className=&#8221;inline-flex rounded-lg border border-slate-300 p-0.5 bg-slate-100 text-[11px] font-bold&#8221;&gt;                              &lt;button                                type=&#8221;button&#8221;                                onClick={() =&gt; setInspectorPortionMode(&#8216;grams&#8217;)}                                className={`px-2 py-0.5 rounded-md transition ${                                  inspectorPortionMode === &#8216;grams&#8217; ? &#8216;bg-teal-600 text-white&#8217; : &#8216;text-slate-600&#8217;                                }`}                              &gt;                                By Grams (g)                              &lt;\/button&gt;                              &lt;button                                type=&#8221;button&#8221;                                onClick={() =&gt; setInspectorPortionMode(&#8216;servings&#8217;)}                                className={`px-2 py-0.5 rounded-md transition ${                                  inspectorPortionMode === &#8216;servings&#8217; ? &#8216;bg-teal-600 text-white&#8217; : &#8216;text-slate-600&#8217;                                }`}                              &gt;                                By Serving (x)                              &lt;\/button&gt;                            &lt;\/div&gt;                          &lt;\/div&gt;                          {inspectorPortionMode === &#8216;grams&#8217; ? (                            &lt;div className=&#8221;space-y-1.5&#8243;&gt;                              &lt;div className=&#8221;flex flex-wrap gap-1&#8243;&gt;                                {[15, 30, 50, 100, 150, 200, 250, 300].map(g =&gt; (                                  &lt;button                                    key={g}                                    type=&#8221;button&#8221;                                    onClick={() =&gt; setInspectorGrams(g)}                                    className={`px-2 py-1 rounded-lg text-[11px] font-bold border transition ${                                      Number(inspectorGrams) === g                                        ? &#8216;bg-teal-600 text-white border-teal-600&#8217;                                        : &#8216;bg-slate-50 text-slate-700 border-slate-300 hover:bg-teal-50&#8217;                                    }`}                                  &gt;                                    {g}g                                  &lt;\/button&gt;                                ))}                              &lt;\/div&gt;                              &lt;div className=&#8221;flex items-center gap-2&#8243;&gt;                                &lt;input                                  type=&#8221;number&#8221;                                  min=&#8221;5&#8243;                                  max=&#8221;2000&#8243;                                  step=&#8221;5&#8243;                                  value={inspectorGrams}                                  onChange={e =&gt; setInspectorGrams(parseInputNum(e.target.value, 0, 2000))}                                  placeholder=&#8221;Custom grams (e.g. 120)&#8221;                                  className=&#8221;w-full px-3 py-1.5 rounded-lg border border-slate-300 text-xs font-bold text-slate-900&#8243;                                \/&gt;                                &lt;span className=&#8221;text-xs text-slate-500 font-semibold shrink-0&#8243;&gt;                                  grams (Std: {inspectedFoodMetrics.baseGrams}g)                                &lt;\/span&gt;                              &lt;\/div&gt;                            &lt;\/div&gt;                          ) : (                            &lt;div className=&#8221;flex flex-wrap gap-1.5 pt-0.5&#8243;&gt;                              {[                                { s: 0.25, label: &#8216;0.25x (Quarter)&#8217; },                                { s: 0.5, label: &#8216;0.5x (Half)&#8217; },                                { s: 1, label: &#8216;1.0x (Standard)&#8217; },                                { s: 1.5, label: &#8216;1.5x Portion&#8217; },                                { s: 2, label: &#8216;2.0x (Double)&#8217; },                                { s: 3, label: &#8216;3.0x (Triple)&#8217; }                              ].map(opt =&gt; (                                &lt;button                                  key={opt.s}                                  type=&#8221;button&#8221;                                  onClick={() =&gt; setInspectorServings(opt.s)}                                  className={`px-2.5 py-1.5 rounded-lg text-[11px] font-bold border transition ${                                    Number(inspectorServings) === opt.s                                      ? &#8216;bg-teal-600 text-white border-teal-600&#8217;                                      : &#8216;bg-slate-50 text-slate-700 border-slate-300 hover:bg-teal-50&#8217;                                  }`}                                &gt;                                  {opt.label}                                &lt;\/button&gt;                              ))}                            &lt;\/div&gt;                          )}                        &lt;\/div&gt;                        &lt;div className=&#8221;lg:col-span-2&#8243;&gt;                          &lt;button                            type=&#8221;button&#8221;                            onClick={() =&gt;                              addFoodToLog(                                inspectorFoodId,                                inspectedFoodMetrics.effectiveServings,                                inspectorPortionMode === &#8216;grams&#8217;                                  ? `${inspectedFoodMetrics.effectiveGrams}g`                                  : `${inspectedFoodMetrics.effectiveServings}x`                              )                            }                            className=&#8221;w-full px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-500 text-white text-xs font-extrabold shadow-sm transition flex items-center justify-center gap-1.5&#8243;                          &gt;                            &lt;Icon name=&#8221;plus&#8221; className=&#8221;w-4 h-4&#8243; \/&gt;                            &lt;span&gt;                              Add ({inspectorPortionMode === &#8216;grams&#8217; ? `${inspectedFoodMetrics.effectiveGrams}g` : `${inspectedFoodMetrics.effectiveServings}x`}) to Log                            &lt;\/span&gt;                          &lt;\/button&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      {\/* Categorized, Easy-to-Read 4-Column Nutrient Breakdown of the Selected Food *\/}                      &lt;div className=&#8221;grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3 text-xs&#8221;&gt;                        {\/* Box 1: Energy, Carbs &amp; Glycemic Impact *\/}                        &lt;div className=&#8221;bg-white p-3.5 rounded-xl border border-slate-200 space-y-2&#8243;&gt;                          &lt;div className=&#8221;font-extrabold text-slate-900 border-b border-slate-100 pb-1 flex items-center justify-between&#8221;&gt;                            &lt;span&gt;1. Energy &amp;amp; Glycemic Load&lt;\/span&gt;                            &lt;span className={`px-2 py-0.5 rounded text-[10px] font-bold ${inspectedFoodMetrics.glycemicLoad &lt;= 10 ? &#8216;bg-emerald-50 text-emerald-700&#8217; : inspectedFoodMetrics.glycemicLoad &lt;= 19 ? &#8216;bg-amber-50 text-amber-700&#8217; : &#8216;bg-rose-50 text-rose-700&#8217;}`}&gt;                              GL: {inspectedFoodMetrics.glycemicLoad} ({inspectedFoodMetrics.glycemicLoad &lt;= 10 ? &#8216;Low&#8217; : inspectedFoodMetrics.glycemicLoad &lt;= 19 ? &#8216;Med&#8217; : &#8216;High&#8217;})                            &lt;\/span&gt;                          &lt;\/div&gt;                          &lt;div className=&#8221;space-y-1 text-[11px]&#8221;&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Calories:&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-slate-900&#8243;&gt;{inspectedFoodMetrics.cal} kcal&lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Total Carbs:&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;{inspectedFoodMetrics.carb}g&lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Net Digestible Carbs:&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-teal-800&#8243;&gt;{inspectedFoodMetrics.netCarb}g&lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Dietary Fiber:&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-emerald-700&#8243;&gt;                                {inspectedFoodMetrics.fiber}g ({Math.round((inspectedFoodMetrics.fiber \/ DAILY_VALUE_TARGETS.fiber.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                        {\/* Box 2: Protein, Amino Acids &amp; Healthy Fats *\/}                        &lt;div className=&#8221;bg-white p-3.5 rounded-xl border border-slate-200 space-y-2&#8243;&gt;                          &lt;div className=&#8221;font-extrabold text-slate-900 border-b border-slate-100 pb-1 flex items-center justify-between&#8221;&gt;                            &lt;span&gt;2. Protein, Amino &amp;amp; Lipids&lt;\/span&gt;                            &lt;span className=&#8221;text-[10px] font-bold text-teal-700&#8243;&gt;                              {Math.round((inspectedFoodMetrics.pro \/ (nutritionTotals.dynamicProTarget || DAILY_VALUE_TARGETS.pro.dv)) * 100)}% DV Pro                            &lt;\/span&gt;                          &lt;\/div&gt;                          &lt;div className=&#8221;space-y-1 text-[11px]&#8221;&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Protein:&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-slate-900&#8243;&gt;{inspectedFoodMetrics.pro}g&lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Leucine (Muscle Trigger):&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-teal-700&#8243;&gt;                                {inspectedFoodMetrics.leucine}g ({Math.round((inspectedFoodMetrics.leucine \/ DAILY_VALUE_TARGETS.leucine.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Total Fat (SFA\/MUFA\/PUFA):&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;                                {inspectedFoodMetrics.fat}g ({inspectedFoodMetrics.sfa}\/{inspectedFoodMetrics.mufa}\/{inspectedFoodMetrics.pufa}g)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Omega-3 Fatty Acids:&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-sky-700&#8243;&gt;                                {inspectedFoodMetrics.omega3}g ({Math.round((inspectedFoodMetrics.omega3 \/ DAILY_VALUE_TARGETS.omega3.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                        {\/* Box 3: Essential Macro &amp; Trace Minerals (%DV) *\/}                        &lt;div className=&#8221;bg-white p-3.5 rounded-xl border border-slate-200 space-y-2&#8243;&gt;                          &lt;div className=&#8221;font-extrabold text-slate-900 border-b border-slate-100 pb-1 flex items-center justify-between&#8221;&gt;                            &lt;span&gt;3. Essential Minerals (%DV)&lt;\/span&gt;                            &lt;span className=&#8221;text-[10px] font-bold text-indigo-700&#8243;&gt;Electrolytes &amp;amp; Cofactors&lt;\/span&gt;                          &lt;\/div&gt;                          &lt;div className=&#8221;space-y-1 text-[11px]&#8221;&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Magnesium (Mg):&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-slate-900&#8243;&gt;                                {inspectedFoodMetrics.mg}mg ({Math.round((inspectedFoodMetrics.mg \/ DAILY_VALUE_TARGETS.mg.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Potassium (K):&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-slate-900&#8243;&gt;                                {inspectedFoodMetrics.k}mg ({Math.round((inspectedFoodMetrics.k \/ DAILY_VALUE_TARGETS.k.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Calcium (Ca):&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;                                {inspectedFoodMetrics.ca}mg ({Math.round((inspectedFoodMetrics.ca \/ DAILY_VALUE_TARGETS.ca.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Iron (Fe) &amp;amp; Zinc (Zn):&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;                                Fe: {inspectedFoodMetrics.fe}mg ({Math.round((inspectedFoodMetrics.fe \/ DAILY_VALUE_TARGETS.fe.dv) * 100)}%) \u2022 Zn: {inspectedFoodMetrics.zn}mg ({Math.round((inspectedFoodMetrics.zn \/ DAILY_VALUE_TARGETS.zn.dv) * 100)}%)                              &lt;\/span&gt;                            &lt;\/div&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                        {\/* Box 4: Vitamins &amp; Hepatic Choline (%DV) *\/}                        &lt;div className=&#8221;bg-white p-3.5 rounded-xl border border-slate-200 space-y-2&#8243;&gt;                          &lt;div className=&#8221;font-extrabold text-slate-900 border-b border-slate-100 pb-1 flex items-center justify-between&#8221;&gt;                            &lt;span&gt;4. Vitamins &amp;amp; Liver Choline&lt;\/span&gt;                            &lt;span className=&#8221;text-[10px] font-bold text-amber-700&#8243;&gt;Methylation &amp;amp; NAFLD&lt;\/span&gt;                          &lt;\/div&gt;                          &lt;div className=&#8221;space-y-1 text-[11px]&#8221;&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Choline (Liver Export):&lt;\/span&gt;                              &lt;span className=&#8221;font-bold text-teal-800&#8243;&gt;                                {inspectedFoodMetrics.choline}mg ({Math.round((inspectedFoodMetrics.choline \/ DAILY_VALUE_TARGETS.choline.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Folate (B9) &amp;amp; Vit B12:&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;                                B9: {inspectedFoodMetrics.folate}mcg ({Math.round((inspectedFoodMetrics.folate \/ DAILY_VALUE_TARGETS.folate.dv) * 100)}%) \u2022 B12: {inspectedFoodMetrics.b12}mcg ({Math.round((inspectedFoodMetrics.b12 \/ DAILY_VALUE_TARGETS.b12.dv) * 100)}%)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Vitamin C:&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;                                {inspectedFoodMetrics.vitC}mg ({Math.round((inspectedFoodMetrics.vitC \/ DAILY_VALUE_TARGETS.vitC.dv) * 100)}% DV)                              &lt;\/span&gt;                            &lt;\/div&gt;                            &lt;div className=&#8221;flex justify-between&#8221;&gt;                              &lt;span className=&#8221;text-slate-500&#8243;&gt;Vitamin A &amp;amp; Vitamin D3:&lt;\/span&gt;                              &lt;span className=&#8221;font-semibold text-slate-800&#8243;&gt;                                A: {inspectedFoodMetrics.vitA}mcg ({Math.round((inspectedFoodMetrics.vitA \/ DAILY_VALUE_TARGETS.vitA.dv) * 100)}%) \u2022 D: {inspectedFoodMetrics.vitD}IU                              &lt;\/span&gt;                            &lt;\/div&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                    {\/* =====================================================================                        STEP 2 &amp; STEP 3: ORGANIZED DAILY %DV PROGRESS + SMART FOOD ADVISOR                       ===================================================================== *\/}                    &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-12 gap-6&#8243;&gt;                      {\/* Step 2: Grouped Daily %DV Fulfillment Tracker (7 cols) *\/}                      &lt;div className=&#8221;lg:col-span-7 space-y-4&#8243;&gt;                        &lt;div className=&#8221;flex items-center justify-between&#8221;&gt;                          &lt;div className=&#8221;text-xs sm:text-sm font-extrabold text-slate-900 flex items-center gap-2&#8243;&gt;                            &lt;span className=&#8221;w-6 h-6 rounded-full bg-teal-700 text-white flex items-center justify-center text-xs&#8221;&gt;2&lt;\/span&gt;                            &lt;span&gt;Step 2: Your Total Daily %DV Fulfillment Across 15 Key Nutrients&lt;\/span&gt;                          &lt;\/div&gt;                          &lt;span className=&#8221;text-[11px] text-slate-500&#8243;&gt;From {nutrition.loggedFoods.length} logged item(s)&lt;\/span&gt;                        &lt;\/div&gt;                        {[                          { groupTitle: &#8216;A. Macros, Fiber, Essential Amino &amp; Omega-3&#8217;, keys: [&#8216;pro&#8217;, &#8216;fiber&#8217;, &#8216;leucine&#8217;, &#8216;omega3&#8217;] },                          { groupTitle: &#8216;B. Essential Metabolic Minerals (Insulin &amp; Blood Pressure Cofactors)&#8217;, keys: [&#8216;mg&#8217;, &#8216;k&#8217;, &#8216;ca&#8217;, &#8216;fe&#8217;, &#8216;zn&#8217;] },                          { groupTitle: &#8216;C. Hepatic Choline &amp; Essential Vitamins&#8217;, keys: [&#8216;choline&#8217;, &#8216;vitC&#8217;, &#8216;folate&#8217;, &#8216;b12&#8217;, &#8216;vitA&#8217;, &#8216;vitD&#8217;] }                        ].map(group =&gt; (                          &lt;div key={group.groupTitle} className=&#8221;bg-slate-50 p-3.5 rounded-2xl border border-slate-200 space-y-2.5&#8243;&gt;                            &lt;div className=&#8221;text-xs font-extrabold text-teal-900 uppercase tracking-wide&#8221;&gt;                              {group.groupTitle}                            &lt;\/div&gt;                            &lt;div className=&#8221;grid grid-cols-1 sm:grid-cols-2 gap-2.5&#8243;&gt;                              {nutritionTotals.dvProgress                                .filter(item =&gt; group.keys.includes(item.key))                                .map(item =&gt; {                                  const barColor = item.pct &gt;= 80 ? &#8216;bg-emerald-500&#8217; : item.pct &gt;= 45 ? &#8216;bg-amber-500&#8217; : &#8216;bg-rose-500&#8217;;                                  const statusText = item.pct &gt;= 80 ? &#8216;Optimal&#8217; : item.pct &gt;= 45 ? &#8216;Moderate&#8217; : &#8216;Low&#8217;;                                  return (                                    &lt;div key={item.key} className=&#8221;p-2.5 rounded-xl bg-white border border-slate-200 text-xs&#8221;&gt;                                      &lt;div className=&#8221;flex items-center justify-between font-bold text-slate-800 mb-1&#8243;&gt;                                        &lt;span&gt;{item.label}&lt;\/span&gt;                                        &lt;span className={`text-[11px] font-extrabold ${item.pct &gt;= 80 ? &#8216;text-emerald-700&#8217; : item.pct &gt;= 45 ? &#8216;text-amber-700&#8217; : &#8216;text-rose-700&#8217;}`}&gt;                                          {formatNutrientVal(item.current)}{item.unit} \/ {formatNutrientVal(item.target)}{item.unit} ({item.pct}% DV)                                        &lt;\/span&gt;                                      &lt;\/div&gt;                                      &lt;div className=&#8221;w-full h-2 bg-slate-100 rounded-full overflow-hidden mb-1&#8243;&gt;                                        &lt;div                                          className={`h-full ${barColor} transition-all duration-300`}                                          style={{ width: `${Math.min(100, item.pct)}%` }}                                        \/&gt;                                      &lt;\/div&gt;                                      &lt;div className=&#8221;flex items-center justify-between text-[10px] text-slate-500&#8243;&gt;                                        &lt;span className=&#8221;truncate pr-1&#8243;&gt;{item.role}&lt;\/span&gt;                                        &lt;span className=&#8221;font-semibold shrink-0&#8243;&gt;{statusText}&lt;\/span&gt;                                      &lt;\/div&gt;                                    &lt;\/div&gt;                                  );                                })}                            &lt;\/div&gt;                          &lt;\/div&gt;                        ))}                      &lt;\/div&gt;                      {\/* Step 3: Smart Decision Guide \u2014 &#8220;What Should I Eat Next?&#8221; (5 cols) *\/}                      &lt;div className=&#8221;lg:col-span-5 bg-teal-50\/50 rounded-2xl p-4 border border-teal-200 space-y-3 self-start&#8221;&gt;                        &lt;div className=&#8221;text-xs sm:text-sm font-extrabold text-slate-900 flex items-center gap-2&#8243;&gt;                          &lt;span className=&#8221;w-6 h-6 rounded-full bg-teal-700 text-white flex items-center justify-center text-xs&#8221;&gt;3&lt;\/span&gt;                          &lt;span&gt;Step 3: Smart Decision Guide \u2014 What to Eat Next&lt;\/span&gt;                        &lt;\/div&gt;                        &lt;p className=&#8221;text-xs text-slate-600 leading-relaxed&#8221;&gt;                          We automatically scan your logged meals for any nutrient under &lt;strong&gt;60% DV&lt;\/strong&gt; and rank the richest whole foods matching your &lt;strong&gt;{toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20).toUpperCase()}&lt;\/strong&gt; diet. Click any suggestion to add it:                        &lt;\/p&gt;                        {nutritionTotals.lackingNutrients.length === 0 ? (                          &lt;div className=&#8221;p-4 rounded-xl bg-emerald-50 border border-emerald-200 text-xs text-emerald-900 font-semibold&#8221;&gt;                            &#x1f389; Fantastic! You have achieved at least 60% Daily Value across all tracked macro, mineral, and vitamin targets today.                          &lt;\/div&gt;                        ) : (                          &lt;div className=&#8221;space-y-2.5&#8243;&gt;                            {nutritionTotals.lackingNutrients.map(gap =&gt; {                              const deficitVal = formatNutrientVal(Math.max(0, gap.target &#8211; gap.current));                              return (                                &lt;div key={gap.key} className=&#8221;p-3.5 rounded-xl bg-white border border-slate-200 text-xs space-y-2 shadow-sm&#8221;&gt;                                  &lt;div className=&#8221;flex items-center justify-between&#8221;&gt;                                    &lt;span className=&#8221;font-extrabold text-rose-700&#8243;&gt;                                      Gap: {gap.label} ({gap.pct}% DV)                                    &lt;\/span&gt;                                    &lt;span className=&#8221;px-2 py-0.5 rounded bg-rose-50 text-rose-800 font-bold text-[10px] border border-rose-200&#8243;&gt;                                      Need +{deficitVal}{gap.unit} more                                    &lt;\/span&gt;                                  &lt;\/div&gt;                                  &lt;div className=&#8221;text-[11px] text-slate-500&#8243;&gt;                                    &lt;strong&gt;Why it matters:&lt;\/strong&gt; {gap.role}. Top whole-food sources:                                  &lt;\/div&gt;                                  &lt;div className=&#8221;space-y-1.5 pt-0.5&#8243;&gt;                                    {gap.bestFoods.length === 0 ? (                                      &lt;span className=&#8221;text-[11px] text-slate-500 block&#8221;&gt;                                        For Vitamin D3, prioritize 20 mins of midday sunlight exposure or a D3+K2 supplement.                                      &lt;\/span&gt;                                    ) : (                                      gap.bestFoods.map(f =&gt; {                                        const pctFromOneServing = Math.round(((Number(f[gap.key]) || 0) \/ gap.target) * 100);                                        return (                                          &lt;div key={f.id} className=&#8221;flex items-center justify-between gap-2 p-2 rounded-lg bg-teal-50\/70 border border-teal-200\/80&#8243;&gt;                                            &lt;div className=&#8221;text-[11px]&#8221;&gt;                                              &lt;div className=&#8221;font-bold text-slate-900&#8243;&gt;{f.name}&lt;\/div&gt;                                              &lt;div className=&#8221;text-teal-800 font-semibold&#8221;&gt;                                                Provides +{f[gap.key]}{gap.unit} ({pctFromOneServing}% of daily target)                                              &lt;\/div&gt;                                            &lt;\/div&gt;                                            &lt;div className=&#8221;flex items-center gap-1 shrink-0&#8243;&gt;                                              &lt;button                                                type=&#8221;button&#8221;                                                onClick={() =&gt; {                                                  setInspectorFoodId(f.id);                                                  setInspectorGrams(getBaseGrams(f));                                                  triggerToast(`Inspecting ${f.name.split(&#8216;(&#8216;)[0].trim()}`);                                                }}                                                className=&#8221;px-2 py-1 rounded-lg bg-white hover:bg-slate-100 text-slate-700 border border-slate-300 text-[10px] font-bold&#8221;                                                title=&#8221;Inspect full nutrient profile above&#8221;                                              &gt;                                                Inspect                                              &lt;\/button&gt;                                              &lt;button                                                type=&#8221;button&#8221;                                                onClick={() =&gt; addFoodToLog(f.id, 1)}                                                className=&#8221;px-2.5 py-1 rounded-lg bg-teal-600 hover:bg-teal-500 text-white text-[10px] font-bold shadow-sm&#8221;                                              &gt;                                                + Add 1x                                              &lt;\/button&gt;                                            &lt;\/div&gt;                                          &lt;\/div&gt;                                        );                                      })                                    )}                                  &lt;\/div&gt;                                &lt;\/div&gt;                              );                            })}                          &lt;\/div&gt;                        )}                      &lt;\/div&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              )}              {activeTab === &#8216;fasting&#8217; &amp;&amp; (                &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-3 gap-6&#8243;&gt;                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3 text-xs&#8221;&gt;                    &lt;h2 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;Fasting Window &amp;amp; OMAD Tracker&lt;\/h2&gt;                    &lt;div&gt;                      &lt;label className=&#8221;block font-semibold text-slate-600 mb-1&#8243;&gt;Active Fasting Regimen&lt;\/label&gt;                      &lt;select                        value={fasting.protocol}                        onChange={e =&gt; setFasting({ &#8230;fasting, protocol: e.target.value })}                        className=&#8221;w-full px-3 py-2.5 rounded-xl border border-slate-300 bg-white font-semibold&#8221;                      &gt;                        &lt;option value=&#8221;12:12&#8243;&gt;12:12 Basic Circadian Reset&lt;\/option&gt;                        &lt;option value=&#8221;14:10&#8243;&gt;14:10 Early Time-Restricted Eating (eTRE)&lt;\/option&gt;                        &lt;option value=&#8221;16:8&#8243;&gt;16:8 Intermittent Fasting (Insulin Reset)&lt;\/option&gt;                        &lt;option value=&#8221;18:6&#8243;&gt;18:6 Two-Meal Protocol (NAFLD &amp;amp; Visceral Fat)&lt;\/option&gt;                        &lt;option value=&#8221;20:4&#8243;&gt;20:4 Warrior Protocol (Deep Lipolysis)&lt;\/option&gt;                        &lt;option value=&#8221;OMAD&#8221;&gt;OMAD (23:1 One Meal A Day)&lt;\/option&gt;                        &lt;option value=&#8221;24h-Water&#8221;&gt;24-Hour Water + Electrolyte Autophagy Fast&lt;\/option&gt;                        &lt;option value=&#8221;ADF-36h&#8221;&gt;36-Hour Alternate-Day Fast (ADF \/ Monk Fast)&lt;\/option&gt;                        &lt;option value=&#8221;Dry-Soft&#8221;&gt;Dawn-to-Dusk Dry Fast (Circadian Reset)&lt;\/option&gt;                      &lt;\/select&gt;                    &lt;\/div&gt;                    &lt;div&gt;                      &lt;label className=&#8221;block font-semibold text-slate-600 mb-1&#8243;&gt;Fasting Medium&lt;\/label&gt;                      &lt;select                        value={fasting.fastingType}                        onChange={e =&gt; setFasting({ &#8230;fasting, fastingType: e.target.value })}                        className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300 bg-white&#8221;                      &gt;                        &lt;option value=&#8221;water-electrolyte&#8221;&gt;Mineral Water + Unsweetened Electrolytes Only&lt;\/option&gt;                        &lt;option value=&#8221;black-coffee-tea&#8221;&gt;Water + Black Coffee \/ Green Tea \/ Herbal&lt;\/option&gt;                        &lt;option value=&#8221;dry&#8221;&gt;Dry Fasting (Zero Food or Liquid Window)&lt;\/option&gt;                      &lt;\/select&gt;                    &lt;\/div&gt;                    &lt;div&gt;                      &lt;div className=&#8221;flex justify-between font-semibold mb-1&#8243;&gt;                        &lt;span&gt;Current Fast Hours&lt;\/span&gt;                        &lt;span className=&#8221;text-teal-700 font-bold&#8221;&gt;{toSafeFloat(fasting.currentFastHours, 0, 0, 48)}h&lt;\/span&gt;                      &lt;\/div&gt;                      &lt;input                        type=&#8221;range&#8221;                        min=&#8221;0&#8243;                        max=&#8221;48&#8243;                        step=&#8221;0.5&#8243;                        value={toSafeFloat(fasting.currentFastHours, 0, 0, 48)}                        onChange={e =&gt; setFasting({ &#8230;fasting, currentFastHours: toSafeFloat(e.target.value, 0, 0, 48) })}                        className=&#8221;w-full accent-teal-600&#8243;                      \/&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;pt-1&#8243;&gt;                      &lt;label className=&#8221;block font-semibold text-slate-600 mb-1.5&#8243;&gt;Distinct Meals Per Day (OMAD = 1 Meal)&lt;\/label&gt;                      &lt;div className=&#8221;grid grid-cols-4 gap-1.5&#8243;&gt;                        {[                          { count: 1, label: &#8216;1 (OMAD)&#8217; },                          { count: 2, label: &#8216;2 (2MAD)&#8217; },                          { count: 3, label: &#8216;3 Meals&#8217; },                          { count: 4, label: &#8216;4+ Grazing&#8217; }                        ].map(m =&gt; (                          &lt;button                            key={m.count}                            type=&#8221;button&#8221;                            onClick={() =&gt; setFasting({ &#8230;fasting, mealsPerDay: m.count, &#8230;(m.count === 1 ? { protocol: &#8216;OMAD&#8217; } : {}) })}                            className={`py-1.5 px-1 rounded-xl text-[11px] font-bold border transition ${                              Number(fasting.mealsPerDay) === m.count                                ? &#8216;bg-teal-600 text-white border-teal-600&#8217;                                : &#8216;bg-slate-50 text-slate-700 border-slate-200 hover:bg-slate-100&#8217;                            }`}                          &gt;                            {m.label}                          &lt;\/button&gt;                        ))}                      &lt;\/div&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3 text-xs&#8221;&gt;                    &lt;h2 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;                      Circadian Eating Gaps &lt;Tooltip text={CLINICAL_TOOLTIPS.circadianEating} \/&gt;                    &lt;\/h2&gt;                    &lt;div className=&#8221;grid grid-cols-2 gap-2.5&#8243;&gt;                      &lt;div&gt;                        &lt;label className=&#8221;block font-semibold text-slate-600 mb-1&#8243;&gt;Wake Time&lt;\/label&gt;                        &lt;input type=&#8221;time&#8221; value={fasting.wakeTime} onChange={e =&gt; setFasting({ &#8230;fasting, wakeTime: e.target.value })} className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-slate-300&#8243; \/&gt;                      &lt;\/div&gt;                      &lt;div&gt;                        &lt;label className=&#8221;block font-semibold text-slate-600 mb-1&#8243;&gt;First Meal&lt;\/label&gt;                        &lt;input type=&#8221;time&#8221; value={fasting.firstMealTime} onChange={e =&gt; setFasting({ &#8230;fasting, firstMealTime: e.target.value })} className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-slate-300&#8243; \/&gt;                      &lt;\/div&gt;                      &lt;div&gt;                        &lt;label className=&#8221;block font-semibold text-slate-600 mb-1&#8243;&gt;Last Meal&lt;\/label&gt;                        &lt;input type=&#8221;time&#8221; value={fasting.lastMealTime} onChange={e =&gt; setFasting({ &#8230;fasting, lastMealTime: e.target.value })} className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-slate-300&#8243; \/&gt;                      &lt;\/div&gt;                      &lt;div&gt;                        &lt;label className=&#8221;block font-semibold text-slate-600 mb-1&#8243;&gt;Sleep Time&lt;\/label&gt;                        &lt;input type=&#8221;time&#8221; value={fasting.sleepTime} onChange={e =&gt; setFasting({ &#8230;fasting, sleepTime: e.target.value })} className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-slate-300&#8243; \/&gt;                      &lt;\/div&gt;                    &lt;\/div&gt;                    &lt;div className=&#8221;flex justify-between p-3 rounded-xl bg-slate-50 border border-slate-200&#8243;&gt;                      &lt;span&gt;Pre-Sleep Digestion Gap:&lt;\/span&gt;                      &lt;span className={`font-bold ${clinicalMetrics.eveningGapHours === null ? &#8216;text-slate-500&#8217; : clinicalMetrics.eveningGapHours &gt;= 3 ? &#8216;text-emerald-700&#8217; : &#8216;text-rose-600&#8217;}`}&gt;                        {clinicalMetrics.eveningGapHours !== null ? `${clinicalMetrics.eveningGapHours} hrs (Target: 3h+)` : &#8216;Enter Meal &amp; Sleep Times&#8217;}                      &lt;\/span&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;bg-teal-950 text-white rounded-2xl p-6 shadow-sm space-y-2 text-xs&#8221;&gt;                    &lt;div className=&#8221;font-bold text-teal-300 text-sm&#8221;&gt;Why Meal Frequency Drives Insulin&lt;\/div&gt;                    &lt;p className=&#8221;text-slate-200 leading-relaxed&#8221;&gt;                      Consolidating intake into 2 structured meals within an early 6\u20138 hour window allows serum insulin to remain at baseline for 16+ hours, unlocking hepatic fat oxidation and reversing peripheral insulin resistance.                    &lt;\/p&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              )}              {activeTab === &#8216;activity&#8217; &amp;&amp; (                &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-12 gap-6&#8243;&gt;                  {\/* Upgraded Post-Meal Walk Tracker with Pace &amp; Flexible Duration (10m &#8211; 60m) *\/}                  &lt;div className=&#8221;lg:col-span-5 bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-4 text-xs&#8221;&gt;                    &lt;div className=&#8221;flex items-center justify-between&#8221;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2&#8243;&gt;                        &lt;Icon name=&#8221;footprints&#8221; className=&#8221;w-5 h-5 text-teal-600&#8243; \/&gt;                        Post-Meal Walk Tracker                        &lt;Tooltip text={CLINICAL_TOOLTIPS.postMealWalk} \/&gt;                      &lt;\/h2&gt;                      &lt;StatusBadge                        status={clinicalMetrics.totalPostMealWalkMins &gt;= 30 ? &#8216;optimal&#8217; : clinicalMetrics.totalPostMealWalkMins &gt; 0 ? &#8216;info&#8217; : &#8216;warning&#8217;}                        label={`${clinicalMetrics.totalPostMealWalkMins}m Total (-${clinicalMetrics.totalWalkReduction} mg\/dL Peak)`}                      \/&gt;                    &lt;\/div&gt;                    &lt;p className=&#8221;text-slate-600 leading-relaxed&#8221;&gt;                      Walking within 15\u201320 minutes after eating contracts skeletal muscle fibers, pulling glucose out of the bloodstream via &lt;strong&gt;insulin-independent GLUT4 translocation&lt;\/strong&gt;. Choose your pace and duration for each meal:                    &lt;\/p&gt;                    &lt;div className=&#8221;space-y-3&#8243;&gt;                      {[                        { key: &#8216;breakfastWalk&#8217;, minsKey: &#8216;breakfastWalkMins&#8217;, paceKey: &#8216;breakfastWalkPace&#8217;, title: &#8216;Post-Meal Walk #1 (After Breakfast \/ First Meal)&#8217; },                        { key: &#8216;lunchWalk&#8217;, minsKey: &#8216;lunchWalkMins&#8217;, paceKey: &#8216;lunchWalkPace&#8217;, title: &#8216;Post-Meal Walk #2 (After Lunch \/ Midday Meal)&#8217; },                        { key: &#8216;dinnerWalk&#8217;, minsKey: &#8216;dinnerWalkMins&#8217;, paceKey: &#8216;dinnerWalkPace&#8217;, title: &#8216;Post-Meal Walk #3 (After Dinner &#8211; Most Crucial)&#8217; }                      ].map(item =&gt; {                        const walksObj = activity?.postMealWalks || DEFAULT_ACTIVITY.postMealWalks;                        const isChecked = Boolean(walksObj[item.key]);                        const currentMins = toSafeFloat(walksObj[item.minsKey], 20, 5, 120);                        const currentPace = walksObj[item.paceKey] || &#8216;normal&#8217;;                        return (                          &lt;div                            key={item.key}                            className={`p-3.5 rounded-xl border transition ${                              isChecked ? &#8216;bg-teal-50\/70 border-teal-400&#8217; : &#8216;bg-slate-50 border-slate-200&#8217;                            }`}                          &gt;                            &lt;label className=&#8221;flex items-center justify-between cursor-pointer mb-2.5&#8243;&gt;                              &lt;span className=&#8221;font-bold text-slate-900&#8243;&gt;{item.title}&lt;\/span&gt;                              &lt;input                                type=&#8221;checkbox&#8221;                                checked={isChecked}                                onChange={e =&gt;                                  setActivity({                                    &#8230;activity,                                    postMealWalks: {                                      &#8230;walksObj,                                      [item.key]: e.target.checked                                    }                                  })                                }                                className=&#8221;w-4 h-4 accent-teal-600 rounded&#8221;                              \/&gt;                            &lt;\/label&gt;                            &lt;div className=&#8221;grid grid-cols-1 sm:grid-cols-2 gap-2 pt-1 border-t border-slate-200\/80&#8243;&gt;                              &lt;div&gt;                                &lt;label className=&#8221;block text-[10px] font-semibold text-slate-500 mb-1&#8243;&gt;Walking Pace \/ Speed&lt;\/label&gt;                                &lt;select                                  value={currentPace}                                  onChange={e =&gt;                                    setActivity({                                      &#8230;activity,                                      postMealWalks: {                                        &#8230;walksObj,                                        [item.paceKey]: e.target.value,                                        [item.key]: true                                      }                                    })                                  }                                  className=&#8221;w-full px-2.5 py-1.5 rounded-lg border border-slate-300 bg-white font-semibold text-slate-800&#8243;                                &gt;                                  &lt;option value=&#8221;slow&#8221;&gt;Slow \/ Gentle Stroll (Aids Digestion)&lt;\/option&gt;                                  &lt;option value=&#8221;normal&#8221;&gt;Normal \/ Steady Walk (Moderate GLUT4)&lt;\/option&gt;                                  &lt;option value=&#8221;brisk&#8221;&gt;Brisk \/ Purposeful Walk (Max Glucose Sink)&lt;\/option&gt;                                &lt;\/select&gt;                              &lt;\/div&gt;                              &lt;div&gt;                                &lt;label className=&#8221;block text-[10px] font-semibold text-slate-500 mb-1&#8243;&gt;Duration (Minutes)&lt;\/label&gt;                                &lt;div className=&#8221;flex flex-wrap gap-1&#8243;&gt;                                  {[10, 15, 20, 30, 40, 60].map(m =&gt; (                                    &lt;button                                      key={m}                                      type=&#8221;button&#8221;                                      onClick={() =&gt;                                        setActivity({                                          &#8230;activity,                                          postMealWalks: {                                            &#8230;walksObj,                                            [item.minsKey]: m,                                            [item.key]: true                                          }                                        })                                      }                                      className={`px-2 py-1 rounded-lg text-[11px] font-bold border transition ${                                        isChecked &amp;&amp; currentMins === m                                          ? &#8216;bg-teal-600 text-white border-teal-600&#8217;                                          : &#8216;bg-white text-slate-700 border-slate-300 hover:bg-teal-50&#8217;                                      }`}                                    &gt;                                      {m}m                                    &lt;\/button&gt;                                  ))}                                &lt;\/div&gt;                              &lt;\/div&gt;                            &lt;\/div&gt;                          &lt;\/div&gt;                        );                      })}                    &lt;\/div&gt;                    {\/* Daily Non-Exercise Steps (NEAT) Slider *\/}                    &lt;div className=&#8221;pt-2 border-t border-slate-200&#8243;&gt;                      &lt;div className=&#8221;flex justify-between font-semibold mb-1&#8243;&gt;                        &lt;span className=&#8221;text-slate-700&#8243;&gt;Total Daily Step Count (NEAT)&lt;\/span&gt;                        &lt;span className=&#8221;text-teal-700 font-bold&#8221;&gt;{toSafeFloat(activity.dailySteps, 0, 0, 100000).toLocaleString()} steps&lt;\/span&gt;                      &lt;\/div&gt;                      &lt;input                        type=&#8221;range&#8221;                        min=&#8221;0&#8243;                        max=&#8221;20000&#8243;                        step=&#8221;500&#8243;                        value={toSafeFloat(activity.dailySteps, 0, 0, 20000)}                        onChange={e =&gt; setActivity({ &#8230;activity, dailySteps: toSafeFloat(e.target.value, 0, 0, 20000) })}                        className=&#8221;w-full accent-teal-600&#8243;                      \/&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  {\/* Upgraded Exercise &amp; Peri-Workout Nutrition Protocol *\/}                  &lt;div className=&#8221;lg:col-span-7 bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-4 text-xs&#8221;&gt;                    &lt;div className=&#8221;flex flex-wrap items-center justify-between gap-2&#8243;&gt;                      &lt;div&gt;                        &lt;h2 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;Exercise &amp;amp; Peri-Workout Nutrition Engine&lt;\/h2&gt;                        &lt;p className=&#8221;text-slate-500&#8243;&gt;                          Align your pre-workout fuel, intra-workout electrolytes, and post-workout protein\/leucine window with your training style                        &lt;\/p&gt;                      &lt;\/div&gt;                      &lt;StatusBadge                        status={activity.workouts.length &gt; 0 ? &#8216;optimal&#8217; : &#8216;info&#8217;}                        label={`${activity.workouts.length} Session(s) Logged`}                      \/&gt;                    &lt;\/div&gt;                    &lt;form onSubmit={addWorkoutLog} className=&#8221;bg-slate-50 p-4 rounded-2xl border border-slate-200 space-y-3&#8243;&gt;                      &lt;div className=&#8221;grid grid-cols-1 sm:grid-cols-3 gap-2.5&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;1. Exercise Modality&lt;\/label&gt;                          &lt;select                            value={newWorkout.type}                            onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, type: e.target.value })}                            className=&#8221;w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white font-semibold&#8221;                          &gt;                            &lt;option value=&#8221;Resistance Training (Hypertrophy)&#8221;&gt;Resistance Training (Builds Muscle Glucose Sink)&lt;\/option&gt;                            &lt;option value=&#8221;Zone 2 Brisk Walk \/ Cycling \/ Swim&#8221;&gt;Zone 2 Cardio (Mitochondrial Fat Oxidation)&lt;\/option&gt;                            &lt;option value=&#8221;HIIT \/ Sprint Intervals&#8221;&gt;HIIT \/ Sprints (Liver Glycogen Depletion)&lt;\/option&gt;                            &lt;option value=&#8221;Bodyweight Calisthenics &amp; Core&#8221;&gt;Bodyweight Calisthenics &amp;amp; Functional Strength&lt;\/option&gt;                            &lt;option value=&#8221;Surya Namaskar, Yoga &amp; Pranayama&#8221;&gt;Surya Namaskar, Yoga &amp;amp; Vagal Toning&lt;\/option&gt;                            &lt;option value=&#8221;Sports \/ Badminton \/ Tennis \/ Running&#8221;&gt;Active Sports \/ Running&lt;\/option&gt;                          &lt;\/select&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;2. Effort &amp;amp; Metabolic State&lt;\/label&gt;                          &lt;div className=&#8221;grid grid-cols-2 gap-1.5&#8243;&gt;                            &lt;select                              value={newWorkout.intensity}                              onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, intensity: e.target.value })}                              className=&#8221;px-2 py-2 rounded-xl border border-slate-300 bg-white&#8221;                            &gt;                              &lt;option value=&#8221;Light (Zone 1-2)&#8221;&gt;Light&lt;\/option&gt;                              &lt;option value=&#8221;Moderate (RPE 7)&#8221;&gt;Moderate&lt;\/option&gt;                              &lt;option value=&#8221;Vigorous (RPE 8-9)&#8221;&gt;Vigorous&lt;\/option&gt;                            &lt;\/select&gt;                            &lt;select                              value={newWorkout.fastedState ? &#8216;fasted&#8217; : &#8216;fed&#8217;}                              onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, fastedState: e.target.value === &#8216;fasted&#8217; })}                              className=&#8221;px-2 py-2 rounded-xl border border-slate-300 bg-white font-semibold text-teal-800&#8243;                            &gt;                              &lt;option value=&#8221;fasted&#8221;&gt;Fasted State&lt;\/option&gt;                              &lt;option value=&#8221;fed&#8221;&gt;Fed State&lt;\/option&gt;                            &lt;\/select&gt;                          &lt;\/div&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;3. Duration (Minutes)&lt;\/label&gt;                          &lt;div className=&#8221;flex gap-1.5&#8243;&gt;                            &lt;input                              type=&#8221;number&#8221;                              min=&#8221;5&#8243;                              max=&#8221;600&#8243;                              value={newWorkout.durationMin}                              onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, durationMin: parseInputNum(e.target.value, 0, 600) })}                              placeholder=&#8221;e.g. 45&#8243;                              className=&#8221;w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white&#8221;                            \/&gt;                            {[30, 45, 60].map(d =&gt; (                              &lt;button                                key={d}                                type=&#8221;button&#8221;                                onClick={() =&gt; setNewWorkout({ &#8230;newWorkout, durationMin: String(d) })}                                className=&#8221;px-2 py-1 rounded-lg bg-white border border-slate-300 hover:bg-teal-50 font-semibold text-[11px]&#8221;                              &gt;                                {d}m                              &lt;\/button&gt;                            ))}                          &lt;\/div&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      {\/* Peri-Workout Nutrition Presets (Pre, Intra, Post) *\/}                      &lt;div className=&#8221;grid grid-cols-1 sm:grid-cols-3 gap-2.5 pt-2 border-t border-slate-200&#8243;&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;Pre-Workout Fuel (30-45m Prior)&lt;\/label&gt;                          &lt;select                            value={newWorkout.preWorkoutNutrition}                            onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, preWorkoutNutrition: e.target.value })}                            className=&#8221;w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white&#8221;                          &gt;                            &lt;option value=&#8221;Mineral Water + Pinch of Sendha Salt \/ Black Coffee&#8221;&gt;Fasted: Water + Sendha Salt \/ Black Coffee (Max Fat Oxidation)&lt;\/option&gt;                            &lt;option value=&#8221;Soaked Almonds, Walnuts &amp; Pumpkin Seeds (15g)&#8221;&gt;Low-Insulin: Soaked Nuts &amp;amp; Pumpkin Seeds&lt;\/option&gt;                            &lt;option value=&#8221;Green Tea + 1 Tbsp Coconut Oil \/ A2 Ghee&#8221;&gt;MCT \/ A2 Ghee + Green Tea (Ketogenic Fuel)&lt;\/option&gt;                            &lt;option value=&#8221;Small Guava \/ Berries + Chia Seeds&#8221;&gt;Targeted Low-GI Fruit + Chia Seeds&lt;\/option&gt;                            &lt;option value=&#8221;2 Boiled Eggs \/ Paneer Cube&#8221;&gt;Protein Primer (Eggs \/ Paneer)&lt;\/option&gt;                          &lt;\/select&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;Intra-Workout Hydration&lt;\/label&gt;                          &lt;select                            value={newWorkout.intraWorkoutHydration}                            onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, intraWorkoutHydration: e.target.value })}                            className=&#8221;w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white&#8221;                          &gt;                            &lt;option value=&#8221;400ml Mineral \/ Electrolyte Water&#8221;&gt;400ml Mineral \/ Electrolyte Water&lt;\/option&gt;                            &lt;option value=&#8221;500ml Water + Sendha Salt &amp; Whole Lemon&#8221;&gt;500ml Water + Sendha Salt &amp;amp; Lemon&lt;\/option&gt;                            &lt;option value=&#8221;Plain Mineral Water Sipping&#8221;&gt;Plain Mineral Water Sipping&lt;\/option&gt;                          &lt;\/select&gt;                        &lt;\/div&gt;                        &lt;div&gt;                          &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;Post-Workout Anabolic Recovery Meal&lt;\/label&gt;                          &lt;select                            value={newWorkout.postWorkoutNutrition}                            onChange={e =&gt; setNewWorkout({ &#8230;newWorkout, postWorkoutNutrition: e.target.value })}                            className=&#8221;w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white&#8221;                          &gt;                            &lt;option value=&#8221;High-Leucine Protein + Whole Food Carbs within 45m&#8221;&gt;High-Leucine Protein (2.5g+ Leu) + RS3 Carbs within 45m&lt;\/option&gt;                            &lt;option value=&#8221;Sprouted Moong Dal, Tofu\/Paneer &amp; Leafy Greens&#8221;&gt;Veg\/Vegan: Sprouted Moong, Paneer\/Tofu &amp;amp; Greens&lt;\/option&gt;                            &lt;option value=&#8221;Pasture Eggs \/ Wild Fish \/ Chicken + Cooled Potato\/Rice&#8221;&gt;Omni\/Ovo: Eggs\/Fish\/Chicken + Cooled RS3 Potato\/Rice&lt;\/option&gt;                            &lt;option value=&#8221;A2 Greek Curd + Chia, Hemp &amp; Pumpkin Seeds&#8221;&gt;Probiotic: A2 Curd + Chia, Hemp &amp;amp; Pumpkin Seeds&lt;\/option&gt;                            &lt;option value=&#8221;Continue Clean Fast for 1-2h (Growth Hormone Pulse)&#8221;&gt;Delayed Refeed: Ride Post-Exercise GH Pulse (1h)&lt;\/option&gt;                          &lt;\/select&gt;                        &lt;\/div&gt;                      &lt;\/div&gt;                      &lt;button                        type=&#8221;submit&#8221;                        className=&#8221;w-full bg-indigo-600 text-white font-bold rounded-xl py-2.5 hover:bg-indigo-700 transition shadow-sm&#8221;                      &gt;                        + Log Exercise &amp;amp; Peri-Workout Nutrition Protocol                      &lt;\/button&gt;                    &lt;\/form&gt;                    {\/* Logged Workouts List *\/}                    &lt;div className=&#8221;space-y-2 max-h-60 overflow-y-auto&#8221;&gt;                      {activity.workouts.length === 0 ? (                        &lt;div className=&#8221;p-4 rounded-xl bg-slate-50 border border-dashed border-slate-300 text-center text-xs text-slate-500&#8243;&gt;                          No workouts logged today. Select your modality, duration, and peri-workout nutrition above to log a session.                        &lt;\/div&gt;                      ) : (                        activity.workouts.map(w =&gt; (                          &lt;div key={w.id} className=&#8221;p-3 rounded-xl bg-slate-50 border border-slate-200 flex items-center justify-between gap-2&#8243;&gt;                            &lt;div className=&#8221;space-y-0.5&#8243;&gt;                              &lt;div className=&#8221;font-bold text-slate-900 flex flex-wrap items-center gap-1.5&#8243;&gt;                                &lt;span&gt;{w.type} ({w.durationMin} mins)&lt;\/span&gt;                                &lt;span className=&#8221;px-2 py-0.5 rounded bg-indigo-50 text-indigo-700 border border-indigo-200 text-[10px]&#8221;&gt;                                  {w.intensity || &#8216;Moderate&#8217;}                                &lt;\/span&gt;                                &lt;span className=&#8221;px-2 py-0.5 rounded bg-teal-50 text-teal-700 border border-teal-200 text-[10px]&#8221;&gt;                                  {w.fastedState ? &#8216;Fasted Training&#8217; : &#8216;Fed State&#8217;}                                &lt;\/span&gt;                              &lt;\/div&gt;                              &lt;div className=&#8221;text-[11px] text-slate-600&#8243;&gt;                                &lt;strong&gt;Pre:&lt;\/strong&gt; {w.preWorkoutNutrition || &#8216;Water&#8217;} \u2022 &lt;strong&gt;Intra:&lt;\/strong&gt; {w.intraWorkoutHydration || &#8216;Mineral Water&#8217;}                              &lt;\/div&gt;                              &lt;div className=&#8221;text-[11px] text-teal-800 font-medium&#8221;&gt;                                &lt;strong&gt;Post-Fuel:&lt;\/strong&gt; {w.postWorkoutNutrition || &#8216;Not specified&#8217;}                              &lt;\/div&gt;                            &lt;\/div&gt;                            &lt;button                              type=&#8221;button&#8221;                              onClick={() =&gt; removeWorkoutFromLog(w.id)}                              className=&#8221;text-slate-400 hover:text-rose-600 p-1.5 shrink-0&#8243;                              title=&#8221;Delete workout&#8221;                            &gt;                              &lt;Icon name=&#8221;trash&#8221; className=&#8221;w-4 h-4&#8243; \/&gt;                            &lt;\/button&gt;                          &lt;\/div&gt;                        ))                      )}                    &lt;\/div&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              )}              {activeTab === &#8216;lifestyle&#8217; &amp;&amp; (                &lt;div className=&#8221;grid grid-cols-1 lg:grid-cols-3 gap-6 text-xs&#8221;&gt;                  {\/* Upgraded Sunlight, Photobiology &amp; Dermal Nitric Oxide Card with Flexible Skin Exposure Options *\/}                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3.5&#8243;&gt;                    &lt;div className=&#8221;flex items-center justify-between&#8221;&gt;                      &lt;h2 className=&#8221;text-base font-bold text-slate-900 flex items-center gap-2&#8243;&gt;                        &lt;Icon name=&#8221;sun&#8221; className=&#8221;w-5 h-5 text-amber-500&#8243; \/&gt;                        Sunlight, Vitamin D &amp;amp; Nitric Oxide                      &lt;\/h2&gt;                      &lt;StatusBadge                        status={toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60) &gt;= 20 ? &#8216;optimal&#8217; : &#8216;info&#8217;}                        label={`${toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}% Skin Exposed`}                      \/&gt;                    &lt;\/div&gt;                    &lt;div&gt;                      &lt;label className=&#8221;block font-semibold text-slate-700 mb-1&#8243;&gt;1. Solar Wavelength Window&lt;\/label&gt;                      &lt;select                        value={lifestyle.sunlightTimeOfDay}                        onChange={e =&gt; setLifestyle({ &#8230;lifestyle, sunlightTimeOfDay: e.target.value })}                        className=&#8221;w-full px-3 py-2 rounded-xl border border-slate-300 bg-white font-semibold&#8221;                      &gt;                        &lt;option value=&#8221;Morning (07:00 &#8211; 09:00 AM)&#8221;&gt;Morning (07:00 &#8211; 09:00 AM): Circadian SCN Anchor &amp;amp; Near-Infrared (NIR)&lt;\/option&gt;                        &lt;option value=&#8221;Solar Noon (11:00 AM &#8211; 01:30 PM)&#8221;&gt;Solar Noon (11:00 AM &#8211; 01:30 PM): Peak UVB Vitamin D3 Synthesis&lt;\/option&gt;                        &lt;option value=&#8221;Late Afternoon (04:00 &#8211; 05:30 PM)&#8221;&gt;Late Afternoon (04:00 &#8211; 05:30 PM): UVA Dermal Nitric Oxide (BP Drop)&lt;\/option&gt;                        &lt;option value=&#8221;Minimal \/ Indoors Behind Glass&#8221;&gt;Minimal \/ Indoors Behind Window Glass (Blocks UVB)&lt;\/option&gt;                      &lt;\/select&gt;                    &lt;\/div&gt;                    &lt;div&gt;                      &lt;div className=&#8221;flex justify-between font-semibold mb-1&#8243;&gt;                        &lt;span&gt;2. Direct Sunlight Duration&lt;\/span&gt;                        &lt;span className=&#8221;text-amber-600 font-bold&#8221;&gt;{toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 120)} mins&lt;\/span&gt;                      &lt;\/div&gt;                      &lt;input                        type=&#8221;range&#8221;                        min=&#8221;0&#8243;                        max=&#8221;60&#8243;                        step=&#8221;5&#8243;                        value={toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60)}                        onChange={e =&gt; setLifestyle({ &#8230;lifestyle, sunlightDurationMin: toSafeFloat(e.target.value, 0, 0, 60) })}                        className=&#8221;w-full accent-amber-500&#8243;                      \/&gt;                    &lt;\/div&gt;                    &lt;div&gt;                      &lt;div className=&#8221;flex justify-between font-semibold mb-1.5&#8243;&gt;                        &lt;span&gt;3. Skin Surface Area Exposed (Rule of Nines)&lt;\/span&gt;                        &lt;span className=&#8221;text-teal-700 font-bold&#8221;&gt;{toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}%&lt;\/span&gt;                      &lt;\/div&gt;                      &lt;div className=&#8221;grid grid-cols-2 sm:grid-cols-3 gap-1.5 mb-2&#8243;&gt;                        {[                          { pct: 10, label: &#8216;10% (Face &amp; Hands)&#8217; },                          { pct: 25, label: &#8216;25% (Short Sleeves)&#8217; },                          { pct: 40, label: &#8216;40% (T-Shirt &amp; Shorts)&#8217; },                          { pct: 60, label: &#8216;60% (Back\/Chest + Limbs)&#8217; },                          { pct: 75, label: &#8216;75% (Full Torso &amp; Legs)&#8217; },                          { pct: 85, label: &#8216;85%+ (Sunbathing)&#8217; }                        ].map(opt =&gt; (                          &lt;button                            key={opt.pct}                            type=&#8221;button&#8221;                            onClick={() =&gt; setLifestyle({ &#8230;lifestyle, skinExposurePct: opt.pct })}                            className={`px-2 py-1.5 rounded-xl border text-[11px] font-bold transition ${                              toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100) === opt.pct                                ? &#8216;bg-amber-500 text-white border-amber-500 shadow-sm&#8217;                                : &#8216;bg-slate-50 text-slate-700 border-slate-200 hover:bg-amber-50&#8217;                            }`}                          &gt;                            {opt.label}                          &lt;\/button&gt;                        ))}                      &lt;\/div&gt;                      &lt;input                        type=&#8221;range&#8221;                        min=&#8221;5&#8243;                        max=&#8221;90&#8243;                        step=&#8221;5&#8243;                        value={toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}                        onChange={e =&gt; setLifestyle({ &#8230;lifestyle, skinExposurePct: toSafeFloat(e.target.value, 25, 0, 100) })}                        className=&#8221;w-full accent-amber-500&#8243;                      \/&gt;                    &lt;\/div&gt;                    {\/* Photobiology Bio-Calculator Readout *\/}                    &lt;div className=&#8221;p-3 rounded-xl bg-amber-50\/80 border border-amber-200 text-[11px] text-amber-950 space-y-1&#8243;&gt;                      &lt;div className=&#8221;font-bold&#8221;&gt;Photobiology Effect (Dermal NO &amp;amp; Mitochondrial Melatonin):&lt;\/div&gt;                      &lt;p&gt;                        With &lt;strong&gt;{toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60)} mins&lt;\/strong&gt; at &lt;strong&gt;{toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}% skin exposure&lt;\/strong&gt;, UVA light liberates dermal &lt;em&gt;nitric oxide (NO)&lt;\/em&gt; stores into circulation (supporting natural arterial vasodilation), while Near-Infrared (NIR) photons penetrate deep into muscle mitochondria to reduce oxidative stress.                      &lt;\/p&gt;                    &lt;\/div&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3&#8243;&gt;                    &lt;h2 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;Sleep Duration &amp; Dawn Glucose&lt;\/h2&gt;                    &lt;div className=&#8221;flex justify-between font-semibold&#8221;&gt;                      &lt;span&gt;Total Sleep&lt;\/span&gt;                      &lt;span className=&#8221;text-indigo-600 font-bold&#8221;&gt;{toSafeFloat(lifestyle.sleepHours, 0, 0, 10)} hrs&lt;\/span&gt;                    &lt;\/div&gt;                    &lt;input                      type=&#8221;range&#8221;                      min=&#8221;0&#8243;                      max=&#8221;10&#8243;                      step=&#8221;0.5&#8243;                      value={toSafeFloat(lifestyle.sleepHours, 0, 0, 10)}                      onChange={e =&gt; setLifestyle({ &#8230;lifestyle, sleepHours: toSafeFloat(e.target.value, 0, 0, 10) })}                      className=&#8221;w-full accent-indigo-600&#8243;                    \/&gt;                    &lt;p className=&#8221;text-slate-600&#8243;&gt;                      Sleeping &amp;lt;6.5 hours acutely reduces insulin sensitivity by 24\u201330% the following morning.                    &lt;\/p&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3&#8243;&gt;                    &lt;h2 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;                      Cortisol &amp; Stress Scale &lt;Tooltip text={CLINICAL_TOOLTIPS.cortisol} \/&gt;                    &lt;\/h2&gt;                    &lt;div className=&#8221;flex justify-between font-semibold&#8221;&gt;                      &lt;span&gt;Daily Stress Level&lt;\/span&gt;                      &lt;span className=&#8221;text-rose-600 font-bold&#8221;&gt;{toSafeFloat(lifestyle.stressScore, 5, 1, 10)} \/ 10&lt;\/span&gt;                    &lt;\/div&gt;                    &lt;input                      type=&#8221;range&#8221;                      min=&#8221;1&#8243;                      max=&#8221;10&#8243;                      value={toSafeFloat(lifestyle.stressScore, 5, 1, 10)}                      onChange={e =&gt; setLifestyle({ &#8230;lifestyle, stressScore: toSafeFloat(e.target.value, 5, 1, 10) })}                      className=&#8221;w-full accent-rose-600&#8243;                    \/&gt;                    &lt;p className=&#8221;text-slate-600&#8243;&gt;                      Elevated cortisol triggers hepatic gluconeogenesis, raising blood sugar even during fasting.                    &lt;\/p&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              )}              {activeTab === &#8216;insights&#8217; &amp;&amp; (                &lt;div className=&#8221;grid grid-cols-1 md:grid-cols-2 gap-6 text-xs&#8221;&gt;                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-2.5&#8243;&gt;                    &lt;h3 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;1. Insulin Sensitivity &amp; Blood Sugar Action Guide&lt;\/h3&gt;                    &lt;p className=&#8221;text-slate-700&#8243;&gt;                      \u2022 &lt;strong&gt;HOMA-IR ({clinicalMetrics.homaIr !== null ? clinicalMetrics.homaIr : &#8216;Not Entered&#8217;}):&lt;\/strong&gt;{&#8216; &#8216;}                      {clinicalMetrics.homaIr === null                        ? &#8216;Enter your Fasting Insulin and Fasting Glucose in Tab 1 to calculate your HOMA-IR score.&#8217;                        : clinicalMetrics.homaIr &lt; 1.5                        ? &#8216;Optimal insulin sensitivity range maintained.&#8217;                        : &#8216;Elevated insulin resistance marker. Research shows eating fibrous vegetables first, cooling\/reheating cooked starches (RS3), and taking a 15-minute brisk walk after dinner help flatten post-meal glucose spikes.&#8217;}                    &lt;\/p&gt;                  &lt;\/div&gt;                  &lt;div className=&#8221;bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-2.5&#8243;&gt;                    &lt;h3 className=&#8221;text-base font-bold text-slate-900&#8243;&gt;2. Liver Wellness &amp; Healthy Lipid Habits&lt;\/h3&gt;                    &lt;p className=&#8221;text-slate-700&#8243;&gt;                      \u2022 &lt;strong&gt;Liver Enzymes (ALT {profile.alt ? `${profile.alt} U\/L` : &#8216;Not Entered&#8217;}) &amp; Cooking Fats:&lt;\/strong&gt;{&#8216; &#8216;}                      {nutrition.cookingFat === &#8216;refined-seed&#8217;                        ? &#8216;Consider replacing refined seed oils with traditional fats like A2 Ghee, Cold-Pressed Coconut Oil, or Extra Virgin Olive Oil to reduce dietary lipid oxidation.&#8217;                        : &#8216;Your selected cooking fat supports cellular membrane stability. Aim for ~550mg of daily dietary choline (from wholefoods like sprouted legumes, cruciferous vegetables, or eggs) to support healthy liver fat metabolism.&#8217;}                    &lt;\/p&gt;                  &lt;\/div&gt;                &lt;\/div&gt;              )}            &lt;\/main&gt;          &lt;\/div&gt;          {\/* Dedicated Personal PDF Summary Layout (Table-Based, High-Contrast &amp; Zero Overlap) *\/}          &lt;div className=&#8221;hidden print-only&#8221;&gt;            {activeSampleMode !== null &amp;&amp; (              &lt;div style={{ padding: &#8216;8px 12px&#8217;, marginBottom: &#8217;10px&#8217;, border: &#8216;2px solid #d97706&#8217;, backgroundColor: &#8216;#fffbeb&#8217;, color: &#8216;#92400e&#8217;, fontSize: &#8216;9.5pt&#8217;, fontWeight: 700 }}&gt;                SAMPLE DEMO REPORT: This PDF was generated while viewing the {activeSampleMode === &#8216;high-risk&#8217; ? &#8216;High-Risk Sample&#8217; : &#8216;Optimal Sample&#8217;} demo profile. To generate your personal report, click &#8220;Exit Sample&#8221; on screen and enter your own numbers.              &lt;\/div&gt;            )}            &lt;div style={{ borderBottom: &#8216;3px solid #0f766e&#8217;, paddingBottom: &#8217;10px&#8217;, marginBottom: &#8217;14px&#8217; }}&gt;              &lt;table style={{ width: &#8216;100%&#8217;, borderCollapse: &#8216;collapse&#8217; }}&gt;                &lt;tbody&gt;                  &lt;tr&gt;                    &lt;td style={{ border: &#8216;none&#8217;, padding: 0 }}&gt;                      &lt;div style={{ fontSize: &#8217;18pt&#8217;, fontWeight: 800, color: &#8216;#0f172a&#8217; }}&gt;                        MetabolicGuide \u2014 Personal Nutrition &amp;amp; Lifestyle Summary                      &lt;\/div&gt;                      &lt;div style={{ fontSize: &#8216;9.5pt&#8217;, color: &#8216;#475569&#8217;, marginTop: &#8216;2px&#8217; }}&gt;                        Generated via GroundReportIndia.org \u2022 Date: {new Date().toLocaleDateString()} \u2022 Educational Self-Tracking Report                      &lt;\/div&gt;                    &lt;\/td&gt;                    &lt;td style={{ border: &#8216;none&#8217;, padding: 0, textAlign: &#8216;right&#8217;, width: &#8216;170px&#8217; }}&gt;                      &lt;div style={{ fontSize: &#8216;8.5pt&#8217;, fontWeight: 700, textTransform: &#8216;uppercase&#8217;, color: &#8216;#0f766e&#8217; }}&gt;                        Metabolic Lifestyle Score                      &lt;\/div&gt;                      &lt;div style={{ fontSize: &#8217;20pt&#8217;, fontWeight: 900, color: &#8216;#0f172a&#8217; }}&gt;                        {clinicalMetrics.reversalScore} \/ 100                      &lt;\/div&gt;                    &lt;\/td&gt;                  &lt;\/tr&gt;                &lt;\/tbody&gt;              &lt;\/table&gt;            &lt;\/div&gt;            {\/* Section 1: Profile &amp; Anthropometrics *\/}            &lt;div className=&#8221;print-section-title&#8221;&gt;1. Personal Profile &amp;amp; Body Measurements&lt;\/div&gt;            &lt;table className=&#8221;print-table&#8221;&gt;              &lt;thead&gt;                &lt;tr&gt;                  &lt;th style={{ width: &#8216;25%&#8217; }}&gt;Profile Alias&lt;\/th&gt;                  &lt;th style={{ width: &#8216;25%&#8217; }}&gt;Age &amp;amp; Biological Sex&lt;\/th&gt;                  &lt;th style={{ width: &#8216;25%&#8217; }}&gt;Weight, Height &amp;amp; BMI&lt;\/th&gt;                  &lt;th style={{ width: &#8216;25%&#8217; }}&gt;Waist-to-Hip &amp;amp; WHtR&lt;\/th&gt;                &lt;\/tr&gt;              &lt;\/thead&gt;              &lt;tbody&gt;                &lt;tr&gt;                  &lt;td&gt;&lt;strong&gt;{toSafeStr(profile.alias, &#8216;Anonymous Reader&#8217;, 40) || &#8216;Anonymous Reader&#8217;}&lt;\/strong&gt;&lt;\/td&gt;                  &lt;td&gt;{profile.age || &#8216;\u2014&#8217;} yrs \/ {toSafeStr(profile.gender, &#8216;male&#8217;, 10).toUpperCase()}&lt;\/td&gt;                  &lt;td&gt;                    {profile.weightKg || &#8216;\u2014&#8217;} kg \u2022 {profile.heightCm || &#8216;\u2014&#8217;} cm&lt;br \/&gt;                    &lt;strong&gt;BMI: {clinicalMetrics.bmi !== null ? clinicalMetrics.bmi : &#8216;\u2014&#8217;}&lt;\/strong&gt;                  &lt;\/td&gt;                  &lt;td&gt;                    &lt;strong&gt;WHR: {clinicalMetrics.whr !== null ? clinicalMetrics.whr : &#8216;\u2014&#8217;}&lt;\/strong&gt; (Waist: {profile.waistCm || &#8216;\u2014&#8217;}cm)&lt;br \/&gt;                    &lt;strong&gt;WHtR: {clinicalMetrics.whtr !== null ? clinicalMetrics.whtr : &#8216;\u2014&#8217;}&lt;\/strong&gt; (Target: &amp;lt;0.50)                  &lt;\/td&gt;                &lt;\/tr&gt;              &lt;\/tbody&gt;            &lt;\/table&gt;            {\/* Section 2: Endocrine, Glycemic &amp; Hepatic Biomarkers *\/}            &lt;div className=&#8221;print-section-title&#8221;&gt;2. Endocrine, Blood Sugar, Lipid &amp;amp; Liver Biomarkers&lt;\/div&gt;            &lt;table className=&#8221;print-table&#8221;&gt;              &lt;thead&gt;                &lt;tr&gt;                  &lt;th style={{ width: &#8216;33%&#8217; }}&gt;HOMA-IR &amp;amp; Glycemic Control&lt;\/th&gt;                  &lt;th style={{ width: &#8216;33%&#8217; }}&gt;Lipids &amp;amp; TG:HDL Ratio&lt;\/th&gt;                  &lt;th style={{ width: &#8216;34%&#8217; }}&gt;Blood Pressure &amp;amp; Liver Enzymes&lt;\/th&gt;                &lt;\/tr&gt;              &lt;\/thead&gt;              &lt;tbody&gt;                &lt;tr&gt;                  &lt;td&gt;                    &lt;strong&gt;HOMA-IR: {clinicalMetrics.homaIr !== null ? `${clinicalMetrics.homaIr} (${clinicalMetrics.homaIr &lt; 1.5 ? &#8216;Optimal&#8217; : &#8216;Resistant&#8217;})` : &#8216;Not Entered&#8217;}&lt;\/strong&gt;&lt;br \/&gt;                    HbA1c: &lt;strong&gt;{clinicalMetrics.hba1cVal !== null ? `${clinicalMetrics.hba1cVal}%` : &#8216;\u2014&#8217;}&lt;\/strong&gt;&lt;br \/&gt;                    Fasting Insulin: {profile.fastingInsulin || &#8216;\u2014&#8217;} \u03bcIU\/mL&lt;br \/&gt;                    Fasting Glucose: {profile.fastingGlucose || &#8216;\u2014&#8217;} mg\/dL                  &lt;\/td&gt;                  &lt;td&gt;                    &lt;strong&gt;TG:HDL Ratio: {clinicalMetrics.tgHdlRatio !== null ? clinicalMetrics.tgHdlRatio : &#8216;\u2014&#8217;}&lt;\/strong&gt; (Target: &amp;lt;2.0)&lt;br \/&gt;                    Triglycerides: {profile.triglycerides || &#8216;\u2014&#8217;} mg\/dL&lt;br \/&gt;                    HDL Cholesterol: {profile.hdl || &#8216;\u2014&#8217;} mg\/dL&lt;br \/&gt;                    Dietary Preference: {toSafeStr(profile.dietPreference, &#8216;lacto&#8217;, 20).toUpperCase()}                  &lt;\/td&gt;                  &lt;td&gt;                    &lt;strong&gt;Blood Pressure: {clinicalMetrics.sysBP !== null &amp;&amp; clinicalMetrics.diaBP !== null ? `${clinicalMetrics.sysBP}\/${clinicalMetrics.diaBP} mmHg` : &#8216;\u2014&#8217;}&lt;\/strong&gt;&lt;br \/&gt;                    Liver ALT: &lt;strong&gt;{clinicalMetrics.altVal !== null ? `${clinicalMetrics.altVal} U\/L` : &#8216;\u2014&#8217;}&lt;\/strong&gt;&lt;br \/&gt;                    Liver AST: {clinicalMetrics.astVal !== null ? `${clinicalMetrics.astVal} U\/L` : &#8216;\u2014&#8217;}&lt;br \/&gt;                    Liver GGT: {toValidNum(profile.ggt) !== null ? `${toValidNum(profile.ggt)} U\/L` : &#8216;\u2014&#8217;}                  &lt;\/td&gt;                &lt;\/tr&gt;              &lt;\/tbody&gt;            &lt;\/table&gt;            {\/* Section 3: Daily Nutrition, Sequencing &amp; Hydration *\/}            &lt;div className=&#8221;print-section-title&#8221;&gt;3. Nutrition, Meal Sequencing, Resistant Starch &amp;amp; Hydration&lt;\/div&gt;            &lt;table className=&#8221;print-table&#8221;&gt;              &lt;thead&gt;                &lt;tr&gt;                  &lt;th style={{ width: &#8216;50%&#8217; }}&gt;Calorie, Macronutrient &amp;amp; Mineral Intake&lt;\/th&gt;                  &lt;th style={{ width: &#8216;50%&#8217; }}&gt;Meal Sequencing, Cooking Fats &amp;amp; Hydration&lt;\/th&gt;                &lt;\/tr&gt;              &lt;\/thead&gt;              &lt;tbody&gt;                &lt;tr&gt;                  &lt;td&gt;                    Calories Logged: &lt;strong&gt;{nutritionTotals.cal} kcal&lt;\/strong&gt; (Target: {clinicalMetrics.targetCalories &gt; 0 ? `${clinicalMetrics.targetCalories} kcal` : &#8216;\u2014&#8217;})&lt;br \/&gt;                    Protein &amp;amp; Leucine: &lt;strong&gt;{nutritionTotals.pro}g Protein&lt;\/strong&gt; ({nutritionTotals.leucine}g Leucine)&lt;br \/&gt;                    Carbohydrates: &lt;strong&gt;{nutritionTotals.netCarbs}g Net Carbs&lt;\/strong&gt; ({nutritionTotals.fiber}g Fiber)&lt;br \/&gt;                    Total Fat &amp;amp; Omega-3: &lt;strong&gt;{nutritionTotals.fat}g Fat&lt;\/strong&gt; (SFA: {nutritionTotals.sfa}g, MUFA: {nutritionTotals.mufa}g, PUFA: {nutritionTotals.pufa}g, Omega-3: {nutritionTotals.omega3}g)&lt;br \/&gt;                    Minerals (%DV): Mg: &lt;strong&gt;{nutritionTotals.mg}mg&lt;\/strong&gt; \u2022 K: &lt;strong&gt;{nutritionTotals.k}mg&lt;\/strong&gt; \u2022 Ca: &lt;strong&gt;{nutritionTotals.ca}mg&lt;\/strong&gt; \u2022 Fe: &lt;strong&gt;{nutritionTotals.fe}mg&lt;\/strong&gt; \u2022 Zn: &lt;strong&gt;{nutritionTotals.zn}mg&lt;\/strong&gt;&lt;br \/&gt;                    Vitamins &amp;amp; Choline: Choline: &lt;strong&gt;{nutritionTotals.choline}mg&lt;\/strong&gt; \u2022 Vit C: &lt;strong&gt;{nutritionTotals.vitC}mg&lt;\/strong&gt; \u2022 Folate: &lt;strong&gt;{nutritionTotals.folate}mcg&lt;\/strong&gt; \u2022 Vit B12: &lt;strong&gt;{nutritionTotals.b12}mcg&lt;\/strong&gt;                  &lt;\/td&gt;                  &lt;td&gt;                    Meal Sequence: &lt;strong&gt;{nutrition.mealSequence}&lt;\/strong&gt;&lt;br \/&gt;                    Starch Preparation (RS3): &lt;strong&gt;{nutrition.starchPrepMethod}&lt;\/strong&gt;&lt;br \/&gt;                    Primary Cooking Fat: &lt;strong&gt;{nutrition.cookingFat}&lt;\/strong&gt;&lt;br \/&gt;                    Daily Snacking Frequency: &lt;strong&gt;{nutrition.snackingCount} snacks\/day&lt;\/strong&gt;&lt;br \/&gt;                    Total Hydration Logged: &lt;strong&gt;{nutritionTotals.totalWaterMl} ml ({(nutritionTotals.totalWaterMl \/ 1000).toFixed(2)} L)&lt;\/strong&gt;&lt;br \/&gt;                    Logged Foods: &lt;strong&gt;{nutrition.loggedFoods.length &gt; 0 ? nutrition.loggedFoods.map(f =&gt; f.name).join(&#8216;; &#8216;) : &#8216;None logged&#8217;}&lt;\/strong&gt;                  &lt;\/td&gt;                &lt;\/tr&gt;              &lt;\/tbody&gt;            &lt;\/table&gt;            {\/* Section 4: Fasting, Movement &amp; Circadian Lifestyle *\/}            &lt;div className=&#8221;print-section-title&#8221;&gt;4. Fasting Protocol, Post-Meal Movement &amp;amp; Circadian Lifestyle&lt;\/div&gt;            &lt;table className=&#8221;print-table&#8221;&gt;              &lt;thead&gt;                &lt;tr&gt;                  &lt;th style={{ width: &#8216;50%&#8217; }}&gt;Fasting &amp;amp; Circadian Eating Window&lt;\/th&gt;                  &lt;th style={{ width: &#8216;50%&#8217; }}&gt;Post-Meal Walks, Sunlight, Sleep &amp;amp; Stress&lt;\/th&gt;                &lt;\/tr&gt;              &lt;\/thead&gt;              &lt;tbody&gt;                &lt;tr&gt;                  &lt;td&gt;                    Active Fasting Regimen: &lt;strong&gt;{fasting.protocol}&lt;\/strong&gt; ({fasting.fastingType})&lt;br \/&gt;                    Current Fast Duration: &lt;strong&gt;{toSafeFloat(fasting.currentFastHours, 0, 0, 48)} hours&lt;\/strong&gt;&lt;br \/&gt;                    Distinct Meals Per Day: &lt;strong&gt;{fasting.mealsPerDay} meal(s)\/day&lt;\/strong&gt;&lt;br \/&gt;                    Pre-Sleep Digestion Gap: &lt;strong&gt;{clinicalMetrics.eveningGapHours !== null ? `${clinicalMetrics.eveningGapHours} hours` : &#8216;Not Entered&#8217;}&lt;\/strong&gt; (Target: 3+ hours)                  &lt;\/td&gt;                  &lt;td&gt;                    15m+ Post-Meal Walks: Breakfast: &lt;strong&gt;{activity?.postMealWalks?.breakfastWalk ? `Yes (${activity.postMealWalks.breakfastWalkMins || 15}m, ${activity.postMealWalks.breakfastWalkPace || &#8216;normal&#8217;})` : &#8216;No&#8217;}&lt;\/strong&gt; \u2022 Lunch: &lt;strong&gt;{activity?.postMealWalks?.lunchWalk ? `Yes (${activity.postMealWalks.lunchWalkMins || 20}m, ${activity.postMealWalks.lunchWalkPace || &#8216;brisk&#8217;})` : &#8216;No&#8217;}&lt;\/strong&gt; \u2022 Dinner: &lt;strong&gt;{activity?.postMealWalks?.dinnerWalk ? `Yes (${activity.postMealWalks.dinnerWalkMins || 30}m, ${activity.postMealWalks.dinnerWalkPace || &#8216;normal&#8217;})` : &#8216;No&#8217;}&lt;\/strong&gt;&lt;br \/&gt;                    Workouts Logged Today: &lt;strong&gt;{activity.workouts.length} session(s)&lt;\/strong&gt; (Daily Steps: {toSafeFloat(activity.dailySteps, 0, 0, 100000).toLocaleString()})&lt;br \/&gt;                    Sunlight Exposure: &lt;strong&gt;{toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60)} mins&lt;\/strong&gt; at &lt;strong&gt;{toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}% skin exposed&lt;\/strong&gt; ({lifestyle.sunlightTimeOfDay})&lt;br \/&gt;                    Sleep &amp;amp; Stress: &lt;strong&gt;{toSafeFloat(lifestyle.sleepHours, 0, 0, 10)} hrs sleep&lt;\/strong&gt; \u2022 Stress Score: &lt;strong&gt;{toSafeFloat(lifestyle.stressScore, 5, 1, 10)} \/ 10&lt;\/strong&gt;                  &lt;\/td&gt;                &lt;\/tr&gt;              &lt;\/tbody&gt;            &lt;\/table&gt;            {\/* Section 5: Science-Based Action Guide *\/}            &lt;div className=&#8221;print-section-title&#8221;&gt;5. Personalized Science-Based Action Guide&lt;\/div&gt;            &lt;table className=&#8221;print-table&#8221;&gt;              &lt;tbody&gt;                &lt;tr&gt;                  &lt;td&gt;                    &lt;strong&gt;\u2022 Insulin Sensitivity &amp;amp; Glycemic Control:&lt;\/strong&gt;{&#8216; &#8216;}                    {clinicalMetrics.homaIr !== null &amp;&amp; clinicalMetrics.homaIr &gt;= 1.5                      ? `Your HOMA-IR (${clinicalMetrics.homaIr}) indicates insulin resistance. Prioritize eating fiber\/vegetables and protein before starches, cool cooked rice\/potatoes for 12-24h to form Resistant Starch (RS3), finish meals with whole lemon (skin, seeds &amp; juice), and walk briskly for 15 minutes after dinner.`                      : &#8216;Maintain post-meal glucose stability by sequencing fibrous vegetables and protein first, avoiding between-meal grazing, and walking 15 minutes after main meals.&#8217;}                    &lt;br \/&gt;&lt;br \/&gt;                    &lt;strong&gt;\u2022 Liver Wellness, Cooking Lipids &amp;amp; Circadian Rhythm:&lt;\/strong&gt;{&#8216; &#8216;}                    {nutrition.cookingFat === &#8216;refined-seed&#8217;                      ? &#8216;Replace refined seed oils with traditional stable fats (A2 Ghee, Cold-Pressed Coconut Oil, or Extra Virgin Olive Oil) to reduce hepatic lipid peroxidation, and aim for a 3+ hour gap between your last meal and bedtime.&#8217;                      : &#8216;Continue using stable cooking fats (A2 Ghee \/ Cold-Pressed oils), aim for ~550mg of daily dietary choline from whole foods, and maintain at least a 3-hour digestion gap before sleep.&#8217;}                  &lt;\/td&gt;                &lt;\/tr&gt;              &lt;\/tbody&gt;            &lt;\/table&gt;            {\/* Print Educational Disclaimer *\/}            &lt;div style={{ padding: &#8217;10px 12px&#8217;, border: &#8216;1px solid #94a3b8&#8217;, backgroundColor: &#8216;#f8fafc&#8217;, fontSize: &#8216;8.5pt&#8217;, color: &#8216;#334155&#8242;, marginTop: &#8217;10px&#8217; }}&gt;              &lt;strong&gt;Educational &amp;amp; Informational Disclaimer:&lt;\/strong&gt; MetabolicGuide on GroundReportIndia.org is an educational nutrition and lifestyle self-tracking tool based on peer-reviewed metabolic research. It does not provide medical advice, clinical diagnosis, or medical prescriptions. Always consult a qualified physician or healthcare provider before modifying medications, fasting regimens, or diet plans.            &lt;\/div&gt;          &lt;\/div&gt;          {\/* Screen Footer Disclaimer *\/}          &lt;footer className=&#8221;no-print max-w-7xl mx-auto px-4 sm:px-6 pt-6 pb-4&#8243;&gt;            &lt;div className=&#8221;bg-white rounded-2xl p-4 border border-slate-200 text-[11px] text-slate-500 leading-relaxed flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3&#8243;&gt;              &lt;div&gt;                &lt;strong className=&#8221;text-slate-700&#8243;&gt;Educational &amp; Informational Disclaimer (GroundReportIndia.org):&lt;\/strong&gt;{&#8216; &#8216;}                MetabolicGuide is an educational self-tracking wellness guide and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult your physician before changing your diet, exercise, or medication routine.              &lt;\/div&gt;              &lt;div className=&#8221;shrink-0 font-semibold text-teal-700&#8243;&gt;                Privacy-First Cloud &amp; Local Vault              &lt;\/div&gt;            &lt;\/div&gt;          &lt;\/footer&gt;        &lt;\/div&gt;      );    }    const rootElement = document.getElementById(&#8216;root&#8217;);    const root = ReactDOM.createRoot(rootElement);    root.render(      &lt;ClinicalErrorBoundary&gt;        &lt;App \/&gt;      &lt;\/ClinicalErrorBoundary&gt;    );  [\/tcb-script]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MetabolicGuide | Science-Based Nutrition &amp; Metabolic Lifestyle Tracker [tcb-script src=&#8221;https:\/\/cdn.tailwindcss.com&#8221;][\/tcb-script] [tcb-script src=&#8221;https:\/\/unpkg.com\/react@18\/umd\/react.production.min.js&#8221; crossorigin=&#8221;&#8221;][\/tcb-script] [tcb-script src=&#8221;https:\/\/unpkg.com\/react-dom@18\/umd\/react-dom.production.min.js&#8221; crossorigin=&#8221;&#8221;][\/tcb-script] [tcb-script src=&#8221;https:\/\/unpkg.com\/@babel\/standalone\/babel.min.js&#8221;][\/tcb-script] [tcb-script type=&#8221;module&#8221;] import { initializeApp } from &#8220;https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-app.js&#8221;; import { getAuth, signInAnonymously, signInWithCustomToken, onAuthStateChanged } from &#8220;https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-auth.js&#8221;; import { getFirestore, doc, setDoc, getDoc, deleteDoc, onSnapshot } from &#8220;https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-firestore.js&#8221;; \/\/ ============================================================================ \/\/ STEP FOR GROUNDREPORTINDIA.ORG: \/\/ Paste your [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","tve_updated_post":"<div class=\"thrv_wrapper thrv_custom_html_shortcode\">\n\n\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>MetabolicGuide | Science-Based Nutrition &amp; Metabolic Lifestyle Tracker<\/title>\n  <!-- Tailwind CSS CDN -->\n  <code class=\"tve_js_placeholder\">[tcb-script src=\"https:\/\/cdn.tailwindcss.com\"][\/tcb-script]<\/code>\n  <!-- Google Fonts: Inter -->\n  <link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\">\n  <link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin=\"\">\n  <link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700;800&amp;display=swap\" rel=\"stylesheet\">\n  <!-- React 18 & Babel Standalone for Single-File WordPress Execution -->\n  <code class=\"tve_js_placeholder\">[tcb-script src=\"https:\/\/unpkg.com\/react@18\/umd\/react.production.min.js\" crossorigin=\"\"][\/tcb-script]<\/code>\n  <code class=\"tve_js_placeholder\">[tcb-script src=\"https:\/\/unpkg.com\/react-dom@18\/umd\/react-dom.production.min.js\" crossorigin=\"\"][\/tcb-script]<\/code>\n  <code class=\"tve_js_placeholder\">[tcb-script src=\"https:\/\/unpkg.com\/@babel\/standalone\/babel.min.js\"][\/tcb-script]<\/code>\n  <style>\n    body {\n      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n    }\n    \/* Custom subtle scrollbars for food logs *\/\n    ::-webkit-scrollbar {\n      width: 6px;\n      height: 6px;\n    }\n    ::-webkit-scrollbar-track {\n      background: #f1f5f9;\n      border-radius: 8px;\n    }\n    ::-webkit-scrollbar-thumb {\n      background: #cbd5e1;\n      border-radius: 8px;\n    }\n    ::-webkit-scrollbar-thumb:hover {\n      background: #94a3b8;\n    }\n    \/* Clinical PDF Print Stylesheet - Table-based, Non-Overlapping & High Contrast *\/\n    @media print {\n      @page {\n        size: A4 portrait;\n        margin: 10mm;\n      }\n      html, body {\n        background: #ffffff !important;\n        color: #000000 !important;\n        font-size: 11pt !important;\n        line-height: 1.45 !important;\n        -webkit-print-color-adjust: exact !important;\n        print-color-adjust: exact !important;\n        overflow: visible !important;\n        height: auto !important;\n      }\n      .no-print {\n        display: none !important;\n      }\n      .print-only {\n        display: block !important;\n        width: 100% !important;\n        color: #000000 !important;\n        background: #ffffff !important;\n      }\n      .print-table {\n        width: 100% !important;\n        border-collapse: collapse !important;\n        margin-bottom: 14px !important;\n        page-break-inside: avoid !important;\n      }\n      .print-table th,\n      .print-table td {\n        border: 1px solid #cbd5e1 !important;\n        padding: 8px 10px !important;\n        text-align: left !important;\n        vertical-align: top !important;\n        color: #0f172a !important;\n        background: #ffffff !important;\n        word-wrap: break-word !important;\n      }\n      .print-table th {\n        background: #f1f5f9 !important;\n        font-weight: 700 !important;\n        font-size: 9.5pt !important;\n        text-transform: uppercase !important;\n        color: #0f766e !important;\n      }\n      .print-section-title {\n        font-size: 11pt !important;\n        font-weight: 800 !important;\n        color: #0f766e !important;\n        text-transform: uppercase !important;\n        margin: 12px 0 6px 0 !important;\n        border-bottom: 2px solid #0f766e !important;\n        padding-bottom: 3px !important;\n      }\n    }\n  <\/style>\n\n\n  <div id=\"root\"><\/div>\n\n  <code class=\"tve_js_placeholder\">[tcb-script type=\"module\"]\n    import { initializeApp } from \"https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-app.js\";\n    import {\n      getAuth,\n      signInAnonymously,\n      signInWithCustomToken,\n      onAuthStateChanged\n    } from \"https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-auth.js\";\n    import {\n      getFirestore,\n      doc,\n      setDoc,\n      getDoc,\n      deleteDoc,\n      onSnapshot\n    } from \"https:\/\/www.gstatic.com\/firebasejs\/11.6.1\/firebase-firestore.js\";\n\n    \/\/ ============================================================================\n    \/\/ STEP FOR GROUNDREPORTINDIA.ORG:\n    \/\/ Paste your 6 Firebase configuration keys inside CUSTOM_FIREBASE_CONFIG below\n    \/\/ once you create your free project at https:\/\/console.firebase.google.com\/\n    \/\/ ============================================================================\n    const CUSTOM_FIREBASE_CONFIG = {\n      apiKey: \"AIzaSyBLtqWwDVpMcZiDjeCWHUpmjVSQQO1Tpj8\",\n      authDomain: \"metabolicrx-gri.firebaseapp.com\",\n      projectId: \"metabolicrx-gri\",\n      storageBucket: \"metabolicrx-gri.firebasestorage.app\",\n      messagingSenderId: \"540547307341\",\n      appId: \"1:540547307341:web:4d616282c8e844dbc6c904\"\n    };\n\n    \/\/ Automatic Environment Detection (Works here in Preview AND on groundreportindia.org)\n    let activeConfig = null;\n    let usingCustomProject = false;\n    if (CUSTOM_FIREBASE_CONFIG.apiKey &amp;&amp; CUSTOM_FIREBASE_CONFIG.projectId) {\n      activeConfig = CUSTOM_FIREBASE_CONFIG;\n      usingCustomProject = true;\n    } else if (typeof __firebase_config !== \"undefined\" &amp;&amp; __firebase_config) {\n      try {\n        activeConfig = JSON.parse(__firebase_config);\n      } catch (e) {\n        console.error(\"Failed to parse environment Firebase config:\", e);\n      }\n    }\n\n    const appId = usingCustomProject\n      ? \"metabolicrx-gri-prod\"\n      : (typeof __app_id !== \"undefined\" &amp;&amp; __app_id ? __app_id : \"metabolicrx-gri-prod\");\n\n    window.__METABOLIC_CLOUD__ = {\n      isConfigured: Boolean(activeConfig &amp;&amp; activeConfig.apiKey),\n      usingCustomProject,\n      appId,\n      initializeApp,\n      getAuth,\n      signInAnonymously,\n      signInWithCustomToken,\n      onAuthStateChanged,\n      getFirestore,\n      doc,\n      setDoc,\n      getDoc,\n      deleteDoc,\n      onSnapshot,\n      activeConfig,\n      cachedApp: null\n    };\n\n    window.__METABOLIC_CLOUD_READY__ = true;\n    window.dispatchEvent(new Event(\"metabolic-cloud-ready\"));\n  [\/tcb-script]<\/code>\n\n  <code class=\"tve_js_placeholder\">[tcb-script type=\"text\/babel\"]\n    const { useState, useEffect, useMemo, useRef } = React;\n\n    \/\/ Safe numeric coercion helper: prevents NaN, Infinity, booleans, arrays, or empty-string comparison bugs\n    const toValidNum = (val) =&gt; {\n      if (val === '' || val === null || typeof val === 'undefined' || typeof val === 'boolean' || typeof val === 'object') return null;\n      const n = Number(val);\n      return Number.isFinite(n) &amp;&amp; n &gt; 0 ? n : null;\n    };\n\n    \/\/ Safe non-negative numeric coercion with fallback (for sliders, counts, and macro totals)\n    const toSafeFloat = (val, fallback = 0, min = 0, max = 100000) =&gt; {\n      if (val === '' || val === null || typeof val === 'undefined' || typeof val === 'boolean' || typeof val === 'object') return fallback;\n      const n = Number(val);\n      if (!Number.isFinite(n)) return fallback;\n      return Math.min(max, Math.max(min, n));\n    };\n\n    \/\/ Safe string coercion helper with max length cap\n    const toSafeStr = (val, fallback = '', maxLen = 120) =&gt; {\n      if (val === null || typeof val === 'undefined' || typeof val === 'object' || typeof val === 'boolean') return fallback;\n      return String(val).slice(0, maxLen);\n    };\n\n    \/\/ Safe input sanitizer for numeric fields (allows smooth decimal\/intermediate typing while blocking negatives, NaN &amp; scientific notation)\n    const parseInputNum = (rawVal, min = 0, max = 2000) =&gt; {\n      if (rawVal === '' || rawVal === null || typeof rawVal === 'undefined' || typeof rawVal === 'boolean' || typeof rawVal === 'object') return '';\n      const str = String(rawVal).trim();\n      if (str === '' || str.startsWith('-') || \/[eE+]\/.test(str)) return '';\n      if (!\/^\\d*\\.?\\d*$\/.test(str)) return '';\n      const n = Number(str);\n      if (!Number.isFinite(n) || n &lt; 0) return '';\n      if (n &gt; max) return String(max);\n      return str;\n    };\n\n    \/\/ Single centralized food scaling helper (eliminates duplicate scaling logic between Inspector and Food Logger)\n    const scaleFoodItem = (baseFood, servings = 1) =&gt; {\n      const mult = toSafeFloat(servings, 1, 0.25, 10);\n      const scale = (val, dec = 1) =&gt; +((Number(val) || 0) * mult).toFixed(dec);\n      const cal = Math.round((baseFood.cal || 0) * mult);\n      const pro = scale(baseFood.pro, 1);\n      const carb = scale(baseFood.carb, 1);\n      const fiber = scale(baseFood.fiber, 1);\n      const netCarb = Math.max(0, +(carb - fiber).toFixed(1));\n      return {\n        ...baseFood,\n        mult,\n        servings: mult,\n        cal,\n        pro,\n        carb,\n        fiber,\n        netCarb,\n        fat: scale(baseFood.fat, 1),\n        sfa: scale(baseFood.sfa, 1),\n        mufa: scale(baseFood.mufa, 1),\n        pufa: scale(baseFood.pufa, 1),\n        leucine: scale(baseFood.leucine, 2),\n        omega3: scale(baseFood.omega3, 2),\n        mg: Math.round((baseFood.mg || 0) * mult),\n        k: Math.round((baseFood.k || 0) * mult),\n        ca: Math.round((baseFood.ca || 0) * mult),\n        fe: scale(baseFood.fe, 1),\n        zn: scale(baseFood.zn, 1),\n        choline: Math.round((baseFood.choline || 0) * mult),\n        vitC: Math.round((baseFood.vitC || 0) * mult),\n        vitA: Math.round((baseFood.vitA || 0) * mult),\n        vitD: Math.round((baseFood.vitD || 0) * mult),\n        b12: scale(baseFood.b12, 1),\n        folate: Math.round((baseFood.folate || 0) * mult),\n        glycemicLoad: Math.round((baseFood.glycemicLoad || 0) * mult)\n      };\n    };\n\n    \/\/ Clean numeric formatter for %DV and nutrient deficits (avoids trailing .00 on integers)\n    const formatNutrientVal = (val) =&gt; {\n      const n = Number(val);\n      if (!Number.isFinite(n)) return '0';\n      return Number.isInteger(n) ? String(n) : String(+n.toFixed(2));\n    };\n\n    \/\/ Deep clone helper for safe state snapshotting (prevents nested object\/array reference mutation)\n    const deepCloneState = (obj) =&gt; {\n      try {\n        return JSON.parse(JSON.stringify(obj));\n      } catch (e) {\n        return obj;\n      }\n    };\n\n    \/\/ Safe localStorage fallback helpers (so users never lose data if offline or if adblockers block Firebase)\n    const LOCAL_BACKUP_KEY = 'metabolicrx_gri_local_vault_v1';\n    const saveLocalBackup = (dataObj) =&gt; {\n      try {\n        window.localStorage.setItem(LOCAL_BACKUP_KEY, JSON.stringify(dataObj));\n      } catch (e) {\n        \/\/ Ignore Safari private browsing \/ storage quota errors\n      }\n    };\n    const loadLocalBackup = () =&gt; {\n      try {\n        const raw = window.localStorage.getItem(LOCAL_BACKUP_KEY);\n        return raw ? JSON.parse(raw) : null;\n      } catch (e) {\n        return null;\n      }\n    };\n    const clearLocalBackup = () =&gt; {\n      try {\n        window.localStorage.removeItem(LOCAL_BACKUP_KEY);\n      } catch (e) {\n        \/\/ Ignore storage errors\n      }\n    };\n\n    \/\/ Unique ID generator to prevent duplicate React keys on rapid clicks\n    let uidCounter = 0;\n    const makeUniqueId = () =&gt; `${Date.now()}-${++uidCounter}`;\n\n    \/\/ React Error Boundary so any unexpected browser\/DOM extension error never white-screens the page\n    class ClinicalErrorBoundary extends React.Component {\n      constructor(props) {\n        super(props);\n        this.state = { hasError: false, errorMsg: '' };\n      }\n      static getDerivedStateFromError(error) {\n        return { hasError: true, errorMsg: error?.message || 'Unexpected rendering error' };\n      }\n      componentDidCatch(error, info) {\n        console.error(\"MetabolicGuide Boundary Caught:\", error, info);\n      }\n      render() {\n        if (this.state.hasError) {\n          return (\n            &lt;div className=\"min-h-screen bg-slate-50 flex items-center justify-center p-6\"&gt;\n              &lt;div className=\"bg-white rounded-2xl max-w-md w-full p-6 shadow-xl border border-rose-200 space-y-4 text-center\"&gt;\n                &lt;div className=\"text-base font-bold text-slate-900\"&gt;Display Recovery Mode&lt;\/div&gt;\n                &lt;p className=\"text-xs text-slate-600\"&gt;\n                  A browser extension or corrupted input interrupted the view ({this.state.errorMsg}).\n                &lt;\/p&gt;\n                &lt;button\n                  type=\"button\"\n                  onClick={() =&gt; this.setState({ hasError: false, errorMsg: '' })}\n                  className=\"px-4 py-2 rounded-xl bg-teal-600 text-white text-xs font-semibold hover:bg-teal-700\"\n                &gt;\n                  Reload MetabolicGuide Dashboard\n                &lt;\/button&gt;\n              &lt;\/div&gt;\n            &lt;\/div&gt;\n          );\n        }\n        return this.props.children;\n      }\n    }\n\n    \/\/ Clean, zero-dependency inline SVG icons\n    const Icon = ({ name, className = \"w-5 h-5\" }) =&gt; {\n      const paths = {\n        activity: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M22 12h-4l-3 9L9 3l-3 9H2\" \/&gt;,\n        heart: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 000-7.78z\" \/&gt;,\n        droplet: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M12 2.69l5.66 5.66a8 8 0 11-11.31 0z\" \/&gt;,\n        sun: (\n          &lt;&gt;\n            &lt;circle cx=\"12\" cy=\"12\" r=\"4\" strokeWidth=\"2\" \/&gt;\n            &lt;path strokeLinecap=\"round\" strokeWidth=\"2\" d=\"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41\" \/&gt;\n          &lt;\/&gt;\n        ),\n        moon: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z\" \/&gt;,\n        utensils: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 002-2V2M7 2v20m14-7V2a5 5 0 00-5 5v6c0 1.1.9 2 2 2h3zm0 0v7\" \/&gt;,\n        clock: (\n          &lt;&gt;\n            &lt;circle cx=\"12\" cy=\"12\" r=\"10\" strokeWidth=\"2\" \/&gt;\n            &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M12 6v6l4 2\" \/&gt;\n          &lt;\/&gt;\n        ),\n        trendingDown: (\n          &lt;&gt;\n            &lt;polyline strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" points=\"23 18 13.5 8.5 8.5 13.5 1 6\" \/&gt;\n            &lt;polyline strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" points=\"17 18 23 18 23 12\" \/&gt;\n          &lt;\/&gt;\n        ),\n        info: (\n          &lt;&gt;\n            &lt;circle cx=\"12\" cy=\"12\" r=\"10\" strokeWidth=\"2\" \/&gt;\n            &lt;line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\" strokeWidth=\"2\" strokeLinecap=\"round\" \/&gt;\n            &lt;line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\" strokeWidth=\"2\" strokeLinecap=\"round\" \/&gt;\n          &lt;\/&gt;\n        ),\n        alert: (\n          &lt;&gt;\n            &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z\" \/&gt;\n            &lt;line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" strokeWidth=\"2\" strokeLinecap=\"round\" \/&gt;\n            &lt;line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\" strokeWidth=\"2\" strokeLinecap=\"round\" \/&gt;\n          &lt;\/&gt;\n        ),\n        check: (\n          &lt;&gt;\n            &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M22 11.08V12a10 10 0 11-5.93-9.14\" \/&gt;\n            &lt;polyline strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" points=\"22 4 12 14.01 9 11.01\" \/&gt;\n          &lt;\/&gt;\n        ),\n        flame: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8.5 14.5A2.5 2.5 0 0011 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 11-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 002.5 2.5z\" \/&gt;,\n        shield: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\" \/&gt;,\n        brain: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M9.5 2A2.5 2.5 0 0112 4.5v15a2.5 2.5 0 01-4.96.44 2.5 2.5 0 01-2.96-3.08 3 3 0 01-.34-5.58 2.5 2.5 0 011.32-4.24 2.5 2.5 0 013.44-2.04zM14.5 2A2.5 2.5 0 0012 4.5v15a2.5 2.5 0 004.96.44 2.5 2.5 0 002.96-3.08 3 3 0 00.34-5.58 2.5 2.5 0 00-1.32-4.24 2.5 2.5 0 00-3.44-2.04z\" \/&gt;,\n        plus: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M12 5v14M5 12h14\" \/&gt;,\n        trash: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2\" \/&gt;,\n        cloud: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M17.5 19H9a7 7 0 116.71-9h1.79a4.5 4.5 0 110 9z\" \/&gt;,\n        download: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3\" \/&gt;,\n        printer: (\n          &lt;&gt;\n            &lt;polyline strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" points=\"6 9 6 2 18 2 18 9\" \/&gt;\n            &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2\" \/&gt;\n            &lt;rect x=\"6\" y=\"14\" width=\"12\" height=\"8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" \/&gt;\n          &lt;\/&gt;\n        ),\n        upload: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12\" \/&gt;,\n        footprints: &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 11-4 0zm10 4v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C8.63 6 8 7.8 8 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 104 0z\" \/&gt;,\n        userCheck: (\n          &lt;&gt;\n            &lt;path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M16 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2\" \/&gt;\n            &lt;circle cx=\"8.5\" cy=\"7\" r=\"4\" strokeWidth=\"2\" \/&gt;\n            &lt;polyline strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" points=\"17 11 19 13 23 9\" \/&gt;\n          &lt;\/&gt;\n        )\n      };\n      return (\n        &lt;svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" className={className}&gt;\n          {paths[name] || paths.activity}\n        &lt;\/svg&gt;\n      );\n    };\n\n    const CLINICAL_TOOLTIPS = {\n      homaIr: \"HOMA-IR (Homeostatic Model Assessment for Insulin Resistance) is calculated as (Fasting Insulin \u00d7 Fasting Glucose) \/ 405. Optimal is &lt; 1.0. Above 1.9 indicates early insulin resistance; &gt; 2.9 indicates significant resistance.\",\n      whr: \"Waist-to-Hip Ratio (WHR) is a superior predictor of visceral adiposity and cardiovascular risk compared to BMI. WHO cutoffs for abdominal obesity are &gt;0.90 for men and &gt;0.85 for women.\",\n      mealSequencing: \"Consuming dietary fiber (vegetables) or protein\/fat first, eating starches\/sugars later, and finishing with whole lemon (skin, seeds, and juice\u2014rich in citric acid, pectin fiber, and citrus polyphenols like eriocitrin &amp; hesperidin) slows gastric emptying, inhibits salivary\/pancreatic alpha-amylase, and reduces postprandial glucose spikes by up to 73%.\",\n      resistantStarch: \"Cooking and cooling starches (rice, potatoes, oats) for 12-24 hours at 4\u00b0C triggers 'retrogradation', converting digestible amylose into Type 3 Resistant Starch (RS3), which bypasses small intestine digestion and feeds butyrate-producing colonic bacteria.\",\n      cookingOils: \"Industrial seed oils high in linoleic acid (soybean, sunflower, corn, safflower) are prone to lipid peroxidation when heated, generating 4-HNE which induces mitochondrial oxidative stress and hepatic insulin resistance. Prefer A2 Ghee, Butter, Coconut Oil, or Extra Virgin Olive Oil.\",\n      grazing: \"Every meal or caloric snack triggers an insulin wave taking 3\u20135 hours to return to baseline. Frequent snacking ('grazing') keeps insulin chronically elevated, locking adipose tissue in lipogenesis (fat storage) and downregulating insulin receptors.\",\n      postMealWalk: \"Skeletal muscle contraction during a 10\u201315 minute brisk walk immediately after a meal translocates GLUT4 receptors to the cell membrane via an AMPK-dependent, insulin-independent pathway, soaking up blood glucose without requiring extra pancreatic insulin.\",\n      circadianEating: \"Melatonin binds to MT1\/MT2 receptors on pancreatic beta-cells, suppressing insulin secretion at night. Eating within 3 hours of sleep causes prolonged nocturnal hyperglycemia and impairs hepatic autophagy.\",\n      waterRO: \"Reverse Osmosis (RO) strips water of essential divalent cations (Magnesium, Calcium). Drinking demineralized water increases urinary electrolyte excretion. Always remineralize RO water with trace mineral drops, rock salt (Sendha Namak), or choose natural spring\/mineral water.\",\n      cortisol: \"Psychological stress activates the HPA axis, releasing cortisol. Cortisol stimulates hepatic gluconeogenesis (creating new glucose from protein) and directly antagonizes insulin signaling in skeletal muscle.\"\n    };\n\n    const FOOD_DATABASE = [\n      \/\/ --- VEGETABLES &amp; LEAFY GREENS ---\n      {\n        id: 'f1', name: 'Steamed Broccoli &amp; Extra Virgin Olive Oil (150g)', category: 'Vegetables &amp; Greens', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 110, pro: 3, carb: 7, fiber: 4, fat: 8, sfa: 1, mufa: 6, pufa: 1,\n        mg: 25, k: 316, ca: 47, fe: 0.7, zn: 0.4, vitC: 89, vitA: 31, vitD: 0, b12: 0, folate: 63, choline: 40, leucine: 0.1, omega3: 0.1, glycemicLoad: 2\n      },\n      {\n        id: 'f14', name: 'Moringa, Palak (Spinach) &amp; Methi Greens Stir-Fry (150g)', category: 'Vegetables &amp; Greens', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 95, pro: 5.2, carb: 9, fiber: 5.5, fat: 4.5, sfa: 0.6, mufa: 3.1, pufa: 0.5,\n        mg: 135, k: 720, ca: 290, fe: 4.9, zn: 1.1, vitC: 65, vitA: 620, vitD: 0, b12: 0, folate: 210, choline: 42, leucine: 0.35, omega3: 0.25, glycemicLoad: 1\n      },\n      {\n        id: 'f16', name: 'Bitter Gourd (Karela) &amp; Onion Saut\u00e9 (150g)', category: 'Vegetables &amp; Greens', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 68, pro: 2.1, carb: 8, fiber: 4.2, fat: 3.2, sfa: 0.5, mufa: 2.1, pufa: 0.4,\n        mg: 38, k: 440, ca: 32, fe: 1.1, zn: 0.9, vitC: 78, vitA: 48, vitD: 0, b12: 0, folate: 92, choline: 24, leucine: 0.12, omega3: 0.05, glycemicLoad: 1\n      },\n      {\n        id: 'f17', name: 'Okra (Bhindi), Bell Peppers &amp; Garlic (150g)', category: 'Vegetables &amp; Greens', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 75, pro: 2.8, carb: 10, fiber: 4.8, fat: 3.0, sfa: 0.4, mufa: 2.0, pufa: 0.4,\n        mg: 62, k: 380, ca: 95, fe: 0.9, zn: 0.7, vitC: 95, vitA: 85, vitD: 0, b12: 0, folate: 88, choline: 28, leucine: 0.15, omega3: 0.04, glycemicLoad: 2\n      },\n      {\n        id: 'f18', name: 'Cauliflower, Cabbage &amp; Turmeric Roast (150g)', category: 'Vegetables &amp; Greens', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 82, pro: 2.9, carb: 8.5, fiber: 4.0, fat: 4.2, sfa: 0.6, mufa: 2.8, pufa: 0.5,\n        mg: 26, k: 410, ca: 45, fe: 0.8, zn: 0.5, vitC: 68, vitA: 12, vitD: 0, b12: 0, folate: 75, choline: 65, leucine: 0.16, omega3: 0.08, glycemicLoad: 2\n      },\n\n      \/\/ --- GRAINS, MILLETS &amp; STARCHES (RS3 &amp; LOW GI) ---\n      {\n        id: 'f2', name: 'Cooled &amp; Reheated White Rice (RS3 Retrograded, 150g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 190, pro: 4, carb: 42, fiber: 4.5, fat: 0.4, sfa: 0.1, mufa: 0.1, pufa: 0.1,\n        mg: 19, k: 55, ca: 16, fe: 0.4, zn: 0.8, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 9, choline: 3, leucine: 0.3, omega3: 0, glycemicLoad: 14, isRS: true\n      },\n      {\n        id: 'f3', name: 'Freshly Cooked Piping Hot White Rice (150g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 205, pro: 4.3, carb: 45, fiber: 0.6, fat: 0.4, sfa: 0.1, mufa: 0.1, pufa: 0.1,\n        mg: 19, k: 55, ca: 16, fe: 0.4, zn: 0.8, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 9, choline: 3, leucine: 0.3, omega3: 0, glycemicLoad: 33, isRS: false\n      },\n      {\n        id: 'f11', name: 'Boiled &amp; Cooled Potato (12-24h at 4\u00b0C - RS3 Retrograded, 150g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 115, pro: 3.1, carb: 26, fiber: 4.8, fat: 0.2, sfa: 0.05, mufa: 0.01, pufa: 0.08,\n        mg: 34, k: 640, ca: 18, fe: 1.2, zn: 0.5, vitC: 19, vitA: 2, vitD: 0, b12: 0, folate: 24, choline: 22, leucine: 0.2, omega3: 0.02, glycemicLoad: 11, isRS: true\n      },\n      {\n        id: 'f12', name: 'Freshly Boiled \/ Mashed Piping Hot Potato (150g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 130, pro: 3.1, carb: 30, fiber: 2.2, fat: 0.2, sfa: 0.05, mufa: 0.01, pufa: 0.08,\n        mg: 34, k: 640, ca: 18, fe: 1.2, zn: 0.5, vitC: 19, vitA: 2, vitD: 0, b12: 0, folate: 24, choline: 22, leucine: 0.2, omega3: 0.02, glycemicLoad: 26, isRS: false\n      },\n      {\n        id: 'f19', name: 'Ragi (Finger Millet) \/ Jowar Bhakri or Porridge (120g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 160, pro: 5.2, carb: 32, fiber: 5.6, fat: 1.1, sfa: 0.2, mufa: 0.3, pufa: 0.4,\n        mg: 78, k: 290, ca: 195, fe: 2.4, zn: 1.3, vitC: 0, vitA: 4, vitD: 0, b12: 0, folate: 28, choline: 18, leucine: 0.48, omega3: 0.04, glycemicLoad: 10\n      },\n      {\n        id: 'f20', name: 'Cooked Quinoa &amp; Amaranth (Rajgira) Bowl (150g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 180, pro: 6.8, carb: 31, fiber: 4.5, fat: 2.8, sfa: 0.3, mufa: 0.8, pufa: 1.4,\n        mg: 98, k: 318, ca: 42, fe: 2.8, zn: 1.6, vitC: 0, vitA: 1, vitD: 0, b12: 0, folate: 65, choline: 44, leucine: 0.42, omega3: 0.12, glycemicLoad: 9\n      },\n      {\n        id: 'f21', name: 'Steel-Cut Oats (Soaked\/Cooled Overnight RS3, 150g)', category: 'Grains, Millets &amp; Starches', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 155, pro: 5.5, carb: 27, fiber: 4.8, fat: 2.6, sfa: 0.4, mufa: 0.8, pufa: 1.0,\n        mg: 66, k: 170, ca: 24, fe: 1.9, zn: 1.5, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 22, choline: 16, leucine: 0.4, omega3: 0.05, glycemicLoad: 8, isRS: true\n      },\n\n      \/\/ --- FRUITS &amp; CITRUS POLYPHENOLS ---\n      {\n        id: 'f10', name: 'Whole Lemon with Skin, Seeds &amp; Juice (1 Medium)', category: 'Fruits &amp; Berries', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 22, pro: 1.2, carb: 11, fiber: 5.1, fat: 0.3, sfa: 0.04, mufa: 0.01, pufa: 0.09,\n        mg: 14, k: 150, ca: 65, fe: 0.8, zn: 0.1, vitC: 84, vitA: 3, vitD: 0, b12: 0, folate: 18, choline: 6, leucine: 0.05, omega3: 0.02, glycemicLoad: 1\n      },\n      {\n        id: 'f9', name: 'Avocado, Cucumber &amp; Hemp Seed Salad (150g)', category: 'Fruits &amp; Berries', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 290, pro: 8, carb: 11, fiber: 8, fat: 25, sfa: 3.5, mufa: 14, pufa: 6.5,\n        mg: 140, k: 680, ca: 35, fe: 2.1, zn: 1.9, vitC: 18, vitA: 45, vitD: 0, b12: 0, folate: 110, choline: 35, leucine: 0.5, omega3: 1.5, glycemicLoad: 1\n      },\n      {\n        id: 'f22', name: 'Guava (Amrood - Whole with Seeds, 1 Medium 120g)', category: 'Fruits &amp; Berries', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 82, pro: 3.1, carb: 17, fiber: 6.5, fat: 1.1, sfa: 0.3, mufa: 0.1, pufa: 0.5,\n        mg: 26, k: 500, ca: 22, fe: 0.4, zn: 0.3, vitC: 250, vitA: 38, vitD: 0, b12: 0, folate: 58, choline: 12, leucine: 0.18, omega3: 0.08, glycemicLoad: 4\n      },\n      {\n        id: 'f23', name: 'Blueberries, Blackberries &amp; Jamun (100g)', category: 'Fruits &amp; Berries', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 52, pro: 1.1, carb: 12, fiber: 4.5, fat: 0.4, sfa: 0.02, mufa: 0.05, pufa: 0.2,\n        mg: 16, k: 140, ca: 20, fe: 0.5, zn: 0.4, vitC: 24, vitA: 12, vitD: 0, b12: 0, folate: 22, choline: 8, leucine: 0.06, omega3: 0.06, glycemicLoad: 3\n      },\n      {\n        id: 'f24', name: 'Pomegranate Arils (Anar with Seeds, 100g)', category: 'Fruits &amp; Berries', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 83, pro: 1.7, carb: 18, fiber: 4.0, fat: 1.2, sfa: 0.1, mufa: 0.1, pufa: 0.1,\n        mg: 12, k: 236, ca: 10, fe: 0.3, zn: 0.35, vitC: 10, vitA: 0, vitD: 0, b12: 0, folate: 38, choline: 8, leucine: 0.08, omega3: 0.04, glycemicLoad: 5\n      },\n      {\n        id: 'f25', name: 'Green Apple with Skin &amp; Cinnamon (1 Medium)', category: 'Fruits &amp; Berries', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 88, pro: 0.5, carb: 22, fiber: 4.4, fat: 0.3, sfa: 0.05, mufa: 0.01, pufa: 0.09,\n        mg: 9, k: 195, ca: 11, fe: 0.2, zn: 0.1, vitC: 8, vitA: 5, vitD: 0, b12: 0, folate: 5, choline: 6, leucine: 0.03, omega3: 0.02, glycemicLoad: 6\n      },\n\n      \/\/ --- NUTS, SEEDS &amp; HEALTHY OILS ---\n      {\n        id: 'f8', name: 'Soaked Almonds, Walnuts &amp; Mixed Nuts (30g)', category: 'Nuts, Seeds &amp; Oils', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 185, pro: 6.5, carb: 5, fiber: 3.2, fat: 16.5, sfa: 1.5, mufa: 7, pufa: 7.5,\n        mg: 110, k: 220, ca: 65, fe: 1.9, zn: 1.8, vitC: 0.5, vitA: 2, vitD: 0, b12: 0, folate: 22, choline: 18, leucine: 0.45, omega3: 1.2, glycemicLoad: 1\n      },\n      {\n        id: 'f26', name: 'Pumpkin Seeds (Pepitas - Raw\/Soaked, 30g)', category: 'Nuts, Seeds &amp; Oils', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 170, pro: 9.0, carb: 3.2, fiber: 1.8, fat: 14.5, sfa: 2.5, mufa: 4.5, pufa: 6.2,\n        mg: 168, k: 240, ca: 15, fe: 2.5, zn: 2.3, vitC: 0.5, vitA: 1, vitD: 0, b12: 0, folate: 17, choline: 19, leucine: 0.72, omega3: 0.05, glycemicLoad: 1\n      },\n      {\n        id: 'f27', name: 'Chia Seeds (Soaked in Water, 2 Tbsp \/ 28g)', category: 'Nuts, Seeds &amp; Oils', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 138, pro: 4.7, carb: 12, fiber: 9.8, fat: 8.7, sfa: 0.9, mufa: 0.7, pufa: 6.7,\n        mg: 95, k: 115, ca: 179, fe: 2.2, zn: 1.3, vitC: 0.5, vitA: 2, vitD: 0, b12: 0, folate: 14, choline: 20, leucine: 0.39, omega3: 5.0, glycemicLoad: 1\n      },\n      {\n        id: 'f28', name: 'Ground Flaxseeds (Alsi, 2 Tbsp \/ 20g)', category: 'Nuts, Seeds &amp; Oils', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 110, pro: 3.8, carb: 6, fiber: 5.6, fat: 8.5, sfa: 0.7, mufa: 1.5, pufa: 5.7,\n        mg: 78, k: 162, ca: 52, fe: 1.2, zn: 0.9, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 18, choline: 16, leucine: 0.25, omega3: 4.5, glycemicLoad: 0\n      },\n      {\n        id: 'f29', name: 'Extra Virgin Olive Oil (Cold-Pressed, 1 Tbsp \/ 14g)', category: 'Nuts, Seeds &amp; Oils', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 119, pro: 0, carb: 0, fiber: 0, fat: 13.5, sfa: 1.9, mufa: 9.9, pufa: 1.4,\n        mg: 0, k: 0, ca: 0, fe: 0.1, zn: 0, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 0, choline: 0, leucine: 0, omega3: 0.1, glycemicLoad: 0\n      },\n      {\n        id: 'f30', name: 'A2 Cultured Ghee \/ Clarified Butter (1 Tbsp \/ 14g)', category: 'Nuts, Seeds &amp; Oils', diet: ['lacto', 'ovo', 'omni'],\n        cal: 125, pro: 0, carb: 0, fiber: 0, fat: 14, sfa: 8.8, mufa: 4.0, pufa: 0.5,\n        mg: 0, k: 0, ca: 0, fe: 0, zn: 0, vitC: 0, vitA: 120, vitD: 15, b12: 0, folate: 0, choline: 3, leucine: 0, omega3: 0.2, glycemicLoad: 0\n      },\n      {\n        id: 'f15', name: 'Nutritional Yeast (Plant B12) &amp; Sesame Tahini (2 Tbsp)', category: 'Nuts, Seeds &amp; Oils', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 130, pro: 9, carb: 6, fiber: 4, fat: 8, sfa: 1.1, mufa: 3.0, pufa: 3.5,\n        mg: 65, k: 310, ca: 140, fe: 2.6, zn: 2.8, vitC: 0, vitA: 0, vitD: 40, b12: 2.4, folate: 160, choline: 38, leucine: 0.65, omega3: 0.05, glycemicLoad: 1\n      },\n\n      \/\/ --- PROTEINS, LEGUMES &amp; DAIRY ---\n      {\n        id: 'f7', name: 'Sprouted Moong Dal &amp; Spinach Bowl (180g)', category: 'Proteins, Legumes &amp; Dairy', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 185, pro: 13, carb: 30, fiber: 8.5, fat: 1.2, sfa: 0.2, mufa: 0.3, pufa: 0.5,\n        mg: 95, k: 540, ca: 85, fe: 3.8, zn: 1.7, vitC: 28, vitA: 280, vitD: 0, b12: 0, folate: 190, choline: 55, leucine: 0.9, omega3: 0.1, glycemicLoad: 8\n      },\n      {\n        id: 'f31', name: 'Kala Chana (Black Chickpeas) &amp; Tofu\/Soy Chunks (150g)', category: 'Proteins, Legumes &amp; Dairy', diet: ['vegan', 'lacto', 'ovo', 'omni'],\n        cal: 225, pro: 17.5, carb: 24, fiber: 7.8, fat: 5.5, sfa: 0.8, mufa: 1.3, pufa: 3.0,\n        mg: 88, k: 420, ca: 210, fe: 3.6, zn: 1.9, vitC: 3, vitA: 12, vitD: 0, b12: 0, folate: 175, choline: 95, leucine: 1.35, omega3: 0.3, glycemicLoad: 6\n      },\n      {\n        id: 'f6', name: 'Paneer \/ Indian Cottage Cheese (100g)', category: 'Proteins, Legumes &amp; Dairy', diet: ['lacto', 'ovo', 'omni'],\n        cal: 265, pro: 18, carb: 3, fiber: 0, fat: 20, sfa: 13, mufa: 5, pufa: 0.8,\n        mg: 22, k: 105, ca: 480, fe: 0.4, zn: 2.1, vitC: 0, vitA: 195, vitD: 15, b12: 0.8, folate: 15, choline: 45, leucine: 1.8, omega3: 0.15, glycemicLoad: 1\n      },\n      {\n        id: 'f13', name: 'A2 Curd \/ Greek Yogurt with Flax &amp; Chia Seeds (150g)', category: 'Proteins, Legumes &amp; Dairy', diet: ['lacto', 'ovo', 'omni'],\n        cal: 165, pro: 12, carb: 8, fiber: 3.5, fat: 9.5, sfa: 4.2, mufa: 2.1, pufa: 2.8,\n        mg: 55, k: 260, ca: 240, fe: 0.9, zn: 1.4, vitC: 1, vitA: 45, vitD: 10, b12: 0.9, folate: 18, choline: 32, leucine: 1.2, omega3: 1.8, glycemicLoad: 2\n      },\n      {\n        id: 'f4', name: 'Pasture-Raised Whole Eggs (2 Large)', category: 'Proteins, Legumes &amp; Dairy', diet: ['ovo', 'omni'],\n        cal: 145, pro: 12.6, carb: 0.8, fiber: 0, fat: 10, sfa: 3.2, mufa: 3.8, pufa: 1.4,\n        mg: 12, k: 138, ca: 56, fe: 1.8, zn: 1.3, vitC: 0, vitA: 160, vitD: 82, b12: 1.1, folate: 47, choline: 294, leucine: 1.1, omega3: 0.22, glycemicLoad: 0\n      },\n      {\n        id: 'f5', name: 'Wild-Caught Salmon \/ Mackerel Fillet (150g)', category: 'Proteins, Legumes &amp; Dairy', diet: ['omni'],\n        cal: 280, pro: 34, carb: 0, fiber: 0, fat: 15, sfa: 3, mufa: 5, pufa: 6,\n        mg: 45, k: 620, ca: 20, fe: 1.2, zn: 0.9, vitC: 0, vitA: 50, vitD: 650, b12: 4.8, folate: 40, choline: 135, leucine: 2.8, omega3: 2.6, glycemicLoad: 0\n      },\n      {\n        id: 'f32', name: 'Free-Range Chicken Breast &amp; Herbs (150g)', category: 'Proteins, Legumes &amp; Dairy', diet: ['omni'],\n        cal: 245, pro: 45, carb: 0, fiber: 0, fat: 5.4, sfa: 1.5, mufa: 1.8, pufa: 1.1,\n        mg: 42, k: 490, ca: 22, fe: 1.5, zn: 1.6, vitC: 0, vitA: 14, vitD: 12, b12: 0.6, folate: 9, choline: 130, leucine: 3.4, omega3: 0.1, glycemicLoad: 0\n      }\n    ];\n\n    \/\/ Evidence-based Daily Value (DV) reference targets for metabolic &amp; endocrine health\n    const DAILY_VALUE_TARGETS = {\n      pro: { label: 'Protein', unit: 'g', dv: 90, role: 'Skeletal muscle GLUT4 sink &amp; satiety' },\n      fiber: { label: 'Dietary Fiber', unit: 'g', dv: 35, role: 'Duodenal viscous mesh &amp; butyrate synthesis' },\n      leucine: { label: 'Leucine (Essential Amino)', unit: 'g', dv: 7.5, role: 'Triggers muscle protein synthesis (2.5g\/meal)' },\n      omega3: { label: 'Omega-3 Fatty Acids', unit: 'g', dv: 2.0, role: 'Resolves hepatic &amp; vascular inflammation' },\n      mg: { label: 'Magnesium (Mg)', unit: 'mg', dv: 420, role: 'Intracellular insulin receptor tyrosine kinase cofactor' },\n      k: { label: 'Potassium (K)', unit: 'mg', dv: 3500, role: 'Endothelial vasodilation &amp; sodium excretion (BP)' },\n      ca: { label: 'Calcium (Ca)', unit: 'mg', dv: 1000, role: 'Pancreatic beta-cell insulin exocytosis signaling' },\n      fe: { label: 'Iron (Fe)', unit: 'mg', dv: 18, role: 'Mitochondrial electron transport &amp; hemoglobin' },\n      zn: { label: 'Zinc (Zn)', unit: 'mg', dv: 11, role: 'Crystallizes &amp; packages insulin hexamers in pancreas' },\n      choline: { label: 'Choline (Hepatic)', unit: 'mg', dv: 550, role: 'Exports trapped liver fat (VLDL) to reverse NAFLD' },\n      vitC: { label: 'Vitamin C', unit: 'mg', dv: 90, role: 'Endothelial nitric oxide protection &amp; iron absorption' },\n      vitA: { label: 'Vitamin A (RAE)', unit: 'mcg', dv: 900, role: 'Retinoid X receptor signaling &amp; immune barrier' },\n      vitD: { label: 'Vitamin D3 (Food)', unit: 'IU', dv: 600, role: 'Modulates insulin gene expression &amp; immunity' },\n      b12: { label: 'Vitamin B12', unit: 'mcg', dv: 2.4, role: 'Myelin integrity, homocysteine clearance &amp; energy' },\n      folate: { label: 'Folate (Vitamin B9)', unit: 'mcg', dv: 400, role: 'Methylation cycle &amp; endothelial homocysteine control' }\n    };\n\n    const DEFAULT_PROFILE = {\n      alias: '',\n      age: '',\n      gender: 'male',\n      weightKg: '',\n      heightCm: '',\n      bodyFatPct: '',\n      waistCm: '',\n      hipCm: '',\n      neckCm: '',\n      dietPreference: 'lacto',\n      activityMultiplier: 1.375,\n      hba1c: '',\n      fastingInsulin: '',\n      fastingGlucose: '',\n      systolicBP: '',\n      diastolicBP: '',\n      alt: '',\n      ast: '',\n      ggt: '',\n      triglycerides: '',\n      hdl: ''\n    };\n\n    const DEFAULT_NUTRITION = {\n      loggedFoods: [],\n      mealSequence: 'fiber-protein-carb',\n      cookingFat: 'ghee',\n      snackingCount: 0,\n      starchPrepMethod: 'cooled-reheated',\n      waterLogs: []\n    };\n\n    const DEFAULT_FASTING = {\n      protocol: '16:8',\n      fastingType: 'water-electrolyte',\n      currentFastHours: 0,\n      wakeTime: '',\n      firstMealTime: '',\n      lastMealTime: '',\n      sleepTime: '',\n      mealsPerDay: 2\n    };\n\n    const DEFAULT_ACTIVITY = {\n      workouts: [],\n      postMealWalks: {\n        breakfastWalk: false,\n        breakfastWalkMins: 15,\n        breakfastWalkPace: 'brisk',\n        lunchWalk: false,\n        lunchWalkMins: 20,\n        lunchWalkPace: 'brisk',\n        dinnerWalk: false,\n        dinnerWalkMins: 30,\n        dinnerWalkPace: 'normal'\n      },\n      dailySteps: 0\n    };\n\n    const DEFAULT_LIFESTYLE = {\n      sunlightTimeOfDay: 'Morning (07:00 - 09:00 AM)',\n      sunlightDurationMin: 0,\n      skinExposurePct: 25,\n      sleepHours: 0,\n      sleepQuality: 5,\n      wakingGlucose: '',\n      stressScore: 5\n    };\n\n    const Tooltip = ({ text }) =&gt; {\n      const [open, setOpen] = useState(false);\n      return (\n        &lt;span className=\"relative inline-block ml-1.5 align-middle\"&gt;\n          &lt;button\n            type=\"button\"\n            onMouseEnter={() =&gt; setOpen(true)}\n            onMouseLeave={() =&gt; setOpen(false)}\n            onClick={() =&gt; setOpen(!open)}\n            className=\"text-teal-600 hover:text-teal-500 hover:bg-teal-50 p-0.5 rounded-full focus:outline-none transition-colors\"\n            aria-label=\"Scientific Explanation\"\n          &gt;\n            &lt;Icon name=\"info\" className=\"w-4 h-4\" \/&gt;\n          &lt;\/button&gt;\n          {open &amp;&amp; (\n            &lt;div className=\"absolute z-50 bottom-full left-1\/2 -translate-x-1\/2 mb-2 w-72 p-3.5 bg-white text-slate-700 text-xs leading-relaxed rounded-xl shadow-xl border border-teal-200 pointer-events-none\"&gt;\n              &lt;div className=\"font-bold text-teal-700 mb-1 flex items-center gap-1 border-b border-teal-100 pb-1\"&gt;\n                &lt;span&gt;Scientific Mechanism&lt;\/span&gt;\n              &lt;\/div&gt;\n              {text}\n            &lt;\/div&gt;\n          )}\n        &lt;\/span&gt;\n      );\n    };\n\n    const StatusBadge = ({ status, label }) =&gt; {\n      const colors = {\n        optimal: 'bg-emerald-50 text-emerald-700 border-emerald-200',\n        warning: 'bg-amber-50 text-amber-700 border-amber-200',\n        critical: 'bg-rose-50 text-rose-700 border-rose-200',\n        info: 'bg-sky-50 text-sky-700 border-sky-200'\n      };\n      return (\n        &lt;span className={`px-2.5 py-0.5 text-xs font-semibold rounded-full border ${colors[status] || colors.info}`}&gt;\n          {label}\n        &lt;\/span&gt;\n      );\n    };\n\n    function App() {\n      const [activeTab, setActiveTab] = useState('profile');\n      const [toastMessage, setToastMessage] = useState(null);\n      const [confirmResetModal, setConfirmResetModal] = useState(false);\n      const [activeSampleMode, setActiveSampleMode] = useState(null); \/\/ null | 'high-risk' | 'reversing'\n\n      \/\/ Core Clinical States\n      const [profile, setProfile] = useState(DEFAULT_PROFILE);\n      const [nutrition, setNutrition] = useState(DEFAULT_NUTRITION);\n      const [fasting, setFasting] = useState(DEFAULT_FASTING);\n      const [activity, setActivity] = useState(DEFAULT_ACTIVITY);\n      const [lifestyle, setLifestyle] = useState(DEFAULT_LIFESTYLE);\n\n      \/\/ Cloud Storage Sync States (Option 5.1)\n      const [cloudUser, setCloudUser] = useState(null);\n      const [cloudStatus, setCloudStatus] = useState('connecting'); \/\/ 'connecting' | 'synced' | 'saving' | 'unconfigured' | 'error'\n      const [initialCloudLoadComplete, setInitialCloudLoadComplete] = useState(false);\n      const dbRef = useRef(null);\n      const appIdRef = useRef('metabolicrx-gri-prod');\n      const saveTimeoutRef = useRef(null);\n      const toastTimeoutRef = useRef(null);\n      const applyTimeoutRef = useRef(null);\n      const fileInputRef = useRef(null);\n      const isApplyingRemoteUpdateRef = useRef(false);\n      const isMountedRef = useRef(true);\n      const activeSampleModeRef = useRef(null);\n      const lastSavedJsonRef = useRef('');\n      const preSampleSnapshotRef = useRef(null);\n\n      \/\/ Keep activeSampleModeRef in sync with state so async Firestore listeners always read current mode\n      useEffect(() =&gt; {\n        activeSampleModeRef.current = activeSampleMode;\n      }, [activeSampleMode]);\n\n      const sanitizeIncomingPayload = (data) =&gt; {\n        if (!data || typeof data !== 'object') return null;\n\n        const rawProfile = data.profile &amp;&amp; typeof data.profile === 'object' ? data.profile : {};\n        const validDiets = ['vegan', 'lacto', 'ovo', 'omni'];\n        const validGenders = ['male', 'female'];\n        const mergedProfile = {\n          ...DEFAULT_PROFILE,\n          alias: toSafeStr(rawProfile.alias, '', 40),\n          age: parseInputNum(rawProfile.age, 0, 120),\n          gender: validGenders.includes(rawProfile.gender) ? rawProfile.gender : 'male',\n          weightKg: parseInputNum(rawProfile.weightKg, 0, 400),\n          heightCm: parseInputNum(rawProfile.heightCm, 0, 260),\n          bodyFatPct: parseInputNum(rawProfile.bodyFatPct, 0, 75),\n          waistCm: parseInputNum(rawProfile.waistCm, 0, 250),\n          hipCm: parseInputNum(rawProfile.hipCm, 0, 250),\n          neckCm: parseInputNum(rawProfile.neckCm, 0, 80),\n          dietPreference: validDiets.includes(rawProfile.dietPreference) ? rawProfile.dietPreference : 'lacto',\n          activityMultiplier: toSafeFloat(rawProfile.activityMultiplier, 1.375, 1.0, 2.5),\n          hba1c: parseInputNum(rawProfile.hba1c, 0, 25),\n          fastingInsulin: parseInputNum(rawProfile.fastingInsulin, 0, 300),\n          fastingGlucose: parseInputNum(rawProfile.fastingGlucose, 0, 600),\n          systolicBP: parseInputNum(rawProfile.systolicBP, 0, 300),\n          diastolicBP: parseInputNum(rawProfile.diastolicBP, 0, 200),\n          alt: parseInputNum(rawProfile.alt, 0, 1000),\n          ast: parseInputNum(rawProfile.ast, 0, 1000),\n          ggt: parseInputNum(rawProfile.ggt, 0, 1000),\n          triglycerides: parseInputNum(rawProfile.triglycerides, 0, 1500),\n          hdl: parseInputNum(rawProfile.hdl, 0, 200)\n        };\n\n        const rawNutrition = data.nutrition &amp;&amp; typeof data.nutrition === 'object' ? data.nutrition : {};\n        const sanitizeFoodItem = (item, idx) =&gt; {\n          if (!item || typeof item !== 'object') return null;\n          return {\n            id: toSafeStr(item.id, `custom-${idx}`, 40),\n            instanceId: toSafeStr(item.instanceId, makeUniqueId(), 60),\n            name: toSafeStr(item.name, 'Logged Food Item', 100),\n            category: toSafeStr(item.category, 'Whole Food', 50),\n            servings: toSafeFloat(item.servings, 1, 0.1, 20),\n            cal: toSafeFloat(item.cal, 0, 0, 5000),\n            pro: toSafeFloat(item.pro, 0, 0, 500),\n            carb: toSafeFloat(item.carb, 0, 0, 500),\n            fiber: toSafeFloat(item.fiber, 0, 0, 200),\n            fat: toSafeFloat(item.fat, 0, 0, 500),\n            sfa: toSafeFloat(item.sfa, 0, 0, 200),\n            mufa: toSafeFloat(item.mufa, 0, 0, 200),\n            pufa: toSafeFloat(item.pufa, 0, 0, 200),\n            mg: toSafeFloat(item.mg, 0, 0, 5000),\n            k: toSafeFloat(item.k, 0, 0, 10000),\n            ca: toSafeFloat(item.ca, 0, 0, 5000),\n            fe: toSafeFloat(item.fe, 0, 0, 200),\n            zn: toSafeFloat(item.zn, 0, 0, 200),\n            vitC: toSafeFloat(item.vitC, 0, 0, 5000),\n            vitA: toSafeFloat(item.vitA, 0, 0, 10000),\n            vitD: toSafeFloat(item.vitD, 0, 0, 10000),\n            b12: toSafeFloat(item.b12, 0, 0, 500),\n            folate: toSafeFloat(item.folate, 0, 0, 5000),\n            choline: toSafeFloat(item.choline, 0, 0, 5000),\n            leucine: toSafeFloat(item.leucine, 0, 0, 100),\n            omega3: toSafeFloat(item.omega3, 0, 0, 100),\n            glycemicLoad: toSafeFloat(item.glycemicLoad, 0, 0, 200)\n          };\n        };\n\n        const sanitizeWaterItem = (w) =&gt; {\n          if (!w || typeof w !== 'object') return null;\n          return {\n            id: toSafeStr(w.id, makeUniqueId(), 60),\n            timing: toSafeStr(w.timing, 'Morning Waking', 50),\n            amountMl: toSafeFloat(w.amountMl, 250, 10, 5000),\n            source: toSafeStr(w.source, 'Natural Mineral Water', 60)\n          };\n        };\n\n        const mergedNutrition = {\n          ...DEFAULT_NUTRITION,\n          mealSequence: toSafeStr(rawNutrition.mealSequence, DEFAULT_NUTRITION.mealSequence, 40),\n          cookingFat: toSafeStr(rawNutrition.cookingFat, DEFAULT_NUTRITION.cookingFat, 40),\n          snackingCount: Math.round(toSafeFloat(rawNutrition.snackingCount, 0, 0, 10)),\n          starchPrepMethod: toSafeStr(rawNutrition.starchPrepMethod, DEFAULT_NUTRITION.starchPrepMethod, 40),\n          loggedFoods: Array.isArray(rawNutrition.loggedFoods)\n            ? rawNutrition.loggedFoods.slice(0, 150).map(sanitizeFoodItem).filter(Boolean)\n            : [],\n          waterLogs: Array.isArray(rawNutrition.waterLogs)\n            ? rawNutrition.waterLogs.slice(0, 150).map(sanitizeWaterItem).filter(Boolean)\n            : []\n        };\n\n        const rawFasting = data.fasting &amp;&amp; typeof data.fasting === 'object' ? data.fasting : {};\n        const mergedFasting = {\n          ...DEFAULT_FASTING,\n          protocol: toSafeStr(rawFasting.protocol, DEFAULT_FASTING.protocol, 40),\n          fastingType: toSafeStr(rawFasting.fastingType, DEFAULT_FASTING.fastingType, 40),\n          currentFastHours: toSafeFloat(rawFasting.currentFastHours, 0, 0, 48),\n          wakeTime: toSafeStr(rawFasting.wakeTime, '', 10),\n          firstMealTime: toSafeStr(rawFasting.firstMealTime, '', 10),\n          lastMealTime: toSafeStr(rawFasting.lastMealTime, '', 10),\n          sleepTime: toSafeStr(rawFasting.sleepTime, '', 10),\n          mealsPerDay: Math.round(toSafeFloat(rawFasting.mealsPerDay, 2, 1, 10))\n        };\n\n        const rawActivity = data.activity &amp;&amp; typeof data.activity === 'object' ? data.activity : {};\n        const sanitizeWorkoutItem = (w) =&gt; {\n          if (!w || typeof w !== 'object') return null;\n          return {\n            id: toSafeStr(w.id, makeUniqueId(), 60),\n            type: toSafeStr(w.type, 'Resistance Training (Hypertrophy)', 80),\n            intensity: toSafeStr(w.intensity, 'Moderate (RPE 7)', 40),\n            durationMin: Math.round(toSafeFloat(w.durationMin, 30, 1, 600)),\n            fastedState: Boolean(w.fastedState),\n            preWorkoutNutrition: toSafeStr(w.preWorkoutNutrition, '', 120),\n            intraWorkoutHydration: toSafeStr(w.intraWorkoutHydration, '', 120),\n            postWorkoutNutrition: toSafeStr(w.postWorkoutNutrition, '', 120)\n          };\n        };\n\n        const validPaces = ['slow', 'normal', 'brisk'];\n        const mergedActivity = {\n          ...DEFAULT_ACTIVITY,\n          dailySteps: Math.round(toSafeFloat(rawActivity.dailySteps, 0, 0, 100000)),\n          workouts: Array.isArray(rawActivity.workouts)\n            ? rawActivity.workouts.slice(0, 100).map(sanitizeWorkoutItem).filter(Boolean)\n            : [],\n          postMealWalks: {\n            breakfastWalk: Boolean(rawActivity?.postMealWalks?.breakfastWalk),\n            breakfastWalkMins: Math.round(toSafeFloat(rawActivity?.postMealWalks?.breakfastWalkMins, 15, 5, 120)),\n            breakfastWalkPace: validPaces.includes(rawActivity?.postMealWalks?.breakfastWalkPace) ? rawActivity.postMealWalks.breakfastWalkPace : 'brisk',\n            lunchWalk: Boolean(rawActivity?.postMealWalks?.lunchWalk),\n            lunchWalkMins: Math.round(toSafeFloat(rawActivity?.postMealWalks?.lunchWalkMins, 20, 5, 120)),\n            lunchWalkPace: validPaces.includes(rawActivity?.postMealWalks?.lunchWalkPace) ? rawActivity.postMealWalks.lunchWalkPace : 'brisk',\n            dinnerWalk: Boolean(rawActivity?.postMealWalks?.dinnerWalk),\n            dinnerWalkMins: Math.round(toSafeFloat(rawActivity?.postMealWalks?.dinnerWalkMins, 30, 5, 120)),\n            dinnerWalkPace: validPaces.includes(rawActivity?.postMealWalks?.dinnerWalkPace) ? rawActivity.postMealWalks.dinnerWalkPace : 'normal'\n          }\n        };\n\n        const rawLifestyle = data.lifestyle &amp;&amp; typeof data.lifestyle === 'object' ? data.lifestyle : {};\n        const mergedLifestyle = {\n          ...DEFAULT_LIFESTYLE,\n          sunlightTimeOfDay: toSafeStr(rawLifestyle.sunlightTimeOfDay, DEFAULT_LIFESTYLE.sunlightTimeOfDay, 60),\n          sunlightDurationMin: toSafeFloat(rawLifestyle.sunlightDurationMin, 0, 0, 60),\n          skinExposurePct: toSafeFloat(rawLifestyle.skinExposurePct, 10, 0, 100),\n          sleepHours: toSafeFloat(rawLifestyle.sleepHours, 0, 0, 10),\n          sleepQuality: toSafeFloat(rawLifestyle.sleepQuality, 5, 1, 10),\n          wakingGlucose: parseInputNum(rawLifestyle.wakingGlucose, 0, 600),\n          stressScore: toSafeFloat(rawLifestyle.stressScore, 5, 1, 10)\n        };\n\n        return {\n          profile: mergedProfile,\n          nutrition: mergedNutrition,\n          fasting: mergedFasting,\n          activity: mergedActivity,\n          lifestyle: mergedLifestyle\n        };\n      };\n\n      const applyIncomingData = (data) =&gt; {\n        const sanitized = sanitizeIncomingPayload(data);\n        if (!sanitized) return;\n\n        \/\/ If user is currently previewing a Sample Demo Profile, update their background restore snapshot\n        \/\/ and local backup without clobbering the active sample view\n        const serialized = JSON.stringify(sanitized);\n        lastSavedJsonRef.current = serialized;\n        saveLocalBackup(sanitized);\n\n        if (activeSampleModeRef.current !== null) {\n          preSampleSnapshotRef.current = deepCloneState(sanitized);\n          return;\n        }\n\n        isApplyingRemoteUpdateRef.current = true;\n        setProfile(sanitized.profile);\n        setNutrition(sanitized.nutrition);\n        setFasting(sanitized.fasting);\n        setActivity(sanitized.activity);\n        setLifestyle(sanitized.lifestyle);\n\n        if (applyTimeoutRef.current) clearTimeout(applyTimeoutRef.current);\n        applyTimeoutRef.current = setTimeout(() =&gt; {\n          isApplyingRemoteUpdateRef.current = false;\n        }, 60);\n      };\n\n      const triggerToast = (msg) =&gt; {\n        if (!isMountedRef.current) return;\n        setToastMessage(msg);\n        if (toastTimeoutRef.current) clearTimeout(toastTimeoutRef.current);\n        toastTimeoutRef.current = setTimeout(() =&gt; {\n          if (isMountedRef.current) setToastMessage(null);\n        }, 3200);\n      };\n\n      \/\/ Cleanup timers on unmount\n      useEffect(() =&gt; {\n        isMountedRef.current = true;\n        return () =&gt; {\n          isMountedRef.current = false;\n          if (toastTimeoutRef.current) clearTimeout(toastTimeoutRef.current);\n          if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n          if (applyTimeoutRef.current) clearTimeout(applyTimeoutRef.current);\n        };\n      }, []);\n\n      \/\/ 1. Initialize Local Fallback + Firebase Authentication &amp; Real-time Private Vault Listener\n      useEffect(() =&gt; {\n        let unsubscribeSnapshot = null;\n        let unsubscribeAuth = null;\n\n        \/\/ Immediately hydrate from local backup first so offline\/ad-blocked users never lose progress\n        const cachedLocal = loadLocalBackup();\n        if (cachedLocal) {\n          applyIncomingData(cachedLocal);\n        }\n\n        const initCloud = async () =&gt; {\n          const cloud = window.__METABOLIC_CLOUD__;\n          if (!cloud || !cloud.isConfigured) {\n            if (isMountedRef.current) {\n              setCloudStatus('unconfigured');\n              setInitialCloudLoadComplete(true);\n            }\n            return;\n          }\n\n          try {\n            \/\/ Singleton guard: prevents duplicate-app crash if React re-mounts or hot-reloads\n            const app = cloud.cachedApp || cloud.initializeApp(cloud.activeConfig);\n            cloud.cachedApp = app;\n            const auth = cloud.getAuth(app);\n            const db = cloud.getFirestore(app);\n            dbRef.current = db;\n            appIdRef.current = cloud.appId;\n\n            \/\/ Register Auth listener BEFORE signing in to avoid any missed state transitions\n            unsubscribeAuth = cloud.onAuthStateChanged(auth, (user) =&gt; {\n              if (!user || !isMountedRef.current) return;\n              setCloudUser(user);\n\n              if (unsubscribeSnapshot) {\n                unsubscribeSnapshot();\n                unsubscribeSnapshot = null;\n              }\n\n              \/\/ Rule 1: Strict private user path\n              const userDocRef = cloud.doc(\n                db,\n                'artifacts',\n                cloud.appId,\n                'users',\n                user.uid,\n                'metabolicData',\n                'dailyState'\n              );\n\n              unsubscribeSnapshot = cloud.onSnapshot(\n                userDocRef,\n                (snapshot) =&gt; {\n                  if (!isMountedRef.current) return;\n                  \/\/ Ignore local latency-compensation echoes while user is actively typing\n                  if (snapshot.metadata &amp;&amp; snapshot.metadata.hasPendingWrites) {\n                    return;\n                  }\n\n                  if (snapshot.exists()) {\n                    applyIncomingData(snapshot.data() || {});\n                  } else {\n                    \/\/ If cloud doc is empty but user has local data, allow next edit or sync to persist\n                    const existingLocal = loadLocalBackup();\n                    if (existingLocal) {\n                      lastSavedJsonRef.current = '';\n                    }\n                  }\n                  setCloudStatus('synced');\n                  setInitialCloudLoadComplete(true);\n                },\n                (err) =&gt; {\n                  console.error(\"Firestore Listener Error:\", err);\n                  if (isMountedRef.current) {\n                    setCloudStatus('error');\n                    setInitialCloudLoadComplete(true);\n                  }\n                }\n              );\n            });\n\n            \/\/ Rule 3: Authenticate FIRST before any Firestore operation.\n            if (!cloud.usingCustomProject &amp;&amp; typeof __initial_auth_token !== 'undefined' &amp;&amp; __initial_auth_token) {\n              try {\n                await cloud.signInWithCustomToken(auth, __initial_auth_token);\n              } catch (tokenErr) {\n                await cloud.signInAnonymously(auth);\n              }\n            } else {\n              await cloud.signInAnonymously(auth);\n            }\n          } catch (err) {\n            console.error(\"Cloud Initialization Error:\", err);\n            if (isMountedRef.current) {\n              setCloudStatus('error');\n              setInitialCloudLoadComplete(true);\n            }\n          }\n        };\n\n        if (window.__METABOLIC_CLOUD__) {\n          initCloud();\n        } else {\n          window.addEventListener('metabolic-cloud-ready', initCloud, { once: true });\n        }\n\n        return () =&gt; {\n          window.removeEventListener('metabolic-cloud-ready', initCloud);\n          if (unsubscribeSnapshot) unsubscribeSnapshot();\n          if (unsubscribeAuth) unsubscribeAuth();\n        };\n      }, []);\n\n      \/\/ 2. Debounced Auto-Save to Local Vault &amp; Cloud Whenever User Updates Any Metric\n      useEffect(() =&gt; {\n        if (!initialCloudLoadComplete) return;\n        if (isApplyingRemoteUpdateRef.current) return;\n        \/\/ CRITICAL PROTECTION: Never overwrite the user's Cloud Vault or Local Backup while viewing a Sample Demo Profile\n        if (activeSampleMode !== null || activeSampleModeRef.current !== null) return;\n\n        const payloadObj = {\n          profile,\n          nutrition,\n          fasting,\n          activity,\n          lifestyle\n        };\n        const currentPayloadJson = JSON.stringify(payloadObj);\n\n        \/\/ Prevent redundant write loops if data hasn't changed\n        if (currentPayloadJson === lastSavedJsonRef.current) return;\n\n        \/\/ Always save to local browser fallback immediately\n        saveLocalBackup(payloadObj);\n\n        const cloud = window.__METABOLIC_CLOUD__;\n        if (!cloud || !cloud.isConfigured || !cloudUser || !dbRef.current) {\n          lastSavedJsonRef.current = currentPayloadJson;\n          return;\n        }\n\n        setCloudStatus('saving');\n        if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n\n        saveTimeoutRef.current = setTimeout(async () =&gt; {\n          if (!isMountedRef.current || activeSampleModeRef.current !== null) return;\n          try {\n            lastSavedJsonRef.current = currentPayloadJson;\n            const userDocRef = cloud.doc(\n              dbRef.current,\n              'artifacts',\n              appIdRef.current,\n              'users',\n              cloudUser.uid,\n              'metabolicData',\n              'dailyState'\n            );\n            await cloud.setDoc(\n              userDocRef,\n              {\n                ...payloadObj,\n                updatedAt: new Date().toISOString()\n              },\n              { merge: true }\n            );\n            if (isMountedRef.current) setCloudStatus('synced');\n          } catch (err) {\n            console.error(\"Auto-save failed:\", err);\n            if (isMountedRef.current) setCloudStatus('error');\n          }\n        }, 700);\n\n        return () =&gt; {\n          if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n        };\n      }, [profile, nutrition, fasting, activity, lifestyle, cloudUser, initialCloudLoadComplete, activeSampleMode]);\n\n      \/\/ 3. Privacy Safeguard: 1-Click Wipe Cloud Record &amp; Reset\n      const handleDeleteCloudData = async () =&gt; {\n        try {\n          if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n          activeSampleModeRef.current = null;\n          setActiveSampleMode(null);\n          preSampleSnapshotRef.current = null;\n          clearLocalBackup();\n          const cloud = window.__METABOLIC_CLOUD__;\n          if (cloud &amp;&amp; cloud.isConfigured &amp;&amp; cloudUser &amp;&amp; dbRef.current) {\n            const userDocRef = cloud.doc(\n              dbRef.current,\n              'artifacts',\n              appIdRef.current,\n              'users',\n              cloudUser.uid,\n              'metabolicData',\n              'dailyState'\n            );\n            await cloud.deleteDoc(userDocRef);\n          }\n          lastSavedJsonRef.current = JSON.stringify({\n            profile: DEFAULT_PROFILE,\n            nutrition: DEFAULT_NUTRITION,\n            fasting: DEFAULT_FASTING,\n            activity: DEFAULT_ACTIVITY,\n            lifestyle: DEFAULT_LIFESTYLE\n          });\n          setProfile(DEFAULT_PROFILE);\n          setNutrition(DEFAULT_NUTRITION);\n          setFasting(DEFAULT_FASTING);\n          setActivity(DEFAULT_ACTIVITY);\n          setLifestyle(DEFAULT_LIFESTYLE);\n          setConfirmResetModal(false);\n          triggerToast('All cloud &amp; local records permanently erased.');\n        } catch (err) {\n          console.error(\"Delete failed:\", err);\n          triggerToast('Local data cleared; cloud reset completed.');\n        }\n      };\n\n      \/\/ 4. Privacy Safeguard: Export JSON Backup\n      const handleExportBackup = () =&gt; {\n        const safeAlias = String(profile.alias || 'backup').replace(\/[^a-zA-Z0-9_-]\/g, '_');\n        const payload = {\n          exportedFrom: 'groundreportindia.org - MetabolicGuide',\n          exportedAt: new Date().toISOString(),\n          profile,\n          nutrition,\n          fasting,\n          activity,\n          lifestyle\n        };\n        const blob = new Blob([JSON.stringify(payload, null, 2)], { type: 'application\/json' });\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = `metabolicguide-${safeAlias}.json`;\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n        triggerToast('Downloaded personal JSON health backup');\n      };\n\n      \/\/ 4b. Restore Personal JSON Backup\n      const handleImportBackup = (e) =&gt; {\n        const file = e.target.files &amp;&amp; e.target.files[0];\n        if (!file) return;\n        const reader = new FileReader();\n        reader.onload = (event) =&gt; {\n          try {\n            const parsed = JSON.parse(String(event.target?.result || '{}'));\n            if (!parsed || typeof parsed !== 'object' || (!parsed.profile &amp;&amp; !parsed.nutrition)) {\n              triggerToast('Invalid backup file format.');\n              return;\n            }\n            \/\/ Exit Sample Mode first so imported data applies directly to the user's active profile &amp; syncs to Cloud\n            if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n            activeSampleModeRef.current = null;\n            setActiveSampleMode(null);\n            preSampleSnapshotRef.current = null;\n\n            applyIncomingData(parsed);\n            \/\/ Force cloud sync of imported backup\n            lastSavedJsonRef.current = '';\n            triggerToast('Successfully restored personal JSON health backup!');\n          } catch (err) {\n            console.error(\"Backup import failed:\", err);\n            triggerToast('Could not read JSON backup file.');\n          } finally {\n            if (fileInputRef.current) fileInputRef.current.value = '';\n          }\n        };\n        reader.readAsText(file);\n      };\n\n      \/\/ 5. Clinical PDF Report Generator (Vector Print-to-PDF)\n      const handleDownloadPDF = () =&gt; {\n        try {\n          \/\/ If embedded inside a WordPress iframe, ensure print targets the active window\n          window.focus();\n          window.print();\n        } catch (err) {\n          console.error(\"Print error:\", err);\n          triggerToast('Press Ctrl+P (or Cmd+P on Mac) to save as PDF.');\n        }\n      };\n\n      const clinicalMetrics = useMemo(() =&gt; {\n        const weight = toValidNum(profile.weightKg) || 0;\n        const height = toValidNum(profile.heightCm) || 0;\n        const age = toValidNum(profile.age) || 0;\n        const waist = toValidNum(profile.waistCm) || 0;\n        const hip = toValidNum(profile.hipCm) || 0;\n        const insulin = toValidNum(profile.fastingInsulin) || 0;\n        const glucose = toValidNum(profile.fastingGlucose) || 0;\n        const hba1cVal = toValidNum(profile.hba1c);\n        const sysBP = toValidNum(profile.systolicBP);\n        const diaBP = toValidNum(profile.diastolicBP);\n        const tg = toValidNum(profile.triglycerides) || 0;\n        const hdl = toValidNum(profile.hdl) || 0;\n        const alt = toValidNum(profile.alt);\n        const ast = toValidNum(profile.ast);\n        const activityMult = toValidNum(profile.activityMultiplier) || 1.375;\n\n        const heightM = height \/ 100;\n        const bmi = weight &gt; 0 &amp;&amp; heightM &gt; 0 ? +(weight \/ (heightM * heightM)).toFixed(1) : null;\n        const whr = waist &gt; 0 &amp;&amp; hip &gt; 0 ? +(waist \/ hip).toFixed(2) : null;\n        const whtr = waist &gt; 0 &amp;&amp; height &gt; 0 ? +(waist \/ height).toFixed(2) : null;\n        const homaIr = insulin &gt; 0 &amp;&amp; glucose &gt; 0 ? +((insulin * glucose) \/ 405).toFixed(2) : null;\n        const tgHdlRatio = tg &gt; 0 &amp;&amp; hdl &gt; 0 ? +(tg \/ hdl).toFixed(2) : null;\n        const astAltRatio = ast !== null &amp;&amp; alt !== null &amp;&amp; alt &gt; 0 ? +(ast \/ alt).toFixed(2) : null;\n\n        const bmr = weight &gt; 0 &amp;&amp; height &gt; 0 &amp;&amp; age &gt; 0\n          ? (profile.gender === 'male'\n              ? Math.round(10 * weight + 6.25 * height - 5 * age + 5)\n              : Math.round(10 * weight + 6.25 * height - 5 * age - 161))\n          : 0;\n        const tdee = bmr &gt; 0 ? Math.round(bmr * activityMult) : 0;\n        const targetCalories = tdee &gt; 0 ? Math.round(tdee * 0.85) : 0;\n\n        const baseGlucose = glucose &gt; 0 ? glucose : 95;\n        let peakDelta = 55;\n        const walks = activity?.postMealWalks || DEFAULT_ACTIVITY.postMealWalks;\n        const calcWalkBenefit = (enabled, mins, pace) =&gt; {\n          if (!enabled) return 0;\n          const durFactor = Math.min(2.0, (toSafeFloat(mins, 15, 5, 120) \/ 15));\n          const paceMult = pace === 'brisk' ? 1.25 : pace === 'normal' ? 1.0 : 0.75;\n          return Math.round(7 * durFactor * paceMult);\n        };\n        const totalWalkReduction =\n          calcWalkBenefit(walks.breakfastWalk, walks.breakfastWalkMins, walks.breakfastWalkPace) +\n          calcWalkBenefit(walks.lunchWalk, walks.lunchWalkMins, walks.lunchWalkPace) +\n          calcWalkBenefit(walks.dinnerWalk, walks.dinnerWalkMins, walks.dinnerWalkPace);\n        const totalPostMealWalkMins =\n          (walks.breakfastWalk ? toSafeFloat(walks.breakfastWalkMins, 15, 5, 120) : 0) +\n          (walks.lunchWalk ? toSafeFloat(walks.lunchWalkMins, 20, 5, 120) : 0) +\n          (walks.dinnerWalk ? toSafeFloat(walks.dinnerWalkMins, 30, 5, 120) : 0);\n\n        const optimalSequences = [\n          'fiber-protein-carb',\n          'protein-fiber-carb-lemon',\n          'fiber-protein-carb-lemon',\n          'lemon-fiber-protein-carb'\n        ];\n        if (optimalSequences.includes(nutrition.mealSequence)) peakDelta -= 24;\n        if (nutrition.mealSequence === 'carb-first') peakDelta += 18;\n        if (['cooled-reheated', 'potato-cooled-rs3', 'vinegar-added', 'green-banana-legume'].includes(nutrition.starchPrepMethod)) peakDelta -= 14;\n        peakDelta -= Math.min(24, totalWalkReduction);\n        if (Number(lifestyle.sleepHours) &gt; 0 &amp;&amp; Number(lifestyle.sleepHours) &lt; 6.5) peakDelta += 12;\n        if (Number(lifestyle.stressScore) &gt;= 7) peakDelta += 10;\n\n        peakDelta = Math.max(12, peakDelta);\n        const glucoseCurve = [\n          { min: 0, optimized: baseGlucose, unoptimized: baseGlucose },\n          { min: 30, optimized: Math.round(baseGlucose + peakDelta * 0.75), unoptimized: Math.round(baseGlucose + 52) },\n          { min: 60, optimized: Math.round(baseGlucose + peakDelta), unoptimized: Math.round(baseGlucose + 68) },\n          { min: 90, optimized: Math.round(baseGlucose + peakDelta * 0.55), unoptimized: Math.round(baseGlucose + 48) },\n          { min: 120, optimized: Math.round(baseGlucose + peakDelta * 0.15), unoptimized: Math.round(baseGlucose + 29) }\n        ];\n\n        const parseTimeToMins = (t) =&gt; {\n          if (typeof t !== 'string' || !t.includes(':')) return null;\n          const parts = t.trim().split(':');\n          if (parts.length &lt; 2) return null;\n          if (parts[0].trim() === '' || parts[1].trim() === '') return null;\n          const h = Number(parts[0]);\n          const m = Number(parts[1]);\n          if (!Number.isInteger(h) || !Number.isInteger(m) || h &lt; 0 || h &gt; 23 || m &lt; 0 || m &gt; 59) return null;\n          return h * 60 + m;\n        };\n        const wakeMins = parseTimeToMins(fasting.wakeTime);\n        const firstMealMins = parseTimeToMins(fasting.firstMealTime);\n        const lastMealMins = parseTimeToMins(fasting.lastMealTime);\n        const sleepMins = parseTimeToMins(fasting.sleepTime);\n\n        const morningGapHours = wakeMins !== null &amp;&amp; firstMealMins !== null\n          ? +(((firstMealMins - wakeMins + 1440) % 1440) \/ 60).toFixed(1)\n          : null;\n        const eveningGapHours = sleepMins !== null &amp;&amp; lastMealMins !== null\n          ? +(((sleepMins - lastMealMins + 1440) % 1440) \/ 60).toFixed(1)\n          : null;\n\n        let reversalScore = 65;\n        if (homaIr !== null) {\n          if (homaIr &lt; 1.5) reversalScore += 10;\n          else if (homaIr &gt; 2.5) reversalScore -= 8;\n        }\n        if (optimalSequences.includes(nutrition.mealSequence)) reversalScore += 8;\n        if (nutrition.cookingFat === 'refined-seed') reversalScore -= 12;\n        else reversalScore += 5;\n        if (Number(nutrition.snackingCount) === 0) reversalScore += 8;\n        else if (Number(nutrition.snackingCount) &gt;= 3) reversalScore -= 10;\n        if (eveningGapHours !== null &amp;&amp; eveningGapHours &gt;= 3) reversalScore += 7;\n        if (walks.dinnerWalk) reversalScore += Math.min(10, Math.round(totalPostMealWalkMins \/ 5));\n        if (Number(lifestyle.stressScore) &lt;= 4 &amp;&amp; Number(lifestyle.sleepHours) &gt;= 7) reversalScore += 6;\n\n        reversalScore = Math.min(99, Math.max(25, reversalScore));\n\n        return {\n          bmi, whr, whtr, homaIr, tgHdlRatio, astAltRatio,\n          hba1cVal, sysBP, diaBP, altVal: alt, astVal: ast,\n          bmr, tdee, targetCalories, glucoseCurve,\n          morningGapHours, eveningGapHours, reversalScore,\n          totalPostMealWalkMins, totalWalkReduction\n        };\n      }, [profile, nutrition, fasting, activity, lifestyle]);\n\n      const nutritionTotals = useMemo(() =&gt; {\n        const safeFoods = Array.isArray(nutrition?.loggedFoods) ? nutrition.loggedFoods : [];\n        const safeWater = Array.isArray(nutrition?.waterLogs) ? nutrition.waterLogs : [];\n        const totals = safeFoods.reduce(\n          (acc, item) =&gt; ({\n            cal: Math.round(acc.cal + (Number(item?.cal) || 0)),\n            pro: +(acc.pro + (Number(item?.pro) || 0)).toFixed(1),\n            carb: +(acc.carb + (Number(item?.carb) || 0)).toFixed(1),\n            fiber: +(acc.fiber + (Number(item?.fiber) || 0)).toFixed(1),\n            fat: +(acc.fat + (Number(item?.fat) || 0)).toFixed(1),\n            sfa: +(acc.sfa + (Number(item?.sfa) || 0)).toFixed(1),\n            mufa: +(acc.mufa + (Number(item?.mufa) || 0)).toFixed(1),\n            pufa: +(acc.pufa + (Number(item?.pufa) || 0)).toFixed(1),\n            mg: Math.round(acc.mg + (Number(item?.mg) || 0)),\n            k: Math.round(acc.k + (Number(item?.k) || 0)),\n            ca: Math.round(acc.ca + (Number(item?.ca) || 0)),\n            fe: +(acc.fe + (Number(item?.fe) || 0)).toFixed(1),\n            zn: +(acc.zn + (Number(item?.zn) || 0)).toFixed(1),\n            vitC: Math.round(acc.vitC + (Number(item?.vitC) || 0)),\n            vitA: Math.round(acc.vitA + (Number(item?.vitA) || 0)),\n            vitD: Math.round(acc.vitD + (Number(item?.vitD) || 0)),\n            b12: +(acc.b12 + (Number(item?.b12) || 0)).toFixed(1),\n            folate: Math.round(acc.folate + (Number(item?.folate) || 0)),\n            choline: Math.round(acc.choline + (Number(item?.choline) || 0)),\n            leucine: +(acc.leucine + (Number(item?.leucine) || 0)).toFixed(2),\n            omega3: +(acc.omega3 + (Number(item?.omega3) || 0)).toFixed(2),\n            glycemicLoad: Math.round(acc.glycemicLoad + (Number(item?.glycemicLoad) || 0))\n          }),\n          { cal: 0, pro: 0, carb: 0, fiber: 0, fat: 0, sfa: 0, mufa: 0, pufa: 0, mg: 0, k: 0, ca: 0, fe: 0, zn: 0, vitC: 0, vitA: 0, vitD: 0, b12: 0, folate: 0, choline: 0, leucine: 0, omega3: 0, glycemicLoad: 0 }\n        );\n        const totalWaterMl = safeWater.reduce((sum, w) =&gt; sum + (Number(w?.amountMl) || 0), 0);\n        const hasPlainROWarning = safeWater.some(w =&gt; w?.source === 'Plain RO (Unmineralized)');\n\n        \/\/ Calculate % Daily Value (%DV) achieved for each key nutrient\n        const weightNum = toValidNum(profile.weightKg);\n        const dynamicProTarget = weightNum ? Math.round(weightNum * 1.2) : DAILY_VALUE_TARGETS.pro.dv;\n        const dvProgress = Object.entries(DAILY_VALUE_TARGETS).map(([key, meta]) =&gt; {\n          const target = key === 'pro' ? dynamicProTarget : meta.dv;\n          const current = Number(totals[key]) || 0;\n          const pct = target &gt; 0 ? Math.min(200, Math.round((current \/ target) * 100)) : 0;\n          return { key, ...meta, target, current, pct };\n        });\n\n        \/\/ Smart Diet-Compatible Food Recommendations for any nutrient below 60% DV\n        const activeDiet = toSafeStr(profile.dietPreference, 'lacto', 20);\n        const compatibleFoods = FOOD_DATABASE.filter(f =&gt; f.diet.includes(activeDiet));\n        const lackingNutrients = dvProgress\n          .filter(n =&gt; n.pct &lt; 60)\n          .sort((a, b) =&gt; a.pct - b.pct)\n          .slice(0, 4)\n          .map(gap =&gt; {\n            const bestFoods = [...compatibleFoods]\n              .filter(f =&gt; (Number(f[gap.key]) || 0) &gt; 0)\n              .sort((a, b) =&gt; (Number(b[gap.key]) || 0) - (Number(a[gap.key]) || 0))\n              .slice(0, 2);\n            return { ...gap, bestFoods };\n          });\n\n        return {\n          ...totals,\n          netCarbs: Math.max(0, +(totals.carb - totals.fiber).toFixed(1)),\n          totalWaterMl,\n          hasPlainROWarning,\n          dvProgress,\n          lackingNutrients\n        };\n      }, [nutrition, profile.weightKg, profile.dietPreference]);\n\n      \/\/ Interactive Single-Food Nutrient &amp; %DV Inspector State\n      const [inspectorCategory, setInspectorCategory] = useState('All');\n      const [inspectorFoodId, setInspectorFoodId] = useState('f11');\n      const [inspectorServings, setInspectorServings] = useState(1);\n\n      const filteredInspectorFoods = useMemo(() =&gt; {\n        if (inspectorCategory === 'All') return FOOD_DATABASE;\n        return FOOD_DATABASE.filter(f =&gt; f.category === inspectorCategory);\n      }, [inspectorCategory]);\n\n      const inspectedFoodMetrics = useMemo(() =&gt; {\n        const baseFood = FOOD_DATABASE.find(f =&gt; f.id === inspectorFoodId) || FOOD_DATABASE[0];\n        return {\n          baseFood,\n          ...scaleFoodItem(baseFood, inspectorServings)\n        };\n      }, [inspectorFoodId, inspectorServings]);\n\n      const addFoodToLog = (foodId, customServings = 1) =&gt; {\n        const food = FOOD_DATABASE.find(f =&gt; f.id === foodId);\n        if (!food) return;\n        const scaled = scaleFoodItem(food, customServings);\n        const scaledFood = {\n          ...scaled,\n          instanceId: makeUniqueId(),\n          name: scaled.mult === 1 ? food.name : `${food.name} (${scaled.mult}x serving)`\n        };\n        setNutrition(prev =&gt; {\n          const existing = Array.isArray(prev.loggedFoods) ? prev.loggedFoods : [];\n          if (existing.length &gt;= 150) return prev;\n          return {\n            ...prev,\n            loggedFoods: [...existing, scaledFood]\n          };\n        });\n        triggerToast(`Added ${scaledFood.name}`);\n      };\n\n      const removeFoodFromLog = (instanceId) =&gt; {\n        setNutrition(prev =&gt; ({\n          ...prev,\n          loggedFoods: (Array.isArray(prev.loggedFoods) ? prev.loggedFoods : []).filter(f =&gt; f.instanceId !== instanceId)\n        }));\n      };\n\n      const [newWater, setNewWater] = useState({ timing: 'Morning Waking', amountMl: '', source: 'Natural Mineral Water' });\n      const addWaterLog = (e) =&gt; {\n        e.preventDefault();\n        const amt = toValidNum(newWater.amountMl);\n        if (!amt) {\n          triggerToast('Please enter a valid water volume in ml');\n          return;\n        }\n        const clampedAmt = Math.min(5000, Math.round(amt));\n        setNutrition(prev =&gt; {\n          const existing = Array.isArray(prev.waterLogs) ? prev.waterLogs : [];\n          return {\n            ...prev,\n            waterLogs: [...existing.slice(-149), { ...newWater, id: makeUniqueId(), amountMl: clampedAmt }]\n          };\n        });\n        setNewWater(prev =&gt; ({ ...prev, amountMl: '' }));\n        triggerToast(`Logged ${clampedAmt}ml (${newWater.source})`);\n      };\n\n      const removeWaterFromLog = (waterId) =&gt; {\n        setNutrition(prev =&gt; ({\n          ...prev,\n          waterLogs: (Array.isArray(prev.waterLogs) ? prev.waterLogs : []).filter(w =&gt; w.id !== waterId)\n        }));\n      };\n\n      const [newWorkout, setNewWorkout] = useState({\n        type: 'Resistance Training (Hypertrophy)',\n        intensity: 'Moderate (RPE 7)',\n        durationMin: '',\n        fastedState: true,\n        preWorkoutNutrition: 'Mineral Water + Pinch of Sendha Salt \/ Black Coffee',\n        intraWorkoutHydration: '400ml Mineral \/ Electrolyte Water',\n        postWorkoutNutrition: 'High-Leucine Protein + Whole Food Carbs within 45m'\n      });\n\n      const addWorkoutLog = (e) =&gt; {\n        e.preventDefault();\n        const dur = Math.min(600, Math.round(toValidNum(newWorkout.durationMin) || 30));\n        setActivity(prev =&gt; {\n          const existing = Array.isArray(prev.workouts) ? prev.workouts : [];\n          return {\n            ...prev,\n            workouts: [...existing.slice(-99), { ...newWorkout, id: makeUniqueId(), durationMin: dur }]\n          };\n        });\n        setNewWorkout(prev =&gt; ({ ...prev, durationMin: '' }));\n        triggerToast(`Logged ${newWorkout.type} (${dur} mins)`);\n      };\n\n      const removeWorkoutFromLog = (workoutId) =&gt; {\n        setActivity(prev =&gt; ({\n          ...prev,\n          workouts: (Array.isArray(prev.workouts) ? prev.workouts : []).filter(w =&gt; w.id !== workoutId)\n        }));\n      };\n\n      const loadClinicalPreset = (presetType) =&gt; {\n        \/\/ Deep-clone the user's real inputs before entering Sample Mode so nested objects\/arrays are never mutated\n        if (activeSampleMode === null &amp;&amp; activeSampleModeRef.current === null) {\n          preSampleSnapshotRef.current = deepCloneState({\n            profile,\n            nutrition,\n            fasting,\n            activity,\n            lifestyle\n          });\n        }\n        if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n        activeSampleModeRef.current = presetType;\n        setActiveSampleMode(presetType);\n\n        if (presetType === 'reversing') {\n          setProfile(p =&gt; ({\n            ...p, alias: 'SAMPLE: Optimal Demo', age: '42', weightKg: '74', heightCm: '174', bodyFatPct: '18.5', neckCm: '37',\n            hba1c: '5.3', fastingInsulin: '4.8', fastingGlucose: '84', systolicBP: '116', diastolicBP: '74',\n            alt: '21', ast: '20', ggt: '19', triglycerides: '82', hdl: '58', waistCm: '84', hipCm: '98'\n          }));\n          setNutrition(n =&gt; ({\n            ...n, mealSequence: 'fiber-protein-carb', cookingFat: 'ghee', snackingCount: 0,\n            starchPrepMethod: 'cooled-reheated'\n          }));\n          setFasting(f =&gt; ({ ...f, protocol: '18:6', currentFastHours: 18, mealsPerDay: 2, wakeTime: '06:30', firstMealTime: '11:30', lastMealTime: '18:00', sleepTime: '22:15' }));\n          setActivity(a =&gt; ({\n            ...a,\n            postMealWalks: {\n              breakfastWalk: true, breakfastWalkMins: 15, breakfastWalkPace: 'brisk',\n              lunchWalk: true, lunchWalkMins: 20, lunchWalkPace: 'brisk',\n              dinnerWalk: true, dinnerWalkMins: 30, dinnerWalkPace: 'brisk'\n            },\n            dailySteps: 9500\n          }));\n          setLifestyle(l =&gt; ({ ...l, sleepHours: 8, stressScore: 2, wakingGlucose: '84', sunlightDurationMin: 25, skinExposurePct: 40 }));\n          triggerToast('Viewing Optimal Sample (Cloud Sync Paused)');\n        } else {\n          setProfile(p =&gt; ({\n            ...p, alias: 'SAMPLE: High-Risk Demo', age: '48', weightKg: '92', heightCm: '172', bodyFatPct: '29.5', neckCm: '41',\n            hba1c: '6.8', fastingInsulin: '22.4', fastingGlucose: '128', systolicBP: '142', diastolicBP: '92',\n            alt: '64', ast: '48', ggt: '55', triglycerides: '240', hdl: '34', waistCm: '104', hipCm: '100'\n          }));\n          setNutrition(n =&gt; ({\n            ...n, mealSequence: 'carb-first', cookingFat: 'refined-seed', snackingCount: 3,\n            starchPrepMethod: 'pressure-cooked-hot'\n          }));\n          setFasting(f =&gt; ({ ...f, protocol: '14:10', currentFastHours: 11, mealsPerDay: 4, wakeTime: '07:00', firstMealTime: '07:30', lastMealTime: '21:45', sleepTime: '23:00' }));\n          setActivity(a =&gt; ({\n            ...a,\n            postMealWalks: {\n              breakfastWalk: false, breakfastWalkMins: 15, breakfastWalkPace: 'slow',\n              lunchWalk: false, lunchWalkMins: 15, lunchWalkPace: 'slow',\n              dinnerWalk: false, dinnerWalkMins: 15, dinnerWalkPace: 'slow'\n            },\n            dailySteps: 3200\n          }));\n          setLifestyle(l =&gt; ({ ...l, sleepHours: 5.5, stressScore: 8, wakingGlucose: '128', sunlightDurationMin: 5, skinExposurePct: 10 }));\n          triggerToast('Viewing High-Risk Sample (Cloud Sync Paused)');\n        }\n      };\n\n      const exitSampleModeAndRestore = () =&gt; {\n        if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);\n        activeSampleModeRef.current = null;\n        if (preSampleSnapshotRef.current) {\n          const snap = deepCloneState(preSampleSnapshotRef.current);\n          const restoredPayload = {\n            profile: snap.profile || DEFAULT_PROFILE,\n            nutrition: snap.nutrition || DEFAULT_NUTRITION,\n            fasting: snap.fasting || DEFAULT_FASTING,\n            activity: snap.activity || DEFAULT_ACTIVITY,\n            lifestyle: snap.lifestyle || DEFAULT_LIFESTYLE\n          };\n          lastSavedJsonRef.current = JSON.stringify(restoredPayload);\n          setProfile(restoredPayload.profile);\n          setNutrition(restoredPayload.nutrition);\n          setFasting(restoredPayload.fasting);\n          setActivity(restoredPayload.activity);\n          setLifestyle(restoredPayload.lifestyle);\n          preSampleSnapshotRef.current = null;\n        } else {\n          const defaultPayload = {\n            profile: DEFAULT_PROFILE,\n            nutrition: DEFAULT_NUTRITION,\n            fasting: DEFAULT_FASTING,\n            activity: DEFAULT_ACTIVITY,\n            lifestyle: DEFAULT_LIFESTYLE\n          };\n          lastSavedJsonRef.current = JSON.stringify(defaultPayload);\n          setProfile(DEFAULT_PROFILE);\n          setNutrition(DEFAULT_NUTRITION);\n          setFasting(DEFAULT_FASTING);\n          setActivity(DEFAULT_ACTIVITY);\n          setLifestyle(DEFAULT_LIFESTYLE);\n        }\n        setActiveSampleMode(null);\n        triggerToast('Exited Sample Mode \u2014 Ready for your personal data!');\n      };\n\n      return (\n        &lt;div className=\"min-h-screen bg-slate-50 text-slate-800 font-sans pb-16\"&gt;\n          &lt;div className=\"no-print\"&gt;\n            {\/* Toast Notification *\/}\n            {toastMessage &amp;&amp; (\n              &lt;div className=\"fixed bottom-5 right-5 z-50 flex items-center gap-2.5 bg-slate-900 text-white px-4 py-3 rounded-xl shadow-2xl border border-teal-500\/40\"&gt;\n                &lt;Icon name=\"check\" className=\"w-5 h-5 text-teal-400 shrink-0\" \/&gt;\n                &lt;span className=\"text-sm font-medium\"&gt;{toastMessage}&lt;\/span&gt;\n              &lt;\/div&gt;\n            )}\n\n            {\/* Confirm Delete Cloud Data Modal *\/}\n            {confirmResetModal &amp;&amp; (\n              &lt;div className=\"fixed inset-0 z-50 bg-slate-950\/70 backdrop-blur-sm flex items-center justify-center p-4\"&gt;\n                &lt;div className=\"bg-white rounded-2xl max-w-md w-full p-6 shadow-2xl border border-slate-200 space-y-4\"&gt;\n                  &lt;div className=\"flex items-center gap-2.5 text-rose-600 font-bold text-base\"&gt;\n                    &lt;Icon name=\"alert\" className=\"w-6 h-6\" \/&gt;\n                    &lt;span&gt;Permanently Erase Cloud &amp; Local Data?&lt;\/span&gt;\n                  &lt;\/div&gt;\n                  &lt;p className=\"text-xs text-slate-600 leading-relaxed\"&gt;\n                    This will permanently delete your private health vault from both the cloud database and this browser, resetting all biomarkers and logs to blank.\n                  &lt;\/p&gt;\n                  &lt;div className=\"flex items-center justify-end gap-2 pt-2\"&gt;\n                    &lt;button\n                      type=\"button\"\n                      onClick={() =&gt; setConfirmResetModal(false)}\n                      className=\"px-4 py-2 rounded-xl text-xs font-semibold bg-slate-100 text-slate-700 hover:bg-slate-200\"\n                    &gt;\n                      Cancel\n                    &lt;\/button&gt;\n                    &lt;button\n                      type=\"button\"\n                      onClick={handleDeleteCloudData}\n                      className=\"px-4 py-2 rounded-xl text-xs font-semibold bg-rose-600 text-white hover:bg-rose-700\"\n                    &gt;\n                      Yes, Erase My Cloud Data\n                    &lt;\/button&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              &lt;\/div&gt;\n            )}\n\n            {\/* Top Header *\/}\n            &lt;header className=\"bg-gradient-to-r from-slate-900 via-teal-950 to-slate-900 text-white border-b border-teal-800\/50 sticky top-0 z-30 shadow-md\"&gt;\n              &lt;div className=\"max-w-7xl mx-auto px-4 sm:px-6 py-3.5 flex flex-wrap items-center justify-between gap-4\"&gt;\n                &lt;div className=\"flex items-center gap-3\"&gt;\n                  &lt;div className=\"w-10 h-10 rounded-xl bg-teal-500\/20 border border-teal-400\/40 flex items-center justify-center text-teal-300\"&gt;\n                    &lt;Icon name=\"activity\" className=\"w-6 h-6\" \/&gt;\n                  &lt;\/div&gt;\n                  &lt;div&gt;\n                    &lt;div className=\"flex flex-wrap items-center gap-2\"&gt;\n                      &lt;h1 className=\"text-lg sm:text-xl font-bold tracking-tight text-white\"&gt;MetabolicGuide&lt;\/h1&gt;\n                      &lt;span className=\"text-[11px] uppercase tracking-wider px-2 py-0.5 rounded bg-teal-500\/20 text-teal-300 border border-teal-400\/30 font-semibold\"&gt;\n                        GroundReportIndia Wellness Guide\n                      &lt;\/span&gt;\n                    &lt;\/div&gt;\n                    &lt;p className=\"text-xs text-slate-300 hidden sm:block\"&gt;\n                      Science-Based Nutrition &amp; Lifestyle Tracker for Insulin Sensitivity, Blood Sugar, Liver &amp; Heart Health\n                    &lt;\/p&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n\n                {\/* Cloud Sync Status + Privacy Actions + Wellness Score *\/}\n                &lt;div className=\"flex flex-wrap items-center gap-2\"&gt;\n                  {\/* Live Cloud Vault Pill *\/}\n                  &lt;div className=\"flex items-center gap-1.5 bg-slate-800\/90 px-3 py-1.5 rounded-xl border border-slate-700 text-xs\"&gt;\n                    &lt;Icon\n                      name=\"cloud\"\n                      className={`w-4 h-4 ${\n                        activeSampleMode !== null\n                          ? 'text-amber-400'\n                          : cloudStatus === 'synced'\n                          ? 'text-emerald-400'\n                          : cloudStatus === 'saving'\n                          ? 'text-amber-400 animate-pulse'\n                          : 'text-slate-400'\n                      }`}\n                    \/&gt;\n                    &lt;span className=\"font-semibold text-slate-200\"&gt;\n                      {activeSampleMode !== null\n                        ? 'Sample Mode (Cloud Paused)'\n                        : cloudStatus === 'synced'\n                        ? 'Cloud Vault Synced'\n                        : cloudStatus === 'saving'\n                        ? 'Saving to Cloud...'\n                        : cloudStatus === 'connecting'\n                        ? 'Connecting Vault...'\n                        : cloudStatus === 'unconfigured'\n                        ? 'Local Backup Active'\n                        : 'Local Vault Active'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n\n                  {\/* Privacy Controls: PDF Report, Export\/Import JSON &amp; Wipe Cloud Data *\/}\n                  &lt;button\n                    type=\"button\"\n                    onClick={handleDownloadPDF}\n                    className=\"flex items-center gap-1.5 bg-teal-600 hover:bg-teal-500 text-white px-3 py-1.5 rounded-xl border border-teal-400\/50 text-xs font-semibold shadow-sm transition\"\n                    title=\"Download Personal Summary Report (PDF)\"\n                  &gt;\n                    &lt;Icon name=\"printer\" className=\"w-3.5 h-3.5 text-white\" \/&gt;\n                    &lt;span&gt;PDF Summary&lt;\/span&gt;\n                  &lt;\/button&gt;\n\n                  &lt;button\n                    type=\"button\"\n                    onClick={handleExportBackup}\n                    className=\"flex items-center gap-1 bg-slate-800 hover:bg-teal-800 text-slate-100 px-2.5 py-1.5 rounded-xl border border-slate-600 text-xs font-medium transition\"\n                    title=\"Export Personal Backup (JSON)\"\n                  &gt;\n                    &lt;Icon name=\"download\" className=\"w-3.5 h-3.5 text-teal-400\" \/&gt;\n                    &lt;span className=\"hidden md:inline\"&gt;Export&lt;\/span&gt;\n                  &lt;\/button&gt;\n\n                  &lt;button\n                    type=\"button\"\n                    onClick={() =&gt; fileInputRef.current &amp;&amp; fileInputRef.current.click()}\n                    className=\"flex items-center gap-1 bg-slate-800 hover:bg-teal-800 text-slate-100 px-2.5 py-1.5 rounded-xl border border-slate-600 text-xs font-medium transition\"\n                    title=\"Restore Personal Backup (JSON)\"\n                  &gt;\n                    &lt;Icon name=\"upload\" className=\"w-3.5 h-3.5 text-sky-400\" \/&gt;\n                    &lt;span className=\"hidden md:inline\"&gt;Import&lt;\/span&gt;\n                  &lt;\/button&gt;\n                  &lt;input\n                    ref={fileInputRef}\n                    type=\"file\"\n                    accept=\".json,application\/json\"\n                    onChange={handleImportBackup}\n                    className=\"hidden\"\n                  \/&gt;\n\n                  &lt;button\n                    type=\"button\"\n                    onClick={() =&gt; setConfirmResetModal(true)}\n                    className=\"flex items-center gap-1 bg-rose-900\/80 hover:bg-rose-700 text-rose-100 px-2.5 py-1.5 rounded-xl border border-rose-700\/60 text-xs font-medium transition\"\n                    title=\"Delete My Cloud Data\"\n                  &gt;\n                    &lt;Icon name=\"trash\" className=\"w-3.5 h-3.5 text-rose-300\" \/&gt;\n                    &lt;span className=\"hidden md:inline\"&gt;Reset Vault&lt;\/span&gt;\n                  &lt;\/button&gt;\n\n                  {\/* Wellness Score Badge *\/}\n                  &lt;div className=\"flex items-center gap-2 bg-teal-900\/60 border border-teal-500\/40 px-3 py-1 rounded-xl\"&gt;\n                    &lt;div className=\"text-right\"&gt;\n                      &lt;div className=\"text-[10px] uppercase tracking-wider text-teal-300 font-semibold\"&gt;Metabolic Score&lt;\/div&gt;\n                      &lt;div className=\"text-sm font-bold text-white\"&gt;{clinicalMetrics.reversalScore}\/100&lt;\/div&gt;\n                    &lt;\/div&gt;\n                    &lt;div className=\"w-7 h-7 rounded-lg bg-teal-500 text-slate-950 font-extrabold flex items-center justify-center text-xs\"&gt;\n                      {clinicalMetrics.reversalScore &gt;= 75 ? 'A' : clinicalMetrics.reversalScore &gt;= 55 ? 'B' : 'C'}\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              &lt;\/div&gt;\n\n              {\/* Biomarker Ribbon *\/}\n              &lt;div className=\"bg-slate-900\/80 border-t border-slate-800\/80\"&gt;\n                &lt;div className=\"max-w-7xl mx-auto px-4 sm:px-6 py-2 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 text-xs\"&gt;\n                  &lt;div className=\"flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60\"&gt;\n                    &lt;span className=\"text-slate-400\"&gt;HOMA-IR:&lt;\/span&gt;\n                    &lt;span className={`font-bold ${clinicalMetrics.homaIr === null ? 'text-slate-400' : clinicalMetrics.homaIr &lt; 1.5 ? 'text-emerald-400' : clinicalMetrics.homaIr &lt; 2.5 ? 'text-amber-400' : 'text-rose-400'}`}&gt;\n                      {clinicalMetrics.homaIr !== null ? `${clinicalMetrics.homaIr} ${clinicalMetrics.homaIr &lt; 1.5 ? '(Sensitive)' : '(Resistant)'}` : '\u2014'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n                  &lt;div className=\"flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60\"&gt;\n                    &lt;span className=\"text-slate-400\"&gt;HbA1c:&lt;\/span&gt;\n                    &lt;span className={`font-bold ${clinicalMetrics.hba1cVal === null ? 'text-slate-400' : clinicalMetrics.hba1cVal &lt; 5.7 ? 'text-emerald-400' : clinicalMetrics.hba1cVal &lt; 6.5 ? 'text-amber-400' : 'text-rose-400'}`}&gt;\n                      {clinicalMetrics.hba1cVal !== null ? `${clinicalMetrics.hba1cVal}%` : '\u2014'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n                  &lt;div className=\"flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60\"&gt;\n                    &lt;span className=\"text-slate-400\"&gt;TG:HDL Ratio:&lt;\/span&gt;\n                    &lt;span className={`font-bold ${clinicalMetrics.tgHdlRatio === null ? 'text-slate-400' : clinicalMetrics.tgHdlRatio &lt; 2.0 ? 'text-emerald-400' : 'text-rose-400'}`}&gt;\n                      {clinicalMetrics.tgHdlRatio !== null ? clinicalMetrics.tgHdlRatio : '\u2014'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n                  &lt;div className=\"flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60\"&gt;\n                    &lt;span className=\"text-slate-400\"&gt;Waist-to-Hip:&lt;\/span&gt;\n                    &lt;span className={`font-bold ${clinicalMetrics.whr === null ? 'text-slate-400' : (profile.gender === 'male' ? clinicalMetrics.whr &lt; 0.9 : clinicalMetrics.whr &lt; 0.85) ? 'text-emerald-400' : 'text-amber-400'}`}&gt;\n                      {clinicalMetrics.whr !== null ? clinicalMetrics.whr : '\u2014'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n                  &lt;div className=\"flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60\"&gt;\n                    &lt;span className=\"text-slate-400\"&gt;Liver ALT:&lt;\/span&gt;\n                    &lt;span className={`font-bold ${clinicalMetrics.altVal === null ? 'text-slate-400' : clinicalMetrics.altVal &lt;= 30 ? 'text-emerald-400' : 'text-amber-400'}`}&gt;\n                      {clinicalMetrics.altVal !== null ? `${clinicalMetrics.altVal} U\/L` : '\u2014'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n                  &lt;div className=\"flex items-center justify-between bg-slate-800\/60 px-3 py-1.5 rounded-lg border border-slate-700\/60\"&gt;\n                    &lt;span className=\"text-slate-400\"&gt;BP:&lt;\/span&gt;\n                    &lt;span className={`font-bold ${clinicalMetrics.sysBP === null || clinicalMetrics.diaBP === null ? 'text-slate-400' : clinicalMetrics.sysBP &lt;= 120 &amp;&amp; clinicalMetrics.diaBP &lt;= 80 ? 'text-emerald-400' : 'text-amber-400'}`}&gt;\n                      {clinicalMetrics.sysBP !== null &amp;&amp; clinicalMetrics.diaBP !== null ? `${clinicalMetrics.sysBP}\/${clinicalMetrics.diaBP}` : '\u2014'}\n                    &lt;\/span&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              &lt;\/div&gt;\n            &lt;\/header&gt;\n\n            {\/* Navigation Tabs *\/}\n            &lt;div className=\"max-w-7xl mx-auto px-4 sm:px-6 pt-5\"&gt;\n              &lt;div className=\"flex flex-wrap items-center justify-between gap-2 mb-3\"&gt;\n                &lt;nav className=\"flex flex-wrap gap-1.5 bg-white p-1.5 rounded-2xl shadow-sm border border-slate-200 flex-1\"&gt;\n                  {[\n                    { id: 'profile', label: '1. Profile &amp; Biomarkers', icon: 'userCheck' },\n                    { id: 'nutrition', label: '2. Nutrition, Sequencing &amp; RS3', icon: 'utensils' },\n                    { id: 'fasting', label: '3. Fasting &amp; Circadian', icon: 'clock' },\n                    { id: 'activity', label: '4. Exercise &amp; Walk', icon: 'footprints' },\n                    { id: 'lifestyle', label: '5. Sunlight, Sleep &amp; Stress', icon: 'sun' },\n                    { id: 'insights', label: '6. Science-Based Action Guide', icon: 'brain' }\n                  ].map(tab =&gt; {\n                    const active = activeTab === tab.id;\n                    return (\n                      &lt;button\n                        key={tab.id}\n                        type=\"button\"\n                        onClick={() =&gt; setActiveTab(tab.id)}\n                        className={`flex items-center gap-2 px-3 py-2 rounded-xl text-xs sm:text-sm font-semibold transition-all flex-1 sm:flex-initial justify-center ${\n                          active\n                            ? 'bg-teal-600 text-white shadow-sm'\n                            : 'text-slate-600 hover:bg-teal-50 hover:text-teal-800'\n                        }`}\n                      &gt;\n                        &lt;Icon name={tab.icon} className=\"w-4 h-4 shrink-0\" \/&gt;\n                        &lt;span&gt;{tab.label}&lt;\/span&gt;\n                      &lt;\/button&gt;\n                    );\n                  })}\n                &lt;\/nav&gt;\n\n                {\/* Quick Demo Presets *\/}\n                &lt;div className=\"flex items-center gap-1.5 bg-white px-3 py-2 rounded-2xl border border-slate-200 text-xs shadow-sm\"&gt;\n                  &lt;span className=\"text-slate-500 font-medium\"&gt;Preview Demo Only:&lt;\/span&gt;\n                  &lt;button\n                    type=\"button\"\n                    onClick={() =&gt; loadClinicalPreset('high-risk')}\n                    className={`px-2 py-1 rounded-lg font-semibold transition ${\n                      activeSampleMode === 'high-risk'\n                        ? 'bg-rose-600 text-white'\n                        : 'bg-rose-50 text-rose-700 hover:bg-rose-100'\n                    }`}\n                  &gt;\n                    High-Risk Sample\n                  &lt;\/button&gt;\n                  &lt;button\n                    type=\"button\"\n                    onClick={() =&gt; loadClinicalPreset('reversing')}\n                    className={`px-2 py-1 rounded-lg font-semibold transition ${\n                      activeSampleMode === 'reversing'\n                        ? 'bg-emerald-600 text-white'\n                        : 'bg-emerald-50 text-emerald-700 hover:bg-emerald-100'\n                    }`}\n                  &gt;\n                    Optimal Sample\n                  &lt;\/button&gt;\n                  {activeSampleMode !== null &amp;&amp; (\n                    &lt;button\n                      type=\"button\"\n                      onClick={exitSampleModeAndRestore}\n                      className=\"px-2.5 py-1 rounded-lg bg-amber-500 hover:bg-amber-600 text-white font-bold shadow-sm transition\"\n                    &gt;\n                      \u2715 Exit Sample\n                    &lt;\/button&gt;\n                  )}\n                &lt;\/div&gt;\n              &lt;\/div&gt;\n\n              {\/* High-Visibility Sample Mode Protection Banner *\/}\n              {activeSampleMode !== null &amp;&amp; (\n                &lt;div className=\"mb-3 p-3.5 rounded-2xl bg-amber-50 border-2 border-amber-400 shadow-sm flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3\"&gt;\n                  &lt;div className=\"flex items-start sm:items-center gap-2.5 text-xs text-amber-950\"&gt;\n                    &lt;Icon name=\"alert\" className=\"w-5 h-5 text-amber-600 shrink-0 mt-0.5 sm:mt-0\" \/&gt;\n                    &lt;div&gt;\n                      &lt;span className=\"font-extrabold uppercase tracking-wide text-amber-900 block sm:inline mr-1.5\"&gt;\n                        Sample Demo Mode Active (Not Saved to Cloud):\n                      &lt;\/span&gt;\n                      &lt;span&gt;\n                        You are viewing example numbers ({activeSampleMode === 'high-risk' ? 'High-Risk Sample' : 'Optimal Sample'}). Your personal Cloud Vault has &lt;strong&gt;not&lt;\/strong&gt; been overwritten.\n                      &lt;\/span&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n                  &lt;button\n                    type=\"button\"\n                    onClick={exitSampleModeAndRestore}\n                    className=\"px-4 py-2 rounded-xl bg-amber-600 hover:bg-amber-700 text-white text-xs font-bold shrink-0 shadow-sm transition\"\n                  &gt;\n                    Exit Sample &amp;amp; Enter My Own Data\n                  &lt;\/button&gt;\n                &lt;\/div&gt;\n              )}\n            &lt;\/div&gt;\n\n            &lt;main className=\"max-w-7xl mx-auto px-4 sm:px-6 py-4\"&gt;\n              {activeTab === 'profile' &amp;&amp; (\n                &lt;div className=\"grid grid-cols-1 lg:grid-cols-3 gap-6\"&gt;\n                  {\/* Anthropometrics &amp; Pseudonymous Alias *\/}\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200\"&gt;\n                    &lt;div className=\"flex items-center justify-between mb-4\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2\"&gt;\n                        &lt;Icon name=\"userCheck\" className=\"w-5 h-5 text-teal-600\" \/&gt;\n                        Pseudonymous Profile &amp; Biometrics\n                      &lt;\/h2&gt;\n                      &lt;StatusBadge\n                        status={clinicalMetrics.whr === null ? 'info' : clinicalMetrics.whr &gt; (profile.gender === 'male' ? 0.9 : 0.85) ? 'warning' : 'optimal'}\n                        label={clinicalMetrics.whr !== null ? `WHR: ${clinicalMetrics.whr}` : 'WHR: \u2014'}\n                      \/&gt;\n                    &lt;\/div&gt;\n                      &lt;div className=\"space-y-3.5 text-sm\"&gt;\n                      &lt;div&gt;\n                        &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;\n                          Profile Alias \/ Nickname (Privacy-Safe: Do Not Use Legal Name)\n                        &lt;\/label&gt;\n                        &lt;input\n                          type=\"text\"\n                          maxLength={40}\n                          value={profile.alias}\n                          onChange={e =&gt; setProfile({ ...profile, alias: e.target.value.slice(0, 40) })}\n                          placeholder=\"e.g., Reader-01\"\n                          className=\"w-full px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 focus:outline-none\"\n                        \/&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Age (Years)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"1\"\n                            max=\"120\"\n                            value={profile.age}\n                            onChange={e =&gt; setProfile({ ...profile, age: parseInputNum(e.target.value, 0, 120) })}\n                            placeholder=\"e.g., 40\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Biological Sex&lt;\/label&gt;\n                          &lt;select\n                            value={profile.gender}\n                            onChange={e =&gt; setProfile({ ...profile, gender: e.target.value })}\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300 bg-white\"\n                          &gt;\n                            &lt;option value=\"male\"&gt;Male&lt;\/option&gt;\n                            &lt;option value=\"female\"&gt;Female&lt;\/option&gt;\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Weight (kg)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"1\"\n                            max=\"400\"\n                            step=\"0.5\"\n                            value={profile.weightKg}\n                            onChange={e =&gt; setProfile({ ...profile, weightKg: parseInputNum(e.target.value, 0, 400) })}\n                            placeholder=\"e.g., 75\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Height (cm)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"50\"\n                            max=\"260\"\n                            value={profile.heightCm}\n                            onChange={e =&gt; setProfile({ ...profile, heightCm: parseInputNum(e.target.value, 0, 260) })}\n                            placeholder=\"e.g., 170\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Waist Circumference (cm)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"30\"\n                            max=\"250\"\n                            value={profile.waistCm}\n                            onChange={e =&gt; setProfile({ ...profile, waistCm: parseInputNum(e.target.value, 0, 250) })}\n                            placeholder=\"e.g., 88\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;\n                            Hip Circumference (cm) &lt;Tooltip text={CLINICAL_TOOLTIPS.whr} \/&gt;\n                          &lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"30\"\n                            max=\"250\"\n                            value={profile.hipCm}\n                            onChange={e =&gt; setProfile({ ...profile, hipCm: parseInputNum(e.target.value, 0, 250) })}\n                            placeholder=\"e.g., 98\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Body Fat (%)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"2\"\n                            max=\"75\"\n                            step=\"0.5\"\n                            value={profile.bodyFatPct}\n                            onChange={e =&gt; setProfile({ ...profile, bodyFatPct: parseInputNum(e.target.value, 0, 75) })}\n                            placeholder=\"Optional\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Neck (cm)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"15\"\n                            max=\"80\"\n                            value={profile.neckCm}\n                            onChange={e =&gt; setProfile({ ...profile, neckCm: parseInputNum(e.target.value, 0, 80) })}\n                            placeholder=\"Optional\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"pt-2 border-t border-slate-100\"&gt;\n                        &lt;label className=\"block text-xs font-semibold text-slate-700 mb-1\"&gt;Primary Dietary Preference&lt;\/label&gt;\n                        &lt;select\n                          value={profile.dietPreference}\n                          onChange={e =&gt; setProfile({ ...profile, dietPreference: e.target.value })}\n                          className=\"w-full px-3 py-2.5 rounded-xl border border-teal-300 bg-teal-50\/50 text-slate-900 font-medium\"\n                        &gt;\n                          &lt;option value=\"vegan\"&gt;Pure Vegetarian (Vegan - Plant Only)&lt;\/option&gt;\n                          &lt;option value=\"lacto\"&gt;Vegetarian Lacto (Plants, Dairy &amp;amp; Honey)&lt;\/option&gt;\n                          &lt;option value=\"ovo\"&gt;Vegetarian Ovo-Lacto (Plants, Dairy, Honey &amp;amp; Egg)&lt;\/option&gt;\n                          &lt;option value=\"omni\"&gt;Meat, Fish, Eggs, Dairy &amp;amp; Plants (Omnivore)&lt;\/option&gt;\n                        &lt;\/select&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  {\/* Glycemic &amp; Endocrine Baselines *\/}\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200\"&gt;\n                    &lt;div className=\"flex items-center justify-between mb-4\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2\"&gt;\n                        &lt;Icon name=\"droplet\" className=\"w-5 h-5 text-rose-600\" \/&gt;\n                        Endocrine &amp; Glycemic Labs\n                      &lt;\/h2&gt;\n                      &lt;StatusBadge\n                        status={clinicalMetrics.homaIr === null ? 'info' : clinicalMetrics.homaIr &lt; 1.5 ? 'optimal' : clinicalMetrics.homaIr &lt; 2.9 ? 'warning' : 'critical'}\n                        label={clinicalMetrics.homaIr !== null ? `HOMA-IR: ${clinicalMetrics.homaIr}` : 'HOMA-IR: \u2014'}\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    &lt;div className=\"space-y-3.5 text-sm\"&gt;\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;HbA1c (%)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"3\"\n                            max=\"25\"\n                            step=\"0.1\"\n                            value={profile.hba1c}\n                            onChange={e =&gt; setProfile({ ...profile, hba1c: parseInputNum(e.target.value, 0, 25) })}\n                            placeholder=\"e.g., 5.6\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                          &lt;span className=\"text-[11px] text-slate-400\"&gt;Optimal: &amp;lt;5.4%&lt;\/span&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;\n                            Fasting Insulin (\u03bcIU\/mL) &lt;Tooltip text={CLINICAL_TOOLTIPS.homaIr} \/&gt;\n                          &lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"0.5\"\n                            max=\"300\"\n                            step=\"0.5\"\n                            value={profile.fastingInsulin}\n                            onChange={e =&gt; setProfile({ ...profile, fastingInsulin: parseInputNum(e.target.value, 0, 300) })}\n                            placeholder=\"e.g., 6.0\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                          &lt;span className=\"text-[11px] text-slate-400\"&gt;Optimal: 2 - 6 \u03bcIU\/mL&lt;\/span&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Fasting Glucose (mg\/dL)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"30\"\n                            max=\"600\"\n                            value={profile.fastingGlucose}\n                            onChange={e =&gt; setProfile({ ...profile, fastingGlucose: parseInputNum(e.target.value, 0, 600) })}\n                            placeholder=\"e.g., 90\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Triglycerides (mg\/dL)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"20\"\n                            max=\"1500\"\n                            value={profile.triglycerides}\n                            onChange={e =&gt; setProfile({ ...profile, triglycerides: parseInputNum(e.target.value, 0, 1500) })}\n                            placeholder=\"e.g., 110\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;HDL Cholesterol (mg\/dL)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"10\"\n                            max=\"200\"\n                            value={profile.hdl}\n                            onChange={e =&gt; setProfile({ ...profile, hdl: parseInputNum(e.target.value, 0, 200) })}\n                            placeholder=\"e.g., 50\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-slate-50 p-2.5 rounded-xl border border-slate-200 flex flex-col justify-center\"&gt;\n                          &lt;span className=\"text-[11px] text-slate-500 font-medium\"&gt;Calculated HOMA-IR&lt;\/span&gt;\n                          &lt;span className=\"text-lg font-extrabold text-slate-900\"&gt;\n                            {clinicalMetrics.homaIr !== null ? clinicalMetrics.homaIr : '\u2014'}\n                          &lt;\/span&gt;\n                          &lt;span className=\"text-[11px] text-teal-700 font-medium\"&gt;\n                            {clinicalMetrics.homaIr === null\n                              ? 'Enter Insulin &amp; Glucose'\n                              : clinicalMetrics.homaIr &lt; 1.5\n                              ? 'Insulin Sensitive'\n                              : 'Insulin Resistant'}\n                          &lt;\/span&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"p-3.5 rounded-xl bg-teal-50\/70 border border-teal-200 text-xs text-slate-700 space-y-1\"&gt;\n                        &lt;div className=\"font-bold text-teal-900\"&gt;Early Detection Insight:&lt;\/div&gt;\n                        &lt;p&gt;\n                          Fasting glucose is the last marker to rise before Type 2 Diabetes. Tracking &lt;strong&gt;HOMA-IR ({clinicalMetrics.homaIr !== null ? clinicalMetrics.homaIr : '\u2014'})&lt;\/strong&gt; and &lt;strong&gt;TG:HDL ratio ({clinicalMetrics.tgHdlRatio !== null ? clinicalMetrics.tgHdlRatio : '\u2014'})&lt;\/strong&gt; reveals hyperinsulinemia up to a decade earlier.\n                        &lt;\/p&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  {\/* Cardiovascular &amp; Hepatic (NAFLD) Panel *\/}\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200\"&gt;\n                    &lt;div className=\"flex items-center justify-between mb-4\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2\"&gt;\n                        &lt;Icon name=\"heart\" className=\"w-5 h-5 text-indigo-600\" \/&gt;\n                        Cardiovascular &amp; Hepatic (NAFLD)\n                      &lt;\/h2&gt;\n                      &lt;StatusBadge\n                        status={clinicalMetrics.altVal === null &amp;&amp; clinicalMetrics.sysBP === null ? 'info' : (clinicalMetrics.altVal === null || clinicalMetrics.altVal &lt;= 30) &amp;&amp; (clinicalMetrics.sysBP === null || clinicalMetrics.sysBP &lt;= 125) ? 'optimal' : 'warning'}\n                        label={clinicalMetrics.altVal === null &amp;&amp; clinicalMetrics.sysBP === null ? 'Enter Labs' : clinicalMetrics.altVal !== null &amp;&amp; clinicalMetrics.altVal &gt; 35 ? 'Elevated ALT' : 'Hepatic Stable'}\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    &lt;div className=\"space-y-3.5 text-sm\"&gt;\n                      &lt;div className=\"grid grid-cols-2 gap-3\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Systolic BP (mmHg)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"50\"\n                            max=\"300\"\n                            value={profile.systolicBP}\n                            onChange={e =&gt; setProfile({ ...profile, systolicBP: parseInputNum(e.target.value, 0, 300) })}\n                            placeholder=\"e.g., 120\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;Diastolic BP (mmHg)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"30\"\n                            max=\"200\"\n                            value={profile.diastolicBP}\n                            onChange={e =&gt; setProfile({ ...profile, diastolicBP: parseInputNum(e.target.value, 0, 200) })}\n                            placeholder=\"e.g., 80\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-3 gap-2.5\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;ALT (U\/L)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"1\"\n                            max=\"1000\"\n                            value={profile.alt}\n                            onChange={e =&gt; setProfile({ ...profile, alt: parseInputNum(e.target.value, 0, 1000) })}\n                            placeholder=\"e.g., 25\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;AST (U\/L)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"1\"\n                            max=\"1000\"\n                            value={profile.ast}\n                            onChange={e =&gt; setProfile({ ...profile, ast: parseInputNum(e.target.value, 0, 1000) })}\n                            placeholder=\"e.g., 22\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block text-xs font-semibold text-slate-600 mb-1\"&gt;GGT (U\/L)&lt;\/label&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"1\"\n                            max=\"1000\"\n                            value={profile.ggt}\n                            onChange={e =&gt; setProfile({ ...profile, ggt: parseInputNum(e.target.value, 0, 1000) })}\n                            placeholder=\"e.g., 20\"\n                            className=\"w-full px-3 py-2 rounded-xl border border-slate-300\"\n                          \/&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"grid grid-cols-2 gap-2.5 pt-2\"&gt;\n                        &lt;div className=\"p-3 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                          &lt;div className=\"text-[11px] text-slate-500\"&gt;Waist-to-Height Ratio&lt;\/div&gt;\n                          &lt;div className=\"text-base font-bold text-slate-900\"&gt;\n                            {clinicalMetrics.whtr !== null ? clinicalMetrics.whtr : '\u2014'}\n                          &lt;\/div&gt;\n                          &lt;div className=\"text-[11px] text-slate-500\"&gt;Target: &amp;lt; 0.50&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"p-3 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                          &lt;div className=\"text-[11px] text-slate-500\"&gt;Target Caloric Intake&lt;\/div&gt;\n                          &lt;div className=\"text-base font-bold text-teal-700\"&gt;\n                            {clinicalMetrics.targetCalories &gt; 0 ? `${clinicalMetrics.targetCalories} kcal` : '\u2014'}\n                          &lt;\/div&gt;\n                          &lt;div className=\"text-[11px] text-slate-500\"&gt;\n                            TDEE: {clinicalMetrics.tdee &gt; 0 ? `${clinicalMetrics.tdee} kcal` : 'Enter Weight\/Height'}\n                          &lt;\/div&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  {\/* Explicit Calculate, Save &amp; Action Bar for User Confidence *\/}\n                  &lt;div className=\"lg:col-span-3 bg-teal-50\/90 border border-teal-200 rounded-2xl p-4 flex flex-col sm:flex-row items-center justify-between gap-4 shadow-sm\"&gt;\n                    &lt;div className=\"flex items-center gap-3\"&gt;\n                      &lt;div className=\"w-9 h-9 rounded-xl bg-teal-600 text-white flex items-center justify-center shrink-0\"&gt;\n                        &lt;Icon name=\"check\" className=\"w-5 h-5\" \/&gt;\n                      &lt;\/div&gt;\n                      &lt;div className=\"text-xs text-slate-700\"&gt;\n                        &lt;span className=\"font-bold text-slate-900 block\"&gt;Live Auto-Calculation &amp; Cloud Sync Active&lt;\/span&gt;\n                        Your biomarkers (HOMA-IR, WHR, TG:HDL, BMR\/TDEE) calculate automatically as you type, or click the button to confirm &amp; save manually.\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                    &lt;div className=\"flex flex-wrap items-center gap-2.5 shrink-0 w-full sm:w-auto justify-end\"&gt;\n                      &lt;button\n                        type=\"button\"\n                        onClick={() =&gt; triggerToast('Biomarkers calculated &amp; saved to your vault!')}\n                        className=\"px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-500 text-white text-xs font-bold shadow-sm transition flex items-center gap-1.5\"\n                      &gt;\n                        &lt;Icon name=\"check\" className=\"w-4 h-4\" \/&gt;\n                        &lt;span&gt;Calculate &amp;amp; Save Profile&lt;\/span&gt;\n                      &lt;\/button&gt;\n                      &lt;button\n                        type=\"button\"\n                        onClick={() =&gt; setActiveTab('insights')}\n                        className=\"px-4 py-2.5 rounded-xl bg-white hover:bg-teal-100 text-teal-800 border border-teal-300 text-xs font-bold transition\"\n                      &gt;\n                        View Action Guide \u2192\n                      &lt;\/button&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              )}\n\n              {\/* TAB 2: NUTRITION, SEQUENCING &amp; RS3 *\/}\n              {activeTab === 'nutrition' &amp;&amp; (\n                &lt;div className=\"space-y-6\"&gt;\n                  &lt;div className=\"grid grid-cols-1 lg:grid-cols-3 gap-6\"&gt;\n                    {\/* Meal Sequencing *\/}\n                    &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2 mb-2\"&gt;\n                        &lt;Icon name=\"trendingDown\" className=\"w-5 h-5 text-teal-600\" \/&gt;\n                        Meal Sequencing\n                        &lt;Tooltip text={CLINICAL_TOOLTIPS.mealSequencing} \/&gt;\n                      &lt;\/h2&gt;\n                      &lt;div className=\"space-y-2 mb-4 max-h-64 overflow-y-auto pr-1\"&gt;\n                        {[\n                          { id: 'fiber-protein-carb', title: '1. Fiber\/Veg \u2192 2. Protein\/Fat \u2192 3. Carbs Last', desc: 'Forms viscous fiber matrix; flattens post-meal glucose spike by up to 73%.' },\n                          { id: 'protein-fiber-carb-lemon', title: '1. Protein\/Fat \u2192 2. Fiber\/Veg \u2192 3. Carbs \u2192 4. Whole Lemon (Skin, Seeds &amp; Juice)', desc: 'Stimulates early GLP-1\/GIP incretins; whole lemon pectin, citric acid &amp; polyphenols blunt starch digestion.' },\n                          { id: 'fiber-protein-carb-lemon', title: '1. Fiber\/Veg \u2192 2. Protein\/Fat \u2192 3. Carbs \u2192 4. Whole Lemon (Skin, Seeds &amp; Juice)', desc: 'Combines duodenal fiber mesh with citrus alpha-amylase inhibition &amp; eriocitrin liver support.' },\n                          { id: 'lemon-fiber-protein-carb', title: '1. Whole Lemon (Skin, Seeds &amp; Juice) \u2192 2. Fiber\/Veg \u2192 3. Protein\/Fat \u2192 4. Carbs', desc: 'Pre-meal citric acid &amp; citrus bioflavonoids prime gastric pH and slow starch breakdown.' },\n                          { id: 'mixed', title: 'Mixed Thali \/ Bowl Eaten Together', desc: 'Moderate gastric emptying and standard glucose response.' },\n                          { id: 'carb-first', title: 'Carbs\/Rice\/Bread First on Empty Stomach', desc: 'Rapid glucose excursion &amp; reactive insulin surge.' }\n                        ].map(seq =&gt; (\n                          &lt;button\n                            key={seq.id}\n                            type=\"button\"\n                            onClick={() =&gt; setNutrition({ ...nutrition, mealSequence: seq.id })}\n                            className={`w-full text-left p-2.5 rounded-xl border transition ${\n                              nutrition.mealSequence === seq.id\n                                ? 'bg-teal-50 border-teal-500 ring-1 ring-teal-500'\n                                : 'border-slate-200 hover:bg-teal-50\/60 hover:border-teal-300'\n                            }`}\n                          &gt;\n                            &lt;div className=\"text-xs font-bold text-slate-900\"&gt;{seq.title}&lt;\/div&gt;\n                            &lt;div className=\"text-[11px] text-slate-600\"&gt;{seq.desc}&lt;\/div&gt;\n                          &lt;\/button&gt;\n                        ))}\n                      &lt;\/div&gt;\n\n                      {\/* Simulated Glucose Curve *\/}\n                      &lt;div className=\"bg-slate-900 text-white p-3.5 rounded-xl\"&gt;\n                        &lt;div className=\"flex justify-between text-xs mb-2\"&gt;\n                          &lt;span className=\"font-semibold text-teal-300\"&gt;2-Hour Post-Meal Glucose Curve&lt;\/span&gt;\n                          &lt;span className=\"text-[11px] text-slate-400\"&gt;Peak: {clinicalMetrics.glucoseCurve[2].optimized} mg\/dL&lt;\/span&gt;\n                        &lt;\/div&gt;\n                        &lt;svg viewBox=\"0 0 260 90\" className=\"w-full h-20 overflow-visible\"&gt;\n                          &lt;line x1=\"0\" y1=\"20\" x2=\"260\" y2=\"20\" stroke=\"#334155\" strokeDasharray=\"3 3\" strokeWidth=\"1\" \/&gt;\n                          &lt;polyline\n                            fill=\"none\"\n                            stroke=\"#f43f5e\"\n                            strokeWidth=\"1.8\"\n                            strokeDasharray=\"4 3\"\n                            points={clinicalMetrics.glucoseCurve.map((pt, idx) =&gt; `${idx * 62},${Math.min(88, Math.max(5, 85 - (pt.unoptimized - 70) * 0.65))}`).join(' ')}\n                          \/&gt;\n                          &lt;polyline\n                            fill=\"none\"\n                            stroke=\"#2dd4bf\"\n                            strokeWidth=\"2.5\"\n                            points={clinicalMetrics.glucoseCurve.map((pt, idx) =&gt; `${idx * 62},${Math.min(88, Math.max(5, 85 - (pt.optimized - 70) * 0.65))}`).join(' ')}\n                          \/&gt;\n                        &lt;\/svg&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n\n                    {\/* Resistant Starch RS3 Module *\/}\n                    &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2 mb-2\"&gt;\n                        &lt;Icon name=\"flame\" className=\"w-5 h-5 text-amber-500\" \/&gt;\n                        Resistant Starch (RS3) Prep (Rice &amp;amp; Potato)\n                        &lt;Tooltip text={CLINICAL_TOOLTIPS.resistantStarch} \/&gt;\n                      &lt;\/h2&gt;\n                      &lt;div className=\"space-y-2 mb-3 max-h-64 overflow-y-auto pr-1\"&gt;\n                        {[\n                          { id: 'cooled-reheated', label: 'Rice: Cooked \u2192 Cooled 12-24h at 4\u00b0C \u2192 Reheated', badge: '-35% GI Spike', good: true },\n                          { id: 'potato-cooled-rs3', label: 'Potato: Boiled \u2192 Cooled 12-24h at 4\u00b0C (Potato Salad \/ Gently Reheated)', badge: '-40% GI \/ High RS3', good: true },\n                          { id: 'vinegar-added', label: 'Rice\/Potato Paired with Whole Lemon (Skin, Seeds &amp; Juice) \/ ACV + A2 Ghee', badge: '-30% Spike', good: true },\n                          { id: 'green-banana-legume', label: 'Raw Green Banana \/ Sprouted Lentils \/ Cooled Oats (RS2 + RS3)', badge: 'Prebiotic Butyrate', good: true },\n                          { id: 'fermented', label: 'Fermented Batter \/ Sprouted Legumes &amp; Millets', badge: 'Low GI', good: true },\n                          { id: 'pressure-cooked-hot', label: 'Freshly Boiled\/Mashed Piping Hot Potato or Rice', badge: 'High Spike', good: false }\n                        ].map(m =&gt; (\n                          &lt;button\n                            key={m.id}\n                            type=\"button\"\n                            onClick={() =&gt; setNutrition({ ...nutrition, starchPrepMethod: m.id })}\n                            className={`w-full text-left p-2.5 rounded-xl border flex items-center justify-between gap-2 transition ${\n                              nutrition.starchPrepMethod === m.id\n                                ? 'bg-amber-50 border-amber-500'\n                                : 'border-slate-200 hover:bg-amber-50\/50 hover:border-amber-300'\n                            }`}\n                          &gt;\n                            &lt;span className=\"text-xs font-medium text-slate-800\"&gt;{m.label}&lt;\/span&gt;\n                            &lt;span className={`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 ${m.good ? 'bg-emerald-100 text-emerald-800' : 'bg-rose-100 text-rose-800'}`}&gt;\n                              {m.badge}\n                            &lt;\/span&gt;\n                          &lt;\/button&gt;\n                        ))}\n                      &lt;\/div&gt;\n                      &lt;p className=\"text-[11px] text-slate-600 bg-amber-50\/60 p-2.5 rounded-xl border border-amber-200\/80\"&gt;\n                        &lt;strong&gt;Potato RS3 Tip:&lt;\/strong&gt; Freshly boiled hot potatoes have a high Glycemic Index (~78\u201385). Refrigerating boiled potatoes at 4\u00b0C for 12\u201324 hours retrogrades gelatinized starch into &lt;strong&gt;Type 3 Resistant Starch (RS3)&lt;\/strong&gt;, cutting the glycemic load by ~40% while feeding colonic butyrate bacteria.\n                      &lt;\/p&gt;\n                    &lt;\/div&gt;\n\n                    {\/* Cooking Oils &amp; Grazing *\/}\n                    &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-4\"&gt;\n                      &lt;div&gt;\n                        &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2 mb-2\"&gt;\n                          Cooking Lipids &amp; Grazing\n                          &lt;Tooltip text={CLINICAL_TOOLTIPS.cookingOils} \/&gt;\n                        &lt;\/h2&gt;\n                        &lt;select\n                          value={nutrition.cookingFat}\n                          onChange={e =&gt; setNutrition({ ...nutrition, cookingFat: e.target.value })}\n                          className=\"w-full px-3 py-2.5 rounded-xl border border-slate-300 text-xs font-semibold bg-white\"\n                        &gt;\n                          &lt;option value=\"ghee\"&gt;A2 Cultured Ghee \/ Clarified Butter&lt;\/option&gt;\n                          &lt;option value=\"cold-pressed\"&gt;Cold-Pressed Coconut \/ Mustard \/ Olive Oil&lt;\/option&gt;\n                          &lt;option value=\"butter\"&gt;Grass-Fed Butter&lt;\/option&gt;\n                          &lt;option value=\"refined-seed\"&gt;Refined Seed Oils (Soybean, Sunflower, Canola)&lt;\/option&gt;\n                        &lt;\/select&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"pt-3 border-t border-slate-200\"&gt;\n                        &lt;div className=\"flex items-center justify-between mb-2\"&gt;\n                          &lt;span className=\"text-xs font-bold text-slate-800 flex items-center\"&gt;\n                            Daily Snacking \/ Grazing &lt;Tooltip text={CLINICAL_TOOLTIPS.grazing} \/&gt;\n                          &lt;\/span&gt;\n                          &lt;StatusBadge\n                            status={nutrition.snackingCount === 0 ? 'optimal' : nutrition.snackingCount === 1 ? 'warning' : 'critical'}\n                            label={`${nutrition.snackingCount} Snacks`}\n                          \/&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"grid grid-cols-4 gap-1.5\"&gt;\n                          {[0, 1, 2, 3].map(cnt =&gt; (\n                            &lt;button\n                              key={cnt}\n                              type=\"button\"\n                              onClick={() =&gt; setNutrition({ ...nutrition, snackingCount: cnt })}\n                              className={`py-1.5 rounded-xl text-xs font-bold border transition ${\n                                nutrition.snackingCount === cnt\n                                  ? 'bg-teal-600 text-white border-teal-600'\n                                  : 'bg-slate-50 text-slate-700 border-slate-200 hover:bg-slate-100'\n                              }`}\n                            &gt;\n                              {cnt === 3 ? '3+' : cnt}\n                            &lt;\/button&gt;\n                          ))}\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                    {\/* Diet-Filtered Food Logger &amp; Hydration *\/}\n                  &lt;div className=\"grid grid-cols-1 lg:grid-cols-12 gap-6\"&gt;\n                    &lt;div className=\"lg:col-span-7 bg-white rounded-2xl p-6 shadow-sm border border-slate-200\"&gt;\n                      &lt;h3 className=\"text-sm font-bold text-slate-900 mb-3\"&gt;\n                        Quick-Add Whole Foods ({toSafeStr(profile.dietPreference, 'lacto', 20).toUpperCase()})\n                      &lt;\/h3&gt;\n                      &lt;div className=\"flex flex-wrap gap-2 mb-4\"&gt;\n                        {FOOD_DATABASE.filter(f =&gt; f.diet.includes(toSafeStr(profile.dietPreference, 'lacto', 20))).map(food =&gt; (\n                          &lt;button\n                            key={food.id}\n                            type=\"button\"\n                            onClick={() =&gt; addFoodToLog(food.id)}\n                            className=\"flex items-center gap-1 px-3 py-1.5 rounded-xl text-xs font-semibold bg-teal-50 text-teal-800 border border-teal-200 hover:bg-teal-100\"\n                          &gt;\n                            &lt;Icon name=\"plus\" className=\"w-3.5 h-3.5\" \/&gt;\n                            {food.name}\n                          &lt;\/button&gt;\n                        ))}\n                      &lt;\/div&gt;\n                      &lt;div className=\"space-y-2 max-h-60 overflow-y-auto\"&gt;\n                        {nutrition.loggedFoods.length === 0 ? (\n                          &lt;div className=\"p-4 rounded-xl bg-slate-50 border border-dashed border-slate-300 text-center text-xs text-slate-500\"&gt;\n                            No foods logged yet. Click any food item above to add it to your daily nutrition log.\n                          &lt;\/div&gt;\n                        ) : (\n                          nutrition.loggedFoods.map((item, idx) =&gt; {\n                            if (!item || typeof item !== 'object') return null;\n                            const safeCarb = toSafeFloat(item.carb, 0);\n                            const safeFiber = toSafeFloat(item.fiber, 0);\n                            const netCarbStr = Math.max(0, safeCarb - safeFiber).toFixed(1);\n                            return (\n                              &lt;div key={item.instanceId || idx} className=\"flex items-center justify-between p-2.5 rounded-xl bg-slate-50 border border-slate-200 text-xs\"&gt;\n                                &lt;div&gt;\n                                  &lt;div className=\"font-bold text-slate-900\"&gt;{toSafeStr(item.name, 'Food Item')}&lt;\/div&gt;\n                                  &lt;div className=\"text-slate-500\"&gt;\n                                    {toSafeFloat(item.cal, 0)} kcal \u2022 Pro: {toSafeFloat(item.pro, 0)}g \u2022 Net Carb: {netCarbStr}g \u2022 Fiber: {safeFiber}g \u2022 Choline: {toSafeFloat(item.choline, 0)}mg\n                                  &lt;\/div&gt;\n                                &lt;\/div&gt;\n                                &lt;button type=\"button\" onClick={() =&gt; removeFoodFromLog(item.instanceId)} className=\"text-slate-400 hover:text-rose-600 p-1\"&gt;\n                                  &lt;Icon name=\"trash\" className=\"w-4 h-4\" \/&gt;\n                                &lt;\/button&gt;\n                              &lt;\/div&gt;\n                            );\n                          })\n                        )}\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n\n                    &lt;div className=\"lg:col-span-5 bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3 text-xs\"&gt;\n                      &lt;div className=\"flex justify-between items-center\"&gt;\n                        &lt;h3 className=\"text-sm font-bold text-slate-900\"&gt;Macro, Amino &amp; Mineral Totals&lt;\/h3&gt;\n                        &lt;span className=\"font-bold text-teal-700\"&gt;\n                          {nutritionTotals.cal} \/ {clinicalMetrics.targetCalories &gt; 0 ? clinicalMetrics.targetCalories : '\u2014'} kcal\n                        &lt;\/span&gt;\n                      &lt;\/div&gt;\n                      &lt;div className=\"grid grid-cols-2 gap-2.5\"&gt;\n                        &lt;div className=\"p-2.5 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                          &lt;div className=\"text-slate-500\"&gt;Protein &amp; Leucine&lt;\/div&gt;\n                          &lt;div className=\"text-sm font-bold text-slate-900\"&gt;{nutritionTotals.pro}g Pro ({nutritionTotals.leucine}g Leu)&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"p-2.5 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                          &lt;div className=\"text-slate-500\"&gt;Net Carbs &amp; Fiber&lt;\/div&gt;\n                          &lt;div className=\"text-sm font-bold text-slate-900\"&gt;{nutritionTotals.netCarbs}g Net ({nutritionTotals.fiber}g Fiber)&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"p-2.5 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                          &lt;div className=\"text-slate-500\"&gt;Magnesium &amp; Potassium&lt;\/div&gt;\n                          &lt;div className=\"text-sm font-bold text-slate-900\"&gt;Mg: {nutritionTotals.mg}mg \u2022 K: {nutritionTotals.k}mg&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"p-2.5 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                          &lt;div className=\"text-slate-500\"&gt;Hepatic Choline&lt;\/div&gt;\n                          &lt;div className=\"text-sm font-bold text-slate-900\"&gt;{nutritionTotals.choline} \/ 550 mg&lt;\/div&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      {\/* Water Mineralization Logger *\/}\n                      &lt;form onSubmit={addWaterLog} className=\"pt-3 border-t border-slate-200 space-y-2\"&gt;\n                        &lt;div className=\"font-bold text-slate-800 flex items-center justify-between\"&gt;\n                          &lt;span&gt;Hydration &amp; Water Source ({nutritionTotals.totalWaterMl} ml) &lt;Tooltip text={CLINICAL_TOOLTIPS.waterRO} \/&gt;&lt;\/span&gt;\n                          {nutritionTotals.hasPlainROWarning &amp;&amp; (\n                            &lt;span className=\"text-[10px] font-semibold text-amber-700 bg-amber-50 px-2 py-0.5 rounded border border-amber-200\"&gt;\n                              Remineralize RO Water\n                            &lt;\/span&gt;\n                          )}\n                        &lt;\/div&gt;\n                        &lt;div className=\"grid grid-cols-2 sm:grid-cols-4 gap-2\"&gt;\n                          &lt;select\n                            value={newWater.timing}\n                            onChange={e =&gt; setNewWater({ ...newWater, timing: e.target.value })}\n                            className=\"px-2 py-1.5 rounded-lg border border-slate-300 bg-white\"\n                          &gt;\n                            &lt;option value=\"Morning Waking\"&gt;Waking&lt;\/option&gt;\n                            &lt;option value=\"Pre-Workout\"&gt;Pre-Workout&lt;\/option&gt;\n                            &lt;option value=\"Intra-Workout\"&gt;Intra-Workout&lt;\/option&gt;\n                            &lt;option value=\"Post-Workout\"&gt;Post-Workout&lt;\/option&gt;\n                          &lt;\/select&gt;\n                          &lt;input\n                            type=\"number\"\n                            min=\"10\"\n                            max=\"5000\"\n                            step=\"50\"\n                            value={newWater.amountMl}\n                            onChange={e =&gt; setNewWater({ ...newWater, amountMl: parseInputNum(e.target.value, 0, 5000) })}\n                            placeholder=\"ml (e.g. 350)\"\n                            className=\"px-2 py-1.5 rounded-lg border border-slate-300 bg-white\"\n                          \/&gt;\n                          &lt;select\n                            value={newWater.source}\n                            onChange={e =&gt; setNewWater({ ...newWater, source: e.target.value })}\n                            className=\"px-2 py-1.5 rounded-lg border border-slate-300 bg-white\"\n                          &gt;\n                            &lt;option value=\"Natural Mineral Water\"&gt;Mineral Water&lt;\/option&gt;\n                            &lt;option value=\"RO + Pink Salt &amp; Lemon\"&gt;RO + Sendha Salt&lt;\/option&gt;\n                            &lt;option value=\"Electrolyte Infused\"&gt;Electrolyte Water&lt;\/option&gt;\n                            &lt;option value=\"Plain RO (Unmineralized)\"&gt;Plain RO (Low TDS)&lt;\/option&gt;\n                          &lt;\/select&gt;\n                          &lt;button type=\"submit\" className=\"bg-sky-600 text-white font-semibold rounded-lg px-2 py-1.5 hover:bg-sky-700\"&gt;\n                            + Log Water\n                          &lt;\/button&gt;\n                        &lt;\/div&gt;\n                        {nutrition.waterLogs.length &gt; 0 &amp;&amp; (\n                          &lt;div className=\"space-y-1.5 max-h-28 overflow-y-auto pt-1\"&gt;\n                            {nutrition.waterLogs.map(w =&gt; (\n                              &lt;div key={w.id} className=\"flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-sky-50\/60 border border-sky-100 text-[11px]\"&gt;\n                                &lt;span className=\"font-medium text-slate-700\"&gt;{w.timing}: &lt;strong&gt;{w.amountMl} ml&lt;\/strong&gt; ({w.source})&lt;\/span&gt;\n                                &lt;button\n                                  type=\"button\"\n                                  onClick={() =&gt; removeWaterFromLog(w.id)}\n                                  className=\"text-slate-400 hover:text-rose-600\"\n                                  title=\"Remove water entry\"\n                                &gt;\n                                  &lt;Icon name=\"trash\" className=\"w-3.5 h-3.5\" \/&gt;\n                                &lt;\/button&gt;\n                              &lt;\/div&gt;\n                            ))}\n                          &lt;\/div&gt;\n                        )}\n                      &lt;\/form&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  {\/* Interactive Food Nutrient &amp; % Daily Value (%DV) Calculator + Smart Meal Decision Advisor *\/}\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-teal-200 space-y-6\"&gt;\n                    &lt;div className=\"flex flex-col sm:flex-row sm:items-center justify-between gap-2 border-b border-slate-200 pb-4\"&gt;\n                      &lt;div&gt;\n                        &lt;h3 className=\"text-base font-bold text-slate-900 flex items-center gap-2\"&gt;\n                          &lt;Icon name=\"utensils\" className=\"w-5 h-5 text-teal-600\" \/&gt;\n                          Food Macro, Micro, Mineral &amp;amp; Vitamin %DV Calculator &amp;amp; Decision Guide\n                        &lt;\/h3&gt;\n                        &lt;p className=\"text-xs text-slate-600\"&gt;\n                          Inspect the exact nutritional density of any food before eating, track your daily %DV fulfillment, and see what to eat next to close your nutritional gaps.\n                        &lt;\/p&gt;\n                      &lt;\/div&gt;\n                      &lt;StatusBadge\n                        status={nutritionTotals.lackingNutrients.length === 0 ? 'optimal' : 'info'}\n                        label={`Diet Filter: ${toSafeStr(profile.dietPreference, 'lacto', 20).toUpperCase()}`}\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    {\/* Part A: Single-Food Nutrient &amp; %DV Inspector *\/}\n                    &lt;div className=\"bg-teal-50\/50 rounded-2xl p-4 border border-teal-200\/80 space-y-4\"&gt;\n                      {\/* Category Filter Pills for 32+ Whole Foods *\/}\n                      &lt;div className=\"space-y-1.5\"&gt;\n                        &lt;div className=\"text-[11px] font-bold text-teal-900 uppercase tracking-wider\"&gt;\n                          Filter Food Group ({FOOD_DATABASE.length} Whole Foods Available: Vegetables, Grains, Fruits, Nuts, Chia, Pumpkin Seeds, Olive Oil &amp;amp; Proteins):\n                        &lt;\/div&gt;\n                        &lt;div className=\"flex flex-wrap gap-1.5\"&gt;\n                          {[\n                            'All',\n                            'Vegetables &amp; Greens',\n                            'Grains, Millets &amp; Starches',\n                            'Fruits &amp; Berries',\n                            'Nuts, Seeds &amp; Oils',\n                            'Proteins, Legumes &amp; Dairy'\n                          ].map(cat =&gt; (\n                            &lt;button\n                              key={cat}\n                              type=\"button\"\n                              onClick={() =&gt; {\n                                setInspectorCategory(cat);\n                                const matching = cat === 'All' ? FOOD_DATABASE : FOOD_DATABASE.filter(f =&gt; f.category === cat);\n                                if (matching.length &gt; 0 &amp;&amp; !matching.some(f =&gt; f.id === inspectorFoodId)) {\n                                  setInspectorFoodId(matching[0].id);\n                                }\n                              }}\n                              className={`px-3 py-1 rounded-xl text-xs font-semibold border transition ${\n                                inspectorCategory === cat\n                                  ? 'bg-teal-700 text-white border-teal-700 shadow-sm'\n                                  : 'bg-white text-slate-700 border-teal-200 hover:bg-teal-100'\n                              }`}\n                            &gt;\n                              {cat}\n                            &lt;\/button&gt;\n                          ))}\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;div className=\"flex flex-col md:flex-row md:items-end justify-between gap-3\"&gt;\n                        &lt;div className=\"flex-1\"&gt;\n                          &lt;label className=\"block text-xs font-bold text-teal-950 mb-1\"&gt;\n                            1. Select Any Food Item to Inspect Its Macro, Mineral, Vitamin &amp;amp; Amino Profile:\n                          &lt;\/label&gt;\n                          &lt;select\n                            value={inspectorFoodId}\n                            onChange={e =&gt; setInspectorFoodId(e.target.value)}\n                            className=\"w-full px-3 py-2 rounded-xl border border-teal-300 bg-white text-xs font-semibold text-slate-900\"\n                          &gt;\n                            {filteredInspectorFoods.map(f =&gt; (\n                              &lt;option key={f.id} value={f.id}&gt;\n                                {f.name} [{f.category}] {f.diet.includes(toSafeStr(profile.dietPreference, 'lacto', 20)) ? '\u2713 Matches Your Diet' : ''}\n                              &lt;\/option&gt;\n                            ))}\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n\n                        &lt;div className=\"w-full md:w-44\"&gt;\n                          &lt;label className=\"block text-xs font-bold text-teal-950 mb-1\"&gt;\n                            Portion Multiplier ({inspectorServings}x Serving)\n                          &lt;\/label&gt;\n                          &lt;select\n                            value={inspectorServings}\n                            onChange={e =&gt; setInspectorServings(toSafeFloat(e.target.value, 1, 0.25, 10))}\n                            className=\"w-full px-3 py-2 rounded-xl border border-teal-300 bg-white text-xs font-semibold text-slate-900\"\n                          &gt;\n                            &lt;option value={0.5}&gt;0.5x Half Portion&lt;\/option&gt;\n                            &lt;option value={1}&gt;1.0x Standard Portion&lt;\/option&gt;\n                            &lt;option value={1.5}&gt;1.5x Portion&lt;\/option&gt;\n                            &lt;option value={2}&gt;2.0x Double Portion&lt;\/option&gt;\n                            &lt;option value={3}&gt;3.0x Triple Portion&lt;\/option&gt;\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n\n                        &lt;button\n                          type=\"button\"\n                          onClick={() =&gt; addFoodToLog(inspectorFoodId, inspectorServings)}\n                          className=\"px-4 py-2 rounded-xl bg-teal-600 hover:bg-teal-500 text-white text-xs font-bold shadow-sm transition shrink-0\"\n                        &gt;\n                          + Add {inspectorServings}x to Today's Log\n                        &lt;\/button&gt;\n                      &lt;\/div&gt;\n\n                      {\/* Inspected Food Nutrient Breakdown Grid *\/}\n                      &lt;div className=\"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-2 text-xs\"&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Calories &amp;amp; GL&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;{inspectedFoodMetrics.cal} kcal&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-teal-700 font-semibold\"&gt;Glycemic Load: {inspectedFoodMetrics.glycemicLoad}&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Protein &amp;amp; Leucine&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;{inspectedFoodMetrics.pro}g ({Math.round((inspectedFoodMetrics.pro \/ DAILY_VALUE_TARGETS.pro.dv) * 100)}% DV)&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-teal-700 font-semibold\"&gt;Leucine: {inspectedFoodMetrics.leucine}g&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Net Carbs &amp;amp; Fiber&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;{inspectedFoodMetrics.netCarb}g Net&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-emerald-700 font-semibold\"&gt;Fiber: {inspectedFoodMetrics.fiber}g ({Math.round((inspectedFoodMetrics.fiber \/ DAILY_VALUE_TARGETS.fiber.dv) * 100)}% DV)&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Fats &amp;amp; Omega-3&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;{inspectedFoodMetrics.fat}g Total&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-sky-700 font-semibold\"&gt;Omega-3: {inspectedFoodMetrics.omega3}g ({Math.round((inspectedFoodMetrics.omega3 \/ DAILY_VALUE_TARGETS.omega3.dv) * 100)}% DV)&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Mg &amp;amp; Potassium&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;Mg: {inspectedFoodMetrics.mg}mg ({Math.round((inspectedFoodMetrics.mg \/ DAILY_VALUE_TARGETS.mg.dv) * 100)}%)&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-slate-600\"&gt;K: {inspectedFoodMetrics.k}mg ({Math.round((inspectedFoodMetrics.k \/ DAILY_VALUE_TARGETS.k.dv) * 100)}%)&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Calcium, Iron, Zinc&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;Ca: {inspectedFoodMetrics.ca}mg ({Math.round((inspectedFoodMetrics.ca \/ DAILY_VALUE_TARGETS.ca.dv) * 100)}%)&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-slate-600\"&gt;Fe: {inspectedFoodMetrics.fe}mg \u2022 Zn: {inspectedFoodMetrics.zn}mg&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Liver Choline &amp;amp; B9&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;Choline: {inspectedFoodMetrics.choline}mg ({Math.round((inspectedFoodMetrics.choline \/ DAILY_VALUE_TARGETS.choline.dv) * 100)}%)&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-slate-600\"&gt;Folate: {inspectedFoodMetrics.folate}mcg ({Math.round((inspectedFoodMetrics.folate \/ DAILY_VALUE_TARGETS.folate.dv) * 100)}%)&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div className=\"bg-white p-2.5 rounded-xl border border-slate-200\"&gt;\n                          &lt;div className=\"text-[10px] text-slate-500\"&gt;Vitamins C, A, D, B12&lt;\/div&gt;\n                          &lt;div className=\"font-bold text-slate-900\"&gt;C: {inspectedFoodMetrics.vitC}mg \u2022 B12: {inspectedFoodMetrics.b12}mcg&lt;\/div&gt;\n                          &lt;div className=\"text-[10px] text-slate-600\"&gt;A: {inspectedFoodMetrics.vitA}mcg \u2022 D: {inspectedFoodMetrics.vitD}IU&lt;\/div&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n\n                    {\/* Part B: Full Daily %DV Progress Bars + Smart Food Recommendations to Fill Gaps *\/}\n                    &lt;div className=\"grid grid-cols-1 lg:grid-cols-12 gap-6\"&gt;\n                      {\/* 15-Nutrient %DV Fulfillment Bars *\/}\n                      &lt;div className=\"lg:col-span-7 space-y-2.5\"&gt;\n                        &lt;div className=\"text-xs font-bold text-slate-900\"&gt;\n                          2. Your Daily Nutrient &amp;amp; % Daily Value (%DV) Fulfillment Tracker\n                        &lt;\/div&gt;\n                        &lt;div className=\"grid grid-cols-1 sm:grid-cols-2 gap-2.5 max-h-80 overflow-y-auto pr-1\"&gt;\n                          {nutritionTotals.dvProgress.map(item =&gt; {\n                            const barColor = item.pct &gt;= 80 ? 'bg-emerald-500' : item.pct &gt;= 40 ? 'bg-amber-500' : 'bg-rose-500';\n                            return (\n                              &lt;div key={item.key} className=\"p-2.5 rounded-xl bg-slate-50 border border-slate-200 text-xs\"&gt;\n                                &lt;div className=\"flex items-center justify-between font-semibold text-slate-800 mb-1\"&gt;\n                                  &lt;span&gt;{item.label}&lt;\/span&gt;\n                                  &lt;span className=\"text-[11px] font-bold text-teal-800\"&gt;\n                                    {item.current}{item.unit} \/ {item.target}{item.unit} ({item.pct}% DV)\n                                  &lt;\/span&gt;\n                                &lt;\/div&gt;\n                                &lt;div className=\"w-full h-2 bg-slate-200 rounded-full overflow-hidden mb-1\"&gt;\n                                  &lt;div\n                                    className={`h-full ${barColor} transition-all duration-300`}\n                                    style={{ width: `${Math.min(100, item.pct)}%` }}\n                                  \/&gt;\n                                &lt;\/div&gt;\n                                &lt;div className=\"text-[10px] text-slate-500\"&gt;{item.role}&lt;\/div&gt;\n                              &lt;\/div&gt;\n                            );\n                          })}\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      {\/* Smart \"What Should I Eat Next?\" Gap Advisor *\/}\n                      &lt;div className=\"lg:col-span-5 bg-slate-50 rounded-2xl p-4 border border-slate-200 space-y-3\"&gt;\n                        &lt;div className=\"text-xs font-bold text-slate-900 flex items-center justify-between\"&gt;\n                          &lt;span&gt;3. Smart Advisor: What to Eat Next to Fulfill %DV&lt;\/span&gt;\n                          &lt;span className=\"text-[10px] text-teal-700 font-semibold\"&gt;Tailored to Your Diet&lt;\/span&gt;\n                        &lt;\/div&gt;\n                        &lt;p className=\"text-[11px] text-slate-600\"&gt;\n                          Based on your logged meals today, here are your top nutritional gaps and the best whole foods ({toSafeStr(profile.dietPreference, 'lacto', 20).toUpperCase()}) you can add right now:\n                        &lt;\/p&gt;\n                        &lt;div className=\"space-y-2.5\"&gt;\n                          {nutritionTotals.lackingNutrients.map(gap =&gt; {\n                            const deficitVal = formatNutrientVal(Math.max(0, gap.target - gap.current));\n                            return (\n                              &lt;div key={gap.key} className=\"p-3 rounded-xl bg-white border border-slate-200 text-xs space-y-1.5\"&gt;\n                                &lt;div className=\"flex items-center justify-between\"&gt;\n                                  &lt;span className=\"font-bold text-rose-700\"&gt;\n                                    Low {gap.label}: {gap.pct}% DV ({formatNutrientVal(gap.current)}\/{formatNutrientVal(gap.target)}{gap.unit})\n                                  &lt;\/span&gt;\n                                  &lt;span className=\"text-[10px] text-slate-500\"&gt;Need +{deficitVal}{gap.unit}&lt;\/span&gt;\n                                &lt;\/div&gt;\n                                &lt;div className=\"text-[11px] text-slate-600\"&gt;Best foods to eat for {gap.label}:&lt;\/div&gt;\n                                &lt;div className=\"flex flex-wrap gap-1.5 pt-0.5\"&gt;\n                                  {gap.bestFoods.length === 0 ? (\n                                    &lt;span className=\"text-[10px] text-slate-400\"&gt;Consider sunlight exposure or trace mineral supplementation.&lt;\/span&gt;\n                                  ) : (\n                                    gap.bestFoods.map(f =&gt; (\n                                      &lt;button\n                                        key={f.id}\n                                        type=\"button\"\n                                        onClick={() =&gt; addFoodToLog(f.id, 1)}\n                                        className=\"px-2.5 py-1 rounded-lg bg-teal-50 hover:bg-teal-100 text-teal-800 border border-teal-200 text-[11px] font-semibold transition flex items-center gap-1\"\n                                      &gt;\n                                        &lt;span&gt;+ {f.name.split('(')[0].trim()} (+{f[gap.key]}{gap.unit})&lt;\/span&gt;\n                                      &lt;\/button&gt;\n                                    ))\n                                  )}\n                                &lt;\/div&gt;\n                              &lt;\/div&gt;\n                            );\n                          })}\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              )}\n\n              {activeTab === 'fasting' &amp;&amp; (\n                &lt;div className=\"grid grid-cols-1 lg:grid-cols-3 gap-6\"&gt;\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3 text-xs\"&gt;\n                    &lt;h2 className=\"text-base font-bold text-slate-900\"&gt;Fasting Window &amp;amp; OMAD Tracker&lt;\/h2&gt;\n                    &lt;div&gt;\n                      &lt;label className=\"block font-semibold text-slate-600 mb-1\"&gt;Active Fasting Regimen&lt;\/label&gt;\n                      &lt;select\n                        value={fasting.protocol}\n                        onChange={e =&gt; setFasting({ ...fasting, protocol: e.target.value })}\n                        className=\"w-full px-3 py-2.5 rounded-xl border border-slate-300 bg-white font-semibold\"\n                      &gt;\n                        &lt;option value=\"12:12\"&gt;12:12 Basic Circadian Reset&lt;\/option&gt;\n                        &lt;option value=\"14:10\"&gt;14:10 Early Time-Restricted Eating (eTRE)&lt;\/option&gt;\n                        &lt;option value=\"16:8\"&gt;16:8 Intermittent Fasting (Insulin Reset)&lt;\/option&gt;\n                        &lt;option value=\"18:6\"&gt;18:6 Two-Meal Protocol (NAFLD &amp;amp; Visceral Fat)&lt;\/option&gt;\n                        &lt;option value=\"20:4\"&gt;20:4 Warrior Protocol (Deep Lipolysis)&lt;\/option&gt;\n                        &lt;option value=\"OMAD\"&gt;OMAD (23:1 One Meal A Day)&lt;\/option&gt;\n                        &lt;option value=\"24h-Water\"&gt;24-Hour Water + Electrolyte Autophagy Fast&lt;\/option&gt;\n                        &lt;option value=\"ADF-36h\"&gt;36-Hour Alternate-Day Fast (ADF \/ Monk Fast)&lt;\/option&gt;\n                        &lt;option value=\"Dry-Soft\"&gt;Dawn-to-Dusk Dry Fast (Circadian Reset)&lt;\/option&gt;\n                      &lt;\/select&gt;\n                    &lt;\/div&gt;\n                    &lt;div&gt;\n                      &lt;label className=\"block font-semibold text-slate-600 mb-1\"&gt;Fasting Medium&lt;\/label&gt;\n                      &lt;select\n                        value={fasting.fastingType}\n                        onChange={e =&gt; setFasting({ ...fasting, fastingType: e.target.value })}\n                        className=\"w-full px-3 py-2 rounded-xl border border-slate-300 bg-white\"\n                      &gt;\n                        &lt;option value=\"water-electrolyte\"&gt;Mineral Water + Unsweetened Electrolytes Only&lt;\/option&gt;\n                        &lt;option value=\"black-coffee-tea\"&gt;Water + Black Coffee \/ Green Tea \/ Herbal&lt;\/option&gt;\n                        &lt;option value=\"dry\"&gt;Dry Fasting (Zero Food or Liquid Window)&lt;\/option&gt;\n                      &lt;\/select&gt;\n                    &lt;\/div&gt;\n                    &lt;div&gt;\n                      &lt;div className=\"flex justify-between font-semibold mb-1\"&gt;\n                        &lt;span&gt;Current Fast Hours&lt;\/span&gt;\n                        &lt;span className=\"text-teal-700 font-bold\"&gt;{toSafeFloat(fasting.currentFastHours, 0, 0, 48)}h&lt;\/span&gt;\n                      &lt;\/div&gt;\n                      &lt;input\n                        type=\"range\"\n                        min=\"0\"\n                        max=\"48\"\n                        step=\"0.5\"\n                        value={toSafeFloat(fasting.currentFastHours, 0, 0, 48)}\n                        onChange={e =&gt; setFasting({ ...fasting, currentFastHours: toSafeFloat(e.target.value, 0, 0, 48) })}\n                        className=\"w-full accent-teal-600\"\n                      \/&gt;\n                    &lt;\/div&gt;\n                    &lt;div className=\"pt-1\"&gt;\n                      &lt;label className=\"block font-semibold text-slate-600 mb-1.5\"&gt;Distinct Meals Per Day (OMAD = 1 Meal)&lt;\/label&gt;\n                      &lt;div className=\"grid grid-cols-4 gap-1.5\"&gt;\n                        {[\n                          { count: 1, label: '1 (OMAD)' },\n                          { count: 2, label: '2 (2MAD)' },\n                          { count: 3, label: '3 Meals' },\n                          { count: 4, label: '4+ Grazing' }\n                        ].map(m =&gt; (\n                          &lt;button\n                            key={m.count}\n                            type=\"button\"\n                            onClick={() =&gt; setFasting({ ...fasting, mealsPerDay: m.count, ...(m.count === 1 ? { protocol: 'OMAD' } : {}) })}\n                            className={`py-1.5 px-1 rounded-xl text-[11px] font-bold border transition ${\n                              Number(fasting.mealsPerDay) === m.count\n                                ? 'bg-teal-600 text-white border-teal-600'\n                                : 'bg-slate-50 text-slate-700 border-slate-200 hover:bg-slate-100'\n                            }`}\n                          &gt;\n                            {m.label}\n                          &lt;\/button&gt;\n                        ))}\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3 text-xs\"&gt;\n                    &lt;h2 className=\"text-base font-bold text-slate-900\"&gt;\n                      Circadian Eating Gaps &lt;Tooltip text={CLINICAL_TOOLTIPS.circadianEating} \/&gt;\n                    &lt;\/h2&gt;\n                    &lt;div className=\"grid grid-cols-2 gap-2.5\"&gt;\n                      &lt;div&gt;\n                        &lt;label className=\"block font-semibold text-slate-600 mb-1\"&gt;Wake Time&lt;\/label&gt;\n                        &lt;input type=\"time\" value={fasting.wakeTime} onChange={e =&gt; setFasting({ ...fasting, wakeTime: e.target.value })} className=\"w-full px-2.5 py-1.5 rounded-lg border border-slate-300\" \/&gt;\n                      &lt;\/div&gt;\n                      &lt;div&gt;\n                        &lt;label className=\"block font-semibold text-slate-600 mb-1\"&gt;First Meal&lt;\/label&gt;\n                        &lt;input type=\"time\" value={fasting.firstMealTime} onChange={e =&gt; setFasting({ ...fasting, firstMealTime: e.target.value })} className=\"w-full px-2.5 py-1.5 rounded-lg border border-slate-300\" \/&gt;\n                      &lt;\/div&gt;\n                      &lt;div&gt;\n                        &lt;label className=\"block font-semibold text-slate-600 mb-1\"&gt;Last Meal&lt;\/label&gt;\n                        &lt;input type=\"time\" value={fasting.lastMealTime} onChange={e =&gt; setFasting({ ...fasting, lastMealTime: e.target.value })} className=\"w-full px-2.5 py-1.5 rounded-lg border border-slate-300\" \/&gt;\n                      &lt;\/div&gt;\n                      &lt;div&gt;\n                        &lt;label className=\"block font-semibold text-slate-600 mb-1\"&gt;Sleep Time&lt;\/label&gt;\n                        &lt;input type=\"time\" value={fasting.sleepTime} onChange={e =&gt; setFasting({ ...fasting, sleepTime: e.target.value })} className=\"w-full px-2.5 py-1.5 rounded-lg border border-slate-300\" \/&gt;\n                      &lt;\/div&gt;\n                    &lt;\/div&gt;\n                    &lt;div className=\"flex justify-between p-3 rounded-xl bg-slate-50 border border-slate-200\"&gt;\n                      &lt;span&gt;Pre-Sleep Digestion Gap:&lt;\/span&gt;\n                      &lt;span className={`font-bold ${clinicalMetrics.eveningGapHours === null ? 'text-slate-500' : clinicalMetrics.eveningGapHours &gt;= 3 ? 'text-emerald-700' : 'text-rose-600'}`}&gt;\n                        {clinicalMetrics.eveningGapHours !== null ? `${clinicalMetrics.eveningGapHours} hrs (Target: 3h+)` : 'Enter Meal &amp; Sleep Times'}\n                      &lt;\/span&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  &lt;div className=\"bg-teal-950 text-white rounded-2xl p-6 shadow-sm space-y-2 text-xs\"&gt;\n                    &lt;div className=\"font-bold text-teal-300 text-sm\"&gt;Why Meal Frequency Drives Insulin&lt;\/div&gt;\n                    &lt;p className=\"text-slate-200 leading-relaxed\"&gt;\n                      Consolidating intake into 2 structured meals within an early 6\u20138 hour window allows serum insulin to remain at baseline for 16+ hours, unlocking hepatic fat oxidation and reversing peripheral insulin resistance.\n                    &lt;\/p&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              )}\n\n              {activeTab === 'activity' &amp;&amp; (\n                &lt;div className=\"grid grid-cols-1 lg:grid-cols-12 gap-6\"&gt;\n                  {\/* Upgraded Post-Meal Walk Tracker with Pace &amp; Flexible Duration (10m - 60m) *\/}\n                  &lt;div className=\"lg:col-span-5 bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-4 text-xs\"&gt;\n                    &lt;div className=\"flex items-center justify-between\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2\"&gt;\n                        &lt;Icon name=\"footprints\" className=\"w-5 h-5 text-teal-600\" \/&gt;\n                        Post-Meal Walk Tracker\n                        &lt;Tooltip text={CLINICAL_TOOLTIPS.postMealWalk} \/&gt;\n                      &lt;\/h2&gt;\n                      &lt;StatusBadge\n                        status={clinicalMetrics.totalPostMealWalkMins &gt;= 30 ? 'optimal' : clinicalMetrics.totalPostMealWalkMins &gt; 0 ? 'info' : 'warning'}\n                        label={`${clinicalMetrics.totalPostMealWalkMins}m Total (-${clinicalMetrics.totalWalkReduction} mg\/dL Peak)`}\n                      \/&gt;\n                    &lt;\/div&gt;\n                    &lt;p className=\"text-slate-600 leading-relaxed\"&gt;\n                      Walking within 15\u201320 minutes after eating contracts skeletal muscle fibers, pulling glucose out of the bloodstream via &lt;strong&gt;insulin-independent GLUT4 translocation&lt;\/strong&gt;. Choose your pace and duration for each meal:\n                    &lt;\/p&gt;\n\n                    &lt;div className=\"space-y-3\"&gt;\n                      {[\n                        { key: 'breakfastWalk', minsKey: 'breakfastWalkMins', paceKey: 'breakfastWalkPace', title: 'Post-Meal Walk #1 (After Breakfast \/ First Meal)' },\n                        { key: 'lunchWalk', minsKey: 'lunchWalkMins', paceKey: 'lunchWalkPace', title: 'Post-Meal Walk #2 (After Lunch \/ Midday Meal)' },\n                        { key: 'dinnerWalk', minsKey: 'dinnerWalkMins', paceKey: 'dinnerWalkPace', title: 'Post-Meal Walk #3 (After Dinner - Most Crucial)' }\n                      ].map(item =&gt; {\n                        const walksObj = activity?.postMealWalks || DEFAULT_ACTIVITY.postMealWalks;\n                        const isChecked = Boolean(walksObj[item.key]);\n                        const currentMins = toSafeFloat(walksObj[item.minsKey], 20, 5, 120);\n                        const currentPace = walksObj[item.paceKey] || 'normal';\n                        return (\n                          &lt;div\n                            key={item.key}\n                            className={`p-3.5 rounded-xl border transition ${\n                              isChecked ? 'bg-teal-50\/70 border-teal-400' : 'bg-slate-50 border-slate-200'\n                            }`}\n                          &gt;\n                            &lt;label className=\"flex items-center justify-between cursor-pointer mb-2.5\"&gt;\n                              &lt;span className=\"font-bold text-slate-900\"&gt;{item.title}&lt;\/span&gt;\n                              &lt;input\n                                type=\"checkbox\"\n                                checked={isChecked}\n                                onChange={e =&gt;\n                                  setActivity({\n                                    ...activity,\n                                    postMealWalks: {\n                                      ...walksObj,\n                                      [item.key]: e.target.checked\n                                    }\n                                  })\n                                }\n                                className=\"w-4 h-4 accent-teal-600 rounded\"\n                              \/&gt;\n                            &lt;\/label&gt;\n\n                            &lt;div className=\"grid grid-cols-1 sm:grid-cols-2 gap-2 pt-1 border-t border-slate-200\/80\"&gt;\n                              &lt;div&gt;\n                                &lt;label className=\"block text-[10px] font-semibold text-slate-500 mb-1\"&gt;Walking Pace \/ Speed&lt;\/label&gt;\n                                &lt;select\n                                  value={currentPace}\n                                  onChange={e =&gt;\n                                    setActivity({\n                                      ...activity,\n                                      postMealWalks: {\n                                        ...walksObj,\n                                        [item.paceKey]: e.target.value,\n                                        [item.key]: true\n                                      }\n                                    })\n                                  }\n                                  className=\"w-full px-2.5 py-1.5 rounded-lg border border-slate-300 bg-white font-semibold text-slate-800\"\n                                &gt;\n                                  &lt;option value=\"slow\"&gt;Slow \/ Gentle Stroll (Aids Digestion)&lt;\/option&gt;\n                                  &lt;option value=\"normal\"&gt;Normal \/ Steady Walk (Moderate GLUT4)&lt;\/option&gt;\n                                  &lt;option value=\"brisk\"&gt;Brisk \/ Purposeful Walk (Max Glucose Sink)&lt;\/option&gt;\n                                &lt;\/select&gt;\n                              &lt;\/div&gt;\n\n                              &lt;div&gt;\n                                &lt;label className=\"block text-[10px] font-semibold text-slate-500 mb-1\"&gt;Duration (Minutes)&lt;\/label&gt;\n                                &lt;div className=\"flex flex-wrap gap-1\"&gt;\n                                  {[10, 15, 20, 30, 40, 60].map(m =&gt; (\n                                    &lt;button\n                                      key={m}\n                                      type=\"button\"\n                                      onClick={() =&gt;\n                                        setActivity({\n                                          ...activity,\n                                          postMealWalks: {\n                                            ...walksObj,\n                                            [item.minsKey]: m,\n                                            [item.key]: true\n                                          }\n                                        })\n                                      }\n                                      className={`px-2 py-1 rounded-lg text-[11px] font-bold border transition ${\n                                        isChecked &amp;&amp; currentMins === m\n                                          ? 'bg-teal-600 text-white border-teal-600'\n                                          : 'bg-white text-slate-700 border-slate-300 hover:bg-teal-50'\n                                      }`}\n                                    &gt;\n                                      {m}m\n                                    &lt;\/button&gt;\n                                  ))}\n                                &lt;\/div&gt;\n                              &lt;\/div&gt;\n                            &lt;\/div&gt;\n                          &lt;\/div&gt;\n                        );\n                      })}\n                    &lt;\/div&gt;\n\n                    {\/* Daily Non-Exercise Steps (NEAT) Slider *\/}\n                    &lt;div className=\"pt-2 border-t border-slate-200\"&gt;\n                      &lt;div className=\"flex justify-between font-semibold mb-1\"&gt;\n                        &lt;span className=\"text-slate-700\"&gt;Total Daily Step Count (NEAT)&lt;\/span&gt;\n                        &lt;span className=\"text-teal-700 font-bold\"&gt;{toSafeFloat(activity.dailySteps, 0, 0, 100000).toLocaleString()} steps&lt;\/span&gt;\n                      &lt;\/div&gt;\n                      &lt;input\n                        type=\"range\"\n                        min=\"0\"\n                        max=\"20000\"\n                        step=\"500\"\n                        value={toSafeFloat(activity.dailySteps, 0, 0, 20000)}\n                        onChange={e =&gt; setActivity({ ...activity, dailySteps: toSafeFloat(e.target.value, 0, 0, 20000) })}\n                        className=\"w-full accent-teal-600\"\n                      \/&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  {\/* Upgraded Exercise &amp; Peri-Workout Nutrition Protocol *\/}\n                  &lt;div className=\"lg:col-span-7 bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-4 text-xs\"&gt;\n                    &lt;div className=\"flex flex-wrap items-center justify-between gap-2\"&gt;\n                      &lt;div&gt;\n                        &lt;h2 className=\"text-base font-bold text-slate-900\"&gt;Exercise &amp;amp; Peri-Workout Nutrition Engine&lt;\/h2&gt;\n                        &lt;p className=\"text-slate-500\"&gt;\n                          Align your pre-workout fuel, intra-workout electrolytes, and post-workout protein\/leucine window with your training style\n                        &lt;\/p&gt;\n                      &lt;\/div&gt;\n                      &lt;StatusBadge\n                        status={activity.workouts.length &gt; 0 ? 'optimal' : 'info'}\n                        label={`${activity.workouts.length} Session(s) Logged`}\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    &lt;form onSubmit={addWorkoutLog} className=\"bg-slate-50 p-4 rounded-2xl border border-slate-200 space-y-3\"&gt;\n                      &lt;div className=\"grid grid-cols-1 sm:grid-cols-3 gap-2.5\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;1. Exercise Modality&lt;\/label&gt;\n                          &lt;select\n                            value={newWorkout.type}\n                            onChange={e =&gt; setNewWorkout({ ...newWorkout, type: e.target.value })}\n                            className=\"w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white font-semibold\"\n                          &gt;\n                            &lt;option value=\"Resistance Training (Hypertrophy)\"&gt;Resistance Training (Builds Muscle Glucose Sink)&lt;\/option&gt;\n                            &lt;option value=\"Zone 2 Brisk Walk \/ Cycling \/ Swim\"&gt;Zone 2 Cardio (Mitochondrial Fat Oxidation)&lt;\/option&gt;\n                            &lt;option value=\"HIIT \/ Sprint Intervals\"&gt;HIIT \/ Sprints (Liver Glycogen Depletion)&lt;\/option&gt;\n                            &lt;option value=\"Bodyweight Calisthenics &amp; Core\"&gt;Bodyweight Calisthenics &amp;amp; Functional Strength&lt;\/option&gt;\n                            &lt;option value=\"Surya Namaskar, Yoga &amp; Pranayama\"&gt;Surya Namaskar, Yoga &amp;amp; Vagal Toning&lt;\/option&gt;\n                            &lt;option value=\"Sports \/ Badminton \/ Tennis \/ Running\"&gt;Active Sports \/ Running&lt;\/option&gt;\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n\n                        &lt;div&gt;\n                          &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;2. Effort &amp;amp; Metabolic State&lt;\/label&gt;\n                          &lt;div className=\"grid grid-cols-2 gap-1.5\"&gt;\n                            &lt;select\n                              value={newWorkout.intensity}\n                              onChange={e =&gt; setNewWorkout({ ...newWorkout, intensity: e.target.value })}\n                              className=\"px-2 py-2 rounded-xl border border-slate-300 bg-white\"\n                            &gt;\n                              &lt;option value=\"Light (Zone 1-2)\"&gt;Light&lt;\/option&gt;\n                              &lt;option value=\"Moderate (RPE 7)\"&gt;Moderate&lt;\/option&gt;\n                              &lt;option value=\"Vigorous (RPE 8-9)\"&gt;Vigorous&lt;\/option&gt;\n                            &lt;\/select&gt;\n                            &lt;select\n                              value={newWorkout.fastedState ? 'fasted' : 'fed'}\n                              onChange={e =&gt; setNewWorkout({ ...newWorkout, fastedState: e.target.value === 'fasted' })}\n                              className=\"px-2 py-2 rounded-xl border border-slate-300 bg-white font-semibold text-teal-800\"\n                            &gt;\n                              &lt;option value=\"fasted\"&gt;Fasted State&lt;\/option&gt;\n                              &lt;option value=\"fed\"&gt;Fed State&lt;\/option&gt;\n                            &lt;\/select&gt;\n                          &lt;\/div&gt;\n                        &lt;\/div&gt;\n\n                        &lt;div&gt;\n                          &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;3. Duration (Minutes)&lt;\/label&gt;\n                          &lt;div className=\"flex gap-1.5\"&gt;\n                            &lt;input\n                              type=\"number\"\n                              min=\"5\"\n                              max=\"600\"\n                              value={newWorkout.durationMin}\n                              onChange={e =&gt; setNewWorkout({ ...newWorkout, durationMin: parseInputNum(e.target.value, 0, 600) })}\n                              placeholder=\"e.g. 45\"\n                              className=\"w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white\"\n                            \/&gt;\n                            {[30, 45, 60].map(d =&gt; (\n                              &lt;button\n                                key={d}\n                                type=\"button\"\n                                onClick={() =&gt; setNewWorkout({ ...newWorkout, durationMin: String(d) })}\n                                className=\"px-2 py-1 rounded-lg bg-white border border-slate-300 hover:bg-teal-50 font-semibold text-[11px]\"\n                              &gt;\n                                {d}m\n                              &lt;\/button&gt;\n                            ))}\n                          &lt;\/div&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      {\/* Peri-Workout Nutrition Presets (Pre, Intra, Post) *\/}\n                      &lt;div className=\"grid grid-cols-1 sm:grid-cols-3 gap-2.5 pt-2 border-t border-slate-200\"&gt;\n                        &lt;div&gt;\n                          &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;Pre-Workout Fuel (30-45m Prior)&lt;\/label&gt;\n                          &lt;select\n                            value={newWorkout.preWorkoutNutrition}\n                            onChange={e =&gt; setNewWorkout({ ...newWorkout, preWorkoutNutrition: e.target.value })}\n                            className=\"w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white\"\n                          &gt;\n                            &lt;option value=\"Mineral Water + Pinch of Sendha Salt \/ Black Coffee\"&gt;Fasted: Water + Sendha Salt \/ Black Coffee (Max Fat Oxidation)&lt;\/option&gt;\n                            &lt;option value=\"Soaked Almonds, Walnuts &amp; Pumpkin Seeds (15g)\"&gt;Low-Insulin: Soaked Nuts &amp;amp; Pumpkin Seeds&lt;\/option&gt;\n                            &lt;option value=\"Green Tea + 1 Tbsp Coconut Oil \/ A2 Ghee\"&gt;MCT \/ A2 Ghee + Green Tea (Ketogenic Fuel)&lt;\/option&gt;\n                            &lt;option value=\"Small Guava \/ Berries + Chia Seeds\"&gt;Targeted Low-GI Fruit + Chia Seeds&lt;\/option&gt;\n                            &lt;option value=\"2 Boiled Eggs \/ Paneer Cube\"&gt;Protein Primer (Eggs \/ Paneer)&lt;\/option&gt;\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n\n                        &lt;div&gt;\n                          &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;Intra-Workout Hydration&lt;\/label&gt;\n                          &lt;select\n                            value={newWorkout.intraWorkoutHydration}\n                            onChange={e =&gt; setNewWorkout({ ...newWorkout, intraWorkoutHydration: e.target.value })}\n                            className=\"w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white\"\n                          &gt;\n                            &lt;option value=\"400ml Mineral \/ Electrolyte Water\"&gt;400ml Mineral \/ Electrolyte Water&lt;\/option&gt;\n                            &lt;option value=\"500ml Water + Sendha Salt &amp; Whole Lemon\"&gt;500ml Water + Sendha Salt &amp;amp; Lemon&lt;\/option&gt;\n                            &lt;option value=\"Plain Mineral Water Sipping\"&gt;Plain Mineral Water Sipping&lt;\/option&gt;\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n\n                        &lt;div&gt;\n                          &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;Post-Workout Anabolic Recovery Meal&lt;\/label&gt;\n                          &lt;select\n                            value={newWorkout.postWorkoutNutrition}\n                            onChange={e =&gt; setNewWorkout({ ...newWorkout, postWorkoutNutrition: e.target.value })}\n                            className=\"w-full px-2.5 py-2 rounded-xl border border-slate-300 bg-white\"\n                          &gt;\n                            &lt;option value=\"High-Leucine Protein + Whole Food Carbs within 45m\"&gt;High-Leucine Protein (2.5g+ Leu) + RS3 Carbs within 45m&lt;\/option&gt;\n                            &lt;option value=\"Sprouted Moong Dal, Tofu\/Paneer &amp; Leafy Greens\"&gt;Veg\/Vegan: Sprouted Moong, Paneer\/Tofu &amp;amp; Greens&lt;\/option&gt;\n                            &lt;option value=\"Pasture Eggs \/ Wild Fish \/ Chicken + Cooled Potato\/Rice\"&gt;Omni\/Ovo: Eggs\/Fish\/Chicken + Cooled RS3 Potato\/Rice&lt;\/option&gt;\n                            &lt;option value=\"A2 Greek Curd + Chia, Hemp &amp; Pumpkin Seeds\"&gt;Probiotic: A2 Curd + Chia, Hemp &amp;amp; Pumpkin Seeds&lt;\/option&gt;\n                            &lt;option value=\"Continue Clean Fast for 1-2h (Growth Hormone Pulse)\"&gt;Delayed Refeed: Ride Post-Exercise GH Pulse (1h)&lt;\/option&gt;\n                          &lt;\/select&gt;\n                        &lt;\/div&gt;\n                      &lt;\/div&gt;\n\n                      &lt;button\n                        type=\"submit\"\n                        className=\"w-full bg-indigo-600 text-white font-bold rounded-xl py-2.5 hover:bg-indigo-700 transition shadow-sm\"\n                      &gt;\n                        + Log Exercise &amp;amp; Peri-Workout Nutrition Protocol\n                      &lt;\/button&gt;\n                    &lt;\/form&gt;\n\n                    {\/* Logged Workouts List *\/}\n                    &lt;div className=\"space-y-2 max-h-60 overflow-y-auto\"&gt;\n                      {activity.workouts.length === 0 ? (\n                        &lt;div className=\"p-4 rounded-xl bg-slate-50 border border-dashed border-slate-300 text-center text-xs text-slate-500\"&gt;\n                          No workouts logged today. Select your modality, duration, and peri-workout nutrition above to log a session.\n                        &lt;\/div&gt;\n                      ) : (\n                        activity.workouts.map(w =&gt; (\n                          &lt;div key={w.id} className=\"p-3 rounded-xl bg-slate-50 border border-slate-200 flex items-center justify-between gap-2\"&gt;\n                            &lt;div className=\"space-y-0.5\"&gt;\n                              &lt;div className=\"font-bold text-slate-900 flex flex-wrap items-center gap-1.5\"&gt;\n                                &lt;span&gt;{w.type} ({w.durationMin} mins)&lt;\/span&gt;\n                                &lt;span className=\"px-2 py-0.5 rounded bg-indigo-50 text-indigo-700 border border-indigo-200 text-[10px]\"&gt;\n                                  {w.intensity || 'Moderate'}\n                                &lt;\/span&gt;\n                                &lt;span className=\"px-2 py-0.5 rounded bg-teal-50 text-teal-700 border border-teal-200 text-[10px]\"&gt;\n                                  {w.fastedState ? 'Fasted Training' : 'Fed State'}\n                                &lt;\/span&gt;\n                              &lt;\/div&gt;\n                              &lt;div className=\"text-[11px] text-slate-600\"&gt;\n                                &lt;strong&gt;Pre:&lt;\/strong&gt; {w.preWorkoutNutrition || 'Water'} \u2022 &lt;strong&gt;Intra:&lt;\/strong&gt; {w.intraWorkoutHydration || 'Mineral Water'}\n                              &lt;\/div&gt;\n                              &lt;div className=\"text-[11px] text-teal-800 font-medium\"&gt;\n                                &lt;strong&gt;Post-Fuel:&lt;\/strong&gt; {w.postWorkoutNutrition || 'Not specified'}\n                              &lt;\/div&gt;\n                            &lt;\/div&gt;\n                            &lt;button\n                              type=\"button\"\n                              onClick={() =&gt; removeWorkoutFromLog(w.id)}\n                              className=\"text-slate-400 hover:text-rose-600 p-1.5 shrink-0\"\n                              title=\"Delete workout\"\n                            &gt;\n                              &lt;Icon name=\"trash\" className=\"w-4 h-4\" \/&gt;\n                            &lt;\/button&gt;\n                          &lt;\/div&gt;\n                        ))\n                      )}\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              )}\n\n              {activeTab === 'lifestyle' &amp;&amp; (\n                &lt;div className=\"grid grid-cols-1 lg:grid-cols-3 gap-6 text-xs\"&gt;\n                  {\/* Upgraded Sunlight, Photobiology &amp; Dermal Nitric Oxide Card with Flexible Skin Exposure Options *\/}\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3.5\"&gt;\n                    &lt;div className=\"flex items-center justify-between\"&gt;\n                      &lt;h2 className=\"text-base font-bold text-slate-900 flex items-center gap-2\"&gt;\n                        &lt;Icon name=\"sun\" className=\"w-5 h-5 text-amber-500\" \/&gt;\n                        Sunlight, Vitamin D &amp;amp; Nitric Oxide\n                      &lt;\/h2&gt;\n                      &lt;StatusBadge\n                        status={toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60) &gt;= 20 ? 'optimal' : 'info'}\n                        label={`${toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}% Skin Exposed`}\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    &lt;div&gt;\n                      &lt;label className=\"block font-semibold text-slate-700 mb-1\"&gt;1. Solar Wavelength Window&lt;\/label&gt;\n                      &lt;select\n                        value={lifestyle.sunlightTimeOfDay}\n                        onChange={e =&gt; setLifestyle({ ...lifestyle, sunlightTimeOfDay: e.target.value })}\n                        className=\"w-full px-3 py-2 rounded-xl border border-slate-300 bg-white font-semibold\"\n                      &gt;\n                        &lt;option value=\"Morning (07:00 - 09:00 AM)\"&gt;Morning (07:00 - 09:00 AM): Circadian SCN Anchor &amp;amp; Near-Infrared (NIR)&lt;\/option&gt;\n                        &lt;option value=\"Solar Noon (11:00 AM - 01:30 PM)\"&gt;Solar Noon (11:00 AM - 01:30 PM): Peak UVB Vitamin D3 Synthesis&lt;\/option&gt;\n                        &lt;option value=\"Late Afternoon (04:00 - 05:30 PM)\"&gt;Late Afternoon (04:00 - 05:30 PM): UVA Dermal Nitric Oxide (BP Drop)&lt;\/option&gt;\n                        &lt;option value=\"Minimal \/ Indoors Behind Glass\"&gt;Minimal \/ Indoors Behind Window Glass (Blocks UVB)&lt;\/option&gt;\n                      &lt;\/select&gt;\n                    &lt;\/div&gt;\n\n                    &lt;div&gt;\n                      &lt;div className=\"flex justify-between font-semibold mb-1\"&gt;\n                        &lt;span&gt;2. Direct Sunlight Duration&lt;\/span&gt;\n                        &lt;span className=\"text-amber-600 font-bold\"&gt;{toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 120)} mins&lt;\/span&gt;\n                      &lt;\/div&gt;\n                      &lt;input\n                        type=\"range\"\n                        min=\"0\"\n                        max=\"60\"\n                        step=\"5\"\n                        value={toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60)}\n                        onChange={e =&gt; setLifestyle({ ...lifestyle, sunlightDurationMin: toSafeFloat(e.target.value, 0, 0, 60) })}\n                        className=\"w-full accent-amber-500\"\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    &lt;div&gt;\n                      &lt;div className=\"flex justify-between font-semibold mb-1.5\"&gt;\n                        &lt;span&gt;3. Skin Surface Area Exposed (Rule of Nines)&lt;\/span&gt;\n                        &lt;span className=\"text-teal-700 font-bold\"&gt;{toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}%&lt;\/span&gt;\n                      &lt;\/div&gt;\n                      &lt;div className=\"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mb-2\"&gt;\n                        {[\n                          { pct: 10, label: '10% (Face &amp; Hands)' },\n                          { pct: 25, label: '25% (Short Sleeves)' },\n                          { pct: 40, label: '40% (T-Shirt &amp; Shorts)' },\n                          { pct: 60, label: '60% (Back\/Chest + Limbs)' },\n                          { pct: 75, label: '75% (Full Torso &amp; Legs)' },\n                          { pct: 85, label: '85%+ (Sunbathing)' }\n                        ].map(opt =&gt; (\n                          &lt;button\n                            key={opt.pct}\n                            type=\"button\"\n                            onClick={() =&gt; setLifestyle({ ...lifestyle, skinExposurePct: opt.pct })}\n                            className={`px-2 py-1.5 rounded-xl border text-[11px] font-bold transition ${\n                              toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100) === opt.pct\n                                ? 'bg-amber-500 text-white border-amber-500 shadow-sm'\n                                : 'bg-slate-50 text-slate-700 border-slate-200 hover:bg-amber-50'\n                            }`}\n                          &gt;\n                            {opt.label}\n                          &lt;\/button&gt;\n                        ))}\n                      &lt;\/div&gt;\n                      &lt;input\n                        type=\"range\"\n                        min=\"5\"\n                        max=\"90\"\n                        step=\"5\"\n                        value={toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}\n                        onChange={e =&gt; setLifestyle({ ...lifestyle, skinExposurePct: toSafeFloat(e.target.value, 25, 0, 100) })}\n                        className=\"w-full accent-amber-500\"\n                      \/&gt;\n                    &lt;\/div&gt;\n\n                    {\/* Photobiology Bio-Calculator Readout *\/}\n                    &lt;div className=\"p-3 rounded-xl bg-amber-50\/80 border border-amber-200 text-[11px] text-amber-950 space-y-1\"&gt;\n                      &lt;div className=\"font-bold\"&gt;Photobiology Effect (Dermal NO &amp;amp; Mitochondrial Melatonin):&lt;\/div&gt;\n                      &lt;p&gt;\n                        With &lt;strong&gt;{toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60)} mins&lt;\/strong&gt; at &lt;strong&gt;{toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}% skin exposure&lt;\/strong&gt;, UVA light liberates dermal &lt;em&gt;nitric oxide (NO)&lt;\/em&gt; stores into circulation (supporting natural arterial vasodilation), while Near-Infrared (NIR) photons penetrate deep into muscle mitochondria to reduce oxidative stress.\n                      &lt;\/p&gt;\n                    &lt;\/div&gt;\n                  &lt;\/div&gt;\n\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3\"&gt;\n                    &lt;h2 className=\"text-base font-bold text-slate-900\"&gt;Sleep Duration &amp; Dawn Glucose&lt;\/h2&gt;\n                    &lt;div className=\"flex justify-between font-semibold\"&gt;\n                      &lt;span&gt;Total Sleep&lt;\/span&gt;\n                      &lt;span className=\"text-indigo-600 font-bold\"&gt;{toSafeFloat(lifestyle.sleepHours, 0, 0, 10)} hrs&lt;\/span&gt;\n                    &lt;\/div&gt;\n                    &lt;input\n                      type=\"range\"\n                      min=\"0\"\n                      max=\"10\"\n                      step=\"0.5\"\n                      value={toSafeFloat(lifestyle.sleepHours, 0, 0, 10)}\n                      onChange={e =&gt; setLifestyle({ ...lifestyle, sleepHours: toSafeFloat(e.target.value, 0, 0, 10) })}\n                      className=\"w-full accent-indigo-600\"\n                    \/&gt;\n                    &lt;p className=\"text-slate-600\"&gt;\n                      Sleeping &amp;lt;6.5 hours acutely reduces insulin sensitivity by 24\u201330% the following morning.\n                    &lt;\/p&gt;\n                  &lt;\/div&gt;\n\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-3\"&gt;\n                    &lt;h2 className=\"text-base font-bold text-slate-900\"&gt;\n                      Cortisol &amp; Stress Scale &lt;Tooltip text={CLINICAL_TOOLTIPS.cortisol} \/&gt;\n                    &lt;\/h2&gt;\n                    &lt;div className=\"flex justify-between font-semibold\"&gt;\n                      &lt;span&gt;Daily Stress Level&lt;\/span&gt;\n                      &lt;span className=\"text-rose-600 font-bold\"&gt;{toSafeFloat(lifestyle.stressScore, 5, 1, 10)} \/ 10&lt;\/span&gt;\n                    &lt;\/div&gt;\n                    &lt;input\n                      type=\"range\"\n                      min=\"1\"\n                      max=\"10\"\n                      value={toSafeFloat(lifestyle.stressScore, 5, 1, 10)}\n                      onChange={e =&gt; setLifestyle({ ...lifestyle, stressScore: toSafeFloat(e.target.value, 5, 1, 10) })}\n                      className=\"w-full accent-rose-600\"\n                    \/&gt;\n                    &lt;p className=\"text-slate-600\"&gt;\n                      Elevated cortisol triggers hepatic gluconeogenesis, raising blood sugar even during fasting.\n                    &lt;\/p&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              )}\n\n              {activeTab === 'insights' &amp;&amp; (\n                &lt;div className=\"grid grid-cols-1 md:grid-cols-2 gap-6 text-xs\"&gt;\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-2.5\"&gt;\n                    &lt;h3 className=\"text-base font-bold text-slate-900\"&gt;1. Insulin Sensitivity &amp; Blood Sugar Action Guide&lt;\/h3&gt;\n                    &lt;p className=\"text-slate-700\"&gt;\n                      \u2022 &lt;strong&gt;HOMA-IR ({clinicalMetrics.homaIr !== null ? clinicalMetrics.homaIr : 'Not Entered'}):&lt;\/strong&gt;{' '}\n                      {clinicalMetrics.homaIr === null\n                        ? 'Enter your Fasting Insulin and Fasting Glucose in Tab 1 to calculate your HOMA-IR score.'\n                        : clinicalMetrics.homaIr &lt; 1.5\n                        ? 'Optimal insulin sensitivity range maintained.'\n                        : 'Elevated insulin resistance marker. Research shows eating fibrous vegetables first, cooling\/reheating cooked starches (RS3), and taking a 15-minute brisk walk after dinner help flatten post-meal glucose spikes.'}\n                    &lt;\/p&gt;\n                  &lt;\/div&gt;\n                  &lt;div className=\"bg-white rounded-2xl p-6 shadow-sm border border-slate-200 space-y-2.5\"&gt;\n                    &lt;h3 className=\"text-base font-bold text-slate-900\"&gt;2. Liver Wellness &amp; Healthy Lipid Habits&lt;\/h3&gt;\n                    &lt;p className=\"text-slate-700\"&gt;\n                      \u2022 &lt;strong&gt;Liver Enzymes (ALT {profile.alt ? `${profile.alt} U\/L` : 'Not Entered'}) &amp; Cooking Fats:&lt;\/strong&gt;{' '}\n                      {nutrition.cookingFat === 'refined-seed'\n                        ? 'Consider replacing refined seed oils with traditional fats like A2 Ghee, Cold-Pressed Coconut Oil, or Extra Virgin Olive Oil to reduce dietary lipid oxidation.'\n                        : 'Your selected cooking fat supports cellular membrane stability. Aim for ~550mg of daily dietary choline (from wholefoods like sprouted legumes, cruciferous vegetables, or eggs) to support healthy liver fat metabolism.'}\n                    &lt;\/p&gt;\n                  &lt;\/div&gt;\n                &lt;\/div&gt;\n              )}\n            &lt;\/main&gt;\n          &lt;\/div&gt;\n\n          {\/* Dedicated Personal PDF Summary Layout (Table-Based, High-Contrast &amp; Zero Overlap) *\/}\n          &lt;div className=\"hidden print-only\"&gt;\n            &lt;div style={{ borderBottom: '3px solid #0f766e', paddingBottom: '10px', marginBottom: '14px' }}&gt;\n              &lt;table style={{ width: '100%', borderCollapse: 'collapse' }}&gt;\n                &lt;tbody&gt;\n                  &lt;tr&gt;\n                    &lt;td style={{ border: 'none', padding: 0 }}&gt;\n                      &lt;div style={{ fontSize: '18pt', fontWeight: 800, color: '#0f172a' }}&gt;\n                        MetabolicGuide \u2014 Personal Nutrition &amp;amp; Lifestyle Summary\n                      &lt;\/div&gt;\n                      &lt;div style={{ fontSize: '9.5pt', color: '#475569', marginTop: '2px' }}&gt;\n                        Generated via GroundReportIndia.org \u2022 Date: {new Date().toLocaleDateString()} \u2022 Educational Self-Tracking Report\n                      &lt;\/div&gt;\n                    &lt;\/td&gt;\n                    &lt;td style={{ border: 'none', padding: 0, textAlign: 'right', width: '170px' }}&gt;\n                      &lt;div style={{ fontSize: '8.5pt', fontWeight: 700, textTransform: 'uppercase', color: '#0f766e' }}&gt;\n                        Metabolic Lifestyle Score\n                      &lt;\/div&gt;\n                      &lt;div style={{ fontSize: '20pt', fontWeight: 900, color: '#0f172a' }}&gt;\n                        {clinicalMetrics.reversalScore} \/ 100\n                      &lt;\/div&gt;\n                    &lt;\/td&gt;\n                  &lt;\/tr&gt;\n                &lt;\/tbody&gt;\n              &lt;\/table&gt;\n            &lt;\/div&gt;\n\n            {\/* Section 1: Profile &amp; Anthropometrics *\/}\n            &lt;div className=\"print-section-title\"&gt;1. Personal Profile &amp;amp; Body Measurements&lt;\/div&gt;\n            &lt;table className=\"print-table\"&gt;\n              &lt;thead&gt;\n                &lt;tr&gt;\n                  &lt;th style={{ width: '25%' }}&gt;Profile Alias&lt;\/th&gt;\n                  &lt;th style={{ width: '25%' }}&gt;Age &amp;amp; Biological Sex&lt;\/th&gt;\n                  &lt;th style={{ width: '25%' }}&gt;Weight, Height &amp;amp; BMI&lt;\/th&gt;\n                  &lt;th style={{ width: '25%' }}&gt;Waist-to-Hip &amp;amp; WHtR&lt;\/th&gt;\n                &lt;\/tr&gt;\n              &lt;\/thead&gt;\n              &lt;tbody&gt;\n                &lt;tr&gt;\n                  &lt;td&gt;&lt;strong&gt;{toSafeStr(profile.alias, 'Anonymous Reader', 40) || 'Anonymous Reader'}&lt;\/strong&gt;&lt;\/td&gt;\n                  &lt;td&gt;{profile.age || '\u2014'} yrs \/ {toSafeStr(profile.gender, 'male', 10).toUpperCase()}&lt;\/td&gt;\n                  &lt;td&gt;\n                    {profile.weightKg || '\u2014'} kg \u2022 {profile.heightCm || '\u2014'} cm&lt;br \/&gt;\n                    &lt;strong&gt;BMI: {clinicalMetrics.bmi !== null ? clinicalMetrics.bmi : '\u2014'}&lt;\/strong&gt;\n                  &lt;\/td&gt;\n                  &lt;td&gt;\n                    &lt;strong&gt;WHR: {clinicalMetrics.whr !== null ? clinicalMetrics.whr : '\u2014'}&lt;\/strong&gt; (Waist: {profile.waistCm || '\u2014'}cm)&lt;br \/&gt;\n                    &lt;strong&gt;WHtR: {clinicalMetrics.whtr !== null ? clinicalMetrics.whtr : '\u2014'}&lt;\/strong&gt; (Target: &amp;lt;0.50)\n                  &lt;\/td&gt;\n                &lt;\/tr&gt;\n              &lt;\/tbody&gt;\n            &lt;\/table&gt;\n\n            {\/* Section 2: Endocrine, Glycemic &amp; Hepatic Biomarkers *\/}\n            &lt;div className=\"print-section-title\"&gt;2. Endocrine, Blood Sugar, Lipid &amp;amp; Liver Biomarkers&lt;\/div&gt;\n            &lt;table className=\"print-table\"&gt;\n              &lt;thead&gt;\n                &lt;tr&gt;\n                  &lt;th style={{ width: '33%' }}&gt;HOMA-IR &amp;amp; Glycemic Control&lt;\/th&gt;\n                  &lt;th style={{ width: '33%' }}&gt;Lipids &amp;amp; TG:HDL Ratio&lt;\/th&gt;\n                  &lt;th style={{ width: '34%' }}&gt;Blood Pressure &amp;amp; Liver Enzymes&lt;\/th&gt;\n                &lt;\/tr&gt;\n              &lt;\/thead&gt;\n              &lt;tbody&gt;\n                &lt;tr&gt;\n                  &lt;td&gt;\n                    &lt;strong&gt;HOMA-IR: {clinicalMetrics.homaIr !== null ? `${clinicalMetrics.homaIr} (${clinicalMetrics.homaIr &lt; 1.5 ? 'Optimal' : 'Resistant'})` : 'Not Entered'}&lt;\/strong&gt;&lt;br \/&gt;\n                    HbA1c: &lt;strong&gt;{clinicalMetrics.hba1cVal !== null ? `${clinicalMetrics.hba1cVal}%` : '\u2014'}&lt;\/strong&gt;&lt;br \/&gt;\n                    Fasting Insulin: {profile.fastingInsulin || '\u2014'} \u03bcIU\/mL&lt;br \/&gt;\n                    Fasting Glucose: {profile.fastingGlucose || '\u2014'} mg\/dL\n                  &lt;\/td&gt;\n                  &lt;td&gt;\n                    &lt;strong&gt;TG:HDL Ratio: {clinicalMetrics.tgHdlRatio !== null ? clinicalMetrics.tgHdlRatio : '\u2014'}&lt;\/strong&gt; (Target: &amp;lt;2.0)&lt;br \/&gt;\n                    Triglycerides: {profile.triglycerides || '\u2014'} mg\/dL&lt;br \/&gt;\n                    HDL Cholesterol: {profile.hdl || '\u2014'} mg\/dL&lt;br \/&gt;\n                    Dietary Preference: {toSafeStr(profile.dietPreference, 'lacto', 20).toUpperCase()}\n                  &lt;\/td&gt;\n                  &lt;td&gt;\n                    &lt;strong&gt;Blood Pressure: {clinicalMetrics.sysBP !== null &amp;&amp; clinicalMetrics.diaBP !== null ? `${clinicalMetrics.sysBP}\/${clinicalMetrics.diaBP} mmHg` : '\u2014'}&lt;\/strong&gt;&lt;br \/&gt;\n                    Liver ALT: &lt;strong&gt;{clinicalMetrics.altVal !== null ? `${clinicalMetrics.altVal} U\/L` : '\u2014'}&lt;\/strong&gt;&lt;br \/&gt;\n                    Liver AST: {clinicalMetrics.astVal !== null ? `${clinicalMetrics.astVal} U\/L` : '\u2014'}&lt;br \/&gt;\n                    Liver GGT: {toValidNum(profile.ggt) !== null ? `${toValidNum(profile.ggt)} U\/L` : '\u2014'}\n                  &lt;\/td&gt;\n                &lt;\/tr&gt;\n              &lt;\/tbody&gt;\n            &lt;\/table&gt;\n\n            {\/* Section 3: Daily Nutrition, Sequencing &amp; Hydration *\/}\n            &lt;div className=\"print-section-title\"&gt;3. Nutrition, Meal Sequencing, Resistant Starch &amp;amp; Hydration&lt;\/div&gt;\n            &lt;table className=\"print-table\"&gt;\n              &lt;thead&gt;\n                &lt;tr&gt;\n                  &lt;th style={{ width: '50%' }}&gt;Calorie, Macronutrient &amp;amp; Mineral Intake&lt;\/th&gt;\n                  &lt;th style={{ width: '50%' }}&gt;Meal Sequencing, Cooking Fats &amp;amp; Hydration&lt;\/th&gt;\n                &lt;\/tr&gt;\n              &lt;\/thead&gt;\n              &lt;tbody&gt;\n                &lt;tr&gt;\n                  &lt;td&gt;\n                    Calories Logged: &lt;strong&gt;{nutritionTotals.cal} kcal&lt;\/strong&gt; (Target: {clinicalMetrics.targetCalories &gt; 0 ? `${clinicalMetrics.targetCalories} kcal` : '\u2014'})&lt;br \/&gt;\n                    Protein &amp;amp; Leucine: &lt;strong&gt;{nutritionTotals.pro}g Protein&lt;\/strong&gt; ({nutritionTotals.leucine}g Leucine)&lt;br \/&gt;\n                    Carbohydrates: &lt;strong&gt;{nutritionTotals.netCarbs}g Net Carbs&lt;\/strong&gt; ({nutritionTotals.fiber}g Fiber)&lt;br \/&gt;\n                    Total Fat &amp;amp; Omega-3: &lt;strong&gt;{nutritionTotals.fat}g Fat&lt;\/strong&gt; (SFA: {nutritionTotals.sfa}g, MUFA: {nutritionTotals.mufa}g, PUFA: {nutritionTotals.pufa}g, Omega-3: {nutritionTotals.omega3}g)&lt;br \/&gt;\n                    Minerals (%DV): Mg: &lt;strong&gt;{nutritionTotals.mg}mg&lt;\/strong&gt; \u2022 K: &lt;strong&gt;{nutritionTotals.k}mg&lt;\/strong&gt; \u2022 Ca: &lt;strong&gt;{nutritionTotals.ca}mg&lt;\/strong&gt; \u2022 Fe: &lt;strong&gt;{nutritionTotals.fe}mg&lt;\/strong&gt; \u2022 Zn: &lt;strong&gt;{nutritionTotals.zn}mg&lt;\/strong&gt;&lt;br \/&gt;\n                    Vitamins &amp;amp; Choline: Choline: &lt;strong&gt;{nutritionTotals.choline}mg&lt;\/strong&gt; \u2022 Vit C: &lt;strong&gt;{nutritionTotals.vitC}mg&lt;\/strong&gt; \u2022 Folate: &lt;strong&gt;{nutritionTotals.folate}mcg&lt;\/strong&gt; \u2022 Vit B12: &lt;strong&gt;{nutritionTotals.b12}mcg&lt;\/strong&gt;\n                  &lt;\/td&gt;\n                  &lt;td&gt;\n                    Meal Sequence: &lt;strong&gt;{nutrition.mealSequence}&lt;\/strong&gt;&lt;br \/&gt;\n                    Starch Preparation (RS3): &lt;strong&gt;{nutrition.starchPrepMethod}&lt;\/strong&gt;&lt;br \/&gt;\n                    Primary Cooking Fat: &lt;strong&gt;{nutrition.cookingFat}&lt;\/strong&gt;&lt;br \/&gt;\n                    Daily Snacking Frequency: &lt;strong&gt;{nutrition.snackingCount} snacks\/day&lt;\/strong&gt;&lt;br \/&gt;\n                    Total Hydration Logged: &lt;strong&gt;{nutritionTotals.totalWaterMl} ml&lt;\/strong&gt;\n                  &lt;\/td&gt;\n                &lt;\/tr&gt;\n              &lt;\/tbody&gt;\n            &lt;\/table&gt;\n\n            {\/* Section 4: Fasting, Movement &amp; Circadian Lifestyle *\/}\n            &lt;div className=\"print-section-title\"&gt;4. Fasting Protocol, Post-Meal Movement &amp;amp; Circadian Lifestyle&lt;\/div&gt;\n            &lt;table className=\"print-table\"&gt;\n              &lt;thead&gt;\n                &lt;tr&gt;\n                  &lt;th style={{ width: '50%' }}&gt;Fasting &amp;amp; Circadian Eating Window&lt;\/th&gt;\n                  &lt;th style={{ width: '50%' }}&gt;Post-Meal Walks, Sunlight, Sleep &amp;amp; Stress&lt;\/th&gt;\n                &lt;\/tr&gt;\n              &lt;\/thead&gt;\n              &lt;tbody&gt;\n                &lt;tr&gt;\n                  &lt;td&gt;\n                    Active Fasting Regimen: &lt;strong&gt;{fasting.protocol}&lt;\/strong&gt; ({fasting.fastingType})&lt;br \/&gt;\n                    Current Fast Duration: &lt;strong&gt;{toSafeFloat(fasting.currentFastHours, 0, 0, 48)} hours&lt;\/strong&gt;&lt;br \/&gt;\n                    Distinct Meals Per Day: &lt;strong&gt;{fasting.mealsPerDay} meal(s)\/day&lt;\/strong&gt;&lt;br \/&gt;\n                    Pre-Sleep Digestion Gap: &lt;strong&gt;{clinicalMetrics.eveningGapHours !== null ? `${clinicalMetrics.eveningGapHours} hours` : 'Not Entered'}&lt;\/strong&gt; (Target: 3+ hours)\n                  &lt;\/td&gt;\n                  &lt;td&gt;\n                    15m+ Post-Meal Walks: Breakfast: &lt;strong&gt;{activity?.postMealWalks?.breakfastWalk ? `Yes (${activity.postMealWalks.breakfastWalkMins || 15}m, ${activity.postMealWalks.breakfastWalkPace || 'normal'})` : 'No'}&lt;\/strong&gt; \u2022 Lunch: &lt;strong&gt;{activity?.postMealWalks?.lunchWalk ? `Yes (${activity.postMealWalks.lunchWalkMins || 20}m, ${activity.postMealWalks.lunchWalkPace || 'brisk'})` : 'No'}&lt;\/strong&gt; \u2022 Dinner: &lt;strong&gt;{activity?.postMealWalks?.dinnerWalk ? `Yes (${activity.postMealWalks.dinnerWalkMins || 30}m, ${activity.postMealWalks.dinnerWalkPace || 'normal'})` : 'No'}&lt;\/strong&gt;&lt;br \/&gt;\n                    Workouts Logged Today: &lt;strong&gt;{activity.workouts.length} session(s)&lt;\/strong&gt; (Daily Steps: {toSafeFloat(activity.dailySteps, 0, 0, 100000).toLocaleString()})&lt;br \/&gt;\n                    Sunlight Exposure: &lt;strong&gt;{toSafeFloat(lifestyle.sunlightDurationMin, 0, 0, 60)} mins&lt;\/strong&gt; at &lt;strong&gt;{toSafeFloat(lifestyle.skinExposurePct, 25, 0, 100)}% skin exposed&lt;\/strong&gt; ({lifestyle.sunlightTimeOfDay})&lt;br \/&gt;\n                    Sleep &amp;amp; Stress: &lt;strong&gt;{toSafeFloat(lifestyle.sleepHours, 0, 0, 10)} hrs sleep&lt;\/strong&gt; \u2022 Stress Score: &lt;strong&gt;{toSafeFloat(lifestyle.stressScore, 5, 1, 10)} \/ 10&lt;\/strong&gt;\n                  &lt;\/td&gt;\n                &lt;\/tr&gt;\n              &lt;\/tbody&gt;\n            &lt;\/table&gt;\n\n            {\/* Section 5: Science-Based Action Guide *\/}\n            &lt;div className=\"print-section-title\"&gt;5. Personalized Science-Based Action Guide&lt;\/div&gt;\n            &lt;table className=\"print-table\"&gt;\n              &lt;tbody&gt;\n                &lt;tr&gt;\n                  &lt;td&gt;\n                    &lt;strong&gt;\u2022 Insulin Sensitivity &amp;amp; Glycemic Control:&lt;\/strong&gt;{' '}\n                    {clinicalMetrics.homaIr !== null &amp;&amp; clinicalMetrics.homaIr &gt;= 1.5\n                      ? `Your HOMA-IR (${clinicalMetrics.homaIr}) indicates insulin resistance. Prioritize eating fiber\/vegetables and protein before starches, cool cooked rice\/potatoes for 12-24h to form Resistant Starch (RS3), finish meals with whole lemon (skin, seeds &amp; juice), and walk briskly for 15 minutes after dinner.`\n                      : 'Maintain post-meal glucose stability by sequencing fibrous vegetables and protein first, avoiding between-meal grazing, and walking 15 minutes after main meals.'}\n                    &lt;br \/&gt;&lt;br \/&gt;\n                    &lt;strong&gt;\u2022 Liver Wellness, Cooking Lipids &amp;amp; Circadian Rhythm:&lt;\/strong&gt;{' '}\n                    {nutrition.cookingFat === 'refined-seed'\n                      ? 'Replace refined seed oils with traditional stable fats (A2 Ghee, Cold-Pressed Coconut Oil, or Extra Virgin Olive Oil) to reduce hepatic lipid peroxidation, and aim for a 3+ hour gap between your last meal and bedtime.'\n                      : 'Continue using stable cooking fats (A2 Ghee \/ Cold-Pressed oils), aim for ~550mg of daily dietary choline from whole foods, and maintain at least a 3-hour digestion gap before sleep.'}\n                  &lt;\/td&gt;\n                &lt;\/tr&gt;\n              &lt;\/tbody&gt;\n            &lt;\/table&gt;\n\n            {\/* Print Educational Disclaimer *\/}\n            &lt;div style={{ padding: '10px 12px', border: '1px solid #94a3b8', backgroundColor: '#f8fafc', fontSize: '8.5pt', color: '#334155', marginTop: '10px' }}&gt;\n              &lt;strong&gt;Educational &amp;amp; Informational Disclaimer:&lt;\/strong&gt; MetabolicGuide on GroundReportIndia.org is an educational nutrition and lifestyle self-tracking tool based on peer-reviewed metabolic research. It does not provide medical advice, clinical diagnosis, or medical prescriptions. Always consult a qualified physician or healthcare provider before modifying medications, fasting regimens, or diet plans.\n            &lt;\/div&gt;\n          &lt;\/div&gt;\n\n          {\/* Screen Footer Disclaimer *\/}\n          &lt;footer className=\"no-print max-w-7xl mx-auto px-4 sm:px-6 pt-6 pb-4\"&gt;\n            &lt;div className=\"bg-white rounded-2xl p-4 border border-slate-200 text-[11px] text-slate-500 leading-relaxed flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3\"&gt;\n              &lt;div&gt;\n                &lt;strong className=\"text-slate-700\"&gt;Educational &amp; Informational Disclaimer (GroundReportIndia.org):&lt;\/strong&gt;{' '}\n                MetabolicGuide is an educational self-tracking wellness guide and is not a substitute for professional medical advice, diagnosis, or treatment. Always consult your physician before changing your diet, exercise, or medication routine.\n              &lt;\/div&gt;\n              &lt;div className=\"shrink-0 font-semibold text-teal-700\"&gt;\n                Privacy-First Cloud &amp; Local Vault\n              &lt;\/div&gt;\n            &lt;\/div&gt;\n          &lt;\/footer&gt;\n        &lt;\/div&gt;\n      );\n    }\n\n    const rootElement = document.getElementById('root');\n    const root = ReactDOM.createRoot(rootElement);\n    root.render(\n      &lt;ClinicalErrorBoundary&gt;\n        &lt;App \/&gt;\n      &lt;\/ClinicalErrorBoundary&gt;\n    );\n  [\/tcb-script]<\/code>\n\n<\/div>","tve_custom_css":"","tve_user_custom_css":"","tve_globals":{"e":"1","font_cls":[]},"tcb2_ready":1,"tcb_editor_enabled":1,"tve_landing_page":"","_tve_header":"","_tve_footer":""},"categories":[552],"tags":[533],"gri_pub_year":[],"gri_pub_month":[],"gri_volume":[],"gri_edition":[],"class_list":["post-14569","post","type-post","status-publish","format-standard","hentry","category-csr","tag-health"],"_links":{"self":[{"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/posts\/14569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/comments?post=14569"}],"version-history":[{"count":15,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/posts\/14569\/revisions"}],"predecessor-version":[{"id":14599,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/posts\/14569\/revisions\/14599"}],"wp:attachment":[{"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/media?parent=14569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/categories?post=14569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/tags?post=14569"},{"taxonomy":"gri_pub_year","embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/gri_pub_year?post=14569"},{"taxonomy":"gri_pub_month","embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/gri_pub_month?post=14569"},{"taxonomy":"gri_volume","embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/gri_volume?post=14569"},{"taxonomy":"gri_edition","embeddable":true,"href":"https:\/\/groundreportindia.org\/monthly\/wp-json\/wp\/v2\/gri_edition?post=14569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}