:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --series-income: #2a78d6;
  --series-expense: #eb6834;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --good: #0ca30c;
  --critical: #d03b3b;
  /* Single vertical-rhythm unit for the gap between sibling top-level page
     blocks (cards, toolbars, section grids) — every such class below reads
     this one variable instead of its own hardcoded number (previously a mix
     of 8/10/14/16/20/22px depending on the page, which is what made gaps
     look inconsistent even between blocks on the very same page). */
  --gap: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --series-income: #3987e5;
    --series-expense: #d95926;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --good: #0ca30c;
    --critical: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --series-income: #3987e5;
  --series-expense: #d95926;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --good: #0ca30c;
  --critical: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

nav {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* The bar itself spans the full width (background/sticky), but its content
   is capped and centered to the same width as the page's own .container
   below it — otherwise on wide screens the nav links sit flush against the
   viewport edges while "2026"/"+ Операция" etc. underneath sit inset,
   visibly misaligned. */
.nav-inner {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
}

.page-transactions .nav-inner { max-width: 1280px; }

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}

nav a.active { color: var(--text-primary); background: var(--gridline); font-weight: 600; }
nav a:hover { background: var(--gridline); }

.nav-inner form { margin-left: auto; }
.nav-inner form + form { margin-left: 0; }

.currency-switcher select {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: var(--gap);
}

h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--text-secondary); }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-tile { flex: 1 1 140px; min-width: max(140px, max-content); }
.stat-tile .label { font-size: 12px; color: var(--text-muted); }
.stat-tile .value { font-size: 24px; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.stat-tile .value.income { color: var(--series-income); }
.stat-tile .value.expense { color: var(--series-expense); }

/* Budget overview: two compact, predictable rows of comparable values. */
.budget-overview {
  width: 100%;
  max-width: 1060px;
  margin-right: auto;
  margin-left: auto;
  padding: 0;
  overflow: hidden;
}
.budget-overview-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  border-bottom: 1px solid var(--border);
}
.budget-overview-metric,
.budget-savings-metric,
.budget-savings-change {
  min-width: 0;
  padding: 8px 14px;
}
.budget-overview-metric + .budget-overview-metric { border-left: 1px solid var(--border); }
.budget-overview-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
}
.budget-overview-value,
.budget-savings-value,
.budget-savings-change-value {
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.1;
  white-space: nowrap;
}
.budget-overview-value { font-size: 21px; }
.budget-overview-metric--income .budget-overview-value { color: var(--series-income); }
.budget-overview-metric--expense .budget-overview-value { color: var(--series-expense); }
.budget-overview-metric--net.is-positive .budget-overview-value,
.budget-savings-change.is-positive .budget-savings-change-value { color: var(--good); }
.budget-overview-metric--net.is-negative .budget-overview-value,
.budget-savings-change.is-negative .budget-savings-change-value { color: var(--critical); }
.budget-savings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  min-width: 0;
}
.budget-savings-metric,
.budget-savings-change { padding: 8px 14px; }
.budget-savings > * + * { border-left: 1px solid var(--border); }
.budget-savings .budget-overview-label { font-size: 11px; }
.budget-savings-value { font-size: 21px; }
.budget-savings-arrow { display: none; }
.budget-savings-change {
  padding-right: 14px;
  padding-left: 14px;
}
.budget-savings-change-value { font-size: 21px; }
.budget-savings-change-value span { font-size: .62em; font-weight: 600; letter-spacing: 0; }

@media (max-width: 760px) {
  .budget-overview-flow { grid-template-columns: 1fr; }
  .budget-overview-metric + .budget-overview-metric { border-top: 1px solid var(--border); border-left: 0; }
  .budget-overview-metric { padding: 10px 14px; }
  .budget-savings {
    grid-template-columns: 1fr;
    gap: 0;
    background: transparent;
  }
  .budget-savings-metric,
  .budget-savings-change { padding: 10px 14px; }
  .budget-savings > * + * { border-top: 1px solid var(--border); border-left: 0; }
  .budget-savings-arrow { display: none; }
  .budget-savings-change {
    order: 1;
    border-top: 1px solid var(--border);
  }
  .budget-savings-metric:last-child { order: 2; }
}

@media (max-width: 430px) {
  .budget-overview-value { font-size: 22px; }
  .budget-savings-value,
  .budget-savings-change-value { font-size: 21px; }
}

