:root {
  --bg: #0b111c;
  --card: #121b2c;
  --card2: #0f1726;
  --border: #223252;
  --text: #e8eefb;
  --muted: #8fa3c4;
  --accent: #4c9aff;
  --accent-strong: #2f7df6;
  --brand-blue: #2f3fb8;      /* фирменный тёмно-синий (как в логотипе) */
  --brand-blue-lit: #4a63f0;  /* его читаемый вариант на тёмном фоне */
  --brand-red: #e02020;
  --danger: #ff6b6b;
  --ok: #35c46f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); color: var(--text); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 14px 0; }

/* ---------- шапка: фирменный логотип «АвтоСОВЕСТЬ» ---------- */
.hero { margin: 6px 0 16px; }

.brand { text-align: center; padding: 4px 0 2px; }

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

/* сам логотип — картинкой */
.brand-logo-wrap { margin: 0; line-height: 0; font-size: 22px; color: var(--brand-blue-lit); }
.brand-logo {
  display: block;
  width: 100%;
  max-width: 380px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* линия под логотипом */
.brand-rule {
  height: 2px;
  max-width: 440px;
  margin: 9px auto 8px;
  background: var(--brand-blue-lit);
}

.brand-tagline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  color: #e3eaf8;
  font-size: clamp(10px, 3.1vw, 13px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .32em;
  text-indent: .32em;
  white-space: nowrap;
}
.brand-dot {
  flex: 0 0 auto;
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: var(--brand-red);
}

.hero-sub {
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
}
.intro { color: var(--muted); margin-bottom: 14px; }

.section-title { font-size: 18px; font-weight: 700; margin: 22px 0 10px; }

/* ---------- карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--card);
  transition: filter .15s;
}
.btn:active { filter: brightness(1.25); }
.btn-outline { border: 1px solid var(--accent); background: transparent; color: var(--text); }
.btn-primary { background: var(--accent-strong); width: 100%; }
.btn-drafts { margin-bottom: 14px; }
.btn-photo {
  border: 1px solid var(--accent);
  background: var(--card2);
  color: var(--accent);
  font-weight: 600;
  padding: 10px 12px;
  font-size: 14px;
}
.btn-photo.busy { opacity: .6; pointer-events: none; }
.btn-photo.done { border-color: var(--ok); color: var(--ok); }

/* ---------- сегменты (физ/юр/ип) ---------- */
.seg {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.seg button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.seg button.active { background: var(--accent-strong); border-color: var(--accent-strong); }
.seg.seg-gender { width: 150px; }
.seg.seg-gender button { padding: 6px; font-size: 13px; }

.gender-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.gender-row .hint { flex: 1; }

/* ---------- поля ---------- */
.field { margin-bottom: 10px; }
.field label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 11px 12px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.field input.flash { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(53,196,111,.25); transition: box-shadow .3s; }
input[type="date"] { color-scheme: dark; }

.photo-row { display: flex; gap: 8px; margin-bottom: 6px; }
.photo-row .half { flex: 1; }
.file-names { display: flex; gap: 8px; margin-bottom: 8px; }
.file-name { flex: 1; color: var(--muted); font-size: 12px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-hint-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.photo-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.photo-stack .row { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; }
.hint.center { text-align: center; margin: 4px 0 12px; }

.deal-row { display: flex; gap: 10px; }
.deal-row .field { flex: 1; }

/* ---------- чекбоксы ---------- */
.consent, .doc-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.consent { margin-bottom: 6px; }
.consent input, .doc-item input { display: none; }
.checkmark {
  flex: 0 0 22px;
  height: 22px;
  border: 1.5px solid var(--muted);
  border-radius: 6px;
  margin-top: 1px;
  position: relative;
}
.consent input:checked + .checkmark,
.doc-item input:checked + .checkmark {
  background: var(--ok);
  border-color: var(--ok);
}
.consent input:checked + .checkmark::after,
.doc-item input:checked + .checkmark::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.doc-item input:disabled + .checkmark { opacity: .7; }
.consent-text { color: var(--muted); font-size: 13.5px; }
.consent-text a { color: var(--accent); }

.disclaimer {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid #d9a441;
  border-radius: 0 10px 10px 0;
  background: rgba(217, 164, 65, .07);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- подвал со ссылками на документы ---------- */
.app-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.app-foot a { color: var(--muted); text-decoration: none; }
.app-foot a:active { color: var(--accent); }
.doc-list .doc-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.doc-list .doc-item:last-child { border-bottom: none; }
.doc-item em { color: var(--muted); font-style: normal; font-size: 12.5px; }

/* ---------- нижняя панель ---------- */
.spacer { height: 130px; }
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 75%, transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}
.bottom-bar .btn-outline { width: 100%; }

/* ---------- пакеты договоров ---------- */
.tariff-list { display: flex; flex-direction: column; gap: 10px; }
.tariff {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.tariff.active {
  border-color: var(--accent);
  background: rgba(76, 154, 255, .1);
}
.tariff-name { font-size: 16px; font-weight: 700; }
.tariff-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tariff-price {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}
.tariff-list.compact .tariff { padding: 11px 13px; border-radius: 12px; }
.outside-warn {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid #d9a441;
  border-radius: 0 10px 10px 0;
  background: rgba(217, 164, 65, .1);
  color: #e7d3ac;
  font-size: 13.5px;
  line-height: 1.5;
}
.outside-warn a { color: var(--accent); }

.tariff-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  padding: 14px 8px;
}
.tariff-list.compact .tariff-name { font-size: 15px; }

.pay-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 16px; }
.seller-line { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.pay-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
  font-size: 12.5px;
}
.pay-links a { color: var(--accent); text-decoration: none; }

/* ---------- плашка оплаты ---------- */
/* .modal-box описан ниже и перебивал бы эти значения — поэтому селектор точнее */
#paySheet .pay-box {
  max-width: 460px;
  max-height: 94vh;      /* выше обычной модалки: пакеты должны быть видны сразу */
}
.pay-body { flex: 1; overflow-y: auto; padding: 14px 16px 6px; }
.pay-reason {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.pay-hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* длинные пояснения спрятаны, чтобы не заслонять пакеты */
.pay-details {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.pay-details summary {
  color: var(--accent);
  font-size: 13.5px;
  cursor: pointer;
  list-style: none;
}
.pay-details summary::-webkit-details-marker { display: none; }
.pay-details summary::before { content: "▸ "; }
.pay-details[open] summary::before { content: "▾ "; }
.pay-details > *:not(summary) { margin-top: 10px; }
.pay-what { font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.pay-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}
.pay-total b { color: var(--text); font-size: 20px; }
.pay-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.pay-actions .btn { width: 100%; }
.pay-actions .pay-stub { margin-top: 0; margin-bottom: 2px; }

/* невысокие экраны: ужимаем всё, чтобы пакеты помещались целиком */
@media (max-height: 680px) {
  .pay-hint { display: none; }
  .pay-reason { font-size: 14.5px; margin-bottom: 10px; }
  .tariff-list.compact { gap: 7px; }
  .tariff-list.compact .tariff { padding: 9px 12px; }
  .tariff-list.compact .tariff-sub { display: none; }
  .pay-total { margin-top: 10px; padding-top: 9px; }
  .pay-details { margin-top: 10px; padding-top: 8px; }
  .pay-actions { padding-top: 9px; gap: 6px; }
  .pay-actions .pay-stub { font-size: 12px; padding: 8px 10px; line-height: 1.4; }
  .btn-check { margin-top: 8px; }
}
.btn-check { width: 100%; margin-top: 10px; }
.pay-stub {
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-left: 3px solid #d9a441;
  border-radius: 0 10px 10px 0;
  background: rgba(217, 164, 65, .08);
  color: #e7d3ac;
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- попап ---------- */
.popup, .modal, .overlay {
  position: fixed; inset: 0;
  background: rgba(4, 8, 16, .6);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
/* плашке оплаты нужно больше места: тарифы должны помещаться без прокрутки */
#paySheet { padding: 10px; }
.hidden { display: none !important; }
.popup-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 340px;
  position: relative;
}
.popup-x {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px;
}
.popup-text { padding-right: 18px; margin-bottom: 12px; }
.popup-close {
  background: none; border: none; color: var(--accent);
  font-size: 15px; font-weight: 600; cursor: pointer;
  float: right;
}

/* ---------- черновики ---------- */
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-head .popup-x { position: static; }
.drafts-list { overflow-y: auto; padding: 8px 16px 16px; }
.draft-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.draft-row:last-child { border-bottom: none; }
.draft-info { flex: 1; cursor: pointer; min-width: 0; }
.draft-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-date { color: var(--muted); font-size: 12.5px; }
.draft-del { background: none; border: none; color: var(--danger); font-size: 16px; cursor: pointer; padding: 6px; }
.drafts-empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- оверлей ---------- */
.overlay-box { text-align: center; color: var(--text); }
.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
