:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #7c5cff);
  --danger: var(--tg-theme-destructive-text-color, #ff3b30);
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --grad: linear-gradient(135deg, #7c5cff 0%, #b05cf0 50%, #ff5c8a 100%);
  --tint: color-mix(in srgb, var(--accent) 12%, transparent);
  --sep: color-mix(in srgb, var(--hint) 22%, transparent);
  --field: color-mix(in srgb, var(--hint) 12%, transparent);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) { --bg: #0f0f12; --card: #1c1c21; --text: #f2f2f5; --hint: #8a8a93; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--link); text-decoration: none; }

#app { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(110px + env(safe-area-inset-bottom)); }
.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- типографика */
h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.3px; }
h2 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.center { text-align: center; }
.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--hint);
  margin: 22px 4px 8px; font-weight: 600;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 4px 14px; }
.page-head .sub { color: var(--hint); font-size: 14px; margin-top: 2px; }

.topbar { display: flex; align-items: center; height: 36px; margin-bottom: 4px; }
.back { color: var(--link); font-size: 16px; display: flex; align-items: center; gap: 2px; }

/* ---------- карточки и списки */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 10px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: left;
  position: relative; transition: background .15s;
}
.row + .row::before { content: ""; position: absolute; left: 16px; right: 0; top: 0; height: 1px; background: var(--sep); }
button.row:active { background: var(--field); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { color: var(--hint); font-size: 13px; margin-top: 2px; }
.row .price { font-weight: 700; white-space: nowrap; }
.chev { color: var(--hint); opacity: .6; flex: none; }
.icon-badge {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--tint); color: var(--accent); font-size: 20px;
}

