/* Клиентская часть для телефонов. Экраны 320–440 px, iOS 10+.
   Без flex-gap, inset, grid-gap, color-mix, :focus-visible, aspect-ratio и clamp. */
:root {
  --bg: #F2F5F9; --card: #FFFFFF; --ink: #0F1B2D; --muted: #66758A;
  --primary: #12508C; --accent-text: #12508C; --sky: #3F7FC0; --deep: #0B3560;
  --tint: #E3ECF6; --tint2: #F4F7FB; --line: #E3E9F1; --good: #17825A; --bad: #C23B30; --bad-bg: #F8E4E2;
  --hero-a: #3F7FC0; --hero-b: #0B3560;
  --font-body: 'Onest', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Unbounded', 'Onest', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09111F; --card: #101C30; --ink: #E9EFF8; --muted: #93A3BA;
    --primary: #2C6DB5; --accent-text: #86B8F0; --tint: #17294A; --tint2: #0D1829; --line: #1C2B44;
    --good: #46C28C; --bad: #F0776D; --bad-bg: #3A1F24; --hero-a: #2F66A6; --hero-b: #06192F;
  }
}
* { -webkit-box-sizing: border-box; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-weight: 500; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; margin: 0; -webkit-appearance: none; appearance: none; text-align: left; }
button:focus, input:focus { outline: 2px solid var(--accent-text); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
svg.gi { width: 16px; height: 16px; display: inline-block; vertical-align: middle; -webkit-flex: none; flex: none; }
.num { font-variant-numeric: lining-nums proportional-nums; }

.phone { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 92px; padding-bottom: calc(92px + constant(safe-area-inset-bottom)); padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Шапка (hero) ---------- */
.hero { background: #2F66A6; background: -webkit-linear-gradient(top, var(--hero-a), var(--hero-b)); background: linear-gradient(170deg, var(--hero-a) 0%, var(--hero-b) 100%); color: #fff; padding: 14px 16px 54px; position: relative; overflow: hidden; padding-top: calc(14px + constant(safe-area-inset-top)); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.hero-mark { position: absolute; right: -34px; bottom: -6px; width: 250px; height: 234px; opacity: .1; -webkit-filter: brightness(0) invert(1); filter: brightness(0) invert(1); pointer-events: none; }
.hero-top { position: relative; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: space-between; justify-content: space-between; }
.brand { display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; background: #fff; color: #12508C; border-radius: 999px; padding: 6px 14px 6px 10px; font-weight: 800; font-size: 15px; letter-spacing: .02em; -webkit-flex: none; flex: none; }
.brand .emblem { width: 26px; height: 24px; margin-right: 8px; -webkit-flex: none; flex: none; }
.brand-t { display: block; line-height: 1.1; text-align: left; }
.brand-t b { display: block; font-size: 15px; font-weight: 800; letter-spacing: .03em; }
.brand-t small { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0; color: #4F6B8C; white-space: nowrap; margin-top: 1px; }
.seg { display: -webkit-inline-flex; display: inline-flex; background: rgba(255,255,255,.16); border-radius: 999px; padding: 4px; margin-left: 8px; }
.seg button { color: rgba(255,255,255,.85); padding: 0 16px; border-radius: 999px; font-weight: 700; font-size: 14px; min-height: 36px; white-space: nowrap; text-align: center; }
.seg button[aria-pressed="true"] { background: #fff; color: #0B3560; }
.pill { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: rgba(255,255,255,.22); color: #fff; padding: 3px 8px; border-radius: 999px; }
.pill-btn { display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; background: rgba(255,255,255,.16); color: #fff; padding: 0 14px; border-radius: 999px; font-weight: 700; font-size: 14px; min-height: 36px; margin-left: 8px; }
.hero-body { position: relative; margin-top: 18px; }
.hero-who { font-size: 14px; font-weight: 700; opacity: .88; }
.hero-who .pill { margin-left: 6px; }
.hero-place { font-family: var(--font-display); font-weight: 800; font-size: 60px; line-height: 1.05; letter-spacing: -.02em; margin-top: 6px; }
.hero-place small { font-family: var(--font-body); font-size: 15px; font-weight: 700; opacity: .8; letter-spacing: 0; margin-left: 6px; }
.hero-lead { font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1.18; margin-top: 8px; word-wrap: break-word; }
.hero-pts { font-size: 24px; font-weight: 800; margin-top: 4px; }
.hero-pts span { font-size: 14px; font-weight: 700; opacity: .8; }
.hero-stats { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin-top: 14px; }
.hero-stats > div { margin-right: 22px; }
.hero-stats b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.hero-stats span { font-size: 13px; font-weight: 700; opacity: .85; }
.hero-group { display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; margin-top: 10px; background: rgba(255,255,255,.16); border-radius: 999px; padding: 4px 12px 4px 8px; font-weight: 700; font-size: 13px; }
.hero-group svg { margin-right: 6px; }

/* ---------- Белый лист и строки ---------- */
.sheet { background: var(--card); border-radius: 28px 28px 0 0; margin-top: -28px; position: relative; padding: 10px 10px 8px; min-height: 240px; }
.chips { display: -webkit-flex; display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 2px 8px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { -webkit-flex: none; flex: none; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; background: var(--tint2); color: var(--muted); border-radius: 999px; padding: 0 14px 0 10px; min-height: 40px; margin-right: 8px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.chip svg { margin-right: 6px; width: 20px; height: 20px; }
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; }
.sheet-head { display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; padding: 8px 6px 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.row { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; width: 100%; padding: 8px; border-radius: 18px; min-height: 62px; }
.row:active { background: var(--tint2); }
.row.me { background: var(--tint); }
.place { width: 44px; height: 44px; border-radius: 12px; background: var(--tint2); color: var(--muted); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; font-weight: 800; font-size: 17px; -webkit-flex: none; flex: none; margin-right: 12px; }
.row.me .place { background: var(--card); }
/* Топ-3: золото, серебро, бронза. Фон строк полупрозрачный, чтобы текст читался и на светлой, и на тёмной теме. */
.row.m1 { box-shadow: inset 0 0 0 2px #D4A62A; background: rgba(212,166,42,.13); margin-bottom: 4px; }
.row.m2 { box-shadow: inset 0 0 0 2px #A9B4C2; background: rgba(169,180,194,.17); margin-bottom: 4px; }
.row.m3 { box-shadow: inset 0 0 0 2px #C47C40; background: rgba(196,124,64,.13); margin-bottom: 4px; }
.row .place.m1 { background: #E6BE55; background: linear-gradient(145deg, #FBE9AC, #D9A93E); color: #2B1E04; }
.row .place.m2 { background: #C9D1DB; background: linear-gradient(145deg, #F6F8FB, #AEB9C7); color: #1B2635; }
.row .place.m3 { background: #D9A06A; background: linear-gradient(145deg, #F6D6B3, #C98650); color: #2E1807; }
.who { -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; }
.who b { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; font-size: 16px; font-weight: 800; line-height: 1.2; }
.who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.who em { font-style: normal; font-size: 13px; font-weight: 700; color: var(--muted); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; margin-top: 2px; }
.who em svg { margin-right: 5px; width: 15px; height: 15px; }
.who em span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-me { -webkit-flex: none; flex: none; margin-left: 8px; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; background: var(--primary); color: #fff; padding: 2px 7px; border-radius: 999px; }
.pts { -webkit-flex: none; flex: none; margin-left: 10px; text-align: right; font-weight: 800; font-size: 20px; white-space: nowrap; }
.pts small { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 3px; }
.neg { color: var(--bad); }
.note { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding: 12px 8px 8px; }
.state { text-align: center; color: var(--muted); font-weight: 700; padding: 40px 16px; }
.state .btn { margin-top: 14px; }
.btn { display: inline-block; background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; padding: 0 22px; border-radius: 999px; min-height: 46px; line-height: 46px; text-align: center; }
.btn.ghost { background: var(--tint); color: var(--accent-text); }
.btn.block { display: block; width: 100%; }
.btn[disabled] { opacity: .55; }

/* ---------- Нижняя панель ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: -webkit-flex; display: flex; padding: 8px 12px; padding-bottom: calc(8px + constant(safe-area-inset-bottom)); padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 20; }
.nav-in { max-width: 480px; margin: 0 auto; width: 100%; display: -webkit-flex; display: flex; }
.nav button { -webkit-flex: 1 1 0; flex: 1 1 0; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; border-radius: 18px; color: var(--muted); font-weight: 800; font-size: 13px; min-height: 56px; text-align: center; margin: 0 4px; }
.nav button svg { width: 24px; height: 24px; margin-bottom: 3px; }
.nav button[aria-current="page"] { background: var(--tint); color: var(--accent-text); }

/* ---------- Профиль ---------- */
.p-hero { padding-bottom: 46px; }
.p-id { position: relative; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; margin-top: 14px; }
.avatar { width: 62px; height: 62px; border-radius: 50%; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.9); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 21px; -webkit-flex: none; flex: none; margin-right: 14px; }
.p-id h1 { font-size: 20px; font-weight: 800; line-height: 1.15; word-wrap: break-word; }
.p-id p { margin-top: 3px; font-size: 13px; font-weight: 700; opacity: .88; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.p-id p svg { margin-right: 5px; }
.p-info { min-width: 0; }
.kpis { position: relative; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin-top: 12px; }
.kpi { background: rgba(255,255,255,.16); border-radius: 14px; padding: 8px 12px; margin: 0 8px 8px 0; }
.kpi b { display: block; font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.1; }
.kpi span { font-size: 11px; font-weight: 700; opacity: .88; }
.p-body { padding: 0 10px 10px; margin-top: -26px; position: relative; }
.card { background: var(--card); border-radius: 24px; padding: 14px; margin-bottom: 10px; }
.card h2 { font-size: 16px; font-weight: 800; margin-bottom: 10px; display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; -webkit-align-items: baseline; align-items: baseline; }
.card h2 small { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 8px; }
.tiles { display: -webkit-flex; display: flex; }
.tile { -webkit-flex: 1 1 0; flex: 1 1 0; min-width: 0; background: var(--tint2); border-radius: 18px; padding: 10px 4px; text-align: center; margin-left: 6px; }
.tile:first-child { margin-left: 0; }
.tile b { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; font-size: 22px; font-weight: 800; line-height: 1.1; color: var(--accent-text); }
.tile b svg { width: 15px; height: 15px; margin-right: 3px; fill: currentColor; stroke: none; }
.tile span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); line-height: 1.2; margin-top: 3px; }
.bar { height: 4px; background: var(--tint); border-radius: 999px; overflow: hidden; margin: 6px 8px 0; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.ach { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -3px; }
.ach-i { width: 25%; padding: 0 3px; margin-bottom: 12px; text-align: center; }
.medal { display: block; width: 54px; height: 54px; margin: 0 auto 4px; }
.m-bg { fill: var(--primary); } .m-ic { fill: #fff; } .m-ring { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 2; }
.medal.locked .m-bg { fill: var(--tint); } .medal.locked .m-ic { fill: var(--muted); opacity: .7; } .medal.locked .m-ring { stroke: var(--line); }
.ach-i b { display: block; font-size: 11px; font-weight: 800; line-height: 1.2; word-wrap: break-word; }
.ach-i span { display: block; font-size: 10px; font-weight: 700; color: var(--muted); margin-top: 2px; }
.ach-i.locked b { color: var(--muted); }
.mini { height: 4px; background: var(--tint); border-radius: 999px; overflow: hidden; margin: 4px 6px 0; }
.mini i { display: block; height: 100%; background: var(--sky); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bpos { fill: var(--primary); } .chart .bneg { fill: var(--bad); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-weight: 700; }
.chart .zero { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.day { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day time { width: 46px; -webkit-flex: none; flex: none; font-weight: 800; font-size: 13px; }
.day time span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.tags { -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.tg { font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: var(--tint); color: var(--accent-text); margin: 2px 4px 2px 0; white-space: nowrap; }
.tg.bad { background: var(--bad-bg); color: var(--bad); }
.day .sc { -webkit-flex: none; flex: none; margin-left: 8px; font-weight: 800; font-size: 16px; }
.sc.pos { color: var(--good); }

/* ---------- Вход и формы ---------- */
.login h2 { font-size: 20px; margin-bottom: 4px; display: block; }
.sub { color: var(--muted); font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.fld { display: block; margin-bottom: 12px; }
.fld > span { display: block; font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.in { display: block; width: 100%; background: var(--tint2); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-height: 48px; font-weight: 700; -webkit-appearance: none; appearance: none; color: var(--ink); }
.pw { display: -webkit-flex; display: flex; }
.pw .in { -webkit-flex: 1 1 auto; flex: 1 1 auto; min-width: 0; }
.pw .btn { -webkit-flex: none; flex: none; margin-left: 6px; padding: 0 14px; min-height: 48px; line-height: 48px; font-size: 14px; }
.err { color: var(--bad); font-size: 13px; font-weight: 800; min-height: 20px; margin-bottom: 4px; }
.ok { color: var(--good); font-size: 13px; font-weight: 800; min-height: 20px; margin-bottom: 4px; }
.link { color: var(--accent-text); font-weight: 800; font-size: 14px; padding: 8px 0; }

/* ---------- Окно обзора ---------- */
.ov { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(6,16,34,.55); display: -webkit-flex; display: flex; -webkit-align-items: flex-end; align-items: flex-end; -webkit-justify-content: center; justify-content: center; z-index: 60; }
.md { background: var(--card); width: 100%; max-width: 480px; border-radius: 28px 28px 0 0; padding: 16px 14px; padding-bottom: calc(16px + constant(safe-area-inset-bottom)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); max-height: 90%; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; }
.md-x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%; background: var(--tint); color: var(--accent-text); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; }
.md-x svg { width: 18px; height: 18px; }
.md-head { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding-right: 48px; }
.md-head .avatar { background: var(--primary); border-color: var(--tint); color: #fff; width: 52px; height: 52px; font-size: 18px; margin-right: 12px; }
.md-head b { display: block; font-size: 18px; font-weight: 800; line-height: 1.2; word-wrap: break-word; }
.md-head span { font-size: 13px; color: var(--muted); font-weight: 700; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; margin-top: 2px; }
.md-head span svg { margin-right: 5px; }
.md-chips { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 12px 0 4px; }
.md-chips .kpi { background: var(--tint2); }
.md-chips .kpi b { color: var(--accent-text); }
.md-chips .kpi span { color: var(--muted); }
.md h3 { margin: 12px 0 8px; font-size: 14px; font-weight: 800; display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; }
.md h3 small { color: var(--muted); font-weight: 700; font-size: 12px; }
.md .medal { width: 46px; height: 46px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 100px; margin: 0 auto; max-width: 360px; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 800; font-size: 14px; text-align: center; z-index: 80; }

/* ---------- Профиль топ-3: золотой, серебряный, бронзовый фон ---------- */
.hero.m1 { --hero-a: #F9E8AB; --hero-b: #D9A93E; --mink: #2B1E04; --ring: #A8780F; }
.hero.m2 { --hero-a: #F7F9FC; --hero-b: #B2BCC9; --mink: #1B2635; --ring: #6F7C8C; }
.hero.m3 { --hero-a: #F7D9B8; --hero-b: #C98650; --mink: #2E1807; --ring: #94551F; }
.hero.m { color: var(--mink); }
.hero.m .hero-mark { -webkit-filter: brightness(0); filter: brightness(0); opacity: .08; }
.hero.m .pill-btn, .hero.m .pill { background: rgba(255,255,255,.55); color: var(--mink); }
.hero.m .kpi { background: rgba(255,255,255,.5); }
.hero.m .avatar { background: rgba(255,255,255,.6); color: var(--mink); border: 3px solid var(--ring); }
.md-head .avatar.m1 { border-color: #D4A62A; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #D4A62A; }
.md-head .avatar.m2 { border-color: #A9B4C2; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #A9B4C2; }
.md-head .avatar.m3 { border-color: #C47C40; box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #C47C40; }
.md-head .avatar.m { margin-left: 4px; margin-right: 16px; }

/* ---------- Маленькие экраны (iPhone 5/SE: 320 px) ---------- */
@media (max-width: 374px) {
  .hero-top { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .hero-top .seg { display: -webkit-flex; display: flex; width: 100%; margin-left: 0; margin-top: 10px; }
  .hero-top .seg button { -webkit-flex: 1 1 0; flex: 1 1 0; }
}
@media (max-width: 350px) {
  .hero { padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 14px; padding: 5px 11px 5px 8px; }
  .brand .emblem { width: 22px; height: 21px; margin-right: 6px; }
  .seg button { padding: 0 12px; font-size: 13px; min-height: 34px; }
  .hero-place { font-size: 50px; }
  .hero-lead { font-size: 21px; }
  .hero-pts { font-size: 21px; }
  .hero-stats > div { margin-right: 16px; }
  .hero-stats b { font-size: 21px; }
  .hero-stats span { font-size: 12px; }
  .sheet { padding-left: 6px; padding-right: 6px; }
  .row { padding: 6px; }
  .place { width: 38px; height: 38px; font-size: 15px; margin-right: 10px; }
  .who b { font-size: 15px; }
  .pts { font-size: 18px; }
  .pts small { display: none; }
  .p-body { padding-left: 6px; padding-right: 6px; }
  .card { padding: 12px 10px; border-radius: 20px; }
  .tile b { font-size: 19px; }
  .tile span { font-size: 10px; }
  .kpi { padding: 7px 10px; }
  .kpi b { font-size: 18px; }
  .medal { width: 46px; height: 46px; }
  .ach-i b { font-size: 10px; }
  .avatar { width: 54px; height: 54px; font-size: 18px; margin-right: 10px; }
  .p-id h1 { font-size: 18px; }
}
@media (max-height: 580px) { .hero-place { font-size: 46px; } }
@media (min-width: 481px) { body { background: var(--bg); } .nav { border-radius: 0; } }
@media (prefers-reduced-motion: reduce) { * { -webkit-transition: none !important; transition: none !important; } }
[hidden] { display: none !important; }
