/* ===== 에코잇(ECOEAT) - 화이트 + 그린 톤 디자인 시스템 ===== */
:root {
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-800: #166534;
  --gray-50: #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;
  --white: #ffffff;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px -2px rgba(22,163,74,0.10), 0 2px 4px -2px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 24px -4px rgba(22,163,74,0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray-50);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--white);
  position: relative;
  display: flex;
  flex-direction: column;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== 상단 헤더 ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--white);
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 19px;
  color: var(--green-700);
}
.app-header .brand .logo-emoji { font-size: 22px; }
.app-header .header-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}
.header-icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--green-50);
  color: var(--green-700);
  border: none;
  font-size: 15px;
}

/* ===== 본문 영역 ===== */
.main-content {
  flex: 1;
  padding: 20px 20px 100px;
  overflow-y: auto;
}

/* ===== 하단 네비게이션 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--white);
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
  background: none;
  border: none;
  flex: 1;
}
.nav-item i { font-size: 19px; }
.nav-item.active { color: var(--green-600); }
.nav-item.active i { transform: translateY(-1px); }

/* ===== 카드 ===== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }

/* ===== 그린 히어로 카드 ===== */
.hero-card {
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  color: var(--white);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: '🌿';
  position: absolute;
  right: -6px;
  bottom: -14px;
  font-size: 90px;
  opacity: 0.15;
  transform: rotate(-10deg);
}
.hero-card .hero-label {
  font-size: 12.5px;
  opacity: 0.9;
  font-weight: 500;
  margin-bottom: 6px;
}
.hero-card .hero-value {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.15;
}
.hero-card .hero-value .unit { font-size: 16px; font-weight: 700; margin-left: 3px; }
.hero-card .hero-desc {
  font-size: 12.5px;
  opacity: 0.92;
  margin-top: 8px;
}

/* ===== 통계 그리드 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.stat-box {
  background: var(--green-50);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
}
.stat-box .stat-num {
  font-size: 20px;
  font-weight: 900;
  color: var(--green-700);
}
.stat-box .stat-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 500;
}

/* ===== 섹션 타이틀 ===== */
.section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--gray-900);
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title .more-link {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
}

/* ===== 버튼 ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  border: none;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--green-600);
  color: var(--white);
  box-shadow: 0 6px 16px -4px rgba(22,163,74,0.4);
}
.btn-primary:disabled { opacity: 0.5; }
.btn-outline {
  background: var(--white);
  color: var(--green-700);
  border: 1.5px solid var(--green-200);
}
.btn-ghost {
  background: var(--green-50);
  color: var(--green-700);
}
.btn-danger-ghost {
  background: #fef2f2;
  color: var(--danger);
}
.btn-sm { padding: 10px; font-size: 13px; }

/* ===== 폼 ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 7px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--gray-900);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--green-500);
  background: var(--white);
}
.form-textarea { resize: none; min-height: 70px; }
.form-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 8px;
  display: none;
}
.form-error.show { display: block; }

/* ===== 인증 화면 (로그인/회원가입) ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 60px 26px 40px;
  background: linear-gradient(180deg, var(--green-50) 0%, var(--white) 40%);
}
.auth-logo {
  text-align: center;
  margin-bottom: 36px;
}
.auth-logo .emoji { font-size: 52px; }
.auth-logo h1 {
  font-size: 24px;
  font-weight: 900;
  color: var(--green-700);
  margin: 10px 0 4px;
}
.auth-logo h1 .brand-en {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-500);
  letter-spacing: 0.5px;
  margin-left: 6px;
  vertical-align: middle;
}
.auth-logo p {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0;
}
.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13.5px;
  color: var(--gray-500);
}
.auth-switch span {
  color: var(--green-600);
  font-weight: 700;
}

/* ===== 식사 유형 선택 탭 ===== */
.meal-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.meal-type-tab {
  flex: 1;
  padding: 12px 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-500);
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
}
.meal-type-tab.active {
  border-color: var(--green-500);
  background: var(--green-50);
  color: var(--green-700);
}

/* ===== 사진 업로드 박스 ===== */
.photo-upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.photo-upload-box {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--gray-300);
  background: var(--gray-50);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--gray-400);
  position: relative;
  overflow: hidden;
}
.photo-upload-box.filled {
  border: none;
}
.photo-upload-box img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.photo-upload-box .upload-icon {
  font-size: 24px;
}
.photo-upload-box .upload-text {
  font-size: 12px;
  font-weight: 600;
}
.photo-upload-box .badge-tag {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(22,163,74,0.9);
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}
.photo-upload-box .remove-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  background: rgba(0,0,0,0.5);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  border: none;
}
.photo-upload-box input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ===== 기록 리스트 카드 ===== */
.record-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.record-item:last-child { border-bottom: none; }
.record-photos {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.record-photos img {
  width: 52px; height: 52px;
  border-radius: 10px;
  object-fit: cover;
}
.record-info { flex: 1; min-width: 0; }
.record-info .meal-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--green-700);
  background: var(--green-100);
  padding: 3px 9px;
  border-radius: 20px;
  margin-bottom: 5px;
}
.record-info .record-memo {
  font-size: 13px;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-info .record-date {
  font-size: 11.5px;
  color: var(--gray-400);
  margin-top: 4px;
}
.record-delete-btn {
  background: none;
  border: none;
  color: var(--gray-300);
  font-size: 14px;
  align-self: flex-start;
  padding: 4px;
}

/* ===== 랭킹 리스트 ===== */
.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--gray-100);
}
.ranking-item:last-child { border-bottom: none; }
.ranking-rank {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}
.ranking-rank.top1 { background: #fef3c7; color: #b45309; }
.ranking-rank.top2 { background: #e5e7eb; color: #4b5563; }
.ranking-rank.top3 { background: #fed7aa; color: #9a3412; }
.ranking-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gray-800);
}
.ranking-dept {
  font-size: 11.5px;
  color: var(--gray-400);
  font-weight: 500;
}
.ranking-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--green-600);
}

/* ===== 바 차트(간단) ===== */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 100px;
  margin-top: 12px;
}
.bar-chart .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.bar-chart .bar-fill {
  width: 100%;
  max-width: 22px;
  background: var(--green-400);
  border-radius: 6px 6px 3px 3px;
  min-height: 3px;
  transition: height 0.4s ease;
}
.bar-chart .bar-label {
  font-size: 9.5px;
  color: var(--gray-400);
}

/* ===== 빈 상태 ===== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--gray-400);
}
.empty-state .empty-emoji { font-size: 42px; margin-bottom: 10px; }
.empty-state p { font-size: 13.5px; margin: 4px 0; }

/* ===== 토스트 ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 85%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--green-600); }

/* ===== 로딩 오버레이 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  flex-direction: column;
  gap: 10px;
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--green-100);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay .loading-text {
  font-size: 13px;
  color: var(--green-700);
  font-weight: 600;
}

/* ===== 모달(사진 확대) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal-backdrop img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
}
.modal-close {
  position: absolute;
  top: 24px; right: 24px;
  color: white;
  font-size: 22px;
  background: none;
  border: none;
}

/* ===== 프로필 화면 ===== */
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0 20px;
}
.profile-avatar {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--green-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: var(--green-700);
  flex-shrink: 0;
}
.profile-name { font-size: 17px; font-weight: 800; color: var(--gray-900); }
.profile-dept { font-size: 12.5px; color: var(--gray-400); margin-top: 3px; }

/* 유틸 */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
