/* ========== Design tokens (дизайн-система) ==========
   Единый источник правды палитры/радиусов/теней. Новый CSS использует var(--cb-*), а не литералы.
   Документ: culture-biz-admin-doc/docs/guides/ui-design-system.md
   Часть легаси-правил ниже ещё с литералами — мигрируют по мере правок (значения совпадают). */
:root {
    /* Поверхности и текст */
    --cb-bg: #f5f7fa;
    --cb-surface: #ffffff;
    --cb-surface-muted: #f7fafc;
    --cb-surface-alt: #f8fafc;
    --cb-text: #1a1a2e;
    --cb-text-heading: #2d3748;
    --cb-text-body: #4a5568;
    --cb-text-muted: #718096;
    --cb-text-faint: #a0aec0;

    /* Бренд и границы */
    --cb-brand: #667eea;
    --cb-brand-strong: #5a67d8;
    --cb-brand-weak: #eef1fe;
    --cb-sidebar: #1a1a2e;
    --cb-border: #e2e8f0;
    --cb-border-weak: #edf2f7;
    --cb-border-faint: #f1f5f9;
    --cb-border-input: #a0aec0; /* граница полей ввода — заметная (было почти невидимо: --cb-border и Radzen base-300 слишком светлые) */

    /* Семантика статусов: fg / mid (заливка баров) / bg (фон бейджа) */
    --cb-success: #276749; --cb-success-mid: #48bb78; --cb-success-bg: #f0fff4;
    --cb-warn:    #c05621; --cb-warn-mid:    #ed8936; --cb-warn-bg:    #fffaf0;
    --cb-danger:  #c53030; --cb-danger-mid:  #e53e3e; --cb-danger-bg:  #fff5f5;
    --cb-info:    #2b6cb0; --cb-info-mid:    #4299e1; --cb-info-bg:    #ebf8ff;
    --cb-active:  #2c7a7b; --cb-active-bg:   #e6fffa;

    /* Радиусы и тени */
    --cb-radius-sm: 6px;
    --cb-radius: 8px;
    --cb-radius-lg: 10px;
    --cb-radius-pill: 12px;
    --cb-shadow-card: 0 1px 4px rgba(0,0,0,.08);
    --cb-shadow-pop: 0 4px 20px rgba(0,0,0,.15);
}

/* Границы полей ввода Radzen (RadzenTextBox/Numeric/DropDown/TextArea/DatePicker/MultiSelect/Lookup):
   тема default брала слишком светлый --rz-base-300 (#dadfe2) — контур почти не читался. Затемняем
   ТОЛЬКО input-переменные темы (не сам --rz-base-300: у него ещё границы таблиц/панелей). site.css
   грузится после default.css, оба блока — :root, поэтому переопределение выигрывает по порядку.
   Hover заметнее, focus — бренд (нельзя оставить normal темнее hover/focus, иначе контур светлеет). */
:root {
    --rz-input-border: 1px solid var(--cb-border-input);
    --rz-input-hover-border: 1px solid var(--cb-text-muted);
    --rz-input-focus-border: 1px solid var(--cb-brand);
}

/* Текстовые утилиты — приглушённый текст классом вместо инлайнового color: */
.text-body { color: var(--cb-text-body); }
.text-muted { color: var(--cb-text-muted); }
.text-faint { color: var(--cb-text-faint); }

/* Подзаголовок блока внутри контента (бывшие инлайновые h3/h4) */
.subsection-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--cb-text-body); }

/* Плашка-сводка над списком: счётчик + ключевые величины (заменяет инлайновые f7fafc-плашки) */
.summary-strip {
    margin: 0 0 12px; padding: 8px 12px; border-radius: var(--cb-radius-sm);
    background: var(--cb-surface-muted); color: var(--cb-text-body); font-size: 13px;
}
/* Хиро-строка экономики объекта над вкладками карточки ОКН (BF-6): выровнена по полям страницы 24px */
.okn-hero-economy { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 24px; }
.okn-hero-economy > .btn-outline { margin-left: auto; }
/* Кликабельная плитка/секция дашборда (BF-8) */
.stat-card-link { text-decoration: none; color: inherit; transition: box-shadow .12s ease; }
.stat-card-link:hover { box-shadow: var(--cb-shadow-pop); }
.dash-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Свёрнутые параметры сценария над секциями лендинга (BF-10) */
.scenario-params { margin: 8px 24px 0; }
.scenario-params > summary { cursor: pointer; font-size: 13px; color: var(--cb-text-body); padding: 6px 0; user-select: none; }
/* Якорная навигация по секциям лендинга сценария (BF-9): липкая полоса под шапкой */
.scenario-anchors {
    position: sticky; top: 61px; z-index: 5;
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 24px; background: var(--cb-surface); border-bottom: 1px solid var(--cb-border);
}
.scenario-anchors a {
    font-size: 13px; color: var(--cb-text-body); text-decoration: none;
    padding: 3px 10px; border-radius: var(--cb-radius-pill); background: var(--cb-surface-muted);
}
.scenario-anchors a:hover { color: var(--cb-brand); background: var(--cb-brand-weak); }
/* Якорь секции с учётом липкой шапки + навигации, чтобы заголовок не уезжал под них */
.card-section[id] { scroll-margin-top: 112px; }
/* Сравнение сценариев рядом на карточке ОКН (BF-2) */
.scenario-compare-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.scenario-compare { margin: 0 0 16px; overflow-x: auto; }
/* Индикатор автосохранения лендинга сценария (BF-3) */
.autosave { font-size: 13px; color: var(--cb-text-muted); }
.autosave.ok { color: var(--cb-success); }
.autosave.err { color: var(--cb-danger); font-weight: 600; }

/* Обёртка индикатора загрузки страницы (вместо инлайнового padding) */
.page-loading { padding: 40px 24px; }

/* Контентный блок с боковыми полями страницы вне form-grid (вместо инлайнового padding) */
.content-block { padding: 0 24px 24px; }

/* ========== Layout ========== */
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--cb-bg); color: var(--cb-text); }

/* FocusOnNavigate moves focus to <h1> after each navigation; suppress the outline
   for programmatic (non-keyboard) focus so titles don't show a stray black box,
   while keeping it for real keyboard navigation (accessibility). h1 is never
   reachable by Tab (only programmatic tabindex=-1), so killing its outline is safe. */
:focus:not(:focus-visible) { outline: none; }
h1:focus, h1:focus-visible { outline: none; }