/* ---------- герой мастера */
.hero { text-align: center; padding: 22px 16px 18px; }
.avatar {
  width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 12px; padding: 3px; background: var(--grad);
}
.avatar > * {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: grid; place-items: center;
  background: var(--card); border: 3px solid var(--card); font-size: 34px; font-weight: 700; color: var(--accent);
}
.hero .desc { color: var(--hint); margin-top: 6px; white-space: pre-line; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 12px; border-radius: 999px;
  background: var(--tint); color: var(--accent); font-size: 13px; font-weight: 600; max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- выбор дня и времени */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: none; width: 58px; padding: 10px 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  text-align: center; transition: transform .15s;
}
.day .wd { font-size: 12px; color: var(--hint); text-transform: capitalize; }
.day .num { font-size: 20px; font-weight: 700; margin-top: 2px; }
.day .mon { font-size: 11px; color: var(--hint); }
.day.off { opacity: .35; pointer-events: none; }
.day.active { background: var(--grad); color: #fff; }
.day.active .wd, .day.active .mon { color: rgba(255, 255, 255, .85); }
.day:active { transform: scale(.96); }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
  padding: 12px 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-weight: 600;
  font-variant-numeric: tabular-nums; transition: transform .15s;
}
.slot.active { background: var(--grad); color: #fff; }
.slot:active { transform: scale(.95); }

/* ---------- кнопки */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px;
  border-radius: 16px; font-weight: 650; font-size: 16px; transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.secondary { background: var(--tint); color: var(--accent); }
.btn.ghost { color: var(--link); height: 44px; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn:disabled { opacity: .45; pointer-events: none; box-shadow: none; }
.btn.small { height: 38px; font-size: 14px; border-radius: 12px; width: auto; padding: 0 14px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.bottom-bar > * { max-width: 528px; margin: 0 auto; }
.bottom-bar.with-tabs { bottom: calc(64px + env(safe-area-inset-bottom)); padding-bottom: 8px; }

/* ---------- формы */
.field { display: block; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.field > span { display: block; font-size: 13px; color: var(--hint); margin: 0 4px 6px; }
.input {
  width: 100%; border: 0; outline: 0; background: var(--field); border-radius: 14px; padding: 13px 14px;
  font-size: 16px; transition: box-shadow .15s;
}
.input:focus { box-shadow: 0 0 0 2px var(--accent); }
textarea.input { resize: none; min-height: 86px; }
.prefix-input { display: flex; align-items: center; background: var(--field); border-radius: 14px; padding-left: 14px; }
.prefix-input .pre { color: var(--hint); font-size: 14px; white-space: nowrap; }
.prefix-input .input { background: transparent; padding-left: 2px; }
.hint { font-size: 12px; color: var(--hint); margin: 6px 4px 0; }
.err { color: var(--danger); font-size: 13px; margin: 8px 4px 0; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--field); transition: .2s; }
.switch i::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wday { height: 44px; border-radius: 12px; background: var(--field); font-weight: 600; font-size: 14px; color: var(--hint); }
.wday.on { background: var(--grad); color: #fff; }
.time-pair { display: flex; align-items: center; gap: 10px; }
.time-pair .input { text-align: center; }

/* ---------- календарь выходных */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-head b { text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wdh { font-size: 11px; color: var(--hint); text-align: center; padding-bottom: 4px; }
.cal button {
  aspect-ratio: 1; border-radius: 12px; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums;
}
.cal button.weekend { color: var(--hint); }
.cal button.dayoff { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.cal button.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal button:disabled { opacity: .25; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--hint); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- записи мастера */
.booking { display: flex; gap: 14px; }
.booking .time { flex: none; width: 58px; font-weight: 700; font-variant-numeric: tabular-nums; }
.booking .time small { display: block; color: var(--hint); font-weight: 500; font-size: 12px; }
.booking .body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 12px; }
.booking .who { margin-top: 4px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---------- статистика */
.seg { display: flex; background: var(--field); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; height: 34px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--hint); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--hint); font-size: 13px; }
.kpi.main { grid-column: span 2; background: var(--grad); color: #fff; }
.kpi.main .l { color: rgba(255, 255, 255, .85); }
.bar { height: 6px; border-radius: 99px; background: var(--field); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }

/* ---------- таббар */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--sep); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar > div { display: flex; width: 100%; max-width: 560px; }
.tab { flex: 1; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--hint); font-size: 11px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }

/* ---------- прочее */
.empty { text-align: center; padding: 34px 20px; }
.empty .em { font-size: 44px; }
.empty p { color: var(--hint); margin: 8px 0 16px; }
.success-mark {
  width: 88px; height: 88px; border-radius: 50%; background: var(--grad); margin: 26px auto 16px;
  display: grid; place-items: center; color: #fff; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 40%, transparent);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.summary .line { display: flex; gap: 12px; padding: 9px 0; }
.summary .line + .line { border-top: 1px solid var(--sep); }
.summary .line .k { color: var(--hint); width: 92px; flex: none; }
.summary .line .v { font-weight: 600; }
.feature { display: flex; gap: 12px; align-items: flex-start; }
.feature + .feature { margin-top: 14px; }
.feature b { display: block; }
.logo { width: 76px; height: 76px; border-radius: 22px; display: block; margin: 18px auto 14px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent); }
.link-box { background: var(--field); border-radius: 12px; padding: 11px 12px; font-size: 14px; word-break: break-all; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 5px 10px; border-radius: 99px; }
.status.ok { background: color-mix(in srgb, #34c759 16%, transparent); color: #1f9d48; }
.status.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.skeleton { border-radius: var(--radius); height: 72px; margin-top: 10px;
  background: linear-gradient(90deg, var(--card) 25%, var(--field) 50%, var(--card) 75%); background-size: 200% 100%;
  animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; top: 14px; transform: translate(-50%, -200%); opacity: 0; visibility: hidden; z-index: 100; max-width: 90%;
  background: rgba(30, 30, 34, .92); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px;
  font-weight: 500; transition: transform .3s cubic-bezier(.2, 1.2, .4, 1), opacity .2s, visibility .3s; backdrop-filter: blur(10px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); display: flex; align-items: flex-end;
  animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; margin: 0 auto; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2, 1, .3, 1);
  max-height: 92vh; overflow-y: auto; }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grabber { width: 38px; height: 5px; border-radius: 99px; background: var(--sep); margin: 0 auto 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 8px 12px; border-radius: 10px; background: var(--field); font-weight: 600; font-size: 14px; }
.chips button.on { background: var(--accent); color: #fff; }

/* приглашение и «Тоже мастер?» */
.invite-card { margin-top: 12px; background: linear-gradient(135deg, rgba(139, 92, 246, .12), rgba(236, 72, 153, .12)); }
.join-hint { margin: 22px 0 4px; text-align: center; font-size: 12px; color: var(--hint, #8e8e93); }
.join-hint a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
