/* Heaven — личный журнал тела и привычек.
   Шрифт Onest, цветная навигация; палитра по умолчанию — shadcn slate + blue,
   варианты (zinc, violet, хвоя) — data-palette; янтарь — бегунок весов (фирменный приём).  */

@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-cyrillic-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===== Общие токены (состояния, янтарь, шрифт, размеры) ===== */
:root {
  --amber: #b86f0e; --amber-soft: #f6e5c6;
  --good: #1d7a4b; --good-soft: #dcefe2; --warn: #9a5a07; --warn-soft: #f6e6c8;
  --bad: #b2362d; --bad-soft: #f7dcd8; --info: #2c5d98;
  --lapse: #f6e7a6; --lapse-strong: #e2c75a; --lapse-ink: #6f5a10;
  --radius: 12px; --radius-sm: 8px;
  --font: "Onest", "Segoe UI", system-ui, sans-serif;
  --step--1: .8125rem; --step-0: .9375rem; --step-1: 1.0625rem; --step-2: 1.25rem; --step-3: 1.625rem; --step-4: 2rem;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --amber: #e7aa45; --amber-soft: #3a2c12;
    --good: #5cc48e; --good-soft: #15301f; --warn: #e3a646; --warn-soft: #362812;
    --bad: #f0806f; --bad-soft: #3a1c18; --info: #86abe6;
    --lapse: #3a3417; --lapse-strong: #a8923b; --lapse-ink: #e6d38a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --amber: #e7aa45; --amber-soft: #3a2c12;
  --good: #5cc48e; --good-soft: #15301f; --warn: #e3a646; --warn-soft: #362812;
  --bad: #f0806f; --bad-soft: #3a1c18; --info: #86abe6;
  --lapse: #3a3417; --lapse-strong: #a8923b; --lapse-ink: #e6d38a;
  color-scheme: dark;
}

