:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #111827;
  --text-muted: #6b7280;

  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #e6f6f4;

  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --income: #16a34a;
  --expense: #dc2626;
  --transfer: #475569;
  --accrual: #9333ea;
  --radius: 8px;

  --ind-income: #38bdf8;
  --ind-expense: #fb923c;
  --ind-profit: #16a34a;
  --ind-dividends: #9333ea;

  --sidebar-w: 84px;
  --sidebar-bg: #16283a;
  --sidebar-bg-active: #21384d;
  --sidebar-text: #93a5b8;
  --sidebar-text-active: #ffffff;
  --sidebar-border: #223449;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }

/* ── App shell: sidebar + content ─────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.sidebar-logo {
  display: flex; align-items: center; justify-content: center;
  height: 56px; color: #fff; font-weight: 700; font-size: 18px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo span {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}

.sidebar-nav { flex: 1; padding: 10px 0; overflow: visible; }

.sidebar-item { position: relative; }
.sidebar-item > a, .sidebar-item > .sidebar-item-label {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; margin: 2px 8px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 11px; text-align: center; line-height: 1.2;
  cursor: pointer; user-select: none;
}
.sidebar-item > a:hover, .sidebar-item > .sidebar-item-label:hover { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); }
.sidebar-item.active > a { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); }
.sidebar-item.active > a::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.sidebar-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-submenu {
  display: none; position: absolute; left: 100%; top: 0; min-width: 200px;
  background: var(--sidebar-bg); border: 1px solid var(--sidebar-border);
  border-radius: 8px; padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 30;
}
.sidebar-item.has-submenu:hover .sidebar-submenu { display: block; }
.sidebar-submenu a {
  display: block; padding: 8px 12px; border-radius: 6px; color: var(--sidebar-text);
  font-size: 13px; text-align: left; white-space: nowrap;
}
.sidebar-submenu a:hover, .sidebar-submenu a.active { background: var(--sidebar-bg-active); color: var(--sidebar-text-active); }

.sidebar-user {
  border-top: 1px solid var(--sidebar-border); padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.sidebar-user-name { color: var(--sidebar-text); font-size: 11px; text-align: center; line-height: 1.3; }
.sidebar-user .link-btn { color: var(--sidebar-text); font-size: 12px; }
.sidebar-user .link-btn:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
/* Раньше .page был ограничен 1400px и центрировался — на широких мониторах
   это оставляло пустые поля по бокам на всех разделах. Контент каждой
   страницы сам решает, как использовать освободившееся место (список
   операций растягивается, карточки/таблицы остаются обычной ширины). */
.page { margin: 0 auto; padding: 24px 28px; }
.page-noauth { max-width: none; padding: 0; margin: 0; width: 100%; }

/* ── Topbar: account balance widget ──────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; justify-content: flex-end;
  padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.balance-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; color: var(--text);
}
.balance-pill:hover { background: var(--bg); }
.balance-chevron { width: 14px; height: 14px; color: var(--text-muted); }
.balance-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.balance-dot-muted { background: var(--text-muted); }

.balance-dropdown {
  position: absolute; right: 28px; top: calc(100% + 6px); width: 320px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); z-index: 40; padding: 6px;
}
.balance-dropdown-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 700; font-size: 15px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.balance-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.balance-row:hover { background: var(--bg); }
.balance-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance-row-entity { color: var(--text-muted); font-size: 12px; }
.balance-row-amount { font-weight: 600; white-space: nowrap; }
.balance-row-archived { color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.balance-row-empty { color: var(--text-muted); justify-content: center; }

/* ── Buttons / forms ──────────────────────────────────────── */
.link-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 14px; padding: 0;
}
.link-btn:hover { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 500;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-link { border: none; background: none; color: var(--accent); padding: 0; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }

.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--sidebar-bg); }
.login-form {
  background: var(--surface); border-radius: 12px;
  padding: 36px; width: 340px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-form h1 { margin: 0 0 8px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.login-form h1 .brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
}
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }

input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}

.page-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.page-header h1 { font-size: 20px; margin: 0; }
.page-header .actions { display: flex; align-items: center; gap: 10px; }
.search-input { width: 240px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--bg); cursor: pointer; }

