/* ============ ПЕРЕМЕННЫЕ ============ */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #f4f4f7);
  --text: var(--tg-theme-text-color, #0f0f0f);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);

  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-danger: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);

  --radius: 18px;
  --radius-sm: 14px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 24px rgba(102, 126, 234, 0.15);
  --shadow-lg: 0 12px 32px rgba(102, 126, 234, 0.25);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
               Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ============ ПРОГРЕСС-БАР ============ */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-secondary);
  z-index: 999;
}

.progress-fill {
  height: 100%;
  background: var(--gradient);
  width: 20%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px rgba(102, 126, 234, 0.6);
}

#app {
  padding: 28px 20px 40px;
  max-width: 560px;
  margin: 0 auto;
}

/* ============ ЭКРАНЫ ============ */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: screenIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ ВЕРХНЯЯ ПАНЕЛЬ ============ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: var(--bg-secondary);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}

.user-badge:active {
  transform: scale(0.96);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 14px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.icon-btn:active {
  transform: scale(0.9);
  background: var(--gradient);
  color: #fff;
}

/* ============ HERO ============ */
.hero-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  animation: floatIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-icon svg { width: 100%; height: 100%; }

@keyframes floatIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.8); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ ЗАГОЛОВКИ ============ */
h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin-bottom: 8px;
  line-height: 1.15;
}

.subtitle {
  font-size: 15px;
  color: var(--hint);
  margin-bottom: 28px;
  line-height: 1.4;
}

/* ============ ФОРМА ============ */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

input[type="text"] {
  width: 100%;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  transition: all var(--transition);
  margin-bottom: 20px;
}

input[type="text"]:focus {
  border-color: #667eea;
  background: var(--bg);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

input[type="text"]::placeholder {
  color: var(--hint);
  opacity: 0.6;
  font-weight: 400;
}

/* ============ КНОПКИ ============ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 18px;
  background: var(--gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
}

.btn-arrow {
  width: 20px;
  height: 20px;
  transition: transform var(--transition);
}

.btn-primary:active .btn-arrow {
  transform: translateX(4px);
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--hint);
  border: none;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  margin-top: 16px;
  cursor: pointer;
  transition: color var(--transition);
}

.btn-secondary:active {
  color: var(--text);
}

.btn-danger {
  background: var(--gradient-danger);
  box-shadow: 0 8px 24px rgba(245, 87, 108, 0.2);
}

.btn-danger:active {
  box-shadow: 0 12px 32px rgba(245, 87, 108, 0.3);
}

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.4) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s;
}

.ripple:active::before {
  opacity: 1;
}

/* ============ СПИСКИ ============ */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item {
  padding: 20px 22px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
}

.item::after {
  content: "›";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--hint);
  font-size: 24px;
  font-weight: 300;
  transition: all var(--transition);
}

.item.no-arrow::after {
  display: none;
}

.item:active {
  transform: scale(0.98);
  border-color: #667eea;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.item:active::after {
  color: #667eea;
  transform: translateY(-50%) translateX(4px);
}

.item-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 3px;
  letter-spacing: -0.2px;
}

.item-sub {
  font-size: 14px;
  color: var(--hint);
}

.item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ============ КАЛЕНДАРЬ ============ */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 4px;
}

.calendar-header span {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.4px;
}

.calendar-header button {
  background: var(--bg-secondary);
  border: none;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 12px;
  font-family: inherit;
  transition: all var(--transition);
  font-weight: 600;
}

.calendar-header button:active {
  transform: scale(0.9);
  background: var(--gradient);
  color: #ffffff;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: all var(--transition);
  user-select: none;
  position: relative;
}

.calendar-day:active {
  transform: scale(0.88);
  background: var(--gradient);
  color: #ffffff;
}

.calendar-day.empty {
  background: transparent;
  cursor: default;
  font-size: 12px;
  font-weight: 700;
  color: var(--hint);
  opacity: 0.5;
  letter-spacing: 0.5px;
}

.calendar-day.empty:active {
  transform: none;
  background: transparent;
  color: var(--hint);
}

.calendar-day.disabled {
  opacity: 0.2;
  pointer-events: none;
  background: transparent;
  color: var(--hint);
}