/* ===== Палитры: синяя (shadcn slate + blue) по умолчанию, остальные — в Настройках ===== */
:root {
  --ground: #f8fafc;
  --surface: #ffffff;
  --sunken: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --rail: #0f172a;
  --rail-2: #1e293b;
  --rail-ink: #f1f5f9;
  --rail-muted: #94a3b8;
  --rail-active: #60a5fa;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #dbeafe;
  --focus: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #020817;
    --surface: #0b1222;
    --sunken: #131c2e;
    --line: #1e293b;
    --line-strong: #334155;
    --ink: #f1f5f9;
    --ink-2: #cbd5e1;
    --muted: #94a3b8;
    --rail: #0f172a;
    --rail-2: #1e293b;
    --rail-ink: #f1f5f9;
    --rail-muted: #94a3b8;
    --rail-active: #60a5fa;
    --accent: #3b82f6;
    --accent-ink: #0b1222;
    --accent-soft: #172554;
    --focus: #3b82f6;
  }
}
:root[data-theme="dark"] {
  --ground: #020817;
  --surface: #0b1222;
  --sunken: #131c2e;
  --line: #1e293b;
  --line-strong: #334155;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --rail: #0f172a;
  --rail-2: #1e293b;
  --rail-ink: #f1f5f9;
  --rail-muted: #94a3b8;
  --rail-active: #60a5fa;
  --accent: #3b82f6;
  --accent-ink: #0b1222;
  --accent-soft: #172554;
  --focus: #3b82f6;
}
:root[data-palette="zinc"] {
  --ground: #fafafa;
  --surface: #ffffff;
  --sunken: #f4f4f5;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --ink: #09090b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --rail: #18181b;
  --rail-2: #27272a;
  --rail-ink: #fafafa;
  --rail-muted: #a1a1aa;
  --rail-active: #fafafa;
  --accent: #18181b;
  --accent-ink: #fafafa;
  --accent-soft: #f4f4f5;
  --focus: #18181b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="zinc"] {
    --ground: #09090b;
    --surface: #111113;
    --sunken: #18181b;
    --line: #27272a;
    --line-strong: #3f3f46;
    --ink: #fafafa;
    --ink-2: #d4d4d8;
    --muted: #a1a1aa;
    --rail: #0f0f11;
    --rail-2: #27272a;
    --rail-ink: #fafafa;
    --rail-muted: #a1a1aa;
    --rail-active: #fafafa;
    --accent: #fafafa;
    --accent-ink: #18181b;
    --accent-soft: #27272a;
    --focus: #d4d4d8;
  }
}
:root[data-palette="zinc"][data-theme="dark"] {
  --ground: #09090b;
  --surface: #111113;
  --sunken: #18181b;
  --line: #27272a;
  --line-strong: #3f3f46;
  --ink: #fafafa;
  --ink-2: #d4d4d8;
  --muted: #a1a1aa;
  --rail: #0f0f11;
  --rail-2: #27272a;
  --rail-ink: #fafafa;
  --rail-muted: #a1a1aa;
  --rail-active: #fafafa;
  --accent: #fafafa;
  --accent-ink: #18181b;
  --accent-soft: #27272a;
  --focus: #d4d4d8;
}
:root[data-palette="violet"] {
  --ground: #f8f7fc;
  --surface: #ffffff;
  --sunken: #f1effa;
  --line: #e6e3f3;
  --line-strong: #cfcae6;
  --ink: #17132b;
  --ink-2: #3b3554;
  --muted: #655f7d;
  --rail: #1e1538;
  --rail-2: #2e2252;
  --rail-ink: #f1edff;
  --rail-muted: #b3a8d9;
  --rail-active: #c4b5fd;
  --accent: #6d28d9;
  --accent-ink: #ffffff;
  --accent-soft: #ede9fe;
  --focus: #6d28d9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="violet"] {
    --ground: #0c0a16;
    --surface: #131022;
    --sunken: #1b1730;
    --line: #262040;
    --line-strong: #372e5a;
    --ink: #f1edff;
    --ink-2: #d2cbe9;
    --muted: #a49cc3;
    --rail: #120e22;
    --rail-2: #241c42;
    --rail-ink: #f1edff;
    --rail-muted: #a49cc3;
    --rail-active: #c4b5fd;
    --accent: #8b5cf6;
    --accent-ink: #0c0a16;
    --accent-soft: #2e1f5e;
    --focus: #a78bfa;
  }
}
:root[data-palette="violet"][data-theme="dark"] {
  --ground: #0c0a16;
  --surface: #131022;
  --sunken: #1b1730;
  --line: #262040;
  --line-strong: #372e5a;
  --ink: #f1edff;
  --ink-2: #d2cbe9;
  --muted: #a49cc3;
  --rail: #120e22;
  --rail-2: #241c42;
  --rail-ink: #f1edff;
  --rail-muted: #a49cc3;
  --rail-active: #c4b5fd;
  --accent: #8b5cf6;
  --accent-ink: #0c0a16;
  --accent-soft: #2e1f5e;
  --focus: #a78bfa;
}
:root[data-palette="spruce"] {
  --ground: #f5f2ea;
  --surface: #fffdf8;
  --sunken: #ede8dc;
  --line: #ddd6c7;
  --line-strong: #c9c0ad;
  --ink: #1b221f;
  --ink-2: #3b4541;
  --muted: #5d6762;
  --rail: #143a30;
  --rail-2: #1b4a3d;
  --rail-ink: #e4efe9;
  --rail-muted: #a9c6ba;
  --rail-active: #f1c46b;
  --accent: #1d6b54;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe3;
  --focus: #1d6b54;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="spruce"] {
    --ground: #0e1311;
    --surface: #151c19;
    --sunken: #1b2420;
    --line: #26312c;
    --line-strong: #34433c;
    --ink: #e8eee9;
    --ink-2: #c3cdc8;
    --muted: #95a39c;
    --rail: #0a1f19;
    --rail-2: #12302a;
    --rail-ink: #dfece6;
    --rail-muted: #8fb0a3;
    --rail-active: #f1c46b;
    --accent: #4dbb93;
    --accent-ink: #062018;
    --accent-soft: #173229;
    --focus: #4dbb93;
  }
}
:root[data-palette="spruce"][data-theme="dark"] {
  --ground: #0e1311;
  --surface: #151c19;
  --sunken: #1b2420;
  --line: #26312c;
  --line-strong: #34433c;
  --ink: #e8eee9;
  --ink-2: #c3cdc8;
  --muted: #95a39c;
  --rail: #0a1f19;
  --rail-2: #12302a;
  --rail-ink: #dfece6;
  --rail-muted: #8fb0a3;
  --rail-active: #f1c46b;
  --accent: #4dbb93;
  --accent-ink: #062018;
  --accent-soft: #173229;
  --focus: #4dbb93;
}

