:root {
  color-scheme: light;
  --bg: #eef7f4;
  --surface: #fbfefd;
  --surface-strong: #ffffff;
  --text: #1f2933;
  --muted: #64727a;
  --line: #d5e3df;
  --accent: #146c64;
  --accent-strong: #0f554f;
  --accent-soft: #cfede7;
  --gold: #94610f;
  --rose: #c2414b;
  --shadow: 0 18px 45px rgba(26, 60, 56, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(20, 108, 100, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(194, 65, 75, 0.12), transparent 40%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2 {
  line-height: 1.1;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
}

h2 {
  font-size: 1.15rem;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.stat,
.panel {
  background: rgba(251, 254, 253, 0.92);
  border: 1px solid rgba(213, 227, 223, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat {
  display: grid;
  gap: 8px;
  min-height: 138px;
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.stat strong {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.stat span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.15fr 0.85fr;
}

.panel {
  padding: 18px;
}

.meal-panel,
.history-panel {
  grid-column: 1;
}

.fasting-panel,
.exercise-panel {
  grid-column: 2;
}

.sheets-panel {
  grid-column: 1 / -1;
}

.panel-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 46px;
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 100, 0.14);
}

textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(130px, 0.55fr) minmax(210px, 1fr);
  margin-top: 14px;
}

.lookup-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.lookup-row span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.lookup-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lookup-result {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.lookup-result:hover {
  border-color: var(--accent);
}

.lookup-result strong {
  display: block;
}

.lookup-meta {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 3px;
}

.lookup-calories {
  color: var(--gold);
  font-weight: 900;
  white-space: nowrap;
}

.exercise-estimator {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.burn-estimate {
  align-items: baseline;
  background: var(--accent-soft);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 12px;
}

.burn-estimate strong {
  color: var(--accent-strong);
  font-size: 1.3rem;
}

.burn-estimate span:last-child {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.icon-button {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
}

.primary-button {
  background: var(--accent);
  border-radius: 6px;
  color: white;
  font-weight: 800;
  min-height: 42px;
  padding: 0 16px;
  white-space: nowrap;
}

.secondary-button {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-strong);
  font-weight: 800;
  min-height: 46px;
  padding: 0 14px;
  white-space: nowrap;
}

.secondary-button:hover {
  border-color: var(--accent);
}

.primary-button,
.icon-button {
  border: 0;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.icon-button {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.25rem;
  height: 42px;
  width: 42px;
}

.icon-button:hover {
  border-color: var(--accent);
}

.icon-button.danger {
  color: var(--rose);
  font-size: 1.4rem;
}

.fast-ring {
  --progress: 0deg;
  aspect-ratio: 1;
  background:
    radial-gradient(circle at center, var(--surface) 0 58%, transparent 59%),
    conic-gradient(var(--accent) var(--progress), var(--accent-soft) 0);
  border-radius: 50%;
  display: grid;
  margin: 2px auto 18px;
  max-width: 250px;
  place-items: center;
  width: 72%;
}

.fast-ring div {
  display: grid;
  gap: 6px;
  text-align: center;
}

.fast-ring span {
  font-size: 1.8rem;
  font-weight: 900;
}

.fast-ring small {
  color: var(--muted);
  font-weight: 700;
}

.switch {
  display: inline-flex;
  height: 30px;
  position: relative;
  width: 56px;
}

.switch input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch span {
  background: #c8d0d6;
  border-radius: 999px;
  cursor: pointer;
  inset: 0;
  position: absolute;
  transition: background 0.18s ease;
}

.switch span::after {
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  content: "";
  height: 24px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 0.18s ease;
  width: 24px;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(26px);
}

.pill {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 7px 10px;
  white-space: nowrap;
}

.meal-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.meal-item {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px;
}

.meal-name {
  display: block;
  margin-bottom: 4px;
}

.meal-time {
  color: var(--muted);
  font-size: 0.88rem;
}

.meal-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.meal-calories {
  color: var(--gold);
  font-weight: 900;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.sheets-controls {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.sync-status {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  margin: 12px 0 0;
}

@media (max-width: 860px) {
  .stats-grid,
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .meal-panel,
  .history-panel,
  .fasting-panel,
  .exercise-panel,
  .sheets-panel {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 18px;
  }

  .stats-grid,
  .workspace,
  .form-row,
  .sheets-controls {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .fast-ring {
    width: min(78%, 230px);
  }

  .meal-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .meal-actions {
    justify-content: space-between;
    width: 100%;
  }
}
