@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #0a0a0a;
  --bg2: #141414;
  --bg3: #1e1e1e;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --accent: #C8F135;
  --accent2: #a8d420;
  --text: #f0f0f0;
  --text2: #888;
  --text3: #555;
  --danger: #ff5b5b;
  --warn: #ffb347;
  --info: #60b4ff;
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 68px;
  --header-h: 56px;
  --font-mono: 'Space Mono', monospace;
  --font-body: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  overflow: hidden;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ─── SPLASH ─── */
#splash {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; z-index: 999;
  animation: splashOut 0.4s ease 1.8s forwards;
}
@keyframes splashOut {
  to { opacity: 0; pointer-events: none; }
}
.splash-logo {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 22px; font-weight: 700;
  letter-spacing: 4px; color: var(--accent);
  animation: splashIn 0.5s ease 0.2s both;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.splash-sub {
  font-size: 13px; color: var(--text2); letter-spacing: 0.5px;
  animation: splashIn 0.5s ease 0.5s both;
}

/* ─── ONBOARDING ─── */
#onboarding {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: 100;
}
.onb-wrap {
  flex: 1; overflow: hidden; position: relative;
}
.onb-step {
  position: absolute; inset: 0;
  padding: 48px 28px 24px;
  display: flex; flex-direction: column;
  gap: 16px; overflow-y: auto;
  opacity: 0; pointer-events: none;
  transform: translateX(40px);
  transition: all 0.35s ease;
}
.onb-step.active {
  opacity: 1; pointer-events: all;
  transform: translateX(0);
}
.onb-icon {
  font-size: 42px; margin-bottom: 4px;
}
.onb-step h1 {
  font-size: 26px; font-weight: 600; color: var(--text);
  line-height: 1.2;
}
.onb-step p {
  font-size: 14px; color: var(--text2); line-height: 1.6;
}
.goal-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-top: 8px;
}
.goal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text2);
  transition: all 0.2s;
}
.goal-card.active {
  border-color: var(--accent);
  background: rgba(200,241,53,0.08);
  color: var(--accent);
}
.goal-ico { font-size: 28px; }
.form-grid { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.inp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inp-group { display: flex; flex-direction: column; gap: 6px; }
.inp-group label { font-size: 12px; color: var(--text2); font-weight: 500; letter-spacing: 0.3px; }
.inp-group input, .inp-group select {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: var(--text); font-family: var(--font-body); font-size: 15px;
  outline: none; transition: border-color 0.2s;
}
.inp-group input:focus, .inp-group select:focus {
  border-color: var(--accent);
}
.level-row { display: flex; gap: 8px; flex-wrap: wrap; }
.level-btn {
  padding: 8px 14px; border-radius: 20px;
  border: 1px solid var(--border2); background: var(--bg2);
  color: var(--text2); font-size: 13px; cursor: pointer;
  transition: all 0.2s;
}
.level-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #0a0a0a; font-weight: 600;
}
.days-selector {
  display: flex; gap: 12px; justify-content: center; margin: 16px 0 8px;
}
.day-num {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border2); background: var(--bg2);
  font-size: 18px; font-weight: 600; font-family: var(--font-mono);
  color: var(--text2); cursor: pointer; transition: all 0.2s;
}
.day-num.active {
  background: var(--accent); border-color: var(--accent);
  color: #0a0a0a;
}
.days-label { text-align: center; color: var(--text2); font-size: 13px; }
.onb-footer {
  padding: 20px 28px 36px;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.onb-dots { display: flex; gap: 8px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg3);
  transition: all 0.3s;
}
.dot.active { background: var(--accent); width: 24px; border-radius: 4px; }

/* ─── BUTTONS ─── */
.btn-primary {
  background: var(--accent); color: #0a0a0a;
  border: none; border-radius: var(--radius-sm);
  padding: 14px 28px; font-size: 15px; font-weight: 600;
  font-family: var(--font-body); cursor: pointer;
  transition: all 0.15s;
}
.btn-primary:active { transform: scale(0.97); background: var(--accent2); }
.btn-primary.full { width: 100%; margin-top: 8px; }
.btn-secondary {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  padding: 14px 28px; font-size: 15px; font-weight: 500;
  font-family: var(--font-body); cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary.full { width: 100%; margin-top: 8px; }
.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(255,91,91,0.3); border-radius: var(--radius-sm);
  padding: 14px 28px; font-size: 14px; font-weight: 500;
  font-family: var(--font-body); cursor: pointer;
  transition: all 0.15s; margin-top: 8px;
}
.btn-danger.full { width: 100%; }