/* ===== База ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body { background: var(--ground); color: var(--ink); font: 400 var(--step-0)/1.5 var(--font); -webkit-font-smoothing: antialiased; caret-color: var(--accent); }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
svg { display: block; }
::selection { background: var(--amber-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num, .mono, td, .value, .big-num { font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); } .info { color: var(--info); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== Каркас: хвойная навигация + бумага ===== */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 22px 12px 16px; background: var(--rail); color: var(--rail-ink); }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 22px; font-weight: 700; font-size: var(--step-1); letter-spacing: -.01em; }
.brand .mark { width: 9px; height: 9px; border-radius: 50%; background: var(--rail-active); align-self: center; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--rail-muted); font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: var(--rail-2); color: var(--rail-ink); text-decoration: none; }
.nav a.active { background: var(--rail-2); color: var(--rail-ink); box-shadow: inset 2px 0 0 var(--rail-active); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.side .spacer { flex: 1; }
.side-foot { display: flex; gap: 6px; padding: 12px 4px 0; border-top: 1px solid var(--rail-2); }
.side-foot .btn, .side-foot .btn.ghost { color: var(--rail-muted); border-color: var(--rail-2); }
.side-foot .btn:hover { background: var(--rail-2); color: var(--rail-ink); }
.side :focus-visible, .topbar :focus-visible { outline-color: var(--rail-active); }

.main { min-width: 0; width: 100%; max-width: 1120px; padding: 30px 36px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: var(--step-4); font-weight: 700; letter-spacing: -.025em; line-height: 1.1; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* мобильная навигация: та же хвоя, полоса вкладок */
.topbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; gap: 2px; overflow-x: auto; padding: 8px 10px; background: var(--rail); scrollbar-width: none; }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar a { flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 8px; color: var(--rail-muted); font-weight: 500; white-space: nowrap; }
  .topbar a:hover { text-decoration: none; }
  .topbar a svg { width: 16px; height: 16px; }
  .topbar a.active { background: var(--rail-2); color: var(--rail-ink); box-shadow: inset 0 -2px 0 var(--rail-active); }
  .main { padding: 20px 16px 56px; }
  .page-head h1 { font-size: var(--step-3); }
}

/* ===== Сетки ===== */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1000px) { .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-kpi > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } .g-2, .g-3 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } .g-2.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.mt { margin-top: 16px; }

