/* =====================================================
   Variables y Reset
===================================================== */
:root {
  --bg: #1A1A18;
  --bg-elev: #242422;
  --bg-elev-2: #2A2A28;
  --border: #333333;
  --text: #FFFFFF;
  --text-muted: #CCCCCC;
  --text-dim: #888888;
  --accent: #D4A017;
  --accent-2: #1B4F8A;
  --accent-soft: rgba(212, 160, 23, 0.12);
  --danger: #C0392B;
  --warning: #ffb547;
  --success: #2ecc71;
  --gradient: linear-gradient(135deg, #D4A017 0%, #B8880F 100%);
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg: #F5F2EA;
  --bg-elev: #FFFFFF;
  --bg-elev-2: #F5F2EA;
  --border: #E0D9CA;
  --text: #1A1A18;
  --text-muted: #555555;
  --text-dim: #888888;
  --accent-soft: rgba(212, 160, 23, 0.10);
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

/* =====================================================
   Layout
===================================================== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  padding: 12px 10px 4px;
  letter-spacing: -0.5px;
}
.logo-fit { color: #D4A017; }
.logo-col { color: #FFFFFF; }
[data-theme="light"] .logo-col { color: #1A1A18; }
.logo-tag {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 10px 14px;
  font-style: italic;
  letter-spacing: 0.2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: var(--transition);
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#theme-toggle {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}
#theme-toggle:hover { background: var(--bg-elev-2); color: var(--text); }

.content {
  padding: 28px 32px 60px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.view-header p {
  color: var(--text-muted);
  margin-top: 4px;
}

/* =====================================================
   Cards y elementos
===================================================== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: var(--transition);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.stat-card .unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
}
.stat-card .delta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.stat-card .delta.up { color: var(--success); }
.stat-card .delta.down { color: var(--danger); }
.stat-card.accent {
  background: var(--gradient);
  border: none;
  color: #1A1A18;
}
.stat-card.accent .label,
.stat-card.accent .delta { color: rgba(26, 26, 24, 0.75); }

/* =====================================================
   Forms
===================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  min-width: 0;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field input,
.field select,
.field textarea {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  width: 100%;
  min-width: 0;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.25);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--gradient);
  color: #1A1A18;
  border: none;
  font-weight: 700;
}
.btn-primary:hover {
  background: #B8880F;
  filter: none;
  color: #1A1A18;
}
.btn-danger {
  border-color: rgba(192, 57, 43, 0.4);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(192, 57, 43, 0.08); border-color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* Pills */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  padding: 8px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.pill:hover { color: var(--text); border-color: var(--accent); }
.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* =====================================================
   Macro bars
===================================================== */
.macro-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.macro-row .macro-label {
  width: 70px;
  font-size: 13px;
  color: var(--text-muted);
}
.macro-row .macro-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.macro-row .macro-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.macro-row .macro-fill.protein { background: linear-gradient(90deg, #D4A017, #1B4F8A); }
.macro-row .macro-fill.carbs   { background: linear-gradient(90deg, #ffb547, #ff8a47); }
.macro-row .macro-fill.fat     { background: linear-gradient(90deg, #C0392B, #8B1A1A); }
.macro-row .macro-value {
  width: 76px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
}

/* =====================================================
   Recipe cards
===================================================== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.recipe-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
}
.recipe-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.recipe-card .recipe-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.3;
}
.recipe-card .recipe-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}
.recipe-card .recipe-meta span strong { color: var(--text); font-weight: 600; }

.recipe-detail {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  font-size: 13px;
  display: none;
}
.recipe-card.open .recipe-detail { display: block; }
.recipe-detail h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
  margin-top: 8px;
}
.recipe-detail h4:first-child { margin-top: 0; }
.recipe-detail ul { padding-left: 18px; color: var(--text-muted); }

/* =====================================================
   Workout
===================================================== */
.workout-day {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.workout-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.workout-day-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.workout-day-header .muscle-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.muscle-tag {
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.exercise-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.exercise-row:last-child { border-bottom: none; }
.exercise-row .ex-name { font-weight: 500; }
.exercise-row .ex-equip {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.exercise-row .ex-meta {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}
.exercise-row .ex-meta strong {
  color: var(--text);
  font-weight: 600;
}

.rest-day {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* =====================================================
   Progreso
===================================================== */
.measurement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.measurement-grid .field { margin-bottom: 0; }

.weight-entry-list {
  max-height: 320px;
  overflow-y: auto;
}
.weight-entry {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.weight-entry .date { color: var(--text-muted); font-size: 12px; }
.weight-entry .weight-val { font-weight: 600; }
.weight-entry .delete-btn {
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 6px;
}
.weight-entry .delete-btn:hover { color: var(--danger); background: rgba(192, 57, 43, 0.08); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.photo-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.photo-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.photo-card .photo-info {
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.photo-card .photo-date {
  font-size: 12px;
  color: var(--text-muted);
}
.photo-card .delete-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: var(--transition);
}
.photo-card:hover .delete-photo { opacity: 1; }

.photo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.photo-upload:hover { border-color: var(--accent); color: var(--accent); }
.photo-upload input { display: none; }

/* =====================================================
   Charts
===================================================== */
.chart-container {
  position: relative;
  height: 280px;
}

/* =====================================================
   Empty state
===================================================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state h3 {
  color: var(--text);
  margin-bottom: 8px;
}

/* =====================================================
   Toast
===================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: 0.3s ease;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================
   Bottom nav (móvil)
===================================================== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: 8px;
}
.bottom-nav button.active { color: var(--accent); }
.bottom-nav svg { width: 20px; height: 20px; }

/* =====================================================
   Onboarding modal
===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 22px;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.modal p {
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* =====================================================
   Responsive
===================================================== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    display: none;
  }
  .content {
    padding: 18px 16px 90px;
  }
  .bottom-nav { display: flex; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .view-header h1 { font-size: 22px; }
  .stat-card .value { font-size: 22px; }
}

@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .exercise-row { grid-template-columns: 1fr; gap: 4px; }
  .exercise-row .ex-meta { text-align: left; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* =====================================================
   Tabs
===================================================== */
.tabbar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 18px;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.card-meta {
  color: var(--text-dim);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}
.card-select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

/* =====================================================
   Meal actions + diet log
===================================================== */
.meal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.btn-success-soft {
  background: rgba(46, 204, 113, 0.12);
  color: var(--success);
  border-color: rgba(46, 204, 113, 0.4);
  cursor: default;
}

.diet-log-list {
  display: flex;
  flex-direction: column;
}
.diet-log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.diet-log-row:last-child { border-bottom: none; }

/* =====================================================
   Workout set logging
===================================================== */
.exercise-log-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-elev-2);
}
.exercise-log-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.set-table {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}
.set-table-head, .set-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 2fr) minmax(0, 1.1fr) 38px;
  gap: 8px;
  align-items: center;
}
.set-table-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 0 6px;
}
.set-row {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  transition: var(--transition);
}
.set-row.done {
  background: rgba(212, 160, 23, 0.08);
  border-color: rgba(212, 160, 23, 0.4);
}
.set-num {
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
}
.set-weight {
  display: flex;
  gap: 4px;
  min-width: 0;
}
.set-weight .weight-input {
  flex: 1 1 0;
  min-width: 0;
}
.set-weight .unit-select {
  flex: 0 0 46px;
  width: 46px;
  padding: 7px 4px;
  font-size: 12px;
  text-align: center;
}
.set-row input,
.set-row select {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  min-width: 0;
  width: 100%;
}
.set-row input:focus,
.set-row select:focus { border-color: var(--accent); }
.set-row .reps-input { width: 100%; text-align: center; }
.set-check {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 700;
  transition: var(--transition);
}
.set-check:hover { color: var(--accent); border-color: var(--accent); }
.set-check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.add-set-btn { margin-top: 6px; }

.custom-routine-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.custom-routine-row.active { border-color: var(--accent); background: var(--accent-soft); }

/* =====================================================
   Chat
===================================================== */
.chat-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 280px);
  min-height: 420px;
  padding: 0;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--gradient);
  color: #1A1A18;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble.typing {
  color: var(--text-muted);
  font-style: italic;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  align-items: flex-end;
}
.chat-input-bar textarea {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  resize: none;
  max-height: 140px;
  outline: none;
  font-family: inherit;
}
.chat-input-bar textarea:focus { border-color: var(--accent); }

@media (max-width: 900px) {
  .chat-card { height: calc(100vh - 220px); }
  .set-table-head, .set-row { grid-template-columns: 30px minmax(0, 2fr) minmax(0, 1.1fr) 36px; gap: 6px; }
  .set-weight .unit-select { flex-basis: 42px; width: 42px; padding: 7px 2px; }
  .set-check { width: 34px; height: 34px; }
}
@media (max-width: 480px) {
  .set-table-head, .set-row { grid-template-columns: 26px minmax(0, 2fr) minmax(0, 1.05fr) 32px; gap: 5px; font-size: 12px; }
  .set-table-head { font-size: 10px; padding: 0 2px; }
  .set-weight { gap: 3px; }
  .set-weight .unit-select { flex-basis: 38px; width: 38px; }
  .set-row input, .set-row select { padding: 6px 4px; font-size: 12px; }
  .set-check { width: 30px; height: 30px; font-size: 14px; }
  .meal-actions .btn { font-size: 11px; padding: 6px 10px; }
}

/* =====================================================
   Pantalla de Login
===================================================== */
.auth-root {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, rgba(212,160,23,0.08), transparent 60%), var(--bg);
  padding: 20px;
  z-index: 500;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
}
.auth-logo {
  font-size: 30px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.auth-tag {
  text-align: center;
  color: var(--text-muted);
  margin: 4px 0 24px;
  font-size: 14px;
}
.auth-banner {
  background: rgba(255,181,71,0.12);
  border: 1px solid var(--warning);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.auth-banner code { background: var(--bg-elev-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: white;
  color: #1a2030;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid #dadce0;
  cursor: pointer;
  transition: var(--transition);
}
.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--text-dim);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 12px;
  margin-bottom: 4px;
}
.auth-form input {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.25); }
.auth-form button { margin-top: 18px; }
.auth-form .btn-primary {
  width: 100%;
  background: var(--gradient);
  color: #1A1A18;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.auth-toggle {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-toggle a {
  margin-left: 6px;
  color: var(--accent);
  font-weight: 600;
}
.auth-error {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 14px;
}
.auth-success {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 14px;
}

/* User badge en sidebar */
.user-badge {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-elev-2);
  font-size: 12px;
  color: var(--text-muted);
}
.user-badge:empty { display: none; }
.user-badge .user-email {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

/* =====================================================
   Foto: cámara o galería
===================================================== */
.foto-opciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.foto-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}
.foto-preview img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.photo-upload-actions {
  cursor: default;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Modal weight details */
.wm-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}
.wm-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  user-select: none;
}
.wm-details[open] summary { color: var(--accent); margin-bottom: 12px; }

/* =====================================================
   Buscador comidas
===================================================== */
.food-result-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.food-portion-row {
  display: grid;
  grid-template-columns: auto 90px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.food-portion-row label { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.food-portion-row input {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.fs-calc { color: var(--text); font-size: 12px; }

/* Excel drop zone */
.xls-drop {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.xls-drop:hover, .xls-drop.dragging { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* =====================================================
   Fixes responsive — Entreno + Progreso
===================================================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}
.table-responsive table {
  min-width: 500px;
  width: 100%;
  border-collapse: collapse;
}
.chart-container { position: relative; width: 100%; max-width: 100%; height: 280px; overflow: hidden; }
.chart-container canvas { display: block; max-width: 100% !important; }

/* Evita scroll horizontal / necesidad de zoom-out en móvil */
html, body { max-width: 100%; overflow-x: hidden; }
.app { max-width: 100%; }
.content { min-width: 0; }
img, canvas, video, svg { max-width: 100%; }
.recipe-name, .diet-log-row, .card-title, .exercise-log-block, .workout-day-header h3 { overflow-wrap: anywhere; word-break: break-word; }
.nav-item, .bottom-nav button, .tab, .pill, .btn { touch-action: manipulation; }

@media (max-width: 480px) {
  .content { padding: 14px 10px 90px; }
  .chart-container { height: 220px; }
  .view-header h1 { font-size: 20px; }
  .view-header p { font-size: 13px; }
  .grid-2, .grid-3, .grid-4 { display: flex; flex-direction: column; gap: 12px; }
  .stat-card .value { font-size: 22px; }
  .workout-day { padding: 14px 10px; }
  .workout-day-header { flex-wrap: wrap; gap: 8px; }
  .exercise-log-block { padding: 10px 8px; }
  .food-portion-row { grid-template-columns: 1fr; }
  .food-portion-row input { width: 100%; }
  .auth-card { padding: 24px 18px; }
  .modal { padding: 20px 16px; max-height: 92vh; }
  .modal h2 { font-size: 19px; }
  .field-row { gap: 10px; }
}

/* =====================================================
   Gamification — Racha, Niveles y Logros
===================================================== */

/* Streak badge en el sidebar */
.streak-badge {
  background: #1A1A18;
  border: 1px solid #D4A017;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-align: center;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.streak-badge:empty { display: none; }

.streak-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.streak-condor { font-size: 20px; line-height: 1; }

.streak-num {
  font-size: 26px;
  font-weight: 800;
  color: #D4A017;
  line-height: 1;
}

.streak-msg {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
}

/* Bump animation al incrementar racha */
@keyframes gami-bump {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.bump { animation: gami-bump 0.5s ease; }

/* Bottom-nav streak button */
.bottom-streak-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
}

#streak-count-mobile {
  font-size: 11px;
  font-weight: 700;
  color: #D4A017;
}

/* Unlock toast — notificación de logro desbloqueado */
.gami-unlock-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1A1A18;
  border: 2px solid #D4A017;
  border-radius: 14px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  box-shadow: 0 8px 32px rgba(212,160,23,0.28);
  font-size: 13px;
  min-width: 220px;
  max-width: 340px;
  pointer-events: none;
}
.gami-unlock-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.gami-unlock-icon { font-size: 32px; flex-shrink: 0; }
.gami-unlock-name { color: #D4A017; font-weight: 600; font-size: 13px; }

/* Level card */
.gami-level-card {
  background: linear-gradient(135deg, #1A1A18 0%, #2A2A28 100%);
  border-color: #D4A017 !important;
}
.gami-level-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.gami-level-badge {
  background: #D4A017;
  color: #1A1A18;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 20px;
  flex-shrink: 0;
}
.gami-level-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.gami-streak-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.gami-streak-hero-num {
  font-size: 38px;
  font-weight: 800;
  color: #D4A017;
  line-height: 1;
}
.gami-streak-hero-lbl {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.gami-streak-msg {
  color: #D4A017;
  font-weight: 600;
  font-size: 13px;
  margin-top: 10px;
}
.gami-level-progress { margin-top: 16px; }
.gami-level-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.gami-progress-bar {
  background: var(--border);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}
.gami-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #D4A017, #f0c040);
  border-radius: 6px;
  transition: width 0.6s ease;
}
.gami-level-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 5px;
}
.gami-max-level {
  color: #D4A017;
  font-weight: 700;
  font-size: 15px;
  margin-top: 14px;
  text-align: center;
}

/* Achievement cards grid */
.gami-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.gami-card {
  background: #1A1A18;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 10px 14px;
  text-align: center;
  position: relative;
  transition: 0.2s ease;
}
.gami-card.unlocked {
  border-color: #D4A017;
  box-shadow: 0 0 0 1px rgba(212,160,23,0.18);
}
.gami-card.locked {
  filter: grayscale(0.8);
  opacity: 0.5;
}
.gami-card-icon {
  font-size: 30px;
  margin-bottom: 8px;
  position: relative;
  display: inline-block;
  line-height: 1;
}
.gami-lock {
  position: absolute;
  bottom: -4px;
  right: -10px;
  font-size: 13px;
}
.gami-card-name {
  font-weight: 700;
  font-size: 11px;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}
.gami-card-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}
.gami-card-date {
  font-size: 9px;
  color: #D4A017;
  margin-top: 6px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .gami-grid { grid-template-columns: repeat(3, 1fr); }
  .gami-streak-hero-num { font-size: 30px; }
}
@media (max-width: 480px) {
  .gami-grid { grid-template-columns: repeat(2, 1fr); }
  .gami-level-top { gap: 10px; }
  .gami-level-name { font-size: 15px; }
}

