/* ЮрЭкс Защита: PWA для iPhone. Цвета повторяют Android-приложение (Resources/Styles/Colors.xaml). */

:root {
  --navy: #1E3A6E;
  --primary: #1A56DB;
  --primary-2: #3B82F6;
  --primary-soft: #DBEAFE;
  --on-primary-soft: #0D2B6B;
  --red: #E30613;
  --danger: #DC2626;
  --success: #16A34A;
  --success-soft: #DCFCE7;
  --warning: #F59E0B;
  --warning-soft: #FEF3C7;

  --bg: #F0F4FF;
  --card: #FFFFFF;
  --text: #1E293B;
  --text-2: #475569;
  --muted: #64748B;
  --line: #E2E8F0;
  --field: #F8FAFC;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(30, 58, 110, .08);

  --radius: 20px;
  --radius-sm: 14px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #3B82F6;
    --primary-2: #60A5FA;
    --primary-soft: #1E3A8A;
    --on-primary-soft: #DBEAFE;
    --success-soft: #14532D;
    --warning-soft: #422006;
    --bg: #0B1220;
    --card: #162033;
    --text: #E2E8F0;
    --text-2: #CBD5E1;
    --muted: #94A3B8;
    --line: #26334A;
    --field: #0F172A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
a { color: var(--primary); text-decoration: none; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

/* --------------------------------------------------------------------------- layout */

svg.chev { width: 18px; height: 18px; fill: var(--muted); flex: none; }

.view {
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 32px);
  max-width: 560px;
  margin: 0 auto;
  outline: none;
}
body.has-tabbar .view { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }

.boot { min-height: 70vh; display: grid; place-items: center; }
.boot img { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------- header */

.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.topbar h1 { font-size: 20px; font-weight: 700; }
.back {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card);
  display: grid; place-items: center; box-shadow: var(--shadow); cursor: pointer; flex: none;
}
.back svg { width: 22px; height: 22px; fill: var(--text); }

.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 4px; }
.page-sub { color: var(--muted); }

.hello { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.logo {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: var(--navy) url("../img/icon-192.png") center / 118% no-repeat;
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--primary-2);
}
.logo.lg { width: 84px; height: 84px; border-radius: 24px; box-shadow: var(--shadow); }
.hello small { display: block; color: var(--muted); font-size: 14px; }
.hello strong { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 18px; font-weight: 700; margin: 24px 0 10px;
}
.section-title a { font-size: 15px; font-weight: 600; }

/* --------------------------------------------------------------------------- cards */

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card h2 { font-size: 17px; font-weight: 700; }
.card p { color: var(--text-2); }

