/* ============================================================
   PixelFood — Nordic Elegance (light)
   Paleta: marfil, verde bosque, dorado sutil
   ============================================================ */
:root {
  --bg: #f7f5f1;
  --bg-grad: radial-gradient(1200px 600px at 85% -10%, #eef3ec 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 110%, #f3efe6 0%, transparent 55%);
  --card: #ffffff;
  --card2: #f3f1ec;
  --text: #2b2a26;
  --text-soft: #6f6c63;
  --sub: #9a968b;
  --accent: #44634f;
  --accent-strong: #2f4a3a;
  --accent-soft: #e6ede7;
  --gold: #b99a6b;
  --bad: #b25c52;
  --line: #e9e6df;
  --shadow: 0 1px 2px rgba(47, 43, 35, .05), 0 8px 24px rgba(47, 43, 35, .06);
  --shadow-sm: 0 1px 2px rgba(47, 43, 35, .05), 0 3px 10px rgba(47, 43, 35, .05);
  --radius: 20px;
  --radius-sm: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 32px;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .1px;
}

/* ---------- Header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 20px 12px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 24px; font-weight: 800; letter-spacing: -.3px;
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px;
  box-shadow: 0 4px 10px rgba(47, 74, 58, .25);
}
.logo span { color: var(--accent-strong); }
.badge {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 11px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; padding: 10px 16px 4px;
  position: sticky; top: 0;
  background: rgba(247, 245, 241, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
  border-bottom: 1px solid rgba(233, 230, 223, .8);
}
.tab {
  flex: 1; background: transparent; color: var(--sub);
  border: none; padding: 12px 0 10px; border-radius: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
  position: relative;
}
.tab::after {
  content: ""; position: absolute; left: 50%; bottom: 2px;
  width: 0; height: 2.5px; border-radius: 2px;
  background: var(--accent); transform: translateX(-50%);
  transition: width .2s ease;
}
.tab.active { color: var(--accent-strong); }
.tab.active::after { width: 28px; }

/* ---------- Views ---------- */
.view { display: none; padding: 6px 16px; animation: fadeUp .25s ease; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.hint { color: var(--text-soft); font-size: 13px; line-height: 1.6; }
.hint b { color: var(--text); }

/* ---------- Form controls ---------- */
.row { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row label { color: var(--sub); font-size: 12.5px; font-weight: 500; }
select, input[type="text"], input[type="datetime-local"], textarea {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px; font-size: 15px;
  flex: 1; min-width: 120px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(68, 99, 79, .12);
}
textarea { width: 100%; resize: vertical; min-height: 76px; margin-top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: block; width: 100%; text-align: center;
  border: none; border-radius: 999px; padding: 15px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff; margin-top: 14px;
  box-shadow: 0 6px 16px rgba(47, 74, 58, .28);
}
.btn-primary:active { box-shadow: 0 3px 8px rgba(47, 74, 58, .3); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-option {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  margin-top: 10px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.btn-option:hover { border-color: var(--gold); }
.btn-option:active { background: var(--card2); }
.btn-option .opt-icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

/* Divider "o" */
.or {
  display: flex; align-items: center; gap: 12px;
  text-align: center; color: var(--sub); font-size: 11.5px;
  margin: 16px 0 4px; letter-spacing: 1px; text-transform: uppercase; font-weight: 500;
}
.or::before, .or::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ---------- Preview ---------- */
.preview-wrap { margin-top: 14px; }
.preview-wrap img {
  width: 100%; border-radius: var(--radius-sm);
  display: block; box-shadow: var(--shadow);
}
.status { margin-top: 12px; font-size: 14px; color: var(--text-soft); text-align: center; min-height: 20px; }

/* ---------- Stats ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 12px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-card .num { font-size: 21px; font-weight: 700; color: var(--accent-strong); letter-spacing: -.3px; }
.stat-card .lbl { font-size: 11px; color: var(--sub); margin-top: 5px; letter-spacing: .3px; }
.chart-title { font-size: 12.5px; color: var(--sub); margin-bottom: 10px; font-weight: 500; }
#chart { width: 100%; height: 250px; }

.macros { display: flex; flex-direction: column; gap: 10px; }
.macro { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-soft); }
.macro b { margin-left: auto; color: var(--text); font-weight: 600; }
.m-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Historial ---------- */
.hist-list { list-style: none; margin-top: 12px; }
.hist-list li {
  display: flex; align-items: center; gap: 13px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px; margin-bottom: 9px; cursor: pointer;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.hist-list li:active { transform: scale(.985); background: var(--card2); }
.h-icon { font-size: 19px; }
.h-body { flex: 1; min-width: 0; }
.h-title { font-size: 13px; font-weight: 600; }
.h-sub { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-kcal { font-size: 16px; font-weight: 700; color: var(--accent-strong); text-align: right; }
.h-kcal small { font-size: 10px; color: var(--sub); font-weight: 400; }
.empty { color: var(--sub); text-align: center; padding: 28px 0; display: block !important; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(43, 40, 35, .4);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
  backdrop-filter: blur(4px);
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card); width: 100%; max-width: 540px;
  border-radius: 24px 24px 0 0; padding: 22px 18px 28px;
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.modal-title span { color: var(--sub); font-weight: 500; font-size: 13px; }
.edit-photo { width: 100%; border-radius: var(--radius-sm); max-height: 220px; object-fit: cover; margin-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; color: var(--sub); font-size: 12px; font-weight: 500; }
.field input {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 12px; font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(68, 99, 79, .12); }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .btn { flex: 1; margin-top: 0; }
.btn-del { background: #f4e8e6; color: var(--bad); }
.btn-ghost { background: var(--card2); color: var(--text-soft); }

/* ---------- Login ---------- */
#view-login input[type="text"], #view-login input[type="password"] {
  width: 100%; background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-size: 15px; outline: none; margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s;
}
#view-login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(68, 99, 79, .12); }
.login-sub { color: var(--sub); font-size: 13px; text-align: center; margin-bottom: 16px; }

/* ---------- Garmin ---------- */
.garmin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.garmin-sub { color: var(--sub); font-size: 11px; font-weight: 400; }

/* ---------- Dashboard Garmin ---------- */
.gchart { width: 100%; height: 260px; }
.g-kpi { border-color: var(--line); }
.g-kpi .num { font-size: 20px; }
.g-kpi .lbl { text-transform: uppercase; letter-spacing: .5px; }
.g-c1 .num { color: #ff5c39; }
.g-c2 .num { color: #38bdf8; }
.g-c3 .num { color: #34d399; }
.g-c4 .num { color: #fbbf24; }
.g-c5 .num { color: #a78bfa; }
.g-c6 .num { color: #f87171; }
#g-tabla { overflow-x: auto; }
#g-tabla table { min-width: 480px; }
#g-tabla th { font-size: 9px; }
#g-tabla td { font-size: 11px; }

/* ---------- Calendario historial ---------- */
.cal-wrap { margin-top: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 14px; font-weight: 700; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  background: var(--card2); border: 1px solid var(--line); border-radius: 9px;
  text-align: center; padding: 9px 0; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.cal-dow { background: transparent; border: none; color: var(--sub); font-size: 10px; font-weight: 700; cursor: default; text-transform: uppercase; padding: 4px 0; }
.cal-cell.cal-empty { background: transparent; border: none; cursor: default; }
.cal-cell.cal-has { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
.cal-cell.cal-today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.cal-cell.cal-sel { background: var(--accent); color: #fff; }
.cal-day-info { margin-top: 12px; }
.cal-day-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; text-transform: capitalize; }
.cal-day-empty { color: var(--sub); font-size: 13px; text-align: center; padding: 12px 0; }
.cal-day-info .hist-list { margin: 0; }

/* ---------- Consejo motivacional ---------- */
.tip-card {
  display: flex; align-items: center; gap: 14px;
  border-left: 4px solid var(--accent);
}
.tip-emoji { font-size: 30px; flex: 0 0 auto; }
.tip-text { font-size: 13.5px; line-height: 1.45; color: var(--text); }
.tip-ok { border-left-color: var(--accent); background: linear-gradient(135deg, #f0f6f1, #ffffff); }
.tip-warn { border-left-color: var(--gold); background: linear-gradient(135deg, #faf5ea, #ffffff); }
.tip-bad { border-left-color: var(--bad); background: linear-gradient(135deg, #faf0ee, #ffffff); }


/* ---------- Logo Pixel (robot) ---------- */
.logo-img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; vertical-align: middle; }
#view-login .logo-img { width: 64px; height: 64px; border-radius: 16px; }
