/* ============================================================
   ActivAI — Sistema de diseño
   Estética: Apple Health / iOS · Minimalista · Colores pastel
   IMPORTANTE: Sin modo oscuro. Siempre fondo claro.
   ============================================================ */

/* ------------------------------------------------------------
   1. VARIABLES — tokens de diseño fijos (no cambian con el sistema)
   ------------------------------------------------------------ */
:root {
  /* Fondos */
  --bg:           #FAFAF8;
  --bg-2:         #F2F2F0;
  --bg-3:         #E8E8E6;
  --card:         #FFFFFF;

  /* Texto */
  --t1:           #1C1C1E;
  --t2:           #6E6E73;
  --t3:           #AEAEB2;
  --t-inv:        #FFFFFF;

  /* Acentos pastel */
  --blue:         #5B9CF6;
  --blue-bg:      #EBF3FF;
  --green:        #5AC8A0;
  --green-bg:     #E6F9F3;
  --pink:         #FF6B9D;
  --pink-bg:      #FFF0F6;
  --amber:        #FFB347;
  --amber-bg:     #FFF6E8;
  --purple:       #A78BFA;
  --purple-bg:    #F3EFFF;
  --red:          #FF453A;
  --red-bg:       #FFF1F0;

  /* Bordes */
  --border:       rgba(0, 0, 0, 0.08);
  --border-mid:   rgba(0, 0, 0, 0.12);

  /* Sombras */
  --shadow-xs:    0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);

  /* Radios */
  --r-sm:         8px;
  --r-md:         12px;
  --r-lg:         16px;
  --r-xl:         20px;
  --r-2xl:        24px;
  --r-full:       9999px;

  /* Espaciado */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* Tipografía */
  --font:    -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
             'Helvetica Neue', Arial, sans-serif;

  /* Tamaños */
  --sz-xs:   11px;
  --sz-sm:   13px;
  --sz-base: 15px;
  --sz-md:   17px;
  --sz-lg:   20px;
  --sz-xl:   24px;
  --sz-2xl:  28px;
  --sz-3xl:  34px;

  /* Transiciones */
  --ease:    200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Nav */
  --nav-h:       58px;
  --safe-b:      env(safe-area-inset-bottom, 0px);
  --safe-t:      env(safe-area-inset-top, 0px);
  --safe-l:      env(safe-area-inset-left, 0px);
  --safe-r:      env(safe-area-inset-right, 0px);
}

/* ------------------------------------------------------------
   2. RESET BASE
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* Fuerza fondo claro siempre — anula cualquier preferencia del SO */
html {
  background: var(--bg);
  color-scheme: light only;
}

body {
  font-family: var(--font);
  font-size: var(--sz-base);
  line-height: 1.5;
  color: var(--t1);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
  padding-top: var(--safe-t);
  /* Antialiasing Apple-style */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg  { display: block; max-width: 100%; }
a                { color: var(--blue); text-decoration: none; }
button           { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol           { list-style: none; }

/* Scrollbar mínima */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: var(--r-full); }

/* Selección */
::selection { background: var(--blue-bg); color: var(--blue); }

/* ------------------------------------------------------------
   3. TIPOGRAFÍA
   ------------------------------------------------------------ */
h1, .h1 { font-size: var(--sz-2xl); font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; }
h2, .h2 { font-size: var(--sz-xl);  font-weight: 700; letter-spacing: -0.3px; line-height: 1.2; }
h3, .h3 { font-size: var(--sz-lg);  font-weight: 600; letter-spacing: -0.2px; }
h4, .h4 { font-size: var(--sz-md);  font-weight: 600; }

.text-xs   { font-size: var(--sz-xs); }
.text-sm   { font-size: var(--sz-sm); }
.text-base { font-size: var(--sz-base); }
.text-md   { font-size: var(--sz-md); }
.text-lg   { font-size: var(--sz-lg); }
.text-xl   { font-size: var(--sz-xl); }
.text-2xl  { font-size: var(--sz-2xl); }
.text-3xl  { font-size: var(--sz-3xl); }

.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.text-primary   { color: var(--t1); }
.text-secondary { color: var(--t2); }
.text-tertiary  { color: var(--t3); }
.text-blue      { color: var(--blue); }
.text-green     { color: var(--green); }
.text-pink      { color: var(--pink); }
.text-amber     { color: var(--amber); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }

/* Número grande estilo Apple Health */
.big-number {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}
.big-unit {
  font-size: var(--sz-md);
  font-weight: 400;
  color: var(--t2);
}

/* Texto de categoría (ALL CAPS, tracking) */
.eyebrow {
  font-size: var(--sz-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--t2);
}

/* ------------------------------------------------------------
   4. LAYOUT
   ------------------------------------------------------------ */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--s4);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s3); }

