:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e3e6ef;
  --text: #171a23;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --ok: #0f9d58;
  --ok-soft: #e7f6ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #161923;
    --surface-2: #1c202c;
    --border: #272c3a;
    --text: #e8eaf2;
    --muted: #9aa1b1;
    --accent: #8b8cf7;
    --accent-soft: #1e2039;
    --ok: #4ade80;
    --ok-soft: #14261c;
    --warn: #fbbf24;
    --warn-soft: #2a2113;
    --danger: #f87171;
    --danger-soft: #2c1618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 880px; margin: 0 auto; padding: 32px 20px 64px; }
.container.wide { max-width: 1120px; }

.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }

/* header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(8px);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; max-width: 1120px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; font-size: .8rem; font-weight: 700; letter-spacing: .5px;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
  color: var(--muted); padding: 7px 12px; border-radius: 9px; font-size: .92rem;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }

/* hero */
.hero { padding: 40px 0 12px; }
.hero h1 { font-size: 2.6rem; line-height: 1.15; margin: 18px 0 14px; letter-spacing: -.02em; }
.hero .lead { font-size: 1.12rem; color: var(--muted); max-width: 62ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.pill {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .8rem; font-weight: 600; letter-spacing: .02em;
}

/* cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 1.25rem; letter-spacing: -.01em; }
.card h3 { margin: 20px 0 8px; font-size: 1rem; }
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin: 20px 0 0; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-top: 8px;
}
.page-head h1 { margin: 0 0 4px; font-size: 1.9rem; letter-spacing: -.02em; }
.page-head p { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.big-value { font-size: 1.2rem; font-weight: 600; margin: 0 0 8px; }

/* buttons */
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: .95rem; font-weight: 550; cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { text-decoration: none; background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.big { padding: 13px 24px; font-size: 1rem; }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* steps */
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr);
         gap: 12px; padding: 0; margin: 20px 0; counter-reset: step; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr 1fr; } }
.step {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.step-no {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 700;
}
.step span:last-child { color: var(--muted); font-size: .86rem; }
.step.current { border-color: var(--accent); background: var(--accent-soft); }
.step.current .step-no { background: var(--accent); color: #fff; }
.step.done .step-no { background: var(--ok-soft); color: var(--ok); }

/* doc cards */
.doc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
@media (max-width: 860px) { .doc-grid { grid-template-columns: 1fr; } }
.doc-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.doc-card h3 { margin: 0 0 8px; font-size: 1rem; }
.doc-card p { margin: 0 0 8px; font-size: .9rem; }

/* forms */
.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px;
}
.field .req { color: var(--danger); }
.auto-tag {
  display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 6px;
  background: var(--ok-soft); color: var(--ok); font-size: .72rem; font-weight: 600;
}
input[type=text], input[type=date], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: .95rem;
}
textarea { resize: vertical; min-height: 68px; }
#original_email { font-family: var(--mono); font-size: .88rem; line-height: 1.55; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.hint { margin: 6px 0 0; font-size: .82rem; color: var(--muted); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 800px) { .field-grid { grid-template-columns: 1fr; } }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.checkbox input { width: 16px; height: 16px; }
.form-actions {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 8px;
}
.form-actions.sticky {
  position: sticky; bottom: 0; background: var(--bg);
  padding: 16px 0; border-top: 1px solid var(--border); margin-top: 20px;
}

.doc-options { display: grid; gap: 10px; }
.doc-option {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
  background: var(--surface-2);
}
.doc-option:hover { border-color: var(--accent); }
.doc-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.doc-option input { margin-top: 4px; }
.doc-option-body { display: flex; flex-direction: column; gap: 3px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.kv, table.list { width: 100%; border-collapse: collapse; font-size: .94rem; }
table.kv th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 10px 14px 10px 0; vertical-align: top; width: 42%;
}
table.kv td { padding: 10px 0; vertical-align: top; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid var(--border); }
table.list th {
  text-align: left; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 0 12px 10px 0;
}
table.list td { padding: 12px 12px 12px 0; border-top: 1px solid var(--border); vertical-align: top; }

/* badges & alerts */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.alert {
  border-radius: 12px; padding: 14px 18px; margin: 18px 0;
  border: 1px solid var(--border); background: var(--surface-2); font-size: .93rem;
}
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert p:last-child { margin-bottom: 0; }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.progress {
  width: 120px; height: 6px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden; margin-top: 6px;
}
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }

