* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --primary: #0B5FFF;
  --primary-dark: #0047CC;
  --primary-light: #EBF2FF;
  --accent: #00B956;
  --accent-light: #E6F9EE;
  --text: #1C2B4A;
  --text-muted: #8A96A8;
  --border: #E4E8EE;
  --shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.05);
  --radius: 16px;
  --radius-sm: 10px;
}

html { height: 100%; height: -webkit-fill-available; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* === ЭКРАНЫ === */
.screen {
  display: none;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.screen.active { display: flex; }
#screen-login { display: flex; background: var(--primary); }
#screen-login.hidden { display: none; }

/* === ХЕДЕР === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}
.header > span:first-child { font-size: 17px; font-weight: 700; }
.header-title { font-size: 17px; font-weight: 700; color: #fff; }
.header-back {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; padding: 0; line-height: 1;
}

/* === ЛОГИН === */
.login-container {
  flex: 1; display: flex; flex-direction: column;
}
.login-top {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 32px 32px; color: #fff;
}
.login-logo .logo-icon {
  width: 88px; height: 88px;
  background: rgba(255,255,255,0.18);
  border-radius: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 42px; margin-bottom: 20px;
}
.login-logo h1 { font-size: 28px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.login-logo p { color: rgba(255,255,255,0.7); margin-top: 6px; font-size: 15px; }
.login-bottom {
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 32px 24px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
}
.login-bottom h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; color: var(--text); }

/* === ФОРМЫ === */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input, .form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text); font-size: 16px;
  outline: none; -webkit-appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11,95,255,0.1);
}
.form-group textarea { resize: none; height: 80px; }

/* === КНОПКИ === */
.btn {
  width: 100%; padding: 15px; border: none;
  border-radius: var(--radius-sm); font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform 0.1s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: #E53935; color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* === СКРОЛЛ === */
.scroll-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dashboard-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px 24px; }

