/* ==========================================================================
   Poodle's Plate — единственный файл стилей.
   Все цвета берутся из CSS-переменных: хардкод цвета ниже :root запрещён.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-cyrillic-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* Светлая тема — по умолчанию. */
:root {
  color-scheme: light;

  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --border: #dce3da;
  --text: #121815;
  --text-muted: #5e6b63;
  --accent: #4d7c0f;
  --accent-2: #0e7490;
  --water: #0284c7;
  --warn: #b45309;
  --danger: #dc2626;

  --accent-ink: #ffffff;
  --accent-soft: rgba(77, 124, 15, 0.12);
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warn-soft: rgba(180, 83, 9, 0.1);
  --water-soft: rgba(2, 132, 199, 0.12);
  --ring-track: #e3e9e1;
  --overlay: rgba(18, 24, 21, 0.4);
  --topbar-bg: rgba(245, 247, 244, 0.86);
  --shadow: 0 18px 48px rgba(18, 24, 21, 0.14);
  --shadow-soft: 0 1px 2px rgba(18, 24, 21, 0.04);
  --glow: 0 0 0 1px rgba(77, 124, 15, 0.18);
  --gradient: linear-gradient(120deg, var(--accent), var(--accent-2));
  --radius: 16px;
}

/* Тёмная тема. */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1311;
  --surface: #151c19;
  --surface-2: #1c2521;
  --border: #26312c;
  --text: #e8ede9;
  --text-muted: #8a968f;
  --accent: #a3e635;
  --accent-2: #22d3ee;
  --water: #38bdf8;
  --warn: #f59e0b;
  --danger: #f87171;

  --accent-ink: #0e1311;
  --accent-soft: rgba(163, 230, 53, 0.12);
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn-soft: rgba(245, 158, 11, 0.12);
  --water-soft: rgba(56, 189, 248, 0.14);
  --ring-track: #26312c;
  --overlay: rgba(4, 8, 6, 0.62);
  --topbar-bg: rgba(14, 19, 17, 0.82);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.44);
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.03);
  --glow: 0 0 22px rgba(163, 230, 53, 0.28);
  --gradient: linear-gradient(120deg, var(--accent), var(--accent-2));
  --radius: 16px;
}

/* ------------------------------------------------------------------ база */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1000px 520px at 12% -12%, var(--accent-soft), transparent 62%) no-repeat,
    radial-gradient(760px 420px at 96% 0%, var(--water-soft), transparent 60%) no-repeat,
    var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

img,
svg {
  display: block;
}

/* Атрибут hidden должен побеждать display из классов. */
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  flex: none;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 20px 104px;
}

/* ------------------------------------------------------------------ шапка */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 5px;
  padding: 14px 0;
  margin-bottom: 18px;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: 20px;
  color: var(--text);
  min-width: 0;
}