.tx-selection-by-currency {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Plan-vs-actual / period-over-period difference: green = favourable (spent
   under budget, earned over budget, reserves grew), red = unfavourable —
   used on the /budget page, on any element (table cells, stat values, the
   small inline % next to a reserve change, ...). */
.diff-good { color: var(--good); }
.diff-bad { color: var(--critical); }

/* /budget "Фактические" cell — a thin Excel-style data bar showing how much
   of the plan is already used up (expense) / already earned (income), same
   green/red as the diff-good/diff-bad numbers right next to it. Anchored to
   the cell's own bottom edge so it never competes with the figures above it
   for space; width starts at 0 and is flipped to its real value on load
   (see budget.js) for the same "fills in" read as the /goals progress bars. */
.budget-databar-cell { position: relative; }
.budget-databar {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 0;
  background: var(--good);
  border-radius: 0 2px 2px 0;
  transition: width 0.6s cubic-bezier(.22,.9,.32,1);
}
.budget-databar.diff-bad-bar { background: var(--critical); }

/* Month-status pill next to "Расходы"/"Доходы — план и факт" — the same
   at-a-glance read as a goal's done/overdue flag, just for the whole
   section instead of one card. */
.status-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; vertical-align: middle; margin-left: 8px; }
.status-badge-good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.status-badge-bad { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }

/* /budget autosave feedback: a brief "✓" after each row saves on its own
   (no Save button on that page), fading out; a persistent "⚠" if the
   request failed, so a lost save is never silent. */
.save-status {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}
.save-status.save-ok { color: var(--good); opacity: 1; }
.save-status.save-err { color: var(--critical); opacity: 1; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--gridline); }
th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; }
tfoot td { border-top: 1px solid var(--border); border-bottom: none; }

th.sortable-col { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-col:hover { color: var(--text-primary); }
th.sortable-col .sort-arrow { display: inline-block; margin-left: 4px; font-size: 10px; opacity: 0.5; }
th.sortable-col[data-sort-dir] .sort-arrow { opacity: 1; }

tr.group-row[data-toggle-group] { cursor: pointer; }
tr.group-row[data-toggle-group]:hover td { background: var(--gridline); }
.row-caret { display: inline-block; width: 12px; margin-right: 2px; color: var(--text-muted); transition: transform 0.15s ease; }
tr.group-row.is-expanded .row-caret { transform: rotate(90deg); }
tr.subcat-row td { color: var(--text-secondary); }
tr.subcat-row td:first-child { padding-left: 30px; }

/* /budget rows carry a second, smaller line under the main figure (the
   native/display currency conversion) — that already adds height, so the
   table gets tighter row padding than the site default to avoid rows
   growing very tall; the amount input and currency select shrink to match.
   Row density/borders match .page-transactions (below) — same minimal gaps. */
#budget-form {
  display: grid;
  justify-items: center;
}
#budget-form .card {
  width: 934px;
  max-width: 100%;
}
.budget-table {
  table-layout: fixed;
  width: 900px;
  min-width: 900px;
}
.budget-col-category { width: 350px; }
.budget-col-currency { width: 100px; }
.budget-col-amount { width: 150px; }
.budget-table td, .budget-table th { padding: 3px 8px; font-size: 13px; line-height: 1.3; }
.budget-table input.budget-input,
.budget-table select[data-role="currency"] { padding: 4px 8px; }

/* Card title + its "Свернуть/развернуть все" button (collapsible-rows.js) on
   one line, button pinned to the right regardless of title length. */
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-header h2 { margin: 0; }