.quote-list { margin: 0; padding-left: 0; list-style: none; }
.quote-list li {
  border-left: 3px solid var(--border); padding: 4px 0 4px 12px;
  margin-bottom: 10px; color: var(--muted); font-size: .9rem;
}
.checklist { margin: 8px 0 0; padding-left: 20px; }
.checklist li { margin-bottom: 6px; }

pre.email {
  white-space: pre-wrap; word-break: break-word; font-family: var(--mono);
  font-size: .86rem; line-height: 1.6; margin: 0; color: var(--text);
}

/* document sheet */
.document-sheet {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 56px 64px; margin: 20px 0;
  font-family: Georgia, "Times New Roman", serif; line-height: 1.7;
}
@media (max-width: 700px) { .document-sheet { padding: 28px 22px; } }
.document-watermark {
  position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
  font-size: 8rem; font-weight: 800; letter-spacing: .1em;
  color: var(--text); opacity: .045; pointer-events: none; user-select: none;
}
.doc-title { text-align: center; font-size: 1.5rem; letter-spacing: .06em; margin: 0 0 28px; }
.doc-heading { font-size: 1.02rem; margin: 26px 0 8px; letter-spacing: .02em; }
.doc-p { margin: 0 0 12px; text-align: justify; }
.doc-list { margin: 0 0 12px; padding-left: 22px; }
.doc-list li { margin-bottom: 8px; }
.doc-meta {
  font-family: var(--mono); font-size: .82rem; color: var(--muted);
  border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 22px;
}
.doc-note { font-size: .88rem; color: var(--muted); }
.doc-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 32px; }
@media (max-width: 700px) { .doc-signatures { grid-template-columns: 1fr; } }
.sign-col { font-size: .92rem; }
.sign-party { font-weight: 700; margin-bottom: 4px; }
.sign-entity { color: var(--muted); margin-bottom: 34px; }
.sign-line { border-bottom: 1px solid var(--text); margin-bottom: 6px; }
.sign-position, .sign-date { color: var(--muted); font-size: .86rem; }
.sign-date { margin-top: 10px; }
.gap {
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px dashed var(--warn); border-radius: 4px;
  padding: 0 4px; font-family: var(--mono); font-size: .82em;
}
.doc-disclaimer {
  margin: 36px 0 0; padding-top: 16px; border-top: 1px solid var(--border);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: .8rem; color: var(--muted); text-align: center;
}

/* footer */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 28px 0; margin-top: 40px;
}
.site-footer .container { padding-top: 0; padding-bottom: 0; }
.disclaimer-footer { font-size: .86rem; color: var(--muted); margin: 0 0 8px; max-width: 80ch; }

/* ============ шаги case ============ */
.case-steps { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .case-steps { grid-template-columns: 1fr 1fr; } }
a.step { color: var(--text); text-decoration: none; transition: border-color .15s ease; }
a.step:hover { border-color: var(--accent); text-decoration: none; }
.page-head.compact { align-items: center; margin: 0 0 12px; }
.page-head.compact h2 { margin: 0; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ research ============ */
.state-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.state-badge.confirmed { background: var(--ok-soft); color: var(--ok); }
.state-badge.likely { background: var(--warn-soft); color: var(--warn); }
.state-badge.unverified { background: var(--danger-soft); color: var(--danger); }
.state-badge.missing { background: var(--surface-2); color: var(--muted); }

.research-row {
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
  background: var(--surface-2);
}
.research-row.confirmed { border-left-color: var(--ok); }
.research-row.likely { border-left-color: var(--warn); }
.research-row.unverified { border-left-color: var(--danger); }
.research-row.missing { border-left-color: var(--border); }
.research-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 8px;
}
.research-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 8px;
}
.research-meta select { width: auto; padding: 5px 8px; font-size: .85rem; }
label.inline { display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 500; margin: 0; }
.checkbox.inline { font-size: .82rem; }
.research-source { margin-top: 10px; }
.research-source summary {
  cursor: pointer; font-size: .82rem; color: var(--muted); padding: 4px 0;
}
.research-source[open] summary { margin-bottom: 8px; }
.research-source .field { margin-bottom: 10px; }
.not-found {
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 6px; padding: 1px 7px; margin-left: 6px;
}

