/* Портал регистрации Sito Застройщик.
   Слева — синяя плитка во весь рост: шахматка дома и название компании, которое человек вписывает справа.
   Справа — короткая форма: название, адрес, вход через Google (Apple — пока окно «временно недоступно»),
   логин и пароль свёрнуты под одной ссылкой. На телефоне синяя часть — узкая шапка над формой. */

@font-face { font-family: Onest; font-weight: 400 700; font-display: swap; src: url('/fonts/onest-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212; }
@font-face { font-family: Onest; font-weight: 400 700; font-display: swap; src: url('/fonts/onest-cyrillic.woff2') format('woff2'); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; font-weight: 400 700; font-display: swap; src: url('/fonts/onest-cyrillic-ext.woff2') format('woff2'); unicode-range: U+0460-048F, U+0492-04AF, U+04B2-052F; }

:root {
  color-scheme: light;
  --tile: #1f44ff;
  --tile-deep: #1534d1;
  --paper: #f5f6f9;
  --surface: #fff;
  --surface-2: #eef0f4;
  --line: #dde1e8;
  --line-strong: #c9ced7;
  --text: #0e1013;
  --text-2: #2d3238;
  --muted: #4d535c;
  --faint: #5b616b;
  --accent: #0e1013;
  --on-accent: #fff;
  --ok: #13704f;
  --warn-soft: #fdf4e3;
  --warn-line: #ecd9ae;
  --danger: #a8281c;
  --r-in: 14px;
  --r-pill: 999px;
  --sans: Onest, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* Квартира в шахматке и зазоры: растут с окном, но дом всегда влезает по высоте; на телефоне — мельче. */
  --cell-w: clamp(22px, min(2.5vw, 4vh), 40px);
  --cell-h: calc(var(--cell-w) * .62);
  --cell-gap: 6px;
  --section-gap: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--paper); color: var(--text);
  font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
a { color: var(--tile); text-underline-offset: 2px; }
b { font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--tile); outline-offset: 2px; border-radius: 6px; }
::selection { background: #cdd6ff; }

/* ---------- две половины ---------- */
.page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(440px, 1fr); }

.hero {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto; gap: 32px;
  padding: calc(36px + var(--safe-t)) clamp(32px, 5vw, 72px) 36px;
  background: var(--tile); color: #fff;
}
/* Земля под домом: светлее к горизонту, чтобы плитка не была плоской заливкой. */
.hero::before {
  content: ''; position: absolute; inset: auto 0 0 0; height: 38%;
  background: linear-gradient(180deg, transparent, rgba(8, 24, 140, .28)); pointer-events: none;
}
.hero > * { position: relative; }
.hero-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.hero-mark { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .35), 0 8px 18px -8px rgba(0, 0, 0, .5); }

.hero-main { align-self: end; display: grid; gap: 28px; justify-items: start; }

/* Шахматка: три подъезда по четыре квартиры, двенадцать этажей. Квартиры рисует portal.js. */
.house {
  display: grid; grid-auto-flow: column; gap: var(--section-gap); align-items: end;
  padding-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, .4);
}
.section { display: grid; grid-template-columns: repeat(4, var(--cell-w)); gap: var(--cell-gap); }
.cell { width: var(--cell-w); height: var(--cell-h); border-radius: 3px; }
.cell.sold { background: #fff; }
.cell.held { background: rgba(255, 255, 255, .42); }
.cell.free { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .38); }

/* Один раз при открытии дом «строится» снизу вверх, этаж за этажом. */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cell { animation: rise .42s cubic-bezier(.2, .8, .2, 1) both; }
.f1 { animation-delay: .06s; } .f2 { animation-delay: .12s; } .f3 { animation-delay: .18s; }
.f4 { animation-delay: .24s; } .f5 { animation-delay: .30s; } .f6 { animation-delay: .36s; }
.f7 { animation-delay: .42s; } .f8 { animation-delay: .48s; } .f9 { animation-delay: .54s; }
.f10 { animation-delay: .60s; } .f11 { animation-delay: .66s; } .f12 { animation-delay: .72s; }
@media (prefers-reduced-motion: reduce) { .cell { animation: none; } }

