/* ============================================================
   Nutrelo — diseño flat, estilo Apple, acento verde
   ============================================================ */

/* ---------- Fuente Ubuntu (autoalojada) ---------- */
@font-face { font-family: 'Ubuntu'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/ubuntu-400.woff2') format('woff2'); }
@font-face { font-family: 'Ubuntu'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/ubuntu-500.woff2') format('woff2'); }
@font-face { font-family: 'Ubuntu'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/ubuntu-700.woff2') format('woff2'); }

/* ---------- Tokens ---------- */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --surface-3: #e3e6ea;
  --border: #e4e7ea;
  --border-strong: #d6dade;
  --text: #10151b;
  --muted: #6b7480;
  --faint: #9aa2ad;

  --accent: #2fb457;
  --accent-press: #279a4a;
  --accent-ink: #1f8a44;
  --accent-soft: rgba(47, 180, 87, 0.12);
  --warm: #f59331;
  --danger: #e5484d;

  --ring: rgba(47, 180, 87, 0.28);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.05);

  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 10px;

  --chip-alta: rgba(47, 180, 87, 0.14);
  --chip-media: rgba(245, 147, 49, 0.16);
  --chip-baja: rgba(229, 72, 77, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --border: #2c2c2e;
    --border-strong: #3a3a3c;
    --text: #f5f5f7;
    --muted: #9a9aa2;
    --faint: #6a6a70;

    --accent: #34d05e;
    --accent-press: #2bb851;
    --accent-ink: #45d96e;
    --accent-soft: rgba(52, 208, 94, 0.16);
    --warm: #ff9f0a;
    --danger: #ff453a;

    --ring: rgba(52, 208, 94, 0.3);
    --shadow: none;

    --chip-alta: rgba(52, 208, 94, 0.18);
    --chip-media: rgba(255, 159, 10, 0.18);
    --chip-baja: rgba(255, 69, 58, 0.18);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Ubuntu', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.25rem; margin: 0; font-weight: 700; }
h2 {
  font-size: 0.95rem;
  margin: 0 0 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
}
h2 .ic { color: var(--accent); width: 18px; height: 18px; }

/* ---------- Iconos ---------- */
.ic {
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  fill: currentColor;
  flex: 0 0 auto;
  vertical-align: middle;
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand .ic { color: var(--accent); width: 22px; height: 22px; }

.logout-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 38px; height: 38px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.logout-btn .ic { width: 18px; height: 18px; }
.logout-btn:active { background: var(--surface-3); }

/* ---------- Navegación (segmented control, estilo iOS) ---------- */
nav {
  position: fixed;
  top: 12px;
  right: 20px;
  z-index: 31;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color 0.15s, background 0.15s;
}
.tab .ic { width: 16px; height: 16px; }
.tab:active { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}

/* ---------- Layout ---------- */
main { max-width: 720px; margin: 0 auto; padding: 22px 16px 60px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 15px;
}

/* ---------- Fila de stats ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 15px;
}
@media (max-width: 620px) { .cards { grid-template-columns: repeat(2, 1fr); } }

.stat { padding: 16px 15px; }
.stat-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}
.stat-ic .ic { width: 19px; height: 19px; }
.stat .label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.stat .value {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  margin: 3px 0 1px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.stat .unit { font-size: 0.72rem; color: var(--faint); }

/* ---------- Tarjeta de presupuesto calórico ---------- */
.budget-card { display: flex; flex-direction: column; gap: 12px; }
.budget-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.budget-remaining {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}
.budget-remaining.over { color: var(--danger); }
.budget-remaining-unit { color: var(--muted); font-size: 0.85rem; margin-left: 6px; }
.budget-method {
  font-size: 0.66rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.budget-bar {
  height: 9px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.budget-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.budget-bar-fill.over { background: var(--danger); }
.budget-legend { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }
.budget-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.budget-note { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
@media (prefers-color-scheme: dark) { .budget-remaining, .budget-method { color: var(--accent); } }

/* ---------- Estado vacío del presupuesto ---------- */
#budget-empty { text-align: center; padding: 6px 0; }
.budget-empty-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.05rem; margin-bottom: 6px;
}
.budget-empty-title .ic { color: var(--accent); width: 19px; height: 19px; }
#budget-empty .hint { margin-bottom: 14px; }
#budget-empty button { width: 100%; max-width: 320px; }
.budget-edit {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px; height: 34px; padding: 0;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.budget-edit .ic { width: 16px; height: 16px; }
.budget-edit:hover { background: var(--surface-3); color: var(--accent-ink); }

/* ---------- Formulario de perfil / objetivo ---------- */
.profile-form { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }
.field-row button { flex: 0 0 auto; }
@media (max-width: 520px) { .field-row { flex-direction: column; } }
.field-label {
  font-size: 0.72rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-top: 6px;
}
.goal-options { display: flex; gap: 8px; }
.goal-opt {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 12px 8px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.goal-opt .ic { width: 18px; height: 18px; }
.goal-opt:hover { background: var(--surface-3); color: var(--text); }
.goal-opt.active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 400px) { .goal-opt { font-size: 0.78rem; padding: 10px 4px; } }

.profile-summary { font-size: 0.92rem; line-height: 1.6; color: var(--text); margin-bottom: 14px; }
.profile-summary .ps-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.profile-summary .ps-row span:first-child { color: var(--muted); }
.profile-summary .ps-empty { color: var(--muted); }

/* ---------- Navegación de fecha ---------- */
.date-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.date-nav button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  width: 42px; height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.date-nav button .ic { width: 18px; height: 18px; }
.date-nav button:active { background: var(--surface-2); }
.date-nav input {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  box-shadow: var(--shadow);
  color-scheme: light dark;
}

/* ---------- Formularios ---------- */
input[type='number'], input[type='text'], input[type='email'], input[type='password'], select {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--surface);
}
input::placeholder { color: var(--faint); }

.inline-form { display: flex; gap: 10px; }
.inline-form input, .inline-form select { flex: 1; min-width: 0; }

/* ---------- Botones flat (sin glow ni degradado) ---------- */
button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background 0.15s, opacity 0.15s;
}
button:hover, .btn:hover { background: var(--accent-press); }
button:active, .btn:active { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.strava-btn { background: #fc4c02; }
.strava-btn:hover { background: #e34402; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

#meal-form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Chips de tipo de comida ---------- */
.type-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.type-chips button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 0.87rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.type-chips button .ic { width: 15px; height: 15px; }
.type-chips button:hover { background: var(--surface-3); color: var(--text); }
.type-chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Miniaturas ---------- */
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; }
.thumb img {
  width: 76px; height: 76px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.thumb button {
  position: absolute;
  top: -7px; right: -7px;
  width: 22px; height: 22px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  line-height: 1;
}
.thumb button:hover { background: var(--danger); opacity: 0.85; }

/* ---------- Registro rápido (recientes + código de barras) ---------- */
.quick-add { margin-top: 12px; }
.ghost-btn {
  background: var(--surface-2);
  color: var(--accent-ink);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
}
.ghost-btn:hover { background: var(--surface-3); }
.ghost-btn .ic { width: 17px; height: 17px; }
@media (prefers-color-scheme: dark) { .ghost-btn { color: var(--accent); } }

.recent-wrap { margin-top: 16px; }
.recent-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.8rem; font-weight: 500; color: var(--muted);
  margin-bottom: 10px;
}
.recent-title .ic { width: 15px; height: 15px; }
.recent-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.recent-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}
.recent-chip:hover { background: var(--surface-3); border-color: var(--accent); }
.recent-chip .rc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.recent-chip .rc-kcal { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.8rem; }

/* Código de barras */
#barcode-video { width: 100%; border-radius: var(--r-md); background: #000; margin-bottom: 12px; max-height: 260px; object-fit: cover; }
.barcode-manual { display: flex; gap: 10px; }
.barcode-manual input { flex: 1; }
.barcode-manual button { flex: 0 0 auto; }
.barcode-product { margin-bottom: 12px; }
.barcode-name { font-weight: 700; font-size: 1.05rem; }
.barcode-per100 { color: var(--muted); font-size: 0.85rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.barcode-computed { margin: 12px 0; font-weight: 500; font-variant-numeric: tabular-nums; }
#barcode-save { width: 100%; }

/* ---------- Zona de foto ---------- */
.file-drop {
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--r-md);
  min-height: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
  padding: 16px;
  text-align: center;
  font-size: 0.92rem;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.file-drop-ic { color: var(--faint); }
.file-drop-ic .ic { width: 30px; height: 30px; }
.file-drop:hover { border-color: var(--accent); background: var(--surface-3); color: var(--text); }
.file-drop:hover .file-drop-ic { color: var(--accent); }

.hint { color: var(--muted); font-size: 0.84rem; margin: 4px 0 12px; line-height: 1.5; }
.error { color: var(--danger); margin-top: 10px; font-size: 0.9rem; }
.loading { margin-top: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }

.spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list .empty { color: var(--muted); font-size: 0.9rem; padding: 4px 2px; }

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 2px 2px;
  font-weight: 700;
  font-size: 0.9rem;
}
.group-head span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.group-head .ic { width: 15px; height: 15px; color: var(--accent); }
.group-head:not(:first-child) { margin-top: 10px; }
.group-kcal { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }

.meal-item, .activity-item {
  display: flex;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.meal-photo { position: relative; flex-shrink: 0; }
.meal-photo img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--r-sm); }
.photo-count {
  position: absolute;
  bottom: 5px; right: 5px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
}
.mini-gallery { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mini-gallery img { width: 62px; height: 62px; object-fit: cover; border-radius: 9px; border: 1px solid var(--border); }

.meal-item .info { flex: 1; min-width: 0; }
.meal-item .title { font-weight: 500; }
.meal-item .macros { font-size: 0.8rem; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.meal-item .kcal, .activity-item .kcal {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.meal-item details { margin-top: 8px; font-size: 0.85rem; }
.meal-item summary { cursor: pointer; color: var(--accent-ink); font-weight: 500; }
.meal-item ul { margin: 8px 0; padding-left: 18px; line-height: 1.55; }
.meal-item .del {
  background: none; border: none; color: var(--faint);
  cursor: pointer; padding: 4px; align-self: flex-start;
  display: inline-flex;
}
.meal-item .del .ic { width: 17px; height: 17px; }
.meal-item .del:hover { color: var(--danger); background: none; }

/* ---------- Chip de confianza ---------- */
.conf {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.conf.alta { background: var(--chip-alta); color: var(--accent-ink); }
.conf.media { background: var(--chip-media); color: #b45309; }
.conf.baja { background: var(--chip-baja); color: var(--danger); }
@media (prefers-color-scheme: dark) { .conf.media { color: var(--warm); } }

.conf-help {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.6rem; font-weight: 700;
  cursor: help; opacity: 0.7;
}
.conf-help:hover { opacity: 1; }
.conf-help::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem; font-weight: 400;
  text-transform: none; letter-spacing: normal;
  padding: 6px 10px; border-radius: 8px;
  white-space: nowrap; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
  z-index: 10;
}
.conf-help:hover::after { opacity: 1; }

/* ---------- Actividades ---------- */
.activity-item { justify-content: space-between; align-items: center; }
.activity-item .meta { font-size: 0.8rem; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.activity-item.clickable { cursor: pointer; }
.activity-item.clickable:hover { border-color: var(--accent); background: var(--surface-3); }

/* ---------- Opinión de la IA ---------- */
.insight {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 15px 16px;
  font-size: 0.92rem;
  line-height: 1.6;
}
.insight p { margin: 0 0 9px; }
.insight p:last-of-type { margin-bottom: 0; }
.insight .empty { color: var(--muted); font-size: 0.88rem; }
.insight-meta { margin-top: 10px; font-size: 0.72rem; color: var(--faint); }

/* ---------- Tendencias ---------- */
.range-select { margin-bottom: 14px; }
.range-select label { color: var(--muted); font-size: 0.9rem; display: inline-flex; align-items: center; }
.range-select select { width: auto; margin-left: 10px; padding: 8px 12px; }
canvas { max-width: 100%; }
.chart-caption { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 22, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
  animation: fade 0.2s ease;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  width: 32px; height: 32px; padding: 0;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close .ic { width: 15px; height: 15px; }
.modal-close:hover { color: var(--danger); background: var(--surface-2); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
@media (max-width: 440px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid .cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 13px;
}
.detail-grid .cell .k { display: block; font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-bottom: 2px; }
.detail-grid .cell .v { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.detail-desc { margin-top: 12px; font-size: 0.9rem; white-space: pre-wrap; line-height: 1.55; color: var(--muted); }
.detail-link { margin-top: 14px; display: inline-block; color: var(--accent-ink); font-weight: 500; text-decoration: none; }
.detail-link:hover { text-decoration: underline; }

::selection { background: var(--ring); }
.modal-card::-webkit-scrollbar { width: 8px; }
.modal-card::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 30px 26px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card .brand { justify-content: center; font-size: 1.5rem; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-card button { margin-top: 4px; padding: 13px; }
.login-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; margin-top: 4px; }

/* ============================================================
   Responsive — barra de pestañas inferior en móvil
   ============================================================ */
@media (max-width: 620px) {
  header { padding: 13px 16px; }
  main { padding: 18px 12px 92px; }
  .card { padding: 16px; }

  nav {
    position: fixed;
    top: auto;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
    justify-content: space-around;
  }
  .tab {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
    font-size: 0.68rem;
    border-radius: var(--r-sm);
  }
  .tab .ic { width: 23px; height: 23px; }
  .tab.active { background: var(--surface-2); box-shadow: none; }

  .inline-form { flex-direction: column; }
  .meal-photo img { width: 72px; height: 72px; }
  .stat .value { font-size: 1.5rem; }
}
