/* =========================================================================
   Protocolo Neuropatía Cero — Sistema de diseño
   "Medical Tech Premium" · Dark mode · Accesibilidad Sénior (50+)
   Negro/gris oscuro · Verde Sálvia (#728C69) · Blanco Marfil (#FDFDFD)
   · Dorado (#C5A059) para logros/bonos/garantía
   - Texto base 18px (mín. 16px) · Títulos 20px+ · Botones mín. 48px
   ========================================================================= */

:root {
  /* Colores */
  --bg: #0B0B0C;            /* casi negro */
  --bg-2: #1A1A1A;          /* gris muy oscuro */
  --surface: #161617;
  --surface-2: #202022;
  --line: #2C2C2F;

  --sage: #728C69;          /* verde sálvia premium */
  --sage-bright: #8AA67F;
  --sage-dark: #57704F;
  --sage-tint: rgba(114, 140, 105, 0.14);

  --gold: #C5A059;          /* dorado: logros, bonos, garantía */
  --gold-bright: #DDBE7E;
  --gold-tint: rgba(197, 160, 89, 0.14);

  --ivory: #FDFDFD;         /* blanco marfil */
  --text: #FDFDFD;
  --muted: #9A9A9E;
  --danger: #D9756B;

  /* Tipografía */
  --fs-base: 18px;
  --fs-sm: 16px;
  --fs-lg: 20px;
  --fs-title: 24px;
  --fs-hero: 28px;

  /* Medidas */
  --tap: 56px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-gold: 0 6px 22px rgba(197, 160, 89, 0.18);
  --maxw: 560px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
img { max-width: 100%; }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-title); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 1em; }

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

/* --- Utilidades --------------------------------------------------------- */
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }

/* --- Botones ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: var(--tap);
  padding: 14px 20px;
  border: none; border-radius: var(--radius);
  font-size: var(--fs-lg); font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, opacity .15s;
  text-align: center;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .6; cursor: default; }

.btn-primary { background: var(--sage); color: #0B0B0C; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--sage-bright); }

.btn-gold { background: var(--gold); color: #0B0B0C; box-shadow: var(--shadow-gold); }
.btn-gold:hover { background: var(--gold-bright); }

.btn-secondary {
  background: transparent; color: var(--sage-bright);
  border: 2px solid var(--sage);
}
.btn-secondary:hover { background: var(--sage-tint); }

.btn-ghost { background: var(--surface-2); color: var(--ivory); }

/* --- Campos ------------------------------------------------------------- */
.field { margin-bottom: 16px; text-align: left; }
.field label {
  display: block; font-size: var(--fs-sm); font-weight: 700;
  color: var(--ivory); margin-bottom: 8px;
}
.field input, .field select {
  width: 100%; min-height: var(--tap);
  padding: 12px 16px; font-size: var(--fs-base);
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ivory);
}
.field input::placeholder { color: #6C6C70; }
.field input:focus, .field select:focus {
  outline: none; border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-tint);
}
.form-error { color: var(--danger); font-size: var(--fs-sm); font-weight: 600; min-height: 1.2em; margin: 4px 0 12px; }

/* =========================================================================
   ONBOARDING / AUTH
   ========================================================================= */
.screen { min-height: 100vh; display: flex; flex-direction: column; padding: 28px 22px calc(28px + env(safe-area-inset-bottom)); }
.auth-screen { justify-content: center; gap: 8px; }

.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { width: 92px; height: 92px; margin: 0 auto 14px; display: block; }
.brand h1 { color: var(--ivory); }
.brand .tagline { color: var(--sage-bright); font-weight: 600; letter-spacing: .02em; }

.welcome-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  margin-bottom: 22px; border-left: 4px solid var(--gold);
}
.welcome-card p { margin: 0; }

.auth-actions { display: grid; gap: 14px; }
.auth-card { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card h2 { color: var(--sage-bright); text-align: center; }

.link-btn {
  background: none; border: none; color: var(--sage-bright);
  font-size: var(--fs-base); font-weight: 700; text-decoration: underline;
  cursor: pointer; width: 100%; min-height: var(--tap);
}

.guarantee {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  color: var(--gold); font-weight: 700; font-size: var(--fs-sm);
  margin-top: 8px;
}

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, #17201A 0%, #0B0B0C 100%);
  color: var(--ivory);
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  border-bottom: 1px solid var(--line);
}
.app-header .greeting { font-size: var(--fs-sm); color: var(--muted); margin: 0; }
.app-header .gami { font-size: var(--fs-lg); font-weight: 800; margin: 4px 0 0; color: var(--ivory); }
.app-header .gami .day-num { color: var(--gold); }

.view { padding: 20px 18px 110px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.section-title { color: var(--ivory); margin: 6px 0 6px; }
.section-intro { color: var(--muted); margin-top: 0; }

/* Tarjeta genérica */
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
  border: 1px solid var(--line);
}
.card h3 { color: var(--ivory); }
.card.gold-edge { border-left: 4px solid var(--gold); }

/* =========================================================================
   TAB 1 — Mapa de 14 días
   ========================================================================= */