.calendar-day.selected {
  background: var(--gradient);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

/* ============ СЛОТЫ ============ */
.time-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.time-item {
  padding: 18px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.time-item:active {
  transform: scale(0.95);
  background: var(--gradient);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.time-item:active .time-title,
.time-item:active .time-sub {
  color: #ffffff;
}

.time-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.time-sub {
  font-size: 13px;
  color: var(--hint);
  font-weight: 500;
}

.time-item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.time-item.mine {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.time-item.mine .time-title {
  color: #10b981;
}

/* Слоты, которые уже прошли */
.time-item.past {
  opacity: 0.35;
  pointer-events: none;
  position: relative;
}

.time-item.past .time-title {
  text-decoration: line-through;
  text-decoration-color: var(--hint);
}

.time-item.past .time-sub {
  font-size: 12px;
}

/* ============ МОИ ЗАПИСИ ============ */
.booking-card {
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: all var(--transition);
  animation: screenIn 0.3s ease;
}

.booking-card.past {
  opacity: 0.55;
}

.booking-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.booking-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.booking-status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

.booking-status.active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.booking-status.past {
  background: rgba(142, 142, 147, 0.15);
  color: var(--hint);
}

.booking-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--hint);
}

.booking-info span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.booking-actions {
  display: flex;
  gap: 8px;
}

.booking-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.booking-btn.cancel {
  background: rgba(245, 87, 108, 0.1);
  color: #f5576c;
}

.booking-btn.cancel:active {
  background: var(--gradient-danger);
  color: #fff;
  transform: scale(0.96);
}

/* ============ ПРОФИЛЬ ============ */
.profile-card {
  text-align: center;
  padding: 32px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  margin: 0 auto 16px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}

.profile-id {
  font-size: 14px;
  color: var(--hint);
  font-family: ui-monospace, "SF Mono", monospace;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.6px;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 13px;
  color: var(--hint);
  font-weight: 600;
}

/* ============ ЭКРАН УСПЕХА ============ */
.screen-success {
  position: fixed;
  inset: 0;
  padding: 40px 20px;
  overflow-y: auto;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.screen-success.active {
  display: flex;
  animation: screenIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.success-bg {
  position: absolute;
  inset: 0;
  background: var(--gradient);
  opacity: 0.06;
  z-index: 0;
  pointer-events: none;
}

.success-bg::before,
.success-bg::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
}

.success-bg::before {
  width: 300px;
  height: 300px;
  background: #667eea;
  top: -100px;
  left: -100px;
  animation: float 8s ease-in-out infinite;
}

.success-bg::after {
  width: 250px;
  height: 250px;
  background: #10b981;
  bottom: -80px;
  right: -80px;
  animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(20px, 20px); }
}

.success-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
}

.success-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
  animation: bounceIn 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  filter: drop-shadow(0 8px 24px rgba(16, 185, 129, 0.3));
}

.success-icon svg { width: 100%; height: 100%; }

@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.3) rotate(-20deg); }
  60%  { opacity: 1; transform: scale(1.15) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.success-title {
  text-align: center;
  background: var(--gradient-success);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.success-subtitle {
  text-align: center;
  margin-bottom: 32px;
}

.success-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 8px 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.success-row {
  display: flex;
  align-items: center;
  padding: 14px 0;
  font-size: 15px;
}

.success-row:not(:last-child) {
  border-bottom: 1px solid var(--bg-secondary);
}

.success-row .icon {
  font-size: 20px;
  width: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.success-row .label {
  color: var(--hint);
  margin-right: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.success-row .value {
  font-weight: 700;
  color: var(--text);
  text-align: right;
  margin-left: auto;
}

/* ============ ПУСТЫЕ СОСТОЯНИЯ ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--hint);
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state-text {
  font-size: 15px;
  line-height: 1.4;
}

/* ============ РАСПИСАНИЕ НА НЕДЕЛЮ ============ */
.week-section {
  margin-bottom: 32px;
  margin-top: -8px;
}

.week-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.week-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.week-hint {
  font-size: 12px;
  color: var(--hint);
  font-weight: 500;
}

.week-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 20px 8px;
  margin: 0 -20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.week-strip::-webkit-scrollbar {
  display: none;
}

.week-day {
  flex-shrink: 0;
  min-width: 68px;
  padding: 12px 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  user-select: none;
}

.week-day:active {
  transform: scale(0.94);
  border-color: #667eea;
}

.week-day.today {
  background: var(--gradient);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.week-day.today .week-name,
.week-day.today .week-num,
.week-day.today .week-load {
  color: #ffffff;
}

.week-day.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.week-day.full {
  opacity: 0.5;
}

.week-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--hint);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.week-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 6px;
}

.week-load {
  font-size: 10px;
  font-weight: 600;
  color: var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.week-day .day-bar {
  height: 3px;
  background: rgba(128, 128, 128, 0.15);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.week-day .day-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ============ ТОСТ ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 120%);
  background: var(--text);
  color: var(--bg);
  padding: 14px 24px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}