@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

:root {
  --bg: #e4e9f2;
  --bg-dark: #d1d9e6;
  --text: #31344b;
  --text-light: #6c6f7f;
  --text-lighter: #9a9cb0;
  --white: #ffffff;
  --shadow-dark: rgba(163, 177, 198, 0.4);
  --shadow-light: rgba(255, 255, 255, 0.7);
  --blue: #6C63FF;
  --green: #2ecc71;
  --orange: #e67e22;
  --red: #e74c3c;
  --teal: #1abc9c;
  --border: #d1d9e6;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
}

/* 헤더 */
.header {
  background: var(--bg);
  border-radius: 24px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.header p {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.profile-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.profile-badge {
  background: var(--bg);
  padding: 0.5rem 1rem;
  font-size: 0.813rem;
  color: var(--text-light);
  border-radius: 50px;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
}

/* 카드 */
.card {
  background: var(--bg);
  border-radius: 24px;
  margin-bottom: 1.5rem;
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-lighter);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* 헤더 개선 */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
  transition: all 0.2s ease;
}

.icon-btn:hover {
  color: var(--red);
}

.icon-btn:active {
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.profile-edit-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.edit-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-lighter);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.edit-btn:hover {
  color: var(--blue);
}

/* 통계 (4열 한 줄) */
.stats-row {
  display: flex;
  padding: 1rem;
  gap: 0.5rem;
}

.stat-item-compact {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.5rem;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.stat-item-compact .stat-label {
  font-size: 0.625rem;
  color: var(--text-lighter);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.stat-item-compact .stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

.stat-item-compact .stat-unit {
  font-size: 0.625rem;
  color: var(--text-lighter);
}

.stat-value.blue { color: var(--blue); }
.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }
.stat-value.teal { color: var(--teal); }

/* 진행률 (컴팩트) */
.progress-compact {
  padding: 1rem 1.25rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-light);
}

.progress-pct {
  font-weight: 600;
  color: var(--blue);
}

.progress-bar {
  background: var(--bg);
  height: 10px;
  border-radius: 10px;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
  overflow: hidden;
  padding: 2px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(145deg, var(--blue), #5a52e0);
  border-radius: 8px;
  transition: width 0.5s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-lighter);
  margin-top: 0.75rem;
}

/* BMI 섹션 */
.bmi-section {
  padding: 1.5rem;
}

.bmi-main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.bmi-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

.bmi-title-value {
  color: var(--red);
  font-weight: 700;
}

.bmi-title-status {
  color: var(--red);
  font-weight: 600;
}

.bmi-info-box {
  background: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 16px;
  text-align: center;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
  flex-shrink: 0;
}

.bmi-info-label {
  font-size: 0.688rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.bmi-info-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.bmi-bar-container {
  position: relative;
  margin-bottom: 0.5rem;
}

.bmi-bar {
  display: flex;
  height: 50px;
  border-radius: 25px;
  overflow: hidden;
  box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
}

.bmi-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
}

.seg-underweight { background: linear-gradient(145deg, #9eaab5, #78909c); flex: 17.5; }
.seg-normal { background: linear-gradient(145deg, #5ba4f5, #1e88e5); flex: 22.5; }
.seg-overweight { background: linear-gradient(145deg, #ba68c8, #8e24aa); flex: 10; }
.seg-obese { background: linear-gradient(145deg, #f06292, #d81b60); flex: 25; }
.seg-severe { background: linear-gradient(145deg, #ef5350, #c62828); flex: 25; }

.bmi-pointer {
  position: absolute;
  top: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 14px solid var(--text);
  transform: translateX(-50%);
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bmi-scale-numbers {
  position: relative;
  height: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

.bmi-scale-numbers span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 500;
}

.bmi-scale-numbers span:first-child {
  transform: none;
}

/* 세그먼트 컨트롤 */
.segment-control {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
}

.segment-btn {
  flex: 1;
  padding: 0.875rem;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
  font-family: inherit;
}

.segment-btn:hover {
  color: var(--text);
}

.segment-btn.active {
  color: var(--blue);
  box-shadow: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light);
}

/* 메인 탭 (통합) */
.main-tabs {
  padding: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.main-tabs .segment-btn {
  flex: 1;
  padding: 0.875rem 0.5rem;
  font-size: 0.813rem;
  font-weight: 500;
}

.main-tabs .segment-btn.active {
  background: linear-gradient(145deg, #7a71ff, #5c54e0);
  color: var(--white);
  box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
}

/* 입력 패널 */
.entry-panel {
  display: none;
  padding: 1rem 1.25rem;
}

.entry-panel.active {
  display: block;
}

.card-header-compact {
  padding: 1rem 1.25rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-lighter);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* 인라인 폼 (한 줄) */
.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap;
}

.inline-form input {
  background: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 0.75rem 0.875rem;
  font-size: 0.813rem;
  color: var(--text);
  font-family: inherit;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
  min-width: 0;
  flex: 1;
}

.inline-form input[type="date"] {
  flex: 0 0 auto;
  width: auto;
  min-width: 130px;
}

.inline-form input[type="number"] {
  flex: 1;
  min-width: 80px;
}

.inline-form input:focus {
  outline: none;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light), 0 0 0 2px var(--blue);
}

.btn-sm {
  padding: 0.75rem 1rem !important;
  font-size: 0.75rem !important;
  white-space: nowrap;
  flex-shrink: 0;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 120px;
}

.field label {
  font-size: 0.688rem;
  font-weight: 500;
  color: var(--text-lighter);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input,
.field select {
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  font-family: inherit;
  box-shadow: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light);
  width: 100%;
}

.field input:focus,
.field select:focus {
  outline: none;
  box-shadow: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light), 0 0 0 2px var(--blue);
}

.field input::placeholder {
  color: var(--text-lighter);
}

/* 버튼 */
.btn {
  padding: 0.875rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  border-radius: 12px;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(145deg, #7a71ff, #5c54e0);
  color: var(--white);
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
}

.btn-secondary:hover {
  color: var(--blue);
}

.save-btn {
  padding: 0.875rem;
  min-width: 60px;
}

.del-btn {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
  transition: all 0.2s ease;
}

.del-btn:hover {
  background: linear-gradient(145deg, #f06060, #d63030);
  color: var(--white);
}

/* 차트 */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 500;
}

.period-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.period-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
  transition: all 0.2s ease;
}

.period-btn:hover {
  color: var(--text);
}

.period-btn.active {
  background: linear-gradient(145deg, #7a71ff, #5c54e0);
  color: var(--white);
}

.chart-wrap {
  padding: 1.5rem;
  height: 300px;
}

/* 직접 날짜 입력 */
#customDateRange {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

.custom-date-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap;
}

.custom-date-form input[type="date"] {
  background: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text);
  font-family: inherit;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
  flex: 1;
  min-width: 0;
}

.custom-date-form input[type="date"]:focus {
  outline: none;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light), 0 0 0 2px var(--blue);
}

.date-separator {
  color: var(--text-lighter);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* 테이블 */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
}

.table-title {
  font-size: 0.875rem;
  font-weight: 500;
}

/* 새로고침 버튼 */
.refresh-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
  transition: all 0.2s ease;
}

.refresh-btn:hover {
  color: var(--blue);
}

.refresh-btn:active {
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.refresh-btn svg {
  transition: transform 0.3s ease;
}

.refresh-btn:hover svg {
  transform: rotate(180deg);
}

.table-tabs {
  display: flex;
  padding: 0 1.5rem 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-tab {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
  transition: all 0.2s ease;
}

.table-tab:hover {
  color: var(--text);
}

.table-tab.active {
  background: linear-gradient(145deg, #7a71ff, #5c54e0);
  color: var(--white);
}

.table-wrap {
  max-height: 400px;
  overflow-y: auto;
  margin: 0 1rem 1rem;
  border-radius: 16px;
  background: var(--bg);
  box-shadow: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light);
}

.table-wrap::-webkit-scrollbar {
  width: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--bg-dark);
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-size: 0.688rem;
  font-weight: 600;
  color: var(--text-lighter);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text);
  border-top: 1px solid var(--bg-dark);
}

tr:first-child td {
  border-top: none;
}

/* 건강 그리드 */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
}

.health-item {
  padding: 1.5rem;
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
}

.health-label {
  font-size: 0.688rem;
  color: var(--text-lighter);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.health-value {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.health-note {
  font-size: 0.75rem;
  color: var(--text-lighter);
  margin-top: 0.75rem;
}

/* 뱃지 */
.badge {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  font-size: 0.688rem;
  font-weight: 500;
  border-radius: 50px;
  text-transform: uppercase;
}

.badge.normal {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green);
}

.badge.warning {
  background: rgba(230, 126, 34, 0.15);
  color: var(--orange);
}

.badge.danger {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red);
}

.positive { color: var(--red); }
.negative { color: var(--green); }

/* 싱크 상태 */
.sync-status {
  font-size: 0.75rem;
  color: var(--text-lighter);
  text-align: center;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg);
  border-radius: 16px;
  margin-top: 1.5rem;
  box-shadow: 2px 2px 6px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
}

.sync-status.loading { color: var(--blue); }
.sync-status.error { color: var(--red); }
.sync-status.success { color: var(--green); }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg-dark);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 스켈레톤 로딩 */
.skeleton {
  background: linear-gradient(90deg, var(--bg-dark) 25%, var(--bg) 50%, var(--bg-dark) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton-title { height: 1.5rem; width: 60%; margin-bottom: 1rem; }
.skeleton-value { height: 2.5rem; width: 80%; margin: 0 auto; border-radius: 12px; }
.skeleton-bar { height: 12px; border-radius: 10px; margin: 1rem 0; }
.skeleton-bmi { height: 50px; border-radius: 25px; }
.skeleton-chart { height: 300px; border-radius: 16px; }

/* 토스트 */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 1rem 1.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
  border-radius: 16px;
  max-width: calc(100vw - 2rem);
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: linear-gradient(145deg, #34d67c, #27ae60);
  color: var(--white);
}

.toast.error {
  background: linear-gradient(145deg, #f06060, #c0392b);
  color: var(--white);
}

/* BMI 컴팩트 (한 줄) */
.bmi-compact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
}

.bmi-compact .bmi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-lighter);
  text-transform: uppercase;
}

.bmi-compact .bmi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue);
}

.bmi-bar-mini {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #78909c 0%, #1e88e5 25%, #8e24aa 45%, #d81b60 60%, #c62828 100%);
  position: relative;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.1);
}

.bmi-pointer-mini {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: var(--white);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* 건강 요약 (한 줄) */
.summary-row {
  display: flex;
  padding: 1rem 1.25rem;
  gap: 1.5rem;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.summary-label {
  font-size: 0.688rem;
  font-weight: 500;
  color: var(--text-lighter);
  text-transform: uppercase;
}

.summary-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.summary-unit {
  font-size: 0.75rem;
  color: var(--text-light);
}

.summary-note {
  font-size: 0.688rem;
  color: var(--text-lighter);
}

.badge.small {
  padding: 0.2rem 0.5rem;
  font-size: 0.625rem;
}

/* 모달 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--bg);
  border-radius: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.close-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-light);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
}

.close-btn:hover {
  color: var(--red);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
}

.modal-field input {
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  font-family: inherit;
  box-shadow: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light);
}

.modal-field input:focus {
  outline: none;
  box-shadow: inset 2px 2px 6px var(--shadow-dark), inset -2px -2px 6px var(--shadow-light), 0 0 0 2px var(--blue);
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 0 1.5rem 1.5rem;
  justify-content: flex-end;
}

/* 유틸리티 */
.hidden { display: none !important; }
.min-h-screen { min-height: 100vh; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }

.error-box {
  background: linear-gradient(145deg, #f06060, #c0392b);
  color: white;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  border-radius: 12px;
}

/* 반응형 */
@media (max-width: 768px) {
  .container { padding: 1rem; }

  .header {
    border-radius: 20px;
    margin-bottom: 1rem;
    padding: 1.5rem;
  }

  .card {
    border-radius: 20px;
    margin-bottom: 1rem;
  }

  /* 통계 4열 */
  .stats-row {
    padding: 0.75rem;
    gap: 0.375rem;
  }
  .stat-item-compact {
    padding: 0.625rem 0.25rem;
    border-radius: 12px;
  }
  .stat-item-compact .stat-value {
    font-size: 1.125rem;
  }
  .stat-item-compact .stat-label,
  .stat-item-compact .stat-unit {
    font-size: 0.563rem;
  }

  /* 건강 요약 */
  .summary-row {
    padding: 0.75rem 1rem;
    gap: 1rem;
  }
  .summary-label {
    font-size: 0.625rem;
  }
  .summary-value {
    font-size: 0.875rem;
  }

  /* BMI 컴팩트 */
  .bmi-compact {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .bmi-compact .bmi-value {
    font-size: 1.25rem;
  }

  .table-wrap {
    margin: 0 0.75rem 0.75rem;
    border-radius: 12px;
  }

  .segment-control {
    padding: 0.75rem 1rem;
    gap: 0.375rem;
  }

  .segment-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 10px;
  }

  .period-btns { gap: 0.375rem; }

  .period-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.688rem;
    border-radius: 8px;
  }

  .chart-wrap {
    padding: 1rem;
    height: 260px;
  }

  .sync-status {
    border-radius: 16px;
    margin-top: 1rem;
  }

  th, td { padding: 0.875rem 1rem; }

  .form-row { flex-direction: column; }
  .field { min-width: 100%; }

  /* 인라인 폼 - 모바일에서도 한 줄 유지 */
  .inline-form {
    gap: 0.375rem;
  }
  .inline-form input {
    padding: 0.625rem 0.5rem;
    font-size: 0.75rem;
  }
  .inline-form input[type="date"] {
    min-width: 110px;
  }
  .inline-form input[type="number"] {
    min-width: 60px;
  }
  .btn-sm {
    padding: 0.625rem 0.75rem !important;
  }

  .main-tabs .segment-btn {
    padding: 0.75rem 0.25rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .container { padding: 0.75rem; }
  .header { padding: 1rem; }
  .header h1 { font-size: 1.25rem; }
  .card { border-radius: 14px; }
  .chart-wrap { height: 200px; padding: 0.75rem; }
  .period-btn { padding: 0.375rem 0.5rem; font-size: 0.625rem; }
  th, td { padding: 0.625rem 0.5rem; font-size: 0.75rem; }

  /* 통계 4열 - 더 작은 화면 */
  .stats-row {
    padding: 0.5rem;
    gap: 0.25rem;
  }
  .stat-item-compact {
    padding: 0.5rem 0.125rem;
    border-radius: 10px;
  }
  .stat-item-compact .stat-value {
    font-size: 1rem;
  }
  .stat-item-compact .stat-label,
  .stat-item-compact .stat-unit {
    font-size: 0.5rem;
  }

  /* 건강 요약 */
  .summary-row {
    padding: 0.625rem 0.75rem;
    gap: 0.75rem;
    flex-wrap: wrap;
  }
  .summary-item {
    gap: 0.375rem;
  }
  .summary-label {
    font-size: 0.563rem;
  }
  .summary-value {
    font-size: 0.813rem;
  }

  /* BMI */
  .bmi-compact {
    padding: 0.625rem 0.75rem;
    gap: 0.375rem;
  }
  .bmi-compact .bmi-label {
    font-size: 0.625rem;
  }
  .bmi-compact .bmi-value {
    font-size: 1.125rem;
  }

  /* 프로필 */
  .profile-badge {
    padding: 0.375rem 0.625rem;
    font-size: 0.688rem;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .icon-btn svg {
    width: 16px;
    height: 16px;
  }
  .edit-btn {
    width: 28px;
    height: 28px;
  }
  .edit-btn svg {
    width: 12px;
    height: 12px;
  }

  /* 인라인 폼 */
  .inline-form input {
    padding: 0.5rem 0.375rem;
    font-size: 0.688rem;
    border-radius: 8px;
  }
  .inline-form input[type="date"] {
    min-width: 90px;
  }
  .btn-sm {
    padding: 0.5rem 0.5rem !important;
    font-size: 0.625rem !important;
    border-radius: 8px !important;
  }

  .main-tabs {
    padding: 0.5rem;
    gap: 0.25rem;
  }
  .main-tabs .segment-btn {
    padding: 0.5rem 0.25rem;
    font-size: 0.625rem;
    border-radius: 8px;
  }

  .custom-date-form {
    gap: 0.25rem;
  }
  .custom-date-form input[type="date"] {
    padding: 0.5rem 0.375rem;
    font-size: 0.625rem;
  }
  .date-separator {
    font-size: 0.75rem;
  }

  .refresh-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }
  .refresh-btn svg {
    width: 14px;
    height: 14px;
  }

  /* 모달 */
  .modal-content {
    border-radius: 18px;
  }
  .modal-header {
    padding: 1rem;
  }
  .modal-body {
    padding: 1rem;
  }
  .modal-footer {
    padding: 0 1rem 1rem;
  }
}