/* ─── APP ─── */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}

/* Header */
#app-header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  position: relative; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 10px; }
#header-title {
  font-family: var(--font-mono); font-size: 13px;
  font-weight: 700; letter-spacing: 2px;
  color: var(--text2); text-transform: uppercase;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); cursor: pointer;
}

/* Main content */
#main-content {
  flex: 1; position: relative; overflow: hidden;
}

.page {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(8px);
  transition: all 0.25s ease;
  padding-bottom: calc(var(--nav-h) + 8px);
}
.page.active {
  opacity: 1; pointer-events: all;
  transform: translateY(0);
}
.page-scroll { padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }

/* Bottom nav */
#bottom-nav {
  height: var(--nav-h);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  flex-shrink: 0;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 8px 0; cursor: pointer;
  color: var(--text3);
  transition: all 0.2s;
}
.nav-item span { font-size: 10px; font-weight: 500; }
.nav-item.active { color: var(--accent); }
.nav-item:active { transform: scale(0.92); }

/* ─── INICIO ─── */
.greeting-block {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.greeting-hey {
  font-size: 22px; font-weight: 600; color: var(--text);
}
.greeting-sub { font-size: 13px; color: var(--text2); margin-top: 4px; }
.streak-badge {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 8px 14px;
  display: flex; align-items: center; gap: 6px;
}
.streak-fire { font-size: 16px; }
#streak-count {
  font-family: var(--font-mono); font-size: 16px;
  font-weight: 700; color: var(--accent);
}
.metrics-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric-tile {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative; overflow: hidden;
}
.metric-tile.tile-accent {
  background: rgba(200,241,53,0.07);
  border-color: rgba(200,241,53,0.25);
}
.tile-label {
  font-size: 11px; color: var(--text2);
  font-weight: 500; letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.tile-val {
  font-family: var(--font-mono); font-size: 26px;
  font-weight: 700; color: var(--text);
}
.tile-val small { font-size: 13px; color: var(--text2); margin-left: 4px; font-weight: 400; font-family: var(--font-body); }
.tile-accent .tile-val { color: var(--accent); }
.tile-trend { font-size: 11px; color: var(--text3); margin-top: 4px; }
.tile-trend.up { color: #4ade80; }
.tile-trend.down { color: var(--danger); }

.section-hd {
  display: flex; justify-content: space-between;
  align-items: center;
}
.section-hd span {
  font-size: 11px; font-weight: 600;
  color: var(--text3); letter-spacing: 1.5px;
  text-transform: uppercase;
}
.section-hd span:last-child { color: var(--accent); font-size: 12px; letter-spacing: 0; }

.progress-track {
  height: 6px; background: var(--bg3);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.progress-legend { font-size: 12px; color: var(--text2); margin-top: -10px; }

.today-card {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: all 0.2s;
}
.today-card:active { background: var(--bg3); }
.today-icon { font-size: 28px; flex-shrink: 0; }
.today-title { font-size: 15px; font-weight: 500; color: var(--text); }
.today-sub { font-size: 12px; color: var(--text2); margin-top: 3px; }
.today-arrow { margin-left: auto; font-size: 22px; color: var(--text3); }

.mini-chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 72px; padding: 0 4px;
}
.mini-bar {
  flex: 1; border-radius: 4px 4px 0 0;
  min-height: 4px; position: relative;
  transition: height 0.4s ease;
}
.mini-bar-day {
  position: absolute; bottom: -18px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px; color: var(--text3);
  font-family: var(--font-mono);
}

.recovery-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center;
}
.recovery-score {
  font-family: var(--font-mono); font-size: 40px;
  font-weight: 700; color: var(--accent);
}
.recovery-label { font-size: 12px; color: var(--text2); }
.recovery-bar-bg {
  width: 100%; height: 8px; background: var(--bg3);
  border-radius: 4px; overflow: hidden;
}
.recovery-bar-fill {
  height: 100%; border-radius: 4px;
  background: var(--accent);
  transition: width 0.6s ease;
}
.recovery-hint { font-size: 12px; color: var(--text3); }

/* ─── REGISTRO ─── */
.reg-header { display: flex; justify-content: space-between; align-items: center; }
.reg-header h2 { font-size: 20px; font-weight: 600; }
.reg-date { font-size: 12px; color: var(--text2); font-family: var(--font-mono); }

.form-section { display: flex; flex-direction: column; gap: 8px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.5px; text-transform: uppercase; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: var(--text); font-family: var(--font-body); font-size: 15px;
  outline: none; width: 100%; transition: border-color 0.2s;
}
.field:focus { border-color: var(--accent); }
textarea.field { resize: none; line-height: 1.5; }

.type-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.type-chip {
  padding: 8px 14px; border-radius: 20px;
  border: 1px solid var(--border2); background: var(--bg2);
  color: var(--text2); font-size: 13px; cursor: pointer;
  transition: all 0.2s;
}
.type-chip.active {
  background: var(--accent); border-color: var(--accent);
  color: #0a0a0a; font-weight: 600;
}

.rpe-row {
  display: flex; gap: 6px;
}
.rpe-btn {
  flex: 1; padding: 10px 4px; text-align: center;
  border-radius: 8px; background: var(--bg2);
  border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  color: var(--text2); cursor: pointer; transition: all 0.15s;
}
.rpe-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #0a0a0a;
}
.rpe-label { font-size: 12px; color: var(--accent); font-style: italic; }

