:root {
  --bg: #0f1419;
  --bg-elev: #1a2028;
  --bg-elev-2: #232b35;
  --border: #2d3744;
  --text: #e6edf3;
  --text-muted: #8b98a5;
  --accent: #4ade80;
  --accent-dim: #16a34a;
  --warn: #fbbf24;
  --danger: #ef4444;
  --info: #60a5fa;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.nav-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.nav-btn.active { background: var(--accent-dim); color: white; border-color: var(--accent-dim); }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.vista { display: none; }
.vista.activa { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text);
}

h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-titulo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.card-titulo .icono { font-size: 1.4rem; }

.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: var(--bg-elev-2);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 0.75rem;
  margin-right: 0.4rem;
  border: 1px solid var(--border);
}
.tag.tag-info { color: var(--info); border-color: var(--info); }

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.4rem; }

/* HOY */
#hoy-resumen { margin-bottom: 1rem; }

.bloque {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.bloque h4 {
  color: var(--accent);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ejercicio {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ejercicio:hover { border-color: var(--accent-dim); }

.ejercicio.completado {
  opacity: 0.55;
  border-color: var(--accent-dim);
  background: rgba(74, 222, 128, 0.05);
}

.ejercicio.completado .ej-nombre { text-decoration: line-through; }

.check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-muted);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  color: transparent;
  transition: all 0.15s ease;
}

.ejercicio.completado .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.ej-info { flex: 1; }
.ej-nombre { font-weight: 600; margin-bottom: 0.2rem; }
.ej-detalles { color: var(--text-muted); font-size: 0.85rem; }

.ej-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ej-link:hover {
  color: var(--info);
  border-bottom-color: var(--info);
}
.ej-link-icon {
  font-size: 0.75em;
  opacity: 0.6;
  margin-left: 0.15rem;
}
.ej-link:hover .ej-link-icon { opacity: 1; }
.ejercicio.completado .ej-link {
  border-bottom-color: transparent;
}
.ej-notas {
  font-size: 0.8rem;
  color: var(--warn);
  margin-top: 0.3rem;
  font-style: italic;
}

/* SEMANA */
#semana-grid {
  display: grid;
  gap: 0.75rem;
}

.dia-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dia-card.hoy { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dia-icono { font-size: 2rem; }
.dia-info { flex: 1; }
.dia-nombre { font-weight: 700; font-size: 1rem; }
.dia-titulo { color: var(--text-muted); font-size: 0.9rem; }

/* DIETA */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}

.macro-box {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.macro-valor {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.macro-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comida {
  margin-bottom: 1rem;
}

.opcion-comida {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.opcion-titulo {
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--info);
}

.opcion-ingredientes { font-size: 0.9rem; }

.macros-mini {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* PROGRESO */
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent-dim);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--accent); color: var(--bg); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-danger:hover { background: var(--danger); color: white; }

.danger-zone { border-color: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
td.delta-pos { color: var(--accent); }
td.delta-neg { color: var(--warn); }

.empty { color: var(--text-muted); font-style: italic; padding: 1rem 0; }

.btn-secundario {
  background: transparent;
  color: var(--info);
  border: 1px solid var(--info);
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-secundario:hover { background: var(--info); color: white; }

.datos-acciones {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#historico-grafica {
  margin-bottom: 1rem;
}

.grafica-svg {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 0.5rem;
}

.grafica-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.grafica-eje {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
}

.grafica-eje-titulo {
  fill: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grafica-linea {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.grafica-punto {
  stroke: var(--bg-elev);
  stroke-width: 1.5;
  cursor: pointer;
}

.grafica-leyenda {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.leyenda-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.leyenda-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

@media (max-width: 600px) {
  main { padding: 1rem; }
  .macros-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-form { grid-template-columns: 1fr; }
  header h1 { font-size: 1.2rem; }
  .nav-btn { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
}
