/* =====================================================================================
   Дизайн-система трекера (макеты 03.11.2026). Единственное место с цветами, отступами,
   радиусами и шрифтами; компоненты общие для всех разделов. Тема — по системе, либо
   data-theme="light|dark" на <html> (переключатель в настройках).
   ===================================================================================== */
:root {
  /* поверхности и текст */
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f1f2f5;
  --text: #15161a;
  --text-2: #6c6f78;
  --text-3: #a0a3ab;
  --line: rgba(60, 60, 67, 0.13);
  /* один основной акцент */
  --accent: #2f6bff;
  --accent-text: #ffffff;
  /* смысловые: хорошо / оценка или близко к пределу / превышено или не хватает */
  --green: #12a150;
  --green-bg: rgba(18, 161, 80, 0.11);
  --yellow: #b8770b;
  --yellow-bg: rgba(240, 170, 0, 0.15);
  --red: #e0383e;
  --red-bg: rgba(224, 56, 62, 0.10);
  /* тихие цвета разделов — иконки и графики */
  --sec-health: #1f9d6b;
  --sec-finance: #2f6bff;
  --sec-time: #7c5cff;
  --sec-reading: #d9901a;
  --sec: var(--accent);
  /* размеры */
  --radius: 16px;
  --radius-s: 10px;
  --row: 56px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Liberation Sans", sans-serif;
  /* Этап 36 (правило сайта, 24.11): заголовок группы → карточка 8 px, между карточками 12 px — везде */
  --gap-head: 8px;
  --gap-card: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e;
    --text: #f4f4f6; --text-2: #9a9aa2; --text-3: #66666c; --line: rgba(84, 84, 88, 0.5);
    --accent: #4d8dff; --green: #32d074; --green-bg: rgba(50, 208, 116, 0.14);
    --red: #ff5c61; --red-bg: rgba(255, 92, 97, 0.14); --yellow: #ffc53d; --yellow-bg: rgba(255, 197, 61, 0.14);
    --sec-health: #3cc98f; --sec-finance: #4d8dff; --sec-time: #9d85ff; --sec-reading: #f0b04a;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e;
  --text: #f4f4f6; --text-2: #9a9aa2; --text-3: #66666c; --line: rgba(84, 84, 88, 0.5);
  --accent: #4d8dff; --green: #32d074; --green-bg: rgba(50, 208, 116, 0.14);
  --red: #ff5c61; --red-bg: rgba(255, 92, 97, 0.14); --yellow: #ffc53d; --yellow-bg: rgba(255, 197, 61, 0.14);
  --sec-health: #3cc98f; --sec-finance: #4d8dff; --sec-time: #9d85ff; --sec-reading: #f0b04a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.6); color-scheme: dark;
}
[data-sec="health"], [data-sec="food"] { --sec: var(--sec-health); } /* 28.11: «Еда» — отдельный раздел, цвет как у «Здоровья» */
[data-sec="finance"] { --sec: var(--sec-finance); }
[data-sec="time"] { --sec: var(--sec-time); }
[data-sec="reading"] { --sec: var(--sec-reading); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.35; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ===== Числа ===== */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kop, .unit { color: var(--text-3); font-size: 0.68em; font-weight: 500; }
.unit { margin-left: 0.15em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.green { color: var(--green); } .red { color: var(--red); } .yellow { color: var(--yellow); } .sec { color: var(--sec); }

/* ===== Каркас: шапка, вкладки, страница, нижняя панель ===== */
.appbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 16px; padding: 12px 16px 4px; min-height: 52px;
}
.appbar h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.appbar .date { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.appbar .brand { display: none; font-weight: 700; font-size: 17px; }
.appbar .sections { display: none; }
.appbar .icon-btn { margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); color: var(--text-2);
}
.tabs {
  position: sticky; top: 52px; z-index: 4; background: var(--bg);
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 4px 12px 0;
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a {
  flex: none; padding: 10px 8px 9px; color: var(--text-2); font-weight: 500; font-size: 15px;
  border-bottom: 2px solid transparent;
}
.tabs button.active, .tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button.soon { color: var(--text-3); cursor: default; }
.page { max-width: 1120px; margin: 0 auto; padding: 16px 16px 120px; }
.cols { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
.col { display: grid; gap: 24px; align-content: start; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(var(--n, 5), 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
}
.bottombar a { display: grid; justify-items: center; gap: 2px; font-size: 10px; color: var(--text-3); padding: 4px 0; }
.bottombar a.active { color: var(--accent); }
.bottombar svg { width: 24px; height: 24px; }
@media (min-width: 900px) {
  .appbar { padding: 14px 32px; border-bottom: 1px solid var(--line); background: var(--surface); }
  .appbar h1, .appbar .date { display: none; }
  .appbar .brand { display: block; }
  .appbar .sections { display: flex; gap: 4px; }
  .appbar .sections a { padding: 6px 12px; border-radius: 999px; color: var(--text-2); font-weight: 500; }
  .appbar .sections a.active { background: var(--surface-2); color: var(--text); }
  .appbar .icon-btn { background: var(--surface-2); }
  .tabs { top: 65px; padding: 4px max(24px, calc((100vw - 1120px) / 2 + 8px)) 0; }
  .page { padding: 24px 16px 64px; }
  .cols { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
  .cols.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bottombar { display: none; }
  .page-title { display: block; }
}
.page-title { display: none; font-size: 26px; font-weight: 700; margin: 0 4px 16px; letter-spacing: -0.02em; }

/* ===== Карточка-группа и строка списка ===== */
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px var(--gap-head); }
.group-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.group-head .link { color: var(--accent); font-size: 14px; }
.group-head .aside { color: var(--text-2); font-size: 14px; }
.card { background: var(--surface); border-radius: var(--radius); }
.card.pad { padding: 14px 16px; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: var(--row); padding: 8px 16px; width: 100%; text-align: left;
}
.row + .row::before, .row + .expand::before, .expand + .row::before {
  content: ""; position: absolute; top: 0; left: 64px; right: 0; border-top: 1px solid var(--line);
}
.row.plain + .row.plain::before { left: 16px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 15px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .sub { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row .right { text-align: right; flex: none; }
.row .amt { font-size: 15px; font-weight: 500; }
.row .amt-sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.row.done .title, .row.done .amt { color: var(--text-2); }
.row.off { opacity: 0.55; }
.row.opened { background: var(--surface); }
.chev { color: var(--text-3); flex: none; }

/* ===== Иконки: буква-аватар, значок раздела, дата ===== */
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 650; font-size: 15px; color: #fff; background: var(--c, #8e8e93);
}
.avatar.dark-text { color: #1b1b1b; }
.sec-icon {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--sec) 14%, transparent); color: var(--sec);
}
.sec-icon svg { width: 20px; height: 20px; }
.date-badge {
  flex: none; width: 36px; height: 40px; border-radius: var(--radius-s); background: var(--surface-2);
  display: grid; place-content: center; text-align: center; line-height: 1.05;
}
.date-badge b { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.date-badge span { font-size: 10px; color: var(--text-2); }
/* значок состояния справа: ✓ хорошо, ! оценка/близко, ! не хватает, · нейтрально */
.cov { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.cov.ok { background: var(--green-bg); color: var(--green); }
.cov.warn { background: var(--yellow-bg); color: var(--yellow); }
.cov.bad { background: var(--red-bg); color: var(--red); }
.cov.none { background: var(--surface-2); color: var(--text-3); }

/* ===== Главная цифра, плитки 2×2, плашка ===== */
.hero { padding: 4px 4px 0; }
.hero .label { font-size: 14px; color: var(--text-2); }
.hero .big { font-size: 40px; font-weight: 700; letter-spacing: -0.025em; margin: 2px 0; line-height: 1.1; }
.hero .big .kop, .hero .big .unit { font-size: 22px; font-weight: 600; }
.hero .formula { font-size: 13px; color: var(--text-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 12px; font-size: 14px; font-weight: 500;
}
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.warn { background: var(--yellow-bg); color: var(--yellow); }
.pill.neutral { background: var(--surface); color: var(--text-2); }
.pill .muted { font-weight: 400; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; min-width: 0; }
.metric .label { font-size: 13px; color: var(--text-2); }
.metric .value { font-size: 20px; font-weight: 650; margin: 2px 0; letter-spacing: -0.01em; }
.metric .value .unit { font-size: 13px; }
.metric .delta { font-size: 12.5px; }
.metric.blank .value { color: var(--text-3); }

/* ===== Прогресс: полоса и кольцо ===== */
.bar { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 6px; position: relative; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--c, var(--sec)); }
.bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-3); border-radius: 1px; }
.progress-row { padding: 10px 16px; }
.progress-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.progress-row .hint { font-size: 12.5px; margin-top: 4px; color: var(--text-2); }
.progress-row + .progress-row { border-top: 1px solid var(--line); }
.ring { position: relative; display: grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }

/* ===== Переключатели: период, день, сегменты ===== */
.switcher { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 16px; }
.switcher > button { width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--text-2); font-size: 18px; flex: none; }
.switcher .title { min-width: 150px; text-align: center; }
.switcher .title b { display: block; font-size: 17px; }
.switcher .title span { font-size: 12.5px; color: var(--text-2); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { background: none; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 550; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg.full { display: flex; } .seg.full button { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--surface); font-size: 13.5px; }
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.warn { background: var(--yellow-bg); color: var(--yellow); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; vertical-align: 1px; }
.tag.soon, .tag.warn { background: var(--yellow-bg); color: var(--yellow); }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.off { background: var(--surface-2); color: var(--text-2); }
.tag.sec { background: color-mix(in srgb, var(--sec) 14%, transparent); color: var(--sec); }

/* ===== Кнопки ===== */
.btn { white-space: nowrap; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); font-weight: 550; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn-sm { height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); color: var(--accent); font-weight: 600; font-size: 13.5px; flex: none; }
.fab {
  position: fixed; right: 16px; bottom: 84px; z-index: 6; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 30px; font-weight: 300; box-shadow: var(--shadow);
  display: grid; place-items: center;
}
@media (min-width: 900px) { .fab { bottom: 32px; right: max(32px, calc((100vw - 1120px) / 2)); } }

/* ===== Раскрытая строка ===== */
.expand { position: relative; padding: 4px 16px 14px 64px; background: var(--surface); }
.expand dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; }
.expand dt { color: var(--text-2); white-space: nowrap; }
.expand dd { margin: 0; text-align: right; }
.expand .items { margin: 0 0 12px; font-size: 13.5px; display: grid; gap: 4px; }
.expand .items div { display: flex; justify-content: space-between; gap: 12px; }
.actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.actions .btn { min-width: 48px; }

/* ===== Шторка (телефон) / окно (компьютер) ===== */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.38); display: none; }
.backdrop.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--surface);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow); padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow: auto;
}
.sheet .grip { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 2px; font-size: 18px; }
.sheet .subtitle { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-2); }
.field .input {
  min-height: 48px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center;
  justify-content: space-between; gap: 8px; padding: 0 14px; font-size: 16px;
}
.field .hint { font-size: 12.5px; color: var(--text-2); }
.sheet .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.sheet .buttons .btn { height: 48px; border-radius: 14px; font-size: 16px; }
@media (min-width: 900px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 440px; border-radius: 20px; padding: 20px 24px 24px; }
  .sheet .grip { display: none; }
}

