/* ==========================================================================
   Ассоциация правовой помощи — оформление.
   ВСЕ цвета задаются только переменными ниже. Чтобы поменять цвет —
   поменяйте значение переменной, остальное подстроится само.
   Фирменные цвета взяты из брендбука: #02344D (основной), #C49D64 (акцент).
   ========================================================================== */
:root,
[data-theme="light"] {
  --bg: #F3F6F7;
  --card: #FFFFFF;
  --surface: #E9F1F3;
  --surface-2: #DFE9EC;
  --primary: #02344D;
  --primary-hover: #012637;
  --on-primary: #FFFFFF;
  --gold: #C49D64;
  --gold-soft: #F4ECDF;
  --text: #0F1E28;
  --text-2: #5A6B76;
  --border: #DCE5E8;
  --focus: #2D7FF9;
  --sidebar: #02344D;
  --sidebar-text: #D7E4EA;
  --sidebar-muted: #8FAAB8;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(196, 157, 100, 0.18);
  --overlay: rgba(4, 18, 26, 0.45);
  --shadow: 0 1px 2px rgba(2, 52, 77, 0.06), 0 4px 16px rgba(2, 52, 77, 0.06);
  --shadow-lg: 0 12px 40px rgba(2, 52, 77, 0.18);
  /* Статусы (одинаковые во всех разделах) */
  --gray: #8593A0;
  --blue: #2D7FF9;
  --yellow: #F5A524;
  --green: #2FB57A;
  --red: #F04438;
  --badge-text-mix: 72%;
  --on-status: #FFFFFF;
  --on-gold: #06202C;
  --on-yellow: #2A1B00;
  --sidebar-strong: #FFFFFF;
  --scroll: rgba(2, 52, 77, 0.22);
  --scroll-hover: rgba(2, 52, 77, 0.45);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #061820;
  --card: #0C232E;
  --surface: #12303D;
  --surface-2: #183A49;
  --primary: #C49D64;
  --primary-hover: #D4B07A;
  --on-primary: #06202C;
  --gold: #C49D64;
  --gold-soft: rgba(196, 157, 100, 0.14);
  --text: #F2F6F8;
  --text-2: #A6B8C2;
  --border: #1F4050;
  --focus: #6AA8FF;
  --sidebar: #04141B;
  --sidebar-text: #D7E4EA;
  --sidebar-muted: #7F98A6;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(196, 157, 100, 0.16);
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --gray: #93A3AF;
  --blue: #5B9BFF;
  --yellow: #F5A524;
  --green: #3DD68C;
  --red: #FF6B5F;
  --badge-text-mix: 100%;
  --on-status: #FFFFFF;
  --on-gold: #06202C;
  --on-yellow: #2A1B00;
  --sidebar-strong: #FFFFFF;
  --scroll: rgba(255, 255, 255, 0.16);
  --scroll-hover: rgba(255, 255, 255, 0.34);
  color-scheme: dark;
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
a.link, .prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
[data-theme="dark"] a.link { color: var(--gold); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--text-2); }
.icon { flex: none; display: inline-block; vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Тонкая полоса прокрутки в цвет темы */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
*:hover { scrollbar-color: var(--scroll-hover) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }

/* ---------- Каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  transition: width .18s ease; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 16px 14px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; flex: none; object-fit: cover; }
.brand-name { font-weight: 650; font-size: 14px; line-height: 1.2; letter-spacing: .02em; text-transform: uppercase; }
.brand-line { height: 2px; width: 40px; background: var(--gold); margin: 0 16px 10px; border-radius: 2px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--sidebar-text); font-size: 14.5px; position: relative; white-space: nowrap;
}
.nav a:hover { background: var(--sidebar-hover); }
.nav a.active { background: var(--sidebar-active); color: var(--sidebar-strong); }
.nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: var(--gold);
}
.nav .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.count {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--red);
  color: var(--on-status); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.count[hidden] { display: none; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--sidebar-hover); display: flex; gap: 6px; align-items: center; }
.sidebar-foot .me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: 12px; color: var(--sidebar-text); }
.sidebar-foot .me:hover { background: var(--sidebar-hover); }
.sidebar-foot .me-text { min-width: 0; }
.sidebar-foot .me-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .me-role { font-size: 12px; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn-side { background: none; border: 0; color: var(--sidebar-muted); padding: 8px; border-radius: 10px; cursor: pointer; }
.icon-btn-side:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* Свёрнутое меню (только иконки) */
.collapsed .sidebar { width: 76px; }
.collapsed .brand-name, .collapsed .nav .label, .collapsed .me-text, .collapsed .brand-line { display: none; }
.collapsed .nav a { justify-content: center; padding: 11px 0; }
.collapsed .nav .count { position: absolute; top: 2px; right: 6px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
.collapsed .brand { justify-content: center; }
.collapsed .sidebar-foot { flex-direction: column; }
.collapsed .sidebar-foot .me { justify-content: center; }
.collapsed .collapse-btn .icon { transform: rotate(180deg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar .spacer { flex: 1; }
.topbar .mobile-brand { display: none; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; }
.topbar .mobile-brand img { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-2); width: 40px; height: 40px;
  border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn .count { position: absolute; top: 2px; right: 0; height: 18px; min-width: 18px; font-size: 11px; padding: 0 5px; }
.menu-btn { display: none; }
.ti-sun { display: none; }
[data-theme="dark"] .ti-sun { display: inline-block; }
[data-theme="dark"] .ti-moon { display: none; }
.content { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; flex: 1; }

/* Выпадающее окно уведомлений */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: 48px; width: 380px; max-width: calc(100vw - 24px); background: var(--card);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden;
}
.dropdown-panel[hidden] { display: none; }
.dropdown-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dropdown-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif:hover { background: var(--surface); }
.notif.unread { background: var(--gold-soft); }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-top: 7px; flex: none; }
.notif.read .dot { background: transparent; }
.notif-text { font-size: 14px; }
.notif-time { font-size: 12px; color: var(--text-2); }

/* ---------- Заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; margin-bottom: 8px; }
.back:hover { color: var(--text); }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); font-weight: 600; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: var(--on-status); }
.btn-danger:hover { filter: brightness(0.92); background: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 16px 22px; font-size: 16px; border-radius: 14px; }
.btn-success { background: var(--green); border-color: var(--green); color: var(--on-status); }
.btn-success:hover { filter: brightness(0.94); background: var(--green); }
.btn-warning { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }
.btn-warning:hover { filter: brightness(0.95); background: var(--yellow); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; }

/* ---------- Карточки и сетки ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .stack > .card + .card, .notes-grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.nowrap { flex-wrap: nowrap; }

/* Плитки-показатели на главной */
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--primary); flex: none; }
[data-theme="dark"] .stat-icon { color: var(--gold); }
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat.red .stat-icon { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.stat.yellow .stat-icon { color: var(--yellow); background: color-mix(in srgb, var(--yellow) 14%, transparent); }
.stat.green .stat-icon { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }

/* ---------- Плашки статусов ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.badge-gray { color: color-mix(in srgb, var(--gray) var(--badge-text-mix), var(--text)); background: color-mix(in srgb, var(--gray) 16%, transparent); }
.badge-blue { color: color-mix(in srgb, var(--blue) var(--badge-text-mix), var(--text)); background: color-mix(in srgb, var(--blue) 14%, transparent); }
.badge-yellow { color: color-mix(in srgb, var(--yellow) 62%, var(--text)); background: color-mix(in srgb, var(--yellow) 18%, transparent); }
.badge-green { color: color-mix(in srgb, var(--green) var(--badge-text-mix), var(--text)); background: color-mix(in srgb, var(--green) 15%, transparent); }
.badge-red { color: color-mix(in srgb, var(--red) var(--badge-text-mix), var(--text)); background: color-mix(in srgb, var(--red) 14%, transparent); }
[data-theme="dark"] .badge-yellow { color: var(--yellow); }
.prio { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.prio-red { color: var(--red); font-weight: 600; }
.prio-yellow { color: color-mix(in srgb, var(--yellow) 70%, var(--text)); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface); font-size: 13px; color: var(--text-2); }

/* ---------- Таблицы и списки ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--card);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface); }
.table tr.overdue td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.table tr.help td:first-child { box-shadow: inset 4px 0 0 var(--yellow); }
.table .title { font-weight: 600; }
.table .clickable { cursor: pointer; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface); }
.list-item.overdue { box-shadow: inset 4px 0 0 var(--red); }
.list-item.help { box-shadow: inset 4px 0 0 var(--yellow); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .meta { font-size: 13px; color: var(--text-2); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Пустые состояния */
.empty { text-align: center; padding: 36px 20px; color: var(--text-2); }
.empty .icon { color: var(--gold); margin-bottom: 8px; }
.empty-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; color: var(--text-2); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--gold); }
.tabs .n { font-size: 12px; color: var(--text-2); background: var(--surface); border-radius: 999px; padding: 0 7px; }

