:root {
  --bg: #0b1220;
  --bg2: #111827;
  --card: #1e293b;
  --card2: #243044;
  --border: rgba(148, 163, 184, 0.18);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary2: #3b82f6;
  --primary-soft: rgba(37, 99, 235, 0.18);
  --accent: #38bdf8;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", var(--font);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  margin: 0;
  padding: 0;
  background: var(--bg);
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
}
body {
  margin: 0;
  padding: 0;
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: visible;
  overflow-x: hidden;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.25), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(56, 189, 248, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(64px + var(--safe-t));
  padding-bottom: calc(72px + var(--safe-b));
}

.topbar {
  position: fixed;
  top: 0;
  left: max(0px, calc(50% - 240px));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(480px, 100%);
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: #0b1220;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  overflow: visible;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
  flex-shrink: 0;
  aspect-ratio: 1;
}
.brand-logo {
  width: 44px;
  height: 44px;
  display: block;
  object-fit: contain;
  object-position: center;
}
.brand-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.015em;
  display: block;
  line-height: 1.2;
  color: #ffffff;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.brand-tld {
  font-weight: 700;
  font-size: 0.9em;
  color: #7dd3fc;
  letter-spacing: 0;
  margin-left: 1px;
  opacity: 1;
}
.brand-sub {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
  display: block;
  font-weight: 500;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: #f1f5f9;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.96); }
.brand > div {
  min-width: 0;
  overflow: hidden;
}
.nav-svg {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.nav-svg svg { display: block; }

.main { padding: 20px 16px; display: flex; flex-direction: column; gap: 22px; }

.hero-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 26px 16px 26px;
  border-radius: 22px;
  background: linear-gradient(145deg, #1e3a8a, #2563eb 55%, #38bdf8);
  box-shadow: 0 18px 44px rgba(37, 99, 235, 0.38);
  min-height: 160px;
  align-items: center;
}
.hero-stat {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 4px;
}
.hero-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.hero-icon svg { display: block; opacity: 0.95; width: 24px; height: 24px; }
.hero-num {
  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  min-height: 1.35em;
  padding: 4px 0;
}
.hero-label {
  font-size: 0.7rem;
  opacity: 0.95;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,0.95);
}


.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px 18px 24px;
}
.panel-title {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head .panel-title { margin: 0; }
.filter-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input.readonly {
  opacity: 0.85;
  color: var(--accent);
  font-weight: 600;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-box {
  position: relative;
  border-radius: 14px;
  border: 1.5px dashed var(--border);
  background: var(--bg2);
  min-height: 140px;
  overflow: hidden;
}
.photo-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.photo-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  pointer-events: none;
  padding: 12px;
  text-align: center;
}
.photo-placeholder span { font-size: 1.8rem; }
.photo-pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  pointer-events: auto;
  margin-top: 4px;
}
.photo-pick-btn {
  pointer-events: auto;
  z-index: 3;
  position: relative;
}
#photoPreview {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.photo-clear {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  transition: transform 0.12s, filter 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary2), var(--primary));
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}
.btn-block { width: 100%; margin-top: 4px; }
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 0.8rem;
  padding: 6px 10px;
}

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
}
.history-item.has-photo { cursor: pointer; }
.history-thumb {
  width: 64px; height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--card2);
}
.history-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--muted);
}
.history-body h3 {
  margin: 0 0 2px;
  font-size: 0.98rem;
  font-weight: 700;
}
.history-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}
.history-mark {
  font-family: var(--display);
  font-weight: 800;
  color: var(--accent);
  font-size: 0.95rem;
  text-align: right;
}
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #93c5fd;
  margin-right: 4px;
}
.badge.pr {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 1.5rem 0.5rem;
  margin: 0;
}
.empty[hidden], [hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
.modal[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.bottom-nav {
  position: fixed;
  left: max(0px, calc(50% - 240px));
  bottom: 0;
  z-index: 60;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: #0f172a;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 1.15rem;
}
.nav-item small { font-size: 0.68rem; font-weight: 600; }
.nav-item.active {
  color: #fff;
  background: var(--primary-soft);
}
.nav-add {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.modal.is-open {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
}
.modal-card {
  width: min(480px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px 20px 16px 16px;
  padding: 20px 18px 24px;
  border: 1px solid var(--border);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg2);
  font-size: 1.3rem;
}
.modal-card h2 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: 1.2rem;
}
.stats-body { display: flex; flex-direction: column; gap: 10px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.stat-row strong { color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: #1e3a8a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 200;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 481px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* —— ApuntaTuMarca: privacidad y branding —— */
.privacy-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
}
.privacy-banner p { margin: 0 0 6px; }
.privacy-banner p:last-child { margin-bottom: 0; }
.privacy-banner strong { color: var(--accent); }
.privacy-banner-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.home-footer-note {
  text-align: center;
  padding: 8px 4px 20px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.home-footer-note p { margin: 0 0 6px; }
.app-version {
  font-size: 0.72rem;
  opacity: 0.85;
}

.info-body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}
.info-body p { margin: 0 0 12px; }
.info-body ul {
  margin: 0 0 12px;
  padding-left: 1.2em;
}
.info-body li { margin-bottom: 6px; }
.info-body .tiny {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 16px;
}

/* —— Wider desktop —— */
@media (min-width: 768px) {
  .app {
    max-width: 720px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .brand-name { font-size: 1.45rem; letter-spacing: -0.015em; }
  .brand-tld { font-size: 0.82em; color: #38bdf8; }
  .main { padding: 20px 24px; gap: 20px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .hero-card { padding: 20px 16px 22px; }
  .hero-num { font-size: 1.85rem; }
  .hero-icon { width: 42px; height: 42px; border-radius: 12px; }
  .panel { padding: 20px; }
  .field-row { grid-template-columns: 1fr 1fr; gap: 14px; }
  .bottom-nav, .topbar {
    max-width: 720px;
    width: min(720px, 100%);
    left: max(0px, calc(50% - 360px));
  }
  .app { max-width: 720px; padding-top: calc(68px + var(--safe-t)); }
  .history-list { gap: 12px; }
}
@media (min-width: 1024px) {
  .app { max-width: 860px; }
  .bottom-nav, .topbar {
    max-width: 860px;
    width: min(860px, 100%);
    left: max(0px, calc(50% - 430px));
  }
  .app { max-width: 860px; }
  .main { padding: 24px 28px; }
}

/* —— Links —— */
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.link-btn.inline { display: inline; }

/* —— Share modal —— */
.share-card { max-width: 420px; }
.share-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-right: 36px;
}
.share-brand h2 {
  margin: 0;
  font-size: 1.15rem;
}
.share-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}
.share-url {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}
.share-intro {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.5;
}
.share-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  min-height: 76px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}
.share-btn:hover, .share-btn:active {
  border-color: var(--primary2);
  transform: translateY(-2px);
  background: #243044;
}
.share-btn-primary {
  background: linear-gradient(145deg, #1e3a8a, #2563eb);
  border-color: transparent;
  color: #fff;
}
.share-btn-primary:hover, .share-btn-primary:active {
  background: linear-gradient(145deg, #1d4ed8, #3b82f6);
  border-color: transparent;
}
.share-wa:hover, .share-wa:active { border-color: #25d366; }
.share-tg:hover, .share-tg:active { border-color: #2AABEE; }
.share-btn-icon { font-size: 1.45rem; line-height: 1; }
.share-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* —— Legal / privacy —— */
.legal-card {
  max-width: 520px;
  max-height: min(85vh, 640px);
  overflow-y: auto;
}
.legal-body {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}
.legal-body p { margin: 0 0 12px; }
.legal-date {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 16px !important;
}

/* —— Exit modal —— */
.exit-card { max-width: 400px; text-align: center; }
.exit-hero { margin-bottom: 8px; }
.exit-emoji { font-size: 2.4rem; margin-bottom: 8px; }
.exit-card h2 { margin: 0 0 8px; }
.exit-lead {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0 0 4px;
  line-height: 1.45;
}
.exit-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.btn-secondary {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}
.btn-secondary:active { transform: scale(0.98); }
.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  margin-top: 4px;
  text-decoration: underline;
  padding: 8px;
}
.btn-sm { padding: 10px 16px; font-size: 0.9rem; }

/* —— Cookie banner —— */
.cookie-banner {
  position: fixed;
  bottom: calc(72px + var(--safe-b));
  left: 10px;
  right: 10px;
  background: #0f172a;
  color: #e2e8f0;
  z-index: 300;
  padding: 14px;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  border: 1px solid var(--border);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  animation: cookieIn 0.3s ease;
}
@media (min-width: 768px) {
  .cookie-banner { max-width: 560px; bottom: 24px; }
}
@media (min-width: 1024px) {
  .cookie-banner { max-width: 640px; }
}
@keyframes cookieIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.cookie-content p {
  font-size: 0.84rem;
  line-height: 1.45;
  margin: 0 0 12px;
}
.cookie-content .link-btn { color: #7dd3fc; }
.cookie-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.cookie-actions .btn-primary {
  background: #fff;
  color: #0f172a;
}
.cookie-actions .btn-secondary {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.45);
  color: #fff;
}

/* Modal card base tweaks when stacked */
.modal-card.share-card,
.modal-card.exit-card,
.modal-card.legal-card {
  width: min(100% - 24px, 520px);
}


/* —— Mobile: nombre en una línea, botones en otra (sin solaparse) —— */
@media (max-width: 640px) {
  .topbar, .bottom-nav, .app {
    max-width: 100%;
    left: 0;
    width: 100%;
  }
  .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    padding: calc(10px + var(--safe-t)) 12px 10px;
  }
  .brand {
    gap: 8px;
    min-width: 0;
    flex: 0 0 auto;
    width: 100%;
    overflow: visible;
  }
  .brand > div {
    min-width: 0;
    overflow: visible;
  }
  .brand-sub {
    display: none;
  }
  .brand-mark, .brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .brand-name {
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: visible;
  }
  .brand-tld {
    display: inline;
    font-size: 0.86em;
    font-weight: 700;
    color: #38bdf8;
  }

  .topbar-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
    width: 100%;
    gap: 6px;
    flex-shrink: 0;
  }
  .topbar-actions .icon-btn[hidden] {
    display: none !important;
  }
  .icon-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 11px;
    background: #1e293b;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #f8fafc;
  }
  .icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: #f8fafc !important;
  }

  /* cabecera más alta: logo+nombre + fila de botones */
  .app {
    padding-top: calc(98px + var(--safe-t));
  }
}
@media (max-width: 360px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 0.95rem; letter-spacing: -0.03em; }
  .brand-tld { font-size: 0.82em; }
  .icon-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
  .icon-btn svg { width: 16px; height: 16px; }
  .app {
    padding-top: calc(94px + var(--safe-t));
  }
}


/* —— Editar / compartir / foto / suplementos —— */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.supplement-field { gap: 10px; }
.supplement-detail {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  outline: none;
}
.supplement-detail:focus {
  border-color: var(--primary2);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.badge.supp {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.history-thumb-btn {
  padding: 0;
  border: none;
  background: none;
  border-radius: 12px;
  overflow: hidden;
  cursor: zoom-in;
  flex-shrink: 0;
}
.history-thumb-btn .history-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
}
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.btn-sm-action {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-sm-action:active { transform: scale(0.97); }
.btn-danger.btn-sm-action {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.history-mark-wrap {
  text-align: right;
  flex-shrink: 0;
}
.history-item {
  align-items: flex-start;
}

/* Lightbox */
#photoLightbox {
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  padding: 16px;
  z-index: 250;
}
.lightbox-card {
  position: relative;
  max-width: min(960px, 100%);
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-card img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-card .modal-close {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  background: #0f172a;
  border: 1px solid var(--border);
  color: #fff;
}
#formCancelEdit {
  margin-top: 8px;
}

/* —— Programas / biblioteca / medidas —— */
.panel-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: -6px 0 12px;
  line-height: 1.4;
}
.ex-name-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ex-name-row input { flex: 1; }
.library-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  margin-bottom: 12px;
  color: var(--text);
}
.library-list { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; }
.lib-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}
.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 4px;
  cursor: pointer;
}
.library-item:active { border-color: var(--primary2); }
.lib-del {
  color: #fca5a5;
  font-size: 1.1rem;
  padding: 0 6px;
  cursor: pointer;
}
.programs-list, .measures-list { display: flex; flex-direction: column; gap: 10px; }
.program-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.program-card h3 { margin: 0 0 4px; font-size: 1rem; }
.program-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.prog-ex-list { display: flex; flex-direction: column; gap: 8px; }
.prog-ex-row {
  display: grid;
  grid-template-columns: 1fr 90px 36px;
  gap: 6px;
  align-items: center;
}
.prog-ex-row input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  width: 100%;
}
.measure-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.bottom-nav .nav-item small { font-size: 0.62rem; }
@media (max-width: 380px) {
  .bottom-nav .nav-item { padding: 6px 2px; }
  .bottom-nav .nav-item small { font-size: 0.58rem; }
}