/* ===== Панели: бумага + волосяная линия, без теней и вложенности ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: var(--step-1); font-weight: 650; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.card-head h2 svg { width: 17px; height: 17px; color: var(--muted); }
.card-head .hint { color: var(--muted); font-size: var(--step--1); }

/* Сводка — одна строка журнала с делениями, а не россыпь одинаковых плиток */
.g-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
/* деления: линия справа и снизу у каждой ячейки, крайние уходят под рамку */
.g-kpi > .kpi { background: var(--surface); border: 0; border-radius: 0; padding: 14px 16px; margin: 0 -1px -1px 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi .label { color: var(--muted); font-size: var(--step--1); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .label svg { width: 14px; height: 14px; }
.kpi .value { font-size: var(--step-3); font-weight: 650; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.kpi .value small { font-size: var(--step--1); font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi .foot { margin-top: 4px; font-size: var(--step--1); color: var(--muted); }
.big-num { font-size: var(--step-3); font-weight: 650; letter-spacing: -.02em; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--step--1); font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* Предупреждения на «Сегодня» */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.alert { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); font-weight: 500; }
.alert svg { width: 18px; height: 18px; flex: none; color: var(--warn); }
.alert.bad { background: var(--bad-soft); }
.alert.bad svg { color: var(--bad); }
.alert a { margin-left: auto; white-space: nowrap; font-weight: 600; }

/* прогресс */
.progress { height: 6px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s var(--ease); }
.progress.good > i { background: var(--good); } .progress.warn > i { background: var(--warn); } .progress.bad > i { background: var(--bad); }
.meter { display: grid; gap: 7px; }
.meter .row { display: flex; justify-content: space-between; font-size: var(--step-0); }

/* ===== Фирменный приём: коромысло весов (старт → сейчас → цель) ===== */
.beam { position: relative; padding: 38px 8px 0; }
.beam-track { position: relative; height: 34px; border-bottom: 2px solid var(--ink-2); }
.beam-tick { position: absolute; bottom: 0; width: 1px; height: 8px; background: var(--line-strong); }
.beam-tick.major { height: 15px; background: var(--ink-2); }
.beam-tick span { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.beam-done { position: absolute; bottom: -2px; height: 4px; background: var(--good); border-radius: 2px; }
.beam-mark { position: absolute; bottom: -2px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.beam-mark i { width: 2px; height: 22px; background: currentColor; }
.beam-mark.goal i { width: 3px; height: 26px; border-radius: 2px; }
.beam-mark.start { color: var(--muted); }
.beam-mark.goal { color: var(--good); }
.beam-rider { position: absolute; bottom: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; transition: left .5s var(--ease); }
.beam-rider b { font-size: var(--step-2); font-weight: 700; color: var(--ink); margin-bottom: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.beam-rider i { width: 14px; height: 12px; background: var(--amber); clip-path: polygon(50% 100%, 0 0, 100% 0); }
.beam-legend { display: flex; justify-content: space-between; gap: 6px 16px; margin-top: 44px; color: var(--muted); font-size: var(--step--1); flex-wrap: wrap; }
.beam-legend b { color: var(--ink); font-weight: 600; }

/* ===== Формы ===== */
.form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.grow { flex: 1 1 180px; }
.field label { font-size: var(--step--1); color: var(--muted); font-weight: 500; }
.field.w-s { width: 100px; } .field.w-m { width: 156px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
input[type="file"] { padding: 7px; }
textarea { resize: vertical; min-height: 70px; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.actions input[type="date"] { width: auto; }

.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease), filter .15s var(--ease); }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .55; cursor: progress; filter: none; }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink); filter: none; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: var(--step--1); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }
.icon-btn svg { width: 15px; height: 15px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: 9px; }
.seg button { font: inherit; font-size: var(--step--1); font-weight: 600; padding: 5px 11px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease); }
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ===== Списки и таблицы ===== */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .date { width: 52px; flex: none; color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.item .body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .title { font-weight: 600; }
.item .meta { color: var(--muted); font-size: var(--step--1); }
.item .side-val { color: var(--ink-2); font-size: var(--step--1); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.scroll { max-height: 440px; overflow-y: auto; margin-right: -8px; padding-right: 8px; }
table { width: 100%; border-collapse: collapse; font-size: var(--step-0); }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: var(--step--1); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; background: var(--surface); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--sunken); }
td.r, th.r { text-align: right; }
.group-title { color: var(--muted); font-size: var(--step--1); font-weight: 600; margin-top: 18px; padding-bottom: 4px; border-bottom: 1px solid var(--line-strong); }
.empty { color: var(--muted); padding: 22px 0; text-align: center; }

/* ===== Календарь привычки: месяц + год ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-head h2 { font-size: var(--step-2); font-weight: 650; letter-spacing: -.015em; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 6px; }
.cal-dow { text-align: center; font-size: var(--step--1); font-weight: 600; color: var(--muted); padding-bottom: 6px; }
.cal-dow.we { color: var(--ink-2); }
.cal-day { font: inherit; position: relative; height: 58px; border: 0; background: transparent; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-radius: 10px; margin: 0 3px; transition: background .15s var(--ease); }
.cal-day.out { cursor: default; }
.cal-day .n { font-size: var(--step-0); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-day .v { font-size: 11px; font-weight: 650; }
.cal-day:not(.out):not(:disabled):hover { box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.cal-day.none { color: var(--muted); }
.cal-day.clean { background: var(--good-soft); color: var(--good); }
.cal-day.l1 { background: var(--warn-soft); color: var(--warn); }
.cal-day.l2 { background: var(--bad-soft); color: var(--bad); }
.cal-day.est { box-shadow: inset 0 0 0 1px currentColor; }
/* срыв — сплошная жёлтая лента без цифр */
.cal-day.lapse { background: var(--lapse); color: var(--lapse-ink); border-radius: 0; margin: 0; }
.cal-day.lapse.ls { border-top-left-radius: 10px; border-bottom-left-radius: 10px; margin-left: 3px; }
.cal-day.lapse.le { border-top-right-radius: 10px; border-bottom-right-radius: 10px; margin-right: 3px; }
.cal-day.future { color: var(--muted); opacity: .45; cursor: default; }
.cal-day.today .n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--amber); color: #1b1300; }
.cal-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--step--1); color: var(--ink-2); }
.cal-foot b { color: var(--ink); }
.cal-foot .muted { margin-left: auto; }
@media (max-width: 560px) { .cal-day { height: 46px; margin: 0 1px; } .cal-day.lapse.ls { margin-left: 1px; } .cal-day.lapse.le { margin-right: 1px; } .cal-day .v { font-size: 10px; } .cal-foot .muted { margin-left: 0; } }