.bar-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
.bar-row .name { flex: 0 0 160px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: var(--gridline); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--series-expense); height: 100%; border-radius: 4px; }
.bar-value { flex: 0 0 90px; text-align: right; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.legend label { display: inline-flex; align-items: center; cursor: pointer; }
.legend input[type="checkbox"] { margin-right: 4px; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
input, select, button {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}
button {
  background: var(--series-income);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button.danger { background: var(--critical); }

/* "Secondary" outline control — buttons AND links share it (e.g. "Отмена"
   next to a submit button, "Показать"/"Сбросить" in a filter bar). Written
   as one self-contained rule instead of layering on top of the generic
   input/select/button rule above, because that rule doesn't reach <a> tags
   at all — before this, every `<a class="secondary">` had to carry its own
   copy of padding/border/radius inline (four templates did, each slightly
   driftable), while `<button class="secondary">` got its box model for
   free from the cascade. Same class, two different rendering paths — the
   actual root of most of the size/alignment mismatches on the site. */
button.secondary,
a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
button.secondary:hover, a.secondary:hover { background: var(--gridline); color: var(--text-primary); }

.field { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Public login/registration pages have no user settings yet.  Put the
   language choice first and show each language in its own writing system so
   a visitor can orient themselves before they understand the rest of the
   screen. */
.auth-language-picker { margin: -2px 0 20px; }
.auth-language-picker label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.auth-language-picker-controls { display: flex; gap: 8px; }
.auth-language-picker select { min-width: 0; flex: 1; }
.auth-language-picker button { flex: 0 0 auto; }

/* Plain number field, no up/down spinner arrows. */
input.no-spinner::-webkit-outer-spin-button,
input.no-spinner::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.no-spinner { -moz-appearance: textfield; }

.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: var(--gap); flex-wrap: wrap; }
.month-nav a { color: var(--text-secondary); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.month-nav a:hover { background: var(--gridline); }
.month-nav .current { font-weight: 600; }
.month-nav select { font-weight: 600; }

/* The transactions list's one-row toolbar: date range, account/type filters,
   Показать/Сбросить, and the "+ Операция" CTA all in a single flex line.
   Labels sit to the left of their control (not stacked above) to keep the
   bar compact. */
.filter-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: var(--gap); }
.filter-bar .field { display: flex; align-items: center; gap: 6px; margin-bottom: 0; }
.filter-bar .field label { margin-bottom: 0; white-space: nowrap; }
.filter-bar .field-cta { margin-left: auto; }

.error { color: var(--critical); font-size: 14px; margin-bottom: 12px; }

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.08s ease-out;
  white-space: nowrap;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-label { color: var(--text-muted); font-size: 11px; margin-bottom: 2px; }
.chart-tooltip .tt-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-key { display: inline-block; width: 8px; height: 2px; margin-right: 5px; vertical-align: middle; }
[data-tooltip] { cursor: default; }

/* The cheaper/pricier arrows in the operations table are compact enough to
   keep the rows scannable, while their hover tooltip shows the exact past
   purchase used for comparison.  A keyboard focus ring keeps the same detail
   reachable without a mouse. */
.price-indicator { display: inline-block; cursor: help; font-weight: 700; }
.price-indicator-cheaper { color: var(--good); }
.price-indicator-pricier { color: var(--critical); }
.price-indicator:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 2px; }

/* Иконка роли счёта на /summary — узкая колонка, без текста рядом с
   названием (22.08.2026, по просьбе Линара — раньше было текстовым чипом
   после имени, "загромождало"). */
.role-col { width: 1%; padding-right: 4px; font-size: 15px; text-align: center; }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--gridline); color: var(--text-primary); border-color: var(--border); }
.icon-btn svg { width: 16px; height: 16px; }

a.button-link {
  display: inline-flex;
  align-items: center;
  flex: none;
  background: var(--series-income);
  color: white;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .bar-row .name { flex-basis: 100px; }

  /* Mobile-only touch/legibility tweaks — desktop layout above is untouched */
  .container { padding: 10px; }
  .nav-inner { padding: 10px; }

  /* 16px prevents iOS Safari's auto-zoom-on-focus for inputs/selects */
  input, select, button { font-size: 16px; }

  .icon-btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .row-actions { gap: 6px; }

  .month-nav { flex-wrap: wrap; row-gap: 8px; }
  .month-nav a.button-link { margin-left: 0 !important; }
  .month-nav .action-dropdown { margin-left: 0 !important; }

  .filter-bar { row-gap: 10px; }
  .filter-bar .field-cta { margin-left: 0; width: 100%; }
  .filter-bar .field-cta .acct-dropdown,
  .filter-bar .field-cta .acct-dropdown-toggle { width: 100%; }
  .filter-bar .field-cta .acct-dropdown-toggle { justify-content: center; }
  .filter-bar .field-cta .acct-dropdown-menu { left: 0; right: 0; }

  .nav-inner { gap: 2px; padding: 8px 10px; }
  nav a { padding: 8px 10px; font-size: 13px; }
}

/* Accounts/type multi-select dropdown (account balance history chart,
   transactions filter bar). Sized to match .secondary / input / select
   exactly (14px, 8px 10px) — it used to run smaller (13px, 6px 10px), which
   made it look like a different, shorter control sitting next to buttons
   and date fields that were otherwise the same height. */
