/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-dark:  #2d6a4f;
  --green-mid:   #40916c;
  --green-light: #74c69d;
  --green-pale:  #d8f3dc;
  --white:       #ffffff;
  --gray-100:    #f8f9fa;
  --gray-200:    #e9ecef;
  --gray-400:    #ced4da;
  --gray-600:    #6c757d;
  --gray-800:    #343a40;
  --red:         #e63946;
  --orange:      #f4a261;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
  --radius:      12px;
  --radius-sm:   8px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
}

/* ===== SCREEN TRANSITIONS ===== */
.screen { display: none; }
.screen.active { display: block; }

/* Accesibilidad: etiqueta solo para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ===== LOGIN SCREEN ===== */
#screen-login {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  padding: 24px;
}
#screen-login.active {
  display: flex;
}

#screen-configurar-plan-prueba {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  padding: 24px;
}
#screen-configurar-plan-prueba.active {
  display: flex;
}

.plan-prueba-resumen-box {
  font-size: 0.95rem;
  background: var(--green-pale);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--gray-800);
}

#screen-elegir-modo-prueba {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  padding: 24px;
}
#screen-elegir-modo-prueba.active {
  display: flex;
}

.modo-prueba-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}
.btn-modo-prueba {
  background: var(--white);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-modo-prueba:hover {
  opacity: 0.95;
}
.btn-modo-gramos {
  background: var(--green-pale);
  color: var(--green-dark);
  border-color: var(--green-light);
}
.btn-modo-gramos:hover,
.btn-modo-gramos:focus {
  background: var(--green-light);
  color: var(--white);
}
.btn-modo-porciones {
  background: var(--green-dark);
  color: var(--white);
  border-color: var(--green-dark);
}
.btn-modo-porciones:hover,
.btn-modo-porciones:focus {
  background: var(--green-mid);
  border-color: var(--green-mid);
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 640px;
}

.logo-area {
  text-align: center;
  margin-bottom: 28px;
}

.logo-area-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-area .logo-icon {
  font-size: 48px;
  display: block;
}

.logo-area .logo-img {
  height: 48px;
  width: 48px;
  object-fit: cover;
  border-radius: 50%;
}

.logo-area h1 {
  font-size: 1.6rem;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--gray-600);
  font-size: 0.95rem;
}

/* ===== FORM STYLES ===== */
form fieldset {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 18px 16px 14px;
  margin-bottom: 18px;
}

form fieldset legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-mid);
  padding: 0 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.field:last-child { margin-bottom: 0; }

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.field input {
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.95rem;
  transition: border-color .2s;
  outline: none;
}

.field input:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

.field-group.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--green-mid);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(.98); }

.btn-full { width: 100%; }

.btn-ghost {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.8);
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.15); }

.btn-add {
  background: var(--green-pale);
  color: var(--green-dark);
  border: 1.5px solid var(--green-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-add:hover { background: var(--green-light); color: var(--white); }

.btn-remove {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
  line-height: 1;
}
.btn-remove:hover { background: #fdecea; }

/* ===== MAIN APP HEADER ===== */
.app-header {
  background: linear-gradient(90deg, var(--green-dark), var(--green-mid));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.logo-icon-sm { font-size: 1.4rem; }
.app-header .logo-header-sm { height: 1.5rem; width: 1.5rem; object-fit: cover; border-radius: 50%; vertical-align: middle; }

.app-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  opacity: .9;
}

/* ===== APP BODY ===== */
.app-body {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== SUMMARY PANEL ===== */
.summary-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 22px 18px;
}

.summary-panel h3 {
  font-size: 1rem;
  color: var(--gray-600);
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 4px solid var(--green-light);
}

.summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark);
}

.summary-total {
  font-size: 0.78rem;
  color: var(--gray-600);
}

.summary-card-progress {
  margin-top: 8px;
  height: 6px;
  background: rgba(0,0,0,.1);
  border-radius: 99px;
  overflow: hidden;
}

.summary-card-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s ease;
}

/* Modo solo gramos: ocultar barra de porciones */
.summary-panel.modo-gramos .porciones-bar-wrap {
  display: none;
}

/* ===== PROGRESS BAR ===== */
.porciones-bar-wrap {
  background: var(--green-pale);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.porciones-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--green-dark);
}

.porciones-bar-toggle {
  cursor: pointer;
  user-select: none;
  touch-action: manipulation; /* Elimina retardo de 300ms en iOS y hace que el toque dispare el clic */
  -webkit-tap-highlight-color: transparent;
}

.porciones-bar-toggle:hover {
  opacity: 0.9;
}

