/* Дневник питания — страница «Обзор».
   Главный элемент — этикетка «пищевая ценность» сегодняшнего дня (толстые линейки, жирные цифры);
   всё остальное нарочно тихое. Цвета данных — палитра дашборда Grafana (проверена валидатором dataviz). */

@font-face {
  font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(/static/fonts/golos-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(/static/fonts/golos-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
                 U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Чистого белого на странице нет: фон и поверхность — два шага одного холодного серо-лавандового.
     Акцент один (индиго, как на /help) и ни один цвет хрома не повторяет цвет ряда на графике. */
  --paper: #e0e2ee; --surface: #ecedf5; --ink: #191a28; --ink2: #4e536b; --muted: #5d637c;
  /* сетка читается и на панели, и на голом фоне: графики веса стоят прямо на --paper (1.25 и 1.38) */
  --line: #ced2e3; --grid: #c6cbe0; --track: #d5d8e8; --accent: #4b3fd6; --on-accent: #ffffff;
  --blue: #2f74c8; --aqua: #15855e; --yellow: #a86f00; --violet: #7468d6; --magenta: #c04373;
  --good: #0a8f0a; --warn: #c98500; --serious: #d0613a; --crit: #c42f2f; --open: #c7cada;
  --band: rgba(10, 143, 10, 0.13);
  --shadow: 0 1px 2px rgba(25, 26, 40, .05), 0 4px 16px rgba(25, 26, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121322; --surface: #1b1d2f; --ink: #eceefb; --ink2: #b4b8d4; --muted: #8186a3;
    --line: #2c2f47; --grid: #2a2e47; --track: #272a41; --accent: #a79bff; --on-accent: #14122b;
    --blue: #3987e5; --aqua: #199e70; --yellow: #c98500; --violet: #9085e9; --magenta: #d55181;
    --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b; --open: #353953;
    --band: rgba(12, 163, 12, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121322; --surface: #1b1d2f; --ink: #eceefb; --ink2: #b4b8d4; --muted: #8186a3;
  --line: #2c2f47; --grid: #2a2e47; --track: #272a41; --accent: #a79bff; --on-accent: #14122b;
  --blue: #3987e5; --aqua: #199e70; --yellow: #c98500; --violet: #9085e9; --magenta: #d55181;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b; --open: #353953;
  --band: rgba(12, 163, 12, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.45 "Golos Text", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; color: var(--ink2); margin-bottom: 10px; }
small { font-size: 0.5em; font-weight: 500; color: var(--ink2); margin-left: 0.25em; letter-spacing: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button { font: inherit; color: inherit; cursor: pointer; }
button.link { background: none; border: 0; padding: 4px 0; color: var(--ink2); text-decoration: underline;
              text-underline-offset: 3px; }
button.link:hover { color: var(--ink); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------------------------------------------------------------- шапка */
.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; }
.top h1 { font-size: 17px; font-weight: 700; }
.who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; color: var(--ink2); }
.who a { color: var(--ink2); text-underline-offset: 3px; }
.who a:hover { color: var(--ink); }
.theme { background: var(--surface); border: 0; border-radius: 999px; width: 34px; height: 34px; font-size: 15px;
         line-height: 1; box-shadow: var(--shadow); align-self: center; }
.theme:hover { background: var(--track); }
.t-sun { display: none; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .t-moon { display: none; }
  html:not([data-theme="light"]) .t-sun { display: inline; }
}
html[data-theme="dark"] .t-moon { display: none; }
html[data-theme="dark"] .t-sun { display: inline; }
html[data-theme="light"] .t-sun { display: none; }
html[data-theme="light"] .t-moon { display: inline; }

/* ---------------------------------------------------------------- первый экран */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; align-items: start; }

/* Этикетка: единственная «громкая» вещь на странице */
.label {                                   /* единственное громкое место на странице */
  background: var(--surface); border: 2px solid var(--ink); border-radius: 4px; padding: 14px 18px 16px;
  box-shadow: var(--shadow);
}
.label h2 { font-size: 36px; font-weight: 850; letter-spacing: -0.02em; line-height: 1; }
.label-date { color: var(--ink2); margin-top: 4px; }
.label-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 10px; }
.stepper { background: transparent; border: 2px solid var(--ink2); color: var(--ink2); border-radius: 8px;
           width: 38px; height: 38px;
           font-size: 15px; line-height: 1; padding: 0; margin-top: 2px; }
.stepper:hover:not(:disabled) { background: var(--ink); color: var(--surface); }
.stepper:disabled { opacity: .3; cursor: default; }
.label-pick { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.label-pick input[type="date"] { font-size: 14px; }
.label-pick .link { font-size: 14px; }
.label-closed { display: block; margin-top: 6px; }
.label-closed .zw-green { color: var(--good); } .label-closed .zw-yellow { color: var(--warn); }
.label-closed .zw-red { color: var(--crit); }
.rule-xl { height: 9px; background: var(--ink); margin: 12px -4px; }
.rule-m { height: 3px; background: var(--ink); margin: 14px -4px 4px; }
.label-kcal { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label-kcal-name { font-size: 20px; font-weight: 750; }
.label-kcal-value { font-size: 64px; font-weight: 850; line-height: 1; letter-spacing: -0.03em; }
.label-kcal-value small { font-size: 18px; font-weight: 600; color: var(--ink); }
.label-note { color: var(--ink2); margin-top: 6px; }
.label-macros > div {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 12px;
  padding: 9px 0 10px; border-bottom: 1px solid var(--ink2);
}
.label-macros > div:last-child { border-bottom: 0; }
.label-macros b { font-size: 17px; font-weight: 750; }
.label-macros .amount { font-size: 17px; font-weight: 750; }
.label-macros .amount span { font-weight: 400; color: var(--ink2); }
.label-macros .label-meter { grid-column: 1 / -1; margin-top: 4px; }
.label-week { color: var(--ink); line-height: 1.5; }
.label-week b { font-weight: 750; }
.label-ai h3 { margin: 10px 0 6px; font-size: 1rem; font-weight: 750; }
.label-ai p { margin: 0; line-height: 1.5; white-space: pre-line; }
.label-ai .label-ai-note { margin-top: 6px; color: var(--ink2); font-size: .85em; }

/* полоска «съедено / норма»: зона нормы — штриховка, отметка нижней границы */
.label-meter { position: relative; height: 12px; background: var(--track); margin-top: 10px; }
.label-meter .norm { position: absolute; top: 0; bottom: 0; background: var(--band);
                     border-left: 2px solid var(--good); border-right: 2px solid var(--good); }
.label-meter .fill { position: absolute; top: 3px; bottom: 3px; left: 0; }
.label-macros .label-meter { height: 8px; }
.label-macros .label-meter .fill { top: 2px; bottom: 2px; }

/* Вес */
.body { min-width: 0; padding-top: 2px; display: grid; gap: 12px; align-content: start; }
.body-head { display: grid; gap: 6px; }
.body-now { font-size: 40px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; margin-top: 2px; }
.body-facts { color: var(--ink2); max-width: 62ch; }
.body-facts b { color: var(--ink); font-weight: 650; }
.body .panel .chart { margin-top: 0; }
h3.sub { margin: 18px 0 0; }

/* ---------------------------------------------------------------- период */
.period {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 40px;
  padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.period-name { color: var(--ink2); margin-right: 6px; }
.chip {
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px;
  color: var(--ink);
}
.chip:hover { border-color: var(--ink2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.dates { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.dash { color: var(--muted); }
input[type="date"] {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; min-width: 0;
}
.meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 20px;
        margin-top: 8px; }
.meta .hint { margin-top: 0; }
.status { min-height: 1.45em; color: var(--muted); font-size: 13px; }
.status.err { color: var(--crit); }

/* ---------------------------------------------------------------- блоки ниже */
.block { margin-top: 44px; }
.block > h2 { font-size: 22px; letter-spacing: -0.02em; }
.block > h2, .block-head { margin-bottom: 12px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.block-aside { color: var(--ink2); }
.block-aside b { font-weight: 700; }
.panel { background: var(--surface); border-radius: 14px; padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
.panel > h3 { color: var(--ink2); }
.grid { display: grid; gap: 16px; }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-split { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; max-width: 75ch; }
.empty { color: var(--muted); font-size: 14px; padding: 20px 0; }

/* лента зон: клетка на день */
.zones { display: flex; gap: 2px; height: 34px; }
.zones span { flex: 1 1 0; min-width: 2px; border-radius: 3px; }
.zones-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink2); margin-top: 8px; }
.zones-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.z-green { background: var(--good); } .z-yellow { background: var(--warn); } .z-red { background: var(--crit); }
.z-none, .z-open { background: var(--open); }

/* графики */
.chart { width: 100%; }
.chart .uplot { font-family: inherit; }
/* Легенда uPlot отключена: вместо «—» при ненаведённом курсоре — подсказка у курсора и ключ цветов под графиком */
.chart { position: relative; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--ink);
       border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
       padding: 7px 10px; font-size: 13px; line-height: 1.4; white-space: nowrap; }
.tip b { font-weight: 750; }
.tip div { display: flex; gap: 14px; justify-content: space-between; }
.tip .tip-day { color: var(--ink2); margin-bottom: 2px; }
.keys { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 13px; color: var(--ink2); }
.keys span { display: inline-flex; align-items: center; gap: 6px; }
.keys i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.keys i.line { height: 0; border-top: 3px solid; border-radius: 0; background: none; }
.keys i.dash { border-top-style: dashed; }
.u-select { background: rgba(127, 127, 127, 0.16); }

/* полоски (откуда калории) */
.bars { display: grid; grid-template-columns: minmax(0, auto) 1fr auto; gap: 9px 12px; align-items: center; }
.bars .k { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18ch; }
.bars .track { height: 9px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bars .fill { height: 100%; }
.bars .v { font-weight: 600; text-align: right; min-width: 4ch; }

/* таблицы */
.tbl { overflow-x: auto; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--ink2);
          white-space: nowrap; }
.tbl td { padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--track); }
td.n, th.n { text-align: right; }
td.c, th.c { text-align: center; }
td.name { white-space: normal; min-width: 12ch; }
.tbl tr:last-child td { border-bottom: 0; }
th .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.share { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.share .track { width: 56px; height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.share .fill { height: 100%; background: var(--blue); }
.t-good { color: var(--good); } .t-warn { color: var(--warn); } .t-serious { color: var(--serious); }
.t-crit { color: var(--crit); } .t-muted { color: var(--muted); }

/* ---------------------------------------------------------------- вход */
body.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { max-width: 360px; background: var(--surface); border: 2px solid var(--ink2); border-radius: 6px;
         box-shadow: var(--shadow); padding: 22px 22px 24px; }
.login h1 { font-size: 28px; font-weight: 850; letter-spacing: -0.02em; padding-bottom: 12px;
            border-bottom: 8px solid var(--ink2); margin-bottom: 14px; }
.login p { color: var(--ink2); margin-top: 8px; }
.login button { margin-top: 18px; width: 100%; padding: 12px; font-weight: 700; border: 0;
                background: var(--accent); color: var(--on-accent); border-radius: 6px; }

/* ---------------------------------------------------------------- узкие экраны */
@media (max-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .g-3, .g-split { grid-template-columns: minmax(0, 1fr); }
  .dates { margin-left: 0; }
}
@media (max-width: 480px) {
  .label h2 { font-size: 30px; }
  .label-kcal-value { font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------------------------------------------------------------- профиль */
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.norm-rows > div { align-items: center; }
.norm-rows .range { display: inline-flex; align-items: center; gap: 6px; }
.norm-rows .range i { font-style: normal; color: var(--ink2); }
.norm-rows .unit { color: var(--ink2); min-width: 3ch; }
.label input:not([type="radio"]), .panel input:not([type="radio"]):not([type="range"]), .panel select {
  font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; min-width: 0;
}
.label input:not([type="radio"]) { width: 5.5ch; text-align: right; font-weight: 650; box-sizing: content-box; }
.norm-rows input.changed, .field input.changed, .field select.changed { border-color: var(--accent); }
.field input.bad, .norm-rows input.bad { border-color: var(--crit); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; margin-top: 12px; }
.field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.field > span { color: var(--ink2); font-size: 14px; }
.field > span b { color: var(--ink); font-weight: 700; }
.field.wide { grid-column: 1 / -1; margin-top: 12px; }
.fields .field.wide { margin-top: 0; }
.field input[type="date"], .field input:not([type]), .field select { width: 100%; }
.field-note { color: var(--muted); font-size: 13px; margin: 0; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.seg-field legend { color: var(--ink2); font-size: 14px; padding: 0; margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px; }
.seg label:hover span { border-color: var(--ink2); }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.suggest { margin-top: 12px; }
.suggest:hover { border-color: var(--ink); }
.label .hint { margin-top: 8px; }
.panel .seg-field { margin-top: 10px; }

.savebar {
  position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  margin: 28px -16px -64px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
}
.savebar .status { flex: 1; min-height: 0; }
.savebar .status.ok { color: var(--good); }
button.primary { border: 0; border-radius: 6px; padding: 10px 22px; font-weight: 700;
                 background: var(--accent); color: var(--on-accent); }
button.primary:disabled { opacity: .4; cursor: default; }
button.link:disabled { opacity: .4; cursor: default; text-decoration: none; }

@media (max-width: 480px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .savebar { flex-wrap: wrap; }
  .savebar .status { flex-basis: 100%; }
}

/* коридор ккал — две цифры в одной строке, поэтому крупнее «Нормы» нельзя */
.label-kcal-value.corr { font-size: 46px; white-space: nowrap; }
.label-kcal-value.corr small { font-size: 16px; }
@media (max-width: 480px) { .label-kcal-value.corr { font-size: 32px; } .label-kcal-value.corr small { margin-left: 2px; } }

/* имя в шапке ведёт в профиль */
.who a#who { color: var(--ink); font-weight: 600; text-decoration: none; }
.who a#who:hover { text-decoration: underline; text-underline-offset: 3px; }
