:root {
  --bg: #000000;
  --card: #121212;
  --border: #1c1c1e;
  --border-accent: #27272a;
  --emerald: #10b981;
  --emerald-dark: #065f46;
  --cyan: #06b6d4;
  --cyan-dark: #083344;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #ffffff;
  --text-sub: #a1a1aa;
  --text-muted: #71717a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

#app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg);
  border-left: 1px solid #111;
  border-right: 1px solid #111;
}

/* BLOKADA HASŁEM */
.lock-screen {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lock-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border-accent);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
}
.lock-logo {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--emerald);
  margin-bottom: 8px;
}
.lock-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 20px;
}

/* HEADER */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.header-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.2px;
}
.header-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
}
.header-btn {
  background: #121212;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-weight: 700;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

/* CONTENT CONTAINER */
.content {
  flex: 1;
  padding: 14px;
  padding-bottom: 110px;
  overflow-y: auto;
}

/* CARDS */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.card-title {
  color: #e4e4e7;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* RING SECTION */
.ring-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ring-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.ring-svg {
  transform: rotate(-90deg);
  width: 120px;
  height: 120px;
}
.ring-circle-bg {
  stroke: #1c1c1e;
  stroke-width: 8;
  fill: #09090b;
}
.ring-circle-val {
  stroke: var(--cyan);
  stroke-width: 8;
  stroke-linecap: round;
  fill: none;
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s;
}
.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-kcal {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.ring-target {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 3px;
}
.ring-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald);
  margin-top: 2px;
}
.ring-details {
  flex: 1;
}
.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.remaining-text {
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0 10px;
}

/* MTB BOX */
.mtb-box {
  background: var(--border);
  padding: 9px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: 1px solid var(--border-accent);
}
.mtb-title {
  font-size: 13px;
  font-weight: 700;
}
.mtb-sub {
  font-size: 11px;
  color: var(--emerald);
  margin-top: 2px;
}

/* PACING BANNER */
.pacing-banner {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--emerald);
  background: #061c14;
}
.pacing-banner.lagging {
  border-color: var(--red);
  background: #1f0909;
}
.pacing-text {
  font-size: 12px;
  font-weight: 600;
  color: #6ee7b7;
  line-height: 1.35;
}
.pacing-banner.lagging .pacing-text {
  color: #fca5a5;
}

/* PROGRESS */
.progress-group {
  margin-bottom: 12px;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #d4d4d8;
}
.progress-header span:last-child {
  color: #fff;
  font-weight: 700;
}
.progress-track {
  height: 9px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease;
}

/* BUTTONS */
.btn-row {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.btn-outline {
  flex: 1;
  background: var(--border);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}
.btn-outline.muted {
  border-color: #3f3f46;
  color: #a1a1aa;
}
.btn-emerald {
  background: var(--emerald);
  color: #000;
  border: none;
  font-weight: 900;
  font-size: 12px;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
.btn-cyan {
  background: var(--cyan);
  color: #000;
  border: none;
  font-weight: 900;
  font-size: 12px;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-box {
  background: var(--border);
  padding: 12px;
  border-radius: 10px;
}
.stat-lbl {
  color: var(--text-sub);
  font-size: 11px;
}
.stat-val {
  font-size: 16px;
  font-weight: 800;
  margin-top: 4px;
  color: #fff;
}
.stat-sub {
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 2px;
}

/* FORMS */
.form-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.input-lbl {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.input-dark {
  background: var(--border);
  border: 1px solid var(--border-accent);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  width: 100%;
  outline: none;
}
.input-dark:focus {
  border-color: var(--cyan);
}

/* LIST ITEMS */
.food-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.food-name {
  font-size: 14px;
  font-weight: 700;
}
.food-portion {
  font-size: 12px;
  color: #d4d4d8;
  margin-top: 2px;
}
.food-macros {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.food-actions {
  display: flex;
  gap: 5px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.btn-del {
  background: var(--border-accent);
  color: var(--red);
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

/* PLAN TRENINGOWY KARTY */
.plan-item {
  background: var(--border);
  border: 1px solid var(--border-accent);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.plan-item.done {
  border-color: var(--emerald-dark);
  background: #061c14;
}
.plan-name {
  font-size: 14px;
  font-weight: 800;
}
.plan-sub {
  font-size: 12px;
  color: var(--cyan);
  margin-top: 2px;
}
.plan-check-btn {
  background: #27272a;
  color: #a1a1aa;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.plan-check-btn.checked {
  background: var(--emerald);
  color: #000;
  border-color: var(--emerald);
}

/* LEADERBOARD PROFILE CARDS */
.leader-card {
  background: var(--border);
  border: 1px solid var(--border-accent);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.leader-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.leader-name {
  font-size: 15px;
  font-weight: 900;
  color: var(--emerald);
}
.leader-time {
  font-size: 11px;
  color: var(--text-muted);
}
.leader-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.leader-metric-box {
  background: #121212;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
}

/* RECORD BOX */
.record-box {
  background: var(--border);
  border-radius: 10px;
  padding: 12px;
}
.record-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
}
.record-sub {
  font-size: 12px;
  color: #d4d4d8;
  margin-top: 3px;
}

/* BOTTOM NAV */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 68px;
  background: #09090b;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}
.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  gap: 3px;
}
.nav-item.active {
  color: var(--emerald);
  font-weight: 900;
}

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--emerald);
  border-radius: 16px;
  padding: 20px;
}
.modal-card.cyan-border {
  border-color: var(--cyan);
}
.modal-title {
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 8px;
}
.modal-sub {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.4;
  margin-bottom: 12px;
}
.modal-input {
  background: var(--border);
  border: 1px solid var(--border-accent);
  color: var(--emerald);
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  width: 100%;
  margin-bottom: 16px;
  outline: none;
}
.modal-btns {
  display: flex;
  gap: 8px;
}
.modal-btn-cancel {
  flex: 1;
  background: var(--border);
  color: var(--text-sub);
  border: none;
  padding: 12px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
}
.modal-btn-ok {
  flex: 1;
  background: var(--emerald);
  color: #000;
  border: none;
  padding: 12px;
  font-weight: 900;
  border-radius: 8px;
  cursor: pointer;
}

/* TOAST */
#toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #18181b;
  border: 1px solid var(--emerald);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  pointer-events: none;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}