/* —— Consejos del coach —— */
.coach-tips-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.tip-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.tip-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.tip-card h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
  font-family: var(--display);
}
.tip-body {
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}
@media (max-width: 420px) {
  .bottom-nav .nav-item small { font-size: 0.55rem; }
  .bottom-nav .nav-item { padding: 6px 1px; font-size: 1rem; }
}

/* —— Plan / metas / logros —— */
.hub-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sub-title {
  font-family: var(--display);
  font-size: 0.95rem;
  margin: 18px 0 10px;
  color: var(--text);
}
.plan-days { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.plan-day-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
}
.plan-day-row select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
}
.goals-list, .achievements-list { display: flex; flex-direction: column; gap: 10px; }
.goal-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.goal-card.goal-done { border-color: rgba(34, 197, 94, 0.4); }
.goal-bar {
  height: 8px;
  background: var(--card);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.goal-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #22c55e);
  border-radius: 999px;
}
.ach-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.ach-card.ach-off { opacity: 0.55; }
.ach-card.ach-on { border-color: rgba(250, 204, 21, 0.35); }
.ach-icon { font-size: 1.4rem; line-height: 1; }

/* —— Dashboard —— */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
@media (max-width: 480px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}
.dash-kpi {
  background: linear-gradient(145deg, #1e3a8a, #2563eb);
  border-radius: 18px;
  padding: 22px 12px;
  text-align: center;
  color: #fff;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
}
.dash-kpi-num {
  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  font-size: 1.85rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
}
.dash-kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.92;
}
.dash-metrics { display: flex; flex-direction: column; gap: 8px; }
.dash-bars { display: flex; flex-direction: column; gap: 8px; }
.dash-bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 28%) 1fr 28px;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}
.dash-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.dash-bar-track {
  height: 8px;
  background: var(--bg2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.dash-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
}
.dash-bar-val { text-align: right; font-weight: 700; color: var(--accent); }
.dash-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-items: end;
  min-height: 100px;
}
.dash-week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--muted);
}
.dash-week-day strong { color: var(--text); font-size: 0.75rem; }
.dash-week-bar-wrap {
  width: 100%;
  height: 64px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.dash-week-bar {
  width: 70%;
  min-height: 4px;
  background: linear-gradient(180deg, var(--accent), var(--primary));
  border-radius: 6px 6px 2px 2px;
}

/* —— Clases del gym + temporizador —— */
.class-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.class-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.class-card h3 { margin: 0; font-size: 1rem; }
.class-time {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.class-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.timer-box {
  text-align: center;
  padding: 20px 12px;
  background: var(--bg2);
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.timer-display {
  font-family: var(--font);
  font-weight: 800;
  font-size: 3rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: #fff;
}
.timer-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}
.timer-presets button {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
}
.timer-presets button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.timer-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.note-day {
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  resize: vertical;
}

.next-class-card {
  background: linear-gradient(135deg, rgba(37,99,235,0.2), rgba(56,189,248,0.1));
  border: 1px solid rgba(56,189,248,0.35);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.next-class-card h3 { margin: 0; font-size: 1.05rem; }
.next-class-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quote-card {
  text-align: center;
  padding: 18px 16px;
  border-radius: 16px;
  background: var(--bg2);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  font-style: italic;
}
.quote-card strong {
  display: block;
  margin-top: 8px;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}


/* ---- Comparación con registros anteriores ---- */
.compare-card {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.cmp-head, .cmp-title, .cmp-new { margin: 0; font-size: 0.9rem; color: var(--text); }
.cmp-new { color: var(--muted); }
.cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp-cell {
  background: var(--bg2);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  min-width: 0;
}
.cmp-cell small { color: var(--muted); font-size: 0.72rem; }
.cmp-cell strong { font-family: var(--display); color: var(--accent); font-size: 1.05rem; overflow-wrap: anywhere; }
.cmp-cell span { color: var(--muted); font-size: 0.78rem; }
.cmp-goal { margin: 0; font-size: 0.85rem; color: var(--muted); }
.cmp-goal strong { color: var(--text); }
.cmp-live { margin: 0; font-size: 0.9rem; font-weight: 700; }
.cmp-live span { font-weight: 500; color: var(--muted); }
.cmp-live.better { color: #86efac; }
.cmp-live.worse { color: #fcd34d; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cmp-chip {
  font: inherit; font-size: 0.85rem; cursor: pointer;
  color: var(--text); background: var(--bg2);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
}
.cmp-fill { justify-self: start; }
.badge.delta.better { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge.delta.worse { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