.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.items-end       { align-items: flex-end; }
.items-start     { align-items: flex-start; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-1          { flex: 1; }
.flex-wrap       { flex-wrap: wrap; }
.gap-1           { gap: var(--s1); }
.gap-2           { gap: var(--s2); }
.gap-3           { gap: var(--s3); }
.gap-4           { gap: var(--s4); }

.mt-1 { margin-top: var(--s1); }
.mt-2 { margin-top: var(--s2); }
.mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.mb-2 { margin-bottom: var(--s2); }
.mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); }
.mb-6 { margin-bottom: var(--s6); }
.w-full { width: 100%; }

/* Bloque de sección con padding vertical */
.section { padding: var(--s5) 0; }

/* Cabecera de sección (título + acción) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s4);
  padding: 0 var(--s4);
}

.section-title {
  font-size: var(--sz-lg);
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--t1);
}

/* Separador sutil */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s4) 0;
}

/* ------------------------------------------------------------
   5. APP BAR (cabecera sticky)
   ------------------------------------------------------------ */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(250, 250, 248, 0.95);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
          backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: var(--s3) var(--s4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.app-bar-title {
  font-size: var(--sz-lg);
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--t1);
}

/* Saludo del dashboard */
.greeting {
  font-size: var(--sz-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--t3);
  margin-bottom: 2px;
}

/* ------------------------------------------------------------
   6. CARDS
   ------------------------------------------------------------ */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: var(--s4);
  box-shadow: var(--shadow-xs);
}

.card-sm {
  padding: var(--s3);
  border-radius: var(--r-md);
}

.card-lg {
  padding: var(--s6);
  border-radius: var(--r-xl);
}

/* Stat card — widget estilo Apple Health */
.stat-card {
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: var(--s4);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  cursor: pointer;
  transition: box-shadow var(--ease), transform var(--ease);
}

.stat-card:active {
  transform: scale(0.98);
  box-shadow: none;
}

.stat-label {
  font-size: var(--sz-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--t2);
}