.year { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px 12px; }
.mini { font: inherit; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 8px; cursor: pointer; text-align: left; color: var(--ink); transition: border-color .15s var(--ease), background .15s var(--ease); }
.mini:hover { background: var(--sunken); }
.mini.on { border-color: var(--line-strong); background: var(--sunken); }
.mini-t { display: block; font-size: var(--step--1); font-weight: 600; margin-bottom: 6px; text-transform: capitalize; }
.mini-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mini-g i { aspect-ratio: 1; border-radius: 2px; background: var(--sunken); }
.mini-g i.o { background: transparent; }
.mini-g i.clean { background: var(--good); opacity: .55; }
.mini-g i.l1 { background: var(--warn); }
.mini-g i.l2 { background: var(--bad); }
.mini-g i.lapse { background: var(--lapse-strong); }
.mini-g i.none { background: var(--sunken); }
.mini-g i.future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--step--1); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend .clean { background: var(--good); opacity: .55; } .legend .l1 { background: var(--warn); } .legend .l2 { background: var(--bad); } .legend .lapse { background: var(--lapse-strong); } .legend .none { background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ===== Графики ===== */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .target { stroke: var(--good); stroke-dasharray: 4 5; stroke-width: 1.5; }
.chart .raw { fill: none; stroke: var(--muted); stroke-width: 1.2; opacity: .55; }
.chart .avg { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); opacity: .6; }
.chart .dot { fill: var(--surface); stroke: var(--muted); stroke-width: 1.3; }
.chart .cursor { stroke: var(--line-strong); stroke-width: 1; }
.chart .cursor-dot { fill: var(--amber); stroke: var(--surface); stroke-width: 2; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 7px; padding: 6px 9px; font-size: var(--step--1); white-space: nowrap; transform: translate(-50%, -115%); font-variant-numeric: tabular-nums; }
.tip .muted { color: inherit; opacity: .75; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: var(--step--1); color: var(--muted); }
.bars .bar i { display: block; width: 100%; max-width: 44px; border-radius: 5px 5px 2px 2px; background: var(--accent); min-height: 3px; }
.bars .bar:last-child i { background: var(--amber); }
.bars .bar b { color: var(--ink); font-size: var(--step-0); font-variant-numeric: tabular-nums; }

