/* ==========================================================================
   components.css — кнопки, поля, карточки, кольцо калорий, строки продуктов
   ========================================================================== */

/* ---- Кнопки ---- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  border: 1.5px solid var(--border); background: var(--glass-in); transition: transform .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, #22C55E, #12A150); color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgba(22, 163, 74, .26);
}
.btn.block { width: 100%; }
.btn.danger { color: var(--over); }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--glass-in); border: 1px solid var(--glass-in-brd); font-size: 18px;
}
.icon-btn svg { width: 19px; height: 19px; }

/* ---- Поля ---- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--dim); font-weight: 600; margin-bottom: 6px; }
.input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; font-size: 16px;   /* 16px — iOS не зумит поле */
  background: var(--glass-in); border: 1.5px solid var(--border); outline: none; transition: border-color .15s;
  -webkit-user-select: text; user-select: text;
}
.input:focus { border-color: rgba(var(--accent-rgb), .7); }
select.input { appearance: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---- Сегменты (выбор из нескольких) ---- */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 0; min-height: 42px; padding: 0 10px; border-radius: 12px; font-weight: 600; font-size: 13.5px;
  background: var(--glass-in); border: 1.5px solid var(--border); white-space: nowrap;
}
.seg button.on { background: rgba(var(--accent-rgb), .16); border-color: rgba(var(--accent-rgb), .6); color: var(--accent); }

/* ---- Карточка ---- */
.card { border-radius: var(--radius-md); background: var(--card); border: 1px solid var(--border); padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: 13px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }

/* ---- Выбор даты ---- */
.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.datebar .d { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.datebar .d small { display: block; color: var(--dim); font-weight: 500; font-size: 12px; margin-top: 1px; }

/* ---- Кольцо калорий ---- */
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring .bg { stroke: rgba(128, 128, 128, .2); }
.ring .fg { stroke: var(--accent); transition: stroke-dashoffset .6s cubic-bezier(.4, 0, .2, 1), stroke .3s; }
.ring.over .fg { stroke: var(--over); }
.ring-c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-c b { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ring-c span { font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.ring-side { flex: 1; min-width: 0; }
.ring-side .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); padding: 4px 0; }
.ring-side .row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Полоски БЖУ ---- */
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.macro .top { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--dim); font-weight: 600; margin-bottom: 7px; }
.macro .top b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }
.macro .bar { height: 7px; border-radius: 99px; background: rgba(128, 128, 128, .2); overflow: hidden; }
.macro .bar i { display: block; height: 100%; border-radius: 99px; transition: width .6s; }

/* ---- График за неделю ---- */
.week { display: flex; align-items: flex-end; gap: 8px; height: 96px; }
.week .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week .b { width: 100%; max-width: 30px; border-radius: 8px 8px 4px 4px; background: rgba(var(--accent-rgb), .35); min-height: 3px; }
.week .b.today { background: var(--accent); }
.week .b.over { background: var(--over); }
.week small { font-size: 11px; color: var(--dim); }

/* ---- Приём пищи ---- */
.meal { margin-bottom: 12px; border-radius: var(--radius-md); background: var(--card); border: 1px solid var(--border); overflow: hidden; }
.meal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.meal-head .em { font-size: 20px; }
.meal-head .t { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; }
.meal-head .t small { display: block; color: var(--dim); font-weight: 500; font-size: 12px; margin-top: 1px; }
.meal-head .add {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid rgba(var(--accent-rgb), .5);
  background: rgba(var(--accent-rgb), .14); color: var(--accent); font-size: 22px; line-height: 1; font-weight: 600;
}
.entry { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--border); cursor: pointer; min-height: 56px; }
.entry:active { background: var(--glass-in); }
.entry .mid { flex: 1; min-width: 0; }
.entry .nm { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .mt { font-size: 12px; color: var(--dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .kc { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .kc small { color: var(--dim); font-weight: 500; }

/* ---- Поиск ---- */
.search-wrap { position: sticky; top: 0; z-index: 5; margin: 0 -14px 12px; padding: 4px 14px 8px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent); }
.food { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 18px; margin-bottom: 8px;
  background: var(--glass-in); border: 1px solid var(--glass-in-brd); cursor: pointer; min-height: 62px; }
.food:active { transform: scale(.985); }
.food .mid { flex: 1; min-width: 0; }
.food .nm { font-weight: 600; font-size: 14.5px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.food .mt { font-size: 12px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food .kc { text-align: right; font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.food .kc small { display: block; color: var(--dim); font-weight: 500; font-size: 11px; }
.tag { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px;
  background: rgba(var(--accent-rgb), .15); color: var(--accent); margin-right: 6px; }
.list-title { font-size: 12.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; margin: 14px 2px 8px; }
.hint { color: var(--dim); text-align: center; padding: 26px 16px; line-height: 1.5; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--glass-in-brd); border-top-color: var(--accent);
  animation: rot .8s linear infinite; margin: 24px auto; }
@keyframes rot { to { transform: rotate(360deg); } }
.attr { font-size: 11px; color: var(--dim); text-align: center; margin: 14px 0; line-height: 1.5; }
.attr a { color: inherit; }

/* ---- Окно добавления: превью ---- */
.preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.preview div { text-align: center; padding: 10px 4px; border-radius: 14px; background: var(--glass-in); border: 1px solid var(--border); }
.preview b { display: block; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.preview span { font-size: 11px; color: var(--dim); }
.preview .k b { color: var(--accent); }

/* ---- Профиль ---- */
.me { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--glass-in); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 28px; font-weight: 800; color: var(--accent); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.me b { font-size: 19px; display: block; }
.me span { color: var(--dim); font-size: 13px; }
.goal-box { text-align: center; padding: 16px; border-radius: var(--radius-md); margin-bottom: 14px;
  background: radial-gradient(150% 170% at 100% 0%, rgba(var(--accent-rgb), .17), transparent 58%), var(--card); border: 1px solid var(--border); }
.goal-box small { font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.goal-box .n { font-size: 38px; font-weight: 800; letter-spacing: -.03em; margin-top: 4px; }
.goal-box .n span { font-size: 15px; color: var(--dim); font-weight: 600; letter-spacing: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; margin: 4px 0 12px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.note { font-size: 11.5px; color: var(--dim); line-height: 1.5; margin: 8px 4px; }