.hero {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 20px; color: #fff;
  background: linear-gradient(135deg, #60A5FA 0%, #1D4ED8 55%, #1E3A6E 100%);
  box-shadow: 0 12px 32px rgba(29, 78, 216, .28);
}
.hero.ok { background: linear-gradient(135deg, #34D399 0%, #059669 55%, #065F46 100%); box-shadow: 0 12px 32px rgba(5, 150, 105, .28); }
.hero h2 { font-size: 22px; font-weight: 800; }
.hero p { color: rgba(255, 255, 255, .88); margin-top: 6px; max-width: 26ch; }
.hero .btn { margin-top: 16px; }
.hero-ring {
  position: absolute; right: -18px; top: 50%; transform: translateY(-50%);
  width: 132px; height: 132px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  display: grid; place-items: center;
}
.hero-ring::after {
  content: ""; width: 92px; height: 92px; border-radius: 50%;
  border: 4px solid #fff; display: block;
}
.hero-ring svg { position: absolute; width: 34px; height: 34px; fill: #fff; }
.progress { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .3); margin-top: 14px; max-width: 60%; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: #fff; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { border-radius: var(--radius); padding: 16px; background: var(--primary-soft); color: var(--on-primary-soft); }
.stat.warm { background: var(--warning-soft); color: #92400E; }
@media (prefers-color-scheme: dark) { .stat.warm { color: #FDE68A; } }
.stat small { font-size: 14px; opacity: .8; }
.stat b { display: block; font-size: 34px; font-weight: 800; line-height: 1.1; margin-top: 6px; }

.action {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--card); border: 0; border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); text-align: left; cursor: pointer; color: var(--text);
}
.action + .action { margin-top: 10px; }
.action .ico {
  width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: var(--primary-soft);
}
.action .ico svg { width: 22px; height: 22px; fill: var(--primary); }
.action .ico.red { background: #FEE2E2; }
.action .ico.red svg { fill: var(--danger); }
.action .ico.green { background: var(--success-soft); }
.action .ico.green svg { fill: var(--success); }
.action b { display: block; font-weight: 700; }
.action span { color: var(--muted); font-size: 14px; }
.action .chev { width: 18px; height: 18px; fill: var(--muted); flex: none; }

/* --------------------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px; border-radius: 16px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 16px; background: var(--primary); color: #fff;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.white { background: #fff; color: var(--primary); }
.btn.soft { background: var(--primary-soft); color: var(--on-primary-soft); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: #FEE2E2; color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 14px; border-radius: 12px; font-size: 14px; }
.btn .spinner { border-color: rgba(255, 255, 255, .4); border-top-color: #fff; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--primary);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------- forms */

.field { display: block; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); margin: 0 0 6px 4px; }
.input {
  display: flex; align-items: center; gap: 8px;
  background: var(--field); border: 1.5px solid var(--line); border-radius: 16px;
  min-height: 54px; padding: 0 16px;
}
.input:focus-within { border-color: var(--primary); background: var(--card); }
.input input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 17px; /* не меньше 16px: иначе iOS зумит страницу */
}
.input .prefix { font-size: 17px; color: var(--muted); font-weight: 600; }
.field.invalid .input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 14px; margin: 6px 0 0 4px; }

.code-input {
  width: 100%; text-align: center; letter-spacing: .5em; text-indent: .5em;
  font-size: 32px !important; font-weight: 800;
}

.choice {
  display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--card);
}
.choice + .choice { margin-top: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .dot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center;
}
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 55%, var(--card)); }
.choice:has(input:checked) .dot { border-color: var(--primary); }
.choice:has(input:checked) .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.choice:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 15px; color: var(--text-2); }
.check input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 1px 0 0;
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer;
}
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

