/* ============================================================
   ÁPICE — hoja de estilos
   Dark-first, acentos vibrantes, móvil-first.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #0B0D12;
  --bg-elev: #12151E;
  --bg-card: #171B26;
  --bg-input: #10141D;
  --border: #242B3B;
  --border-soft: #1C2230;
  --text: #F2F5FA;
  --text-dim: #9AA5B8;
  --text-faint: #67718A;
  --primary: #10B981;
  --primary-strong: #0EA371;
  --primary-soft: rgba(16, 185, 129, 0.14);
  --accent: #FF6B35;
  --accent-soft: rgba(255, 107, 53, 0.16);
  --protein: #4E8CFF;
  --fat: #F5B93E;
  --carbs: #34D399;
  --danger: #F43F5E;
  --success: #10B981;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.28);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --maxw: 480px;
}

[data-theme="light"] {
  --bg: #F4F6FA;
  --bg-elev: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-input: #EFF2F8;
  --border: #E3E8F1;
  --border-soft: #EDF1F7;
  --text: #0F1522;
  --text-dim: #5A6478;
  --text-faint: #9AA3B5;
  --primary-soft: rgba(16, 185, 129, 0.12);
  --accent-soft: rgba(255, 107, 53, 0.12);
  --shadow: 0 12px 34px rgba(20, 30, 60, 0.12);
  --shadow-soft: 0 4px 14px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app { max-width: var(--maxw); margin: 0 auto; min-height: 100vh; position: relative; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- utilidades ---------- */
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.tiny { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.grow { flex: 1; }
.emoji-lg { font-size: 26px; }

/* ============================================================
   ONBOARDING
   ============================================================ */
#screen-onboarding { min-height: 100vh; display: flex; flex-direction: column; }
.ob-hero {
  padding: 34px 26px 22px;
  display: flex; flex-direction: column; gap: 6px;
}
.ob-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.ob-logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, #10B981, #0D9488);
  display: grid; place-items: center; font-size: 24px; color: #fff;
  box-shadow: 0 6px 18px rgba(16, 185, 129, .35);
}
.ob-brand h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.ob-brand .tag { color: var(--text-dim); font-size: 13px; }
.ob-hero h2 { font-size: 30px; font-weight: 900; letter-spacing: -.03em; line-height: 1.12; }
.ob-hero h2 em { font-style: normal; color: var(--primary); }
.ob-hero .lead { color: var(--text-dim); font-size: 15.5px; margin-top: 6px; }

.ob-steps { padding: 6px 26px; display: flex; gap: 8px; }
.ob-steps .dot { flex: 1; height: 4px; border-radius: 99px; background: var(--border); transition: .25s; }
.ob-steps .dot.on { background: var(--primary); }

.ob-body { padding: 22px 26px 120px; display: flex; flex-direction: column; gap: 20px; }
.ob-card {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-soft);
}

/* auth */
.auth-tabs { display: flex; background: var(--bg-input); border-radius: 12px; padding: 4px; gap: 4px; }
.auth-tabs button {
  flex: 1; padding: 11px; border-radius: 9px; font-weight: 600; color: var(--text-dim);
  transition: .18s;
}
.auth-tabs button.on { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field input, .field select {
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 14px; color: var(--text);
  font-size: 16px; transition: border-color .18s, box-shadow .18s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input::placeholder { color: var(--text-faint); }

/* selector de objetivo (tarjetas) */
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.goal-card {
  background: var(--bg-card); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius); padding: 18px 16px; text-align: left;
  display: flex; flex-direction: column; gap: 8px; transition: .18s;
}
.goal-card .g-emoji { font-size: 30px; }
.goal-card .g-title { font-weight: 700; font-size: 15px; }
.goal-card .g-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.35; }
.goal-card.sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }

/* chips de nivel de actividad */
.chip-row { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  padding: 10px 15px; border-radius: 99px; border: 1.5px solid var(--border);
  background: var(--bg-input); font-size: 14px; font-weight: 600; color: var(--text-dim); transition: .15s;
}
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }

/* botones */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px; border-radius: 16px; font-weight: 700; font-size: 16px;
  transition: transform .12s, opacity .18s, background .18s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, #10B981, #0D9488); color: #fff; box-shadow: 0 10px 26px rgba(16, 185, 129, .32); }