.mood-row {
  display: flex; gap: 10px; justify-content: center;
}
.mood-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); border: 1px solid var(--border);
  font-size: 24px; cursor: pointer; transition: all 0.2s;
}
.mood-btn.active {
  border-color: var(--accent);
  background: rgba(200,241,53,0.12);
  transform: scale(1.1);
}

.fatigue-row { display: flex; gap: 8px; }
.fat-btn {
  flex: 1; padding: 10px; text-align: center;
  border-radius: var(--radius-sm); background: var(--bg2);
  border: 1px solid var(--border); font-size: 12px;
  color: var(--text2); cursor: pointer; transition: all 0.2s;
}
.fat-btn.active {
  border-color: var(--accent); background: rgba(200,241,53,0.1);
  color: var(--accent); font-weight: 600;
}

.save-feedback {
  text-align: center; color: #4ade80;
  font-size: 14px; padding: 12px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── PROGRESO ─── */
.pg-title { font-size: 20px; font-weight: 600; }
.stats-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
}
.stat-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  text-align: center;
}
.stat-num {
  font-family: var(--font-mono); font-size: 22px;
  font-weight: 700; color: var(--accent);
}
.stat-lbl { font-size: 11px; color: var(--text2); margin-top: 4px; }

.chart-wrap {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  min-height: 120px;
}
.chart-empty {
  color: var(--text3); font-size: 13px;
  text-align: center; padding: 24px 0;
}
.donut-wrap {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  min-height: 80px;
}

.records-list { display: flex; flex-direction: column; gap: 10px; }
.record-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.record-top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.record-name { font-weight: 500; font-size: 14px; }
.record-vals { font-family: var(--font-mono); font-size: 12px; color: var(--text2); }
.record-bar-bg { height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.record-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.record-add-btn {
  border: 1px dashed var(--border2); border-radius: var(--radius);
  padding: 16px; text-align: center;
  color: var(--text2); font-size: 13px; cursor: pointer;
  transition: all 0.2s;
}
.record-add-btn:active { border-color: var(--accent); color: var(--accent); }

/* chart bars inline */
.chart-bars-inner { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.cb { flex: 1; border-radius: 4px 4px 0 0; min-height: 4px; position: relative; }
.cb-lbl { position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--text3); font-family: var(--font-mono); }

.type-breakdown-inner { display: flex; flex-direction: column; gap: 8px; }
.type-row { display: flex; align-items: center; gap: 10px; }
.type-name { font-size: 13px; color: var(--text2); width: 90px; flex-shrink: 0; }
.type-bar-bg { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.type-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.type-count { font-family: var(--font-mono); font-size: 12px; color: var(--text2); }

/* ─── PERFIL ─── */
.profile-hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 20px 0 4px;
}
.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(200,241,53,0.15);
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: var(--accent);
  font-family: var(--font-mono);
}
.profile-name { font-size: 20px; font-weight: 600; }
.profile-sport { font-size: 13px; color: var(--text2); }

.data-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.data-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.data-row.last { border-bottom: none; }
.data-key { font-size: 14px; color: var(--text2); }
.data-val { font-size: 14px; font-weight: 500; color: var(--text); font-family: var(--font-mono); }

.zones-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.zone-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.zone-row:last-child { border-bottom: none; }
.zone-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.zone-name { font-size: 13px; color: var(--text2); flex: 1; }
.zone-range { font-family: var(--font-mono); font-size: 12px; color: var(--text); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 20px; padding: 24px;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-title { font-size: 17px; font-weight: 600; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-secondary, .modal-actions .btn-primary { flex: 1; }
