:root {
  --bg: #f6f7f4;
  --ink: #1d2528;
  --muted: #617077;
  --line: #d7ded8;
  --panel: #ffffff;
  --accent: #147c72;
  --accent-dark: #0d5752;
  --rose: #b94a62;
  --gold: #b98222;
  --blue: #3a6fa7;
  --shadow: 0 18px 42px rgba(22, 34, 36, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  min-height: 48px;
}

button.primary:hover {
  background: var(--accent-dark);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand-block {
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  /* Надпись «ЭПИСТЕМА» входит в сам знак и занимает нижнюю его треть:
     ниже ~80 px она перестаёт читаться. */
  height: 84px;
  max-width: 100%;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.status-card {
  flex: 0 0 auto;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 410px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

/* Три шага сверху страницы: тот же порядок, что и у панелей ниже. */
.guide {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.guide h2 {
  margin-bottom: 8px;
}

.guide-lead {
  margin-bottom: 14px;
  max-width: 78ch;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.88rem;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  counter-reset: guide-step;
}

.guide-steps li {
  counter-increment: guide-step;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px 12px 12px 44px;
}

.guide-steps li::before {
  content: counter(guide-step);
  position: absolute;
  left: 12px;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-steps strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.guide-steps span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.guide-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.step-badge {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

/* Всё, что нужно не каждому: расширенные показатели пациента и ручная
   настройка расчёта. Свёрнуто по умолчанию — иначе первое, что видит
   человек, это полсотни полей. */
.advanced {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfb;
}

.advanced summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.advanced[open] summary {
  margin-bottom: 10px;
}

.advanced .add-row {
  border-top: 0;
  padding-top: 0;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.presets-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.presets button {
  min-height: 32px;
  padding: 0 11px;
  font-size: 0.8rem;
}

/* Карточка ближайшего готового пациента: появляется мгновенно, в отличие от
   подбора, поэтому визуально это первое, что человек видит после ввода. */
.twin {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #f2f9f7;
}

.twin h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.twin .hint {
  margin-bottom: 8px;
}

.twin .patient-table {
  background: #fff;
}

.twin .twin-far {
  color: var(--rose);
  font-weight: 700;
}

.twin-verdict {
  margin: 10px 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.twin button {
  min-height: 34px;
}

/* Оценка времени подбора: меряется на машине пользователя, поэтому это
   единственное место, где сказано, сколько реально ждать. */
.eta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.eta.slow {
  padding: 9px 11px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: #fdf8ee;
  color: var(--ink);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls {
  padding: 16px;
}

.results {
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.control-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.control-grid.compact {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
}

label span,
.hint {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.chart-wrap {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.metric {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  background: #fbfcfb;
}

.metric small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 0.98rem;
}

.output-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 9px;
  color: var(--ink);
  font-size: 0.82rem;
}

.chip i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chip button {
  min-height: 24px;
  width: 24px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}

.app-footer {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.app-footer h2 {
  margin-bottom: 14px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.footer-grid h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  color: var(--accent-dark);
}

.footer-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.app-footer .disclaimer {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.footer-tech,
.footer-guide {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-tech summary,
.footer-guide summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.footer-tech p,
.footer-guide p,
.footer-guide ul,
.footer-tech ul {
  max-width: 860px;
  line-height: 1.55;
  margin-top: 10px;
}

.footer-tech h3,
.footer-guide h3 {
  margin: 18px 0 0;
  font-size: 0.88rem;
  color: var(--accent-dark);
}

.footer-guide li,
.footer-tech li {
  margin-bottom: 6px;
}

.footer-tech a {
  color: var(--accent-dark);
}

/* Обязательство по договору гранта — ссылка на поддержку Фонда должна быть
   на самом сайте, а не только в отчётности. */
.grant-credit {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.footer-tech img {
  margin-top: 10px;
  width: 100%;
  max-width: 420px;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.run-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.run-row .primary {
  width: auto;
}

.progress-bar {
  position: relative;
  display: none;
  margin-top: 10px;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--accent);
  opacity: 0.35;
  transition: width 0.15s ease;
}

.progress-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 10px;
  font-size: 0.72rem;
  color: var(--ink);
  text-align: center;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Завершение подбора после нажатия «Стоп»: сколько ещё осталось считать —
   неизвестно (доигрывается текущее поколение, затем идёт финальный прогон на
   полной модели), поэтому шкала переходит в неопределённый режим — бегущая
   полоса вместо процентов. */
.progress-bar.indeterminate .progress-fill {
  width: 35%;
  transition: none;
  animation: progress-sweep 1.1s ease-in-out infinite;
}

@keyframes progress-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(285%); }
}

/* Внутренние отступы панелей заданы по одной на каждый класс, и для .feedback
   такого правила не было вовсе: форма упиралась прямо в рамку карточки, а
   сама карточка — в предыдущую панель. */
.feedback {
  margin-top: 18px;
  padding: 16px;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.feedback-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
}

.feedback-text textarea,
.feedback-text input {
  font: inherit;
  font-weight: 400;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

.feedback-text span {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

/* Крутилка рядом с текстом статуса */
.spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 7px;
  vertical-align: -1px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar.indeterminate .progress-fill,
  .spinner {
    animation-duration: 0s;
  }
}

.patient {
  margin-top: 18px;
  padding: 16px;
}

.patient-grid,
.drug-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.drugs {
  margin-top: 18px;
  padding: 16px;
}

/* Карточка препарата. Названия у препаратов разной длины, и у самых длинных
   («Гидрохлортиазид (тиазидный диуретик)») раскладка в одну строку рассыпала
   подпись по одному слову в строку. Поэтому карточка вертикальная: галочка и
   название сверху, пояснение и доза — отдельными строками. */
.drug-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfb;
  font-weight: 600;
  cursor: pointer;
}

.drug-toggle:hover {
  border-color: var(--accent);
}

.drug-toggle input[type="checkbox"] {
  grid-row: 1;
  grid-column: 1;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 1px 0 0;
  flex: none;
}

.drug-name {
  grid-row: 1;
  grid-column: 2;
  font-size: 0.88rem;
  line-height: 1.3;
}

.drug-class {
  grid-row: 2;
  grid-column: 2;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
}

.drug-dose {
  grid-row: 3;
  grid-column: 2;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 2px;
}

/* Во время расчёта поля выключены — курсор должен об этом говорить. */
body.run-locked .patient,
body.run-locked .drugs,
body.run-locked .controls {
  cursor: not-allowed;
}

body.run-locked input:disabled,
body.run-locked select:disabled,
body.run-locked button:disabled {
  opacity: 0.55;
}

.baseline-field {
  margin-top: 14px;
  max-width: 420px;
}

.patient-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.82rem;
}

.patient-table th,
.patient-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}

.patient-table th {
  background: #fbfcfb;
}

@media (max-width: 980px) {
  .topbar,
  .model-notes {
    grid-template-columns: 1fr;
    display: grid;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .status-card {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 14px;
  }

  .control-grid.compact,
  .output-bar {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    min-height: 300px;
  }
}

/* Live view of the DE search's current best candidate (see app.js
   renderLiveSearch) - one range bar per free parameter, showing its
   Kidney/Heart_Params.csv min..max bound and where the current best
   candidate sits within it, updated every generation. */
.live-search {
  display: none;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.live-search.visible {
  display: block;
}

.live-search h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.live-search-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.live-target {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
  min-width: 130px;
}

.live-target.out-of-range {
  border-color: #b94a62;
  background: #fdf1f3;
}

.live-target .lt-label {
  color: var(--muted);
  font-weight: 700;
}

.live-target .lt-value {
  font-size: 0.95rem;
  font-weight: 700;
}

.live-target .lt-goal {
  color: var(--muted);
  font-weight: 400;
}

.live-search-params {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 380px;
  overflow-y: auto;
}

.live-param {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 2fr auto;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
}

.live-param .lp-label {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lp-track {
  position: relative;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.lp-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--accent);
  opacity: 0.25;
  border-radius: 4px 0 0 4px;
}

.lp-marker {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 14px;
  background: var(--accent-dark);
  border-radius: 2px;
  transform: translateX(-50%);
}

.lp-range,
.lp-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Логотип в одну строку с заголовком, а не над ним: сам по себе сбоку сверху
   он с названием страницы не связывался. */
.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  margin-bottom: 0;
  flex: none;
}

/* Отступ от дорожки прогресса: раскрывашка прилипала к ней вплотную. */
.advanced.tuning {
  margin-top: 18px;
}

/* Итог расчёта словами. */
.run-summary {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfa;
  font-size: 0.9rem;
  line-height: 1.5;
}

.run-summary h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.run-summary p {
  margin: 0 0 6px;
}

.run-summary .delta-up { color: var(--rose); font-weight: 700; }
.run-summary .delta-down { color: var(--accent-dark); font-weight: 700; }

/* Сброс — разрушительное действие, поэтому он внизу и с объяснением. */
.reset-block {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.reset-block span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Что исключено из перебора и почему — раскрывается по требованию, чтобы
   строка состояния не превращалась в простыню. */
.dropped-params {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fbfcfb;
}

.dropped-params summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.dropped-params ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Заголовок длинный, и при крупном кегле он не влезал в одну строку с
   логотипом — flex-wrap переносил его вниз, то есть визуально ничего не
   менялось. Даём заголовку сжиматься и чуть уменьшаем знак. */
.brand-block h1 {
  flex: 1 1 280px;
  min-width: 0;
  font-size: clamp(1.5rem, 2.2vw, 2.2rem);
}

.brand-block .brand-logo {
  height: 68px;
}

/* Появление логотипа.
   В самой картинке поток точек идёт слева направо и втекает в букву — эффект
   обыгрывает именно это: знак прорисовывается по ходу потока, на гребне
   прорисовки бежит подсветка, в конце знак коротко «вдыхает».
   Вешается НЕ на вёрстку, а классом brand-logo--intro из app.js в момент,
   когда картинка действительно загрузилась: логотип это отдельный запрос на
   97 КБ, и на голой вёрстке анимация отыгрывала до его появления. */
.brand {
  position: relative;
}

.brand-logo--intro {
  -webkit-mask-image: linear-gradient(100deg, #000 0 34%, rgba(0, 0, 0, 0.45) 46%, transparent 56%);
  mask-image: linear-gradient(100deg, #000 0 34%, rgba(0, 0, 0, 0.45) 46%, transparent 56%);
  -webkit-mask-size: 320% 100%;
  mask-size: 320% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  animation: brand-draw 1250ms cubic-bezier(0.3, 0.7, 0.25, 1) both;
}

@keyframes brand-draw {
  0% {
    -webkit-mask-position: 100% 0;
    mask-position: 100% 0;
    transform: translateX(-18px) scale(0.97);
    filter: blur(3px);
  }
  55% {
    filter: blur(0);
  }
  82% {
    transform: translateX(0) scale(1.05);
  }
  100% {
    -webkit-mask-position: 0% 0;
    mask-position: 0% 0;
    transform: none;
    filter: blur(0);
  }
}

/* Подсветка, бегущая по гребню прорисовки: узкая вертикальная полоса цвета
   акцента, которая проходит слева направо и гаснет. Белая на светлом фоне
   была бы не видна, поэтому именно цветная. */
.brand-logo--intro + .brand-sheen,
.brand-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 10px;
  background: linear-gradient(
    100deg,
    transparent 38%,
    rgba(20, 124, 114, 0.28) 47%,
    rgba(58, 111, 167, 0.5) 51%,
    rgba(20, 124, 114, 0.28) 55%,
    transparent 64%
  );
  background-size: 320% 100%;
  background-repeat: no-repeat;
  opacity: 0;
}

.brand-logo--intro ~ .brand-sheen {
  animation: brand-sheen 1250ms cubic-bezier(0.3, 0.7, 0.25, 1) both;
}

@keyframes brand-sheen {
  0% { background-position: 100% 0; opacity: 0; }
  12% { opacity: 1; }
  85% { opacity: 0.85; }
  100% { background-position: 0% 0; opacity: 0; }
}

/* Мягкое свечение под знаком в самом конце — короткий «выдох». */
.brand-logo--intro ~ .brand-glow {
  position: absolute;
  inset: -10% -6%;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(58, 111, 167, 0.32), transparent 72%);
  opacity: 0;
  animation: brand-glow 900ms 700ms ease-out both;
}

@keyframes brand-glow {
  0% { opacity: 0; transform: scale(0.7); }
  45% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 0; transform: scale(1.16); }
}

/* Плашка состояния во время расчёта: другой фон, акцентная рамка и бегущая
   полоска по нижнему краю. */
.status-card.busy {
  border-color: var(--accent);
  background: #f2f9f7;
  color: var(--accent-dark);
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.status-card.busy::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: status-sweep 1.4s ease-in-out infinite;
}

@keyframes status-sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(250%); }
}

/* Предложение платного расчёта. Появляется только там, где у человека
   действительно возникла нехватка, поэтому выглядит как действие, а не как
   реклама: обычная кнопка акцентного цвета, без баннерных приёмов. */
.paid-cta {
  display: inline-block;
  margin-top: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  min-height: 40px;
  padding: 0 16px;
  line-height: 40px;
  text-decoration: none;
  cursor: pointer;
}

.paid-cta:hover {
  background: var(--accent-dark);
}

.eta-cta {
  margin-top: 6px;
}

.order-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
}

.order-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 34, 36, 0.45);
}

.order-card {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.order-card h2 {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.order-card h3 {
  margin: 16px 0 6px;
  font-size: 0.92rem;
}

.order-card p {
  font-size: 0.86rem;
  line-height: 1.55;
}

.order-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.86rem;
  line-height: 1.55;
}

.order-card label {
  margin-top: 14px;
}

.order-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  font: inherit;
  resize: vertical;
}

.order-consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  font-weight: 500;
  font-size: 0.82rem;
}

.order-consent input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.order-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer a {
  color: var(--accent-dark);
}

/* Страницы оферты и политики: узкая колонка для чтения, ничего лишнего. */
.doc-page {
  width: min(760px, calc(100vw - 32px));
}

.doc-page h1 {
  margin: 18px 0 4px;
  font-size: 1.7rem;
}

.doc-page h2 {
  margin: 22px 0 6px;
  font-size: 1rem;
}

.doc-page p,
.doc-page li {
  font-size: 0.9rem;
  line-height: 1.6;
}

.doc-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.doc-draft {
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: #fdf8ee;
  padding: 10px 12px;
}

.doc-back {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---------- Полноэкранная заставка при загрузке ----------
   Знак прорисовывается слева направо — по направлению потока точек в самой
   картинке, — на гребне прорисовки идёт цветная подсветка, под знаком
   разгорается свечение, снизу прочерчивается линия. Затем вся заставка
   расходится и открывает приложение.
   Общая длительность ~1.9 с; клик пропускает. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 45%, #ffffff 0%, #f2f6f4 45%, #e7edea 100%);
  cursor: pointer;
}

/* Заставка видна с первого кадра, поэтому страница под ней не мелькает.
   Уход запускается классом, который ставит app.js — когда логотип
   действительно загрузился и отыграл прорисовку. */
.splash--leaving {
  animation: splash-out 520ms ease-in both;
}

.splash-inner {
  position: relative;
  width: min(520px, 74vw);
  animation: splash-lift 1900ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.splash-logo {
  display: block;
  width: 100%;
  height: auto;
  -webkit-mask-image: linear-gradient(100deg, #000 0 34%, rgba(0, 0, 0, 0.4) 46%, transparent 56%);
  mask-image: linear-gradient(100deg, #000 0 34%, rgba(0, 0, 0, 0.4) 46%, transparent 56%);
  -webkit-mask-size: 320% 100%;
  mask-size: 320% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  animation: splash-draw 1250ms cubic-bezier(0.3, 0.7, 0.25, 1) both;
}

.splash-sheen {
  position: absolute;
  inset: -4% -3%;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 40%,
    rgba(20, 124, 114, 0.3) 47%,
    rgba(58, 111, 167, 0.62) 51%,
    rgba(20, 124, 114, 0.3) 55%,
    transparent 62%
  );
  background-size: 320% 100%;
  background-repeat: no-repeat;
  filter: blur(6px);
  animation: splash-sheen 1250ms cubic-bezier(0.3, 0.7, 0.25, 1) both;
}

.splash-glow {
  position: absolute;
  inset: -18% -12%;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(58, 111, 167, 0.3), transparent 70%);
  animation: splash-glow 1100ms 620ms ease-out both;
}

/* Тонкая линия под знаком: прочерчивается из центра в обе стороны. */
.splash-line {
  position: absolute;
  left: 50%;
  top: calc(50% + min(210px, 30vw));
  height: 2px;
  width: min(520px, 74vw);
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: splash-line 900ms 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes splash-draw {
  0% {
    -webkit-mask-position: 100% 0;
    mask-position: 100% 0;
    filter: blur(14px);
  }
  55% { filter: blur(0); }
  100% {
    -webkit-mask-position: 0% 0;
    mask-position: 0% 0;
    filter: blur(0);
  }
}

@keyframes splash-sheen {
  0% { background-position: 100% 0; opacity: 0; }
  12% { opacity: 1; }
  86% { opacity: 0.9; }
  100% { background-position: 0% 0; opacity: 0; }
}

@keyframes splash-glow {
  0% { opacity: 0; transform: scale(0.72); }
  45% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.2); }
}

@keyframes splash-line {
  0% { transform: translateX(-50%) scaleX(0); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateX(-50%) scaleX(1); opacity: 0.55; }
}

@keyframes splash-lift {
  0% { transform: translateY(14px) scale(0.94); }
  70% { transform: translateY(0) scale(1.03); }
  100% { transform: none; }
}

@keyframes splash-out {
  0% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; transform: scale(1.06); }
}

body.splash-on {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .splash { display: none; }
}

/* Атрибут hidden задаёт display:none с нулевой специфичностью, и правило
   .order-dialog{display:flex} его перебивает — диалог оставался на экране,
   а невидимая подложка перехватывала клики по всей странице. */
.order-dialog[hidden],
.splash[hidden] {
  display: none;
}

/* Заголовок блока «Что здесь можно сделать» с кнопкой заказа справа. */
.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* Заметный вариант кнопки заказа: платный тариф — это отдельное действие,
   а не ещё одна ссылка в ряду. */
.paid-cta--strong {
  background: var(--rose);
  box-shadow: 0 6px 18px rgba(185, 74, 98, 0.28);
}

.paid-cta--strong:hover {
  background: #a03e54;
}

.order-pay {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfa;
}

.order-pay--pending {
  border-color: var(--gold);
  background: #fdf8ee;
}

.order-pay p {
  margin: 6px 0 0;
}

/* Пока терминал тестовый, предупреждение обязано быть заметным. */
.order-testmode {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: #fdf8ee;
}