.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; min-width: 240px; background: #1a1a2e; color: #e2e8f0;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    transition: transform .25s ease; z-index: 50;
}
.sidebar-brand {
    padding: 20px 16px; font-size: 18px; font-weight: 700; color: #fff;
    border-bottom: 1px solid #2d3748; display: flex; justify-content: space-between; align-items: center;
}
.sidebar-toggle { display: none; background: transparent; border: none; color: #a0aec0; font-size: 18px; cursor: pointer; padding: 0; line-height: 1; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
    display: block; padding: 10px 20px; color: #a0aec0; text-decoration: none;
    transition: all .2s; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: #2d3748; }
.sidebar-nav a.active { color: #fff; background: #2d3748; border-left-color: #667eea; }
.sidebar-footer { padding: 16px; border-top: 1px solid #2d3748; }
.sidebar-footer a { color: #a0aec0; text-decoration: none; font-size: 14px; }

.hamburger {
    display: none; position: fixed; top: 14px; left: 14px; z-index: 60;
    background: #1a1a2e; border: none; color: #e2e8f0; font-size: 22px;
    padding: 6px 10px; border-radius: 6px; cursor: pointer; line-height: 1;
}

@media (max-width: 768px) {
    .hamburger { display: block; }
    .sidebar { position: fixed; top: 0; left: 0; transform: translateX(-100%); }
    .sidebar-toggle { display: block; }
    .admin-layout.sidebar-open .sidebar { transform: translateX(0); }
    .main-content { padding-top: 52px; }
}

.main-content { flex: 1; overflow-x: auto; }

/* ========== Page header ========== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; background: #fff; border-bottom: 1px solid #e2e8f0;
    position: sticky; top: 0; z-index: 10;
}
.page-header h1 { margin: 0; font-size: 22px; display: inline; margin-left: 8px; }
.page-header > div { display: flex; align-items: center; gap: 8px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ========== Filter bar ========== */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 14px 24px; background: #fff; border-bottom: 1px solid #e2e8f0;
}
.filter-search { min-width: 260px; }
.filter-select { min-width: 150px; }
/* Счётчик результатов в правом краю фильтр-бара (G17.4) */
.filter-count { margin-left: auto; font-size: 13px; color: #718096; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* BF-17: фильтр «только проблемные» + маркер «требует внимания» в дереве портфеля */
.attn-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--cb-text-body); white-space: nowrap; cursor: pointer; }
.attn-badge { color: var(--cb-warn); font-size: 12px; margin-left: 3px; cursor: help; }
.tree-row-okn .attn-badge, .tree-row-scenario .attn-badge { font-size: 13px; }

/* ========== Grid ========== */
.okn-grid { margin: 0; border-radius: 0; }

/* ========== Badges ========== */
/* Бейджи статусов — единая семантика цвета через токены (источник правды класса — StatusBadges.cs) */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--cb-radius-pill); font-size: 12px; font-weight: 500; }
.badge-registry { background: var(--cb-border-weak); color: var(--cb-text-body); }
.badge-preproject { background: var(--cb-info-bg); color: var(--cb-info); }
.badge-design { background: #faf5ff; color: #6b46c1; } /* фиолетовый «Проектирование» — единичный lifecycle-цвет, токена нет */
.badge-restoration { background: var(--cb-danger-bg); color: var(--cb-danger); }
.badge-commissioning { background: var(--cb-warn-bg); color: var(--cb-warn); }
.badge-operating { background: var(--cb-success-bg); color: var(--cb-success); }
.badge-active { background: var(--cb-active-bg); color: var(--cb-active); } /* «Активный» сценарий — teal, не красный (G17.1) */
.badge-draft { background: var(--cb-border-weak); color: var(--cb-text-body); }
.badge-published { background: var(--cb-success-bg); color: var(--cb-success); }
.badge-archived { background: var(--cb-danger-bg); color: var(--cb-danger); }
.badge-pending { background: var(--cb-warn-bg); color: var(--cb-warn); }
.badge-needsreview { background: var(--cb-info-bg); color: var(--cb-info); }
.badge-approved { background: var(--cb-success-bg); color: var(--cb-success); }
.badge-rejected { background: var(--cb-danger-bg); color: var(--cb-danger); }
.badge-downloaded { background: var(--cb-success-bg); color: var(--cb-success); }
.badge-notfound, .badge-failed { background: var(--cb-danger-bg); color: var(--cb-danger); }
.badge-planned { background: var(--cb-border-weak); color: var(--cb-text-body); }

/* ========== Forms ========== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 20px 24px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.wide { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: #4a5568; }

/* ========== Gallery ========== */
.photo-gallery { padding: 16px 24px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery-item img { width: 100%; height: 140px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: border .15s; }
.gallery-item.primary img { border-color: #667eea; }
.gallery-item img:hover { border-color: #90cdf4; }
.gallery-placeholder { height: 140px; background: #edf2f7; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: #718096; }
.no-media { color: #a0aec0; font-style: italic; }
.gallery-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 999; display: flex; align-items: center; justify-content: center; }
.gallery-lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
.lightbox-close { position: absolute; top: 16px; right: 16px; background: transparent; border: none; color: #fff; font-size: 32px; cursor: pointer; }

/* ========== Confirm dialog ========== */
.confirm-dialog { position: fixed; bottom: 24px; right: 24px; z-index: 100; padding: 16px 20px; display: flex; align-items: center; gap: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.15); }

/* ========== Dashboard ========== */
.dashboard { padding: 24px; display: flex; flex-direction: column; gap: 32px; }
.dash-section h2 { margin: 0 0 16px; font-size: 18px; color: #2d3748; }
.stat-cards { display: flex; flex-wrap: wrap; gap: 16px; }
.stat-card {
    background: #fff; border-radius: 10px; padding: 20px 24px;
    min-width: 140px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
    border-top: 4px solid #667eea;
}
.stat-card.stat-ok { border-top-color: #48bb78; }
.stat-card.stat-warn { border-top-color: #ed8936; }
.stat-value { font-size: 36px; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 13px; color: #718096; margin-top: 4px; }

/* Компактный «рабочий» вид KPI карточки сценария — показатели читаемы, но не давят на глаза.
   Глобальные .stat-card (дашборд) не трогаем: стили только при модификаторе .stat-cards-compact.
   Толстый цветной верхний бордер убран; смысл IRR/NPV несёт цвет самого значения (irr-good/bad). */
.stat-cards-compact { gap: 10px; }
.stat-cards-compact .stat-card {
    padding: 10px 14px; min-width: 104px; border-radius: 8px;
    background: #f8fafc; box-shadow: none;
    border: 1px solid #edf2f7; border-top: 1px solid #edf2f7;
}
.stat-cards-compact .stat-card.stat-ok,
.stat-cards-compact .stat-card.stat-warn { border-top-color: #edf2f7; }
.stat-cards-compact .stat-value { font-size: 21px; }
.stat-cards-compact .stat-label { font-size: 11px; margin-top: 2px; }

/* ===== Операторский дашборд «Мой день» (BF-17/BF-18): канбан дел + портфель + биржа ===== */
/* Чип-счётчик (N просрочено / M сегодня): семантика цвета токенами, как у бейджей */
.day-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.day-chip { display: inline-block; padding: 2px 8px; border-radius: var(--cb-radius-pill); font-size: 11px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-danger { background: var(--cb-danger-bg); color: var(--cb-danger); }
.chip-warn { background: var(--cb-warn-bg); color: var(--cb-warn); }
.chip-info { background: var(--cb-info-bg); color: var(--cb-info); }
.chip-success { background: var(--cb-success-bg); color: var(--cb-success); }

/* Канбан: колонки времени (просрочено → сегодня → на неделе → фоновые) */
.day-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
/* Колонка — flex+gap (вместо margin-top у карточек: в потоке смешаны ссылки, задачи и обёртки сигналов) */
.day-col { background: var(--cb-surface-alt); border: 1px solid var(--cb-border-weak); border-radius: var(--cb-radius-sm); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.day-col-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 0; font-size: 11px; font-weight: 600; color: var(--cb-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.day-task { display: block; background: var(--cb-surface); border: 1px solid var(--cb-border-weak); border-left: 3px solid var(--cb-border); border-radius: 6px; padding: 7px 9px; text-decoration: none; color: inherit; transition: box-shadow .12s; }
.day-task:hover { box-shadow: var(--cb-shadow-card); }
/* Обёртка derived-сигнала: «+ задача по сигналу» в правом верхнем углу на ховере */
.day-sig { position: relative; }
.task-from-signal { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border: 1px solid var(--cb-border); border-radius: 6px; background: var(--cb-surface); color: var(--cb-text-muted); font-size: 13px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .12s, color .12s, border-color .12s; }
.day-sig:hover .task-from-signal { opacity: 1; }
.task-from-signal:hover { color: var(--cb-brand); border-color: var(--cb-brand); }
.day-task.sev-danger { border-left-color: var(--cb-danger-mid); }
.day-task.sev-warn { border-left-color: var(--cb-warn-mid); }
.day-task.sev-info { border-left-color: var(--cb-info-mid); }
.day-task-act { display: block; font-size: 12px; font-weight: 600; color: var(--cb-text); line-height: 1.3; }
.day-task-ctx { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--cb-text-muted); margin-top: 3px; }
.day-task-due { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.day-task-due.neg { color: var(--cb-danger); }
.day-empty { padding: 14px 8px; text-align: center; font-size: 11px; color: var(--cb-text-faint); border: 1px dashed var(--cb-border-weak); border-radius: 6px; }
.day-note { margin: 10px 0 0; font-size: 11px; color: var(--cb-text-faint); line-height: 1.5; }
.chip-muted { background: var(--cb-border-weak); color: var(--cb-text-muted); }

/* Ручные задачи на канбане (этап 3): чекбокс + тело + «→ завтра»; derived-карточки остаются ссылками */
.day-task-manual { display: flex; align-items: flex-start; gap: 8px; }
.day-task-manual .task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-check { flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px; border: 1.5px solid var(--cb-border); border-radius: 6px; background: var(--cb-surface); color: transparent; font-size: 13px; font-weight: 700; line-height: 1; cursor: pointer; transition: border-color .12s, background .12s, color .12s; }
.task-check:hover { border-color: var(--cb-success-mid); color: var(--cb-success-mid); }
.task-check.on { background: var(--cb-success-mid); border-color: var(--cb-success-mid); color: #fff; }
.task-done { opacity: .72; }
.task-done .day-task-act { text-decoration: line-through; color: var(--cb-text-faint); }
.task-time { font-size: 12px; font-weight: 700; color: var(--cb-info); margin-right: 5px; font-variant-numeric: tabular-nums; }
.task-kind-ico { font-size: 11px; margin-right: 3px; }
.task-tomorrow { flex: 0 0 auto; border: none; background: transparent; color: var(--cb-text-faint); font-size: 13px; line-height: 1; padding: 3px 5px; border-radius: var(--cb-radius-sm); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s, background .12s; }
.day-task-manual:hover .task-tomorrow { opacity: 1; }
.task-tomorrow:hover { color: var(--cb-brand); background: var(--cb-brand-weak); }
/* Быстрое добавление внизу колонки: барьер записи ниже, чем у стикера */
.task-quick { display: block; width: 100%; padding: 6px 8px; border: 1px dashed var(--cb-border); border-radius: 6px; background: transparent; color: var(--cb-text-faint); font-size: 11px; font-family: inherit; text-align: left; cursor: pointer; transition: color .12s, border-color .12s; }
.task-quick:hover { color: var(--cb-brand); border-color: var(--cb-brand); }
.task-quick-input { display: block; width: 100%; padding: 6px 8px; border: 1px solid var(--cb-brand); border-radius: 6px; background: var(--cb-surface); font-size: 12px; font-family: inherit; color: var(--cb-text); outline: none; box-sizing: border-box; }

/* Диалог задачи (TaskEditDialog) */
.task-dlg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; }
.task-dlg-grid .form-group { min-width: 0; } /* даём колонкам ужиматься: длинный текст дропдауна усекается, а не распирает грид за края диалога */
.task-dlg-grid .form-group.wide { grid-column: 1 / -1; }
.task-dlg-when { display: flex; gap: 8px; }
.task-dlg-when input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--cb-border-input); border-radius: var(--cb-radius-sm); font-family: inherit; font-size: 13px; color: var(--cb-text); background: var(--cb-surface); }
.task-dlg-okn { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.task-dlg-clear { border: none; background: transparent; color: var(--cb-text-faint); font-size: 15px; cursor: pointer; padding: 2px 6px; border-radius: var(--cb-radius-sm); }
.task-dlg-clear:hover { color: var(--cb-danger); background: var(--cb-danger-bg); }
.task-dlg-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }

/* Две панели под канбаном: портфель + биржа */
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.dash-panel { background: var(--cb-surface); border: 1px solid var(--cb-border); border-radius: var(--cb-radius); box-shadow: var(--cb-shadow-card); padding: 16px; }
.dash-panel .dash-section-head { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--cb-border-weak); }
.dash-panel .dash-section-head h2 { font-size: 15px; margin: 0; }

/* Строка портфеля: сценарий + бейдж, объект, полоса освоения, IRR */
.pf-row { display: flex; align-items: center; gap: 14px; padding: 10px 4px; border-top: 1px solid var(--cb-border-faint); text-decoration: none; color: inherit; }
.pf-row:hover { background: var(--cb-surface-muted); }
.pf-name { flex: 1; min-width: 0; }
.pf-scenario { font-size: 13px; font-weight: 600; color: var(--cb-text); }
.pf-scenario .badge { margin-left: 6px; vertical-align: middle; }
.pf-okn { display: block; font-size: 12px; color: var(--cb-text-muted); margin-top: 2px; }
.pf-spent { width: 150px; flex: 0 0 auto; }
.pf-cap { display: block; font-size: 11px; color: var(--cb-text-muted); margin-top: 4px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-irr { width: 60px; flex: 0 0 auto; text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Строка открытой сделки биржи */
.deal-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--cb-border-faint); text-decoration: none; color: inherit; }
.deal-row:hover { background: var(--cb-surface-muted); }
.deal-name { flex: 1; min-width: 0; }
.deal-subject { display: block; font-size: 13px; font-weight: 600; color: var(--cb-text); }
.deal-okn { display: block; font-size: 12px; color: var(--cb-text-muted); margin-top: 2px; }
.deal-amount { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.deal-days { font-size: 11px; color: var(--cb-warn); white-space: nowrap; }

/* ===== Избранное (этап 2 операторского дашборда): звезда-toggle + полоса чипов ===== */
/* Звезда в шапке карточки: ★ = закреплено (бренд — «выбор пользователя», как выбранная строка) */
.fav-toggle { border: none; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; color: var(--cb-text-faint); padding: 4px 6px; border-radius: var(--cb-radius-sm); transition: color .12s, background .12s; }
.fav-toggle:hover { color: var(--cb-brand); background: var(--cb-brand-weak); }
.fav-toggle.on { color: var(--cb-brand); }
.fav-toggle:disabled { opacity: .6; cursor: default; }
/* Полоса чипов на дашборде */
.fav-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.fav-chip { display: flex; align-items: center; gap: 9px; border: 1px solid var(--cb-border); border-radius: var(--cb-radius); padding: 8px 12px; background: var(--cb-surface); text-decoration: none; color: inherit; transition: border-color .12s; }
.fav-chip:hover { border-color: var(--cb-brand); }
.fav-star { color: var(--cb-brand); font-size: 14px; flex: 0 0 auto; }
.fav-body b { display: block; font-size: 13px; color: var(--cb-text); }
.fav-body small { display: block; font-size: 11px; color: var(--cb-text-muted); max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-kind { font-size: 10px; color: var(--cb-text-faint); text-transform: uppercase; letter-spacing: .04em; flex: 0 0 auto; }
.fav-hint { margin: 0; font-size: 12px; color: var(--cb-text-faint); }

@media (max-width: 1500px) {
    .day-board { grid-template-columns: repeat(2, 1fr); } /* 4 колонки → 2×2 */
}

@media (max-width: 1100px) {
    .day-board { grid-template-columns: 1fr; }
    .dash-cols { grid-template-columns: 1fr; }
}

/* ========== Confirm dialog overlay ========== */
.confirm-dialog-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.3);
    z-index: 200; display: flex; align-items: center; justify-content: center;
}
.confirm-dialog-overlay .confirm-dialog {
    position: static; padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 300px;
}
.confirm-dialog-overlay .confirm-dialog p { margin: 0; }
.confirm-dialog-overlay .confirm-dialog > div { display: flex; gap: 12px; }

/* ========== Login ========== */
body.login-body { margin: 0; padding: 0; }
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #1a1a2e; }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; color: #1a1a2e; font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.login-title { text-align: center; color: #718096; margin: 0 0 28px; font-size: 16px; font-weight: 400; }
.btn-login { width: 100%; padding: 12px; background: #667eea; color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-login:hover { background: #5a67d8; }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }
.login-error { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.login-cancel { display: block; text-align: center; margin-top: 16px; color: #718096; font-size: 14px; text-decoration: none; }
.login-cancel:hover { color: #5a67d8; }
.error-message { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }

/* Дружелюбная карточка глобального ErrorBoundary (render/lifecycle-исключения; детали — в журнале) */
.app-error { margin: 40px 24px; max-width: 640px; padding: 24px; background: var(--cb-surface); border: 1px solid var(--cb-border); border-radius: var(--cb-radius-lg); box-shadow: var(--cb-shadow-card); }
.app-error h2 { margin: 0 0 8px; font-size: 18px; color: var(--cb-text-heading); }
.app-error p { margin: 0 0 16px; color: var(--cb-text-body); }
.app-error-actions { display: flex; gap: 10px; align-items: center; }

/* ========== Blazor unhandled-error banner ========== */
/* Hidden by default; Blazor toggles display:block on a real circuit error. */
#blazor-error-ui {
    display: none;
    position: fixed; left: 0; bottom: 0; width: 100%; z-index: 1000;
    background: #fff5f5; color: #c53030; border-top: 2px solid #feb2b2;
    padding: 12px 20px; font-size: 14px; box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
#blazor-error-ui .reload { color: #c53030; font-weight: 600; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; color: #c53030; }

/* ========== OKN Map ========== */
.okn-map-page { display: flex; height: calc(100vh - 60px); overflow: hidden; }
.okn-map-sidebar {
    width: 280px; min-width: 280px; background: #fff; border-right: 1px solid #e2e8f0;
    overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.okn-map-sidebar h2 { margin: 0 0 4px; font-size: 16px; }
.okn-map-sidebar .filter-group { display: flex; flex-direction: column; gap: 4px; }
.okn-map-sidebar .filter-group label { font-size: 12px; font-weight: 600; color: #718096; }
.okn-map-container { flex: 1; position: relative; }
.okn-map-el { width: 100%; height: 100%; }
.okn-map-truncated {
    display: none; position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
    background: #fff3cd; border: 1px solid #ffc107; border-radius: 6px;
    padding: 6px 14px; font-size: 13px; z-index: 1000; white-space: nowrap;
}
.okn-map-stats { font-size: 12px; color: #718096; }

/* Popup */
.okn-leaflet-popup .leaflet-popup-content-wrapper { border-radius: 10px; padding: 0; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,.15); }
.okn-leaflet-popup .leaflet-popup-content { margin: 0; width: 240px !important; }
.okn-popup { display: flex; flex-direction: column; }
.okn-popup-photo { width: 100%; height: 140px; object-fit: cover; display: block; }
.okn-popup-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.okn-popup-reg { font-size: 11px; color: #a0aec0; }
.okn-popup-name { font-size: 14px; font-weight: 600; color: #1a1a2e; line-height: 1.3; }
.okn-popup-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; width: fit-content; }
.okn-popup-cat { font-size: 12px; color: #718096; }
.okn-popup-link { margin-top: 6px; font-size: 13px; color: #667eea; font-weight: 500; text-decoration: none; }
.okn-popup-link:hover { text-decoration: underline; }

/* ===== Единообразные иконки карты (круги) ===== */
.okn-marker-wrap, .okn-cluster-wrap { background: transparent; border: 0; }
.okn-marker {
    width: 100%; height: 100%; border-radius: 50%;
    border: 2px solid #fff; box-sizing: border-box;
    box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.okn-cluster {
    width: 100%; height: 100%; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #2b6cb0; color: #fff;
    border: 2px solid #fff; box-sizing: border-box;
    box-shadow: 0 1px 5px rgba(0,0,0,.4);
    font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.okn-cluster span { line-height: 1; }

/* ===== Меню «несколько ОКН под иконкой» (клик по кластеру) ===== */
.okn-menu-popup .leaflet-popup-content { margin: 0; width: 280px !important; }
.okn-menu-popup .leaflet-popup-content-wrapper { border-radius: 10px; padding: 0; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,.18); }
.okn-menu-head { padding: 9px 12px; font-size: 12px; font-weight: 600; color: #4a5568; background: #f7fafc; border-bottom: 1px solid #edf2f7; }
.okn-menu-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; text-decoration: none; border-bottom: 1px solid #f1f5f9; }
.okn-menu-item:hover { background: #f7fafc; }
.okn-menu-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; border: 1px solid rgba(0,0,0,.1); }
.okn-menu-text { display: flex; flex-direction: column; min-width: 0; }
.okn-menu-name { font-size: 13px; font-weight: 600; color: #1a1a2e; line-height: 1.3; }
.okn-menu-sub { font-size: 11px; color: #718096; line-height: 1.3; }
.okn-menu-more { padding: 8px 12px; font-size: 11px; color: #a0aec0; }

/* ========== Stages table ========== */
.stages-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.stages-table th { padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 600; color: #718096; border-bottom: 2px solid #e2e8f0; background: #f7fafc; }
.stages-table tbody tr:hover { background: #f7fafc; }
.stages-table tr.stage-root > td:nth-child(2) { font-weight: 600; }
.stages-table tr.stage-child > td { color: #4a5568; }

/* ========== Revenue scenario card ========== */
.revenue-scenario-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-top: 16px; }
.revenue-scenario-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; font-weight: 600; }

/* Секции дашборд-компоновки карточки сценария — история одним потоком вместо вкладок (G17.11) */
.card-section { margin-top: 28px; }
.card-section:first-child { margin-top: 8px; }
.card-section-title { font-size: 15px; font-weight: 700; color: var(--cb-text-heading); margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--cb-border-weak); }

/* Заголовок секции рядом с кнопкой-действием (редактор сценария): тот же масштаб, что
   .card-section-title, но без подчёркивания и в одной строке с «＋». Единый вид с просмотром. */
.section-head-row { display: flex; align-items: center; gap: 12px; margin: 24px 0 8px; }
.section-head-row h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--cb-text-heading); }

/* Mini map */
.okn-mini-map { height: 300px; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; margin-top: 16px; }
.okn-mini-map-placeholder { height: 300px; display: flex; align-items: center; justify-content: center; background: #f7fafc; border: 1px dashed #e2e8f0; border-radius: 8px; color: #a0aec0; font-size: 14px; margin-top: 16px; }

/* ========== Scenario Tree (Variant A) ========== */
.scenario-tree-wrap { overflow: auto; max-height: calc(100vh - 70px); }
.scenario-tree { width: 100%; border-collapse: collapse; }
.scenario-tree thead th {
    padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 600; color: #718096;
    border-bottom: 2px solid #e2e8f0; background: #f7fafc; white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
.scenario-tree .th-r { text-align: right; }
.scenario-tree .col-toggle { width: 28px; }
.scenario-tree .col-budget { width: 150px; }
.scenario-tree .col-irr { width: 80px; }
.scenario-tree .col-period { width: 190px; }
.scenario-tree .col-status { width: 130px; }
.scenario-tree .col-actions { width: 70px; }

/* Common cell */
.tc { padding: 9px 12px; vertical-align: middle; }
.tc-toggle { width: 28px; padding-right: 0; cursor: pointer; }
.tc-r { text-align: right; font-variant-numeric: tabular-nums; }
.tc-period { font-size: 12px; color: #718096; white-space: nowrap; }
/* Метка окупаемости на строке сценария — отличает её от календарных сроков этапа (G17.8) */
.period-payback { font-variant-numeric: tabular-nums; }
.tc-i1 { padding-left: 36px; }
.tc-i2 { padding-left: 68px; }
.tc-i3 { padding-left: 100px; }

/* OKN group header row (level 0) — only groups scenarios, no financial aggregates */
.tree-row-okn td { background: #eef2f9; border-top: 2px solid #c3cfe2; border-bottom: 1px solid #dce3ef; cursor: pointer; }
.tree-row-okn:hover td { background: #e7edf8; }
.tree-row-okn .tree-name { font-weight: 700; font-size: 14px; color: #1a1a2e; }
.tree-row-okn .tree-sub { font-size: 12px; color: #718096; margin-top: 2px; }
.okn-scenario-count { margin-left: 8px; font-size: 12px; color: #718096; white-space: nowrap; }

/* Selected node highlight (master-detail) */
.tree-row-scenario.selected td, .tree-row-stage.selected td, .tree-row-substage.selected td {
    box-shadow: inset 3px 0 0 #667eea; background: #eef1fe;
}

/* ===== Portfolio master-detail layout ===== */
.portfolio-layout { display: flex; gap: 16px; align-items: flex-start; }
.portfolio-tree { flex: 1; min-width: 0; }
.portfolio-panel {
    width: 400px; flex-shrink: 0; position: sticky; top: 16px;
    max-height: calc(100vh - 90px); overflow: auto;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px;
}
.panel-empty { color: #a0aec0; font-size: 14px; text-align: center; padding: 40px 12px; line-height: 1.5; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title { font-size: 16px; font-weight: 700; color: #1a1a2e; }
.panel-sub { font-size: 12px; color: #718096; margin-top: 2px; }
.panel-section-title { font-size: 12px; font-weight: 600; color: #718096; text-transform: uppercase; margin: 18px 0 8px; }
.panel-muted { color: #a0aec0; font-size: 13px; }
.panel-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.panel-kpi { background: #f7fafc; border: 1px solid #edf2f7; border-radius: 6px; padding: 8px 10px; }
.panel-kpi-val { font-size: 17px; font-weight: 700; color: #1a1a2e; font-variant-numeric: tabular-nums; }
.panel-kpi-label { font-size: 11px; color: #718096; margin-top: 2px; }
.panel-rev { border: 1px solid #edf2f7; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.panel-rev-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.panel-stream { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #4a5568; padding: 2px 0; }
.panel-stream-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.panel-cost { background: #f7fafc; border: 1px solid #edf2f7; border-radius: 6px; padding: 8px 10px; font-size: 13px; color: #2d3748; }
.panel-kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 5px 0; border-bottom: 1px solid #f1f5f9; }
.panel-link { display: inline-block; margin-top: 16px; font-size: 13px; color: #667eea; text-decoration: none; font-weight: 500; }
.panel-link:hover { text-decoration: underline; }
.panel-recalc { margin-top: 12px; width: 100%; }
.panel-recalc:disabled { opacity: .6; cursor: default; }

/* Scenario row — visual anchor: насыщеннее фон + верхний разделитель групп */
.tree-row-scenario td { background: #eaf0fb; border-bottom: 1px solid #e8edf4; border-top: 2px solid #d1dae8; cursor: pointer; }
.tree-row-scenario:hover td { background: #e3ebfa; }
.tree-row-scenario .tree-name { font-weight: 600; font-size: 14px; color: #1a1a2e; }
.tree-row-scenario .tree-sub { font-size: 12px; color: #718096; margin-top: 2px; }

/* Stage row */
.tree-row-stage td { background: #f7fafc; border-bottom: 1px solid #edf2f7; cursor: default; }
.tree-row-stage.has-children td { cursor: pointer; }
.tree-row-stage:hover td { background: #edf2f7; }
.tree-row-stage .tree-name { font-size: 13px; color: #2d3748; }

/* Sub-stage row */
.tree-row-substage td { background: #f0f4f8; border-bottom: 1px solid #e8edf4; }
.tree-row-substage:hover td { background: #e6ecf5; }
.tree-row-substage .tree-name { font-size: 12px; color: #4a5568; }

/* Цветовая «лесенка глубины»: левая метка уровня на первой ячейке строки (G17.6).
   Сценарий — яркий бренд-индиго (визуальный якорь истории), ОКН — тёмно-серый
   заголовок, этап/под-этап — всё бледнее по глубине. Так уровень читается слева
   с одного взгляда, не полагаясь на почти одинаковые фоны. */
.tree-row-okn > td:first-child { border-left: 4px solid #94a3b8; }
.tree-row-scenario > td:first-child { border-left: 4px solid #667eea; }
.tree-row-stage > td:first-child { border-left: 4px solid #b8c2d4; }
.tree-row-substage > td:first-child { border-left: 4px solid #dbe2ec; }

/* Chevron / leaf — шеврон = отдельная кнопка раскрытия (G17.7): курсор, зона клика, hover */
.tree-chevron { font-size: 10px; color: #718096; display: inline-block; width: 14px; text-align: center; cursor: pointer; padding: 5px; margin: -5px; border-radius: 4px; transition: background .12s, color .12s; }
.tree-chevron:hover { color: #2d3748; background: rgba(102,126,234,.14); }
.tree-leaf { font-size: 14px; color: #cbd5e0; display: inline-block; width: 14px; text-align: center; }
.tree-chevron-leaf { font-size: 10px; color: var(--cb-text-faint); display: inline-block; width: 14px; text-align: center; cursor: default; } /* пустой ▷ — узел без вложенных */
/* Accent link (e.g. OKN ↔ scenario cross-links) */
.link-accent { color: #667eea; text-decoration: none; font-weight: 500; }
.link-accent:hover { text-decoration: underline; }

.tree-irr { font-weight: 700; font-size: 14px; }
/* Маркер-подсказка к IRR ≥100% в дереве (тултип объясняет «короткий срок проекта», G17.2) */
.irr-info { font-size: 11px; color: #a0aec0; cursor: help; margin-left: 3px; vertical-align: middle; }
/* IRR colour bands — colour only, so they compose with any font size (tree cell or stat card) */
.irr-good { color: #276749; }
.irr-warn { color: #c05621; }
.irr-bad  { color: #c53030; }
.tree-link { font-size: 12px; color: #667eea; text-decoration: none; white-space: nowrap; border: 1px solid #c3cfe2; border-radius: 4px; padding: 3px 8px; background: #f0f4ff; }
.tree-link:hover { background: #667eea; color: #fff; text-decoration: none; }

/* Header action buttons */
.btn-outline {
    padding: 6px 14px; background: transparent; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 13px; color: #4a5568; cursor: pointer;
}
.btn-outline:hover { background: #f7fafc; border-color: #cbd5e0; }
.btn-outline:disabled { opacity: .5; cursor: not-allowed; } /* «нечего сохранять» и т.п. — явный неактивный вид */
.btn-outline:disabled:hover { background: transparent; border-color: var(--cb-border); }

/* ===== Plan vs Actual (освоение бюджета) ===== */
.tree-fact { display: block; font-size: 11px; font-weight: 600; margin-top: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Мини-полоса освоения в колонке бюджета дерева (заменяет слово «факт», G17.2) */
.tree-fact-bar { display: inline-block; width: 26px; height: 4px; border-radius: 2px; background: #e2e8f0; overflow: hidden; vertical-align: middle; margin-right: 5px; }
.tree-fact-bar > i { display: block; height: 100%; border-radius: 2px; background: #48bb78; }
.tree-fact-bar.over > i { background: #e53e3e; }
.spent-ok { color: #276749; }
.spent-warn { color: #c05621; }
.spent-over { color: #c53030; }
.spent-bar { height: 6px; border-radius: 3px; background: #e2e8f0; overflow: hidden; margin-top: 10px; }
.spent-bar > i { display: block; height: 100%; border-radius: 3px; background: #48bb78; }
.spent-bar.over > i { background: #e53e3e; }
.spent-caption { font-size: 11px; color: #718096; margin-top: 4px; text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Scenario timeline / roadmap ===== */
.timeline { margin-top: 8px; font-size: 12px; }
.timeline-axis { display: flex; justify-content: space-between; margin-left: 120px; color: #a0aec0; font-size: 11px; margin-bottom: 4px; }
.timeline-body { position: relative; }
.timeline-overlay { position: absolute; left: 120px; right: 0; top: 0; bottom: 0; pointer-events: none; }
.timeline-today { position: absolute; top: 0; bottom: 0; border-left: 2px dashed #dd6b20; z-index: 5; }
.timeline-row { display: flex; align-items: center; height: 24px; }
.timeline-label { width: 120px; box-sizing: border-box; padding-right: 8px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #4a5568; }
.timeline-track { position: relative; flex: 1; height: 13px; background: #f1f5f9; border-radius: 3px; }
.timeline-bar { position: absolute; top: 0; height: 13px; border-radius: 3px; min-width: 2px; }
.timeline-bar.plan { background: #cbd5e0; }
.timeline-bar.prog { background: #4299e1; }
.timeline-bar.done { background: #48bb78; }
.timeline-bar.skip { background: repeating-linear-gradient(45deg, #e2e8f0, #e2e8f0 4px, #edf2f7 4px, #edf2f7 8px); }
.timeline-overdue { position: absolute; top: -2px; right: -1px; height: 17px; border-left: 2px solid #e53e3e; }
.timeline-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-left: 120px; margin-top: 8px; color: #718096; font-size: 11px; }
.timeline-legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.timeline-legend .lg-plan { background: #cbd5e0; }
.timeline-legend .lg-prog { background: #4299e1; }
.timeline-legend .lg-done { background: #48bb78; }
.timeline-legend .lg-today { width: 0; height: 12px; border-left: 2px dashed #dd6b20; border-radius: 0; }

/* ===== Расходы vs доходы (ARW-G16) ===== */
.cf-chart { margin-top: 12px; }
.cf-head { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 12px; font-size: 13px; color: #4a5568; }
.cf-kpi { display: inline-flex; align-items: center; gap: 6px; }
.cf-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.cf-sw.exp { background: #f6ad55; }
.cf-sw.inc { background: #48bb78; }
.cf-plot { display: flex; align-items: flex-end; gap: 6px; min-height: 200px; padding: 8px 4px 0; border-bottom: 1px solid #e2e8f0; overflow-x: auto; }
.cf-col { flex: 1 1 0; min-width: 30px; display: flex; flex-direction: column; align-items: center; }
.cf-stack { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 170px; width: 100%; }
.cf-bar { width: 42%; max-width: 26px; border-radius: 3px 3px 0 0; min-height: 1px; }
.cf-bar.exp { background: #f6ad55; }
.cf-bar.inc { background: #48bb78; }
.cf-year { font-size: 11px; color: #718096; margin-top: 4px; }
.cf-net { font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cf-net.pos { color: #276749; }
.cf-net.neg { color: #c53030; }
.cf-foot { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: #718096; font-size: 11px; align-items: center; }
.cf-foot i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* ===== Scenario inline editor ===== */
/* Нативные контролы-исключения (даты этапов: DateOnly не покрывается RadzenDatePicker, ADR 0008) */
.scenario-edit input, .scenario-edit select, .scenario-edit textarea {
    padding: 6px 8px; border: 1px solid var(--cb-border-input); border-radius: 6px; font: inherit; background: #fff; color: #1a1a2e;
}
.scenario-edit input:disabled { background: #f1f5f9; color: #a0aec0; cursor: not-allowed; }

/* Таблица этапов: жёсткая сетка колонок, чтобы «Наименование» не схлопывалось (бывший дефект №1) */
.stage-edit-table { table-layout: fixed; }
.stage-edit-table td { padding: 6px 6px; vertical-align: top; }
.stage-edit-table .rz-textbox,
.stage-edit-table .rz-numeric,
.stage-edit-table .rz-dropdown { width: 100%; min-width: 0; }
.stage-edit-table .rz-numeric .rz-inputtext { text-align: right; }

/* Имя этапа: ветка дерева + цветная точка статуса + поле */
.stage-name-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.stage-name-cell .rz-textbox { flex: 1; }
.stage-twig { color: #cbd5e0; flex: 0 0 auto; }
/* Шеврон свёртки под-этапов в редакторе (как в дереве портфеля) */
.stage-chevron { flex: 0 0 auto; width: 16px; text-align: center; border: none; background: none; cursor: pointer; color: #718096; font-size: 10px; line-height: 1; padding: 0; }
.stage-chevron:hover { color: #2d3748; }
.stage-chevron-leaf { color: var(--cb-text-faint); cursor: default; } /* лист: пустой ▷ — явный маркер «нет под-этапов» */
/* Drag-and-drop перестановки этапов: ручка ⠿ + подсветка перетаскиваемой строки + линия места вставки */
.stage-grip { flex: 0 0 auto; cursor: grab; color: var(--cb-text-faint); font-size: 12px; line-height: 1; user-select: none; }
.stage-grip:hover { color: var(--cb-text-muted); }
.stage-grip:active { cursor: grabbing; }
.stage-edit-table tr.dragging > td { opacity: .45; }
/* линия вставки (у первой ячейки перебиваем status-бордер тем же селектором :first-child позже в исходнике) */
.stage-edit-table tr.drop-before > td, .stage-edit-table tr.drop-before > td:first-child { box-shadow: inset 0 2px 0 0 var(--cb-brand, #667eea); }
.stage-edit-table tr.drop-after > td, .stage-edit-table tr.drop-after > td:first-child { box-shadow: inset 0 -2px 0 0 var(--cb-brand, #667eea); }
.stage-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #cbd5e0; }
.stage-dot.st-planned { background: #cbd5e0; }
.stage-dot.st-inprogress { background: #4299e1; }
.stage-dot.st-completed { background: #48bb78; }
.stage-dot.st-skipped { background: #e53e3e; }

/* Контейнер (есть под-этапы) — отделяем фоном + жирность имени (визуальная иерархия в edit) */
.stage-edit-table tr.is-container > td { background: #f6f8fb; }
.stage-edit-table tr.is-container .stage-name-cell .rz-textbox input { font-weight: 600; }

/* Левый цветной бордер строки = статус этапа (восприятие прогресса с одного взгляда) */
.stage-edit-table tr.st-planned > td:first-child { box-shadow: inset 4px 0 0 #cbd5e0; }
.stage-edit-table tr.st-inprogress > td:first-child { box-shadow: inset 4px 0 0 #4299e1; }
.stage-edit-table tr.st-completed > td:first-child { box-shadow: inset 4px 0 0 #48bb78; }
.stage-edit-table tr.st-skipped > td:first-child { box-shadow: inset 4px 0 0 #e53e3e; }

/* Освоение под полем «факт» + пояснение к вычисляемому (заблокированному) «плану» */
.stage-spent { display: block; font-size: 11px; font-weight: 600; margin-top: 3px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-calc-note { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 10px; color: #a0aec0; margin-top: 3px; white-space: nowrap; }

/* Сроки: план над фактом, компактно (4 нативных date в две строки) */
.stage-dates { display: flex; flex-direction: column; gap: 3px; }
.stage-dates .dates-row { display: flex; align-items: center; gap: 3px; }
.stage-dates .dates-lbl { font-size: 10px; color: #a0aec0; flex: 0 0 26px; }
.stage-dates input[type=date] { flex: 1; min-width: 0; padding: 4px; border: 1px solid var(--cb-border-input); border-radius: 6px; font: inherit; font-size: 12px; color: #1a1a2e; background: #fff; }

/* Итоговая строка таблицы этапов */
.stage-edit-table tfoot td { border-top: 2px solid #e2e8f0; padding: 8px 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-edit-table tfoot .ft-label { color: #4a5568; }
.stage-edit-table tfoot .ft-prelim { font-weight: 400; font-size: 11px; color: #a0aec0; }
.stage-del { border: none; background: none; color: #c53030; cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 6px; }
.stage-del:hover { color: #9b2c2c; }
.revenue-edit-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
.revenue-edit-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
/* Поток дохода: выровненная под-форма с метками над полями (G17.10) */
.stream-edit { padding: 10px 0; border-top: 1px solid #f1f5f9; }
.stream-edit-main, .stream-edit-params { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.stream-edit-params { margin-top: 8px; }
.fld { display: flex; flex-direction: column; gap: 3px; width: 132px; }
.fld > label { font-size: 11px; color: #718096; font-weight: 500; line-height: 1.2; }
.fld-grow { flex: 1 1 auto; width: auto; min-width: 160px; }
.fld-narrow { width: 100px; }
.fld .rz-textbox, .fld .rz-numeric, .fld .rz-dropdown { width: 100%; min-width: 0; }
.fld .rz-numeric .rz-inputtext { text-align: right; }
.stream-del { align-self: flex-end; margin-bottom: 4px; }

/* Участники сценария в редакторе (DM-4): строка «участник / роль / дата вхождения» */
.participant-edit-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 8px 0; border-top: 1px solid #f1f5f9; }
.participant-edit-row .stage-del { align-self: flex-end; margin-bottom: 4px; }

/* Стоимость этапа по ставке (DM-2): ставка ₽/кв.м + площадь в ячейке «Стоимость (план)» */
.stage-unitrate { display: flex; flex-direction: column; gap: 2px; }
.stage-unitrate .rz-numeric { width: 100%; }
.stage-unitrate .rz-numeric .rz-inputtext { text-align: right; }
.ur-lbl { font-size: 10px; color: #718096; font-weight: 500; line-height: 1.1; }

/* BF-15: селектор метода расчёта в строке этапа + поле «% бюджета» (стек, как unit-rate) */
.stage-method { margin-bottom: 4px; }
.stage-method .rz-dropdown { width: 100%; }
.stage-pct { display: flex; flex-direction: column; gap: 2px; }
.stage-pct .rz-numeric { width: 100%; }
.stage-pct .rz-numeric .rz-inputtext { text-align: right; }

/* Липкая панель действий редактора — Save/Отмена доступны со дна длинной формы (G17.9).
   Отрицательные поля растягивают бар на всю ширину контейнера .scenario-edit (его padding 20/24). */
.edit-actions-bar {
    position: sticky; bottom: 0; z-index: 8;
    display: flex; align-items: center; gap: 12px;
    margin: 24px -24px -20px; padding: 12px 24px;
    background: #fff; border-top: 1px solid #e2e8f0; box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.edit-actions-hint { flex: 1; font-size: 12px; color: #a0aec0; }

/* ===== Декомпозиция этапов: под-этапы и документы (ARW-G15) ===== */
.stage-row-actions { white-space: nowrap; text-align: right; }
.stage-mini {
    border: 1px solid #e2e8f0; background: #fff; color: #4a5568; cursor: pointer;
    font-size: 12px; line-height: 1; padding: 3px 6px; border-radius: 5px; margin-right: 2px;
}
.stage-mini:hover { background: #f7fafc; border-color: #cbd5e0; }
.stage-mini.has-docs { color: #2b6cb0; border-color: #bee3f8; background: #ebf8ff; }
.stage-mini.has-tasks { color: var(--cb-brand); border-color: var(--cb-brand-weak); background: var(--cb-brand-weak); } /* этап 3b: открытые задачи этапа */
.stage-row-active > td { background: #f7fafc; }
.artifact-editor { border: 1px solid #bee3f8; border-radius: 8px; padding: 12px; margin: 10px 0 4px; background: #f7fbff; }
.artifact-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.artifact-editor-head strong { flex: 1; color: #2c5282; font-size: 14px; }
.artifact-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid #e6f0f9; }
.artifact-row input, .artifact-row select { padding: 4px 6px; border: 1px solid var(--cb-border-input); border-radius: 4px; font-size: 13px; }
/* Инлайн-строка редактора документов под своим этапом дерева (прижата к строке, без hover-подсветки) */
.stage-edit-table tr.artifact-editor-row > td { padding: 0 6px 8px; }
.stage-edit-table tr.artifact-editor-row:hover { background: transparent; }
.artifact-editor-row .artifact-editor { margin-top: 2px; }

/* Инлайн-панель задач этапа (лестница как у документов, этап 3b) */
.task-editor { border: 1px solid var(--cb-brand-weak); border-radius: 8px; padding: 12px; margin: 10px 0 4px; background: #fbfcff; }
.task-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.task-editor-head strong { flex: 1; color: #2c5282; font-size: 14px; }
.task-line { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid #eef2f7; }
.task-line-check { flex: 0 0 auto; width: 18px; height: 18px; padding: 0; border: 1.5px solid #cbd5e0; border-radius: 4px; background: #fff; cursor: pointer; }
.task-line-check:hover { border-color: var(--cb-brand); }
.task-line-body { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
.task-line-body:hover .task-line-title { text-decoration: underline; }
.task-line-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-line-ico { flex: 0 0 auto; }
.task-line-note { color: #a0aec0; font-size: 12px; }
.task-line-due { flex: 0 0 auto; font-size: 12px; color: #718096; }
.task-line-due.neg { color: #c53030; }
.task-new-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0 2px; margin-top: 4px; border-top: 1px solid #eef2f7; }
.task-new-row input[type=date] { padding: 4px 6px; border: 1px solid var(--cb-border-input); border-radius: 4px; font-size: 13px; }
/* Инлайн-строка панели задач под своим этапом дерева (как у документов) */
.stage-edit-table tr.task-editor-row > td { padding: 0 6px 8px; }
.stage-edit-table tr.task-editor-row:hover { background: transparent; }
.task-editor-row .task-editor { margin-top: 2px; }

/* ===== Dictionary CRUD ===== */
.dict-add { display: flex; gap: 8px; margin: 12px 0; }
.dict-add input { flex: 0 0 360px; max-width: 360px; padding: 6px 8px; border: 1px solid var(--cb-border-input); border-radius: 6px; }
.dict-readonly { padding: 12px 0 0 20px; color: #2d3748; }
.dict-readonly li { padding: 2px 0; }