/* Card de color sólido (banners, objetivo 5K) */
.card-colored {
  border-radius: var(--r-xl);
  padding: var(--s5);
  border: none;
}
.card-colored.blue   {
  background: linear-gradient(145deg, #5B9CF6 0%, #4A86E8 100%);
  box-shadow: 0 6px 24px rgba(91,156,246,0.30);
}
.card-colored.green  {
  background: linear-gradient(145deg, #5AC8A0 0%, #47B08C 100%);
  box-shadow: 0 6px 24px rgba(90,200,160,0.30);
}
.card-colored.pink   {
  background: linear-gradient(145deg, #FF6B9D 0%, #F0558A 100%);
  box-shadow: 0 6px 24px rgba(255,107,157,0.30);
}
.card-colored.amber  {
  background: linear-gradient(145deg, #FFB347 0%, #F0A030 100%);
  box-shadow: 0 6px 24px rgba(255,179,71,0.30);
}
.card-colored.purple {
  background: linear-gradient(145deg, #A78BFA 0%, #9274F0 100%);
  box-shadow: 0 6px 24px rgba(167,139,250,0.30);
}
.card-colored * { color: rgba(255,255,255,0.95); }

/* Lista estilo iOS Settings */
.list-card {
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.list-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  min-height: 48px;
  gap: var(--s3);
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  font-size: var(--sz-base);
  color: var(--t1);
  text-align: left;
  transition: background var(--ease);
  width: 100%;
}

.list-card-item:last-child {
  border-bottom: none;
}

.list-card-item.pressable:active,
button.list-card-item:active {
  background: var(--bg-2);
}

.list-card-item svg {
  color: var(--t3);
  flex-shrink: 0;
}

/* Card con franja de color (accent left-border) */
.card-accent-left {
  border-left: 3px solid var(--blue);
}
.card-accent-left.green  { border-left-color: var(--green); }
.card-accent-left.pink   { border-left-color: var(--pink); }
.card-accent-left.amber  { border-left-color: var(--amber); }
.card-accent-left.purple { border-left-color: var(--purple); }

/* ------------------------------------------------------------
   7. BOTONES
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 0 var(--s5);
  height: 44px;
  border-radius: var(--r-full);
  font-family: var(--font);
  font-size: var(--sz-base);
  font-weight: 600;
  line-height: 1;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  transition: all var(--ease);
}

.btn:active      { transform: scale(0.96); }
.btn:disabled    { opacity: 0.45; pointer-events: none; }

/* Primario — azul */
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 10px rgba(91,156,246,0.30);
}
.btn-primary:hover  { background: #4A8AE8; }
.btn-primary:active { box-shadow: none; }

/* Secundario — gris */
.btn-secondary {
  background: var(--bg-2);
  color: var(--t1);
}
.btn-secondary:hover  { background: var(--bg-3); }

/* Ghost — sin fondo */
.btn-ghost {
  background: transparent;
  color: var(--blue);
}
.btn-ghost:hover { background: var(--blue-bg); }

/* Colores */
.btn-green  { background: var(--green);  color: #fff; box-shadow: 0 2px 10px rgba(90,200,160,0.30); }
.btn-pink   { background: var(--pink);   color: #fff; box-shadow: 0 2px 10px rgba(255,107,157,0.30); }
.btn-amber  { background: var(--amber);  color: #fff; box-shadow: 0 2px 10px rgba(255,179,71,0.30); }
.btn-purple { background: var(--purple); color: #fff; box-shadow: 0 2px 10px rgba(167,139,250,0.30); }

/* Destructivo */
.btn-danger {
  background: transparent;
  color: var(--red);
}
.btn-danger:hover { background: var(--red-bg); }

/* Tamaños */
.btn-sm {
  height: 34px;
  padding: 0 var(--s3);
  font-size: var(--sz-sm);
  border-radius: var(--r-md);
}

.btn-lg {
  height: 52px;
  padding: 0 var(--s8);
  font-size: var(--sz-md);
  border-radius: var(--r-xl);
}

.btn-block { width: 100%; }

/* Redondo (solo icono) */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.btn-icon-sm { width: 32px; height: 32px; }
.btn-icon-lg { width: 48px; height: 48px; }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--s4));
  right: var(--s5);
  width: 56px;
  height: 56px;
  border-radius: var(--r-full);
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(91,156,246,0.40);
  border: none;
  z-index: 150;
  transition: all var(--ease);
}
.fab:active { transform: scale(0.92); box-shadow: none; }

/* ------------------------------------------------------------
   8. FORMULARIOS
   ------------------------------------------------------------ */
.form-group { display: flex; flex-direction: column; gap: var(--s2); }

.label {
  font-size: var(--sz-sm);
  font-weight: 600;
  color: var(--t2);
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 var(--s4);
  background: var(--card);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: var(--sz-base);
  color: var(--t1);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.input::placeholder { color: var(--t3); }

.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(91,156,246,0.12);
}

.input.error {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(255,107,157,0.10);
}

textarea.input {
  height: auto;
  min-height: 96px;
  padding: var(--s3) var(--s4);
  resize: vertical;
  line-height: 1.6;
}

/* Input con icono prefijo */
.input-group { position: relative; }

.input-icon {
  position: absolute;
  left: var(--s3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--t3);
  pointer-events: none;
}

.input-group .input { padding-left: 42px; }

/* Input numérico grande */
.input-xl {
  font-size: var(--sz-2xl);
  font-weight: 700;
  text-align: center;
  height: 72px;
  border-radius: var(--r-lg);
  letter-spacing: -0.5px;
}

/* Select */
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23AEAEB2' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s3) center;
  padding-right: 40px;
  cursor: pointer;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-3);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--ease);
}

.toggle input:checked + .toggle-track { background: var(--green); }

.toggle-track::after {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform var(--ease);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(20px);
}

/* Error bajo input */
.field-error {
  font-size: var(--sz-sm);
  color: var(--pink);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ------------------------------------------------------------
   9. TAGS Y BADGES
   ------------------------------------------------------------ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--sz-xs);
  font-weight: 600;
  line-height: 1.4;
}

.tag-blue   { background: var(--blue-bg);   color: #3A7FE8; }
.tag-green  { background: var(--green-bg);  color: #36A07C; }
.tag-pink   { background: var(--pink-bg);   color: #D44D7A; }
.tag-amber  { background: var(--amber-bg);  color: #C07A10; }
.tag-purple { background: var(--purple-bg); color: #7B5FD0; }
.tag-gray   { background: var(--bg-2);      color: var(--t2); }

/* Badge numérico */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--r-full);
  line-height: 1;
}

/* ------------------------------------------------------------
   10. BARRAS DE PROGRESO
   ------------------------------------------------------------ */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-2);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--blue);
  transition: width 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.progress-fill.green  { background: var(--green); }
.progress-fill.pink   { background: var(--pink); }
.progress-fill.amber  { background: var(--amber); }
.progress-fill.purple { background: var(--purple); }

/* Barra de macros tricolor */
.macro-bar {
  height: 10px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--bg-2);
  display: flex;
  gap: 2px;
}

.macro-segment { height: 100%; transition: width 600ms ease; }
.macro-segment.protein { background: var(--blue); }
.macro-segment.carbs   { background: var(--amber); }
.macro-segment.fat     { background: var(--pink); }

/* Anillo circular */
.ring-chart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ring-chart svg { transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: var(--bg-2); }
.ring-fill { fill: none; stroke-linecap: round; transition: stroke-dashoffset 600ms ease; }

.ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------
   11. NAVEGACIÓN INFERIOR — iOS style
   La más crítica del diseño: fondo BLANCO, iconos grises, activo AZUL
   ------------------------------------------------------------ */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;

  /* Fondo blanco sólido + blur para el área de safe area */
  background: rgba(255, 255, 255, 0.98);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
          backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);

  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-left:  max(var(--s2), var(--safe-l));
  padding-right: max(var(--s2), var(--safe-r));
  padding-bottom: var(--safe-b);
  height: calc(var(--nav-h) + var(--safe-b));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  padding: var(--s2) var(--s1);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t3);           /* gris inactivo */
  transition: color var(--ease);
  text-decoration: none;
  min-width: 0;
}