/* ===== Чат ===== */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 58vh; overflow-y: auto; padding: 4px 2px 8px; }
.msg { max-width: min(80%, 68ch); padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--sunken); border-bottom-left-radius: 4px; }
.msg.err { color: var(--bad); }

/* ===== Диалоги и уведомления ===== */
dialog { margin: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 18px 48px rgba(10, 20, 15, .28); }
dialog::backdrop { background: rgba(8, 14, 11, .55); }
dialog h3 { font-size: var(--step-2); margin-bottom: 6px; letter-spacing: -.01em; }
dialog p { color: var(--ink-2); margin-bottom: 14px; }
dialog .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog .stack { gap: 12px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 9px; font-weight: 500; animation: toast-in .2s var(--ease); max-width: 380px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.err { background: var(--bad); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.skeleton { height: 96px; border-radius: var(--radius); background: var(--sunken); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ===== Вход ===== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-side { position: relative; background: var(--rail); overflow: hidden; }
/* шкала весов: деления каждые 24px, крупные каждые 120px, янтарный бегунок */
.auth-side::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 34px; transform: translateY(-50%);
  background:
    linear-gradient(var(--rail-ink), var(--rail-ink)) left bottom / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, rgba(228, 239, 233, .5) 0 1px, transparent 1px 120px) left bottom / 100% 18px no-repeat,
    repeating-linear-gradient(90deg, rgba(228, 239, 233, .22) 0 1px, transparent 1px 24px) left bottom / 100% 9px no-repeat; opacity: .55; }
.auth-side::after { content: ""; position: absolute; left: 62%; top: calc(50% - 30px); width: 18px; height: 15px; background: var(--rail-active); clip-path: polygon(50% 100%, 0 0, 100% 0); }
.auth-main { display: grid; place-items: center; padding: 24px 16px; background: var(--ground); }
.auth-box { width: min(340px, 100%); }
.auth-box .mark { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); margin-bottom: 22px; }
.auth-box h1 { font-size: var(--step-4); font-weight: 700; margin-bottom: 22px; letter-spacing: -.025em; }
.auth-box .field { margin-bottom: 14px; }
.auth-box .btn { width: 100%; margin-top: 6px; padding: 11px; }
.auth-err { color: var(--bad); font-size: var(--step--1); margin-top: 12px; min-height: 18px; }
@media (max-width: 720px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ===== Оформление: выбор палитры ===== */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.swatch { font: inherit; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; transition: border-color .15s var(--ease); }
.swatch:hover { border-color: var(--muted); }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch b { display: block; font-weight: 600; }
.swatch small { display: block; color: var(--muted); font-size: var(--step--1); }
.sw { display: flex; flex: none; }
.sw i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); }
.sw i + i { margin-left: -8px; }

/* ===== Раскладка «inset», как в shadcn dashboard-01: контент — скруглённая вставка на фоне панели ===== */
@media (min-width: 861px) {
  .app { background: var(--rail); }
  .side { background: transparent; }
  .main { background: var(--ground); margin: 8px 8px 8px 0; border-radius: 14px; max-width: none; min-height: calc(100vh - 16px);
          box-shadow: 0 1px 3px rgba(0, 0, 0, .12); padding: 30px clamp(20px, 3vw, 44px) 72px; }
  .main > * { max-width: 1120px; }
}