/* ===== Пустое состояние и скелетон ===== */
.empty-state { padding: 24px 16px; text-align: center; color: var(--text-2); font-size: 14px; }
.empty-state .em-title { color: var(--text); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.empty-state .btn { margin-top: 12px; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 50%, var(--surface)) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk 1.4s infinite linear; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.note { font-size: 12.5px; color: var(--text-2); margin: 8px 4px 0; }

/* ===== Графики (в макете — SVG; на сайте — Chart.js с теми же правилами) ===== */
.chart { display: block; width: 100%; overflow: visible; }
.chart .raw { fill: var(--sec); opacity: 0.28; }
.chart .line { fill: none; stroke: var(--sec); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--sec); opacity: 0.10; }
.chart .goal { stroke: var(--text-3); stroke-width: 1.2; stroke-dasharray: 4 4; fill: none; }
.chart .zero { stroke: var(--line); stroke-width: 1; }
.chart .lbl { fill: var(--text-2); font-size: 11px; font-family: var(--font); }
.chart .lbl-strong { fill: var(--text); font-size: 12px; font-weight: 600; font-family: var(--font); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Режим снимка во всю высоту: закреплённые панели — у нижнего края страницы */
html.shot body { position: relative; min-height: 100vh; }
html.shot .bottombar, html.shot .totals-bar, html.shot .fab { position: absolute; }
html.shot .fab { bottom: 84px; }