.btn-primary:hover { opacity: .94; }
.btn-ghost { background: var(--bg-card); border: 1.5px solid var(--border); color: var(--text); }
.btn-accent { background: linear-gradient(135deg, #FF6B35, #F4511E); color: #fff; box-shadow: 0 10px 24px rgba(255, 107, 53, .3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.ob-footer { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 26px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 60%, transparent); max-width: var(--maxw); margin: 0 auto; }

/* ============================================================
   APP (post-login)
   ============================================================ */
#screen-app { min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar .hello { font-size: 13px; color: var(--text-dim); }
.topbar .hello b { display: block; font-size: 19px; color: var(--text); font-weight: 800; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 13px; background: var(--bg-card);
  border: 1px solid var(--border-soft); display: grid; place-items: center; font-size: 19px;
}

main { padding: 6px 20px 20px; }

/* dashboard */
.ring-card {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 24px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.ring-wrap { position: relative; width: 210px; height: 210px; margin: 6px auto 14px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring-center .big { font-size: 42px; font-weight: 900; letter-spacing: -.03em; }
.ring-center .big span { font-size: 18px; font-weight: 600; color: var(--text-dim); }
.ring-center .cap { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.ring-center .verdict { font-size: 12px; font-weight: 700; color: var(--primary); margin-top: 4px; }

.macro-bars { display: flex; flex-direction: column; gap: 11px; }
.macro-row { display: flex; align-items: center; gap: 10px; }
.macro-row .m-label { width: 30px; font-size: 12px; font-weight: 700; text-align: right; }
.macro-row .m-track { flex: 1; height: 9px; border-radius: 99px; background: var(--bg-input); overflow: hidden; }
.macro-row .m-fill { height: 100%; border-radius: 99px; transition: width .5s cubic-bezier(.22,1,.36,1); }
.macro-row .m-val { width: 96px; font-size: 12.5px; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
.m-fill.p { background: var(--protein); } .m-fill.g { background: var(--fat); } .m-fill.c { background: var(--carbs); }

/* sección de comidas del día */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 12px; }
.sec-head h3 { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.sec-head .add {
  background: var(--primary); color: #fff; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px; font-weight: 600; box-shadow: 0 6px 16px rgba(16,185,129,.3);
}
.meal-group { margin-bottom: 14px; }
.meal-group .m-title { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin: 0 2px 7px; }
.food-row {
  background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 13px 14px; display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.food-row .f-name { font-size: 14.5px; font-weight: 600; }
.food-row .f-sub { font-size: 12px; color: var(--text-dim); }
.food-row .f-kcal { margin-left: auto; font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.food-row .f-del { color: var(--text-faint); font-size: 16px; padding: 4px 6px; }
.empty {
  text-align: center; color: var(--text-dim); padding: 34px 20px; font-size: 14.5px;
  border: 1.5px dashed var(--border); border-radius: var(--radius);
}

/* píldora de estado */
.hero-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px;
  background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700;
}

/* ============================================================
   VISTA COMIDA (búsqueda)
   ============================================================ */
.search-bar {
  position: relative; margin-bottom: 14px;
}
.search-bar input {
  width: 100%; background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: 16px; padding: 15px 16px 15px 46px; color: var(--text); font-size: 16px;
}
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-bar .s-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 17px; color: var(--text-faint); }
.result-list { display: flex; flex-direction: column; gap: 9px; }
.result-item {
  background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 14px; display: flex; align-items: center; gap: 12px; transition: .12s;
}
.result-item:active { border-color: var(--primary); }
.result-item .r-emoji { font-size: 24px; }
.result-item .r-name { font-weight: 600; font-size: 15px; }
.result-item .r-sub { font-size: 12.5px; color: var(--text-dim); }
.result-item .r-kcal { margin-left: auto; text-align: right; }
.result-item .r-kcal b { font-size: 15px; }
.result-item .r-kcal span { display: block; font-size: 11px; color: var(--text-faint); }

/* ============================================================
   VISTA PLAN
   ============================================================ */
.plan-day {
  background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; display: flex; gap: 14px; align-items: center;
}
.plan-day .d-badge {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-input); font-weight: 800;
}
.plan-day .d-badge small { font-size: 9.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }
.plan-day .d-title { font-weight: 700; font-size: 15.5px; }
.plan-day .d-focus { font-size: 13px; color: var(--text-dim); }
.plan-day .d-min { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--text-faint); }
.plan-day.rest .d-badge { background: var(--bg-input); opacity: .7; }
.plan-day.done { border-color: var(--primary); background: var(--primary-soft); }
.plan-day.done .d-badge { background: var(--primary); color: #fff; }

/* ============================================================
   VISTA PERFIL
   ============================================================ */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.avatar {
  width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(135deg, #10B981, #0D9488);
  display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #fff;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-box { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.stat-box b { display: block; font-size: 18px; font-weight: 800; }
.stat-box span { font-size: 11px; color: var(--text-dim); }

/* ============================================================
   TAB BAR
   ============================================================ */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 30;
  width: 100%; max-width: var(--maxw);
  display: flex; padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint); font-size: 10.5px; font-weight: 600; padding: 6px 0;
  border-radius: 12px; transition: .16s;
}
.tabbar button .tb-ico { font-size: 21px; }
.tabbar button.on { color: var(--primary); }
.tabbar button.on .tb-ico { transform: translateY(-1px); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
.modal-sheet {
  width: 100%; max-width: var(--maxw); background: var(--bg-elev);
  border-radius: 26px 26px 0 0; padding: 20px 22px calc(22px + env(safe-area-inset-bottom));
  animation: rise .22s cubic-bezier(.22,1,.36,1);
}
.modal-sheet h3 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.modal-sheet .sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 18px; }
.modal-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--border); margin: 0 auto 14px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(28px); } to { transform: translateY(0); } }

/* quick portion chips dentro del modal */
.qty-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.qty-stepper { display: flex; align-items: center; gap: 2px; background: var(--bg-input); border-radius: 14px; padding: 4px; }
.qty-stepper button { width: 40px; height: 40px; font-size: 20px; font-weight: 700; border-radius: 10px; color: var(--text); }
.qty-stepper button:active { background: var(--bg-card); }
.qty-stepper .qty-val { min-width: 62px; text-align: center; font-weight: 800; font-size: 18px; }
.qty-unit { color: var(--text-dim); font-size: 14px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; z-index: 80;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 99px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow); animation: rise .2s;
}

@media (min-width: 520px) {
  body { background: radial-gradient(1200px 600px at 50% -10%, rgba(16,185,129,.08), transparent), var(--bg); }
  #app { border-left: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft); }
}

/* ============================================================ PROGRESO */
.streak-pill { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--border-soft); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px; }

