/* Фирстиль Realica: тёмно-коричневый, оранжевый, кремовый, голубой. Только светлая тема. */
:root {
  --bg: #FFFAF2;
  --surface: #FFFFFF;
  --surface-2: #F6EEE2;
  --text: #24160F;
  --muted: #7A6558;
  --line: #EADFCF;
  --accent: #E15D2C;
  --accent-ink: #FFFAF2;
  --accent-soft: #FBE5DB;
  --blue: #C5D7E1;
  --pos: #2E7D4F;
  --neg: #C0392B;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(36, 22, 15, .05), 0 8px 24px rgba(36, 22, 15, .06);
  --font: Verdana, "Inter", system-ui, sans-serif;
  color-scheme: light;
}


* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }

h1, h2, .kpi-main b { font-family: var(--font); font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 25px; line-height: 1.15; margin: 14px 0 10px; text-wrap: balance; }
h2 { font-size: 17px; line-height: 1.25; margin: 0 0 14px; }
small { color: var(--muted); font-size: 12.5px; }

.hero { padding: 8px 2px 18px; }
/* Логотип — вектор из фирменного logo.svg (agents_onboarding/assets), цвета как в realica-logo.png */
.brand { display: block; }
.brand .logo { display: block; height: 40px; width: auto; }
.logo-box { fill: #E25E2C; }
.logo-r { fill: #FFFAF2; }
.logo-text { fill: #24160F; }
.lead { color: var(--muted); margin: 0; font-size: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.label { font-size: 13px; font-weight: 500; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row > .field, .row3 > .field { margin-bottom: 14px; }

.input { position: relative; display: flex; align-items: center; background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px; transition: border-color .15s; }
.input:focus-within { border-color: var(--accent); }
.input input { flex: 1; min-width: 0; width: 100%; border: 0; background: none; color: var(--text); font: 600 17px var(--font); padding: 12px 4px 12px 14px; outline: none; font-variant-numeric: tabular-nums; }
.input i { font-style: normal; color: var(--muted); font-size: 13px; padding-right: 12px; white-space: nowrap; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

select { appearance: none; width: 100%; border: 1.5px solid transparent; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23E15D2C' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; color: var(--text); font: 600 16px var(--font); padding: 12px 14px; border-radius: 12px; outline: none; }
select:focus { border-color: var(--accent); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.field .seg { margin-bottom: 0; }
.seg button { flex: 1 1 auto; border: 0; background: none; color: var(--text); font: 500 14px var(--font); padding: 10px 10px; border-radius: 9px; cursor: pointer; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 2px 0 14px; cursor: pointer; font-size: 14.5px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 1px 0 0; flex: none; }
.check small { display: block; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch h2 { margin: 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--line); transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-body { margin-top: 16px; }

.hint { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; }
.hint.good { background: color-mix(in srgb, var(--pos) 12%, transparent); color: var(--text); }
.hint:last-child { margin-bottom: 0; }

.more { margin-top: 8px; }
.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px 0; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: " ↓"; }
.more[open] summary::after { content: " ↑"; }
.more[open] summary { margin-bottom: 12px; }

[hidden] { display: none !important; }

/* ── Результат ── */
.results { margin: 22px 0 12px; }
.results > h2 { font-size: 21px; margin: 0 2px 12px; }
.kpi-main { background: #24160F; color: #FFFAF2; border-radius: var(--radius); padding: 20px 18px; margin-bottom: 10px; }
.kpi-main span { display: block; color: #C5D7E1; font-size: 13px; }
.kpi-main b { display: block; font-size: 32px; line-height: 1.05; margin: 4px 0 6px; font-variant-numeric: lining-nums; }
.kpi-main p { margin: 0; font-size: 14px; color: #FFFAF2; opacity: .85; }
.kpi-main p em { font-style: normal; color: #F08A63; font-weight: 600; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi span { display: block; font-size: 12.5px; color: var(--muted); }
.kpi b { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .pos { color: var(--pos); }
.kpi .neg { color: var(--neg); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; font-weight: 500; }
.table tr.sub td { color: var(--muted); font-size: 13px; }
.table tr.total td { border-bottom: 0; font-weight: 700; font-size: 15.5px; padding-top: 12px; }
.table tr.zero td { color: var(--muted); }
.table .neg { color: var(--neg); }
.card .note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart text { font: 11px var(--font); fill: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.cta p { color: var(--muted); margin: -6px 0 14px; }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 15px; font: 600 16px var(--font); cursor: pointer; margin-top: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { filter: brightness(.95); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.link { background: none; color: var(--muted); font-weight: 500; font-size: 14px; padding: 10px; }
/* В Telegram главная кнопка — нативная MainButton */
.in-tg #cta { display: none; }

/* ── Встраивание в сайт realica.estate: заголовок и рамка — у сайта ── */
.embedded .hero { display: none; }
.embedded .wrap { max-width: 720px; padding-top: 0; }
.lead-form { margin-top: 4px; }
.lead-form h2 { margin-top: 0; }
.lead-text { color: var(--muted); font-size: 14px; margin: -4px 0 14px; }
.lead-form .input input { font-weight: 500; }
.lead-form .input:has(input[aria-invalid]) { border-color: var(--neg); }
.lead-form a { color: inherit; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.lead-status { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.lead-status.ok { background: #E6F4EC; color: #1E5E3A; }
.lead-status.err { background: #FBE9E7; color: #8C2A1E; }

.disclaimer { font-size: 12px; color: var(--muted); padding: 4px 2px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #24160F; color: #FFFAF2; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }

@media (max-width: 380px) {
  .row3 { grid-template-columns: 1fr 1fr; }
  .kpi b { font-size: 17px; }
  .kpi-main b { font-size: 28px; }
}
@media (min-width: 720px) {
  h1 { font-size: 32px; }
  .wrap { padding-top: 32px; }
}

.field > small { font-size: 12.5px; line-height: 1.4; }
input::placeholder { color: var(--muted); opacity: .6; font-weight: 400; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font: 500 13.5px var(--font); cursor: pointer; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }

.empty { text-align: center; padding: 26px 18px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0; }

.btn:disabled { opacity: .45; cursor: not-allowed; }
.cta-note { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 0; }
.cta-note:empty { display: none; }

.sheet { border: 0; border-radius: 20px; padding: 22px 18px; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sheet::backdrop { background: rgba(36, 22, 15, .5); }
.sheet h2 { margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.form-error { color: var(--neg); font-size: 13.5px; margin: 0 0 8px; }

/* Экран подписки в Telegram */
.gate { position: fixed; inset: 0; background: rgba(36, 22, 15, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.gate-card { background: var(--surface); border-radius: 18px; padding: 22px 18px; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.gate-card h2 { margin-bottom: 8px; }
.gate-card p { color: var(--muted); margin: 0 0 16px; }
