/* ФитНутри — серо-голубая тема */
* {
  box-sizing: border-box;
}

:root {
  --bg: #e9eef4;
  --bg-2: #dde5ee;
  --surface: #f7f9fc;
  --surface-2: #eef3f9;
  --line: #c7d3e0;
  --line-soft: #d9e2ec;
  --text: #26313d;
  --muted: #64748b;
  --accent: #3b82b8;
  --accent-2: #5b9fd0;
  --accent-soft: #dcebf7;
  --ok: #3f9e7a;
  --danger: #c25b5b;
  --shadow: 0 6px 24px rgba(56, 78, 104, 0.12);
  --radius: 14px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(91, 159, 208, 0.18), transparent 32%),
    radial-gradient(circle at 88% 0%, rgba(148, 163, 184, 0.25), transparent 30%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
}

h1, h2, h3 {
  margin: 0;
}

/* ---------- Верх ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem clamp(1rem, 3vw, 2rem);
  background: rgba(247, 249, 252, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(56, 78, 104, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand__logo {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.3rem;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  box-shadow: var(--shadow);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__text strong {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand__text span {
  font-size: 0.75rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s ease;
}

.tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab.is-active {
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 6px 16px rgba(59, 130, 184, 0.35);
}

/* ---------- Панели ---------- */
main {
  padding: clamp(1rem, 3vw, 2rem);
  max-width: 1200px;
  margin: 0 auto;
}

.panel {
  display: none;
  animation: fade 0.3s ease;
}

.panel.is-active {
  display: block;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hero {
  margin-bottom: 1.25rem;
  padding: 1.4rem 1.6rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(91, 159, 208, 0.22), rgba(199, 211, 224, 0.35));
  border: 1px solid var(--line);
}

.hero h1 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  margin-bottom: 0.35rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

/* ---------- Сетки и карточки ---------- */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.card__head h2,
.card__head h3 {
  font-size: 1.08rem;
}

.card__head--sub {
  margin-top: 1.2rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
}

.card__filters {
  margin-bottom: 0.8rem;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 184, 0.35);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}

.hint {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.subhead {
  margin: 1.1rem 0 0.55rem;
  font-size: 0.98rem;
  color: var(--accent);
}

/* ---------- Формы ---------- */
.form,
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form {
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.form__row,
.filters {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.filters {
  margin-bottom: 0.7rem;
}

.field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: 0.18s ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(91, 159, 208, 0.25);
}

.input--select {
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.btn--primary {
  color: #fff;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  box-shadow: 0 6px 16px rgba(59, 130, 184, 0.32);
}

.btn--primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn--ghost {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--line);
}

.btn--ghost:hover {
  background: var(--accent-soft);
}

.btn--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

/* ---------- Каталоги ---------- */
.catalog {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 460px;
  overflow: auto;
  padding-right: 0.2rem;
}

.catalog::-webkit-scrollbar {
  width: 8px;
}

.catalog::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
}

.food-item,
.ex-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  transition: 0.18s ease;
}

.food-item:hover,
.ex-item:hover {
  border-color: var(--accent-2);
  transform: translateX(3px);
}

.food-item__emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.food-item__body {
  flex: 1;
  min-width: 0;
}

.food-item__name,
.ex-item__name {
  font-weight: 700;
  font-size: 0.95rem;
}

.food-item__meta,
.ex-item__meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.food-item__kcal {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  font-size: 0.9rem;
}

.ex-item {
  align-items: flex-start;
  flex-direction: column;
  gap: 0.5rem;
}

.ex-item__top {
  display: flex;
  width: 100%;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.chip--goal {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 184, 0.35);
  color: var(--accent);
}

.ex-item__tech {
  font-size: 0.85rem;
  color: var(--text);
  background: #fff;
  border-left: 3px solid var(--accent-2);
  padding: 0.45rem 0.6rem;
  border-radius: 0 8px 8px 0;
  margin: 0;
}

.ex-item__actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

/* ---------- Списки ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  animation: fade 0.25s ease;
}

.list li .item-main {
  min-width: 0;
}

.list li .item-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.list li .item-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.list li .item-kcal {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
}

.list--top li {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--line);
  border-radius: 0;
  padding: 0.45rem 0;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 0.8rem 0 0.2rem;
}

/* ---------- Статистика ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.7rem;
}

.stat {
  background: linear-gradient(160deg, #fff, var(--surface-2));
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 0.8rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat strong {
  font-size: 1.6rem;
  color: var(--accent);
}

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

/* ---------- Календарь ---------- */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  color: var(--muted);
  position: relative;
}

.cal-cell--head {
  background: transparent;
  border: none;
  font-weight: 700;
  color: var(--text);
  aspect-ratio: auto;
  padding-bottom: 0.2rem;
}

.cal-cell--out {
  opacity: 0.35;
}

.dot,
.cal-cell--1 { background: #cfe4f4; }
.cal-cell--1 { color: #2f6f9c; border-color: #b6d6ee; }
.cal-cell--2 { background: #8fc0e4; color: #fff; border-color: #74b0db; font-weight: 700; }
.cal-cell--3 { background: var(--accent); color: #fff; border-color: #2f6f9c; font-weight: 700; }

.cal-cell--today::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--danger);
  border-radius: 10px;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.7rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.calendar-legend .dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 4px;
  margin-right: 0.25rem;
  vertical-align: -1px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}

.dot--1 { background: #cfe4f4; }
.dot--2 { background: #8fc0e4; }
.dot--3 { background: var(--accent); }

/* ---------- Пустые состояния каталога ---------- */
.no-results {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px dashed var(--line);
  font-size: 0.9rem;
}

/* ---------- Футер и тост ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 1.5rem 1rem 2.2rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translate(-50%, 140%);
  background: #243140;
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(20, 30, 45, 0.35);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transition: 0.3s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

.toast.is-show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    justify-content: center;
  }

  .brand {
    justify-content: center;
  }
}
