/* Ремастер: токены и компоненты. Источник — docs/design/MASTER.md. */
:root {
  --bg: #F6F5F9; --surface: #FFFFFF; --surface-2: #EFEDF4; --ink: #1F1D2B; --muted: #5E5A6E; --line: #E7E5EE;
  --accent: #8E2F6E; --accent-text: #7E2862; --accent-soft: #F3E4EE; --on-accent: #FFFFFF;
  --good: #157A4C; --good-soft: #E3F4EA; --warn: #9A5B00; --warn-soft: #FFF1DB;
  --chat: #DCF7C5; --chat-ink: #1D2A16;
  --font: "Onest", "Segoe UI", Roboto, Arial, sans-serif;
  --fs-num: 40px; --fs-h1: clamp(2rem, 5.2vw, 2.75rem); --fs-h2: 1.5rem; --fs-h3: 1.125rem; --fs-body: 1rem; --fs-small: .875rem; --fs-cap: .8125rem;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --r-card: 22px; --r-ctl: 14px; --r-chip: 999px;
  --shadow: 0 12px 32px -20px rgba(31, 29, 43, .45);
  --ease: cubic-bezier(.2, .8, .2, 1); --t-fast: 160ms; --t: 240ms;
  --wrap: 72rem; --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17151F; --surface: #211E2B; --surface-2: #2A2636; --ink: #F2EFF7; --muted: #A9A4B8; --line: #322E3F;
    --accent: #D679B4; --accent-text: #D679B4; --accent-soft: #3A2233; --on-accent: #17151F;
    --good: #4FD198; --good-soft: #17352A; --warn: #F2B455; --warn-soft: #3A2C14;
    --chat: #23402A; --chat-ink: #E5F6DA; --shadow: 0 12px 32px -20px rgba(0, 0, 0, .7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17151F; --surface: #211E2B; --surface-2: #2A2636; --ink: #F2EFF7; --muted: #A9A4B8; --line: #322E3F;
  --accent: #D679B4; --accent-text: #D679B4; --accent-soft: #3A2233; --on-accent: #17151F;
  --good: #4FD198; --good-soft: #17352A; --warn: #F2B455; --warn-soft: #3A2C14;
  --chat: #23402A; --chat-ink: #E5F6DA; --shadow: 0 12px 32px -20px rgba(0, 0, 0, .7); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.hp { position: absolute; left: -9999px; }  /* ловушка для ботов в формах */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs-body)/1.5 var(--font); }
a { color: var(--accent-text); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -.015em; }
h2 { font-size: var(--fs-h2); font-weight: 700; }
h3 { font-size: var(--fs-h3); font-weight: 700; }
p { margin: 0; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.muted { color: var(--muted); }
.cap { font-size: var(--fs-cap); color: var(--muted); font-weight: 500; }
.small { font-size: var(--fs-small); }
.num { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s5); }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: var(--s4); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--s4); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 12px 20px;
  border: 0; border-radius: var(--r-ctl); background: var(--accent); color: var(--on-accent); font: 700 var(--fs-body) var(--font);
  text-decoration: none; cursor: pointer; transition: transform var(--t-fast) var(--ease), background var(--t) var(--ease); }
.btn:hover { background: var(--accent-text); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--accent-soft); color: var(--accent-text); }
.btn.soft:hover { background: var(--accent-soft); filter: brightness(.97); }
.btn.danger { background: transparent; color: var(--accent-text); box-shadow: inset 0 0 0 1px currentColor; }
.btn.sm { min-height: 36px; padding: 8px 14px; font-size: var(--fs-small); }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* формы */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: var(--fs-small); }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink); font: 400 var(--fs-body) var(--font); }
textarea { min-height: 120px; line-height: 1.5; resize: vertical; }
.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
.check input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
.hint { font-size: var(--fs-small); color: var(--muted); font-weight: 400; }

