/* ==========================================================================
   Немезида — светлая тема в стиле Битрикс24
   Палитра: #0077FF (основной), #FF5757 (красный), #FFB800 (жёлтый), #2ED24A (зелёный)
   ========================================================================== */

:root {
  --primary: #0077ff;
  --primary-strong: #0061d4;
  --primary-weak: #e6f1ff;
  --red: #ff5757;
  --red-weak: #ffecec;
  --yellow: #ffb800;
  --yellow-weak: #fff7e0;
  --green: #2ed24a;
  --green-weak: #e6f9ea;

  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --line: #e4e8ee;
  --line-strong: #cdd4de;

  --text: #212a33;
  --text-dim: #5f6b7a;
  --text-faint: #8a95a5;
  --text-invert: #ffffff;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 8px 28px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.16);

  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", "Helvetica Neue", Helvetica, system-ui, sans-serif;
  --font-display: "Manrope", "Inter", system-ui, sans-serif;

  --speed: 0.24s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* --------------------------------------------------------------------------
   Экраны
   -------------------------------------------------------------------------- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* --------------------------------------------------------------------------
   Лендинг
   -------------------------------------------------------------------------- */
#screen-landing { display: none; align-items: center; justify-content: center; padding: 48px 24px; }
#screen-landing.active { display: flex; }

.landing { max-width: 980px; width: 100%; text-align: center; animation: rise 0.6s var(--speed) ease both; }
.landing__badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--primary);
  border: 1px solid var(--primary-weak); background: var(--primary-weak);
  padding: 8px 18px; border-radius: 100px; margin-bottom: 24px;
}
.landing__title { font-family: var(--font-display); font-weight: 800; font-size: clamp(34px, 6vw, 56px); line-height: 1.08; letter-spacing: -0.02em; margin-bottom: 18px; }
.landing__title .accent { color: var(--primary); }
.landing__sub { color: var(--text-dim); font-size: 16px; max-width: 460px; margin: 0 auto 32px; }
.landing__form {
  display: flex; flex-direction: column; gap: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); text-align: left;
}
.field { display: flex; flex-direction: column; gap: 7px; text-align: left; }
.field__label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.field__input {
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; padding: 11px 14px; outline: none;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.field__input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.field__textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field__input[type="date"] { font-size: 14px; }
.field__select { cursor: pointer; height: auto; min-height: 46px; }
.landing__or { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; width: 100%; }
.landing__or::before, .landing__or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.landing__hint { margin-top: 18px; font-size: 13px; color: var(--text-faint); display: flex; align-items: center; justify-content: center; gap: 8px; }
.landing__hint code { font-family: inherit; background: var(--panel); border: 1px solid var(--line); padding: 2px 6px; border-radius: 5px; color: var(--text-dim); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-weak); animation: pulse 2s infinite; }
.landing__entity { margin-top: 18px; text-align: left; }
.landing__entity summary { cursor: pointer; color: var(--text-faint); font-size: 13px; text-align: center; }
.entity-form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* Список всех дел на главном экране (таблица сделок) */
.landing__deals { margin-top: 28px; text-align: left; }
.landing__deals-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.landing__deals-title { font-size: 16px; font-weight: 800; color: var(--text); }
.landing__deals-meta { font-size: 13px; font-weight: 700; color: var(--text-faint); }
.landing-deals-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
}
.landing-deals-table { width: 100%; border-collapse: collapse; min-width: 820px; }
.landing-deals-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-2);
  text-align: left; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.landing-deals-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft, var(--line)); vertical-align: top; }
