:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.15);
  --danger: #f97316;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
  color: var(--text);
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 20px 56px;
}

.card {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

h1, h2, h3, p { margin-top: 0; }
.section-title-row span, .today-sub, .muted, #lastUpdated { color: var(--muted); }
.full-span { width: 100%; }
.top-summary-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 20px;
}
.stats-grid, .goals-grid {
  display: grid;
  gap: 16px;
}
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stats-panel {
  display: grid;
  gap: 12px;
  height: 100%;
}
.side-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.goals-grid { grid-template-columns: 1fr; }
.compact-goal-card {
  margin-bottom: 0;
  height: 100%;
}
.compact-meta-row {
  justify-content: flex-start;
}
.top-actions-row {
  justify-content: flex-start;
}
.grid-layout-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat, .goal-item, .today-item {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.stat-label, .goal-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-value, .goal-value { font-size: 28px; font-weight: 800; }
.goal-dday {
  display: inline-block;
  margin-left: 8px;
  font-size: 16px;
  font-weight: 700;
  color: #fbbf24;
}
.goal-sub { margin-top: 8px; color: var(--muted); font-size: 14px; }
.progress {
  margin-top: 12px;
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #86efac);
}
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.action-btn {
  border: 1px solid var(--line);
  background: #16a34a;
  color: white;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}
.action-btn.secondary { background: #334155; }
.action-btn.danger { background: #b91c1c; }
.hidden { display: none !important; }
.input-cell, .input-inline {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
}
.input-inline.small { width: 110px; }
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 360px;
}
.chart-card canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.today-list { display: grid; gap: 12px; }
.today-item strong { display: block; margin-bottom: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
th { color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

.thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1220;
}
.kcal { font-weight: 700; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #bbf7d0;
  font-size: 12px;
  font-weight: 700;
}
.rules {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.7;
}
code {
  background: rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 8px;
}
.empty {
  color: var(--muted);
  padding: 20px 0;
}

@media (max-width: 960px) {
  .top-summary-layout,
  .grid-layout-main,
  .side-stats-grid {
    grid-template-columns: 1fr;
  }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .toolbar-row { justify-content: flex-start; }
}
