:root {
  --primary: #8E2A86;
  --primary-dark: #6A1E64;
  --primary-ink: #7A1F73;
  --tint: #F5E6F4;
  --tint-2: #FBF2FA;
  --bg: #FAF6FA;
  --card: #FFFFFF;
  --border: #EEE1EE;
  --divider: #F4EAF3;
  --track: #F1E4F0;
  --text: #2A1620;
  --muted: #6E5964;
  --warn: #8A4B08;
  --warn-bg: #FEF3E2;
  --danger: #B3261E;
  --danger-bg: #FDECEA;
  --step: #0E7A66;
  --step-tint: #DCF4EC;
  --lime: #C6E05A;
  --radius: 18px;
  --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;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.35; }
body { min-height: 100vh; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }

/* ---------- каркас */
.screen { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: calc(var(--safe-top) + 10px) 0 calc(var(--safe-bottom) + 96px); }
.screen.no-tabs { padding-bottom: calc(var(--safe-bottom) + 110px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; min-height: 52px; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px; font-size: 16px; font-weight: 700; color: var(--primary); text-decoration: none; background: none; border: none; cursor: pointer; }
.back .chev { font-size: 26px; line-height: 1; margin-top: -2px; }
.page-head { padding: 4px 20px 14px; display: flex; flex-direction: column; gap: 6px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn-text { color: var(--warn); }
.danger-text { color: var(--danger); }
.section { padding: 0 16px; margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.section > h2, .section-title { font-size: 15px; font-weight: 800; color: var(--muted); padding: 0 4px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- карточки и списки */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.shadow { box-shadow: 0 6px 18px rgba(142, 42, 134, 0.08); }
.list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 14px; border-bottom: 1px solid var(--divider); min-height: 56px; width: 100%; background: none; border-left: none; border-right: none; border-top: none; text-align: left; color: inherit; text-decoration: none; }
.item:last-child { border-bottom: none; }
button.item, a.item { cursor: pointer; }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .name { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.item .sub.warn { color: var(--warn); }
.item .chev { color: var(--muted); font-size: 20px; }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-weight: 600; }

.chip { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; background: var(--tint); color: var(--primary-ink); white-space: nowrap; }
.chip.step { background: var(--step-tint); color: var(--step); }
.chip.gray { background: var(--track); color: var(--muted); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px; border-radius: 16px; border: 2px solid transparent; background: var(--primary); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; text-decoration: none; text-align: center; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.ghost { background: #fff; color: var(--text); border-color: #E4D3E3; font-weight: 700; }
.btn.danger { background: var(--danger); }
.btn.danger-outline { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.link-btn { background: none; border: none; padding: 0 4px; min-height: 44px; color: var(--primary); font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.btn-row .btn { padding: 0 10px; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--border); background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--primary); cursor: pointer; flex: none; }
.fab { position: fixed; right: max(20px, calc(50% - 260px)); bottom: calc(var(--safe-bottom) + 92px); height: 56px; padding: 0 22px; border-radius: 28px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; border: none; box-shadow: 0 10px 24px rgba(142, 42, 134, 0.35); cursor: pointer; z-index: 20; text-decoration: none; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--border); padding: 12px 16px calc(var(--safe-bottom) + 14px); }
.action-bar .inner { max-width: 528px; margin: 0 auto; }

/* ---------- нижние вкладки */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--border); padding: 6px 6px calc(var(--safe-bottom) + 6px); }
.tabbar .inner { max-width: 560px; margin: 0 auto; display: flex; justify-content: space-around; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 70px; padding: 6px 0; font-size: 11px; font-weight: 700; color: var(--muted); text-decoration: none; }
.tab.active { color: var(--primary); font-weight: 800; }
.tab svg { width: 24px; height: 24px; }

/* ---------- расписание */
.week-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 8px; }
.week-nav .label { font-size: 15px; font-weight: 800; }
.week-strip { padding: 10px 16px 4px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border-radius: 14px; background: #fff; border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.day .dw { font-size: 12px; font-weight: 600; color: var(--muted); }
.day .dn { font-size: 17px; font-weight: 800; }
.day .dots { display: flex; gap: 3px; height: 6px; }
.day .dot { width: 6px; height: 6px; border-radius: 3px; background: var(--primary); }
.day .dot.step { background: var(--step); }
.day .dot.cancelled { background: #D6C2D4; }
.day.today { background: var(--primary); border-color: var(--primary); color: #fff; }
.day.today .dw { color: #fff; }
.day.today .dot { background: var(--lime); }
.day.empty-day .dn { color: var(--muted); }

.banner { margin: 10px 16px 0; padding: 12px 14px; border-radius: 14px; background: var(--warn-bg); color: var(--warn); display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; text-decoration: none; }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.banner.info { background: var(--tint); color: var(--primary-ink); }

.class-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.class-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.class-card .big { display: flex; align-items: baseline; gap: 8px; }
.class-card .num { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.class-card.cancelled { opacity: 0.7; }
.class-card.past .num { font-size: 22px; }
.progress { height: 8px; border-radius: 4px; background: var(--tint); overflow: hidden; }
.progress > div { height: 8px; border-radius: 4px; background: var(--primary); }
.progress.step { background: var(--step-tint); }
.progress.step > div { background: var(--step); }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-weight: 600; }
.day-title { font-size: 15px; font-weight: 800; color: var(--muted); padding: 0 4px; margin-top: 6px; }
.day-title.today { color: var(--primary); }

/* ---------- тренировка */
.stats { padding: 0 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 20px; font-weight: 800; }
.stat .l { font-size: 12px; font-weight: 600; color: var(--muted); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--track); }
.seg button { min-height: 40px; border: none; border-radius: 10px; background: transparent; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); font-weight: 800; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.check { width: 44px; height: 44px; border-radius: 22px; border: 2px solid #D6C2D4; background: #fff; color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
.check.on { background: var(--primary); border-color: var(--primary); }
.check svg { width: 22px; height: 22px; }

/* ---------- формы */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 800; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 2px solid #E4D3E3; background: #fff; font-size: 17px; outline: none; -webkit-appearance: none; appearance: none; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.45; font-size: 15px; }
.input:focus { border-color: var(--primary); }
select.input { 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; }
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 52px; border-radius: 14px; background: #fff; border: 2px solid #E4D3E3; }
.search:focus-within { border-color: var(--primary); }
.search input { flex: 1; border: none; outline: none; background: transparent; font-size: 17px; min-height: 48px; }
.choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice button { min-height: 62px; padding: 8px 6px; border-radius: 14px; border: 1px solid #E4D3E3; background: #fff; font-size: 14px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.choice button.on { border: 2px solid var(--primary); background: var(--tint); color: var(--primary-ink); font-weight: 800; }
.choice button[disabled] { opacity: 0.45; cursor: default; }
.choice .p { font-size: 13px; font-weight: 700; color: var(--muted); }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; font-size: 15px; font-weight: 600; min-height: 52px; }
.toggle-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- клиент */
.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--track); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; flex: none; }
.avatar.big { width: 64px; height: 64px; border-radius: 32px; background: var(--primary); color: #fff; font-size: 22px; }
.contacts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 0 16px; }
.contact { min-height: 60px; border-radius: 14px; background: #fff; border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text); text-decoration: none; font-size: 12px; font-weight: 700; cursor: pointer; }
.contact.main { background: var(--tint); border: 2px solid var(--primary); color: var(--primary-ink); }
.contact svg { width: 20px; height: 20px; color: var(--primary); }
.pips { display: grid; gap: 4px; }
.pips span { height: 10px; border-radius: 5px; background: var(--track); }
.pips span.on { background: var(--primary); }

/* ---------- финансы */
.hero { padding: 16px; border-radius: 20px; background: var(--primary); color: #fff; display: flex; flex-direction: column; gap: 4px; }
.hero .v { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.tile .v { font-size: 19px; font-weight: 800; }
.tile .l { font-size: 13px; font-weight: 700; color: var(--muted); }
.money-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--divider); }
.money-row:last-child { border-bottom: none; }
.money-row .v { font-size: 16px; font-weight: 800; white-space: nowrap; }

/* ---------- шторка и тост */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(42, 22, 32, 0.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 16px calc(var(--safe-bottom) + 20px); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: #D6C2D4; align-self: center; }
.sheet h3 { font-size: 20px; font-weight: 800; }
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 100px); transform: translateX(-50%); max-width: 90vw; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; text-align: center; }
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

/* ---------- вход */
.login { max-width: 400px; margin: 0 auto; padding: calc(var(--safe-top) + 60px) 24px 40px; display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.login img { width: 128px; height: 128px; align-self: center; }
.login h1 { text-align: center; font-size: 22px; font-weight: 800; }
.spinner { padding: 60px 0; text-align: center; color: var(--muted); font-weight: 600; }

@media (min-width: 600px) {
  .screen { padding-top: 24px; }
}