/* карточки и метрики */
.card { background: var(--surface); border-radius: var(--r-card); padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card.tap { box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: transform var(--t-fast) var(--ease); }
.card.tap:active { transform: scale(.99); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.metric { font-size: var(--fs-num); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.metric.md { font-size: 28px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-chip); font-size: var(--fs-cap); font-weight: 500;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.example { position: relative; }
.example::after { content: "пример"; position: absolute; top: var(--s4); right: var(--s4); font-size: var(--fs-cap); font-weight: 500;
  padding: 2px 10px; border-radius: var(--r-chip); background: var(--warn-soft); color: var(--warn); }
.example .dim { opacity: .55; }
.empty { text-align: left; color: var(--muted); }

/* действия дня */
.todo { display: flex; flex-direction: column; gap: var(--s2); }
.todo-item { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s3); align-items: start; background: var(--surface);
  border-radius: var(--r-card); padding: var(--s4); }
.todo-item .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.todo-item .ico.good { background: var(--good-soft); color: var(--good); }
.todo-item .ico.warn { background: var(--warn-soft); color: var(--warn); }
.todo-item .body { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.todo-item .body p { color: var(--muted); font-size: var(--fs-small); }
.ico svg { width: 22px; height: 22px; }

/* графики */
.spark { width: 100%; height: 56px; display: block; }
.spark .area { fill: var(--good-soft); }
.spark .line { fill: none; stroke: var(--good); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark .dot { fill: var(--good); }
.spark.accent .area { fill: var(--accent-soft); }
.spark.accent .line { stroke: var(--accent); }
.spark.accent .dot { fill: var(--accent); }
.bars { display: flex; flex-direction: column; gap: var(--s3); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s3); align-items: baseline; text-decoration: none; color: inherit; }
.bar-row .track { grid-column: 1 / -1; height: 10px; border-radius: var(--r-chip); background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: var(--r-chip); background: var(--accent); transform-origin: left; }
.bar-row .fill.good { background: var(--good); }
.bar-row .fill.warn { background: var(--warn); }
.bar-row .fill.mute { background: var(--muted); opacity: .45; }
.compare { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s2) var(--s3); align-items: center; font-size: var(--fs-small); }
.compare .track { height: 12px; border-radius: var(--r-chip); background: var(--surface-2); overflow: hidden; }
.compare .fill { height: 100%; border-radius: var(--r-chip); background: var(--good); }
.compare .fill.mute { background: var(--muted); opacity: .45; }

/* списки и таблицы */
.list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-card); overflow: hidden; }
.list > .li { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; padding: 14px var(--s4); border-top: 1px solid var(--line); min-width: 0; }
.list > .li:first-child { border-top: 0; }
.li .main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li .main b { font-weight: 500; }
.li .main span { color: var(--muted); font-size: var(--fs-small); overflow-wrap: anywhere; }
a.li { text-decoration: none; color: inherit; }
.table-box { overflow-x: auto; background: var(--surface); border-radius: var(--r-card); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-small); }
th, td { text-align: left; padding: 12px var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: var(--fs-cap); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips a { flex: none; padding: 8px 14px; border-radius: var(--r-chip); background: var(--surface); color: var(--ink); text-decoration: none;
  font-size: var(--fs-small); font-weight: 500; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.chips a.on { background: var(--ink); color: var(--bg); }
.chips a .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chips a.on .n { color: inherit; opacity: .7; }
details.more > summary { cursor: pointer; color: var(--accent-text); font-weight: 500; list-style: none; min-height: 44px; display: flex; align-items: center; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "↓"; margin-left: 8px; transition: transform var(--t) var(--ease); }
details.more[open] > summary::after { transform: rotate(180deg); }

/* сообщения */
.flash { border-radius: var(--r-ctl); padding: 14px var(--s4); background: var(--good-soft); color: var(--good); font-weight: 500; }
.flash.err { background: var(--warn-soft); color: var(--warn); }
.bubble { background: var(--chat); color: var(--chat-ink); border-radius: 16px 16px 6px 16px; padding: 12px 14px; font-size: var(--fs-small); white-space: pre-wrap; max-width: 34rem; }

/* оболочка приложения: на телефоне нижнее меню, на компьютере боковое */
.app { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.app-side { display: none; }
.app-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); }
.app-top .bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand i { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: var(--on-accent); font-style: normal; font-size: 15px; }
.app-main { padding-block: var(--s3) calc(var(--tabbar) + var(--s6) + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }
.tabbar { position: fixed; inset: auto 0 0; z-index: 6; background: var(--surface); box-shadow: 0 -1px 0 var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.tabbar a { min-height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent-text); }
.page-head { display: flex; flex-direction: column; gap: var(--s2); }
.page-head .sub { color: var(--muted); }
.banner { background: var(--ink); color: var(--bg); font-size: var(--fs-small); }
.banner .wrap { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 44px; flex-wrap: wrap; }
.banner button { background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 10px; padding: 6px 12px; font: inherit; cursor: pointer; }
.side-nav a { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 500; }
.side-nav a svg { width: 22px; height: 22px; flex: none; }
.side-nav a.on { background: var(--surface); color: var(--ink); }
.side-nav .sep { height: 1px; background: var(--line); margin: var(--s2) var(--s3); }

@media (min-width: 960px) {
  .app { grid-template-columns: 248px minmax(0, 1fr); }
  .app-side { display: flex; flex-direction: column; gap: var(--s4); position: sticky; top: 0; height: 100vh; padding: var(--s5) var(--s3); border-right: 1px solid var(--line); }
  .app-side .brand { padding: 0 var(--s3); }
  .app-top, .tabbar { display: none; }
  .app-main { padding-block: var(--s5) var(--s8); }
}

/* появление: один раз, сдвиг 12 px */
.rise { animation: rise var(--t) var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* путь до первого результата */
.steps-path { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.steps-path li { display: grid; grid-template-columns: 32px 1fr; gap: var(--s3); align-items: center; color: var(--muted); }
.steps-path .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-small); background: var(--surface-2); color: var(--muted); }
.steps-path .dot svg { width: 18px; height: 18px; }
.steps-path li.done { color: var(--ink); }
.steps-path li.done .dot { background: var(--good-soft); color: var(--good); }
.steps-path li.cur { color: var(--ink); font-weight: 500; }
.steps-path li.cur .dot { background: var(--accent); color: var(--on-accent); }
.potential { background: var(--surface-2); border-radius: var(--r-ctl); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.reco { box-shadow: inset 0 0 0 2px var(--accent); }

/* переключатель вместо галочки */
.switch { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 48px; min-height: 28px; height: 28px; padding: 0; border: 0; border-radius: 999px;
  background: var(--line); position: relative; cursor: pointer; transition: background var(--t) var(--ease); flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform var(--t) var(--ease); }
.switch input:checked { background: var(--good); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