.porciones-bar-toggle .porciones-toggle-icon {
  margin-left: 6px;
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.porciones-bar-wrap.collapsed .porciones-toggle-icon {
  transform: rotate(-90deg);
}

.porciones-bar-collapsible {
  max-height: 1200px;
  transition: opacity 0.2s ease, max-height 0.3s ease;
  overflow: hidden;
}

.porciones-bar-wrap.collapsed .porciones-bar-collapsible {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  pointer-events: none;
}

.progress-track {
  background: rgba(0,0,0,.1);
  border-radius: 99px;
  height: 14px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--green-mid);
  transition: width .4s ease, background .3s;
  width: 0%;
}

.progress-fill.over-limit {
  background: var(--red);
}

.porciones-restantes {
  text-align: right;
  font-size: 0.85rem;
  color: var(--green-dark);
  margin-top: 6px;
}

.porciones-restantes.over-limit {
  color: var(--red);
  font-weight: 600;
}

/* ===== MEALS SECTION ===== */
.meals-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.meals-section > h3 {
  font-size: 1.05rem;
  color: var(--gray-800);
}

.meal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.meal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--gray-100);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--gray-200);
  transition: background .15s;
}

.meal-header:hover { background: var(--green-pale); }

.meal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meal-icon { font-size: 1.3rem; }

.meal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
}

.meal-subtitle {
  font-size: 0.8rem;
  color: var(--gray-600);
}