.acct-dropdown { position: relative; display: inline-block; }
.acct-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
}
.acct-dropdown-toggle:hover { background: var(--gridline); color: var(--text-primary); }
.acct-dropdown-toggle .caret { opacity: 0.6; margin-left: 4px; }
.acct-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  padding: 8px;
  min-width: 240px;
  max-height: 280px;
  overflow-y: auto;
}
.acct-dropdown-menu[hidden] { display: none; }
.acct-dropdown-actions { display: flex; gap: 6px; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--gridline); }
.acct-dropdown-actions button { font-size: 11px; padding: 4px 8px; }
.acct-dropdown-item { display: flex; align-items: center; gap: 6px; padding: 5px 4px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.acct-dropdown-item:hover { background: var(--gridline); }

/* "+ Операция" on /transactions — same acct-dropdown mechanics as the
   Счета/Тип filters above, styled as the blue CTA button instead of a
   filter chip, menu opening to a text link instead of a checkbox, and
   right-aligned since the button sits at the far right of the bar. */
.action-dropdown .acct-dropdown-toggle {
  background: var(--series-income);
  color: white;
  border-color: var(--series-income);
}
.action-dropdown .acct-dropdown-toggle:hover { filter: brightness(1.08); }
.action-dropdown .acct-dropdown-menu { left: auto; right: 0; min-width: 200px; padding: 6px; }
.action-dropdown .acct-dropdown-item { display: block; text-decoration: none; color: var(--text-primary); white-space: nowrap; }

/* Searchable category picker (transaction form) — text input that filters
   a dropdown list by prefix as you type, instead of a plain <select>.
   Reuses the .acct-dropdown-menu visual language above. */
.combobox { position: relative; }
.combobox-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.combobox-menu[hidden] { display: none; }
.combobox-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-muted); padding: 6px 8px 2px; }
.combobox-item { padding: 6px 8px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.combobox-item:hover, .combobox-item.active { background: var(--gridline); color: var(--text-primary); }
.combobox-empty { padding: 6px 8px; font-size: 13px; color: var(--text-muted); }
.acct-dropdown-item input { margin: 0; }

/* Compact layout for the Сводка (summary) page */
.page-summary .card { padding: 12px 14px; }
.page-summary h1 { font-size: 16px; margin: 0 0 8px; }
.page-summary h2 { font-size: 14px; margin: 0 0 8px; }
.page-summary .stat-row { gap: 8px; }
.page-summary .stat-tile .value { font-size: 19px; }
.page-summary .stat-tile .label { font-size: 11px; }
.page-summary table th, .page-summary table td { padding: 2px 6px; font-size: 12px; line-height: 1.3; }
.page-summary table td:first-child { white-space: nowrap; }
.page-summary .icon-btn { width: 22px; height: 22px; }
.page-summary .icon-btn svg { width: 13px; height: 13px; }

@media (max-width: 600px) {
  /* Restore comfortable tap targets on the compact Сводка layout for phones */
  .page-summary .icon-btn { width: 38px; height: 38px; }
  .page-summary .icon-btn svg { width: 16px; height: 16px; }
  .page-summary table th, .page-summary table td { padding: 6px 8px; font-size: 13px; }
}
.page-summary .row-actions { gap: 3px; }
.page-summary .bar-row { padding: 4px 0; font-size: 13px; }
.page-summary .legend { margin-bottom: 6px; }
.page-summary .field { margin-bottom: 8px; }

/* /summary headline "level" gauge — money across all accounts, start of
   month vs now (see routers/summary.py). Unlike a goal's fill (always 0 to
   100 toward a target), growth can go either way, so this one is centered:
   a track with a fixed midpoint mark, filling right in green for a growing
   month or left in red for a shrinking one. Deliberately a *gauge*, not a
   0-100% claim — the real number is always the text above it; the bar is
   scaled against a fixed ±GAUGE_CLAMP_PCT range purely so it's legible. */
.level-card { display: flex; flex-direction: column; gap: 8px; }
.level-card-compact { padding: 10px 16px; gap: 6px; }
.level-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.level-label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.level-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.level-pct { font-size: 13px; font-weight: 600; }
.level-gauge-track { position: relative; height: 14px; border-radius: 7px; background: var(--gridline); overflow: hidden; }
.level-gauge-mid { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--surface-1); z-index: 1; }
.level-gauge-fill { position: absolute; top: 0; bottom: 0; width: 0; transition: width 0.8s cubic-bezier(.22,.9,.32,1); }
.level-gauge-fill-good { left: 50%; background: var(--good); border-radius: 0 7px 7px 0; }
.level-gauge-fill-bad { right: 50%; background: var(--critical); border-radius: 7px 0 0 7px; }
.level-caption { font-size: 12px; color: var(--text-muted); }