.hero-name { display: grid; gap: 10px; max-width: 100%; }
.hero-company {
  max-width: 11em; font-size: clamp(34px, 3.7vw, 56px); font-weight: 700; line-height: 1.04; letter-spacing: -.045em;
  text-wrap: balance; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-company.empty { color: rgba(255, 255, 255, .5); }
.hero-url { font-size: 15px; font-weight: 500; color: rgba(255, 255, 255, .78); overflow-wrap: anywhere; min-height: 1.5em; }
.hero-url b { color: #fff; font-weight: 600; }

.hero-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 12.5px; color: rgba(255, 255, 255, .8); }
.hero-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.hero-legend-note { color: rgba(255, 255, 255, .62); }
.sw { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.sold { background: #fff; }
.sw.held { background: rgba(255, 255, 255, .42); }
.sw.free { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55); }

/* ---------- форма ---------- */
.side { display: grid; place-items: center; padding: calc(48px + var(--safe-t)) clamp(24px, 4vw, 64px) calc(48px + var(--safe-b)); }
.login { width: min(384px, 100%); display: grid; gap: 22px; }
.login h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.04em; line-height: 1.1; }
.login-head { display: grid; gap: 10px; }
.login-head .muted { font-size: 14.5px; text-wrap: pretty; }
.fields { display: grid; gap: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }

.field { display: grid; gap: 7px; min-width: 0; align-content: start; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.input {
  min-height: 48px; min-width: 0; width: 100%; padding: 11px 16px; border-radius: var(--r-in);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 15px; color: var(--text); text-overflow: ellipsis;
  transition: border-color .12s ease, box-shadow .12s ease;
}
/* На телефоне поле мельче 16 px Safari приближает при нажатии — страница уезжает вбок. */
@media (pointer: coarse) { .input { font-size: 16px; } }
.input::placeholder { color: #8a909a; }
.input:hover:not(:disabled) { border-color: #a9b0bb; }
.input:focus { outline: none; border-color: var(--tile); box-shadow: 0 0 0 4px rgba(31, 68, 255, .14); }
.input:disabled { background-color: var(--surface-2); color: var(--muted); }
.input[aria-invalid='true'] { border-color: var(--danger); }
.input[aria-invalid='true']:focus { box-shadow: 0 0 0 4px rgba(168, 40, 28, .12); }

/* Адрес CRM под названием: целиком, как его увидят в браузере, свободен ли он, и «изменить». */
.slug-hint { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 12.5px; color: var(--faint); padding-inline: 2px; min-height: 19px; }
.slug-url { overflow-wrap: anywhere; }
.slug-url b { color: var(--text); font-weight: 600; }
.slug-state.ok { color: var(--ok); font-weight: 550; }
.slug-state.bad { color: var(--danger); font-weight: 550; }
.link { border: 0; background: none; padding: 0; color: var(--tile); font-size: inherit; font-weight: 550; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(31, 68, 255, .35); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }

.pass { position: relative; display: grid; }
.pass .input { padding-right: 52px; }
.pass-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px;
  display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--faint); cursor: pointer;
}
.pass-eye:hover { color: var(--text); background: var(--surface-2); }
.pass-eye:focus-visible { outline: 2px solid var(--tile); outline-offset: -2px; }
.pass-eye[aria-pressed='true']::after { content: ''; position: absolute; width: 20px; height: 1.7px; border-radius: 1px; background: currentColor; transform: rotate(-40deg); }
.pass-hint { font-size: 12px; padding-inline: 2px; }
.pass-hint.bad { color: var(--danger); }
.pass-hint.good { color: var(--ok); }

.auth-err { color: var(--danger); font-size: 13px; font-weight: 500; }
.auth-err:empty { display: none; }

/* Способы регистрации: Google — главная кнопка, Apple — обычная. */
.ways { display: grid; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 20px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; white-space: nowrap; font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.btn:hover { border-color: #a9b0bb; box-shadow: 0 6px 16px -10px rgba(14, 16, 19, .35); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 10px 22px -12px rgba(14, 16, 19, .7); }
.btn.primary:hover { background: #000; border-color: #000; }
.btn.primary:disabled { background: var(--surface-2); border-color: var(--line-strong); color: var(--faint); box-shadow: none; cursor: not-allowed; transform: none; }
.btn.wide { width: 100%; }
.ico { display: grid; place-items: center; flex: none; }
.ico-g { width: 26px; height: 26px; margin-left: -8px; border-radius: 50%; background: #fff; }
.ico-apple { margin-top: -2px; }

/* «С логином и паролем»: строка-переключатель, под ней — поля, раскрываются по высоте. */
.more {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  margin-top: 4px; padding: 14px 0 0; border: 0; border-top: 1px solid var(--line); background: none;
  color: var(--text-2); font-size: 14px; font-weight: 550; cursor: pointer;
}
.more:hover { color: var(--text); }
.more svg { transition: transform .25s ease; }
.more[aria-expanded='true'] svg { transform: rotate(180deg); }
.pass-group { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s cubic-bezier(.2, .8, .2, 1); }
.pass-group.open { grid-template-rows: 1fr; }
.pass-inner { overflow: hidden; display: grid; gap: 14px; min-height: 0; }
.pass-group.open .pass-inner { padding-top: 4px; }
@media (prefers-reduced-motion: reduce) { .pass-group, .more svg { transition: none; } }

.note {
  font-size: 13px; line-height: 1.5; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px;
}
.note.warn { background: var(--warn-soft); border-color: var(--warn-line); color: #6b4a0e; font-size: 13.5px; }
.note b { font-size: 15px; overflow-wrap: anywhere; }

/* Создаём / готово / не вышло — те же размеры, что у формы. */
.state-head { display: grid; gap: 10px; justify-items: start; }
.state-head .spinner, .state-head .state-ok { margin-bottom: 8px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(31, 68, 255, .16); border-top-color: var(--tile); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.state-ok { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--tile); color: #fff; }

/* «Уже есть CRM? Войти» и список CRM, когда аккаунт есть в нескольких. */
.have { font-size: 14.5px; color: var(--muted); }
.crm-list { display: grid; gap: 10px; }
.crm-item {
  display: grid; gap: 2px; padding: 14px 18px; border-radius: 16px; text-decoration: none; color: var(--text);
  border: 1px solid var(--line-strong); background: var(--surface);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.crm-item:hover { border-color: var(--tile); box-shadow: 0 6px 16px -10px rgba(31, 68, 255, .45); }
.crm-item b { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.crm-item span { font-size: 13px; color: var(--faint); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .crm-item { transition: none; } }

/* Вход в CRM: черта «или» между кнопками Google и Apple и полем логина. */
.or { display: flex; align-items: center; gap: 14px; color: var(--faint); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.signin-form { display: grid; gap: 14px; }

/* Окно «временно недоступно» (Apple). */
.sheet {
  width: min(360px, calc(100% - 32px)); padding: 26px; border: 0; border-radius: 24px;
  background: var(--surface); color: var(--text); box-shadow: 0 30px 70px -20px rgba(14, 16, 19, .45);
}
.sheet::backdrop { background: rgba(14, 16, 19, .42); backdrop-filter: blur(3px); }
.sheet form { display: grid; gap: 12px; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.sheet .btn { margin-top: 8px; }
.sheet[open] { animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }

/* ---------- телефон и узкое окно: синяя шапка над формой ---------- */
@media (max-width: 900px) {
  :root { --cell-w: 11px; --cell-h: 8px; --cell-gap: 2px; --section-gap: 6px; }
  /* В шапке телефона — два подъезда по девять этажей, иначе дом теснит название. */
  .section:nth-child(3), .f10, .f11, .f12 { display: none; }
  .page { grid-template-columns: 1fr; }
  .hero {
    position: relative; height: auto; gap: 18px; grid-template-rows: auto auto;
    padding: calc(16px + var(--safe-t)) 16px 20px;
  }
  .hero-brand { font-size: 14px; gap: 10px; }
  .hero-mark { width: 32px; height: 32px; border-radius: 8px; }
  .hero-main { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; }
  .house { order: 2; padding-bottom: 6px; }
  .hero-name { gap: 4px; }
  .hero-company { font-size: 26px; -webkit-line-clamp: 2; }
  .hero-url { font-size: 12.5px; }
  .hero-legend { display: none; }
  .side { place-items: start center; padding: 24px 16px calc(32px + var(--safe-b)); }
  .login { gap: 18px; }
  .login h1 { font-size: 24px; }
  .login-head .muted { font-size: 13.5px; }
}