/* ---------- Фильтры ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .search { flex: 1 1 240px; position: relative; }
.filters .search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); }
.filters .search input { padding-left: 38px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters .search input { width: 100%; }

/* ---------- Формы ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--red); }
.field .help { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.field .error, .errorlist { color: var(--red); font-size: 13px; margin: 4px 0 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); font: inherit; font-size: 15px; min-height: 42px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
select[multiple] { min-height: 120px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; max-height: 240px; overflow-y: auto; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.checks input { accent-color: var(--primary); width: 16px; height: 16px; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--red); }
details.more { border: 1px dashed var(--border); border-radius: 12px; padding: 0 14px; }
details.more summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { color: var(--text); }
details.more[open] summary .icon { transform: rotate(180deg); }
details.more .form-grid { padding-bottom: 14px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.segmented { display: inline-flex; background: var(--surface); padding: 4px; border-radius: 14px; gap: 4px; flex-wrap: wrap; }
.segmented label { padding: 8px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); }
.segmented input { display: none; }
.segmented input:checked + span { color: var(--text); }
.segmented label:has(input:checked) { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* Загрузка файлов: перетаскивание и прогресс */
.dropzone {
  border: 2px dashed var(--border); border-radius: 14px; padding: 18px; text-align: center; color: var(--text-2);
  cursor: pointer; transition: border-color .15s, background .15s; background: var(--card);
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: var(--gold-soft); color: var(--text); }
.dropzone input[type=file] { display: none; }
.dropzone .dz-title { font-weight: 600; color: var(--text); }
.dz-files { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.dz-files div { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.progress { height: 8px; border-radius: 4px; background: var(--surface); overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.upload-overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 100; }
.upload-overlay[hidden] { display: none; }
.upload-box { background: var(--card); border-radius: 16px; padding: 24px; width: min(420px, 90vw); box-shadow: var(--shadow-lg); }

/* Файлы */
.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface); }
.file-row .grow { flex: 1; min-width: 0; }
.file-row .name { font-weight: 600; font-size: 14px; }
.file-row .meta { font-size: 12px; color: var(--text-2); }
.files-compact .file-row { flex-wrap: wrap; row-gap: 6px; }
.files-compact .file-row .grow { flex: 1 1 calc(100% - 60px); }
.files-compact .file-row .name { white-space: normal; overflow: visible; word-break: break-word; }
.files-compact .file-row .grow ~ :not(.grow):first-of-type, .files-compact .file-row .grow + * { margin-left: auto; }
.file-kind { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--card); color: var(--text-2); text-transform: uppercase; }