/* Операции (transactions) page: nine data columns plus a checkbox column
   don't fit the site's normal 960px container without horizontal scroll —
   give this one page more room, and tighten the table itself, instead of
   widening every page just for this one wide table. */
.page-transactions .container { max-width: 1280px; }
.page-transactions table th, .page-transactions table td { padding: 3px 8px; font-size: 13px; line-height: 1.3; }
.page-transactions .icon-btn { width: 22px; height: 22px; }
.page-transactions .icon-btn svg { width: 13px; height: 13px; }
.page-transactions .row-actions { gap: 2px; }
.page-transactions .tx-select { width: 16px; height: 16px; cursor: pointer; }

@media (max-width: 600px) {
  /* Restore comfortable tap targets on the compact Операции layout for phones */
  .page-transactions .icon-btn { width: 38px; height: 38px; }
  .page-transactions .icon-btn svg { width: 16px; height: 16px; }
  .page-transactions table th, .page-transactions table td { padding: 8px; font-size: 13px; }
}

/* Settings page */
h3 { font-size: 14px; margin: 0 0 10px; color: var(--text-secondary); }

.settings-tabs { display: flex; gap: 6px; margin-bottom: var(--gap); }
.settings-tab-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
}
.settings-tab-btn.active { background: var(--text-primary); color: var(--page); border-color: var(--text-primary); }
.settings-tab-btn:hover:not(.active) { background: var(--gridline); }

.settings-section[hidden] { display: none; }

.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 0 0 4px; }
.section-hint { margin: 0; font-size: 13px; color: var(--text-muted); }

.cat-group { padding: 10px 0; border-bottom: 1px solid var(--gridline); }
.cat-group:last-child { border-bottom: none; }
.cat-group-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.cat-group-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cat-group-header .cat-group-name { margin: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gridline);
  color: var(--text-primary);
  font-size: 12px;
}
.chip-empty { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* Category management stays compact when nothing is being edited.  The
   controls expand into small popovers only on demand, so a long category
   list is still easy to scan instead of becoming a wall of inputs. */
.category-notice {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--good) 12%, transparent);
  color: var(--text-secondary);
  font-size: 13px;
}
.category-notice-warning { background: color-mix(in srgb, var(--series-4) 16%, transparent); }
.category-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.category-actions form, .category-chip-popover > form { margin: 0; }
.category-editor, .category-chip-editor { position: relative; }
.category-editor > summary,
.category-chip-editor > summary { cursor: pointer; list-style: none; }
.category-editor > summary::-webkit-details-marker,
.category-chip-editor > summary::-webkit-details-marker { display: none; }
.category-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.category-icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.category-editor > summary:hover,
.category-editor[open] > summary { color: var(--text-primary); background: var(--gridline); }
.category-editor .category-edit-form,
.category-chip-popover {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  width: min(360px, calc(100vw - 48px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  box-shadow: 0 8px 20px color-mix(in srgb, #000 18%, transparent);
}
.category-edit-form { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; align-items: end; }
.category-edit-form .field { margin: 0; min-width: 0; }
.category-edit-form input, .category-edit-form select { width: 100%; }
.category-edit-form button { align-self: end; }
.category-delete {
  color: var(--text-muted);
}
.category-delete:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); color: var(--critical); }
.category-chip-editor > summary.chip { display: block; user-select: none; }
.category-chip-editor > summary.chip span { margin-left: 3px; color: var(--text-muted); }
.category-chip-editor[open] > summary.chip { outline: 1px solid var(--border); }
.category-chip-popover { left: 0; right: auto; width: min(320px, calc(100vw - 48px)); }
.category-chip-popover .category-edit-form { grid-template-columns: minmax(0, 1fr) auto; }
.category-chip-popover .category-edit-form .field:first-child { grid-column: 1 / -1; }
.category-chip-popover > form + form { margin-top: 8px; }
.category-create-grid > .card { margin-bottom: 0; }
.category-create-form { display: grid; gap: 8px; align-items: end; }
.category-group-create-form { grid-template-columns: minmax(0, 1fr) 170px auto; }
.category-category-create-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.category-create-form .field { min-width: 0; margin: 0; }
.category-create-form input, .category-create-form select { width: 100%; }
.category-create-form button { align-self: end; }

.card-inset { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }

.theme-switch { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.theme-switch label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
}
.theme-switch input { margin: 0; }
.theme-switch label:has(input:checked) { background: var(--gridline); color: var(--text-primary); border-color: var(--text-primary); font-weight: 600; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 20px; }
.color-field { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--page); }
.color-field input[type="color"] { width: 36px; height: 36px; padding: 2px; flex: none; border-radius: 8px; cursor: pointer; }
.color-label { font-size: 12px; color: var(--text-secondary); }
.color-hex { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; }