/* ============ readiness ============ */
.score-hero {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 6px solid var(--muted);
  border-radius: var(--radius); padding: 26px 30px; margin: 20px 0;
  box-shadow: var(--shadow);
}
.score-hero.ok { border-left-color: var(--ok); }
.score-hero.warn { border-left-color: var(--warn); }
.score-hero.danger { border-left-color: var(--danger); }
.score-value { font-size: 3.4rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.score-max { font-size: 1.2rem; font-weight: 600; color: var(--muted); }
.score-body { flex: 1; min-width: 220px; }
.score-body .progress { width: 100%; margin-top: 10px; }

.category { padding: 14px 0; border-top: 1px solid var(--border); }
.category:first-child { border-top: none; padding-top: 0; }
.category-head { display: flex; justify-content: space-between; gap: 12px; }
.category .progress { width: 100%; margin: 8px 0; }
.check-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: .86rem; }
.check-list li { display: flex; gap: 8px; padding: 2px 0; color: var(--muted); }
.check-list li.ok { color: var(--text); }
.check-mark { width: 14px; font-weight: 700; }
.check-list li.ok .check-mark { color: var(--ok); }
.check-list li.miss .check-mark { color: var(--danger); }

.rec-list { list-style: none; margin: 0; padding: 0; }
.rec {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.rec:first-child { border-top: none; }
.rec-delta {
  font-family: var(--mono); font-weight: 700; font-size: .9rem;
  color: var(--ok); background: var(--ok-soft);
  border-radius: 8px; padding: 3px 9px; white-space: nowrap;
}
.rec.critical .rec-delta { color: var(--danger); background: var(--danger-soft); }
.rec-body { display: flex; flex-direction: column; gap: 2px; }

/* ============ переключатель вариантов ============ */
.switcher { display: flex; gap: 32px; flex-wrap: wrap; }
.switch-group {
  display: inline-flex; margin-top: 6px;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.switch {
  padding: 7px 14px; font-size: .88rem; color: var(--muted);
  background: var(--surface-2); border-right: 1px solid var(--border);
}
.switch:last-child { border-right: none; }
.switch:hover { text-decoration: none; background: var(--bg); color: var(--text); }
.switch.active { background: var(--accent); color: #fff; }
.inline-form { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* ============ research: evidence, conflicts, providers ============ */
.state-badge.conflict { background: var(--danger-soft); color: var(--danger); }
.research-row.conflict { border-left-color: var(--danger); background: var(--danger-soft); }

.conflict-note {
  background: var(--surface); border: 1px solid var(--danger);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; font-size: .88rem;
}
.conflict-note ul { margin: 6px 0; padding-left: 20px; }
.conflict-note p { margin: 4px 0 0; }

.research-evidence { margin-top: 10px; }
.research-evidence summary {
  cursor: pointer; font-size: .82rem; color: var(--accent); padding: 4px 0;
}
.evidence-list { list-style: none; margin: 8px 0 0; padding: 0; }
.evidence {
  border-left: 3px solid var(--border); padding: 8px 0 8px 12px; margin-bottom: 10px;
  font-size: .86rem;
}
.evidence.tier-1 { border-left-color: var(--ok); }
.evidence.tier-2 { border-left-color: var(--accent); }
.evidence.tier-3 { border-left-color: var(--warn); }
.evidence.tier-4 { border-left-color: var(--border); }
.evidence-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.evidence-snippet {
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  background: var(--bg); border-radius: 8px; padding: 6px 10px; margin: 6px 0;
}
.tier-badge {
  font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.tier-badge.tier-1 { background: var(--ok-soft); color: var(--ok); }
.tier-badge.tier-2 { background: var(--accent-soft); color: var(--accent); }
.tier-badge.tier-3 { background: var(--warn-soft); color: var(--warn); }

.danger-card { border-color: var(--danger); }
.conflict-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2);
}
.conflict-option {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap;
}

.signatory-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 12px; background: var(--surface-2);
}
.signatory-card h4 { margin: 12px 0 6px; font-size: .9rem; }
.check-list.plain li { font-family: var(--mono); font-size: .82rem; }