.brand__icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
  flex: none;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand__name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand__goal {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__date {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
  padding: 5px;
}

.datenav {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.datenav__label {
  display: inline-flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
}

.datenav__label:hover {
  background: var(--surface-2);
}

.datenav__day {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.datenav__tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.theme-icon {
  display: none;
}

[data-theme="light"] [data-theme-icon="light"],
[data-theme="dark"] [data-theme-icon="dark"] {
  display: inline-flex;
}

/* ------------------------------------------------------------------- сетка */

.page {
  padding-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.card--dashboard {
  grid-column: span 7;
}

/* Кнопка в карточке не растягивается на всю ширину. */
.card > .btn {
  align-self: flex-start;
}

.card--meals {
  grid-column: span 5;
}

.card--water,
.card--weight,
.card--plan {
  grid-column: span 4;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.card__title .icon {
  color: var(--accent);
}

.card__count {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

/* -------------------------------------------------------------- дашборд */

.dashboard {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.dashboard__ring {
  flex: none;
}

.ring {
  position: relative;
  width: 158px;
  height: 158px;
}

.ring__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring__track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 10;
}

.ring__progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(var(--glow));
  transition: stroke-dashoffset 0.45s ease;
}

.ring.is-over .ring__progress {
  stroke: var(--danger);
  filter: none;
}

.ring__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.ring__value {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.ring__caption {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard__left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.dayleft {
  font-size: clamp(22px, 3.1vw, 30px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}

.dayleft.is-over {
  background: none;
  color: var(--danger);
  -webkit-text-fill-color: currentColor;
}

.dayleft__meta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}

.chip--started {
  color: var(--accent);
  background: var(--accent-soft);
}

.macros {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.macro {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 16px;
  gap: 10px;
  align-items: start;
}

.macro__icon {
  color: var(--text-muted);
  padding-top: 2px;
}

.macro__main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.macro__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.macro__name {
  font-weight: 600;
}

.macro__value {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.macro__foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.macro__left {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.macro__hint {
  font-style: italic;
  text-align: right;
}

.macro__check {
  padding-top: 2px;
}

.macro__check.is-ok {
  color: var(--accent);
}

.macro__check.is-over {
  color: var(--danger);
}

/* --------------------------------------------------------------- прогресс */

.progress {
  height: 6px;
  width: 100%;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--gradient);
  transition: width 0.25s ease;
}

.progress__fill.is-over {
  background: var(--danger);
}

.progress--water .progress__fill,
.progress__fill--water {
  background: var(--water);
}

.progress__fill--accent {
  background: var(--gradient);
}

/* ------------------------------------------------------------------ кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--glow);
}

.btn--accent:hover {
  filter: brightness(1.06);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:disabled:hover {
  filter: none;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  color: var(--danger);
}

.btn--danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.btn--sm {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.btn--xs {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 11px;
}

.btn--block {
  width: 100%;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex: none;
}

.iconbtn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.iconbtn--sm {
  width: 34px;
  height: 34px;
}

.iconbtn--xs {
  width: 28px;
  height: 28px;
}

.iconbtn--round {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.iconbtn--round:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.is-disabled {
  opacity: 0.3;
  pointer-events: none;
}

.link-btn {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ поля */

.input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.input--area {
  min-height: 76px;
  resize: vertical;
}

.input--cell {
  min-height: 34px;
  padding: 5px 7px;
  font-size: 12px;
  min-width: 56px;
}

.input--steps {
  max-width: 130px;
  text-align: center;
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field__label {
  font-size: 12px;
  color: var(--text-muted);
}

.field__counter {
  align-self: flex-end;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.field__note {
  min-height: 14px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.photo-attach {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-attach .field__note {
  min-height: 0;
}

.photo-preview {
  margin-top: 10px;
}

.photo-preview img {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 240px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.meal__photo {
  display: block;
  margin: 10px 0 4px;
}

.meal__photo img {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 190px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------ приёмы пищи */

.sort {
  position: relative;
}

.sort__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.select--sm {
  min-height: 32px;
  padding: 4px 30px 4px 10px;
  font-size: 11px;
  border-radius: 999px;
  width: auto;
}

.meals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meal-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meal-group + .meal-group {
  margin-top: 8px;
}

.meal-group__head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 2px 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.meal-group__count {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 10px;
  letter-spacing: 0;
}

.meal-group__kcal {
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.meals__empty {
  margin: 0;
}

.meal {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color 0.15s ease;
}

.meal.is-open {
  border-color: var(--accent);
}

.meal__head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.meal__time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meal__title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal__type {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
}

.meal__kcal {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.meal__macros {
  margin: 5px 0 0 54px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meal__body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.meal__items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.meal__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.meal__item-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal__item.is-warn {
  color: var(--warn);
}

.meal__item.is-warn .meal__item-name {
  color: var(--warn);
}

.meal__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.empty-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: auto;
  padding: 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--glow);
  cursor: pointer;
  transition: filter 0.15s ease;
}

.empty-add:hover {
  color: var(--accent-ink);
  filter: brightness(1.06);
}

/* ----------------------------------------------------------------- вода */

.water {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.water__value {
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--water);
}

.water__unit {
  margin-left: 6px;
  font-size: 15px;
  color: var(--text-muted);
}

.water__of {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.stepper__label {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ вес */

.weight__current {
  font-size: 38px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.weight__current.is-empty {
  color: var(--text-muted);
  font-size: 30px;
}

.weight__unit {
  margin-left: 6px;
  font-size: 15px;
  color: var(--text-muted);
}

.weight__form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.weight__progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.weight__scale {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ план */

.steps,
.plan {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.steps__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.steps__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.steps__value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.steps__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.steps__controls .input {
  flex: 1;
}

.plan {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.plan__day {
  font-size: 13px;
  font-weight: 600;
}

/* --------------------------------------------------------------- модалки */

.sheet {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

.sheet__form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sheet__head h2 {
  font-size: 16px;
  font-weight: 600;
}

.sheet__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 20px;
  overflow: auto;
}

.sheet__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.draft {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.draft__note {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.draft__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.draft__total {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.skeleton {
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-muted);
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.table-wrap {
  overflow-x: auto;
}

.table,
.draft-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.draft-table {
  font-size: 12px;
}

.table th,
.draft-table th {
  padding: 8px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td,
.draft-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.draft-table td {
  padding: 3px;
}

.draft-table tr.is-warn {
  background: var(--warn-soft);
}

.table__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* На странице админки карточки разделены отступом 5 px. */
.admin-page .card {
  margin-bottom: 5px;
}

/* На админке нет плавающей кнопки, поэтому большой нижний отступ не нужен. */
.admin-page .app {
  padding-bottom: 24px;
}

.table-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.table-filters__title {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.input--sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.th-sort:hover {
  color: var(--text);
}

.th-sort__arrow {
  color: var(--accent);
  font-size: 9px;
}

#users-empty td {
  color: var(--text-muted);
  text-align: center;
}

.nowrap {
  white-space: nowrap;
}

.password-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.password-row .input {
  flex: 1;
  min-width: 180px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.02em;
  user-select: all;
}

.activity-help {
  font-size: 12px;
}

.activity-help summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}

.activity-help .table-wrap {
  margin-top: 8px;
}

.table--compact th,
.table--compact td {
  padding: 6px 8px;
  font-size: 11px;
}

.input[readonly] {
  color: var(--text-muted);
  cursor: default;
}

/* BMR и TDEE — справочные значения: явно неактивное поле. */
.input--readonly {
  background: var(--bg);
  border-style: dashed;
  color: var(--text-muted);
  cursor: default;
}

.formula {
  font-size: 12px;
  color: var(--text-muted);
}

.formula summary {
  cursor: pointer;
}

.formula p {
  margin: 6px 0 0;
  line-height: 1.5;
}

/* ----------------------------------------------------------- календарь */

.date-form {
  display: flex;
  gap: 8px;
}

.calendar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.calendar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* В диалоге выбора даты разделитель уже даёт шапка окна. */
.calendar--plain {
  padding-top: 0;
  border-top: 0;
}

.calendar__head--selects .input {
  flex: 1;
}

.calendar__today {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

.calendar__title {
  font-size: 13px;
  font-weight: 600;
}

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar__weekday {
  padding: 4px 0;
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.calendar__day {
  padding: 8px 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

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

.calendar__day.is-today {
  border-color: var(--accent);
  color: var(--accent);
}

.calendar__day.is-disabled {
  opacity: 0.35;
  cursor: default;
}

.chart {
  min-height: 160px;
  font-size: 12px;
  color: var(--text-muted);
}

.chart__svg {
  width: 100%;
  height: auto;
}

.chart__axis {
  stroke: var(--border);
}

.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart__dot {
  fill: var(--accent);
}

.chart__label {
  fill: var(--text-muted);
  font-size: 9px;
  font-family: inherit;
}

.chart__label--right {
  text-anchor: end;
}

/* ---------------------------------------------------------------- сервис */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

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

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--glow), var(--shadow);
  cursor: pointer;
}

/* ---------------------------------------------------------------- логин */

.login {
  display: grid;
  place-items: center;
  min-height: 82vh;
  padding: 24px 0;
}

.login__card {
  width: min(380px, 100%);
  gap: 20px;
  padding: 28px;
}

.login__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.login__title {
  font-size: 22px;
  font-weight: 600;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login__hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------- профиль */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 16px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field--wide,
.field--actions {
  grid-column: span 2;
}

.field--actions {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.card--wide {
  margin-top: 16px;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ---------------------------------------------------------------- админка */

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.status {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

.status--on {
  color: var(--accent);
  background: var(--accent-soft);
}

.status--off {
  color: var(--danger);
  background: var(--danger-soft);
}

.journal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.journal__item {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.journal__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}

.journal__summary::-webkit-details-marker {
  display: none;
}

.journal__time {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.journal__user {
  font-weight: 600;
}

.journal__error {
  color: var(--danger);
}

.journal__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
}

.journal__body h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.pre {
  max-height: 240px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.system {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.system__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.system dt {
  color: var(--text-muted);
}

.system dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- адаптив */

@media (max-width: 1099px) {
  .card--dashboard,
  .card--meals {
    grid-column: span 12;
  }

  .card--water,
  .card--weight {
    grid-column: span 6;
  }

  .card--plan {
    grid-column: span 12;
  }

  .profile-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 12px;
  }

  .topbar__date {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .topbar__actions {
    margin-left: auto;
  }

  .topbar__copy-label {
    display: none;
  }
}

@media (max-width: 700px) {
  .app {
    padding: 0 14px 104px;
  }

  .topbar {
    padding-top: 10px;
    margin-bottom: 12px;
  }

  .brand__name {
    font-size: 16px;
  }

  .card {
    padding: 16px;
  }
  .card--water,
  .card--weight {
    grid-column: span 12;
  }

  .dashboard {
    gap: 16px;
  }

  .ring {
    width: 128px;
    height: 128px;
  }

  .ring__value {
    font-size: 23px;
  }

  .meal__head {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-areas:
      "time title kcal"
      "time type kcal";
    row-gap: 2px;
  }

  .meal__time {
    grid-area: time;
  }

  .meal__title {
    grid-area: title;
  }

  .meal__type {
    grid-area: type;
    justify-self: start;
  }

  .meal__kcal {
    grid-area: kcal;
  }

  .meal__macros {
    margin-left: 0;
  }

  .weight__form {
    grid-template-columns: 1fr 1fr;
  }

  .weight__form .btn {
    grid-column: span 2;
  }

  .field-row,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .field--wide,
  .field--actions {
    grid-column: span 1;
  }

  .inline-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fab {
    display: inline-flex;
  }

  .sheet {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    margin: auto auto 0;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
  }

  .sheet__foot .btn {
    flex: 1;
  }

  .empty-add {
    display: none;
  }

  .draft-table {
    min-width: 520px;
  }
}

/* На очень узких экранах кольцо уходит над текстом: иначе строки рвутся. */
@media (max-width: 480px) {
  .dashboard {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .dashboard__ring {
    align-self: center;
  }

  .dayleft {
    font-size: 23px;
  }

  .macro__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .macro__hint {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