.settings-actions { display: flex; gap: 8px; align-items: center; }
.reset-form { margin-top: 10px; }

.preview-panel { margin-top: 20px; }

@media (max-width: 600px) {
  .settings-tab-btn { flex: 1; padding: 10px 8px; font-size: 13px; }
  .color-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .category-group-create-form, .category-category-create-form { grid-template-columns: 1fr; }
  .category-create-form button { justify-self: start; }
  .category-edit-form { grid-template-columns: 1fr; }
  .category-editor .category-edit-form { right: -44px; }
  .category-chip-popover .category-edit-form { grid-template-columns: 1fr; }
  .category-chip-popover .category-edit-form .field:first-child { grid-column: auto; }
}

/* Цели и мечты (/goals). Each goal gets an accent color by kind (накопление
   = --good green, крупная покупка = --series-5 pink/"мечта", целевой доход
   = --series-income blue) via a --goal-accent custom property set per
   .kind-* class — every accent-colored element below (icon badge tint,
   progress fill, top border) just reads that one variable instead of
   repeating three color rules per kind. */
.goals-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--gap); }
.goals-subtitle { font-size: 13px; color: var(--text-muted); }

.goals-hero-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.goals-hero-count { font-size: 20px; font-weight: 700; }
.goals-hero-pct { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--series-income); }
/* 25/50/75% milestone ticks — thin card-colored notches cut into the track
   background, sitting *behind* the fill so each one visually disappears the
   moment progress reaches it (the classic game XP-bar "next checkpoint"
   read), no JS needed to track which milestones are already passed. */
.goal-hero-track, .goal-track {
  background:
    linear-gradient(var(--surface-1) 0 0) 25% / 2px 100% no-repeat,
    linear-gradient(var(--surface-1) 0 0) 50% / 2px 100% no-repeat,
    linear-gradient(var(--surface-1) 0 0) 75% / 2px 100% no-repeat,
    var(--gridline);
}
.goal-hero-track { height: 14px; border-radius: 7px; }
.goal-hero-fill {
  height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--good), var(--series-income));
  transition: width 0.8s cubic-bezier(.22,.9,.32,1);
}
.goals-hero-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.goals-hero-label { color: var(--text-muted); margin-right: 4px; }

/* Cross-goal "nearest upcoming deposit" line under the hero progress bar —
   same gold accent as .goal-pill-next below, so the two visibly read as the
   same kind of information at both the summary and per-card level. */
.goals-next-contribution { margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--series-4) 14%, transparent); font-size: 13px; color: var(--text-secondary); }
.goals-next-contribution-days { color: var(--series-4); font-weight: 600; }

.goals-section-title { margin: 22px 0 12px; font-size: 15px; color: var(--text-secondary); }

.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }

.goal-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 3px solid var(--goal-accent, var(--series-3));
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.goal-card.kind-saving { --goal-accent: var(--good); }
.goal-card.kind-expense { --goal-accent: var(--series-5); }
.goal-card.kind-income { --goal-accent: var(--series-income); }
.goal-card.goal-done { --goal-accent: var(--good); }
.goal-card.goal-overdue { --goal-accent: var(--critical); }

.goal-card-header { display: flex; align-items: center; gap: 10px; }
.goal-icon-badge {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: color-mix(in srgb, var(--goal-accent, var(--series-3)) 18%, transparent);
}
.goal-title-block { flex: 1; min-width: 0; }
.goal-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-kind-badge { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.goal-flag { font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: 8px; }
.goal-flag-done { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.goal-flag-overdue { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }

.goal-progress-row { display: flex; align-items: center; gap: 10px; }
.goal-track { flex: 1; height: 12px; border-radius: 6px; }
.goal-fill {
  height: 100%; border-radius: 6px; background: var(--goal-accent, var(--series-3));
  transition: width 0.8s cubic-bezier(.22,.9,.32,1);
}

/* Brief highlight on the one card that was just contributed to (see the
   #goal-N / #reserve-N anchor + progress-bars.js) — a restrained "action
   registered" cue: two soft pulses of the card's own accent color, not
   confetti. --goal-accent is unset on .reserve-card, so it falls back to
   the same --series-3 the card's own top border already uses. */
@keyframes goal-card-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  20%, 60% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--goal-accent, var(--series-3)) 45%, transparent); }
  40%, 80% { box-shadow: 0 0 0 0 transparent; }
}
.goal-card.just-updated, .reserve-card.just-updated { animation: goal-card-pulse 1.4s ease-in-out; }
.goal-progress-pct { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }

.goal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.goal-stat-label { font-size: 11px; color: var(--text-muted); }
.goal-stat-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.goal-stat-sub { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.goal-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.goal-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--gridline); color: var(--text-secondary); }
.goal-pill-danger { background: color-mix(in srgb, var(--critical) 18%, transparent); color: var(--critical); }
.goal-pill-next { background: color-mix(in srgb, var(--series-4) 18%, transparent); color: var(--series-4); font-weight: 600; }

.goal-pace { font-size: 12px; color: var(--text-secondary); background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.goal-note { font-size: 13px; color: var(--text-secondary); font-style: italic; }

.goal-quick-add { display: flex; gap: 6px; flex-wrap: wrap; }
.goal-quick-add input { flex: 1 1 80px; min-width: 70px; padding: 6px 8px; font-size: 13px; }
.goal-quick-add button { flex: none; padding: 6px 12px; font-size: 13px; }

.goal-history summary { cursor: pointer; font-size: 12px; color: var(--text-muted); }
.goal-history-table { width: 100%; margin-top: 8px; font-size: 12px; }
.goal-history-table td { padding: 4px; border-bottom: 1px solid var(--gridline); }
.goal-history-empty { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.goals-archive summary { cursor: pointer; color: var(--text-muted); font-size: 13px; margin-top: 8px; }

.icon-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.icon-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.icon-preset { font-size: 16px; padding: 4px 8px; background: var(--page); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.icon-preset:hover { background: var(--gridline); }

.goals-empty { text-align: center; padding: 40px 20px; }
.goals-empty-emoji { font-size: 40px; margin-bottom: 8px; }
.goals-empty p { color: var(--text-muted); max-width: 420px; margin: 8px auto 16px; }

@media (max-width: 600px) {
  .goal-grid { grid-template-columns: 1fr; }
  .goals-toolbar { flex-direction: column; align-items: stretch; }
  .goals-toolbar a.button-link { text-align: center; justify-content: center; }
  .goal-quick-add input, .goal-quick-add button { font-size: 16px; }
}

/* Капитал — раздел 14 ТЗ, с 22.08.2026 часть /summary, не отдельная
   вкладка (см. donut-row ниже: "Доли счетов" и "Структура капитала" рядом,
   а не на двух разных страницах). */
.donut-row { display: flex; gap: 24px; flex-wrap: wrap; }
.donut-col { flex: 1 1 320px; min-width: 260px; }
.donut-col-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; }
.donut-flex { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.donut-svg { width: 150px; height: 150px; flex: 0 0 auto; }

.capital-note { margin-top: 14px; font-size: 12px; color: var(--text-muted); background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }

.capital-links-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap); margin: var(--gap) 0; }
.capital-link-card { display: block; text-decoration: none; color: inherit; }
.capital-link-card strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.capital-link-sub { font-size: 12px; color: var(--text-muted); }

.capital-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
/* .capital-link-card and the two .card panels above are grid ITEMS — a grid
   item's own margin never collapses with anything (unlike normal block
   flow), so the base .card rule's margin-bottom was silently stacking on
   top of gap/margin above, making the vertical gap read as roughly double
   the horizontal one. Zero it out here; spacing between cards is entirely
   the grid's own gap/margin now. */
.capital-links-row > .card, .capital-two-col > .card { margin-bottom: 0; }
.capital-see-all { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--series-income); text-decoration: none; }
.capital-see-all:hover { text-decoration: underline; }

/* Резервы (/reserves) — reuses .goal-card's child classes (header/icon
   badge/stats/pills/history/quick-add all identical in shape) but its own
   top-level class, since a reserve's headline metric ("покрывает N
   месяцев") is conceptually different from a goal's %-to-deadline even
   though the surrounding chrome is the same. */
