/* Палитра в стиле Claude: тёплый светлый по умолчанию, тёплый тёмный — по выбору. */
:root {
  --bg: #F5F4ED; --surface: #FFFFFF; --surface-2: #F0EEE6; --line: #E3E0D6; --text: #1F1E1D; --muted: #6B6963;
  --accent: #B4532F; --accent-deco: #C96442; --accent-soft: #F7E9E1; --on-accent: #FFFFFF;
  --ok: #2E7048; --ok-soft: #E4F1E7; --warn: #8C5A00; --warn-soft: #FBEFD6;
  --bad: #B42318; --bad-soft: #FBE7E4; --nodata: #7B7870; --nodata-soft: #EEECE5; --demo: #7A4FB5; --demo-soft: #EFE8F8;
  --radius: 12px; --shadow: 0 1px 2px rgba(31, 30, 29, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Tiempos Headline", "Copernicus", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #262624; --surface: #30302E; --surface-2: #1F1E1D; --line: #44433F; --text: #F5F4ED; --muted: #AAA79E;
  --accent: #E6906E; --accent-deco: #D97757; --accent-soft: #3D2E27; --on-accent: #1F1E1D;
  --ok: #7FC99A; --ok-soft: #22352A; --warn: #E8B864; --warn-soft: #3A3020;
  --bad: #F09088; --bad-soft: #3E2524; --nodata: #9E9B92; --nodata-soft: #37362F; --demo: #C9A8F2; --demo-soft: #332A42;
  --shadow: none; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #262624; --surface: #30302E; --surface-2: #1F1E1D; --line: #44433F; --text: #F5F4ED; --muted: #AAA79E;
    --accent: #E6906E; --accent-deco: #D97757; --accent-soft: #3D2E27; --on-accent: #1F1E1D;
    --ok: #7FC99A; --ok-soft: #22352A; --warn: #E8B864; --warn-soft: #3A3020;
    --bad: #F09088; --bad-soft: #3E2524; --nodata: #9E9B92; --nodata-soft: #37362F; --demo: #C9A8F2; --demo-soft: #332A42;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-family: var(--serif); font-weight: 500; font-size: 1.7rem; margin: 0 0 .75rem; letter-spacing: -.01em; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.boot { padding: 2rem; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.nodata { color: var(--nodata); font-style: italic; }

/* Раскладка */
.layout { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: auto auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--serif); font-size: 1.1rem; color: var(--text); text-decoration: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
.who { color: var(--muted); font-size: .9rem; }
.mode select { font-size: .9rem; }
#banner { grid-column: 1 / -1; }
.banner { padding: .45rem 1rem; font-size: .9rem; border-bottom: 1px solid var(--line); }
.banner.demo { background: var(--demo-soft); color: var(--demo); font-weight: 600; }
.banner.info { background: var(--surface-2); color: var(--muted); }
.nav { background: var(--surface); border-right: 1px solid var(--line); padding: .75rem .5rem; display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); text-decoration: none; padding: .45rem .7rem; border-radius: 8px; font-size: .94rem; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { padding: 1.25rem 1.5rem 3rem; min-width: 0; outline: none; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .nav { display: none; position: fixed; inset: 52px 0 auto 0; z-index: 30; max-height: calc(100vh - 52px); overflow: auto; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  body.nav-open .nav { display: flex; }
  main { padding: 1rem 16px 3rem; }
  .who { display: none; }
}

/* Карточки и сетки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }
.page-head .muted { font-size: .9rem; }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; text-decoration: none; color: var(--text); display: block; box-shadow: var(--shadow); }
.kpi:hover { border-color: var(--accent); }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.35rem; font-weight: 650; margin: .15rem 0; }
.kpi .value .nodata { font-size: 1rem; }
.kpi .note { font-size: .82rem; color: var(--muted); }
.kpi.bad { border-left: 4px solid var(--bad); }
.kpi.warn { border-left: 4px solid var(--warn); }
.kpi.ok { border-left: 4px solid var(--ok); }
.kpi.nodata-state { border-left: 4px solid var(--nodata); }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.nodata { background: var(--nodata-soft); color: var(--nodata); font-style: normal; }
.badge.demo { background: var(--demo-soft); color: var(--demo); }

.callout { background: var(--surface-2); border-left: 4px solid var(--accent); padding: .6rem .8rem; border-radius: 6px; margin: .5rem 0; }
.callout.error { border-color: var(--bad); background: var(--bad-soft); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.ok { border-color: var(--ok); background: var(--ok-soft); }
.empty { color: var(--muted); padding: .75rem 0; }

/* Списки на главном */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a { text-decoration: none; }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: .87rem; }
.prio { counter-reset: p; }
.prio li { padding-left: 2rem; position: relative; }
.prio li::before { counter-increment: p; content: counter(p); position: absolute; left: 0; top: .55rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--accent-deco); color: var(--on-accent); font-weight: 700; display: grid; place-items: center; font-size: .85rem; }
.flow { display: flex; flex-wrap: wrap; gap: .4rem; align-items: stretch; }
.flow a { flex: 1 1 140px; background: var(--surface-2); border-radius: 8px; padding: .55rem .7rem; text-decoration: none; color: var(--text); position: relative; }
.flow a .label { font-size: .8rem; color: var(--muted); display: block; }
.flow .arrow { align-self: center; color: var(--muted); }

/* Таблицы */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; background: var(--surface-2); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover, tr.clickable:focus { background: var(--surface-2); outline: none; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
tr.sub td { color: var(--muted); }
tr.overdue td:first-child { border-left: 3px solid var(--bad); }
tr.error td { background: var(--bad-soft); }
tr.dup td { color: var(--muted); }
.pnl td:first-child { white-space: nowrap; }
.pnl tr.indent td:first-child { padding-left: 1.4rem; color: var(--muted); }

/* Формы */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem .9rem; }
.field { display: flex; flex-direction: column; gap: .2rem; font-size: .88rem; }
.field > span { color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.field.check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: .5rem; }
.req { color: var(--bad); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: .42rem .55rem; min-width: 0; width: 100%; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.actions { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .6rem; }
.toolbar .grow { flex: 1; }
.form-error { color: var(--bad); min-height: 1.2em; margin: 0; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: .45rem .85rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { font: inherit; font-size: 1.3rem; line-height: 1; background: none; border: 0; color: var(--text); cursor: pointer; padding: .25rem .45rem; border-radius: 6px; }

/* Вкладки */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: .5rem .75rem; cursor: pointer; color: var(--muted); }
.tabs button.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Боковая карточка */
.shade { position: fixed; inset: 0; background: rgba(10, 14, 20, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 50; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0, 0, 0, .15); }
.drawer.wide { width: min(880px, 100vw); }
.drawer header { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.drawer header h2 { margin: 0; flex: 1; font-size: 1.05rem; }
.drawer-body { padding: 1rem; overflow: auto; flex: 1; }
.drawer .form { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .drawer .form { grid-template-columns: 1fr; } }
.history { padding-left: 1.2rem; font-size: .88rem; }
.history .reason { color: var(--warn); }
details.hist, details.explain { margin-top: 1rem; }
details summary { cursor: pointer; color: var(--accent); }
.explain p { color: var(--muted); font-size: .88rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; margin: .5rem 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: .4rem; } }

/* Карта бизнеса */
.map { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: .6rem; overflow-x: auto; padding-bottom: .5rem; }
.map .stage { background: var(--surface-2); border-radius: var(--radius); padding: .6rem; min-width: 0; }
.map .stage h3 { margin: 0 0 .5rem; font-size: .88rem; color: var(--muted); }
.proc { display: block; width: 100%; text-align: left; font: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .45rem; cursor: pointer; color: var(--text); }
.proc:hover { border-color: var(--accent); }
.proc .who { display: block; font-size: .82rem; }
.proc.problem { border-left: 4px solid var(--bad); }
.proc.ok { border-left: 4px solid var(--ok); }
.proc.nodata, .proc.notstarted { border-left: 4px solid var(--nodata); }

/* Прочее */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.log { font-size: .86rem; list-style: none; padding: 0; margin: 0; }
.log li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.log .step { font-weight: 600; margin-right: .4rem; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: .5rem; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; display: flex; flex-direction: column; gap: .75rem; box-shadow: var(--shadow); }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.pill-A { background: var(--accent); color: var(--on-accent); border-radius: 5px; padding: 0 .35rem; font-weight: 700; }
.pill-R { background: var(--ok-soft); color: var(--ok); border-radius: 5px; padding: 0 .35rem; font-weight: 700; }
.pill-C { background: var(--surface-2); color: var(--muted); border-radius: 5px; padding: 0 .35rem; font-weight: 700; }
.score-input { width: 3.2rem; text-align: center; }
.chart { width: 100%; height: auto; }
.chart .base { stroke: var(--accent); }
.chart .cautious { stroke: var(--warn); }
.chart .reserve { stroke: var(--bad); stroke-dasharray: 4 4; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: .3rem; }

/* Переключатель темы, подсказки, первые шаги, руководство */
.theme select, .mode select { font-size: .88rem; padding: .3rem .45rem; }
.hint { background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .95rem; margin-bottom: 1rem; }
.hint summary { color: var(--text); font-weight: 600; list-style: none; cursor: pointer; }
.hint summary::-webkit-details-marker { display: none; }
.hint summary::before { content: "?"; display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--accent-deco); color: var(--on-accent); font-size: .8rem; margin-right: .5rem; }
.hint ol, .hint ul { margin: .5rem 0 .2rem; padding-left: 1.3rem; }
.hint li { margin: .25rem 0; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .6rem; align-items: start; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .mark { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; border: 2px solid var(--line); color: var(--muted); }
.steps li.done .mark { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }
.steps li.done .title { color: var(--muted); text-decoration: line-through; }
.steps li.next .mark { border-color: var(--accent-deco); color: var(--accent); }
.steps .title { font-weight: 600; }
.steps .sub { color: var(--muted); font-size: .88rem; }
.progress { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; color: var(--muted); font-size: .9rem; }
.progress .bar { flex: 1; }
.progress .bar > span { background: var(--ok); }
.guide h2 { margin-top: .25rem; }
.guide h3 { font-family: var(--serif); font-weight: 500; font-size: 1.05rem; }
.guide p, .guide li { max-width: 72ch; }
.guide li { margin: .3rem 0; }
.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.toc a { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; text-decoration: none; color: var(--text); font-size: .9rem; }
.toc a:hover { border-color: var(--accent-deco); }
pre.copy { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: .8rem; font-size: .88rem; }