.group-header { background: var(--bg); font-weight: 600; padding: 8px 12px; font-size: 13px; color: var(--text-muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-receipt { background: #ecfdf5; color: var(--income); }
.badge-payment { background: #fef2f2; color: var(--expense); }
.badge-transfer { background: #f1f5f9; color: var(--transfer); }
.badge-accrual { background: #f5f0ff; color: var(--accrual); }
.badge-muted { background: var(--bg); color: var(--text-muted); }

/* Operation-type direction icon (journal table) */
.type-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
}
.type-icon svg { width: 15px; height: 15px; }
.type-icon.receipt { background: #ecfdf5; color: var(--income); }
.type-icon.payment { background: #fef2f2; color: var(--expense); }
.type-icon.transfer { background: #f1f5f9; color: var(--transfer); }
.type-icon.accrual { background: #f5f0ff; color: var(--accrual); }
.type-cell { display: flex; align-items: center; gap: 8px; }
.type-cell .type-label { font-size: 13px; color: var(--text-muted); }

.amount-income { color: var(--income); font-weight: 600; }
.amount-expense { color: var(--expense); font-weight: 600; }

.category-type-tag { font-size: 11px; color: var(--text-muted); }
.journal-date-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.journal-date-cell { display: flex; align-items: flex-start; gap: 8px; }
.row-expand-toggle {
  flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text-muted); cursor: pointer; font: inherit; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.row-expand-toggle:hover { border-color: var(--accent); color: var(--accent); }
.row-expand-spacer { display: inline-block; width: 18px; flex-shrink: 0; }

.journal-subrow { background: var(--bg); font-size: 13px; }
.journal-subrow:hover { cursor: default; }
.journal-subrow td { padding-top: 7px; padding-bottom: 7px; color: var(--text-muted); }
.journal-subrow-pct { color: var(--text-muted); font-weight: 400; margin-left: 4px; }

/* ── Operations layout: filters panel + table ────────────────── */
/* Высота выставляется в JS (sizeOpsLayout) по фактическому положению на
   странице — дальше обе панели растягиваются на всю эту высоту (align-items:
   stretch) и скроллятся независимо друг от друга каждая своим overflow-y. */
.ops-layout { display: flex; gap: 20px; align-items: stretch; }
.filters-panel {
  width: 240px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}
.filters-panel h2 { font-size: 14px; margin: 0; }
.filters-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.ops-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.ops-main > .page-header, .ops-main > .journal-drill-banner, .ops-main > .report-hint, .ops-main > .selection-bar { flex-shrink: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 140px; }

/* Карточка со списком операций: сама таблица скроллится внутри
   .journal-scroll, а строка итогов остаётся прикреплённой снизу. */
.journal-card { display: flex; flex-direction: column; min-height: 0; flex: 1; padding: 0; overflow: hidden; }
.journal-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.journal-scroll table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
/* Счёт/Контрагент/Статья — самые длинные подписи в журнале, им нужно
   больше места, чтобы название счёта помещалось в одну строку (кроме
   перемещений — там он/она законно в две строки, см. .transfer-accounts). */
.journal-scroll table .col-account { min-width: 220px; }
.journal-scroll table .col-counterparty { min-width: 160px; }
.journal-scroll table .col-category { min-width: 200px; }
.journal-loadmore-hint { text-align: center; color: var(--text-muted); font-size: 12px; padding: 10px; }

.totals-row { display: flex; gap: 24px; padding: 14px 16px; background: var(--surface); border-top: 2px solid var(--border); font-size: 13px; flex-wrap: wrap; flex-shrink: 0; }
.totals-row strong { display: block; font-size: 15px; }

/* ── Выделение строк чекбоксами + сумма по выделенным ─────────── */
.select-cell { width: 28px; }
.selection-bar {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); font-size: 13px;
}
.selection-bar strong { color: var(--accent-hover); }

/* ── Перемещение: два счёта друг под другом вместо контрагента ── */
.transfer-accounts { display: flex; flex-direction: column; gap: 2px; }
.transfer-accounts .transfer-arrow { color: var(--text-muted); font-size: 12px; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg); padding: 4px; border-radius: 10px; width: fit-content; }
.tabs button {
  padding: 8px 18px; border: none; background: none; cursor: pointer; font: inherit;
  color: var(--text-muted); border-radius: 8px; font-weight: 500;
}
.tabs button.active { color: #fff; background: var(--accent); }
.tabs button[data-type="receipt"].active { background: var(--income); }
.tabs button[data-type="payment"].active { background: var(--expense); }
.tabs button[data-type="transfer"].active { background: var(--transfer); }
.tabs button[data-type="accrual"].active { background: var(--accrual); }
.tabs button[data-type="receipt"]:hover:not(.active) { color: var(--income); }
.tabs button[data-type="payment"]:hover:not(.active) { color: var(--expense); }
.tabs button[data-type="transfer"]:hover:not(.active) { color: var(--transfer); }
.tabs button[data-type="accrual"]:hover:not(.active) { color: var(--accrual); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17,24,39,.5);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 640px;
  padding: 24px;
}
.modal h2 { margin-top: 0; }
.modal.hidden, .hidden { display: none !important; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 13px; color: var(--text-muted); }
.form-row .hint-links { display: flex; gap: 14px; margin-top: 2px; }
.form-actions { display: flex; justify-content: space-between; margin-top: 20px; }
.form-actions .right { display: flex; gap: 8px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.checkbox-list { display: flex; flex-direction: column; gap: 4px; }
.checkbox-list .checkbox-row { font-size: 13px; font-weight: normal; text-transform: none; letter-spacing: normal; color: var(--text); }
.filter-group .checkbox-row { font-size: 12px; font-weight: normal; text-transform: none; letter-spacing: normal; color: var(--text-muted); }

.lines-table { margin: 10px 0; }
.lines-table th, .lines-table td { padding: 6px 8px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

.section-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg); padding: 4px; border-radius: 10px; width: fit-content; }
.section-tabs button {
  padding: 8px 16px; border: none; background: none;
  cursor: pointer; font: inherit; border-radius: 8px; color: var(--text-muted); font-weight: 500;
}
.section-tabs button.active { background: var(--accent); color: #fff; }

.archived-row { opacity: .5; }

.text-muted { color: var(--text-muted); }
.mt-16 { margin-top: 16px; }
.mt-4 { margin-top: 4px; }

/* ── Разбивка суммы операции по измерениям (как в ПланФакте) ──── */
#lines-total-pct { color: var(--text-muted); font-weight: 400; margin-left: 6px; }
#lines-remaining-hint { color: var(--danger); font-size: 13px; }
.lines-table .line-pct { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.lines-table td.line-confirmed-cell { text-align: center; }

/* ── Справочники: list/tree/group rows ───────────────────────── */
.ref-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.ref-head-row, .ref-row, .ref-group-row {
  display: grid; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); gap: 12px;
}
.ref-list > *:last-child { border-bottom: none; }
.ref-head-row { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: var(--bg); }
.ref-row { cursor: pointer; font-size: 14px; }
.ref-row:hover { background: var(--bg); }
.ref-row.archived { opacity: .5; }

.ref-group-row { background: var(--bg); font-weight: 600; cursor: pointer; }
.ref-group-row:hover { background: var(--border); }
.ref-group-count { color: var(--text-muted); font-weight: 400; font-size: 13px; }

.ref-cell-subtext { font-weight: 400; font-size: 11px; color: var(--text-muted); }
.ref-archived-badge { margin-left: 4px; padding: 1px 6px; font-size: 10px; }

.ref-name-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ref-name-cell .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tree-toggle {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-muted);
  cursor: pointer; flex-shrink: 0; font-size: 12px; line-height: 1; padding: 0;
}
.tree-spacer { width: 18px; flex-shrink: 0; }

.kebab-cell { position: relative; display: flex; justify-content: flex-end; }
.kebab-btn {
  width: 28px; height: 28px; border: none; background: none; cursor: pointer; color: var(--text-muted);
  border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.kebab-btn:hover { background: var(--border); color: var(--text); }
.kebab-menu {
  position: absolute; right: 0; top: 100%; margin-top: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16);
  min-width: 170px; z-index: 40; padding: 4px; display: none;
}
.kebab-menu.open { display: block; }
.kebab-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none;
  border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); font-size: 13px;
}
.kebab-menu button:hover { background: var(--bg); }
.kebab-menu button.danger { color: var(--danger); }

.report-hint { color: var(--text-muted); font-size: 12px; margin: -6px 0 14px; }

.report-amount-link { cursor: pointer; }
.report-amount-link:hover { color: var(--accent); text-decoration: underline; }

.journal-drill-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.journal-drill-banner a { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.journal-drill-banner a:hover { text-decoration: underline; }
.report-total-row { font-weight: 700; border-top: 2px solid var(--border); }
#report-totals-footer { border-top: 1px solid var(--border); }

/* ── Финплан: карточки безопасности ЗП ───────────────────────── */
.plan-salary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.plan-salary-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--bg); }
.plan-salary-card.level-ok { border-color: #bbf7d0; background: #f0fdf4; }
.plan-salary-card.level-warn { border-color: #fde68a; background: #fffbeb; }
.plan-salary-card.level-red { border-color: #fecaca; background: #fef2f2; }
.plan-salary-date { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.plan-salary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.plan-salary-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; font-weight: 600; }

.subtabs { display: flex; gap: 4px; margin-bottom: 14px; }
.subtabs button {
  padding: 6px 14px; border-radius: 8px; border: none; background: var(--bg); color: var(--text-muted);
  cursor: pointer; font: inherit; font-weight: 500;
}
.subtabs button.active { background: var(--accent-soft); color: var(--accent-hover); }

/* ── Показатели ─────────────────────────────────────────────── */
.ind-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.ind-filters .filter-group { display: flex; flex-direction: column; gap: 6px; }
.ind-filters .filter-group label {
  font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.ind-filters input[type="date"] { width: auto; }

.dropdown-filter { position: relative; }
.dropdown-filter-btn {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit; min-width: 120px; text-align: left;
}
.dropdown-filter-btn:hover { border-color: var(--accent); }
.dropdown-filter-panel {
  position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(17,24,39,.12); padding: 10px 14px; min-width: 240px;
  display: flex; flex-direction: column; max-height: 360px;
}
/* Если снизу не хватает места до края экрана — открываем вверх от кнопки
   (см. positionDropdownPanel в api.js). */
.dropdown-filter-panel.dropdown-filter-panel-up {
  top: auto; bottom: 100%; margin-top: 0; margin-bottom: 4px;
}
/* Если справа не хватает места (кнопка ближе к правому краю, например на
   узком ноутбуке) — открываем от правого края кнопки, а не от левого. */
.dropdown-filter-panel.dropdown-filter-panel-right {
  left: auto; right: 0;
}
.dropdown-filter-search {
  width: 100%; padding: 6px 10px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 13px; flex-shrink: 0; box-sizing: border-box;
}
.dropdown-filter-items { overflow-y: auto; }
.dropdown-filter-panel .checkbox-row { padding: 3px 0; font-size: 13px; }
.dropdown-filter-group-label {
  font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  margin: 10px 0 4px;
}
.dropdown-filter-group-label:first-child { margin-top: 0; }
.dropdown-filter-empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }
.dropdown-filter-entity-row { margin-top: 6px; }
.dropdown-filter-entity-row:first-child { margin-top: 0; }
.dropdown-filter-parent-row { font-weight: 600; }

/* ── Чипы выбранных значений под кнопкой мультиселект-фильтра ──── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px;
  background: var(--accent-soft); color: var(--accent-hover); border-radius: 999px;
  font-size: 12px; line-height: 1.6; max-width: 100%;
}
.filter-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip-remove {
  flex-shrink: 0; border: none; background: none; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px; opacity: .7;
}
.filter-chip-remove:hover { opacity: 1; }

.ind-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.ind-card-header h2 { margin: 0; font-size: 16px; }
.ind-card-header .tabs { margin-bottom: 0; }

.ind-body { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.ind-metrics { display: flex; flex-direction: column; gap: 20px; min-width: 200px; }
.ind-metric-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ind-metric-value { font-size: 24px; font-weight: 700; }
.ind-metric-plan { font-size: 12px; color: var(--accent); margin-top: 2px; }

.ind-chart-area { flex: 1; min-width: 320px; }
.ind-chart-svg { width: 100%; height: auto; display: block; }
.ind-gridline { stroke: var(--border); stroke-width: 1; }
.ind-axis-label { font-size: 11px; fill: var(--text-muted); }
.ind-axis-label-future { fill: var(--accent); font-style: italic; }
.ind-bar-income { fill: var(--ind-income); }
.ind-bar-expense { fill: var(--ind-expense); }
.ind-line-profit-pos { stroke: var(--ind-profit); stroke-width: 2; }
.ind-line-profit-neg { stroke: var(--danger); stroke-width: 2; }
.ind-line-dividends { stroke: var(--ind-dividends); stroke-width: 2; }
.ind-line-future { stroke-dasharray: 5 4; }
.ind-dot-profit-pos { fill: var(--ind-profit); }
.ind-dot-profit-neg { fill: var(--danger); }
.ind-dot-dividends { fill: var(--ind-dividends); }

.ind-slider { position: relative; height: 20px; margin: 0 20px 8px; }
.ind-slider-track {
  position: absolute; top: 50%; left: 0; right: 0; height: 4px; transform: translateY(-50%);
  background: var(--bg); border-radius: 999px;
}
.ind-slider-range {
  position: absolute; top: 50%; height: 4px; transform: translateY(-50%);
  background: var(--accent-soft); border-radius: 999px;
}
.ind-slider-handle {
  position: absolute; top: 50%; width: 16px; height: 16px; transform: translate(-50%, -50%);
  background: var(--surface); border: 2px solid var(--accent); border-radius: 50%; cursor: grab;
}
.ind-slider-handle:active { cursor: grabbing; }

.ind-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; }
.ind-legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.ind-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.ind-legend-swatch.ind-legend-line { height: 3px; border-radius: 2px; }