.landing-deals-table tbody tr:last-child td { border-bottom: none; }
.landing-deal-row { cursor: pointer; transition: background var(--speed); }
.landing-deal-row:hover { background: var(--primary-weak); }
.landing-deal-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.landing-deals__col-name { min-width: 200px; }
.landing-deals__col-phase { min-width: 130px; white-space: nowrap; }
/* Колонка «Иски и розыск»: 4 категории, каждая в своей строке — чуть шире. */
.landing-deals__col-tracks { min-width: 420px; }
.landing-deal-name { display: block; font-weight: 700; font-size: 13px; color: var(--text); line-height: 1.3; }
.landing-deal-id { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; color: var(--text-faint); }
/* Две строки «Этап»: приложение (из стратегии) + этап из CRM (с суффиксом). */
.landing-phase-line { display: flex; align-items: center; gap: 6px; }
.landing-phase-line + .landing-phase-line { margin-top: 6px; }
.landing-phase-label { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); flex-shrink: 0; }
.landing-deal-phase {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: var(--primary-weak); color: var(--primary);
  font-size: 12px; font-weight: 800;
}
.landing-deal-phase--muted { background: var(--panel-2); color: var(--text-faint); }
/* Цвет «Этапа из CRM» по суффиксу: цифра — оранжевый, (о) — зелёный, (н) — красный. */
.landing-deal-phase--orange { background: #fff3e0; color: #e08600; border: 1px solid #ffb74d; }
.landing-deal-phase--green { background: var(--green-weak); color: var(--green); border: 1px solid var(--green); }
.landing-deal-phase--red { background: var(--red-weak); color: var(--red); border: 1px solid var(--red); }
/* Цветные чипы треков («Иски и розыск»): овальчики с цветом по состоянию стадии. */
.landing-track-tag {
  display: flex; align-items: baseline; gap: 6px;
  width: 100%;
  margin: 0 0 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px; line-height: 1.3;
  border: 1px solid transparent;
  white-space: normal;
}
.landing-track-tag em { font-style: normal; font-weight: 800; flex-shrink: 0; }
/* Зелёный — ок / завершено */
.landing-track-tag--ok { background: var(--green-weak); border-color: var(--green); color: var(--green); }
.landing-track-tag--ok em { color: var(--green); }
/* Красный — требует внимания (первая стадия неустойки, розыск на первой стадии) */
.landing-track-tag--red { background: var(--red-weak); border-color: var(--red); color: var(--red); }
.landing-track-tag--red em { color: var(--red); }
/* Primary — в работе */
.landing-track-tag--current { background: var(--primary-weak); border-color: var(--primary); color: var(--primary); }
.landing-track-tag--current em { color: var(--primary); }
/* Серый — ещё не начато */
.landing-track-tag--muted { background: var(--panel-2); border-color: var(--line); color: var(--text-faint); }
.landing-track-tag--muted em { color: var(--text-faint); }
.landing-deals-empty { padding: 18px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* --------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 14px; border: none; border-radius: var(--radius-sm);
  padding: 11px 18px; cursor: pointer; transition: transform 0.12s, box-shadow var(--speed), background var(--speed);
  white-space: nowrap;
}
.btn--primary { background: var(--primary); color: var(--text-invert); box-shadow: 0 4px 14px rgba(0, 119, 255, 0.28); }
.btn--primary:hover { background: var(--primary-strong); box-shadow: 0 6px 18px rgba(0, 119, 255, 0.34); }
.btn--ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); }
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn--light { background: var(--primary-weak); color: var(--primary); }
.btn--light:hover { background: var(--primary); color: var(--text-invert); }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--xs { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Загрузка / Ошибка
   -------------------------------------------------------------------------- */
#screen-loading { display: none; align-items: center; justify-content: center; }
#screen-loading.active { display: flex; }
.loading { text-align: center; }
.loading__spinner { width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
.loading__text { color: var(--text-dim); }

#screen-error { display: none; align-items: center; justify-content: center; padding: 40px 24px; }
#screen-error.active { display: flex; }
.error-card { text-align: center; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.error-card__icon { width: 56px; height: 56px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; color: var(--red); background: var(--red-weak); border-radius: 50%; }
.error-card__title { font-size: 22px; margin-bottom: 8px; }
.error-card__msg { color: var(--text-dim); margin-bottom: 20px; }

/* --------------------------------------------------------------------------
   Шапка приложения
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 22px;
  padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.app-header__brand { display: flex; align-items: center; gap: 12px; }
.app-header__emblem {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong)); border-radius: 11px;
}
.app-header__name { font-family: var(--font-display); font-weight: 800; font-size: 17px; line-height: 1.1; }
.app-header__sub { font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }

.app-header__deal { display: flex; align-items: center; gap: 14px; margin-left: 8px; flex: 1; min-width: 0; }
.deal-switcher {
  display: flex; align-items: center; gap: 8px; background: var(--panel-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 12px;
  cursor: pointer; transition: border-color var(--speed);
  flex-shrink: 0;
}
.deal-switcher:hover { border-color: var(--primary); }
.deal-switcher__label { font-size: 12px; color: var(--text-faint); }
.deal-switcher__id { font-weight: 800; color: var(--primary); font-size: 15px; }
.deal-switcher__caret { color: var(--text-faint); font-size: 12px; }
.deal-title-block { min-width: 0; }
.stage-chip { display: inline-block; font-size: 11px; font-weight: 700; color: var(--primary); background: var(--primary-weak); padding: 2px 9px; border-radius: 100px; margin-bottom: 3px; }
.deal-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-header__actions { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }
.lawyer { display: flex; align-items: center; gap: 10px; }
.lawyer__avatar {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--primary-weak); color: var(--primary); font-weight: 800; font-size: 16px;
  background-size: cover; background-position: center; flex-shrink: 0;
}
.lawyer__role { font-size: 11px; color: var(--text-faint); }
.lawyer__name { font-weight: 700; font-size: 13px; }

/* --------------------------------------------------------------------------
   Навигация модулей
   -------------------------------------------------------------------------- */
.module-nav {
  display: flex; gap: 4px; max-width: 1280px; margin: 18px auto 0; padding: 0 28px;
}
.module-tab {
  background: none; border: none; color: var(--text-dim); font-weight: 700; font-size: 15px;
  padding: 10px 20px; border-radius: 10px 10px 0 0; cursor: pointer; position: relative;
  transition: color var(--speed), background var(--speed);
}
.module-tab:hover { color: var(--primary); background: var(--primary-weak); }
.module-tab.active { color: var(--primary); background: var(--panel); }
.module-tab.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -2px; height: 3px; background: var(--primary); border-radius: 3px; }

/* --------------------------------------------------------------------------
   Контент и модули
   -------------------------------------------------------------------------- */
.content { max-width: 1280px; margin: 0 auto; padding: 0 28px 80px; }
.module { display: none; }
.module.active { display: block; animation: rise 0.4s ease both; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 14px; }
.section-head__title { font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.section-head__meta { font-size: 13px; color: var(--text-faint); }

.empty-note { color: var(--text-faint); padding: 16px; text-align: center; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
.form-hint code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }

/* --------------------------------------------------------------------------
   Карусель стадий (Модуль Дело)
   -------------------------------------------------------------------------- */
.case-stages-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* Дополнительные поля дела перед стадиями («Доп. информация», «Ссылки на ИИ») */
.case-extra {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.case-extra .field { margin-top: 12px; }
.case-extra .section-head { margin-top: 0; }
.case-extra__foot {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
}
.case-extra__status { font-size: 13px; color: var(--text-faint); }
.stage-carousel {
  display: flex; align-items: flex-start; gap: 4px; overflow-x: auto; padding: 8px 2px 12px;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}

/* Узел линейки этапов (степпер): чип + имя + статус под ним. */
.step-node {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 76px; flex-shrink: 0;
}
.step-node__chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 62px; min-height: 58px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--panel-2); cursor: pointer;
  transition: transform var(--speed), border-color var(--speed), background var(--speed), opacity var(--speed);
}
.step-node__chip:hover { transform: translateY(-2px); border-color: var(--primary); }
.step-node__icon { font-size: 20px; line-height: 1; }
.step-node__num { font-size: 12px; font-weight: 800; color: var(--text-dim); }
.step-node__name {
  font-size: 10.5px; line-height: 1.2; font-weight: 600; color: var(--text-dim);
  text-align: center; max-width: 100px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  min-height: 24px;
}
.step-node__status {
  font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 0.02em; max-width: 96px; text-align: center; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-height: 12px;
}
.step-node.done .step-node__chip { border-color: var(--green); background: var(--green-weak); }
.step-node.done .step-node__num { color: var(--green); }
.step-node.done .step-node__name { color: var(--green); }
.step-node.done .step-node__status { color: var(--green); }
.step-node.current .step-node__chip { border-color: var(--primary); background: var(--primary-weak); animation: pulse 2.2s infinite; }
.step-node.current .step-node__num { color: var(--primary); }
.step-node.current .step-node__name { color: var(--primary); }
.step-node.current .step-node__status { color: var(--primary); }
.step-node.overdue .step-node__chip { border-color: var(--red); background: var(--red-weak); }
.step-node.overdue .step-node__num { color: var(--red); }
.step-node.overdue .step-node__name { color: var(--red); }
.step-node.overdue .step-node__status { color: var(--red); }
.step-node.locked { opacity: 0.45; }
.step-node.locked .step-node__chip { cursor: default; }
.step-node.locked .step-node__chip:hover { transform: none; border-color: var(--line); }
.step-node--finish .step-node__chip { border-style: dashed; }

/* Трек-сегмент между узлами: соединён по центру чипов. */
.step-seg {
  flex: 1 1 auto; min-width: 12px; height: 2px; background: var(--line-strong);
  margin-top: 29px; border-radius: 2px; align-self: flex-start;
}
.step-seg.done { background: var(--green); }
.step-seg.overdue { background: var(--red); }

/* --------------------------------------------------------------------------
   Документы дела (Модуль Дело)
   -------------------------------------------------------------------------- */
.case-docs { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 20px; }
.case-docs__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 14px; }
.case-doc {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.case-doc__icon { font-size: 18px; }
.case-doc__name { font-weight: 600; font-size: 13px; flex: 1; }
.case-doc__status { font-size: 12px; font-weight: 700; white-space: nowrap; }
.case-doc--ok { color: var(--green); }
.case-doc--no { color: var(--text-faint); }
.case-docs--other { border-style: dashed; }
.case-docs__group-label { grid-column: 1 / -1; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin: 4px 0 2px; }
.case-doc--file {
  text-decoration: none; color: var(--text); cursor: pointer;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.case-doc--file:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(0, 119, 255, 0.12); }
.case-doc--file .case-doc__status { color: var(--primary); }
/* Внутренняя ссылка карточки требуемого документа (блок «Договор. Доверенность.»):
   занимает всё место, даёт клик по названию, а кнопка загрузки стоит рядом. */
.case-doc__link {
  display: flex; align-items: center; gap: 10px; flex: 1;
  text-decoration: none; color: var(--text); cursor: pointer;
}
.case-doc__link:hover .case-doc__name { color: var(--primary); }

/* --------------------------------------------------------------------------
   Вкладки данных (Модуль Дело)
   -------------------------------------------------------------------------- */
.data-tabs { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 20px; overflow: hidden; }
.data-tabs__nav { display: flex; gap: 2px; padding: 12px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.data-tab {
  background: none; border: none; color: var(--text-dim); font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 8px 8px 0 0; cursor: pointer; transition: color var(--speed), background var(--speed);
  white-space: nowrap;
}
.data-tab:hover { color: var(--primary); background: var(--primary-weak); }
.data-tab.active { color: var(--primary); background: var(--primary-weak); }
.data-tabs__body { padding: 20px; }
.data-panel { min-height: 120px; }
.editable-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.editable-field {
  position: relative; display: flex; flex-direction: column; gap: 5px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: text; transition: border-color var(--speed), background var(--speed), box-shadow var(--speed);
}
.editable-field:hover { border-color: var(--primary); background: #fff; }
.editable-field:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-weak); }
.editable-field.sync-saved { border-color: rgba(46, 210, 74, 0.42); }
.editable-field.sync-error { border-color: rgba(255, 87, 87, 0.72); }
.editable-field__label { padding-right: 66px; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.editable-field__value { font-size: 14px; font-weight: 600; color: var(--text); min-height: 18px; }
.editable-field__hint { font-size: 11px; color: var(--text-faint); }
.editable-input {
  width: 100%; box-sizing: border-box; background: #fff; border: 1px solid var(--line-strong); border-radius: 7px; font-size: 14px;
  padding: 7px 9px; outline: none; font-weight: 600; color: var(--text); transition: border-color var(--speed), box-shadow var(--speed);
}
.editable-input:hover { border-color: var(--primary); }
.editable-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.editable-field__sync {
  position: absolute; top: 9px; right: 10px; min-width: 14px; text-align: right;
  font-size: 10px; font-weight: 800; color: var(--text-faint); white-space: nowrap;
}
.sync-saving .editable-field__sync, .sync-pending .editable-field__sync { color: var(--primary); }
.sync-saved .editable-field__sync { color: var(--green); font-size: 14px; }
.sync-error .editable-field__sync { color: var(--red); font-size: 14px; }
.editable-select { background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; font-size: 14px; padding: 6px 8px; font-weight: 600; }
.data-section-title { grid-column: 1 / -1; font-weight: 800; font-size: 14px; color: var(--primary); margin: 12px 0 2px; }
.data-section-title--sub { color: var(--text-dim); font-size: 12px; font-weight: 700; }
.data-actions { grid-column: 1 / -1; }
.data-tabs__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.data-hint { font-size: 12px; color: var(--text-faint); }
.data-auto-status { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-faint); }
.data-auto-status.is-pending, .data-auto-status.is-saving { color: var(--primary); }
.data-auto-status.is-saved { color: var(--green); }
.data-auto-status.is-error { color: var(--red); }
.case-extra__status.is-pending, .case-extra__status.is-saving { color: var(--primary); }
.case-extra__status.is-saved { color: var(--green); }
.case-extra__status.is-error { color: var(--red); }

/* --------------------------------------------------------------------------
   Канбан
   -------------------------------------------------------------------------- */
.kanban-top { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 26px; }
.stage-block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stage-block--current { border-top: 4px solid var(--primary); }
.stage-block--next { border-top: 4px solid var(--yellow); }
.stage-block__tag { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--text-faint); text-transform: uppercase; margin-bottom: 8px; }
.stage-block__head { font-family: var(--font-display); font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.stage-block__codes { font-size: 13px; color: var(--primary); font-weight: 700; margin-bottom: 14px; }
.stage-block__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kb-item { display: flex; flex-direction: column; gap: 2px; }
.kb-item__label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.kb-item__value { font-size: 15px; font-weight: 700; }
.kb-item__value--status { display: inline-block; padding: 2px 10px; border-radius: 100px; font-size: 12px; width: fit-content; }
.status--green { background: var(--green-weak); color: var(--green); }
.status--yellow { background: var(--yellow-weak); color: #b88700; }
.status--red { background: var(--red-weak); color: var(--red); }

.kanban-strip { background: rgba(255, 255, 255, 0.55); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 22px; }
.kanban-strip__list { display: flex; flex-wrap: wrap; gap: 10px; }
.strip-chip {
  display: flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 12px;
  background: var(--panel); border: 2px solid var(--line); cursor: pointer; font-weight: 700; font-size: 13px;
  transition: transform var(--speed), border-color var(--speed);
}
.strip-chip:hover { transform: translateY(-2px); border-color: var(--primary); }
.strip-chip.done { border-color: var(--green); color: var(--green); background: var(--green-weak); }
.strip-chip.red { border-color: var(--red); color: var(--red); background: var(--red-weak); }
.strip-chip.yellow { border-color: var(--yellow); color: #b88700; background: var(--yellow-weak); }
.strip-chip.current { border-color: var(--primary); color: var(--primary); background: var(--primary-weak); }
.strip-chip__icon { font-size: 15px; }

.kb-legend { display: flex; gap: 20px; margin-top: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.kb-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot-legend { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-legend--green { background: var(--green); }
.dot-legend--yellow { background: var(--yellow); }
.dot-legend--red { background: var(--red); }

/* --------------------------------------------------------------------------
   Доп. услуги
   -------------------------------------------------------------------------- */
.service-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-top: 20px; box-shadow: var(--shadow-sm); }
.service-card__head { margin-bottom: 16px; }
.service-card__title { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.service-card__body { display: flex; flex-direction: column; gap: 14px; }
.service-card__actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.penalty-mode { display: flex; gap: 20px; }
.penalty-rows { display: flex; flex-direction: column; gap: 8px; }
.penalty-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 0.8fr auto; gap: 8px; align-items: center; }
.penalty-manual, .penalty-upload { display: flex; flex-direction: column; gap: 12px; }
.penalty-result-wrap { margin-top: 8px; }
.penalty-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.penalty-table th, .penalty-table td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; }
.penalty-table thead th { background: var(--panel-2); font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.penalty-table tfoot td { background: var(--primary-weak); font-weight: 800; color: var(--primary); }
.penalty-total-cell { font-size: 17px; text-align: right; }

/* --------------------------------------------------------------------------
   Бухгалтерия — счета по сделке
   -------------------------------------------------------------------------- */
.acc-warning { margin: 0 0 16px; padding: 12px 16px; background: var(--warn-weak, #fff6e5); border: 1px solid var(--warn, #f5a623); border-radius: var(--radius-sm); color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.acc-summary { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.acc-card { flex: 1 1 200px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.acc-card__label { font-size: 12px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.acc-card__value { font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--text); }
.acc-table-wrap { margin-top: 4px; }
.acc-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.acc-table th, .acc-table td { border-bottom: 1px solid var(--line); padding: 11px 14px; text-align: left; vertical-align: top; }
.acc-table thead th { background: var(--panel-2); font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.acc-table tr:last-child td { border-bottom: none; }
.acc-table .num { text-align: right; white-space: nowrap; }
.acc-table td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.acc-empty { text-align: center; color: var(--text-faint); padding: 26px 14px; }
.pay-chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 700; margin-right: 6px; }
.pay-chip--paid { background: var(--green-weak, #e7f7ef); color: var(--green, #2fbd6e); }
.pay-chip--unpaid { background: var(--red-weak, #fdecec); color: var(--red, #e5484d); }

/* --------------------------------------------------------------------------
   Документы — каталог
   -------------------------------------------------------------------------- */
.doc-catalog { display: flex; flex-direction: column; gap: 22px; margin-top: 8px; }
.doc-cat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.doc-cat__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.doc-cat__icon { font-size: 20px; }
.doc-cat__name { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.doc-cat__count { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--primary); background: var(--primary-weak); padding: 3px 10px; border-radius: 100px; }
.doc-cat__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.doc-cat__item { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.doc-cat__item-top { display: flex; align-items: flex-start; gap: 8px; }
.doc-cat__code { flex-shrink: 0; font-size: 11px; font-weight: 800; color: var(--primary); background: var(--primary-weak); padding: 2px 7px; border-radius: 5px; margin-top: 2px; }
.doc-cat__title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.doc-cat__desc { font-size: 12px; color: var(--text-faint); flex: 1; }
.doc-cat__actions { display: flex; gap: 8px; }

/* --------------------------------------------------------------------------
   Модальные окна
   -------------------------------------------------------------------------- */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; padding: 24px; }
.modal.open { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.45); backdrop-filter: blur(4px); }
.modal__panel {
  position: relative; width: 100%; max-width: 600px; max-height: 90vh; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; animation: rise 0.3s ease both;
}
.modal__panel--wide { max-width: 860px; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal__code { font-size: 12px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.modal__title { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.3; }
.modal__close { background: none; border: none; color: var(--text-dim); font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal__close:hover { color: var(--red); }
.modal__body { padding: 24px; overflow-y: auto; }
.modal__missing { padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.modal__missing-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 8px; }
.missing-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.missing-chip-list .ok { color: var(--green); font-size: 13px; }
.missing-chip {
  font-size: 11px; font-weight: 600; color: var(--red);
  background: var(--red-weak); border: 1px solid rgba(255, 87, 87, 0.35);
  padding: 3px 9px; border-radius: 100px;
}
.modal__textarea { width: 100%; flex-grow: 1; min-height: 420px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 13.5px; line-height: 1.7; padding: 18px; resize: vertical; outline: none; border-radius: 0 0 var(--radius) var(--radius); }
.modal__foot { display: flex; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal__foot:empty { border-top: none; }

/* Форма этапа (Канбан) + авто-расчёт */
.stage-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stage-form .field--wide, .stage-form .stage-field--wide { grid-column: 1 / -1; }
.modal__desc { font-size: 12.5px; color: var(--text-dim); margin-top: 6px; white-space: pre-line; line-height: 1.5; max-height: 120px; overflow-y: auto; }

/* Модалка результата синхронизации в CRM */
.modal__panel--sm { max-width: 420px; }
.sync-result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 32px 28px 8px; }
.sync-result__icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: #fff;
}
.sync-result__title { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.sync-result__detail { font-size: 13px; color: var(--text-dim); line-height: 1.55; max-width: 340px; }
.sync-result__foot { justify-content: center; padding-bottom: 18px; }
.sync-ok .sync-result__icon { background: var(--green); box-shadow: 0 8px 20px rgba(46, 210, 74, 0.35); }
.sync-error .sync-result__icon { background: var(--red); box-shadow: 0 8px 20px rgba(255, 87, 87, 0.35); }
.sync-info .sync-result__icon { background: var(--yellow); box-shadow: 0 8px 20px rgba(255, 184, 0, 0.35); }
.stage-statements { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.stage-statement { display: flex; flex-direction: column; gap: 6px; }
.stage-statement__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stage-statement__label { font-weight: 700; font-size: 13px; color: var(--primary); }
.stage-statement textarea { min-height: 340px; }
.stage-responses { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.stage-responses__head { display: flex; align-items: center; }
.stage-responses__title { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--text); }
.stage-responses__list { display: flex; flex-direction: column; gap: 18px; }
.stage-response {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px;
}
.stage-response__head { display: flex; align-items: center; }
.stage-response__title { font-weight: 800; font-size: 13px; color: var(--primary); }
.stage-response__file { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.stage-response textarea { min-height: 110px; }
.stage-response .btn-ai-response { align-self: flex-start; }
.stage-response-files { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.response-files__empty { font-size: 12.5px; color: var(--text-faint); }
.response-files__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.response-files__list .case-doc__badge {
  font-size: 10px; font-weight: 800; color: var(--primary);
  background: var(--primary-weak); border: 1px solid rgba(0,119,255,0.25);
  border-radius: var(--radius-sm); padding: 1px 6px; white-space: nowrap;
}
.stage-file { display: flex; flex-direction: column; gap: 6px; }
.stage-file__input { padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: var(--text-dim); font-size: 13px; }
.stage-file__current { font-size: 12px; color: var(--green); font-weight: 600; }
.stage-file__list { display: flex; flex-direction: column; gap: 6px; }
.stage-file__item {
  font-size: 13px; font-weight: 600; color: var(--primary);
  background: var(--primary-weak); border: 1px solid rgba(0,119,255,0.25);
  padding: 7px 11px; border-radius: var(--radius-sm); text-decoration: none;
  display: flex; align-items: center; gap: 8px; word-break: break-all;
}
.stage-file__item:hover { background: var(--primary); color: #fff; }
.btn-ai-summary { align-self: flex-start; }
.stage-auto { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.auto-line { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.auto-line span { color: var(--text-dim); }
.auto-value { font-weight: 800; }
.auto-value--green, .auto-value { color: var(--green); }
.auto-value--red { color: var(--red); }

/* --------------------------------------------------------------------------
   Регистрация подачи (Э-1) в модалке этапа + навигация этапа
   -------------------------------------------------------------------------- */
.stage-register-wrap { margin-top: 18px; }
.stage-register {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 14px;
}
.stage-register__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.stage-register__title { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--text); }
.stage-register__sub { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; max-width: 460px; line-height: 1.45; }
.stage-register__empty { font-size: 13px; color: var(--text-faint); }
.stage-register__display {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: var(--panel);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 14px;
}
.reg-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.reg-item__label { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-faint); }
.reg-item__value { font-size: 14px; font-weight: 600; color: var(--text); word-break: break-word; }
.reg-item__value a { color: var(--primary); }

.stage-divider { height: 1px; background: var(--line-strong); margin: 18px 0; }

.stage-nav { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.stage-nav__row { display: flex; gap: 10px; width: 100%; }
.stage-nav__row .btn--block { width: auto; flex: 1 1 0; }
.stage-nav__row--3 { flex-wrap: wrap; }
.stage-nav-hint { margin: 0; }
.btn--block { width: 100%; justify-content: center; padding: 13px 18px; font-size: 15px; }

.register-form { display: flex; flex-direction: column; gap: 16px; }

.switch-form { display: flex; flex-direction: column; gap: 14px; }

/* --------------------------------------------------------------------------
   Toast / Skeleton
   -------------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity var(--speed), transform var(--speed);
  z-index: 2000; max-width: 90vw;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--success { background: var(--green); }
.toast--error { background: var(--red); }
.toast--info { background: var(--text); }

.skeleton { position: relative; overflow: hidden; background: var(--line); border-radius: var(--radius-sm); }
.skeleton--block { height: 80px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent); animation: shimmer 1.3s infinite; }

/* --------------------------------------------------------------------------
   Анимации
   -------------------------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* --------------------------------------------------------------------------
   Адаптивность
   -------------------------------------------------------------------------- */
@media (min-width: 1280px) {
  .kanban-top { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .app-header { flex-wrap: wrap; gap: 14px; }
  .app-header__deal { flex: 1 1 100%; order: 3; margin-left: 0; }
  .app-header__actions { margin-left: auto; }
  .kanban-top { grid-template-columns: 1fr; }
  .stage-form { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .content { padding: 0 16px 60px; }
  .module-nav { padding: 0 16px; }
  .app-header { padding: 12px 16px; }
  .app-header__actions { width: 100%; flex-wrap: wrap; }
  .app-header__actions .btn { flex: 1; }
  .lawyer { display: none; }
  .penalty-row { grid-template-columns: 1fr 1fr; }
  .stage-block__grid { grid-template-columns: 1fr; }
  .modal__panel--wide { max-width: 100%; }
  .data-tabs__foot { flex-direction: column; align-items: stretch; }
}

/* ===========================================================================
   Поиск сделки (выпадающий список)
   =========================================================================== */
.deal-search {
  position: relative;
  width: 100%;
}

.deal-search__results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
}

.deal-search__results.open {
  display: block;
}

.deal-search__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.15s ease;
}

.deal-search__item:last-child {
  border-bottom: none;
}

.deal-search__item:hover,
.deal-search__item.active {
  background: #f0f7ff;
}

.deal-search__id {
  flex-shrink: 0;
  min-width: 48px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eef3fb;
  color: #0077ff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.deal-search__title {
  flex: 1;
  font-size: 13px;
  color: #1f2a37;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deal-search__empty {
  padding: 12px;
  font-size: 13px;
  color: #8a94a6;
  text-align: center;
}

.deal-search__loading {
  padding: 12px;
  font-size: 13px;
  color: #8a94a6;
  text-align: center;
}

/* ===========================================================================
   Взыскание неустойки (блок в разделе Дело)
   =========================================================================== */
.penalty-case {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 20px;
  padding: 20px;
}
.penalty-case__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.penalty-case__stages {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.penalty-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 128px;
  padding: 12px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--speed), border-color var(--speed), box-shadow var(--speed);
  text-align: center;
}
.penalty-stage:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(0, 119, 255, 0.14);
}
.penalty-stage__num {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-faint);
}
.penalty-stage { position: relative; }
.penalty-stage__icon { font-size: 20px; line-height: 1; }
.penalty-stage__name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  line-height: 1.25;
}
.penalty-stage__sub {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-faint);
  line-height: 1.15;
  white-space: pre-line;
  text-align: center;
}
.penalty-stage.is-current .penalty-stage__sub { color: var(--primary); }
.penalty-stage.is-done .penalty-stage__sub { color: var(--green); }
.penalty-stage.is-final .penalty-stage__sub { color: var(--green); }

.penalty-stage.is-done {
  border-color: var(--green);
  background: var(--green-weak);
}
.penalty-stage.is-done .penalty-stage__name { color: var(--green); }

.penalty-stage.is-current {
  border-color: var(--primary);
  background: var(--primary-weak);
  animation: pulse 2.4s infinite;
}
.penalty-stage.is-current .penalty-stage__name { color: var(--primary); }

.penalty-stage.is-final {
  border-color: var(--green);
  background: linear-gradient(135deg, var(--green-weak), #d6f7df);
  box-shadow: 0 4px 16px rgba(46, 210, 74, 0.22);
}
.penalty-stage.is-final .penalty-stage__name { color: var(--green); font-weight: 800; }

.penalty-stage.is-warn {
  border-color: var(--yellow);
  background: var(--yellow-weak);
  animation: pulse 1.6s infinite;
}
.penalty-stage.is-warn .penalty-stage__name { color: #b88700; }

.penalty-stage.is-pending { opacity: 0.72; }

/* Общий аккордеон */
.penalty-case__accordion {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  overflow: hidden;
}
.penalty-case__accordion.open {
  animation: rise 0.3s var(--speed) ease both;
}
.penalty-case__acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.penalty-case__acc-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--primary);
}
.penalty-case__fields {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.penalty-case__empty {
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 4px;
}

.penalty-group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.penalty-group__num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-weak);
  border-radius: 6px;
}
.penalty-group__title {
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
}
.penalty-group__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.penalty-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.penalty-field.is-filled { border-color: rgba(46, 210, 74, 0.45); }
.penalty-field__label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-right: 18px;
}
.penalty-field__value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.penalty-field__value.is-empty { color: var(--text-faint); font-weight: 500; }
.penalty-field__value--link {
  color: var(--primary);
  text-decoration: none;
}
.penalty-field__value--link:hover { text-decoration: underline; }
.penalty-field__ok {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
}

.penalty-case__acc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.penalty-field--edit .penalty-field__input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.penalty-field--edit .penalty-field__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}
.penalty-field--edit .penalty-field__input::placeholder {
  color: var(--text-faint);
  font-weight: 500;
}
.penalty-field__input.penalty-field__input[type="text"],
.penalty-field--edit select.penalty-field__input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.penalty-field__ro {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 1px 7px;
  margin-left: 2px;
}
.penalty-field--file {
  gap: 8px;
}
.penalty-field--file .penalty-field__value {
  font-size: 13px;
}
.penalty-field__upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.penalty-field__upload {
  align-self: flex-start;
  border-style: dashed;
}
.penalty-field--file.is-filled {
  border-color: rgba(46, 210, 74, 0.45);
}

/* Красная («критичная») подсветка стадии — например первая стадия розыска,
   пока выбран статус «в розыске», но дата розыска не заполнена. */
.penalty-stage.is-critical {
  border-color: var(--red);
  background: var(--red-weak);
  box-shadow: 0 4px 16px rgba(255, 87, 87, 0.28);
  animation: pulse 1.5s infinite;
}
.penalty-stage.is-critical .penalty-stage__name,
.penalty-stage.is-critical .penalty-stage__sub { color: var(--red); }
/* Бейдж «ВНИМАНИЕ» на критичной стадии (например, «Подача иска» судебного
   розыска, когда дата «6 месяцев с даты розыска» уже прошла). */
.penalty-stage__attention {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(255, 87, 87, 0.4);
  animation: pulse 1.5s infinite;
}

/* Раздел «Розыск»: две части (досудебные + судебные) в один раздел, двумя рядами. */
.risk-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 20px;
  padding: 20px;
}
.risk-section__row { display: flex; flex-direction: column; }
.risk-section__row + .risk-section__row { margin-top: 4px; }
.risk-section__part {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.risk-section__part-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.risk-section__part-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--primary);
}
.risk-main-row,
.risk-side-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.risk-side-row {
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
/* Небольшие чипы side-ряда (МВД) */
.risk-side-row .penalty-stage {
  min-width: 110px;
  padding: 8px 10px;
}

@media (max-width: 640px) {
  .penalty-stage { min-width: 110px; }
  .penalty-case__acc-head { flex-direction: column; align-items: flex-start; }
  .penalty-case__acc-actions { width: 100%; }
  .penalty-case__acc-actions .btn { flex: 1; }
  .risk-section__part { padding: 12px; }
}

/* ========================================================================== 
   v0.4.0 — устойчивый layout, полный канбан, синхронизированные услуги, PWA
   ========================================================================== */

/* Любой элемент внутри grid/flex имеет право сжиматься, а длинные названия
   документов/судов/ссылок не выталкивают соседние кнопки за границы карточки. */
.case-docs__list,
.editable-grid,
.penalty-group__grid,
.kanban-top,
.kanban-all-grid,
.services-sync-grid { min-width: 0; }
.case-doc,
.case-doc__link,
.case-doc__name,
.editable-field,
.field,
.stage-block,
.penalty-field,
.penalty-group,
.service-card,
.service-sync-card { min-width: 0; }
.case-doc__name,
.penalty-field__label,
.penalty-field__value,
.stage-block__head,
.stage-block__codes,
.service-sync-card__stage { overflow-wrap: anywhere; word-break: break-word; }
.field__input,
.editable-field__input,
.penalty-field__input,
textarea,
select,
input { min-width: 0; max-width: 100%; }

/* Договор/доверенность и остальные file-карточки: ссылка гибкая, кнопка не
   обрезается. При нехватке места карточка переносит кнопку целиком на строку. */
.case-docs__list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.case-doc { flex-wrap: wrap; align-items: center; }
.case-doc__link { flex: 1 1 210px; min-width: 0; }
.case-doc > .btn { flex: 0 0 auto; max-width: 100%; white-space: normal; }
.case-doc__status { flex: 0 0 auto; }

.editable-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.penalty-group__grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); }
.penalty-field__upload-row { flex-wrap: wrap; }

/* Полный канбан: все 10 этапов видны отдельными карточками. */
.kanban-all-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
  margin-top: 16px;
}
.kanban-all-card {
  appearance: none;
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--speed), box-shadow var(--speed), transform var(--speed);
}
.kanban-all-card:hover { border-color: var(--primary); box-shadow: 0 5px 18px rgba(0,119,255,.10); transform: translateY(-1px); }
.kanban-all-card.is-current { border-color: var(--primary); background: var(--primary-weak); }
.kanban-all-card.is-done { border-color: rgba(46,210,74,.42); }
.kanban-all-card.is-overdue { border-color: rgba(255,87,87,.7); background: var(--red-weak); }
.kanban-all-card__top { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.kanban-all-card__code { font-size:12px; font-weight:900; color:var(--primary); }
.kanban-all-card__state { font-size:11px; font-weight:700; color:var(--text-dim); text-align:right; }
.kanban-all-card__title { font-size:14px; font-weight:800; line-height:1.35; margin-bottom:6px; }
.kanban-all-card__codes { color:var(--text-faint); font-size:11px; line-height:1.4; min-height:30px; overflow-wrap:anywhere; }
.kanban-all-card__meta { display:grid; gap:4px; margin-top:10px; font-size:12px; color:var(--text-dim); }
.kanban-all-card__meta b { color:var(--text); font-weight:700; }

/* Синхронизированные карточки «Доп. услуг». */
.services-sync-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));
  gap:12px;
  margin-bottom:20px;
}
.service-sync-card {
  border:1px solid var(--line);
  background:var(--panel);
  border-radius:var(--radius);
  padding:16px;
}
.service-sync-card__head { display:flex; align-items:flex-start; gap:10px; }
.service-sync-card__icon { font-size:22px; line-height:1; }
.service-sync-card__head h3 { margin:0; font-size:14px; }
.service-sync-card__head p { margin:3px 0 0; color:var(--text-faint); font-size:11px; }
.service-sync-card__stage { margin-top:14px; font-size:14px; font-weight:800; }
.service-sync-card__progress { height:6px; border-radius:999px; background:var(--line); overflow:hidden; margin:10px 0; }
.service-sync-card__progress span { display:block; height:100%; background:var(--primary); border-radius:inherit; }
.service-sync-card__foot { display:flex; align-items:center; justify-content:space-between; gap:10px; color:var(--text-faint); font-size:11px; }
.services-tools-head { margin:22px 0 12px; }
.services-tools-head h3 { margin:0 0 4px; font-size:16px; }
.services-tools-head p { margin:0; color:var(--text-faint); font-size:12px; line-height:1.5; }

.acc-open { white-space:nowrap; }
.acc-table td, .acc-table th { vertical-align:middle; }

/* На узких экранах не допускаем «съезд» кнопок/полей. */
@media (max-width: 760px) {
  .case-doc { align-items:flex-start; }
  .case-doc__link { flex-basis:100%; }
  .case-doc > .btn { width:100%; justify-content:center; }
  .case-doc__status { white-space:normal; }
  .penalty-case__acc-actions .btn { min-width:0; white-space:normal; }
  .service-sync-card__foot { align-items:stretch; flex-direction:column; }
  .service-sync-card__foot .btn { width:100%; justify-content:center; }
  .acc-table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .acc-table { min-width:760px; }
}

@media (max-width: 520px) {
  .case-docs, .risk-section { padding:14px; }
  .case-doc { padding:11px; }
  .penalty-case__fields { padding:12px; }
  .penalty-group__grid { grid-template-columns:1fr; }
  .kanban-all-grid { grid-template-columns:1fr; }
}
.risk-section[hidden] { display: none !important; }
.module-nav { overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.module-tab { flex: 0 0 auto; white-space: nowrap; }