.nav-item:active { opacity: 0.6; }

.nav-item svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  stroke-width: 1.8;
  transition: transform var(--ease-spring);
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
  line-height: 1;
}

/* Estado activo: azul Apple */
.nav-item.active {
  color: var(--blue);
}

.nav-item.active .nav-label { font-weight: 600; }

.nav-item.active svg {
  animation: nav-pop var(--ease-spring) forwards;
}

@keyframes nav-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------
   12. TABS / PANTALLAS
   ------------------------------------------------------------ */
.tab-pane {
  display: none;
  min-height: calc(100dvh - var(--nav-h) - var(--safe-b) - var(--safe-t));
  animation: tab-in var(--ease) both;
}

.tab-pane.active { display: block; }

@keyframes tab-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Scroll horizontal de pills (filtros) */
.pill-scroll {
  display: flex;
  gap: var(--s2);
  overflow-x: auto;
  padding: 0 var(--s4) var(--s1);
  scrollbar-width: none;
}
.pill-scroll::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-full);
  font-size: var(--sz-sm);
  font-weight: 500;
  background: var(--bg-2);
  color: var(--t2);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--ease);
}

.pill:active { transform: scale(0.95); }

.pill.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(91,156,246,0.25);
}

/* ------------------------------------------------------------
   13. MODAL / BOTTOM SHEET
   ------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0);
  visibility: hidden;
  transition: background var(--ease), visibility var(--ease);
}

.overlay.open {
  background: rgba(0, 0, 0, 0.35);
  visibility: visible;
}

.sheet {
  width: 100%;
  max-height: 92dvh;
  background: var(--card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform var(--ease);
  padding-bottom: max(var(--safe-b), var(--s4));
}

.overlay.open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--bg-3);
  border-radius: var(--r-full);
  margin: var(--s3) auto var(--s1);
  flex-shrink: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s2) var(--s4) var(--s4);
  flex-shrink: 0;
}

.sheet-title {
  font-size: var(--sz-lg);
  font-weight: 700;
  color: var(--t1);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--s4);
  -webkit-overflow-scrolling: touch;
}

.sheet-footer {
  padding: var(--s4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  gap: var(--s3);
}

/* Diálogo centrado (alertas) */
.overlay.dialog { align-items: center; padding: var(--s6); }
.overlay.dialog .sheet {
  border-radius: var(--r-xl);
  max-width: 320px;
  margin: auto;
  padding: var(--s6);
  transform: scale(0.94);
  transition: transform var(--ease-spring), opacity var(--ease);
  opacity: 0;
}
.overlay.dialog.open .sheet {
  transform: scale(1);
  opacity: 1;
}

