/* ==========================================================================
   Мониторинг регионального законодательства — оформление страницы.
   Токены перенесены из макета дизайна: светлая тема, акцент — зелёный,
   карточки на белом фоне поверх тёплого серого полотна.
   ========================================================================== */

:root {
  --page-bg: #f6f6f3;
  --surface: #fff;
  --surface-soft: #fbfbf9;
  --text: #1c1c19;
  --text-strong: #3a3a35;
  --muted: #6d6d66;
  --faint: #8a8a82;
  --line: #ececea;
  --line-soft: #f1f1ee;
  --line-head: #e7e7e2;
  --accent: #20724a;
  --accent-dark: #164f33;
  --accent-tint: #e4efe8;
  --danger: #b3402e;
  --danger-line: #f0dcd8;
  --warn: #c47f17;
  --shell: 860px;
  --card-shadow: 0 1px 2px rgba(28, 28, 25, .02), 0 4px 14px rgba(28, 28, 25, .03);
  --card-shadow-lg: 0 1px 2px rgba(28, 28, 25, .03), 0 6px 20px rgba(28, 28, 25, .04);
  --card-shadow-danger: 0 1px 2px rgba(179, 64, 46, .04), 0 6px 20px rgba(179, 64, 46, .07);
  --font: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/* Скрытие атрибутом hidden должно побеждать display из классов ниже. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
::selection { background: #d9eadf; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.shell { width: 100%; max-width: var(--shell); margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* ── Шапка и подвал ──────────────────────────────────────────────────── */
.site-header { border-bottom: 1px solid var(--line-head); background: var(--surface-soft); }
.site-header__inner { padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__mark {
  width: 28px; height: 28px; flex: none; border-radius: 7px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
}
.brand__title { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.site-header__region { font-size: 13px; color: var(--muted); flex: none; }

.site-footer { border-top: 1px solid var(--line-head); margin-top: auto; }
.site-footer__inner {
  padding: 18px 24px; font-size: 12.5px; color: var(--faint);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.site-footer__links { display: flex; gap: 16px; }
.site-footer__links a { color: var(--faint); }

.settings {
  padding: 0 24px 20px; display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
}
.settings__field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--faint); flex: 1 1 220px; }
.settings__field input {
  font-family: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 8px 11px;
}
.settings__field input:focus { outline: none; border-color: var(--accent); }

/* ── Полотно ─────────────────────────────────────────────────────────── */
.page { flex: 1; padding-top: 48px; padding-bottom: 80px; }
.screen { animation: fadeUp .3s ease; }

.hero__title {
  font-size: 40px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em;
  margin: 8px 0 12px; text-align: center;
}
.hero__lead {
  text-align: center; color: var(--muted); font-size: 16px; line-height: 1.5;
  margin: 0 auto 40px; max-width: 520px;
}

/* ── Загрузка файла ──────────────────────────────────────────────────── */
.dropzone {
  display: block; border: 1.5px dashed #d6d6cf; border-radius: 16px; background: var(--surface-soft);
  padding: 44px 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: #f3f8f5; }
.dropzone__title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.dropzone__hint { font-size: 13px; color: var(--faint); }

.drop-note {
  margin-top: 12px; padding: 11px 14px; border-radius: 10px; font-size: 13px; line-height: 1.55;
  color: var(--text-strong); background: var(--surface-soft); border: 1px solid var(--line); text-align: center;
}
.drop-note[data-tone="error"] { border-color: var(--danger-line); background: #fdf6f4; }
.drop-note[data-tone="warn"] { border-color: #f0e4cd; background: #fdfaf3; }

.file-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--card-shadow); padding: 18px 20px;
}
.file-card__head { display: flex; align-items: center; gap: 12px; }
.file-card__icon {
  width: 34px; height: 34px; flex: none; border-radius: 8px; background: #eef4f0; color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.file-card__meta { flex: 1; min-width: 0; }
.file-card__name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card__sub { font-size: 12.5px; color: var(--faint); }
.file-card__note {
  margin-top: 14px; padding: 11px 14px; border-radius: 10px; background: var(--surface-soft);
  border: 1px solid var(--line); font-size: 13px; line-height: 1.55; color: var(--text-strong);
}
.file-card__note[data-tone="warn"] { border-color: #f0e4cd; background: #fdfaf3; }
.file-card__note[data-tone="error"] { border-color: var(--danger-line); background: #fdf6f4; }
.file-card__note b { font-weight: 600; }
.file-card__actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.file-card__skill { font-size: 12.5px; color: var(--faint); }

/* ── Выбор навыка ────────────────────────────────────────────────────── */
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px auto 0; max-width: 560px; }
.skill {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--muted); box-shadow: 0 1px 2px rgba(28, 28, 25, .03); transition: border-color .15s, color .15s, box-shadow .15s;
}
.skill:hover { border-color: #b9d4c5; }
.skill.is-active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px rgba(32, 114, 74, .08); }
.skill:disabled { opacity: .55; cursor: default; }
.skills__hint { max-width: 560px; margin: 10px auto 0; text-align: center; font-size: 12.5px; color: var(--faint); line-height: 1.5; }

/* ── История проверок ────────────────────────────────────────────────── */
.section-label {
  font-size: 13px; font-weight: 600; color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px;
}
.history { margin-top: 56px; }
.history__list { display: flex; flex-direction: column; gap: 8px; }
.history__item {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--card-shadow); padding: 12px 16px; text-align: left;
  font-family: inherit; color: inherit; cursor: default; width: 100%;
}
.history__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.history__body { flex: 1; min-width: 0; }
.history__file { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history__meta { font-size: 12.5px; color: var(--faint); }
.history__result { font-size: 13px; color: var(--muted); flex: none; }

/* ── Кнопки ──────────────────────────────────────────────────────────── */
.btn { font-family: inherit; font-size: 13.5px; border-radius: 9px; cursor: pointer; padding: 10px 18px; }
.btn--primary { border: none; background: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { filter: brightness(.92); }
.btn--primary:disabled { opacity: .5; cursor: default; filter: none; }
.btn--quiet { border: 1px solid #e0e0da; background: var(--surface); color: var(--muted); }
.btn--quiet:hover { color: var(--text); border-color: #cfcfc7; }

/* ── Ход разбора ─────────────────────────────────────────────────────── */
.run-head { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.run-head__file {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--card-shadow);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.run-head__icon {
  width: 34px; height: 34px; flex: none; border-radius: 8px; background: #eef4f0; color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.run-head__meta { min-width: 0; }
.run-head__name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-head__sub { font-size: 12.5px; color: var(--faint); }

.timeline { display: flex; flex-direction: column; max-width: 600px; margin: 12px auto 0; }
.step { display: flex; gap: 14px; }
.step__rail { display: flex; flex-direction: column; align-items: center; width: 26px; flex: none; }
.step__spinner {
  width: 18px; height: 18px; border: 2px solid #d5e5db; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin-top: 3px;
}
.step__check {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent-tint); color: var(--accent);
  font-size: 12px; display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.step__check[data-state="error"] { background: #fbe9e5; color: var(--danger); }
.step__line { width: 2px; flex: 1; background: #e3e3dd; margin: 4px 0; }
.step__body { flex: 1; padding-bottom: 24px; min-width: 0; }
.step__title { font-size: 16px; font-weight: 600; }
.step__meta { font-size: 14px; color: var(--muted); margin-top: 3px; }
.step__log {
  margin-top: 8px; background: var(--surface-soft); border: 1px solid #ecece6; border-radius: 8px; padding: 10px 14px;
}
.step__log div { font-size: 12.5px; color: var(--faint); font-family: var(--mono); line-height: 1.7; }
.step__dur { font-size: 12px; color: var(--faint); margin-top: 4px; }

.timeline--compact { max-width: none; margin-top: 16px; }
.timeline--compact .step__title { font-size: 14px; }
.timeline--compact .step__body { padding-bottom: 14px; }

/* ── Результаты ──────────────────────────────────────────────────────── */
.result-head { text-align: center; margin-bottom: 24px; }
.result-head__title { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px; }
.result-head__file { font-size: 13.5px; color: var(--faint); margin-bottom: 16px; }
.result-head__actions { display: flex; gap: 10px; justify-content: center; }

.stats { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; margin-bottom: 28px; }
.stat { display: flex; align-items: baseline; gap: 7px; padding: 8px 16px; }
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat__value { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.stat__label { font-size: 13px; color: var(--muted); }

.error-box {
  border: 1px solid var(--danger-line); background: #fdf6f4; color: var(--danger);
  border-radius: 14px; padding: 14px 18px; font-size: 13.5px; line-height: 1.55; margin-bottom: 20px;
}

.progress-details { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; }
.progress-details > summary { font-size: 13px; color: var(--faint); cursor: pointer; list-style: none; }
.progress-details > summary::-webkit-details-marker { display: none; }
.progress-details > summary::before { content: '▸ '; }
.progress-details[open] > summary::before { content: '▾ '; }

/* ── Отчёт ───────────────────────────────────────────────────────────── */
.report { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--card-shadow-lg); padding: 22px 24px;
}
.card--danger { border-color: var(--danger-line); box-shadow: var(--card-shadow-danger); }
.card__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px;
}
.card__title { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.card__sub { font-size: 13px; color: var(--faint); }
.card__aside { font-size: 13px; color: var(--faint); white-space: nowrap; flex: none; }

details.card > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
details.card[open] > summary { margin-bottom: 16px; }
.card__body { display: flex; flex-direction: column; }
.norm { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 14px; }
.norm:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.norm__head { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .card__aside::after { content: ' ▾'; color: var(--accent); }
details.card[open] > summary .card__aside::after { content: ' ▴'; }
details.card > summary:hover .card__title { color: var(--accent); }

.field + .field { margin-top: 12px; }
.field__label {
  font-size: 11px; font-weight: 600; color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px;
}
.field__value { font-size: 13.5px; color: var(--text-strong); line-height: 1.55; }
.quote {
  background: var(--surface-soft); border-radius: 8px; padding: 9px 12px;
  font-size: 13.5px; color: #55554f; line-height: 1.55;
}
.quote u { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; }

.link-ok {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--card-shadow); padding: 14px 16px;
}
.link-ok__check {
  width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--accent-tint); color: var(--accent);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.link-ok__body { flex: 1; min-width: 0; }
.link-ok__law { font-size: 14px; font-weight: 500; }
.link-ok__law span { color: var(--faint); font-weight: 400; }
.link-ok__name { font-size: 13px; color: var(--muted); line-height: 1.4; }
.link-ok__link { font-size: 13px; flex: none; }
.link-ok__articles { font-size: 12.5px; color: var(--faint); margin-top: 2px; }

.group { display: flex; flex-direction: column; gap: 12px; }
.group--tight { gap: 8px; }

/* Разметка markdown внутри карточек отчёта. */
.md { font-size: 14px; line-height: 1.6; color: var(--text-strong); }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); line-height: 1.35; margin: 18px 0 8px; }
.md h1 { font-size: 20px; font-weight: 600; }
.md h2 { font-size: 17px; font-weight: 600; }
.md h3 { font-size: 15px; font-weight: 600; }
.md h4 { font-size: 14px; font-weight: 600; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin-bottom: 4px; }
.md blockquote {
  margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--line);
  background: var(--surface-soft); border-radius: 0 8px 8px 0; color: var(--muted);
}
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-soft); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--surface-soft); border: 1px solid #ecece6; border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: none; border-top: 1px solid var(--line-soft); margin: 18px 0; }
.md table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.5; }
.md th { text-align: left; color: var(--faint); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid #ecece6; }
.md td { padding: 10px 14px; vertical-align: top; border-bottom: 1px solid #f2f2ee; }
.md .table-scroll { overflow-x: auto; }

@media (max-width: 640px) {
  .hero__title { font-size: 30px; }
  .skills { grid-template-columns: 1fr; }
  .stat + .stat { border-left: none; }
  .result-head__actions { flex-wrap: wrap; }
}
