/* profile.css — личный кабинет бегуна. Стиль как на главной: Montserrat Alternates,
   зелёный герой, лайм и фиолетовый, тёмная капсула меню. */
:root {
    --green: #34A853; --green-d: #2A8C45;
    --lime: #E2FFAB; --violet: #726BEA; --indigo: #4F46E5;
    --ink: #1C1C1E; --text: #303031; --muted: #6B6F76; --line: #E7E9E4;
    --paper: #F5F6F2; --card: #FFFFFF; --gold: #F5B700; --red: #DC2626;
    --display: "Montserrat Alternates", system-ui, sans-serif;
    --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font-family: var(--body); font-size: 15px; min-height: 100vh; }
button { font: inherit; color: inherit; }
a { color: var(--indigo); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ── Экраны входа ── */
.screen-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 28px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(28,28,30,.08); display: flex; flex-direction: column; gap: 14px; }
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font: 800 26px/1.15 var(--display); color: var(--ink); margin: 0; text-wrap: balance; }
.auth-card p { margin: 0; line-height: 1.5; }
.auth-logo { font: 800 22px var(--display); color: var(--ink); text-decoration: none; letter-spacing: -.3px; }
.auth-logo span, .logo span { font-weight: 500; }
.auth-error, .err-box { background: #FEF2F2; color: #991B1B; border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.45; margin: 0; }
.info { background: #F1FFE0; color: #2B5B12; border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.info a { color: #2B5B12; font-weight: 700; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 14px 20px; background: #fff; border: 1.5px solid var(--line); border-radius: 999px; font: 600 15px var(--display); color: var(--ink); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.btn-google:hover { border-color: #B9BCC2; box-shadow: 0 4px 14px rgba(0,0,0,.07); }
.btn-google:disabled { opacity: .7; cursor: progress; }
.link-muted { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; align-self: center; padding: 4px; }
.link-muted:hover { color: var(--ink); }
.dup-list { display: flex; flex-direction: column; gap: 8px; }
.dup { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper); border-radius: 16px; padding: 12px 14px; }
.dup b { display: block; color: var(--ink); font-size: 15px; }
.dup small { color: var(--muted); font-size: 12.5px; }

/* ── Кнопки ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px; padding: 13px 20px; font: 600 14px var(--display); cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-d); }
.btn-light { background: var(--paper); color: var(--ink); }
.btn-light:hover { background: #ECEEE8; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-sm { padding: 9px 14px; font-size: 13px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; font: 600 12px var(--body); color: var(--indigo); cursor: pointer; }

/* ── Шапка как на сайте ── */
#screen-profile { max-width: 1180px; margin: 0 auto; padding: 0 max(14px, env(safe-area-inset-left)) 24px max(14px, env(safe-area-inset-right)); }
.nav { position: sticky; top: max(10px, env(safe-area-inset-top)); z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px auto 0; max-width: 980px; background: rgba(31,31,31,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #fff; border-radius: 999px; padding: 8px 8px 8px 22px; }
.logo { font: 800 19px var(--display); letter-spacing: -.3px; color: #fff; text-decoration: none; }
.nav-links { display: flex; gap: 24px; font: 600 14px var(--display); }
.nav-links a { color: #fff; text-decoration: none; }
.nav-links a:hover { color: #FFB547; }
.nav-exit { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.1); border: 0; color: #fff; border-radius: 999px; padding: 9px 14px; font: 600 13px var(--display); cursor: pointer; }
.nav-exit:hover { background: #DC2626; }

/* ── Герой ── */
.hero { position: relative; margin-top: 14px; border-radius: 28px; background: var(--green); color: #fff; overflow: hidden; padding: 30px; }
.hero::after { content: ""; position: absolute; right: -70px; top: -50px; width: 360px; height: 360px; background: repeating-linear-gradient(-55deg, rgba(255,255,255,.13) 0 26px, transparent 26px 60px); border-radius: 40px; transform: rotate(8deg); pointer-events: none; }
.hero-in { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center; }
.who { display: flex; gap: 18px; align-items: center; min-width: 0; }
.who-text { min-width: 0; }
.ava { position: relative; width: 96px; height: 96px; border-radius: 50%; flex: none; background: var(--lime); color: var(--ink); display: grid; place-items: center; font: 800 32px var(--display); border: 4px solid rgba(255,255,255,.35); cursor: pointer; padding: 0; }
.ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ava .cam { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; border: 3px solid var(--green); }
.ava.loading { opacity: .55; pointer-events: none; }
.who h2 { font: 800 clamp(24px, 3.4vw, 40px)/1.08 var(--display); margin: 0 0 10px; text-wrap: balance; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 6px 12px; font: 600 12.5px var(--body); text-decoration: none; }
a.chip:hover { background: rgba(255,255,255,.3); }
.chip.dark { background: var(--ink); }
.pass { background: #fff; color: var(--ink); border-radius: 22px; padding: 16px; display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; min-width: 340px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.qr { width: 140px; height: 140px; border-radius: 12px; background: #fff; display: grid; place-items: center; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.pass small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.pass-id { font: 800 36px/1 var(--display); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.pass-hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 12px; }

/* ── Сетка ── */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-top: 14px; }
.box { background: var(--card); border-radius: 22px; padding: 22px; min-width: 0; }
.box h3 { font: 700 17px var(--display); margin: 0 0 16px; color: var(--ink); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.box h3 > span { font: 500 12.5px var(--body); color: var(--muted); }
.c12 { grid-column: span 12; } .c7 { grid-column: span 7; } .c5 { grid-column: span 5; }
.loading, .empty { color: var(--muted); font-size: 14px; padding: 18px 0; text-align: center; line-height: 1.5; }

/* Ближайший забег */
.next { background: var(--lime); display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; }
.date { background: var(--ink); color: #fff; border-radius: 18px; width: 78px; padding: 11px 0; text-align: center; font-family: var(--display); }
.date b { display: block; font-size: 30px; line-height: 1; }
.date i { font-style: normal; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.next h4 { margin: 0 0 5px; font: 700 18px var(--display); color: var(--ink); }
.next p { margin: 0; font-size: 14px; color: #3D4A2A; line-height: 1.5; }
.tag { display: inline-block; border-radius: 999px; padding: 3px 9px; font: 700 11px var(--body); white-space: nowrap; }
.tag.ctl { background: var(--violet); color: #fff; }
.tag.std { background: #EEF0EA; color: #555; }
.tag.today { background: var(--ink); color: var(--lime); }

/* Цифры */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat { background: var(--paper); border-radius: 18px; padding: 15px; }
.stat b { display: block; font: 800 28px/1.1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat.pb { background: var(--ink); }
.stat.pb b { color: var(--lime); }
.stat.pb span { color: #B9BCC2; }

/* График */
#chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* Награды */
.aw { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { border-radius: 18px; padding: 14px; background: var(--paper); display: flex; flex-direction: column; gap: 6px; }
.badge .ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font: 800 14px var(--display); background: #E3E5DF; color: #8B8F95; }
.badge.got { background: #F1FFE0; }
.badge.got .ic { background: var(--green); color: #fff; }
.badge b { font: 700 13.5px var(--display); color: var(--ink); }
.badge small { font-size: 12px; color: var(--muted); line-height: 1.35; }
.bar { height: 6px; border-radius: 9px; background: #E3E5DF; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--violet); border-radius: 9px; }

/* Результаты */
.res { width: 100%; border-collapse: collapse; font-size: 14px; }
.res th { font: 600 11px var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: left; padding: 0 10px 8px; white-space: nowrap; }
.res td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.res .t { font: 700 16px var(--display); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.res .num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.res .run b { display: block; color: var(--ink); font-weight: 600; }
.res .run small { color: var(--muted); }
.pbm { display: inline-block; background: var(--gold); color: var(--ink); font: 800 10px var(--display); border-radius: 6px; padding: 2px 5px; margin-left: 6px; vertical-align: 2px; }
.vol { color: var(--indigo); font: 600 14px var(--body); }
.more { display: block; margin: 12px auto 0; }

/* Форма */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 6px; font: 600 12.5px var(--body); color: var(--muted); min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld input { font: 500 15px var(--body); color: var(--ink); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 13px; background: #fff; width: 100%; min-width: 0; outline: none; transition: border-color .15s; -webkit-appearance: none; appearance: none; }
.fld input:focus { border-color: var(--green); }
.fld input[readonly] { background: var(--paper); color: var(--muted); }
.fld input.bad { border-color: var(--red); background: #FFF8F8; }
.seg { display: flex; background: var(--paper); border-radius: 14px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 11px; font: 600 14px var(--body); color: var(--muted); cursor: pointer; }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.note { font-size: 13px; color: var(--muted); margin: 14px 0 0; overflow-wrap: anywhere; }
.save-state { font: 600 12.5px var(--body) !important; }
.save-state.ok { color: var(--green-d) !important; }
.save-state.err { color: var(--red) !important; }

/* Нижнее меню (телефон) */
.bn { display: none; }

/* QR на весь экран */
.qr-full { position: fixed; inset: 0; z-index: 100; background: #fff; display: flex; align-items: center; justify-content: center; padding: 24px; }
.qr-full-in { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 420px; text-align: center; }
.qr-full-name { font: 700 20px var(--display); color: var(--ink); }
.qr-full-code { width: min(86vw, 420px); aspect-ratio: 1; }
.qr-full-code svg, .qr-full-code img { width: 100%; height: 100%; display: block; }
.qr-full-id { font: 800 44px var(--display); color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font: 600 14px var(--body); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 120; max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Планшет ── */
@media (max-width: 1000px) {
    .c7, .c5 { grid-column: span 12; }
    .stats { grid-template-columns: repeat(3, 1fr); }
    .stat.pb { grid-column: span 3; }
}

/* ── Телефон ── */
@media (max-width: 700px) {
    #screen-profile { padding-bottom: calc(100px + env(safe-area-inset-bottom)); padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .nav { margin-top: 10px; padding-left: 18px; }
    .nav-links, .nav-exit span { display: none; }
    .nav-exit { padding: 9px; }
    .hero { padding: 20px; border-radius: 24px; margin-top: 10px; }
    .hero-in { grid-template-columns: 1fr; gap: 18px; }
    .ava { width: 70px; height: 70px; font-size: 24px; }
    .pass { min-width: 0; grid-template-columns: 1fr; text-align: center; justify-items: center; }
    .qr { width: 210px; height: 210px; }
    body:not([data-tab="pass"]) .pass { display: none; }
    body:not([data-tab="pass"]) .hero { padding: 16px 18px; }
    body:not([data-tab="pass"]) .ava { width: 54px; height: 54px; font-size: 19px; }
    body:not([data-tab="pass"]) .who h2 { font-size: 21px; margin-bottom: 6px; }
    body:not([data-tab="pass"]) .ava .cam { display: none; }
    .who { align-items: flex-start; }
    .btn-row { justify-content: center; }
    .grid { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
    .c12, .c7, .c5 { grid-column: 1; }
    .box { padding: 18px; border-radius: 20px; }
    .grid [data-tab] { display: none; }
    .grid [data-tab].show { display: block; }
    .grid .next[data-tab].show { display: grid; }
    .next { grid-template-columns: auto 1fr; }
    .next .btn { grid-column: 1 / -1; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stat.pb { grid-column: 1 / -1; }
    .stat b { font-size: 24px; }
    .form { grid-template-columns: 1fr; }
    .res thead { display: none; }
    .res tr { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
    .res td { border: 0; padding: 0; }
    .res td.typ { display: none; }
    .res td.place, .res td.pace { grid-column: 1; font-size: 12.5px; }
    .res td.place:empty, .res td.pace:empty { display: none; }
    .res td.t { grid-row: 1 / 4; grid-column: 2; grid-row-start: 1; align-self: center; }
    .res td.d { grid-column: 1; font-size: 12.5px; }
    .bn { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); z-index: 60; background: var(--ink); border-radius: 24px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
    .bn-tabs { display: contents; }
    .bn button, .bn-home { border: 0; background: transparent; color: #B9BCC2; font: 600 11px var(--display); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border-radius: 18px; cursor: pointer; text-decoration: none; text-align: center; white-space: nowrap; min-width: 0; }
    .bn-home:hover { color: #fff; }
    .bn button svg, .bn-home svg { width: 21px; height: 21px; }
    .bn button[aria-selected="true"] { background: var(--green); color: #fff; }
    .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
    .bn { padding: 5px; grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr)); }
    .bn button, .bn-home { font-size: 10px; letter-spacing: -.2px; padding: 8px 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: .01s !important; } }

/* картинки наград из админки — строго в своём квадрате, не налезают на текст */
.badge .ic { overflow: hidden; flex: none; }
.badge .ic.has-img { background: #fff; width: 56px; height: 56px; padding: 6px; border-radius: 16px; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
.badge .ic.has-img img { display: block; width: 100%; height: 100%; max-width: 44px; max-height: 44px; object-fit: contain; }
.badge:not(.got) .ic.has-img img { filter: grayscale(1); opacity: .45; }
.badge b { margin-top: 4px; }
