:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --ink: #16191F;
  --muted: #5B6170;
  --line: #DADDE3;
  --line-soft: #EEF0F3;
  --accent: #0F6E6A;
  --accent-ink: #0A4F4C;
  --accent-soft: #E3EFEE;
  --warn-bg: #FBE9EC;
  --warn-line: #F1C3CB;
  --warn-ink: #7E2333;
  --error: #9A2E40;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #5FA9A5; outline-offset: 2px; }

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; }
.screen { min-height: 100vh; display: flex; flex-direction: column; }
.screen__body { flex: 1; padding: 8px 16px 120px; display: flex; flex-direction: column; gap: 16px; outline: none; }
.screen__title { margin: 4px 0 0; font-size: 28px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.2; }
.screen__title--tight { margin: 0; font-size: 24px; }

.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: max(env(safe-area-inset-top), 8px) 12px 8px; background: rgba(243, 244, 246, 0.94); backdrop-filter: blur(8px); }
.topbar__brand { font-weight: 800; font-size: 17px; padding: 0 4px; }
.topbar__back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 6px; text-decoration: none; font-weight: 700; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.locale { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 2px; }
.locale__btn { min-width: 40px; min-height: 36px; border: 0; border-radius: 999px; background: transparent; font-size: 13px; font-weight: 800; color: var(--muted); cursor: pointer; }
.locale__btn[aria-pressed="true"] { background: var(--accent); color: #FFFFFF; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }

.muted { color: var(--muted); margin: 0; font-size: 14px; }
.pre { white-space: pre-wrap; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; margin: 0; }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.section-title { margin: 8px 0 0; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card__title { margin: 0; font-size: 16px; font-weight: 800; }

.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 48px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--muted); }
.search .input { border: 0; padding: 0; min-height: 46px; background: transparent; }
.search .input:focus { outline: none; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px; background: var(--surface); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.row:hover { color: var(--ink); background: #FAFBFC; }
.row > svg { color: #8A909C; flex-shrink: 0; }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-weight: 700; }
.row__sub { font-size: 13px; color: var(--muted); }
.row__icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar--lg { width: 64px; height: 64px; border-radius: 32px; background: var(--accent); color: #FFFFFF; font-size: 22px; }
.profile { display: flex; align-items: center; gap: 14px; }

.tag { align-self: flex-start; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; margin-top: 2px; }
.tag--warn { background: var(--warn-bg); color: var(--warn-ink); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; }
.notice svg { flex-shrink: 0; margin-top: 2px; }
.notice--warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.notice--error { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.info { background: var(--surface); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.info__label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.info__value { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }

.dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.dl dt { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 10px; }
.dl dt:first-child { margin-top: 0; }
.dl dd { margin: 0; font-weight: 600; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 14px; font-weight: 700; }
.field__req { color: var(--error); }
.field__hint { font-size: 13px; color: var(--muted); margin: 0; }
.field__error { font-size: 13px; font-weight: 700; color: var(--error); min-height: 0; }
.field__error:empty { display: none; }
.field--invalid .input { border-color: var(--error); }

.input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 16px; }
.input:focus { outline: 3px solid #A7D3D0; outline-offset: 0; border-color: var(--accent); }
.input--area { resize: vertical; min-height: 88px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check__box { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.check__text { font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 0 18px; border-radius: 14px; border: 1px solid transparent; font-weight: 800; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn--primary { background: var(--accent); color: #FFFFFF; }
.btn--primary:hover { background: var(--accent-ink); color: #FFFFFF; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--small { min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; }

.sticky-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; padding: 12px 16px max(env(safe-area-inset-bottom), 16px); background: var(--surface); border-top: 1px solid var(--line-soft); }
.sticky-actions > * { max-width: 608px; margin: 0 auto; }

.fab { position: fixed; right: max(20px, calc(50% - 300px)); bottom: max(env(safe-area-inset-bottom), 24px); width: 56px; height: 56px; border-radius: 28px; background: var(--accent); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(15, 110, 106, 0.35); }
.fab:hover { color: #FFFFFF; background: var(--accent-ink); }

.auth { display: flex; flex-direction: column; gap: 16px; padding-top: 24px; }
.auth__title { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.auth__tagline { margin: -8px 0 8px; color: var(--muted); }
.link { font-weight: 700; text-align: center; padding: 12px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #FFFFFF; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; z-index: 50; transition: opacity 0.4s; }
.toast--out { opacity: 0; }

@media (min-width: 700px) {
  .screen__body { padding-top: 16px; }
}

/* ---------- Фото ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.center { text-align: center; }
.grid2--tight { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.notice--info { background: var(--accent-soft); color: var(--accent-ink); }
.btn--danger { background: transparent; border-color: var(--warn-line); color: var(--error); }
.btn--danger:hover { background: var(--warn-bg); color: var(--error); }

.upload__pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 120px; border: 2px dashed #9CCBC8; border-radius: var(--radius); color: var(--accent); font-weight: 800; cursor: pointer; text-align: center; padding: 12px; text-decoration: none; }
.upload__pick:hover { background: #F7FBFB; }
.upload__pick--small { min-height: 88px; flex-direction: row; }
.upload__preview:empty { display: none; }
.upload__img { display: block; width: 100%; max-height: 360px; object-fit: contain; background: #111418; border-radius: 12px; }

.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.thumbs--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.thumb { position: relative; display: block; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: #DDE1E6; }
.thumb__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__badge { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 800; background: rgba(22, 25, 31, 0.75); color: #FFFFFF; }
.thumb__badge--before { background: rgba(126, 35, 51, 0.88); }
.thumb__badge--after { background: rgba(10, 79, 76, 0.9); }

.photo-full { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.photo-full__img { width: 100%; max-height: 70vh; object-fit: contain; background: #111418; border-radius: var(--radius); }

/* ---------- Сравнение до/после ---------- */
.compare { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 72vh; overflow: hidden; border-radius: var(--radius); background: #111418; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: ew-resize; }
.compare__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.compare__divider { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: #FFFFFF; box-shadow: 0 0 6px rgba(0, 0, 0, 0.45); pointer-events: none; }
.compare__handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 20px; background: #FFFFFF; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.compare__tag { position: absolute; top: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(22, 25, 31, 0.75); color: #FFFFFF; font-size: 12px; font-weight: 800; pointer-events: none; }
.compare__tag--left { left: 10px; }
.compare__tag--right { right: 10px; }
.compare__range { width: 100%; height: 32px; accent-color: var(--accent); }

/* ---------- Документы и подпись ---------- */
.doc__title { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.25; }
.doc__notice { margin: 0; font-size: 12px; color: var(--muted); }
.doc__p { margin: 0; line-height: 1.55; }
.sigpad { display: flex; flex-direction: column; gap: 8px; }
.sigpad__frame { position: relative; height: 180px; border: 2px dashed #9CCBC8; border-radius: 14px; background: #FCFDFD; overflow: hidden; }
.sigpad__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sigpad__hint { position: absolute; left: 0; right: 0; bottom: 36px; text-align: center; color: var(--muted); font-size: 14px; pointer-events: none; border-top: 1px solid var(--line); margin: 0 24px; padding-top: 6px; }
.sig-preview { width: 100%; max-width: 320px; height: auto; color: var(--ink); background: #FCFDFD; border: 1px solid var(--line-soft); border-radius: 12px; }
.consent { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 700; }
.consent--ok { color: var(--accent-ink); }
.link-inline { font-weight: 800; }
.row--flat { min-height: 56px; padding: 8px 4px; background: transparent; border-bottom: 1px solid var(--line-soft); border-radius: 0; }
.row--flat:last-child { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }

/* ---------- Демо ---------- */
.demo-banner { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; margin: 0 16px; padding: 6px 10px; border-radius: 10px; background: #FDF1DE; color: #6B4100; font-size: 12px; font-weight: 600; line-height: 1.35; }
.demo-banner span { flex: 1 1 200px; min-width: 0; }
.demo-banner__btn { min-height: 32px; padding: 0 4px; border: 0; background: transparent; color: #6B4100; font-weight: 800; font-size: 12px; text-decoration: underline; cursor: pointer; }
.seed { margin-top: 4px; }
.btn--danger-solid { background: var(--error); color: #FFFFFF; }
.btn--danger-solid:hover { background: #7E2333; color: #FFFFFF; }

.dialog { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 16px max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: rgba(22, 25, 31, 0.45); }
.dialog__card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
.dialog__text { margin: 0; font-size: 16px; font-weight: 700; }
@media (min-width: 700px) { .dialog { align-items: center; } }

/* ---------- Документ на экране (как PDF) ---------- */
.sheet { background: #FFFFFF; border-radius: var(--radius); padding: 20px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 1px 3px rgba(22, 25, 31, 0.08); }
.sheet__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; font-size: 13px; line-height: 1.5; }
.sheet__row--one { grid-template-columns: minmax(0, 1fr); }
.sheet__cell { min-width: 0; overflow-wrap: break-word; hyphens: auto; }
.sheet__title { font-size: 15px; font-weight: 800; line-height: 1.25; hyphens: auto; }
.sheet__notice { font-size: 11px; color: var(--muted); }
.sheet__label { font-size: 11px; font-weight: 800; color: var(--muted); margin-bottom: -6px; }
.sheet__rule { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.sheet__sig { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.sheet__sig .sig-preview { max-width: 240px; margin-bottom: 6px; }
.sheet__signer { font-weight: 800; font-size: 14px; }
.sheet__meta { font-size: 11px; color: var(--muted); }
.sheet__foot { margin: 8px 0 0; color: var(--muted); }