.coach-card { background: linear-gradient(135deg, var(--primary-soft), transparent 55%), var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.coach-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.coach-ico { font-size: 20px; }
.coach-badge { margin-left: auto; background: var(--primary); color: #06281c; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 9px; letter-spacing: .05em; }
.coach-card p { margin: 0; color: var(--text); font-size: 14.5px; line-height: 1.5; white-space: pre-line; }

.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: 10.5px; color: var(--text-dim); font-weight: 700; margin-bottom: 4px; }
.bar-val.over { color: var(--danger); }
.bar-track { width: 100%; max-width: 34px; flex: 1; display: flex; align-items: flex-end; background: var(--bg-input); border-radius: 8px; }
.bar-fill { width: 100%; border-radius: 8px; background: linear-gradient(180deg, var(--primary), var(--primary-strong)); min-height: 3px; }
.bar-fill.over { background: linear-gradient(180deg, var(--danger), #c0263f); }
.bar-lbl { font-size: 11px; color: var(--text-dim); margin-top: 6px; text-transform: capitalize; }
.bar-lbl.today { color: var(--primary); font-weight: 800; }

.weight-line { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 2px; margin-bottom: 8px; }
.w-dot { display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--bg-elev); border: 1px solid var(--border-soft); border-radius: 14px; padding: 10px 12px; min-width: 64px; }
.w-kg { font-weight: 800; font-size: 15px; }
.w-date { font-size: 11px; color: var(--text-dim); }
.good { color: var(--primary); font-weight: 700; }
.warn { color: var(--accent); font-weight: 700; }

#weight-input { flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; color: var(--text); padding: 11px 14px; font-size: 15px; font-family: var(--font); }
#weight-input:focus { outline: none; border-color: var(--primary); }