/* ------------------------------------------------------------
   14. TOAST / NOTIFICACIONES
   ------------------------------------------------------------ */
.toast-container {
  position: fixed;
  top: calc(var(--safe-t) + var(--s4));
  left: var(--s4);
  right: var(--s4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in 320ms var(--ease-spring) both;
}

.toast.exit {
  animation: toast-out 220ms var(--ease) forwards;
}

.toast-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--green); }
.toast.error   .toast-dot { background: var(--pink); }
.toast.warning .toast-dot { background: var(--amber); }
.toast.info    .toast-dot { background: var(--blue); }

.toast-text {
  flex: 1;
  font-size: var(--sz-sm);
  font-weight: 500;
  color: var(--t1);
  line-height: 1.4;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px) scale(0.94); }
}

/* ------------------------------------------------------------
   15. HÁBITOS
   ------------------------------------------------------------ */
.habit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s3);
  padding: 0 var(--s4);
}

.habit-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s4) var(--s2);
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--ease);
  text-align: center;
  aspect-ratio: 1;
  box-shadow: var(--shadow-xs);
}

.habit-item:active { transform: scale(0.95); box-shadow: none; }

.habit-item.done {
  border-color: transparent;
  background: var(--green-bg);
}

.habit-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--bg-2);
}

.habit-item.done .habit-icon {
  background: rgba(90, 200, 160, 0.2);
}

.habit-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--t2);
  line-height: 1.3;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-item.done .habit-name {
  color: var(--green);
}

/* Racha de días */
.streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--sz-xs);
  font-weight: 700;
  color: var(--amber);
}

/* ------------------------------------------------------------
   16. NUTRICIÓN
   ------------------------------------------------------------ */
.macro-summary {
  display: flex;
  gap: var(--s2);
}

.macro-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--s3) var(--s2);
  background: var(--card);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  text-align: center;
}

.macro-value {
  font-size: var(--sz-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}

.macro-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--t2);
}

.macro-item.protein .macro-value { color: var(--blue); }
.macro-item.carbs   .macro-value { color: var(--amber); }
.macro-item.fat     .macro-value { color: var(--pink); }

/* Entradas de comida */
.meal-section-label {
  font-size: var(--sz-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--t3);
  padding: var(--s3) var(--s4) var(--s2);
}

.meal-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  gap: var(--s3);
  border-bottom: 1px solid var(--border);
}

.meal-entry:last-child { border-bottom: none; }

.meal-name { flex: 1; font-size: var(--sz-base); font-weight: 500; color: var(--t1); }
.meal-qty  { font-size: var(--sz-xs); color: var(--t3); }
.meal-cal  { font-size: var(--sz-sm); font-weight: 600; color: var(--t2); white-space: nowrap; }

/* ------------------------------------------------------------
   17. RUNNING
   ------------------------------------------------------------ */
.run-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s3);
}

.run-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--s4) var(--s2);
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow-xs);
}

.run-stat-val {
  font-size: var(--sz-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
  letter-spacing: -0.5px;
}

.run-stat-lbl {
  font-size: 11px;
  font-weight: 500;
  color: var(--t2);
}

/* Timer de entreno */
.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: var(--s12) var(--s6);
  text-align: center;
}

