/* Дашборд штаба. Спокойная поверхность, скруглённые карточки с волосяной рамкой,
   мелкая серая подпись над крупным числом, зелёный — улучшение.
   Цвета — переменные: в Telegram их подменяет тема клиента (ui.js, applyTelegramTheme),
   в браузере — системная светлая или тёмная тема. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #101113;
  --muted: #6e7178;
  --accent: #2a78d6;
  --accent-text: #ffffff;

  --s-blue: #2a78d6;
  --s-green: #1baf7a;
  --s-orange: #eb6834;
  --s-violet: #6250d6;
  --s-grey: #9b9ca1;
  --good: #0ca30c;
  --good-text: #12813a;
  --bad-text: #c9372c;
  --warn-text: #a86400;

  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --sunken: color-mix(in srgb, var(--text) 6%, transparent);
  --s-pale: color-mix(in srgb, var(--text) 16%, transparent);
  --radius: 18px;
  --gap: 12px;
  --nav-height: 60px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1011;
    --surface: #17181a;
    --text: #f1f1ef;
    --muted: #9c9ea5;
    --accent: #4a94ee;
    --s-blue: #3987e5;
    --s-green: #199e70;
    --s-orange: #d95926;
    --s-violet: #9085e9;
    --s-grey: #7c7d84;
    --good-text: #4cc978;
    --bad-text: #f0837a;
    --warn-text: #e2a93b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1011;
  --surface: #17181a;
  --text: #f1f1ef;
  --muted: #9c9ea5;
  --accent: #4a94ee;
  --s-blue: #3987e5;
  --s-green: #199e70;
  --s-orange: #d95926;
  --s-violet: #9085e9;
  --s-grey: #7c7d84;
  --good-text: #4cc978;
  --bad-text: #f0837a;
  --warn-text: #e2a93b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; display: block; }

/* ───────────── Каркас ───────────── */

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(14px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)) 16px
    calc(var(--nav-height) + 28px + env(safe-area-inset-bottom, 0px));
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.brand { display: flex; flex-direction: column; flex: none; white-space: nowrap; }
.brand-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.brand-sub { font-size: 13px; color: var(--muted); min-height: 18px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  /* Разделов четыре, место делится поровну: каждый пункт — крупная зона нажатия во всю свою четверть. */
  display: flex; gap: 4px;
  padding: 5px 8px calc(5px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.nav-item {
  flex: 1 1 0; min-width: 0; min-height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 4px 2px; border-radius: 14px;
  font-size: 11.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.nav-item.is-active { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 11%, transparent); }

/* Вкладки раздела под заголовком: одна полоса на «План», «Деньги» и «Проекты». Если вкладки не помещаются,
   полоса прокручивается по горизонтали — от края до края экрана, без видимой линейки прокрутки. */
.section-tabs {
  margin: 0 -16px 14px; padding: 0 16px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  box-shadow: inset 0 -1px 0 var(--line);
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs .segmented { gap: 2px; width: max-content; min-width: 100%; }
.section-tabs .segment {
  flex: 1 0 auto; min-height: 44px; padding: 0 14px; border-radius: 0;
  font-size: 15px; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent;
}
.section-tabs .segment.is-active { background: none; font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }

.page { display: flex; flex-direction: column; gap: var(--gap); }
.columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.column { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.section { display: flex; flex-direction: column; gap: var(--gap); }
.center { display: flex; justify-content: center; padding-bottom: 8px; }

/* ───────────── Карточки и текст ───────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.label { font-size: 13px; color: var(--muted); }
.big {
  font-size: 30px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.12;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.big.is-empty { color: var(--muted); font-weight: 500; }
.big-small { font-size: 22px; }
.big-unit { font-size: 0.45em; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.sub { font-size: 13px; color: var(--muted); }
.quiet { font-size: 14px; color: var(--muted); }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.tone-good { color: var(--good-text); }
.tone-bad { color: var(--bad-text); }
.tone-warn { color: var(--warn-text); }
.notice { font-size: 13px; color: var(--muted); padding: 0 4px; }
.with-icon { display: inline-flex; align-items: center; gap: 4px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { flex-direction: row; align-items: center; justify-content: space-between; padding: 14px 16px; }
.tile-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-visual { flex: none; }

.pill {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: var(--sunken); color: var(--muted);
}
.pill-info { background: color-mix(in srgb, var(--s-blue) 14%, transparent); color: color-mix(in srgb, var(--s-blue) 70%, var(--text)); }
.pill-good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
.pill-warn { background: color-mix(in srgb, #eda100 18%, transparent); color: var(--warn-text); }
.pill-accent { background: var(--text); color: var(--bg); }

.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--s-grey); }
.dot-task { background: var(--s-blue); }
.dot-event { background: var(--s-green); }
.dot-done { background: var(--s-pale); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--sunken); font-size: 13px; font-weight: 500;
}
.btn-icon { width: 34px; padding: 0; }
.btn-accent { background: var(--accent); color: var(--accent-text); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.segmented { display: flex; gap: 4px; }
.segment {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 10px; border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.segment.is-active { background: var(--sunken); color: var(--text); }
.segment-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 2px; max-width: 620px; }
.empty-icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  background: var(--sunken); color: var(--muted); margin-bottom: 4px;
}
.empty-title { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.empty-text { color: var(--muted); }
.empty-how { font-size: 14px; padding: 12px 14px; border-radius: 12px; background: var(--sunken); }
.empty-how-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }

/* ───────────── Строки списков ───────────── */

.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; padding-top: 2px; }
.row:last-child { padding-bottom: 2px; }
.row-lead {
  flex: 0 0 44px; padding-top: 2px;
  font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.row-plain .row-lead { flex-basis: 52px; }
.row-lead.tone-bad { color: var(--bad-text); }
.row-lead.tone-warn { color: var(--warn-text); }
.row-lead-year, .row-lead-sub { display: block; font-size: 11.5px; font-weight: 400; }
.row-mark { flex: 0 0 24px; display: flex; justify-content: center; align-self: stretch; }
.row-bell { color: var(--muted); padding-top: 2px; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; color: var(--muted); }
.row-meta:empty { display: none; }
.row-value { flex: none; padding-top: 1px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.is-done .row-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--s-pale); }
.event-bar { width: 4px; min-height: 34px; border-radius: 2px; background: var(--s-green); }

.check {
  position: relative; flex: none; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.8px solid color-mix(in srgb, var(--text) 38%, transparent);
  color: transparent; transition: background 0.15s, border-color 0.15s;
}
.check::after { content: ""; position: absolute; inset: -10px; }
.check.is-done { background: var(--good); border-color: var(--good); color: #fff; cursor: default; }
.check.is-busy { border-color: var(--good); border-top-color: transparent; animation: spin 0.7s linear infinite; }
.check.is-agent { border-style: dashed; border-color: var(--s-pale); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────── Главный экран ───────────── */

.home { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.block { gap: 8px; transition: border-color 0.15s; }
.block:active { border-color: var(--s-pale); }
.block-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.block-calendar { grid-column: 1 / -1; }
.block-split { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.block .barlist { gap: 8px; margin-top: 2px; }
.block .stack, .block .spark { margin-top: 2px; }

.next { display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.next li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; }
.next-time { flex: 0 0 40px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.next-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.minibars { display: flex; align-items: flex-end; gap: 5px; }
.minibar { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); }
.minibar-slot { display: flex; align-items: flex-end; width: 16px; height: 56px; }
.minibar-slot i { width: 100%; min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--s-pale); }
.minibar-slot i.is-zero { min-height: 2px; border-radius: 1px; }
.minibar.is-active { color: var(--text); font-weight: 600; }
.minibar.is-active .minibar-slot i { background: var(--s-blue); }

.spark { display: block; width: 100%; height: 40px; fill: none; stroke: var(--s-grey); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark.tone-good { stroke: var(--s-green); }
.spark.tone-bad { stroke: var(--s-orange); }

/* ───────────── Календарь ───────────── */

.week { gap: 12px; }
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.week-nav { display: flex; gap: 6px; }
.week-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 7px; border-radius: 14px; border: 1px solid transparent;
}
.week-day-name { font-size: 11.5px; color: var(--muted); }
.week-day-number { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.week-day-marks { display: flex; align-items: center; justify-content: center; gap: 3px; height: 8px; }
.week-day-marks .dot { width: 5px; height: 5px; }
.week-day-more { font-size: 9px; font-style: normal; line-height: 1; color: var(--muted); }
.week-day.is-today { border-color: var(--line); }
.week-day.is-today .week-day-number { color: var(--accent); }
.week-day.is-selected { background: var(--text); border-color: var(--text); }
.week-day.is-selected .week-day-name { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.week-day.is-selected .week-day-number { color: var(--bg); }
.week-day.is-selected .dot-done { background: color-mix(in srgb, var(--bg) 40%, transparent); }
.week-day.is-selected .week-day-more { color: var(--bg); }

/* ───────────── Графики ───────────── */

.track { display: block; flex: none; width: 100%; height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.track-thin { height: 5px; margin-top: 4px; }
.track-fill { display: block; height: 100%; min-width: 0; border-radius: 4px; background: var(--s-blue); }

.compare { display: flex; flex-direction: column; gap: 8px; }
.compare-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.compare-title { font-size: 15px; font-weight: 500; }
.compare-head .delta { font-size: 17px; }
.compare-row { display: flex; align-items: center; gap: 10px; }
.compare-row .track { flex: 1; width: auto; }
.compare-label { flex: 0 0 40px; font-size: 12.5px; color: var(--muted); }
.compare-value { flex: 0 0 auto; min-width: 64px; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }

.barlist { display: flex; flex-direction: column; gap: 12px; }
.barlist-row { display: flex; flex-direction: column; gap: 5px; }
.barlist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.barlist-label { min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-sub { margin-left: 8px; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.barlist-value { flex: none; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-bar { display: flex; gap: 2px; height: 12px; }
.stack-bar i { min-width: 6px; border-radius: 4px; }

.gbars { --axis: 24px; display: flex; flex-direction: column; gap: 8px; }
.gbars-body { display: flex; gap: 8px; padding-top: 6px; }
.gbars-axis {
  flex: 0 0 var(--axis); display: flex; flex-direction: column; justify-content: space-between; margin: -7px 0;
  font-size: 11px; line-height: 14px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.gbars-plot { position: relative; flex: 1; min-width: 0; }
.gbars-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.gbars-grid:last-of-type { border-top-style: solid; }
.gbars-groups { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 4%; padding: 0 2%; }
.gbars-group { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.gbars-bar { flex: 1; max-width: 46px; min-height: 3px; border-radius: 8px 8px 2px 2px; }
.gbars-bar.is-zero { min-height: 0; }
.gbars-labels { display: flex; gap: 4%; padding: 0 2%; margin-left: calc(var(--axis) + 8px); font-size: 12px; color: var(--muted); }
.gbars-labels span { flex: 1; text-align: center; white-space: nowrap; }
.gbars-labels .is-active { color: var(--text); font-weight: 600; }
.gbars .legend { justify-content: center; margin-top: 2px; }

.line { display: flex; flex-direction: column; gap: 6px; padding-top: 40px; }
.line-plot { position: relative; margin-left: 46px; touch-action: pan-y; }
.line-svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: var(--s-blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.line-tick {
  position: absolute; left: -46px; width: 40px; transform: translateY(-50%); text-align: right;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.line-dot {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--s-blue); box-shadow: 0 0 0 2px var(--surface); pointer-events: none;
}
.line-tip {
  position: absolute; top: -42px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  padding: 4px 9px; border-radius: 9px; background: var(--text); color: var(--bg);
  font-size: 11.5px; line-height: 1.3; white-space: nowrap; pointer-events: none;
}
.line-tip b { font-size: 13px; font-variant-numeric: tabular-nums; }
.line-labels { display: flex; justify-content: space-between; margin-left: 46px; font-size: 12px; color: var(--muted); }

.ring { position: relative; flex: none; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--sunken); stroke-width: 5; }
.ring-value { fill: none; stroke-width: 5; stroke-linecap: round; }
.ring-label { position: relative; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.timeline { position: relative; height: 38px; margin: 6px 8px 0; }
.timeline-line { position: absolute; left: -8px; right: -8px; top: 8px; height: 4px; border-radius: 2px; background: var(--sunken); }
.timeline-dot {
  position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: var(--s-blue); box-shadow: 0 0 0 2px var(--surface);
}
.timeline-from, .timeline-to { position: absolute; bottom: 0; font-size: 11.5px; color: var(--muted); }
.timeline-from { left: -8px; }
.timeline-to { right: -8px; }

/* ───────────── Музыка и проекты ───────────── */

.group { display: flex; flex-direction: column; gap: 10px; }
.group-title { display: flex; align-items: center; gap: 8px; padding: 6px 4px 0; font-size: 15px; font-weight: 600; }
.group-count { font-size: 13px; font-weight: 500; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 10px; }

.work-head { display: flex; align-items: center; gap: 12px; }
.work-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.work-title { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.work .rows { border-top: 1px solid var(--line); padding-top: 8px; }
/* Отметки выпуска трека: четыре кнопки в ряд, отмеченная — зелёная с галочкой в углу. */
.work-checks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.work-check {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 9px 4px 7px;
  border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.work-check-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-check-tick { position: absolute; top: 5px; right: 6px; display: none; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--good); color: #fff; }
.work-check-tick .icon { stroke-width: 3; }
.work-check.is-on { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 13%, transparent); }
.work-check.is-on .work-check-tick { display: grid; }
.work-check.is-busy { opacity: 0.55; }
@media (hover: hover) { .work-check:not(.is-on):hover { color: var(--text); background: var(--sunken); } }
.people { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13.5px; }
.person { display: inline-flex; align-items: center; gap: 6px; }
.avatar {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-style: normal; font-weight: 600;
  background: color-mix(in srgb, var(--s-violet) 18%, transparent); color: color-mix(in srgb, var(--s-violet) 70%, var(--text));
}

.project-head { display: flex; align-items: center; gap: 8px; }
.project-head .work-title { flex: 1; min-width: 0; }
.project-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.project-numbers .label { font-size: 12px; }
.project-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-top: -4px; }
.next-step { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.next-step-text { font-size: 15px; font-weight: 500; }

/* ───────────── Правка: строки, которые открывают редактор ───────────── */

.is-editable { cursor: pointer; }
.row-open { display: block; text-align: left; border-radius: 6px; }
button.row-title { width: 100%; }
.work-open { font: inherit; letter-spacing: inherit; text-align: left; border-radius: 6px; overflow-wrap: anywhere; }
.row-go { flex: none; align-self: center; margin: 0 -4px 0 -2px; color: var(--muted); opacity: 0.5; }
.work-head .row-go, .project-head .row-go { align-self: flex-start; margin-top: 3px; }
.work-head .work-text { flex: 1; }
@media (hover: hover) {
  .row.is-editable:hover .row-title { color: var(--accent); }
  .row.is-editable:hover .row-go, .card.is-editable:hover > div > .row-go { opacity: 1; }
  .card.is-editable:hover { border-color: var(--s-pale); }
}
.row.is-off .row-title { color: var(--muted); }
.check.is-off { border-style: dotted; border-color: var(--s-pale); cursor: default; }
.check.is-agent.is-done { border-style: solid; }

.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row-top .row-title { flex: 1; min-width: 0; width: auto; }
.row-pay .track { height: 6px; margin: 2px 0 3px; }
.row-pay .row-mark { align-self: flex-start; padding-top: 0; }

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.card-actions:empty { display: none; }
.adds { display: flex; flex-wrap: wrap; gap: 6px; }
.adds .btn, .card-actions .btn { min-height: 36px; padding: 0 13px 0 10px; }
.card-actions .btn:last-child:not(:first-child) { padding: 0 8px 0 12px; }
.card-head .btn-accent { margin: -3px 0; }
.btn-accent .icon { stroke-width: 2.2; }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* То, что система делает сама и что править нельзя: пунктир вместо сплошной рамки. */
.card-auto { border-style: dashed; border-color: var(--s-pale); background: color-mix(in srgb, var(--text) 3%, var(--surface)); }

.fold { border-top: 1px solid var(--line); }
.fold > summary {
  display: flex; align-items: center; gap: 8px; padding: 12px 0 10px; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 600; border-radius: 6px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 0 2px;
  border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s;
}
.fold[open] > summary::before { transform: rotate(45deg); }
.fold > .notice { padding-top: 8px; }
.card > .group { gap: 6px; }
.card > .group > .group-title { padding: 4px 0 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ───────────── Фильтр и сортировка ───────────── */

.listbar { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-btn { flex: none; min-height: 38px; padding: 0 13px 0 11px; }
.bar-btn.is-on { background: var(--text); color: var(--bg); }
.bar-count {
  display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bg); color: var(--text); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.bar-sort { flex: 0 1 auto; min-width: 0; padding-right: 8px; cursor: pointer; }
.bar-sort select {
  -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; min-height: 38px; padding: 0 2px 0 0;
  border: 0; background: none; color: inherit; font: inherit; text-overflow: ellipsis; cursor: pointer;
}
.bar-sort:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.bar-sort select:focus-visible { outline: none; }

.bar-panel { display: flex; flex-direction: column; gap: 12px; padding: 12px 12px 14px; border-radius: 14px; background: var(--sunken); }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent); background: var(--surface);
  font-size: 13.5px; white-space: nowrap;
}
.chip.is-on { background: var(--text); border-color: var(--text); color: var(--bg); }

.bar-status {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 11%, transparent); font-size: 13px;
}
.bar-status-text { min-width: 0; }
.bar-status-what { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.bar-reset { flex: none; min-height: 34px; padding: 0 12px 0 9px; background: var(--surface); border: 1px solid var(--line); }

/* ───────────── Редактор: лист снизу на телефоне, окно по центру на широком экране ───────────── */

html.has-sheet { overflow: hidden; }
.sheet {
  position: fixed; inset: auto 0 var(--keyboard, 0px) 0; margin: 0; padding: 0; border: 0;
  width: 100%; max-width: none; height: auto;
  max-height: calc(100vh - 28px);
  max-height: calc(var(--room, 100dvh) - 28px - var(--tg-safe-area-inset-top, 0px));
  overflow: hidden; color: var(--text); background: var(--surface);
  border-radius: 22px 22px 0 0; box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.22);
}
.sheet::backdrop { background: rgba(8, 10, 14, 0.5); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(8, 10, 14, 0.5); }
.sheet.is-plain { display: block; z-index: 50; }
.sheet-form { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 6px 18px; }
.sheet-title { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; outline: none; }
.sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 14px; padding: 8px 18px 18px;
}
.sheet-note { padding: 10px 12px; border-radius: 12px; background: var(--sunken); font-size: 13.5px; color: var(--muted); }
.sheet-foot {
  flex: none; display: flex; flex-direction: column; gap: 10px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface);
}
.sheet-buttons { display: flex; gap: 8px; }
.sheet-buttons .btn { flex: 1; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.sheet.is-asking .sheet-body { opacity: 0.45; pointer-events: none; }
.confirm-text { font-size: 14.5px; font-weight: 500; }
.form-error {
  padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 500;
  background: color-mix(in srgb, var(--bad-text) 12%, transparent); color: var(--bad-text);
}

.btn-big { min-height: 46px; padding: 0 18px; border-radius: 14px; font-size: 15px; }
.btn-danger { color: var(--bad-text); }
.btn-danger-solid { background: var(--bad-text); color: var(--bg); }
.btn:disabled { opacity: 0.55; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px 10px; }
.field-row-wide { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field-must { color: var(--bad-text); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.field-line { display: flex; align-items: center; gap: 6px; }
.field-line .input { flex: 1; }
.field-clear { flex: none; width: 40px; min-height: 40px; color: var(--muted); }
.input {
  display: block; width: 100%; min-width: 0; min-height: 46px; margin: 0; padding: 10px 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--text) 14%, transparent); background: var(--sunken); color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.3; /* 16px: мельче — и телефон приближает страницу при вводе */
}
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea.input { min-height: 88px; resize: vertical; }
select.input {
  -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8c93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input.input[type="date"], input.input[type="datetime-local"] { -webkit-appearance: none; appearance: none; text-align: left; }
.input::-webkit-date-and-time-value { text-align: left; }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--bad-text); background: color-mix(in srgb, var(--bad-text) 8%, transparent); }

.choices { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--sunken); }
.choice { position: relative; flex: 1; display: flex; cursor: pointer; }
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice span {
  flex: 1; display: grid; place-items: center; min-height: 38px; padding: 0 8px; border-radius: 10px;
  font-size: 14.5px; font-weight: 500; color: var(--muted); text-align: center;
}
.choice input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.field-check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; }
.field-check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.field-check label { flex: 1; padding: 10px 0; font-size: 15px; cursor: pointer; }

/* Готовые варианты под полем: на телефоне — одна прокручиваемая строка, чтобы не занимать пол-экрана. */
.chips-scroll {
  flex-wrap: nowrap; overflow-x: auto; margin: 0 -18px; padding: 2px 18px; scrollbar-width: none;
}
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chip { flex: none; background: none; }
.chips-scroll .chip.is-on { background: var(--text); }

/* ───────────── Цели и счета ───────────── */

.tiles-3 > :first-child:nth-last-child(3) ~ :last-child { grid-column: 1 / -1; }

.goal { gap: 12px; }
.goal.is-reached { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 5%, var(--surface)); }
.goal.is-off, .row.is-off { opacity: 0.72; }
.goal-figure { display: flex; flex-direction: column; gap: 2px; }
.goal-figure .big { white-space: normal; }
.goal-figure .big-unit { white-space: nowrap; }
.goal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.goal-foot .sub { flex: 1 1 180px; }
.goal-foot .btn { min-height: 38px; padding: 0 14px 0 10px; }
.card-hint { border-style: dashed; border-color: var(--s-pale); }
.row-goal .track, .row-acct .track { height: 6px; margin: 3px 0; }
.row-goal .row-value { font-size: 13px; font-weight: 500; color: var(--muted); }
.card-subtitle { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.group-title:has(.group-sum) { flex-wrap: wrap; row-gap: 2px; }
.group-sum { margin-left: auto; font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.digits { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.pill-btn { min-height: 24px; padding: 2px 10px; cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.bank-line { display: flex; flex-direction: column; gap: 4px; }
.bank-line + .bank-line { padding-top: 10px; border-top: 1px solid var(--line); }

/* Внутри редактора: остаток крупно, история взносов и остатков. */
.balance-box { display: flex; flex-direction: column; gap: 10px; }
.sheet-later { display: flex; flex-direction: column; gap: 16px; }
.sheet-section { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.sheet-section-title { font-size: 15px; font-weight: 600; }
.sheet-section > .btn { align-self: flex-start; min-height: 38px; padding: 0 14px 0 10px; }
.sheet-section .line { padding-top: 36px; }
.mini-rows { display: flex; flex-direction: column; }
.mini-rows li + li { border-top: 1px solid var(--line); }
.mini-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 0; text-align: left; border-radius: 8px; }
.mini-day { flex: 0 0 52px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini-year { display: block; font-size: 11px; }
.mini-text { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.mini-value { flex: none; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-row .icon { color: var(--muted); opacity: 0.5; }

/* ───────────── Банк: карточки счетов ───────────── */

/* Карточка счёта: сверху полоса в цвете банка со знаком (--brand и --brand-ink задаёт brands.js), под ней цифры. */
.bank-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.bank-card {
  --brand: #2f343c; --brand-ink: #ffffff;
  position: relative; display: flex; flex-direction: column; min-width: 0;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.bank-card.is-closed { filter: grayscale(0.7); opacity: 0.7; }
.wallet-face {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 54px;
  margin: 10px 10px 0; padding: 12px 14px; border-radius: 12px; color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 72%, #000));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-ink) 14%, transparent);
}
.wallet-face-kind { flex: none; font-size: 12.5px; opacity: 0.85; }
.wallet-info { --brand-ink: var(--text); flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 10px 16px 12px; }
.bank-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 24px; }
.bank-card-digits { flex: none; font-size: 13px; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; color: var(--muted); }
.bank-card-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.bank-card-open { font: inherit; color: inherit; text-align: left; border-radius: 6px; }
.bank-card-tag { padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--sunken); }
.bank-card-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; }
.bank-card-amount { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bank-card-label { font-size: 13px; color: var(--muted); }
.bank-card.is-zero .bank-card-amount { opacity: 0.6; font-weight: 600; }
/* Овердрафт: цифра и подпись предупреждающего цвета. */
.bank-card.is-over .bank-card-amount { color: var(--bad-text); }
.bank-card.is-over .bank-card-label {
  padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--bad-text) 16%, transparent); color: var(--bad-text); font-weight: 600;
}
.bank-card-limit { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.bank-card-track { display: block; height: 5px; border-radius: 3px; overflow: hidden; background: var(--sunken); }
.bank-card-track i { display: block; height: 100%; border-radius: 3px; background: var(--text); }
.bank-card-due { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 12.5px; color: var(--muted); }
.bank-card-due > span:not(:last-child)::after { content: ' ·'; opacity: 0.7; }
.bank-card-due.is-soon { align-self: flex-start; padding: 3px 9px; border-radius: 9px; background: #ffd34d; color: #3a2a00; font-weight: 600; }
.bank-card-linked::before { content: ' · '; }
/* Карточки в ряду одной высоты: дата остатка прижата к низу, цифры остаются под названием. */
.bank-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; margin-top: auto; font-size: 12.5px; color: var(--muted); }
.bank-card-refresh { padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--text); background: var(--sunken); }
@media (hover: hover) { .bank-card.is-editable:hover { border-color: color-mix(in srgb, var(--text) 32%, transparent); } }

/* Знак банка — одноцветный SVG из папки brands, окрашенный маской в цвет текста карточки. Нет файла — плашка с названием. */
.bank-brand { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.brand-logo {
  flex: none; display: block; width: 24px; height: 24px; background: var(--brand-ink);
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat;
}
.brand-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-plaque {
  display: inline-block; max-width: 100%; padding: 3px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--brand-ink); color: var(--brand);
}

/* Выбор счёта в форме: ряд маленьких карточек, под каждой — обычная радиокнопка. */
.acct-picker { display: flex; gap: 8px; margin: 0 -18px; padding: 2px 18px 6px; overflow-x: auto; scrollbar-width: none; }
.acct-picker::-webkit-scrollbar { display: none; }
.acct-option { position: relative; flex: none; display: flex; cursor: pointer; }
.acct-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.bank-chip {
  --brand: #2f343c; --brand-ink: #ffffff;
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px; width: 150px; min-height: 84px; padding: 10px 12px;
  border-radius: 14px; color: var(--brand-ink); border: 2px solid transparent;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 72%, #000)); opacity: 0.62;
}
.bank-chip .brand-logo { width: 18px; height: 18px; }
.bank-chip .brand-name { font-size: 12px; }
.bank-chip .brand-plaque { font-size: 11px; padding: 2px 7px; }
.bank-chip-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.bank-chip-sum { font-size: 12.5px; font-variant-numeric: tabular-nums; opacity: 0.9; }
.bank-chip-none { justify-content: center; align-items: center; width: 96px; background: var(--sunken); color: var(--text); text-align: center; }
.acct-option input:checked + .bank-chip { opacity: 1; border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.acct-option input:focus-visible + .bank-chip { outline: 2px solid var(--accent); outline-offset: 2px; }

button.tile-link { text-align: left; cursor: pointer; }
.tile-link .tile-visual { color: var(--muted); }

/* ───────────── Проекты: дерево и страница узла ───────────── */

.tree { display: flex; flex-direction: column; gap: 10px; }
.tree-root { gap: 12px; }
.tree-row { display: flex; align-items: flex-start; gap: 8px; }
.tree-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tree-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tree-title { font-weight: 600; overflow-wrap: anywhere; border-radius: 6px; }
.tree-branch .tree-title { font-size: 15.5px; }
.tree-counts { font-size: 13px; color: var(--muted); }
.tree-toggle {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin: -5px 2px -5px -6px; border-radius: 50%;
  background: var(--sunken); color: var(--text); transition: transform 0.15s;
}
.tree-toggle.is-open { transform: rotate(90deg); }
.tree-dot { flex: none; width: 34px; height: 24px; margin: 0 2px 0 -6px; position: relative; }
.tree-dot::after { content: ""; position: absolute; left: 14px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--s-pale); }
.tree-go { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin: -2px -6px 0 0; color: var(--muted); opacity: 0.5; }
/* Ветки: отступ и тонкая линия слева вместо нарисованных символами «ёлочек». */
.tree-children { display: flex; flex-direction: column; gap: 12px; margin-left: 8px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line); }
.tree-root > .tree-children { margin-top: 2px; }
.tree-branch { display: flex; flex-direction: column; gap: 10px; }
.tree-note { font-size: 12.5px; color: var(--muted); }
.is-context > .tree-row { opacity: 0.6; }
.tree-progress { display: flex; flex-direction: column; gap: 6px; }
.tree-next { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
@media (hover: hover) { .tree-title:hover, .child-card:hover .work-title { color: var(--accent); } .tree-toggle:hover { background: var(--sunken); } }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; padding: 0 4px; font-size: 13.5px; color: var(--muted); }
.crumbs a { padding: 6px 2px; border-radius: 6px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--s-pale); }
.crumbs-here { padding: 6px 2px; color: var(--text); font-weight: 600; }
.crumbs-sep { display: inline-flex; opacity: 0.6; }
.node-head { gap: 12px; }
.node-title { font-size: 22px; font-weight: 700; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.node-goal { font-size: 15px; }
.child-card { gap: 6px; }
.child-card .work-title { flex: 1; min-width: 0; font-size: 16px; }
.child-goal { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Пустой блок — одной спокойной строкой, а не пустой карточкой. */
/* Подключения банков */
.bank-link { flex-wrap: wrap; }
.bank-link-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.bank-link-actions .btn { min-height: 36px; padding: 0 13px; }
.bank-link-confirm { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--sunken); font-size: 13.5px; }
.bank-note { padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--good) 12%, transparent); font-size: 13.5px; }
.row-value.is-transfer { color: var(--muted); }
.calm-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-height: 40px; padding: 2px 6px; }
.card-title .group-count { margin-left: 8px; }
.calm-title { font-size: 15px; font-weight: 600; }
.calm-line .quiet { flex: 1; }
.calm-line .btn { min-height: 34px; padding: 0 12px 0 9px; }

.entries { display: flex; flex-direction: column; }
.entry { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); outline: none; }
.entry:first-child { border-top: 0; padding-top: 2px; }
.entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; color: var(--muted); }
.entry-author { font-weight: 600; color: var(--text); }
.entry-title { margin: 0; font-size: 15px; font-weight: 600; }
.entry-body { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-body.is-clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.entry-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.entry-space { flex: 1; }
.link-btn { padding: 6px 0; font-size: 13px; font-weight: 500; color: var(--accent); border-radius: 6px; }
.entry-foot .confirm-inline .link-btn { color: var(--muted); }
.confirm-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.confirm-inline-text { font-size: 13px; font-weight: 500; }
.confirm-inline .btn { min-height: 34px; }
.report-link { border-radius: 8px; }
.report-summary { font-size: 14px; }

/* ───────────── Инвестиции: позиции ───────────── */

.invest-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 0 4px; }
.invest-head .btn { min-height: 38px; padding: 0 14px 0 11px; }
.row-pos .track { height: 6px; margin: 3px 0; }
.row-pos .row-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.ticker { font-size: 16px; font-weight: 700; letter-spacing: 0.01em; }
.pos-name { font-size: 13px; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }
.pos-foot { align-items: center; }
.pos-gain { flex: none; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-gain.quiet { font-size: 12.5px; font-weight: 400; }
.fold > summary .group-count { font-weight: 400; }

/* ───────────── Служебное ───────────── */

.skeleton { min-height: 84px; border-color: transparent; background: var(--sunken); animation: pulse 1.2s ease-in-out infinite; }
.skeleton-tall { min-height: 260px; }
@keyframes pulse { 50% { opacity: 0.45; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-height) + 22px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  transform: translateX(-50%); max-width: min(92vw, 460px); width: max-content;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-radius: 14px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 500; text-align: center;
}
.toast-action { flex: none; margin: -6px -6px -6px 0; padding: 8px 10px; border-radius: 10px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.noscript { padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ───────────── Шире телефона ───────────── */

@media (min-width: 720px) {
  .sheet {
    inset: 0; margin: auto; width: min(560px, calc(100vw - 48px)); height: fit-content;
    max-height: min(calc(100vh - 64px), 860px); border-radius: 22px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
  }
  .sheet-head { padding: 20px 16px 8px 24px; }
  .sheet-body { padding: 8px 24px 20px; }
  .sheet-foot { padding: 14px 24px 18px; }
  .sheet-buttons { justify-content: flex-end; }
  .sheet-buttons .btn { flex: none; min-width: 132px; }
  .chips-scroll { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .acct-picker { flex-wrap: wrap; overflow: visible; margin: 0; padding: 2px 0 6px; }
  .tiles.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles-3 > :first-child:nth-last-child(3) ~ :last-child { grid-column: auto; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
  .big { font-size: 34px; }
  .big-small { font-size: 24px; }
  .card { padding: 18px 20px; }
  .tile { padding: 16px 20px; }
}

@media (min-width: 900px) {
  :root { --nav-height: 0px; }
  .shell { padding: 26px 28px 40px; }
  .top { margin-bottom: 20px; }
  .brand-title { font-size: 28px; }
  .nav {
    position: static; display: flex; gap: 2px; padding: 0; border: 0; background: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .nav-item { flex-direction: row; gap: 7px; min-height: 0; padding: 8px 14px; border-radius: 999px; font-size: 14px; }
  .nav-item .icon { width: 18px; height: 18px; }
  .nav-item:hover { color: var(--text); }
  .nav-item.is-active { background: var(--sunken); color: var(--text); font-weight: 500; }
  .section-tabs { margin: 0 0 18px; padding: 0; }
  .bank-link-actions { flex: none; margin-left: auto; }
  .section-tabs .segmented { min-width: 0; max-width: none; }
  .section-tabs .segment { flex: none; padding: 0 16px; }
  .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home { gap: var(--gap); }
  .block { padding: 20px 22px; }
  .block:hover { border-color: var(--s-pale); }
  .block .big { font-size: 40px; }
  .block-calendar .big { font-size: 56px; }
  .minibar-slot { width: 26px; height: 96px; }
  .minibars { gap: 8px; }
  .minibar { font-size: 12px; }
  .next li { padding: 8px 0; font-size: 15px; }
  .toast { bottom: 28px; }
  .segmented { max-width: 520px; }
  .nav { flex: none; }
  .nav-item { flex: none; }
}

@media (min-width: 1100px) {
  .home { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .block-calendar { grid-column: span 2; grid-row: span 2; }
}

/* ───────────── Карта проекта ───────────── */

.map-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.view-switch .segmented { gap: 2px; padding: 3px; border-radius: 999px; background: var(--sunken); }
.view-switch .segment { flex: none; min-height: 34px; padding: 0 14px; }
.view-switch .segment.is-active { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }

/* Окно карты: на телефоне — от края до края и почти во весь экран, на широком — в рамке. */
.map-frame {
  position: relative; margin: 0 -16px; height: clamp(360px, calc(100dvh - 208px - env(safe-area-inset-bottom, 0px)), 880px);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background-color: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
}
.map-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; cursor: grab; }
.map-scroll.is-dragging { cursor: grabbing; user-select: none; }
.map-sizer { position: relative; }
.map-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.map-edges { position: absolute; left: 0; top: 0; pointer-events: none; }
.map-edge { stroke: color-mix(in srgb, var(--text) 26%, transparent); stroke-width: 1.6; }
.map-edge.kind-reports { stroke: color-mix(in srgb, var(--s-blue) 60%, transparent); }
.map-edge.kind-changes { stroke: color-mix(in srgb, var(--s-green) 60%, transparent); }
.map-edge.kind-decisions { stroke: color-mix(in srgb, var(--s-orange) 60%, transparent); }

/* Узел-направление: карточка с цветной полосой статуса слева и «хвостиком» справа. */
.map-node { position: absolute; }
.map-node-main {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; width: 100%; height: 100%;
  padding: 8px 16px 8px 14px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-left: 4px solid var(--s-grey); border-radius: 14px;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.map-node.is-good .map-node-main { border-left-color: var(--good); }
.map-node.is-warn .map-node-main { border-left-color: #eda100; }
.map-node.is-done .map-node-main { border-left-color: var(--s-pale); }
.map-node.is-root .map-node-main { background: var(--text); color: var(--bg); border-color: var(--text); border-left-color: var(--accent); }
.map-node.is-root .map-node-line { color: color-mix(in srgb, var(--bg) 72%, transparent); }
.map-node.is-root .tone-bad { color: inherit; font-weight: 600; }
.map-node-title { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 15px; font-weight: 650; line-height: 1.2; }
.map-node-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--s-grey); }
.map-dot.is-good { background: var(--good); }
.map-dot.is-warn { background: #eda100; }
.map-dot.is-done { background: var(--s-pale); }
.map-node-line { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-tail {
  position: absolute; right: -13px; top: 50%; width: 26px; height: 26px; margin-top: -13px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--s-pale); color: var(--muted); font-size: 11.5px; font-weight: 650;
}
/* Зона нажатия у «хвостика» больше, чем он сам: по нему попадают пальцем. */
.map-tail::after { content: ''; position: absolute; inset: -9px; }
.map-tail.is-folded { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Лист: записи одного вида под узлом. Вид виден по цвету полосы и значку. */
.map-leaf {
  position: absolute; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); --kind: var(--s-grey);
  box-shadow: inset 3px 0 0 var(--kind);
}
.map-leaf.kind-reports { --kind: var(--s-blue); }
.map-leaf.kind-changes { --kind: var(--s-green); }
.map-leaf.kind-decisions { --kind: var(--s-orange); }
.map-leaf-head {
  flex: none; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px 0 13px;
  font-size: 12.5px; font-weight: 650; color: color-mix(in srgb, var(--kind) 78%, var(--text));
  background: color-mix(in srgb, var(--kind) 10%, transparent);
}
.map-leaf-count { margin-left: auto; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.map-item {
  flex: none; display: flex; flex-direction: column; justify-content: center; gap: 1px; height: 44px; padding: 0 10px 0 13px;
  text-align: left; cursor: pointer; border-top: 1px solid var(--line);
}
.map-item-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-item-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-more { flex: none; height: 30px; padding: 0 10px 0 13px; text-align: left; font-size: 12px; font-weight: 500; color: var(--accent); border-top: 1px solid var(--line); cursor: pointer; }
.map-node-main:focus-visible, .map-item:focus-visible, .map-more:focus-visible, .map-tail:focus-visible { outline-offset: -2px; }
@media (hover: hover) {
  .map-node-main:hover { border-color: var(--s-pale); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); }
  .map-item:hover, .map-more:hover { background: var(--sunken); }
}

/* Кнопки масштаба — поверх карты, в правом верхнем углу. */
.map-tools {
  position: absolute; right: 10px; top: 10px; display: flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.map-tool { display: flex; align-items: center; justify-content: center; min-width: 38px; height: 38px; border-radius: 999px; color: var(--text); cursor: pointer; }
.map-tool-text { padding: 0 12px; font-size: 13px; font-weight: 500; }
.map-zoom { min-width: 42px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .map-tool:hover { background: var(--sunken); } }

/* Панель подробностей: на телефоне выезжает снизу, над меню; на широком экране стоит справа в окне карты. */
.map-panel {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px)); z-index: 9;
  display: flex; flex-direction: column; max-height: min(62dvh, 520px);
  border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; background: var(--surface);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.16); outline: none;
}
.map-panel-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 10px 8px 18px; }
.map-panel-title { font-size: 18px; font-weight: 700; line-height: 1.25; }
.map-panel-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 18px 18px; overflow-y: auto; overscroll-behavior: contain; }
.map-panel-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.map-field { display: flex; flex-direction: column; gap: 3px; }
.map-field-text { font-size: 14.5px; }
.map-text { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.map-panel-body .link-btn { align-self: flex-start; }
.map-tasks { display: flex; flex-direction: column; }
.map-tasks li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.map-tasks li:first-child { border-top: 0; }
.map-task-title { min-width: 0; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .map-frame { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: clamp(420px, calc(100dvh - 210px), 900px); }
  .map-panel {
    position: absolute; left: auto; right: 12px; top: 60px; bottom: 12px; width: 360px; max-height: none;
    border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  }
}

/* ── Возврат из банка (/plaid/oauth): только сообщение, без меню ── */
html.is-return .nav, html.is-return .section-tabs { display: none; }

/* ── Компактный вид для карточки в браузере (?embed=…) ── */
html.is-embed .top,
html.is-embed .section-tabs,
html.is-embed .nav { display: none; }
html.is-embed .shell { max-width: none; padding: 10px 12px 12px; }
html.is-embed .page { gap: 10px; }

