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

body {
  background: var(--tg-theme-bg-color, #fff);
  color: var(--tg-theme-text-color, #000);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: 80px; /* space for MainButton */
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.section {
  margin-bottom: 20px;
}

/* Input */
.input-section label {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #999);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#weight-input {
  flex: 1;
  font-size: 36px;
  font-weight: 600;
  padding: 12px 16px;
  border: 2px solid var(--tg-theme-hint-color, #ddd);
  border-radius: 12px;
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  color: var(--tg-theme-text-color, #000);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

#weight-input:focus {
  border-color: var(--tg-theme-button-color, #007aff);
}

#weight-input::placeholder {
  color: var(--tg-theme-hint-color, #ccc);
}

.unit {
  font-size: 20px;
  color: var(--tg-theme-hint-color, #999);
  font-weight: 500;
}

/* Period selector */
.period-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.period-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
  color: var(--tg-theme-hint-color, #666);
  transition: all 0.2s;
}

.period-btn.active {
  background: var(--tg-theme-button-color, #007aff);
  color: var(--tg-theme-button-text-color, #fff);
}

/* Date range picker */
.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.date-range input[type="date"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--tg-theme-hint-color, #ddd);
  border-radius: 8px;
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  color: var(--tg-theme-text-color, #000);
  font-size: 13px;
  font-family: inherit;
  -webkit-appearance: none;
}

.date-range-sep {
  color: var(--tg-theme-hint-color, #999);
  font-size: 14px;
  flex-shrink: 0;
}

/* Chart */
.chart-wrapper {
  background: var(--tg-theme-secondary-bg-color, #f8f8f8);
  border-radius: 12px;
  padding: 12px;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-item {
  text-align: center;
  padding: 8px 4px;
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  border-radius: 8px;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
}

.stat-label {
  font-size: 11px;
  color: var(--tg-theme-hint-color, #999);
  margin-top: 2px;
}

.stat-positive { color: #e53935; }
.stat-negative { color: #43a047; }

/* History */
.history-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.history-row:nth-child(odd) {
  background: var(--tg-theme-secondary-bg-color, #f8f8f8);
}

.history-date {
  font-size: 14px;
  color: var(--tg-theme-hint-color, #888);
}

.history-weight {
  font-size: 16px;
  font-weight: 600;
}

.history-delta {
  font-size: 12px;
  margin-left: 6px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--tg-theme-hint-color, #999);
}

/* ========================
   TABS & NEW SECTIONS
   ======================== */

/* Update body padding for tab bar */
body {
  padding-bottom: 120px !important;
}

/* Tab content visibility */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Tab date line */
.tab-date {
  text-align: center;
  font-size: 13px;
  color: var(--tg-theme-hint-color, #999);
  padding: 8px 0 4px;
}

/* Fixed bottom tab bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  background: var(--tg-theme-bg-color, #fff);
  border-top: 1px solid var(--tg-theme-hint-color, #ddd);
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 8px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab-emoji {
  font-size: 22px;
  line-height: 1.2;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--tg-theme-hint-color, #999);
  transition: color 0.2s;
}

.tab-btn.active .tab-label {
  color: var(--tg-theme-button-color, #007aff);
}

/* ========================
   MACROS TAB
   ======================== */

.macro-total {
  text-align: center;
  padding: 16px 0 12px;
}

.macro-cal-number {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
}

.macro-cal-goal {
  font-size: 14px;
  color: var(--tg-theme-hint-color, #999);
  margin-top: 4px;
}

.macro-bars {
  padding: 0 4px;
}

.macro-bar-item {
  margin-bottom: 10px;
}

.macro-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--tg-theme-text-color, #000);
}

.macro-bar-track {
  height: 8px;
  background: var(--tg-theme-secondary-bg-color, #f0f0f0);
  border-radius: 4px;
  overflow: hidden;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ========================
   STEPS TAB
   ======================== */

.steps-hero {
  display: flex;
  justify-content: center;
  padding: 20px 0 12px;
}

.circular-progress {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circular-inner {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: var(--tg-theme-bg-color, #fff);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.steps-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.steps-goal-label {
  font-size: 12px;
  color: var(--tg-theme-hint-color, #999);
  margin-top: 2px;
}

/* ========================
   MEASUREMENTS TAB
   ======================== */

.measurements-hero {
  display: flex;
  gap: 12px;
  padding: 12px 0;
}

.measurement-card {
  flex: 1;
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.measurement-card-label {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #999);
  margin-bottom: 4px;
}

.measurement-card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.measurement-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--tg-theme-hint-color, #999);
}

.measurement-card-delta {
  font-size: 13px;
  margin-top: 4px;
  font-weight: 500;
}

/* For body measurements: decrease = good (green), increase = bad (red) */
.delta-positive {
  color: #e53935;
}

.delta-negative {
  color: #43a047;
}

/* ========================
   MACROS DIARY
   ======================== */

.diary-row {
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: border-left 0.2s;
  border-left: 3px solid transparent;
}

.diary-row.expanded {
  border-left: 3px solid var(--tg-theme-button-color, #007aff);
}

.diary-row.no-data {
  opacity: 0.4;
  cursor: default;
}

.diary-row.no-drilldown .diary-arrow {
  opacity: 0.15;
}

.diary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.diary-date {
  font-size: 13px;
  font-weight: 600;
}

.diary-weekday {
  opacity: 0.4;
  font-weight: 400;
}

.diary-summary {
  text-align: right;
}

.diary-kcal {
  font-size: 14px;
  font-weight: 600;
}

.diary-kcal-unit {
  font-size: 11px;
  opacity: 0.5;
}

.diary-macros-mini {
  font-size: 10px;
  opacity: 0.5;
}

.diary-arrow {
  opacity: 0.3;
  margin-left: 8px;
  font-size: 10px;
  transition: transform 0.2s;
}

.diary-row.expanded .diary-arrow {
  transform: rotate(180deg);
}

.diary-details {
  margin-top: 10px;
}

.diary-meal-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.4;
  margin-bottom: 4px;
  margin-top: 8px;
}

.diary-meal-label:first-child {
  margin-top: 0;
}

.diary-food-row {
  font-size: 12px;
  padding: 2px 0;
  display: flex;
  justify-content: space-between;
}

.diary-food-cal {
  opacity: 0.5;
  white-space: nowrap;
  margin-left: 8px;
}

.diary-spinner {
  text-align: center;
  padding: 12px;
  font-size: 12px;
  opacity: 0.5;
}

.diary-no-detail {
  text-align: center;
  padding: 8px;
  font-size: 11px;
  opacity: 0.3;
}

/* Food macros in diary drill-down */
.diary-food-row {
  align-items: flex-start;
}

.diary-food-cal {
  text-align: right;
  flex-shrink: 0;
}

.diary-food-macros {
  font-size: 9px;
  opacity: 0.4;
  margin-top: 1px;
}

/* ========================
   STEPS HISTORY
   ======================== */

.sync-btn {
  position: relative;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-width: 36px;
  min-height: 36px;
  background: var(--tg-theme-button-color, #007aff);
  color: var(--tg-theme-button-text-color, #fff);
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
}

.steps-bar {
  height: 4px;
  background: rgba(128,128,128,0.15);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.steps-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: #22c55e;
}

/* ========================
   INFO BUTTON & MODAL
   ======================== */

.info-btn {
  position: absolute;
  top: 8px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 5;
  padding: 4px;
}

.tab-content {
  position: relative;
}

.info-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.info-modal-content {
  background: var(--tg-theme-bg-color, #fff);
  border-radius: 12px;
  padding: 20px;
  max-width: 320px;
  width: 100%;
  position: relative;
  font-size: 14px;
  line-height: 1.6;
}

.info-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.5;
}

.info-modal a {
  color: var(--tg-theme-link-color, #007aff);
}

/* ========================
   SHOW MORE BUTTON
   ======================== */

.show-more-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  border: none;
  border-radius: 8px;
  color: var(--tg-theme-link-color, #007aff);
  font-size: 13px;
  cursor: pointer;
}

/* ========================
   TODAY / UPCOMING ROW HIGHLIGHTS
   ======================== */

.history-row.today, .diary-row.today {
  border-left: 3px solid var(--tg-theme-button-color, #007aff);
  background: rgba(99, 102, 241, 0.08);
}

.history-row.upcoming {
  border-left: 3px dashed var(--tg-theme-button-color, #007aff);
  opacity: 0.7;
}