/* ---------- Сообщения ---------- */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); }
.alert-success { border-color: color-mix(in srgb, var(--green) 45%, transparent); background: color-mix(in srgb, var(--green) 10%, var(--card)); }
.alert-success .icon { color: var(--green); }
.alert-error { border-color: color-mix(in srgb, var(--red) 45%, transparent); background: color-mix(in srgb, var(--red) 9%, var(--card)); }
.alert-error .icon { color: var(--red); }
.alert-warning { border-color: color-mix(in srgb, var(--yellow) 55%, transparent); background: color-mix(in srgb, var(--yellow) 12%, var(--card)); }
.alert-warning .icon { color: var(--yellow); }
.alert-info .icon { color: var(--blue); }
.alert .close { margin-left: auto; background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 0 4px; font-size: 18px; line-height: 1; }

/* ---------- Свойства записи ---------- */
.props { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; font-size: 14.5px; }
.props dt { color: var(--text-2); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--on-gold); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 88px; height: 88px; font-size: 28px; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }

/* Поручения: крупные кнопки исполнителя */
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big-actions .btn { padding: 18px; font-size: 17px; border-radius: 14px; }
.assignment-text { font-size: 17px; line-height: 1.6; white-space: pre-wrap; }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 12px; }
.timeline-item .body { flex: 1; min-width: 0; background: var(--surface); border-radius: 12px; padding: 10px 14px; }
.timeline-item .who { font-size: 13px; color: var(--text-2); margin-bottom: 2px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Чек-лист */
.checklist { display: flex; flex-direction: column; gap: 4px; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.checklist-item:hover { background: var(--surface); }
.checklist-item.done .txt { text-decoration: line-through; color: var(--text-2); }
.checkbox-btn { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--on-status); padding: 0; }
.checklist-item.done .checkbox-btn { background: var(--green); border-color: var(--green); }
.bar { height: 6px; border-radius: 3px; background: var(--surface); overflow: hidden; }
.bar > div { height: 100%; background: var(--green); }

/* Заметки */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.note { border-radius: 16px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-top: 4px solid var(--border); display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.note-blue { border-top-color: var(--blue); }
.note-green { border-top-color: var(--green); }
.note-yellow { border-top-color: var(--yellow); }
.note-red { border-top-color: var(--red); }
.note-gold { border-top-color: var(--gold); }
.note .note-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.note .note-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.color-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dots label { cursor: pointer; }
.color-dots input { display: none; }
.color-dots span { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--border); }
.color-dots input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.dot-default { background: var(--surface-2); }
.dot-blue { background: var(--blue); }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }
.dot-gold { background: var(--gold); }