.meal-badge {
  background: var(--green-mid);
  color: var(--white);
  border-radius: 99px;
  padding: 3px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.meal-toggle {
  font-size: 0.9rem;
  color: var(--gray-600);
  transition: transform .2s;
}
.meal-toggle.open { transform: rotate(180deg); }

.meal-body {
  padding: 16px 18px;
}

/* Modo solo macros: ocultar preparación, alimento/porciones y badge porciones; mantener Mis preparaciones */
.meal-card.modo-gramos .prep-row,
.meal-card.modo-gramos .add-entry-row,
.meal-card.modo-gramos .meal-badge {
  display: none !important;
}


/* Entry row */
.entries-list {
  list-style: none;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.entry-name { flex: 1; font-weight: 500; }
.entry-qty {
  font-weight: 700;
  color: var(--green-dark);
  min-width: 60px;
  text-align: right;
}

.add-entry-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.add-entry-row input[type="text"] {
  flex: 1;
  min-width: 140px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color .2s;
}

.add-entry-row input[type="text"]:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

.add-entry-row input[type="number"] {
  width: 80px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color .2s;
  text-align: center;
}

.add-entry-row input[type="number"]:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

/* ===== PREP ROW ===== */
.prep-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.input-prep {
  flex: 1;
  min-width: 180px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
  background: var(--white);
  transition: border-color .2s;
}

.input-prep:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

.input-prep-qty {
  width: 70px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
  text-align: center;
  transition: border-color .2s;
}

.input-prep-qty:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

.btn-add-prep {
  background: var(--green-mid, #52b788);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.btn-add-prep:hover { background: var(--green-light, #74c69d); }

/* Secondary prep entries */
.entry-item--secondary {
  opacity: 0.6;
  background: var(--gray-100);
  font-style: italic;
}

/* ===== EMPTY STATE ===== */
.empty-entries {
  text-align: center;
  color: var(--gray-600);
  font-size: 0.88rem;
  padding: 8px 0 4px;
  font-style: italic;
}

/* ===== RESET DAY BUTTON ===== */
.reset-day-wrap {
  text-align: right;
  margin-top: 8px;
}

.btn-reset {
  background: none;
  border: 1.5px solid var(--orange);
  color: var(--orange);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.btn-reset:hover { background: var(--orange); color: var(--white); }

/* ===== CATEGORY INPUTS GRID ===== */
.section-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--green-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 14px 0 8px;
}

.optional-tag {
  font-weight: 400;
  color: var(--gray-600);
  text-transform: none;
  letter-spacing: 0;
}

.field-group.categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ===== CATEGORY TABLE ===== */
.cat-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.cat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.cat-table th {
  background: var(--green-pale);
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid var(--green-light);
}

.cat-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--gray-200);
}

.cat-table tbody tr:last-child td { border-bottom: none; }

.cat-table tbody tr:hover { background: var(--gray-100); }

.cat-name { font-weight: 600; color: var(--gray-800); }

.cat-note { font-size: 0.75rem; font-weight: 400; color: var(--gray-600); }

.cat-consumed { font-weight: 700; color: var(--green-dark); }

.cat-extra-faltantes { font-weight: 600; color: var(--green-dark); font-size: 0.85em; }

.cat-rest.negative { color: var(--red); font-weight: 700; }

.over-limit-row td { background: #fff5f5; }

/* ===== CATEGORY SELECT IN ADD-ENTRY-ROW ===== */
.input-categoria {
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.88rem;
  background: var(--white);
  color: var(--gray-800);
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}

.input-categoria:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

/* ===== ENTRY CATEGORY BADGE ===== */
.entry-cat {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--green-pale);
  color: var(--green-dark);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .card { padding: 28px 18px; }
  .field-group.two-col { grid-template-columns: 1fr; }
  .field-group.categories-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .add-entry-row input[type="text"] { min-width: 100px; }
  .app-header h2 { font-size: 0.95rem; }
}

@media (max-width: 400px) {
  .summary-grid { grid-template-columns: 1fr; }
  .field-group.categories-grid { grid-template-columns: 1fr; }
}

/* ===== LOGIN ===== */
.login-card {
  max-width: 400px;
  margin: 2rem auto;
}

.error-msg {
  background: #fff0f0;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.auth-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #666;
}

.auth-link a {
  color: var(--green, #4caf50);
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}
/* =====================================================
   AGREGAR AL FINAL DE TU ARCHIVO CSS
   Modal de preparaciones personalizadas
   ===================================================== */

/* ---- Opción especial en el dropdown ---- */
.prep-opcion-nueva {
  color: var(--green-dark);
  font-weight: 700;
  background: var(--green-pale);
}

/* ---- Overlay ---- */
.modal-overlay-prep {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Buscador en móvil: fondo fijo, solo el contenido hace scroll */
.modal-buscador-movil {
  touch-action: pan-y;
}
.modal-buscador-movil .modal-prep-box {
  touch-action: pan-y;
}
.usda-resultados-scroll {
  overscroll-behavior: contain;
  min-height: 120px;
}

/* Botón Escanear: claro para móvil, icono de escáner (no cámara) */
.btn-escanear-movil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 52px;
  flex-shrink: 0;
  background: var(--green-pale);
  color: var(--green-dark);
  border: 1px solid rgba(45, 106, 79, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: visible;
}
.btn-escanear-movil:hover, .btn-escanear-movil:active {
  background: var(--green-mid);
  color: #fff;
}
.btn-escanear-icon {
  display: inline-block;
  width: 3px;
  height: 14px;
  background: currentColor;
  border-radius: 1px;
  opacity: 0.9;
  box-shadow: 4px 0 0 currentColor, 8px 0 0 currentColor, 12px 0 0 currentColor, 16px 0 0 currentColor;
  vertical-align: middle;
}

/* Modal escáner: centrado y botón cerrar siempre visible (móvil) */
.modal-escaner-centrado {
  align-items: center !important;
  padding: 16px;
}
.modal-escaner-caja {
  position: relative;
}
/* Zona de cámara: todo el cuadro sirve para leer el código (centrado en la ventana) */
#escaner-viewfinder {
  position: relative;
  z-index: 1;
}
.escaner-viewfinder-centrado {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
/* Área de lectura más grande en móvil para que el código de barras se lea bien (como en desktop) */
.escaner-viewfinder-movil {
  max-height: 72vmin !important;
  min-height: 240px;
  aspect-ratio: 1;
}
@media (max-width: 480px) {
  .escaner-viewfinder-movil {
    max-height: 65vh !important;
    min-height: 220px;
  }
}
.escaner-viewfinder-movil video,
.escaner-viewfinder-movil #escaner-html5qrcode {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.escaner-viewfinder {
  min-height: 200px;
}
/* Cerrar siempre accesible por encima de la cámara (sin tener que usar Reintentar) */
.btn-cerrar-escaner {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  z-index: 20;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  pointer-events: auto;
}
.escaner-acciones .btn-link-muted {
  pointer-events: auto;
}
.btn-cerrar-escaner:hover, .btn-cerrar-escaner:active {
  background: rgba(0,0,0,0.75);
  color: #fff;
}
.btn-link-muted {
  background: none;
  border: none;
  color: #666;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn-link-muted:hover, .btn-link-muted:active { color: #333; }

/* ---- Caja del modal ---- */
.modal-prep-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ---- Header ---- */
.modal-prep-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-prep-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green-dark);
}

/* ---- Inputs heredan .field de la app ---- */
.modal-prep-box .field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
  display: block;
}

.modal-prep-box .field input {
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color .2s;
}

.modal-prep-box .field input:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

.req { color: var(--red); }

/* ---- Grid 3 columnas: igual que macros principales ---- */
.modal-prep-macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

/* ---- Botón "Otros grupos" ---- */
.mp-toggle-extra {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-top: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green-dark);
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}

.mp-toggle-extra:hover {
  background: var(--green-pale);
  border-color: var(--green-light);
}