/* === БАЛАНС === */
.balance-card {
  background: linear-gradient(135deg, #0B5FFF 0%, #1A73E8 100%);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(11,95,255,0.3);
}
.balance-label { font-size: 13px; color: rgba(255,255,255,0.75); margin-bottom: 6px; font-weight: 500; }
.balance-amount { font-size: 42px; font-weight: 800; color: #fff; letter-spacing: -2px; }
.balance-sub { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 3px; }

/* === КНОПКИ ДЕЙСТВИЙ === */
.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.action-btn {
  background: #FFFFFF !important;
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  border: none;
}
.action-btn:active { transform: scale(0.97); }
.action-btn .icon {
  width: 44px; height: 44px;
  background: var(--primary-light);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
  color: var(--primary);
}
.action-btn .icon svg { width: 22px; height: 22px; }
.action-btn .label { font-size: 13px; font-weight: 600; color: var(--text); }

/* === СЕКЦИЯ === */
.section-title {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.7px;
  margin: 4px 0 10px;
}

/* === СТАТИСТИКА === */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: #FFFFFF !important; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* === НАВИГАЦИЯ === */
.bottom-nav {
  display: flex; background: var(--card);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 6px 4px; cursor: pointer;
  color: var(--text-muted); transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item .nav-label { font-size: 10px; margin-top: 3px; font-weight: 600; }

/* === СПИСКИ === */
.list-container { flex: 1; padding: 12px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.list-item {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 8px; display: flex; align-items: center;
  justify-content: space-between; box-shadow: var(--shadow);
}
.list-item-left { flex: 1; }
.list-item-name { font-weight: 600; font-size: 15px; color: var(--text); }
.list-item-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.list-item-right { text-align: right; }

/* === СТАТУСЫ === */
.status-badge {
  display: inline-block; padding: 4px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 700;
}
.status-waiting { background: #FFF3E0; color: #E65100; }
.status-in_work { background: #E3F2FD; color: #1565C0; }
.status-paid, .status-accrued { background: var(--accent-light); color: #007A3D; }
.status-link_sent { background: var(--bg); color: var(--text-muted); }
.status-applied { background: #F3E5F5; color: #6A1B9A; }

/* === REF === */
.ref-card {
  background: var(--accent-light); border: 1.5px solid rgba(0,185,86,0.25);
  border-radius: var(--radius); padding: 20px; margin: 0 0 12px;
}
.ref-url {
  font-size: 13px; word-break: break-all; color: #007A3D;
  margin-bottom: 12px; font-family: monospace;
  background: rgba(0,185,86,0.08); padding: 10px; border-radius: 6px;
}

/* === ТРАНЗАКЦИИ === */
.tx-amount-plus { color: var(--accent); font-weight: 700; font-size: 15px; }
.tx-amount-minus { color: #E53935; font-weight: 700; font-size: 15px; }

/* === TOAST === */
.toast {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(28,43,74,0.95); color: #fff;
  padding: 12px 20px; border-radius: 24px;
  font-size: 14px; font-weight: 500; z-index: 999;
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: calc(100vw - 48px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* Toast типы */
.toast.success { background: rgba(0,122,61,0.95); }
.toast.error   { background: rgba(197,34,31,0.95); }
.toast.info    { background: rgba(11,95,255,0.95); }

/* === ЛОАДЕР === */
.loading {
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 40px; color: var(--text-muted); gap: 12px;
}
.loading-text { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* Спиннер — три точки */
.spinner {
  display: flex; gap: 6px; align-items: center;
}
.spinner::before, .spinner::after,
.spinner span {
  content: ''; display: block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  animation: bounce 1.2s ease-in-out infinite;
}
.spinner::before { animation-delay: -0.32s; }
.spinner::after { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Скелетон для карточек */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #e8ecf2 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}

/* === ОБУЧЕНИЕ === */
.level-card {
  margin: 12px 16px;
  background: linear-gradient(135deg, #0B5FFF 0%, #1A73E8 100%);
  border-radius: var(--radius); padding: 18px 20px; color: #fff;
  box-shadow: 0 4px 16px rgba(11,95,255,0.3);
}
.level-progress-bg {
  background: rgba(255,255,255,0.2); border-radius: 8px;
  height: 6px; overflow: hidden; margin-top: 12px;
}
.level-progress-fill {
  height: 100%; background: #fff; border-radius: 8px; transition: width 0.5s ease;
}
.module-item {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.module-item:active { transform: scale(0.98); }
.module-icon {
  width: 42px; height: 42px; background: var(--primary-light);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--primary);
}
.module-icon svg { width: 20px; height: 20px; }
.module-item.completed .module-icon { background: var(--accent-light); color: var(--accent); }
.module-info { flex: 1; }
.module-title { font-weight: 600; font-size: 15px; color: var(--text); }
.module-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* === МОДАЛКА === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0);
  z-index: 100; display: flex; align-items: flex-end;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background 0.25s, backdrop-filter 0.25s;
  pointer-events: none;
}
.modal-overlay[style*="flex"] {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: all;
}
.modal-sheet {
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); width: 100%;
  max-height: 92dvh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
.modal-overlay[style*="flex"] .modal-sheet {
  transform: translateY(0);
}
/* Ручка сверху модалки */
.modal-sheet::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: -8px auto 16px;
}
.modal-sheet h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

/* === ТИП ВЫПЛАТЫ === */
.payment-type-btn {
  padding: 10px 6px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg);
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; text-align: center;
}
.payment-type-btn.active {
  background: var(--primary-light); border-color: var(--primary);
  color: var(--primary);
}

/* === ПУСТОЙ ЭКРАН === */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 32px;
  text-align: center; color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.35; }
.empty-state p { font-size: 15px; line-height: 1.5; }

/* === iOS/Android UX улучшения === */

/* Убираем zoom при фокусе на input (iOS) */
@media screen and (max-width: 480px) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* Плавный скролл везде */
* { -webkit-overflow-scrolling: touch; }

/* Активное состояние кнопок на touch */
.btn:active, .action-btn:active, .nav-item:active,
.list-item:active, .module-item:active {
  opacity: 0.75;
  transform: scale(0.98);
}

/* Убираем синюю подсветку везде */
* { -webkit-tap-highlight-color: transparent; }

/* Нижняя навигация — не перекрываем контент */
.tab-content {
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* Textarea — не ресайзить на мобиле */
textarea { resize: none; }

/* Placeholder цвет */
::placeholder { color: var(--text-muted); opacity: 0.6; }

/* Поле ввода — больше padding на мобиле */
@media (max-width: 480px) {
  .form-group input, .form-group textarea {
    padding: 15px 16px;
    min-height: 52px;
  }
  .btn { min-height: 52px; }
  .nav-item { min-height: 52px; }
}

/* Безопасная зона снизу для всех скролл-контейнеров */
.list-container, .dashboard-content, .scroll-content {
  padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
}

/* Анимация модальных окон */
.modal-overlay { transition: opacity 0.2s; }
.modal-sheet {
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Индикатор нажатия на карточки списка */
.list-item { cursor: pointer; transition: opacity 0.15s; }
.list-item:active { opacity: 0.8; }

/* Кнопка выплаты — минимальный размер тача */
.payment-type-btn {
  min-height: 44px;
  font-size: 13px;
}
