@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
  
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  
  :root {
    /* Cores mais harmoniosas, limpas e elegantes (Slate / Indigo palette) */
    --background: #f1f5f9; /* Fundo off-white acinzentado chique */
    --surface: #ffffff; /* Cartões brancos */
    --surface-alt: #f8fafc; /* Destaques muito sutis */
    --border: #e2e8f0;
    
    --primary: #6366f1; /* Indigo 500 - mais vibrante */
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    
    --success: #059669; /* Emerald 600 - verde elegante */
    --success-light: #d1fae5;
    
    --warning: #d97706; /* Amber 600 */
    --warning-light: #fef3c7;
    
    --danger: #e11d48; /* Rose 600 - vermelho moderno */
    --danger-light: #ffe4e6;
    
    --text: #0f172a; /* Slate 900 - quase preto com toque azulado */
    --text-muted: #64748b; /* Slate 500 */
    
    --radius: 20px; 
    --radius-sm: 12px;
    --nav-h: 64px; 
    --bottom-nav-h: 70px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  }

body { font-family: 'Inter', system-ui, sans-serif; background: var(--background); color: var(--text); font-size: 15px; padding-bottom: env(safe-area-inset-bottom); }
  @media (display-mode: standalone) { body { padding-top: env(safe-area-inset-top); } }

  /* ── TOP NAV ── */
  .top-nav { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 0 20px; height: var(--nav-h); position: sticky; top: 0; z-index: 200; box-shadow: var(--shadow-sm); }
  .nav-logo { font-weight: 800; font-size: 18px; color: var(--primary); display: flex; align-items: center; gap: 8px; margin-right: 16px; letter-spacing: -0.5px; }
  .nav-btn { padding: 8px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: 14px; font-weight: 600; background: transparent; color: var(--text-muted); transition: all 0.2s; }
  .nav-btn:hover { background: var(--surface-alt); color: var(--text); }
  .nav-btn.active { background: var(--primary-light); color: var(--primary); }

  /* ── BOTTOM NAV (mobile) ── */
  .bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 200; height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 10px rgb(0 0 0 / 0.05); }
  .bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; height: var(--bottom-nav-h); padding: 0 8px; }
  .bnav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 64px; height: 100%; border: none; background: transparent; color: var(--text-muted); font-size: 10px; font-weight: 600; cursor: pointer; gap: 4px; transition: color 0.2s; }
  .bnav-btn .ico { font-size: 22px; transition: transform 0.2s; }
  .bnav-btn.active { color: var(--primary); }
  .bnav-btn.active .ico { transform: translateY(-3px); }

  /* ── PAGES & LAYOUT ── */
  .page { display: none; padding: 20px; max-width: 1000px; margin: 0 auto; padding-bottom: 30px; animation: fadeIn 0.3s ease; }
  .page.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

  /* ── SUB-NAVIGATION (Tabs) ── */
  .sub-nav { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .sub-nav::-webkit-scrollbar { display: none; }
  .sub-tab { padding: 10px 20px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--text-muted); cursor: pointer; white-space: nowrap; transition: all 0.2s; box-shadow: var(--shadow-sm); }
  .sub-tab.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: var(--shadow); }

  /* ── CARDS ── */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
  .card-title { font-weight: 700; font-size: 16px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; color: var(--text); }
  .food-create-panel > summary { list-style:none; cursor:pointer; display:flex; align-items:center; justify-content:space-between; font-weight:800; font-size:16px; }
  .food-create-panel > summary::-webkit-details-marker { display:none; }
  .food-create-panel > summary::after { content:'＋'; color:var(--primary); font-size:22px; transition:transform .2s; }
  .food-create-panel[open] > summary::after { transform:rotate(45deg); }
  .food-create-panel .panel-body { padding-top:20px; }

  /* ── CALENDAR ── */
  .calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding: 0 4px; }
  .calendar-month { font-weight: 800; font-size: 16px; color: var(--text); }
  .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 20px; }
  .cal-col { display: flex; flex-direction: column; gap: 6px; }
  .cal-top { border: 1px solid var(--border); border-radius: 14px; padding: 8px 0; text-align: center; cursor: pointer; transition: all 0.2s; position: relative; background: var(--surface); color:inherit; font:inherit; width:100%; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; align-items: center; justify-content: center; height: 58px; }
  .cal-top.active { background: var(--text); color: white; border-color: var(--text); transform: scale(1.05); box-shadow: var(--shadow); }
  .cal-top .today-mark { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 12px; height: 4px; background: var(--danger); border-radius: 4px; }
  .cal-dow { font-size: 10px; font-weight: 700; text-transform: uppercase; margin-bottom: 2px; opacity: 0.8; letter-spacing: 0.5px; }
  .cal-num { font-size: 18px; font-weight: 800; line-height: 1; }
  .cal-bottom { display: flex; flex-direction: column; gap: 4px; }
  .cal-metric { font-size: 10px; font-weight: 800; text-align: center; padding: 5px 0; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); line-height: 1; }
  .cal-metric.kcal { color: var(--primary); }
  .cal-metric.fast { color: var(--success); }

  /* ── FASTING WIDGET ── */
  .fasting-card { background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%); color: white; border-radius: var(--radius); padding: 24px; margin-bottom: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; text-align: center; }
  .fasting-card::after { content: '⏱️'; position: absolute; right: -15px; top: -15px; font-size: 120px; opacity: 0.04; transform: rotate(15deg); pointer-events: none; }
  
  .fast-circle-wrap { position: relative; width: 200px; height: 200px; margin: 10px auto 20px; }
  .fast-circle { transform: rotate(-90deg); width: 100%; height: 100%; position: absolute; top: 0; left: 0; pointer-events: none; }
  .fast-circle-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 8; }
  .fast-circle-prog { fill: none; stroke: #38bdf8; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.3s ease; stroke-dasharray: 502.65; stroke-dashoffset: 502.65; }
  
  .fasting-timer { font-size: 38px; font-weight: 800; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; line-height: 1; margin-bottom: 6px; }
  .fasting-goal-text { font-size: 13px; color: rgba(255,255,255,0.8); font-weight: 500; }
  
  .fasting-phase { display: inline-flex; align-items: center; justify-content: center; padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 700; background: rgba(255,255,255,0.15); margin-bottom: 16px; backdrop-filter: blur(4px); transition: all 0.3s; }
  
  .fast-history-item { display: flex; justify-content: space-between; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; box-shadow: var(--shadow-sm); }
  .fast-history-item:last-child { margin-bottom: 0; }
  .fast-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:16px; }
  .fast-stat { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm); padding:14px 8px; text-align:center; }
  .fast-stat strong { display:block; font-size:20px; color:var(--primary); }
  .fast-stat span { display:block; margin-top:4px; font-size:10px; font-weight:700; color:var(--text-muted); text-transform:uppercase; }

  /* ── MACRO GRID ── */
  .macro-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
  .macro-card { background: var(--surface-alt); border-radius: var(--radius-sm); padding: 14px 8px; text-align: center; border: 1px solid var(--border); }
  .macro-card .val { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
  .macro-card .lbl { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
  .macro-card.kcal .val { color: var(--primary); }
  .macro-card.carbo .val { color: var(--warning); }
  .macro-card.prot .val { color: var(--success); }
  .macro-card.gord .val { color: var(--danger); }
  .progress-bar { height: 6px; border-radius: 6px; background: #e2e8f0; margin-top: 10px; overflow: hidden; }
  .progress-fill { height: 100%; border-radius: 6px; transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
  .insight-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; }
  .insight { padding:16px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface-alt); }
  .insight strong { display:block; font-size:22px; letter-spacing:-.5px; margin-top:5px; }
  .insight span { font-size:12px; color:var(--text-muted); font-weight:700; }

  /* ── FORMS & INPUTS ── */
  .form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; align-items: flex-end; }
  .form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 130px; }
  .form-group label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
  select, input[type=text], input[type=number], input[type=date], input[type=datetime-local] {
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 15px; background: var(--surface-alt); color: var(--text); width: 100%; font-family: inherit; transition: all 0.2s;
  }
  select:focus, input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-light); }

  /* ── BUTTONS ── */
  .btn { padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; font-size: 14px; font-weight: 600; background: var(--surface); color: var(--text); transition: all 0.2s; white-space: nowrap; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: var(--shadow-sm); }
  .btn:active { transform: scale(0.97); }
  :focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
  .sr-only { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
  .btn:hover { background: var(--surface-alt); }
  .btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
  .btn-primary:hover { background: var(--primary-hover); }
  .btn-danger { background: var(--danger-light); color: var(--danger); border-color: transparent; box-shadow: none; }
  .btn-danger:hover { background: #fca5a5; }
  .btn-sm { padding: 8px 14px; font-size: 13px; }
  
  /* ── TABLES ── */
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--border); }
  table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 500px; background: var(--surface); }
  th { text-align: left; padding: 14px 16px; background: var(--surface-alt); color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
  td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  .tbl-num { text-align: right; font-variant-numeric: tabular-nums; }

  /* ── AUTOCOMPLETE ── */
  .ac-wrap { position: relative; flex: 2; min-width: 200px; }
  .ac-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto; z-index: 300; box-shadow: var(--shadow-lg); display: none; }
  .ac-dropdown.open { display: block; }
  .ac-item { padding: 12px 14px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border); }
  .ac-item:last-child { border-bottom: none; }
  .ac-item:hover, .ac-item.selected { background: var(--primary-light); color: var(--primary); }
  .ac-item small { color: var(--text-muted); font-size: 12px; display: block; margin-top: 2px; }

  /* ── MODALS (Edit & Confirm) ── */
  .modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); transition: opacity 0.2s; }
  .modal-overlay.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
  .modal { background: var(--surface); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); transform: scale(1); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
  .modal-overlay.hidden .modal { transform: scale(0.95); }
  .modal-title { font-weight: 800; font-size: 18px; margin-bottom: 16px; color: var(--text); }
  .modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

  /* ── MISC ── */
  h2 { font-size: 24px; font-weight: 800; margin-bottom: 24px; letter-spacing: -0.5px; color: var(--text); }
  .badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
  .empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 15px; font-weight: 500; background: var(--surface-alt); border-radius: var(--radius); border: 2px dashed var(--border); }
  #toast { position: fixed; bottom: calc(var(--bottom-nav-h) + 20px); left: 50%; transform: translateX(-50%) translateY(20px); background: #1e293b; color: white; padding: 14px 28px; border-radius: 30px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); z-index: 9999; box-shadow: var(--shadow-lg); white-space: nowrap; }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .pwa-update { position:fixed; left:50%; bottom:24px; transform:translateX(-50%); width:min(560px,calc(100% - 32px)); z-index:10000; display:flex; align-items:center; gap:12px; padding:14px 16px; color:white; background:#1e293b; border-radius:16px; box-shadow:var(--shadow-lg); }
  .pwa-update.hidden { display:none; }
  .pwa-update span { flex:1; font-size:14px; font-weight:600; line-height:1.4; }
  .pwa-update-close { border:0; background:transparent; color:white; font-size:18px; cursor:pointer; padding:6px; }

  /* ── RESPONSIVE TWEAKS ── */
  @media (max-width: 768px) {
    .top-nav { display: none; }
    .bottom-nav { display: block; }
    .page { padding: 16px 16px calc(var(--bottom-nav-h) + 24px); }
    h2 { font-size: 22px; margin-bottom: 16px; }
    .macro-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .form-row { flex-direction: column; gap: 12px; }
    .form-row > div { width: 100%; }
    .modal { padding: 20px; }
    .pwa-update { bottom:calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px); flex-wrap:wrap; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }
