/* ── RESET & BASE ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:      #1B2A4A;
  --navy-dark: #0f1e36;
  --gold:      #C9A84C;
  --gold-lt:   #f5e6c8;
  --white:     #ffffff;
  --gray-50:   #f8f9fa;
  --gray-100:  #f1f3f5;
  --gray-200:  #e9ecef;
  --gray-400:  #ced4da;
  --gray-600:  #868e96;
  --gray-800:  #343a40;
  --green:     #2D6A4F;
  --green-lt:  #d8f3dc;
  --red:       #c0392b;
  --red-lt:    #fdecea;
  --orange:    #e67e22;
  --orange-lt: #fdebd0;
  --blue:      #1A5276;
  --blue-lt:   #d6eaf8;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 2px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.15);
  --transition: all .2s ease;
  --nav-height: 64px;
  --header-height: 60px;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── TYPOGRAPHY ──────────────────────────── */
h1, h2, h3 { font-weight: 700; line-height: 1.2; }
p { line-height: 1.5; }
a { color: var(--navy); text-decoration: none; }

/* ── HEADER ──────────────────────────────── */
.app-header {
  background: var(--navy);
  color: var(--white);
  padding: 16px 20px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-title { font-size: 1.15rem; color: var(--gold); }
.header-sub   { font-size: .8rem; color: rgba(255,255,255,.7); margin-top: 2px; }

/* ── BOTTOM NAV ──────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--navy);
  display: flex;
  border-top: 2px solid var(--gold);
  z-index: 200;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.5);
  gap: 2px;
  transition: var(--transition);
  padding: 4px 0;
}
.nav-item.active { color: var(--gold); }
.nav-item:active { background: rgba(255,255,255,.05); }
.nav-icon  { font-size: 1.3rem; line-height: 1; }
.nav-label { font-size: .65rem; font-weight: 600; letter-spacing: .02em; }
.nav-spacer { height: var(--nav-height); }

/* ── MAIN CONTAINER ──────────────────────── */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

/* ── CARDS ───────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}
.card-header {
  background: var(--navy);
  color: var(--gold);
  padding: 12px 16px;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header .badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: .7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
}
.card-body { padding: 14px 16px; }

/* ── CHECKLIST ───────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: var(--transition);
  -webkit-user-select: none;
  user-select: none;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item:active { background: var(--gray-50); }
.checklist-item.done { opacity: .6; }
.checklist-item.done .item-label { text-decoration: line-through; color: var(--gray-600); }

.check-box {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--gray-400);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  font-size: 1rem;
}
.checklist-item.done .check-box {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.item-info { flex: 1; min-width: 0; }
.item-label { font-size: .9rem; font-weight: 500; }
.item-time  { font-size: .75rem; color: var(--gray-600); margin-top: 1px; }

/* ── PROGRESS RING ───────────────────────── */
.progress-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0 8px;
}
.progress-ring { transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: var(--gray-200); }
.ring-bar { fill: none; stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring-label {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy);
  margin-top: -4px;
}
.ring-sub { font-size: .8rem; color: var(--gray-600); }

/* ── FORMS ───────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--white);
  color: var(--gray-800);
  transition: border-color .2s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--navy);
}
select.form-control { cursor: pointer; }

/* ── BUTTONS ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  letter-spacing: .01em;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--navy);  color: var(--gold); }
.btn-gold     { background: var(--gold);  color: var(--navy); }
.btn-green    { background: var(--green); color: white; }
.btn-danger   { background: var(--red);   color: white; }
.btn-outline  { background: transparent; border: 2px solid var(--navy); color: var(--navy); }
.btn-sm       { padding: 8px 14px; font-size: .82rem; width: auto; }

/* ── LOGIN PAGE ──────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--navy);
}
.login-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}
.login-title {
  color: var(--gold);
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.login-sub {
  color: rgba(255,255,255,.6);
  font-size: .85rem;
  margin-bottom: 32px;
  text-align: center;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-switch {
  text-align: center;
  margin-top: 16px;
  color: rgba(255,255,255,.7);
  font-size: .85rem;
}
.login-switch a { color: var(--gold); font-weight: 600; }

/* ── TABS ────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
}
.tab-btn.active {
  background: var(--navy);
  color: var(--gold);
  box-shadow: var(--shadow);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── STATS / METRICS ─────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: .72rem; color: var(--gray-600); margin-top: 4px; font-weight: 500; }
.stat-delta { font-size: .78rem; font-weight: 700; margin-top: 4px; }
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ── WORKOUT LOG ─────────────────────────── */
.exercise-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 10px;
}
.exercise-row:last-child { border-bottom: none; }
.ex-muscle {
  font-size: .68rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--blue-lt);
  color: var(--blue);
  font-weight: 600;
  white-space: nowrap;
}
.ex-name  { font-size: .9rem; font-weight: 600; flex: 1; }
.ex-arrow { color: var(--gray-400); font-size: 1.1rem; }

.log-form {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 8px;
}
.log-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.log-inputs .form-control { padding: 10px 8px; font-size: .9rem; text-align: center; }

/* ── CHART AREA ──────────────────────────── */
.chart-wrap {
  padding: 8px 0 4px;
  overflow-x: auto;
}
canvas { max-width: 100%; }

/* ── HISTORY LIST ────────────────────────── */
.history-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}
.history-item:last-child { border-bottom: none; }
.hist-date  { font-size: .78rem; color: var(--gray-600); min-width: 64px; }
.hist-val   { font-size: 1rem; font-weight: 700; color: var(--navy); }
.hist-delta { font-size: .78rem; font-weight: 600; margin-left: auto; }
.hist-note  { font-size: .78rem; color: var(--gray-600); flex: 1; }

/* ── ALERT ───────────────────────────────── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 14px;
  font-weight: 500;
}
.alert-success { background: var(--green-lt); color: var(--green); }
.alert-error   { background: var(--red-lt);   color: var(--red); }
.alert-info    { background: var(--blue-lt);   color: var(--blue); }

/* ── EMPTY STATE ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-600);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: .88rem; }

/* ── MODAL ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 20px 32px;
  transform: translateY(100%);
  transition: transform .3s ease;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gold);
}

/* ── TODAY HEADER ────────────────────────── */
.today-hero {
  background: linear-gradient(135deg, var(--navy) 60%, var(--blue));
  color: white;
  padding: 20px 16px 24px;
  margin: -16px -16px 16px;
  border-radius: 0 0 20px 20px;
}
.today-date { font-size: .8rem; color: rgba(255,255,255,.6); margin-bottom: 4px; }
.today-greet { font-size: 1.2rem; font-weight: 700; color: var(--gold); }

/* ── DIETA PAGE ──────────────────────────── */
.meal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.meal-header {
  padding: 10px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
}
.meal-time  { font-size: .75rem; color: var(--gray-600); margin-left: auto; }
.meal-name  { font-size: .9rem; font-weight: 700; }
.meal-body  { padding: 10px 14px; font-size: .85rem; color: var(--gray-800); line-height: 1.5; }
.macro-row  { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.macro-tag  {
  font-size: .7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 10px;
}
.macro-p { background: var(--blue-lt);   color: var(--blue); }
.macro-c { background: var(--orange-lt); color: var(--orange); }
.macro-k { background: var(--green-lt);  color: var(--green); }

/* ── UTIL ────────────────────────────────── */
.text-center { text-align: center; }
.text-muted  { color: var(--gray-600); }
.text-gold   { color: var(--gold); }
.text-navy   { color: var(--navy); }
.fw-bold     { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-0  { margin-bottom: 0; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.w-100 { width: 100%; }

/* ── SECTION TITLE ───────────────────────── */
.section-title {
  font-size: .72rem;
  font-weight: 800;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 16px 0 8px;
  padding-left: 4px;
}

/* ── STREAK BADGE ────────────────────────── */
.streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gold-lt);
  color: var(--navy);
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--gold);
}

/* ── LOCKED CHECKLIST ITEM ───────────────────────────── */
.checklist-item.locked {
  opacity: .55;
  cursor: not-allowed;
}
.checklist-item.locked .check-box {
  border-color: var(--red);
  color: var(--red);
  font-size: .9rem;
}
.checklist-item.locked .item-label {
  color: var(--gray-400);
  text-decoration: line-through;
}

/* ── SHAKE ANIMATION ─────────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ── RANKING PODIUM ──────────────────────────────────── */
.podium-bar {
  border-radius: 8px 8px 0 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  transition: height .4s ease;
}

/* ── PWA INSTALL BANNER ──────────────────────────────── */
#pwa-install-wrap .btn {
  background: var(--gold-lt);
  border: 1.5px solid var(--gold);
  color: var(--navy);
  font-size: .85rem;
}

/* ── TOAST ANIMATION ─────────────────────────────────── */
.toast-msg {
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}