/* Календарь заседаний */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.calendar .dow { padding: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.calendar .day { min-height: 104px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.calendar .day.other { background: var(--bg); color: var(--text-2); }
.calendar .day.today .num { background: var(--gold); color: var(--on-gold); border-radius: 8px; padding: 0 6px; }
.calendar .num { font-weight: 700; display: inline-block; margin-bottom: 4px; }
.calendar .ev { display: block; padding: 3px 6px; border-radius: 8px; margin-bottom: 3px; background: color-mix(in srgb, var(--blue) 14%, transparent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar .ev.held { background: color-mix(in srgb, var(--green) 15%, transparent); }
.calendar .ev.cancelled { background: var(--surface); text-decoration: line-through; color: var(--text-2); }
.calendar .ev.postponed { background: color-mix(in srgb, var(--yellow) 18%, transparent); }

/* Модальное окно подтверждения */
.modal { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border-radius: 16px; width: min(480px, 100%); padding: 22px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal-box h2 { margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.danger-zone { border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); border-radius: 16px; padding: 16px 20px; }

/* Страница входа */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { background: var(--sidebar); color: var(--sidebar-strong); display: flex; flex-direction: column; justify-content: center; padding: 48px; position: relative; overflow: hidden; }
.auth-brand img { width: 96px; height: 96px; border-radius: 20px; }
.auth-brand .gold-line { width: 64px; height: 3px; background: var(--gold); border-radius: 2px; margin: 24px 0; }
.auth-brand h1 { font-size: 34px; text-transform: uppercase; letter-spacing: .02em; }
.auth-brand p { color: var(--sidebar-text); max-width: 380px; margin-top: 12px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 24px; margin-bottom: 4px; }

.pagination { display: flex; gap: 6px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.kbd { font-family: ui-monospace, Consolas, monospace; background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-yellow { color: color-mix(in srgb, var(--yellow) 70%, var(--text)); }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.hide-mobile { }
.show-mobile { display: none; }
.only-mobile { display: none; }
.overlay-bg { display: none; }

/* ---------- Телефоны и планшеты ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; width: 280px; box-shadow: var(--shadow-lg); }
  .collapsed .sidebar { width: 280px; }
  .collapsed .brand-name, .collapsed .nav .label, .collapsed .me-text, .collapsed .brand-line { display: initial; }
  .collapsed .nav a { justify-content: flex-start; padding: 10px 12px; }
  .collapsed .nav .count { position: static; }
  .nav-open .sidebar { transform: translateX(0); }
  .nav-open .overlay-bg { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 35; }
  .collapse-btn { display: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; }
  .topbar .mobile-brand { display: flex; }
  .content { padding: 16px 12px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .props { grid-template-columns: 1fr; gap: 2px 0; }
  .props dd { margin-bottom: 8px; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: inline; }
  .order-item { flex-wrap: wrap; align-items: flex-start; }
  .order-item .truncate { white-space: normal; }
  .only-mobile { display: initial; }
  .page-head h1 { font-size: 21px; }
  .big-actions { grid-template-columns: 1fr; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-num { font-size: 22px; }
  .main { max-width: 100vw; }
  .auth-brand { padding: 28px 24px; }
  .auth-brand h1 { font-size: 22px; }
  .auth-brand img { width: 64px; height: 64px; }
  .auth-brand .gold-line { margin: 14px 0; }
  .calendar .day { min-height: 70px; padding: 4px; font-size: 11px; }
  .table th, .table td { padding: 10px 12px; }
  .filters select, .filters input { min-width: 0; flex: 1 1 140px; }
}

/* ---------- Диаграммы (без внешних библиотек) ---------- */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 200px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.hbar-track { height: 14px; border-radius: 7px; background: var(--surface); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 7px; background: var(--primary); min-width: 2px; }
[data-theme="dark"] .hbar-fill { background: var(--gold); }
.hbar-value { font-weight: 600; white-space: nowrap; min-width: 48px; text-align: right; }

/* ---------- Канбан банкротства ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { flex: 0 0 272px; background: var(--surface); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 260px); overflow-y: auto; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 6px 6px; font-weight: 650; font-size: 14px; position: sticky; top: -10px; background: var(--surface); z-index: 1; }
.kanban-col-head .n { font-size: 12px; background: var(--card); border-radius: 999px; padding: 1px 8px; color: var(--text-2); }
.kcard { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--gold); }
.kcard-name { font-weight: 650; font-size: 14.5px; line-height: 1.3; }
.kcard-meta { font-size: 12.5px; color: var(--text-2); display: flex; justify-content: space-between; gap: 6px; }
.kcard .bar { height: 5px; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.kanban-col.done-col { background: color-mix(in srgb, var(--green) 10%, var(--surface)); }

/* Шаги процедуры */
.stepper { display: flex; flex-direction: column; gap: 0; }
.step { display: flex; gap: 12px; align-items: flex-start; position: relative; padding-bottom: 16px; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.step.passed:not(:last-child)::before { background: var(--green); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); background: var(--card); display: flex; align-items: center; justify-content: center; flex: none; color: var(--on-status); font-size: 12px; font-weight: 700; }
.step.passed .step-dot { background: var(--green); border-color: var(--green); }
.step.skipped .step-dot { background: var(--gray); border-color: var(--gray); }
.step.current .step-dot { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent); }
.step-body { flex: 1; min-width: 0; padding-top: 3px; }
.step-name { font-weight: 600; }
.step.future .step-name { color: var(--text-2); }
.step-meta { font-size: 12.5px; color: var(--text-2); }

/* Документы дела */
.doc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.doc-row:last-child { border-bottom: 0; }
.doc-row.not-required { opacity: .55; }
.doc-row.done-doc { box-shadow: inset 4px 0 0 var(--green); }
.doc-row form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc-row select { width: auto; min-height: 36px; padding: 6px 10px; font-size: 14px; }
.doc-row .mini-drop { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-size: 13px; color: var(--text-2); padding: 6px 10px; border: 1px dashed var(--border); border-radius: 10px; }
.doc-row .mini-drop input { display: none; }
.doc-files { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .doc-row { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: minmax(0, 1fr) auto; }
  .hbar-label { grid-column: 1 / -1; }
  .kanban-col { flex-basis: 250px; max-height: none; }
}

/* ---------- МФЦ: строки отчёта ---------- */
.mfc-row { display: grid; grid-template-columns: minmax(180px, 2fr) 80px 120px 140px minmax(140px, 1.3fr) 110px auto; gap: 8px 10px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.mfc-row.deleted { opacity: .4; }
.mfc-row.deleted input, .mfc-row.deleted select { text-decoration: line-through; }
.mfc-cell input, .mfc-cell select { min-height: 40px; padding: 8px 10px; font-size: 14.5px; }
.mfc-l { display: none; font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.mfc-subtype, [data-reason-wrap] { margin-top: 6px; }
.mfc-free .check { min-height: 40px; font-size: 14px; }
.mfc-sumcell { min-height: 40px; display: flex; align-items: center; justify-content: flex-end; font-weight: 650; white-space: nowrap; }
.mfc-actions { display: flex; gap: 6px; align-items: center; min-height: 40px; }
.mfc-del { cursor: pointer; color: var(--text-2); padding: 6px; border-radius: 10px; display: inline-flex; }
.mfc-del:hover { color: var(--red); background: var(--surface); }
.mfc-del input { display: none; }
.mfc-row .mini-drop { display: inline-flex; align-items: center; gap: 2px; cursor: pointer; font-size: 13px; color: var(--text-2); padding: 7px 9px; border: 1px dashed var(--border); border-radius: 10px; }
.mfc-comment { grid-column: 1 / -1; }
.mfc-comment input { min-height: 34px; padding: 6px 10px; font-size: 13.5px; }
.mfc-files { grid-column: 1 / -1; }
.mfc-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; background: var(--surface); border-radius: 0 0 16px 16px; }
.mfc-sum { font-size: 18px; }
.mfc-sum strong { font-size: 22px; }
@media (max-width: 1100px) {
  .mfc-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .mfc-type, .mfc-free { grid-column: 1 / -1; }
  .mfc-l { display: block; }
  .mfc-sumcell { justify-content: flex-start; }
}
.worktime { border-radius: 999px; }
.worktime.on { background: color-mix(in srgb, var(--green) 14%, var(--card)); border-color: color-mix(in srgb, var(--green) 45%, transparent); color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.props.props-stacked { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
.props.props-stacked dt { font-size: 12.5px; }
.props.props-stacked dd { margin-bottom: 8px; }
.kcard-foot > span:first-child { white-space: nowrap; }
.mfc-row.mfc-head { padding-top: 10px; padding-bottom: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--card); }
@media (max-width: 1100px) { .mfc-row.mfc-head { display: none; } }

/* Вкладки с группами (МФЦ: «Работа» | «Отчёты») */
.tab-groups { align-items: center; }
.tab-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); padding: 0 4px 0 2px; white-space: nowrap; }
.tab-sep { width: 1px; align-self: stretch; margin: 8px 10px; background: var(--border); }

/* МФЦ: данные для документов */
.mfc-group { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.mfc-group:last-child { border-bottom: 0; }
.mfc-person { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--card); }
.mfc-person.deleted { opacity: .45; }
.ai-filled input, .ai-filled select, .ai-filled textarea { background: color-mix(in srgb, var(--yellow) 14%, var(--card)); border-color: color-mix(in srgb, var(--yellow) 55%, transparent); }
.ai-src { font-size: 11px; font-weight: 600; color: color-mix(in srgb, var(--yellow) 70%, var(--text)); background: color-mix(in srgb, var(--yellow) 16%, transparent); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.ai-chip { background: color-mix(in srgb, var(--yellow) 18%, transparent); color: color-mix(in srgb, var(--yellow) 70%, var(--text)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-3 .full { grid-column: span 3; }
@media (max-width: 1100px) { .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid-3 .full { grid-column: 1 / -1; } }
@media (max-width: 860px) { .form-grid-3 { grid-template-columns: minmax(0, 1fr); } }
.price-add { display: grid; grid-template-columns: minmax(200px, 3fr) minmax(150px, 2fr) 110px minmax(140px, 1.5fr) 80px auto; gap: 8px; align-items: center; }
@media (max-width: 1100px) { .price-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .price-add input[name=name] { grid-column: 1 / -1; } }

/* ---------- Голосовой ввод ---------- */
.voice-wrap { position: relative; }
.voice-wrap > textarea, .voice-wrap > input { padding-right: 46px; }
.voice-btn { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.voice-btn:hover { color: var(--primary); border-color: var(--primary); }
.voice-btn.on { background: var(--red); color: #fff; border-color: var(--red); animation: voice-pulse 1.2s infinite; }
@keyframes voice-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 45%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
.voice-hint { font-size: 13px; color: var(--text-2); margin-top: 6px; }

[hidden] { display: none !important; }

/* ---------- Личный кабинет клиента ---------- */
body.cabinet { background: var(--bg); }
.cabinet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.cabinet-brand { display: flex; align-items: center; gap: 12px; }
.cabinet-brand img { width: 40px; height: 40px; border-radius: 10px; }
.cabinet-main { max-width: 900px; margin: 0 auto; padding: 24px 16px 60px; }
.portal-creds { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.portal-creds code { font-size: 17px; font-weight: 700; letter-spacing: .5px; }

/* Движение дела и судебные акты */
a.chip { text-decoration: none; border: 1px solid var(--border); }
a.chip:hover { color: var(--text); }
a.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.table.movement td { vertical-align: top; }
.table.movement tr.act-row td:first-child { box-shadow: inset 3px 0 0 var(--gold, #C49D64); }
.act-kind { font-size: 15px; color: var(--text-2); }
.act-kind.act-decision { color: var(--primary); }
.act-kind.act-important { color: color-mix(in srgb, var(--gold, #C49D64) 80%, var(--text)); }
