:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.5;
}

h1, h2, h3, p, ul, ol { margin: 0; }

a { color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------- Layout -------------------------------- */

.page-main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

@media (max-width: 640px) {
  .page-main { padding: 24px 16px; gap: 24px; }
}

/* -------------------------------- Header -------------------------------- */

.app-header {
  background: linear-gradient(120deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
}

.header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (max-width: 640px) {
  .header-inner { padding: 20px 16px; }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
}

.header-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
}

.header-subtitle {
  color: #cbd5e1;
  font-size: 0.875rem;
  margin-top: 2px;
}

@media (max-width: 640px) {
  .header-title { font-size: 1.125rem; }
  .header-subtitle { display: none; }
}

.help-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
  border: none;
  cursor: pointer;
}
.help-btn:hover { background: rgba(255,255,255,0.22); }

@media (max-width: 480px) {
  .help-btn-label { display: none; }
}

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  padding: 32px 24px;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid #eef0f4;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
}

.icon-accent { color: #6366f1; }
.icon-success { color: #10b981; }
.icon-warn { color: #d97706; }

.rules-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
  color: #475569;
}
/* ВАЖНО: здесь НЕЛЬЗЯ использовать display:flex. Внутри <li> лежит смешанное
   содержимое (иконка + текст + теги <b>/<code>), а flex делает КАЖДЫЙ фрагмент текста
   отдельной колонкой — строки разъезжаются в узкие столбики. Иконку позиционируем
   абсолютно, текст остаётся обычным потоком с висячим отступом. */
.rules-list li {
  position: relative;
  padding-left: 24px;
}
.rules-list li > i:first-child {
  position: absolute;
  left: 2px;
  top: 0.3em;
}
.rules-list code {
  background: #eef2ff;
  color: #4338ca;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

.section-hint {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 16px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  border: 2px dashed #c7d2fe;
  border-radius: 14px;
  background: #f8f9ff;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.dropzone:hover, .dropzone.dragover {
  background: #eef2ff;
  border-color: var(--primary);
}
.dropzone-icon {
  font-size: 1.875rem;
  color: #818cf8;
}
.dropzone-title {
  font-weight: 600;
  color: #334155;
  margin-top: 8px;
}
.dropzone-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.file-info {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 12px 16px;
}
.file-name { font-weight: 500; }
.icon-btn-clear {
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
}
.icon-btn-clear:hover { color: #ef4444; }

.processing-status { margin-top: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-box {
  background: #f8fafc;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.stat-box .stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #312e81;
}
.stat-box .stat-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}
.stat-box.warn .stat-value { color: #c2410c; }
.stat-box.ok .stat-value { color: #047857; }

/* --------------------- Настройки таблиц (Шаг 3) --------------------- */

.settings-block {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
}
.settings-summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4338ca;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
.settings-summary::-webkit-details-marker { display: none; }
.settings-summary::after {
  content: '\25be';
  margin-left: auto;
  color: #94a3b8;
}
.settings-block[open] .settings-summary::after { content: '\25b4'; }
.settings-body {
  padding: 4px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid #eef0f4;
}
.fields-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 520px) {
  .fields-row { grid-template-columns: 1fr 1fr; }
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: #475569;
  cursor: pointer;
  line-height: 1.45;
}
.checkbox-row input { margin-top: 2px; flex-shrink: 0; }

/* Как и .rules-list li — без flex: внутрь подставляется текст с <b>, который
   flex разбил бы на отдельные колонки. */
.account-hint {
  position: relative;
  font-size: 0.8rem;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
  line-height: 1.45;
}
.account-hint > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}
.account-hint-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.account-hint-warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }

.btn-success { background: #059669; color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }

.status-msg.warn { color: #b45309; }

/* ------------------------- Отчёт о разносе (Шаг 4) ------------------------- */

.report-target {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
/* Тоже без flex: строка содержит текст + <b> + <span class="badge"> вперемешку
   (см. комментарий у .rules-list li). */
.report-fio {
  position: relative;
  font-size: 0.95rem;
  padding-left: 26px;
}
.report-fio .fa-user-tie {
  color: #6366f1;
  position: absolute;
  left: 2px;
  top: 0.3em;
}
.report-fio .badge { margin-left: 6px; white-space: nowrap; }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-plan { background: #eef2ff; color: #4338ca; }
.badge-done { background: #d1fae5; color: #047857; }

.report-note {
  position: relative;
  font-size: 0.8rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
}
.report-note > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}

.report-target-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
}
.report-target-row .fa-table { color: #6366f1; margin-top: 3px; }
.report-target-name { font-weight: 600; color: #1e293b; }
.report-target-sheet { font-weight: 400; color: #94a3b8; font-size: 0.8rem; }
.report-target-meta { color: #64748b; font-size: 0.78rem; margin-top: 2px; }
.report-target-alt { color: #b45309; font-size: 0.75rem; margin-top: 4px; }

.report-diag {
  margin-top: 6px;
  font-size: 0.74rem;
  line-height: 1.5;
  color: #475569;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-word;
}
.report-diag-alarm {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* --------------------- Фильтр записей (Шаг 2) --------------------- */

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-chip {
  border: 1px solid #d8dde6;
  background: #fff;
  color: #475569;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-chip:hover { background: #f8fafc; }
.filter-chip.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}
.filter-chip-warn { color: #b45309; border-color: #fed7aa; }
.filter-chip-warn:hover { background: #fff7ed; }
.filter-chip-warn.active { background: #ea580c; border-color: #ea580c; color: #fff; }

.results-table tr.row-problem { background: #fffbeb; }
.results-table tr.row-problem:hover { background: #fef3c7; }
.results-table tr.row-problem-no-case { background: #fef2f2; }
.results-table tr.row-problem-no-case:hover { background: #fee2e2; }
.results-table td.sum-cell-bad { color: #b91c1c; }
.report-target-sheet .fa-wand-magic-sparkles { color: #6366f1; }

/* Подсказка об источнике ФИО. Без flex: внутри текст + <b> (см. .rules-list li). */
.fio-source {
  position: relative;
  margin-top: 6px;
  font-size: 0.75rem;
  line-height: 1.45;
  padding: 8px 10px 8px 28px;
  border-radius: 8px;
}
.fio-source > i:first-child {
  position: absolute;
  left: 10px;
  top: 9px;
}
.fio-source-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.fio-source-warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }

.field-open-link {
  float: right;
  font-weight: 500;
  font-size: 0.72rem;
  color: #4f46e5;
  text-decoration: underline;
}

/* Блок личной таблицы ФУ. Показывается до отчёта, чтобы сотрудник сразу видел,
   с какой таблицей идёт работа. Без flex: внутри текст + <b> + ссылка
   (см. комментарий у .rules-list li). */
.resolved-target {
  position: relative;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
}
.resolved-target > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}
.resolved-target .report-target-link { margin-left: 6px; }

/* Таблица ФУ ещё не определена (нужна проверка через реестр) — нейтральный вид. */
.resolved-target-pending {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #475569;
}
/* Таблица найдена — зелёный, со ссылкой. */
.resolved-target-found {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

/* Пояснение про ограничения PDF под зоной загрузки. Без flex — внутри есть <b>,
   который flex разбил бы на отдельные колонки (см. комментарий у .rules-list li). */
.pdf-note {
  position: relative;
  margin-top: 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
}
.pdf-note > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}

.settings-note {
  position: relative;
  font-size: 0.78rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
  line-height: 1.45;
}
.settings-note > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}
.report-target-link {
  margin-left: auto;
  flex-shrink: 0;
  color: #4f46e5;
  font-size: 0.78rem;
  text-decoration: underline;
  white-space: nowrap;
}

/* Пояснение к арифметике отчёта. Без flex: внутри текст + <b>. */
.report-math {
  position: relative;
  margin-top: 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
}
.report-math > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}

.report-pane-note {
  position: relative;
  font-size: 0.78rem;
  line-height: 1.5;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 10px 12px 10px 32px;
  border-radius: 10px;
  margin-bottom: 10px;
}
.report-pane-note > i:first-child {
  position: absolute;
  left: 12px;
  top: 12px;
}

.report-tabs {
  display: flex;
  gap: 6px;
  margin: 18px 0 12px;
  border-bottom: 1px solid #eef0f4;
}
.report-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  font-family: inherit;
}
.report-tab.active { color: #4338ca; border-bottom-color: #4f46e5; }

.report-actions { margin-top: 16px; flex-wrap: wrap; }

.results-table td.reason-cell {
  max-width: 380px;
  color: #9a3412;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 12px;
}
.results-count { font-size: 0.875rem; color: #64748b; }
.search-input { width: 224px; }

.text-input {
  width: 100%;
  border: 1px solid #d8dde6;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.field-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.meta-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .meta-fields { grid-template-columns: 2fr 1fr; }
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  max-height: 480px;
  overflow-y: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.results-table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  border-bottom: 1px solid #eef0f4;
  white-space: nowrap;
}
.results-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f3f7;
  vertical-align: top;
}
.results-table tbody tr:hover { background: #fafbff; }
.results-table td.case-number { font-weight: 700; color: #4338ca; white-space: nowrap; }
.results-table td.case-missing { color: #c2410c; font-style: italic; }
.results-table td.sum-cell { text-align: right; white-space: nowrap; font-weight: 600; }
.results-table td.purpose-cell { max-width: 360px; color: #64748b; }
.results-table tr.row-multiple-cases { background: #fffbeb; }
.results-table tr.row-multiple-cases:hover { background: #fef3c7; }
.results-table td .fa-triangle-exclamation { color: #d97706; margin-left: 4px; }

.warning-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 640px) {
  .export-grid { grid-template-columns: 1fr 1fr; }
}

.export-option {
  border: 1px solid #eef0f4;
  border-radius: 14px;
  padding: 18px;
  background: #fafbfe;
}
.export-option-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.export-option-icon-green { background: #d1fae5; color: #059669; }
.export-option-icon-indigo { background: #e0e7ff; color: #4f46e5; }

.export-option-title {
  font-weight: 600;
  color: #1e293b;
  margin-top: 8px;
}
.export-option-desc {
  font-size: 0.875rem;
  color: #64748b;
  margin-top: 4px;
  margin-bottom: 16px;
}

.export-btn-row {
  display: flex;
  gap: 8px;
}
.btn-flex { flex: 1; }
.btn-block { width: 100%; }

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #6366f1;
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
}
.link-inline {
  color: #4f46e5;
  text-decoration: underline;
}

.gsheets-status {
  font-size: 0.875rem;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.05s, opacity 0.15s, background 0.15s;
  border: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #eef2ff; color: #4338ca; }
.btn-secondary:hover:not(:disabled) { background: #e0e7ff; }

.status-msg { font-size: 0.85rem; padding: 8px 0; }
.status-msg.success { color: #15803d; }
.status-msg.error { color: #b91c1c; }
.status-msg.loading { color: #4338ca; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #94a3b8;
  font-size: 1.1rem;
}
.modal-close:hover { color: #334155; }
.modal-box code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-subtitle {
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 8px;
}
.modal-text {
  font-size: 0.875rem;
  color: #475569;
  margin-bottom: 12px;
}
.modal-text-last { margin-bottom: 0; }
.modal-list {
  font-size: 0.875rem;
  color: #475569;
  padding-left: 20px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.modal-list li { padding-left: 4px; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(79,70,229,0.25);
  border-top-color: #4338ca;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.table-empty-message {
  text-align: center;
  color: #94a3b8;
  padding: 24px 0;
}

/* ------------------------- Фирменный стиль «Номер Дела» ------------------------- */

:root {
  --primary: #102b85;
  --primary-dark: #0b1f66;
  --brand-blue: #6184f9;
  --brand-navy: #102b85;
  --brand-canvas: #f8f8ff;
  --brand-silver: #d3d3d3;
  --brand-gray: #8b8d8f;
  --brand-line: #dfe5fb;
  --brand-ink: #17234d;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 7% 18%, rgba(97,132,249,0.08) 0 2px, transparent 3px) 0 0 / 28px 28px,
    var(--brand-canvas);
  color: var(--brand-ink);
}

.app-header {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,0.98);
  border-top: 6px solid var(--brand-navy);
  border-bottom: 1px solid var(--brand-line);
  box-shadow: 0 8px 30px rgba(16,43,133,0.06);
}

.app-header::after {
  content: '';
  position: absolute;
  width: 250px;
  height: 250px;
  right: -110px;
  top: -150px;
  border: 2px solid rgba(97,132,249,0.16);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(97,132,249,0.05);
  pointer-events: none;
}

.header-inner {
  position: relative;
  z-index: 1;
  max-width: 76rem;
  padding-top: 18px;
  padding-bottom: 18px;
}

.header-left { gap: 20px; }

.brand-logo {
  display: block;
  width: 252px;
  height: auto;
  flex: 0 0 auto;
}

.header-divider {
  width: 1px;
  height: 54px;
  background: var(--brand-line);
  flex: 0 0 auto;
}

.header-product { min-width: 0; }

.header-eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--brand-blue);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.header-title {
  color: var(--brand-navy);
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  color: var(--brand-gray);
  font-size: 0.78rem;
  font-weight: 500;
}

.help-btn {
  color: var(--brand-navy);
  background: #eef2ff;
  border: 1px solid var(--brand-line);
  border-radius: 999px;
  padding: 10px 16px;
}
.help-btn:hover { background: #e2e9ff; }

.workflow-nav {
  background: var(--brand-navy);
  color: #fff;
  box-shadow: 0 7px 22px rgba(16,43,133,0.16);
}

.workflow-nav-inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 13px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.workflow-step {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  color: #fff;
  text-decoration: none;
}

.workflow-step > span {
  grid-row: 1 / 3;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  border-radius: 50%;
  background: var(--brand-blue);
  font-size: 0.78rem;
  font-weight: 800;
}

.workflow-step b {
  font-size: 0.76rem;
  line-height: 1.25;
}

.workflow-step small {
  min-width: 0;
  overflow: hidden;
  color: #cbd6ff;
  font-size: 0.64rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step:hover > span { background: #fff; color: var(--brand-navy); }
.workflow-arrow { color: rgba(255,255,255,0.34); font-size: 0.7rem; }

.page-main {
  max-width: 76rem;
  padding-top: 28px;
  gap: 24px;
}

.card {
  border: 1px solid var(--brand-line);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(16,43,133,0.07);
}

.card-title {
  color: var(--brand-ink);
  font-size: 1.08rem;
}

.card-title > i:first-child {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #eef2ff;
  color: var(--brand-navy);
}

#rules-section {
  border-left: 4px solid var(--brand-blue);
  background: linear-gradient(110deg, #fff 0%, #f8f9ff 100%);
}

.rules-list { color: #4f5875; }
.rules-list code { background: #eef2ff; color: var(--brand-navy); }

.dropzone {
  border-color: #aebfff;
  border-radius: 16px;
  background: linear-gradient(145deg, #fbfcff 0%, #eef2ff 100%);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-blue);
  background: #e9eeff;
  box-shadow: inset 0 0 0 1px rgba(97,132,249,0.18);
}
.dropzone-icon { color: var(--brand-blue); }
.dropzone-title { color: var(--brand-navy); }

.stat-box {
  border-color: var(--brand-line);
  background: #fbfcff;
}
.stat-box .stat-value { color: var(--brand-navy); }

.text-input { border-color: #cfd7ee; }
.text-input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(97,132,249,0.15);
}

.settings-block,
.export-option,
.table-wrap { border-color: var(--brand-line); }

.export-option { background: #fbfcff; }
.export-option-icon-indigo { background: #e7ecff; color: var(--brand-navy); }
.settings-summary,
.field-open-link,
.link-btn,
.link-inline,
.report-target-link { color: var(--brand-navy); }

.settings-note,
.report-math {
  background: #eef2ff;
  border-color: #cbd6ff;
  color: var(--brand-navy);
}

.btn { font-family: inherit; border-radius: 11px; }
.btn-primary {
  background: var(--brand-navy);
  box-shadow: 0 8px 20px rgba(16,43,133,0.2);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #e9eeff; color: var(--brand-navy); }
.btn-secondary:hover:not(:disabled) { background: #dce5ff; }
.btn-success { box-shadow: 0 8px 20px rgba(5,150,105,0.16); }

.filter-chip { border-color: #cfd7ee; }
.filter-chip.active {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
}

.results-table thead th {
  background: #eef2ff;
  color: var(--brand-navy);
  border-bottom-color: #d5def8;
}
.results-table td.case-number { color: var(--brand-navy); }
.results-table tbody tr:hover { background: #f6f8ff; }

.report-tab.active {
  color: var(--brand-navy);
  border-bottom-color: var(--brand-blue);
}

.badge-plan { background: #e9eeff; color: var(--brand-navy); }
.report-target-row .fa-table,
.report-fio .fa-user-tie,
.report-target-sheet .fa-wand-magic-sparkles { color: var(--brand-blue); }

.modal-overlay { background: rgba(9,22,65,0.64); }
.modal-box {
  border: 1px solid var(--brand-line);
  box-shadow: 0 24px 70px rgba(9,22,65,0.28);
}

.app-footer {
  color: #69718a;
  border-top: 1px solid var(--brand-line);
  background: rgba(255,255,255,0.74);
}
.app-footer b { color: var(--brand-navy); }

@media (max-width: 860px) {
  .brand-logo { width: 205px; }
  .header-divider { height: 46px; }
  .header-subtitle { display: none; }
  .workflow-nav-inner {
    overflow-x: auto;
    grid-template-columns: 180px auto 180px auto 180px auto 180px;
    scrollbar-width: thin;
  }
}

@media (max-width: 640px) {
  .app-header { border-top-width: 4px; }
  .header-inner { padding-top: 14px; padding-bottom: 14px; }
  .header-left { gap: 12px; }
  .brand-logo { width: 168px; }
  .header-divider { display: none; }
  .header-product { display: none; }
  .help-btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .workflow-nav-inner { padding-left: 16px; padding-right: 16px; }
  .page-main { padding-top: 20px; gap: 18px; }
  .card { padding: 20px; border-radius: 16px; }
  .card-title { align-items: flex-start; font-size: 1rem; }
}