.timer-phase {
  font-size: var(--sz-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--t3);
}

.timer-time {
  font-size: 80px;
  font-weight: 700;
  letter-spacing: -4px;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
  line-height: 1;
}

.timer-instruction {
  font-size: var(--sz-lg);
  font-weight: 500;
  color: var(--t2);
}

/* Punto de tipo de sesión */
.type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.type-dot.caco      { background: var(--blue); }
.type-dot.intervals { background: var(--pink); }
.type-dot.long_run  { background: var(--green); }
.type-dot.test      { background: var(--amber); }

/* ------------------------------------------------------------
   18. PANTALLA DE AUTENTICACIÓN
   ------------------------------------------------------------ */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) 0 0;
  background: var(--bg);
  /* Centra en pantallas grandes */
  max-width: 400px;
  margin: 0 auto;
}

.auth-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s10) var(--s6) var(--s6);
  text-align: center;
}

.app-icon {
  width: 90px;
  height: 90px;
  border-radius: 22px;
  background: linear-gradient(145deg, #5B9CF6, #A78BFA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  box-shadow: 0 8px 32px rgba(91,156,246,0.30);
  margin-bottom: var(--s2);
}

.auth-title {
  font-size: var(--sz-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--t1);
}

.auth-sub {
  font-size: var(--sz-base);
  color: var(--t2);
  line-height: 1.5;
  max-width: 260px;
}

.auth-forms {
  padding: 0 var(--s5) calc(var(--safe-b) + var(--s6));
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--t3);
  font-size: var(--sz-sm);
  margin: var(--s1) 0;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ------------------------------------------------------------
   19. SKELETON LOADING
   ------------------------------------------------------------ */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-2) 0%,
    var(--bg-3) 50%,
    var(--bg-2) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--r-md);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-text  { height: 14px; border-radius: var(--r-full); }
.skeleton-title { height: 22px; border-radius: var(--r-full); }
.skeleton-card  { height: 96px; border-radius: var(--r-lg); }

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

/* ------------------------------------------------------------
   20. EMPTY STATE
   ------------------------------------------------------------ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s12) var(--s6);
  text-align: center;
}

.empty-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: var(--s1);
}

.empty-title {
  font-size: var(--sz-lg);
  font-weight: 700;
  color: var(--t1);
}

.empty-desc {
  font-size: var(--sz-base);
  color: var(--t2);
  max-width: 240px;
  line-height: 1.5;
}

/* ------------------------------------------------------------
   21. UTILIDADES
   ------------------------------------------------------------ */
.hidden          { display: none !important; }
.sr-only         { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.truncate        { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overflow-hidden { overflow: hidden; }
.rounded-full    { border-radius: var(--r-full); }
.rounded-lg      { border-radius: var(--r-lg); }

/* Color de acento dinámico vía var CSS (útil para hábitos) */
.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent, var(--blue));
  flex-shrink: 0;
}

/* Textos con gradiente */
.gradient-text {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Animaciones */
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Espaciados de conveniencia */
.p-4  { padding: var(--s4); }
.px-4 { padding-left: var(--s4); padding-right: var(--s4); }
.py-4 { padding-top: var(--s4); padding-bottom: var(--s4); }

/* ------------------------------------------------------------
   22. RESPONSIVE mínimo (tablet/desktop — app siempre centrada)
   ------------------------------------------------------------ */
@media (min-width: 480px) {
  .habit-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 640px) {
  body {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100dvh;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 60px rgba(0,0,0,0.06);
  }

  .app-nav {
    left: 50%;
    transform: translateX(-50%);
    width: 430px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .fab {
    right: calc(50% - 215px + var(--s5));
  }

  .toast-container {
    left: calc(50% - 215px + var(--s4));
    right: calc(50% - 215px + var(--s4));
  }
}

/* ------------------------------------------------------------
   23. PRINT
   ------------------------------------------------------------ */
@media print {
  .app-nav, .fab, .toast-container, .overlay { display: none !important; }
  body { padding-bottom: 0; }
}