.day-map {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px;
  margin: 8px 0 4px;
}
.day-cell {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: var(--fs-base);
  border: 2px solid var(--line); background: var(--surface-2); color: var(--muted);
  position: relative;
}
.day-cell.done { background: var(--sage); color: #0B0B0C; border-color: var(--sage); }
.day-cell.done::after { content: "✓"; position: absolute; top: 2px; right: 5px; font-size: 11px; }
.day-cell.today {
  border-color: var(--gold); color: var(--gold-bright);
  box-shadow: 0 0 0 3px var(--gold-tint); background: var(--surface);
}

/* Checklist de nutrientes */
.check-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.check-item:last-child { border-bottom: none; }
.check-box {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
  border: 2px solid var(--sage); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--sage-bright); background: transparent; font-size: 18px;
  transition: all .15s ease;
}
.check-item.done .check-box { background: var(--sage); color: #0B0B0C; }
.check-item.done .ci-title { color: var(--muted); text-decoration: line-through; }
.ci-body { flex: 1; }
.ci-title { font-weight: 700; }
.ci-sub { font-size: var(--fs-sm); color: var(--muted); }
.ci-emoji { font-size: 24px; }

/* Estimulación de hoy (resumen en Inicio) */
.estim-status {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2);
  margin-top: 6px;
}
.estim-status .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; }
.estim-status.ok .dot { background: var(--sage); }

/* Registro de dolor */
.pain-scale { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.pain-btn {
  flex: 1 1 calc(20% - 8px); min-width: 44px; min-height: 48px;
  border-radius: 10px; border: 2px solid var(--line); background: var(--surface-2);
  color: var(--ivory); font-weight: 800; font-size: var(--fs-base); cursor: pointer;
}
.pain-btn.sel { border-color: var(--gold); color: var(--gold-bright); background: var(--gold-tint); }
.pain-legend { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }

.stat-row { display: flex; gap: 12px; margin-top: 10px; }
.stat-pill { flex: 1; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-pill .num { font-size: var(--fs-title); font-weight: 800; display: block; }
.stat-pill .lbl { font-size: var(--fs-sm); color: var(--muted); }

/* Progreso */
.progress-bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--sage), var(--gold)); border-radius: 999px; transition: width .4s ease; }

/* =========================================================================
   TAB 2 — Protocolo (nutrientes + estimulación / timer)
   ========================================================================= */
.proto-hero {
  background: linear-gradient(135deg, #1D241A 0%, #0B0B0C 100%);
  border: 1px solid var(--line);
  color: var(--ivory); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.proto-hero h2 { color: var(--ivory); }
.proto-hero p { margin: 0; color: var(--muted); }

.nutri-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
.nutri-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.nutri-head .n-emoji {
  width: 52px; height: 52px; border-radius: 14px; background: var(--sage-tint);
  display: flex; align-items: center; justify-content: center; font-size: 26px; flex: 0 0 auto;
}
.nutri-head h3 { margin: 0; color: var(--ivory); }
.nutri-tag {
  display: inline-block; font-size: 12.5px; font-weight: 800; letter-spacing: .04em;
  color: var(--sage-bright); text-transform: uppercase;
}
.nutri-dose {
  display: inline-flex; gap: 8px; align-items: center;
  background: var(--gold-tint); color: var(--gold-bright);
  border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: var(--fs-sm); margin: 4px 0 8px;
}
.nutri-card p { margin: 6px 0 0; }
.nutri-how { color: var(--muted); font-size: var(--fs-sm); margin-top: 8px; }

/* Pasos de la estimulación */
.step {
  display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: flex-start;
}
.step:last-child { border-bottom: none; }
.step .num {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--sage); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--sage-bright); font-size: var(--fs-sm);
}
.step-title { font-weight: 700; margin-bottom: 2px; }
.step-detail { color: var(--muted); font-size: var(--fs-sm); }

/* Temporizador circular */
.timer-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.timer-ring { position: relative; width: 240px; height: 240px; }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring .track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.timer-ring .prog { fill: none; stroke: var(--gold); stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.timer-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px;
}
.timer-time { font-size: 46px; font-weight: 800; color: var(--ivory); line-height: 1; }
.timer-phase { font-size: var(--fs-sm); color: var(--gold-bright); font-weight: 700; margin-top: 8px; }
.timer-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.timer-actions { display: flex; gap: 12px; width: 100%; }

/* =========================================================================
   TAB 3 — Progreso (gráfico)
   ========================================================================= */
.chart-wrap { margin-top: 10px; }
.chart-empty { text-align: center; color: var(--muted); padding: 26px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
svg.chart { width: 100%; height: 220px; display: block; }

/* =========================================================================
   TAB 4 — Recursos (Acordeón)
   ========================================================================= */
.accordion-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.accordion-item.gold { border-color: rgba(197,160,89,.4); }
.accordion-head {
  width: 100%; min-height: 68px; background: transparent; border: none;
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
  font-size: var(--fs-lg); font-weight: 800; color: var(--ivory); text-align: left; cursor: pointer;
}
.accordion-head .acc-ico {
  width: 46px; height: 46px; border-radius: 12px; background: var(--sage-tint);
  display: flex; align-items: center; justify-content: center; font-size: 24px; flex: 0 0 auto;
}
.accordion-item.gold .acc-ico { background: var(--gold-tint); }
.accordion-head .badge-bonus {
  margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  color: var(--gold-bright); border: 1px solid rgba(197,160,89,.5); border-radius: 999px; padding: 3px 8px;
}
.accordion-head .chev { color: var(--sage-bright); font-size: 22px; transition: transform .2s ease; }
.accordion-item.open .accordion-head .chev { transform: rotate(180deg); }
.accordion-body { padding: 0 18px 18px; border-top: 1px solid var(--line); }
.accordion-body p { margin: 14px 0 0; }

/* =========================================================================
   BOTTOM NAV
   ========================================================================= */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: var(--maxw);
  background: var(--bg-2); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  background: none; border: none; min-height: 64px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 700;
}
.nav-btn .nav-ico { font-size: 22px; line-height: 1; }
.nav-btn.active { color: var(--sage-bright); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px);
  background: var(--sage); color: #0B0B0C; padding: 14px 22px; border-radius: 999px; font-weight: 800;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 50;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.gold { background: var(--gold); }

.account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