.reserve-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 3px solid var(--series-3);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Инвестиции (/investments). Deliberately NOT sharing .goal-card's
   progress-bar look (п.12 ТЗ) — no target/percent here, the card leads with
   "текущая стоимость" and puts "вложено" next to a separate profit/loss
   figure instead of one progress fill. Reuses .goal-grid/.goal-quick-add/
   .goal-history*/.icon-picker as-is (identical layout needs), only adds
   what's visually distinct below. */
.investment-positive { color: var(--good); }
.investment-negative { color: var(--critical); }

.investment-hero-row { display: flex; gap: 24px; flex-wrap: wrap; }
.investment-hero-row strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; margin-top: 2px; }

.investment-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 3px solid var(--series-3);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.investment-card.status-paused { border-top-color: var(--series-4); opacity: 0.85; }
.investment-card.status-closed { border-top-color: var(--text-muted); opacity: 0.7; }

.investment-card-header { display: flex; align-items: center; gap: 10px; }
.investment-icon-badge {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: color-mix(in srgb, var(--series-3) 18%, transparent);
}
.investment-title-block { flex: 1; min-width: 0; }
.investment-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.investment-meta-line { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.investment-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--gridline); color: var(--text-secondary); }
.investment-pill-status { background: color-mix(in srgb, var(--series-3) 16%, transparent); color: var(--series-3); }
.investment-pill-plan { font-weight: 600; align-self: flex-start; }
/* Plan-vs-fact (раздел 9 ТЗ) is informational only — a range, not an
   obligation. Deliberately no --critical/red anywhere here, even for
   "below plan": skipping a month is not a missed payment. */
.investment-pill-plan-status.status-within { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.investment-pill-plan-status.status-below,
.investment-pill-plan-status.status-above { background: var(--gridline); color: var(--text-secondary); }

.investment-value-hero { text-align: center; padding: 8px 0; }
.investment-value-current { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.investment-value-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.investment-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.investment-stat-label { font-size: 11px; color: var(--text-muted); }
.investment-stat-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.investment-stat-sub { font-size: 11px; font-variant-numeric: tabular-nums; }

.investment-quick-add-row { display: flex; flex-direction: column; gap: 8px; }

/* Growth chart period switcher (client-side slice of the same full series —
   see investment-chart.js) and its two-line legend ("Вложено" dashed muted
   vs "Текущая стоимость" solid income-green) — the visual counterpart of
   раздел 7 ТЗ ("два источника роста"). */
.chart-period-toggle { display: flex; gap: 4px; flex-wrap: wrap; }
.chart-period-btn {
  background: var(--page); border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.chart-period-btn:hover { background: var(--gridline); }
.chart-period-btn.active { background: var(--series-income); border-color: var(--series-income); color: #fff; }

.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.chart-legend .tt-key { display: inline-block; width: 14px; height: 2px; margin-right: 5px; vertical-align: middle; }

/* Portfolio distribution list (donut companion, раздел 8 ТЗ) — name+swatch,
   current value, share of portfolio, profit/loss per direction. */
.investment-dist-table-wrap { flex: 1 1 260px; min-width: 0; overflow-x: auto; }
.investment-dist-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.investment-dist-table td { padding: 5px 10px 5px 0; border-bottom: 1px solid var(--gridline); }

@media (max-width: 600px) {
  .investment-hero-row { gap: 16px; }
  .card-header { flex-direction: column; align-items: stretch; }
}

/* Прогноз / "что если" калькулятор (раздел 10-11 ТЗ) — plain native
   range inputs on purpose (не терминал трейдера, п.18 ТЗ): no custom
   slider skin, just enough layout to keep label+value+slider tidy. */
.forecast-disclaimer { font-size: 13px; color: var(--text-secondary); background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; }
/* 4 inputs in a 2x2 grid instead of 4 stacked full-width rows — same info,
   roughly half the vertical space (компактность по просьбе Линара 22.08.2026). */
.forecast-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.forecast-grid .field { margin-bottom: 8px; }
.forecast-grid input[type="number"] { width: 100%; }
.forecast-slider-field { margin-bottom: 14px; }
.forecast-slider-field label,
.forecast-grid .field label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.forecast-slider-field label span,
.forecast-grid .field label span { font-weight: 700; color: var(--text-primary); }
.forecast-slider-field input[type="range"],
.forecast-grid input[type="range"] { width: 100%; }

@media (max-width: 600px) {
  .forecast-grid { grid-template-columns: 1fr; }
}