.alert { border-radius: 16px; padding: 12px 14px; font-size: 15px; background: var(--primary-soft); color: var(--on-primary-soft); }
.alert.warn { background: var(--warning-soft); color: #92400E; }
.alert.err { background: #FEE2E2; color: #991B1B; }
@media (prefers-color-scheme: dark) { .alert.warn { color: #FDE68A; } .alert.err { background: #450A0A; color: #FCA5A5; } }

/* --------------------------------------------------------------------------- lists */

.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--text);
  width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
}
.list-item .grow b { display: block; font-weight: 600; }
.list-item .grow span { display: block; color: var(--muted); font-size: 14px; }
.list-item .chev { width: 18px; height: 18px; fill: var(--muted); flex: none; }
.ico-sm {
  width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--primary-soft);
}
.ico-sm svg { width: 19px; height: 19px; fill: var(--primary); }
.ico-sm.red { background: #FEE2E2; }
.ico-sm.red svg { fill: var(--danger); }
.ico-sm.green { background: var(--success-soft); }
.ico-sm.green svg { fill: var(--success); }
@media (prefers-color-scheme: dark) { .ico-sm.red, .action .ico.red, .call .avatar { background: #450A0A; } }

.call { align-items: flex-start; }
.call .avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: #FEE2E2; color: var(--danger);
}
.call .avatar svg { width: 20px; height: 20px; fill: currentColor; }
.list-item.call .grow .meta { display: flex; justify-content: space-between; gap: 8px; color: var(--text); font-size: 16px; }
.call .meta b { font-weight: 700; }
.call .meta time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.list-item.call .grow .summary {
  color: var(--text-2); font-size: 14px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.day { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 20px 4px 8px; }

.empty { text-align: center; padding: 36px 20px; }
.empty .ico {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--primary-soft);
}
.empty .ico svg { width: 34px; height: 34px; fill: var(--primary); }
.empty h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 32ch; margin: 0 auto; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--primary-soft); color: var(--on-primary-soft); }
.chip.ok { background: var(--success-soft); color: var(--success); }

/* --------------------------------------------------------------------------- call detail */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

.transcript { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 84%; padding: 10px 14px; border-radius: 18px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.bubble small { display: block; font-size: 12px; font-weight: 700; opacity: .7; margin-bottom: 2px; }
.bubble.caller { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.bot { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 6px; }

/* --------------------------------------------------------------------------- setup */

.step {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px;
  background: none; border: 0; text-align: left; cursor: pointer; color: var(--text);
}
.step .num {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 2px solid var(--primary-2); color: var(--primary); font-weight: 800;
}
.step.done .num { background: var(--success); border-color: var(--success); color: #fff; }
.step.done .num::before { content: ""; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }
.step.done .num span { display: none; }
.step b { display: block; font-weight: 700; }
.step .grow span { display: block; color: var(--muted); font-size: 14px; }

.howto { counter-reset: n; list-style: none; padding: 0; margin: 0; }
.howto li { counter-increment: n; position: relative; padding: 0 0 14px 44px; color: var(--text-2); }
.howto li::before {
  content: counter(n); position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 800; font-size: 14px;
}
.howto li:last-child { padding-bottom: 0; }
.howto b { color: var(--text); }
.path { font-weight: 700; color: var(--text); }

.codes { display: grid; gap: 8px; }
.code {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px;
  border-radius: 14px; background: var(--field); border: 1px solid var(--line);
}
.code code { font: 700 17px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; }
.code span { color: var(--muted); font-size: 13px; display: block; }

.ops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.op {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 6px;
  font-weight: 700; cursor: pointer; color: var(--text);
}
.op[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--on-primary-soft); }

/* --------------------------------------------------------------------------- install */

.install-hero { text-align: center; padding: 20px 0 8px; }
.install-hero .logo.lg { margin: 0 auto 16px; }
.share-ico { display: inline-block; width: 22px; height: 22px; vertical-align: -5px; fill: var(--primary); }
.arrow-hint {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 10px); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25); animation: bob 1.6s ease-in-out infinite; white-space: nowrap;
}
.arrow-hint::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: var(--navy); }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }

/* --------------------------------------------------------------------------- chat / policy */

.chat-frame {
  width: 100%; border: 0; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  height: calc(100dvh - var(--safe-top) - var(--tabbar-h) - var(--safe-bottom) - 130px); min-height: 380px;
}
.policy { font-size: 15px; color: var(--text-2); }
.policy h2 { font-size: 16px; color: var(--text); margin: 18px 0 8px; }
.policy p + p { margin-top: 8px; }

/* --------------------------------------------------------------------------- tabbar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--card) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 25px; height: 25px; fill: currentColor; }
.tabbar a.active { color: var(--primary); }
.tabbar .badge {
  position: absolute; margin: -22px 0 0 22px; min-width: 9px; height: 9px; border-radius: 9px; background: var(--red);
}

/* --------------------------------------------------------------------------- toast / sheet */

.toast {
  position: fixed; left: 16px; right: 16px; z-index: 30; margin: 0 auto; max-width: 480px;
  top: calc(var(--safe-top) + 10px);
  background: var(--navy); color: #fff; border-radius: 16px; padding: 14px 16px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25); animation: drop .25s ease;
}
.toast.err { background: #991B1B; }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(var(--safe-bottom) + 20px); animation: rise .25s ease;
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 16px; }
.sheet h2 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.sheet p { color: var(--text-2); margin-bottom: 18px; }
.sheet .btn + .btn { margin-top: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: .6; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