.mp-opcional {
  font-weight: 400;
  color: var(--gray-600);
  font-size: 0.8rem;
}

/* ---- Área desplegable ---- */
.mp-extra-wrap {
  border: 1.5px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 14px 12px 10px;
  background: var(--gray-100);
}

/* El grid extra usa el mismo .modal-prep-macros  */
.mp-extra-grid { margin-top: 0; }

/* ---- Preview kcal ---- */
.modal-prep-kcal {
  margin-top: 14px;
  background: var(--green-pale);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--green-dark);
  text-align: center;
}

/* ---- Botones ---- */
.modal-prep-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---- Responsive ---- */
@media (max-width: 440px) {
  .modal-prep-box    { padding: 20px 14px; }
  .modal-prep-macros { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Botón ⚙️ gestionar preparaciones ---- */
.btn-mis-preps {
  background: var(--gray-200);
  color: var(--gray-800);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  text-align: center;
  min-height: 44px;
}
.btn-mis-preps:hover { background: var(--gray-400); }

.entry-macros-row .btn-usda {
  background: var(--green-pale, #d8f3dc);
  color: var(--green-dark, #1b4332);
  border: 1.5px solid var(--green-light, #74c69d);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  text-align: center;
  min-height: 44px;
}
.entry-macros-row .btn-usda:hover { background: var(--green-light, #74c69d); color: var(--white, #fff); }

/* ---- Fila de botones de acción del meal ---- */
.entry-macros-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.entry-macro-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.entry-macro-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
}

.entry-macro-field input {
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.88rem;
  text-align: center;
  outline: none;
  width: 100%;
  transition: border-color .2s;
}
.entry-macro-field input:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}

/* ---- Pestañas del modal Mis preparaciones ---- */
.gestionar-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 12px;
}
.gestionar-tab {
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.gestionar-tab:hover {
  color: var(--gray-800);
}
.gestionar-tab.active {
  color: var(--green-mid);
  border-bottom-color: var(--green-mid);
}

/* ---- Items del modal gestionar preparaciones ---- */
.gestionar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  margin-bottom: 8px;
}

.gestionar-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.gestionar-nombre {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gestionar-macros {
  font-size: 0.75rem;
  color: var(--gray-600);
}

/* ---- Entry item: layout 2 filas (funciona en escritorio y móvil) ---- */
.entry-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.entry-row-top {
  display: flex;
  align-items: center;
  width: 100%;
}

.entry-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.entry-name {
  font-weight: 600;
  color: var(--gray-800);
  word-break: break-word;
  flex: 1;
}

.entry-cat {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--green-pale);
  color: var(--green-dark);
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.entry-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.entry-qty {
  font-weight: 700;
  color: var(--green-dark);
  white-space: nowrap;
  font-size: 0.88rem;
}

/* Input edición inline — siempre contenido */
.entry-qty-input {
  width: 72px;
  padding: 5px 8px;
  border: 2px solid var(--green-mid);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.entry-qty-input::-webkit-outer-spin-button,
.entry-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.btn-confirm {
  background: var(--green-mid);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
}
.btn-confirm:hover { background: var(--green-dark); }

.btn-cancel {
  background: var(--gray-200);
  color: var(--gray-800);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
}
.btn-cancel:hover { background: var(--gray-400); }

.entry-item--secondary {
  opacity: 0.6;
  font-style: italic;
}

/* ---- Ajustes PWA / móvil generales ---- */
@media (max-width: 600px) {
  /* Evitar zoom en inputs iOS */
  input, select, textarea { font-size: 16px !important; }

  /* Touch targets mínimo 44px */
  button, .btn-add, .btn-remove, .btn-edit,
  .btn-add-prep, .btn-mis-preps, .btn-primary, .btn-reset {
    min-height: 44px;
    min-width: 44px;
  }

  /* Modal full-screen en móvil */
  .modal-prep-box {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 50vh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 92vh;
    overflow-y: auto;
  }
  .modal-overlay-prep { align-items: flex-end !important; }

  /* Prep row vertical */
  .prep-row { flex-wrap: wrap; gap: 8px; }
  .prep-row select { width: 100%; }

  /* Add-entry-row vertical */
  .add-entry-row { flex-wrap: wrap; gap: 8px; }
  .add-entry-row input[type="text"]    { width: 100%; }
  .add-entry-row .input-categoria      { width: 100%; flex: unset; }
  .add-entry-row input[type="number"]  { width: 80px; }

  /* Entry item en móvil: botones más grandes */
  .btn-edit, .btn-remove {
    min-width: 40px;
    min-height: 40px;
    font-size: 1.1rem;
    padding: 4px 8px;
  }

  .btn-confirm, .btn-cancel {
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
  }

  /* Input edición en móvil */
  .entry-qty-input {
    width: 80px !important;
    font-size: 16px !important;
    min-height: 40px;
  }

  /* Meal header */
  .meal-header { padding: 12px 12px; }
  .meal-header-left { min-width: 0; flex: 1; }
  .meal-title   { font-size: 0.95rem; }
  .meal-subtitle { font-size: 0.75rem; }

  /* Meal badge */
  .meal-badge {
    max-width: 50vw;
    font-size: 0.66rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Botones de acción al final */
  .reset-day-wrap { text-align: center; }
  .reset-day-wrap .btn-reset { width: 100%; }
}

/* ---- Modal gestionar meals ---- */
.meals-sort-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  user-select: none;
  cursor: grab;
}
.meals-sort-item:active { cursor: grabbing; }
.meals-sort-drag {
  color: var(--gray-400);
  font-size: 0.9rem;
  cursor: grab;
  margin-right: 2px;
}
.meals-sort-item.meals-dragging {
  opacity: 0.6;
  box-shadow: var(--shadow-md);
}
.meals-sort-item.meals-drag-over {
  border-color: var(--green-mid);
  background: var(--green-pale);
}
.meals-sort-icon { font-size: 1.2rem; }
.meals-sort-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
}
.meals-sort-del {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Ajustes PWA / móvil generales ---- */


/* ---- Historial de registros ---- */
.historial-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
  font-size: 0.88rem;
  -webkit-tap-highlight-color: transparent;
}
.historial-item:hover  { background: var(--green-pale); border-color: var(--green-light); }
.historial-hoy         { border-color: var(--green-mid); background: var(--green-pale); }
.historial-fecha       { font-weight: 600; color: var(--gray-800); }
.historial-info        { font-size: 0.78rem; color: var(--gray-600); }

/* ---- Bebestibles sin calorías ---- */
.btn-bebida {
  background: #e8f4fd;
  color: #1a6fa8;
  border: 1.5px solid #90caf9;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  text-align: center;
  min-height: 44px;
}
.btn-bebida:hover { background: #bbdefb; }

.bebidas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-bebida-opcion {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f8ff;
  border: 1.5px solid #90caf9;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}
.btn-bebida-opcion:hover  { background: #bbdefb; border-color: #1a6fa8; }
.btn-bebida-opcion:active { background: #90caf9; }

.bebida-icon  { font-size: 1.2rem; flex-shrink: 0; }
.bebida-label { font-size: 0.82rem; font-weight: 600; color: #1a6fa8; line-height: 1.2; }

/* Badge especial para bebidas */
.entry-cat--bebida {
  background: #e3f2fd;
  color: #1565c0;
}

@media (max-width: 600px) {
  .bebidas-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   MENÚ HAMBURGUESA
   ===================================================== */

#btn-hamburguesa {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
  order: -1;
}
#btn-hamburguesa span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: #fff;
  border-radius: 2px;
  transition: all .25s;
}

/* Overlay */
#menu-hamburguesa-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 300;
  pointer-events: none;
  transition: background .25s;
}
#menu-hamburguesa-overlay.open {
  background: rgba(0,0,0,0.45);
  pointer-events: all;
}

/* Drawer */
#menu-hamburguesa-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(300px, 85vw);
  background: #fff;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,.18);
  pointer-events: all;
}
#menu-hamburguesa-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  background: var(--green-dark, #1b4332);
  color: #fff;
  padding: 28px 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.drawer-name { font-weight: 700; font-size: 0.95rem; }
.drawer-sub  { font-size: 0.75rem; opacity: .7; }
.drawer-user { flex: 1; }
.drawer-close {
  background: none; border: none; color: #fff;
  font-size: 1.1rem; cursor: pointer; opacity: .7;
  padding: 4px;
}

.drawer-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #aaa;
  padding: 16px 20px 4px;
}
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.92rem;
  color: #333;
  cursor: pointer;
  transition: background .15s;
}
.drawer-item:hover { background: #f5f5f5; }
.drawer-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.drawer-contact { cursor: default; }
.drawer-contact:hover { background: none; }

/* =====================================================
   SISTEMA DE VISTAS
   ===================================================== */
.vista-contenido { display: none; }

/* =====================================================
   DASHBOARD
   ===================================================== */
.dashboard-wrap {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}
.dashboard-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark, #1b4332);
  margin-bottom: 2px;
}
.dashboard-fecha {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 4px;
}
.dashboard-bienvenida {
  font-size: 0.95rem;
  color: var(--green-dark, #1b4332);
  margin-bottom: 16px;
  font-weight: 500;
}
.dash-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #aaa;
  margin: 16px 0 8px;
  text-transform: uppercase;
}

/* Grid 2x2 macros */
.dash-macros-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dash-macro-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-macro-icon  { font-size: 1.4rem; }
.dash-macro-label { font-size: 0.72rem; color: #888; font-weight: 600; margin-top: 2px; }
.dash-macro-val   { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.dash-macro-unit  { font-size: 0.75rem; font-weight: 400; }
.dash-macro-meta  { font-size: 0.72rem; color: #aaa; }

.dash-progress-bar {
  width: 100%;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.dash-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}

/* Fibra */
.dash-fibra-card {
  background: #f0faf4;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1.5px solid #b7e4c7;
}
.dash-fibra-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dash-fibra-icon { font-size: 1.4rem; }
.dash-fibra-val  { font-size: 1.4rem; font-weight: 700; color: #2d6a4f; }
.dash-fibra-unit { font-size: 0.8rem; font-weight: 400; }
.dash-fibra-meta { font-size: 0.8rem; color: #888; flex: 1; }
.dash-fibra-edit { background: none; border: none; cursor: pointer; font-size: 0.9rem; padding: 4px; }
.dash-fibra-sub  { font-size: 0.8rem; color: #555; margin-top: 6px; }

/* Bebestibles */
.dash-bebidas-card {
  background: #e8f4fd;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1.5px solid #90caf9;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.dash-bebidas-icon   { font-size: 1.8rem; }
.dash-bebidas-count  { font-size: 1rem; font-weight: 700; color: #1565c0; }
.dash-bebidas-list   { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dash-bebida-tag {
  background: #bbdefb;
  color: #1565c0;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.dash-peso-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1.5px solid #74c69d;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.dash-peso-controles {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* =====================================================
   HÁBITOS
   ===================================================== */
.habitos-wrap {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}
.select-filtro {
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--green-dark, #2d6a4f);
  min-width: 200px;
}
.select-filtro:focus {
  outline: none;
  border-color: var(--green-light, #74c69d);
  background: var(--green-pale, #d8f3dc);
}
.habitos-grafica-personalizado-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.habitos-grafica-desc {
  font-size: 0.82rem;
  color: #666;
  margin: 0 0 8px 0;
}

.habito-banner-vencido {
  background: #fef3c7;
  border: 1.5px solid #f9a825;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #7a5000;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.habito-seguimiento-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}
.habito-seg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.habito-seg-nombre { font-weight: 700; font-size: 0.95rem; color: var(--green-dark); }
.habito-seg-dias   { font-size: 0.78rem; color: #888; }
.habito-seg-fechas { font-size: 0.72rem; color: #aaa; margin-top: 4px; }

.habito-checklist-hoy { margin-top: 10px; }
.habito-check-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  background: #fafafa;
  font-size: 0.88rem;
  cursor: pointer;
  font-weight: 600;
  color: #555;
  transition: all .2s;
}
.habito-check-btn.completado {
  background: #f0faf4;
  border-color: var(--green-mid, #40916c);
  color: var(--green-dark, #1b4332);
}

.habito-maestra-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.habito-maestra-nombre { font-size: 0.9rem; font-weight: 600; }
.habito-maestra-actions { display: flex; gap: 6px; align-items: center; }
.btn-sm-green {
  background: var(--green-pale, #d8f3dc);
  color: var(--green-dark, #1b4332);
  border: none; border-radius: 6px;
  padding: 5px 10px; font-size: 0.78rem;
  font-weight: 700; cursor: pointer;
}
.btn-sm-red {
  background: #fde8e8; color: #c0392b;
  border: none; border-radius: 6px;
  padding: 5px 8px; font-size: 0.78rem;
  font-weight: 700; cursor: pointer;
}
.habito-tag-activo {
  background: #e8f4fd;
  color: #1565c0;
  border-radius: 10px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

.habito-sugerencia-chip {
  background: #f0faf4;
  color: var(--green-dark, #1b4332);
  border: 1.5px solid #b7e4c7;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s;
}
.habito-sugerencia-chip:hover { background: #d8f3dc; }

.seg-opcion {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 0;
}

/* =====================================================
   ESTADO DE ÁNIMO
   ===================================================== */
.animo-wrap {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}
.animo-registro-hoy {
  background: #fff;
  border-radius: 14px;
  padding: 20px 16px;
  box-shadow: 0 1px 8px rgba(0,0,0,.08);
}
.animo-pregunta {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-dark, #1b4332);
  margin-bottom: 14px;
  text-align: center;
}
.animo-opciones {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.animo-opcion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 2px solid #e8e8e8;
  background: #fafafa;
  cursor: pointer;
  min-width: 58px;
  transition: all .2s;
  font-size: 0.72rem;
  color: #666;
  font-weight: 600;
}
.animo-opcion:hover { border-color: var(--green-mid, #40916c); background: #f0faf4; }
.animo-opcion.seleccionado {
  border-color: var(--green-mid, #40916c);
  background: #f0faf4;
  color: var(--green-dark, #1b4332);
}
.animo-emoji { font-size: 1.8rem; }
.animo-label { font-size: 0.65rem; text-align: center; }
.animo-nota-wrap { margin-top: 12px; }
.animo-nota-btn {
  margin-top: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: var(--green-mid, #40916c);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.animo-nota-btn:hover { opacity: 0.9; }

.animo-historial {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.animo-hist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.animo-hist-item-editable {
  cursor: pointer;
}
.animo-hist-item-editable:hover {
  background: #f8faf8;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}
.animo-hist-fecha { font-size: 0.78rem; color: #aaa; width: 36px; flex-shrink: 0; }
.animo-hist-emoji { font-size: 1.3rem; }
.animo-hist-label { font-size: 0.85rem; font-weight: 600; flex: 1; }
.animo-hist-nota  { font-size: 1rem; cursor: help; }

/* =====================================================
   ANTROPOMETRÍA
   ===================================================== */

.antropometria-wrap {
  padding: 1rem;
  max-width: 700px;
  margin: 0 auto;
}

.antropometria-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 0.95rem;
  line-height: 1.6;
}

.medidas-form {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  margin-bottom: 1.25rem;
}

.medidas-form-title {
  font-weight: 700;
  color: var(--green-dark, #2d6a4f);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.medidas-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem 1rem;
}

@media (max-width: 480px) {
  .medidas-form-grid { grid-template-columns: 1fr; }
}

.medidas-historial { margin-top: 1.25rem; }
.medidas-historial-title {
  font-weight: 700;
  color: var(--green-dark, #2d6a4f);
  margin-bottom: 0.6rem;
  font-size: 1rem;
}

.medida-card {
  background: #fff;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.medida-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.medida-fecha { font-size: 0.82rem; color: #888; }
.medida-tipo  { font-weight: 700; font-size: 0.9rem; color: var(--green-dark, #2d6a4f); flex: 1; }
.btn-delete-medida {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  color: #e63946;
  transition: background 0.15s;
}
.btn-delete-medida:hover { background: #fdecea; }

.medida-valores { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.medida-val {
  font-size: 0.82rem;
  background: var(--green-pale, #d8f3dc);
  color: var(--green-dark, #2d6a4f);
  border-radius: 12px;
  padding: 0.15rem 0.6rem;
  font-weight: 600;
}

/* Gráficos */
.graficos-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 600px) {
  .graficos-container { grid-template-columns: 1fr; }
}

.grafico-card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.grafico-title {
  font-weight: 700;
  color: var(--green-dark, #2d6a4f);
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

.grafico-filtros {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.btn-filtro {
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 0.2rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-filtro.active,
.btn-filtro:hover {
  background: var(--green-pale, #d8f3dc);
  border-color: var(--green-light, #74c69d);
  color: var(--green-dark, #2d6a4f);
  font-weight: 600;
}

/* PDF cards (paciente presencial) */
.pdf-card-paciente {
  background: #fff;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pdf-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.pdf-card-nombre {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-card-fecha { font-size: 0.78rem; color: #888; }

/* =====================================================
   CONTROL NUTRICIONAL
   ===================================================== */

/* Banner de notificación */
.control-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: linear-gradient(135deg, #2d6a4f, #40916c);
  color: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  position: relative;
}
.control-banner-text {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.control-banner-icon { font-size: 1.6rem; flex-shrink: 0; }
.control-banner-btn {
  background: #fff;
  color: var(--green-dark, #2d6a4f);
  border: none;
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.control-banner-btn:hover { opacity: 0.9; }

.control-banner-close {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  position: absolute;
  right: 0.9rem;
  top: 0.9rem;
  z-index: 2;
}
.control-banner-close:hover {
  background: rgba(255,255,255,0.4);
}

/* Vista control */
.control-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.control-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  color: var(--gray-600, #6c757d);
}

/* Formulario preguntas */
.control-pregunta {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.control-pregunta-titulo {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--green-dark, #2d6a4f);
  margin-bottom: 0.6rem;
}
.control-subtexto {
  font-size: 0.82rem;
  color: var(--gray-600, #6c757d);
  margin-bottom: 0.5rem;
}
.control-required { color: #e63946; }
.control-input,
.control-textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200, #e9ecef);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.93rem;
  font-family: inherit;
  background: #fafafa;
  transition: border-color 0.15s;
  resize: vertical;
}
.control-input:focus,
.control-textarea:focus { outline: none; border-color: var(--green-mid, #40916c); }
.control-textarea { min-height: 80px; }

/* Escala visual (pills) */
.control-escala-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--gray-600, #6c757d);
  margin-bottom: 0.4rem;
}
.control-escala {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.escala-btn {
  flex: 1;
  min-width: 36px;
  padding: 0.45rem 0.3rem;
  border: 1.5px solid var(--gray-200, #e9ecef);
  border-radius: 8px;
  background: #f4f4f4;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.escala-btn:hover {
  background: var(--green-pale, #d8f3dc);
  border-color: var(--green-light, #74c69d);
}
.escala-btn.active {
  background: var(--green-mid, #40916c);
  border-color: var(--green-dark, #2d6a4f);
  color: #fff;
}

/* Escala de Bristol */
.bristol-tabla {
  margin-bottom: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--gray-200, #e9ecef);
}
.bristol-fila {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}
.bristol-fila:nth-child(even) { background: #f8f9fa; }
.bristol-tipo {
  font-weight: 700;
  color: var(--green-dark, #2d6a4f);
  min-width: 56px;
  flex-shrink: 0;
}
.bristol-desc { color: var(--gray-800, #343a40); }

/* Hidratación */
.hidratacion-barras {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.hidratacion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.4rem;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  flex: 1;
  min-width: 60px;
  transition: border-color 0.15s, transform 0.1s;
  font-family: inherit;
}
.hidratacion-btn:hover { transform: scale(1.05); }
.hidratacion-btn.active { border-color: var(--green-dark, #2d6a4f) !important; box-shadow: 0 0 0 2px rgba(45,106,79,.3); }
.hidratacion-num { font-weight: 800; font-size: 1rem; }
.hidratacion-label { font-size: 0.62rem; text-align: center; margin-top: 2px; }

/* Historial de controles */
.control-historial { margin-top: 1.5rem; }
.control-historial-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--green-dark, #2d6a4f);
  margin-bottom: 0.75rem;
}
.control-card {
  background: #fff;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  overflow: hidden;
}
.control-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  user-select: none;
}
.control-card-header:hover { background: #f8f9fa; }
.control-card-fecha {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--green-dark, #2d6a4f);
  display: block;
  margin-bottom: 0.3rem;
}
.control-card-badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.control-badge {
  font-size: 0.78rem;
  background: var(--green-pale, #d8f3dc);
  color: var(--green-dark, #2d6a4f);
  border-radius: 10px;
  padding: 0.15rem 0.55rem;
  font-weight: 600;
}
.control-card-toggle { color: var(--gray-600, #6c757d); font-size: 0.75rem; flex-shrink: 0; }
.control-card.open .control-card-toggle { transform: rotate(180deg); }
.control-card-body {
  display: none;
  padding: 0 1.1rem 1rem;
  border-top: 1px solid var(--gray-200, #e9ecef);
}
.control-card.open .control-card-body { display: block; }
.control-detalle-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.88rem;
}
.control-detalle-row:last-child { border-bottom: none; }
.control-detalle-label { font-weight: 600; color: var(--gray-600, #6c757d); }

@media (max-width: 500px) {
  .control-detalle-row { grid-template-columns: 1fr; gap: 0.15rem; }
  .hidratacion-label { font-size: 0.55rem; }
}

/* =====================================================
   RESPONSIVE MOBILE — mejoras generales
   ===================================================== */

/* Drawer: touch target mínimo */
.drawer-item { min-height: 48px; }

/* Dashboard macros: 1 col en pantallas muy pequeñas */
@media (max-width: 380px) {
  .dash-macros-grid { grid-template-columns: 1fr; }
}

/* Control nutricional: botón banner full-width en móvil pequeño */
@media (max-width: 480px) {
  .control-banner-btn { width: 100%; }
  .hidratacion-barras { flex-direction: column; }
}

/* Hábitos: wrap en layouts internos + touch targets */
.habito-maestra-item { flex-wrap: wrap; }
.habito-seg-header { flex-wrap: wrap; }

@media (max-width: 480px) {
  .btn-sm-green,
  .btn-sm-red { min-height: 44px; padding: 6px 12px; }
}

/* Antropometría: evitar desborde del canvas */
.grafico-card { overflow: hidden; }

/* =====================================================
   BUSCADOR USDA
   ===================================================== */

.usda-modal-box {
  max-width: 540px;
}

.usda-result-card {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.usda-result-card:hover {
  border-color: var(--green-light);
  background: var(--green-pale);
}

.usda-macros-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 0.78rem;
  color: #666;
}

@media (max-width: 600px) {
  .usda-modal-box { max-width: 100%; }
}
