/* Dental Shifts Mini App — design v2 («современно»: глубина, воздух, motion).
   Темизация через переменные Telegram (светлая/тёмная — автоматически).
   Все селекторы v1 сохранены — app.js/index.html не требуют правок. */

:root {
  --bg: var(--tg-theme-bg-color, #f4f6fb);
  --bg-2: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #16212f);
  --muted: var(--tg-theme-hint-color, #74808f);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);

  --accent: var(--button);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
  --hairline: color-mix(in srgb, var(--muted) 18%, transparent);

  --ok: #22c07a;
  --warn: #f0a131;
  --off: #9aa5b1;
  --danger: #ef5350;

  --radius: 16px;
  --radius-lg: 22px;

  /* слоистые тени — карточка «приподнята», а не «обведена» */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 1px rgba(16, 24, 40, 0.04);
  --shadow-2: 0 2px 4px rgba(16, 24, 40, 0.06), 0 12px 28px -16px rgba(16, 24, 40, 0.28);
  --shadow-pop: 0 8px 16px -6px color-mix(in srgb, var(--accent) 45%, transparent);

  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.2);

  /* fullscreen-режим (Bot API 8.0): системный + контентный отступы */
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: var(--tg-safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: var(--safe-top);
}

/* ---------- top bar: sticky + blur ---------- */
.topbar {
  position: sticky;
  top: var(--safe-top);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 16%, var(--bg-2));
  color: var(--warn);
}

.content {
  flex: 1;
  padding: 0 14px calc(92px + var(--safe-bottom));
}

.screen { display: none; }
.screen.active { display: block; animation: fadeUp 0.28s ease both; }

/* ---------- фильтры: пилюли с откликом ---------- */
.filters { margin-bottom: 12px; }

.chip-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 2px 6px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--hairline);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform 0.16s var(--spring), background 0.18s ease,
    color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.chip:active { transform: scale(0.94); }
.chip.active {
  background: var(--accent);
  color: var(--button-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-pop);
}

.district-input {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--hairline);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  outline: none;
  box-shadow: var(--shadow-1);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.district-input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.district-input::placeholder { color: var(--muted); }

/* ---------- карточки ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}

.shift-card {
  cursor: pointer;
  animation: fadeUp 0.3s ease both;
  transition: transform 0.16s var(--spring), box-shadow 0.2s ease;
}
.shift-card:active { transform: scale(0.98); }

/* лёгкий стаггер появления первых карточек */
.list .shift-card:nth-child(1) { animation-delay: 0.02s; }
.list .shift-card:nth-child(2) { animation-delay: 0.06s; }
.list .shift-card:nth-child(3) { animation-delay: 0.10s; }
.list .shift-card:nth-child(4) { animation-delay: 0.14s; }
.list .shift-card:nth-child(5) { animation-delay: 0.18s; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 3px 0;
}

.rate {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}
.rate-big {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.6px;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}
.per-hour { font-size: 12px; font-weight: 500; letter-spacing: 0; }
.muted { color: var(--muted); font-size: 13px; }
.clinic { font-size: 13px; font-weight: 600; }
.verified { color: var(--ok); font-size: 13px; }
.comment { white-space: pre-wrap; }
.urgent { color: var(--danger); }

/* бейджи: тинт вместо плашки — спокойнее и читаемее в обеих темах */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.badge-ok   { background: color-mix(in srgb, var(--ok) 15%, var(--bg-2));   color: var(--ok); }
.badge-wait { background: color-mix(in srgb, var(--warn) 16%, var(--bg-2)); color: var(--warn); }
.badge-off  { background: color-mix(in srgb, var(--off) 16%, var(--bg-2));  color: var(--off); }

/* ---------- кнопки ---------- */
button { font: inherit; }

.primary {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 92%, #ffffff),
    var(--accent)
  );
  color: var(--button-text);
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  transition: transform 0.16s var(--spring), filter 0.18s ease, box-shadow 0.2s ease;
}
.primary:active { transform: scale(0.97); filter: brightness(0.96); }

.ghost {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--link);
  border: 1px solid color-mix(in srgb, var(--link) 30%, transparent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s var(--spring), background 0.18s ease;
}
.ghost:active { transform: scale(0.96); }
.ghost.danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}

.wide { width: 100%; margin-top: 8px; }
.more { width: 100%; margin-top: 12px; }

/* ---------- состояния ---------- */
.loader, .empty {
  text-align: center;
  color: var(--muted);
  padding: 26px 0;
}
.empty-illustration { margin: 10px auto 4px; opacity: 0.9; }
.empty p { margin: 6px 0; }

/* onboarding (первый запуск) */
.onboard {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 14%, var(--bg-2)),
    var(--bg-2) 65%
  );
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin: 0 0 12px;
  text-align: center;
  box-shadow: var(--shadow-1);
  animation: fadeUp 0.3s ease both;
}
.onboard p { margin: 4px 0; }
.onboard .primary { margin-top: 12px; }

/* скелетоны */
.skeleton { pointer-events: none; }
.sk-line {
  height: 13px;
  border-radius: 7px;
  margin: 8px 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--muted) 13%, transparent) 25%,
    color-mix(in srgb, var(--muted) 24%, transparent) 50%,
    color-mix(in srgb, var(--muted) 13%, transparent) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.sk-w40 { width: 40%; height: 17px; }
.sk-w70 { width: 70%; }
.sk-w55 { width: 55%; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheetUp {
  from { transform: translateY(28px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- профиль ---------- */
.profile-card h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.tier {
  display: inline-block;
  margin: 0 0 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: color-mix(in srgb, var(--accent) 13%, var(--bg-2));
  color: var(--accent);
  font-weight: 700;
}
.stats { display: flex; gap: 10px; margin: 12px 0; }
.stat {
  flex: 1;
  text-align: center;
  background: color-mix(in srgb, var(--muted) 8%, var(--bg-2));
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 12px 4px;
}
.stat strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}
.stat span { font-size: 11px; color: var(--muted); }

/* ---------- задания и рефералка ---------- */
.task {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
}
.task:last-child { border-bottom: none; }
.task-done { opacity: 0.6; }
.task-mark { flex: 0 0 auto; }
.task-body { display: flex; flex-direction: column; gap: 2px; }
.task-title { font-size: 14px; font-weight: 600; }
.task-reward { font-size: 12px; }

.ref-row { margin: 8px 0; }
.ref-link {
  display: block;
  font-size: 12px;
  word-break: break-all;
  background: color-mix(in srgb, var(--muted) 9%, var(--bg-2));
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 9px 11px;
}

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 24, 0.5);
  z-index: 30;
  animation: fadeIn 0.2s ease both;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  background: var(--bg-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 18px calc(20px + var(--safe-bottom));
  max-height: 78vh;
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(16, 24, 40, 0.22);
  animation: sheetUp 0.28s var(--spring) both;
}

.sheet-grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.4;
  margin: 6px auto 12px;
}

.sheet h2 { margin: 4px 0 2px; font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }

/* ---------- tab bar: плавающий док ---------- */
.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + var(--safe-bottom));
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: color-mix(in srgb, var(--bg-2) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
}

.tabbar .tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 4px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.16s var(--spring);
}
.tabbar .tab:active { transform: scale(0.95); }
.tabbar .tab.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: color-mix(in srgb, #101820 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  max-width: 86vw;
  text-align: center;
  box-shadow: var(--shadow-2);
  animation: fadeUp 0.22s ease both;
}

@media (max-width: 360px) {
  .topbar h1 { font-size: 21px; }
}

/* ---------- consent (оферта + ПДн) ---------- */
.consent-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 16, 24, 0.5);
  animation: fadeIn 0.2s ease both;
}
.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  background: var(--bg-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 18px 18px calc(20px + var(--safe-bottom));
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 -12px 40px rgba(16, 24, 40, 0.22);
  animation: sheetUp 0.28s var(--spring) both;
}
.consent[hidden],
.consent-backdrop[hidden] { display: none !important; }
.consent h3 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.consent-hint { margin: 0; color: var(--muted); font-size: 14px; }
.consent-docs {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 80px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--muted) 6%, var(--bg-2));
  border-radius: 12px;
  padding: 12px;
}

/* ---------- контакты и подсказки ---------- */
.clinic-hint { text-align: center; font-size: 12px; margin-top: 12px; }
.contact-link { color: var(--link); text-decoration: none; font-weight: 700; }

/* ---------- доступность: без motion по запросу системы ---------- */
@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
  .screen.active,
  .shift-card,
  .onboard,
  .sheet,
  .consent,
  .sheet-backdrop,
  .consent-backdrop,
  .toast { animation: none; }
  .chip, .primary, .ghost, .tabbar .tab, .shift-card { transition: none; }
}

/* ---------- кабинет клиники (этап 1.6) ---------- */
.create-cta { margin: 2px 0 12px; }

.create-sheet { max-height: 88vh; }

.field { display: block; margin: 10px 0; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field input {
  width: 100%;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--muted) 6%, var(--bg-2));
  color: var(--text);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 16px; /* 16px = без авто-зума iOS */
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.field input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-error { display: block; color: var(--danger); font-size: 12px; font-style: normal; margin-top: 4px; min-height: 0; }
.field-error:empty { display: none; }
.field.has-error input { border-color: var(--danger); }

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  font-size: 14px;
  font-weight: 600;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.form-hint { text-align: center; margin: 10px 0 0; }

/* кандидаты */
.candidate {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}
.candidate:last-child { border-bottom: none; }
.avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--button-text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent));
}
.candidate-body { flex: 1; min-width: 0; }
.candidate-name { font-weight: 700; font-size: 15px; }
.candidate-meta { font-size: 12px; color: var(--muted); }
.candidate-actions { display: flex; gap: 6px; }
.icon-btn {
  border: none;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.16s var(--spring);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.yes { background: color-mix(in srgb, var(--ok) 16%, var(--bg-2)); }
.icon-btn.no  { background: color-mix(in srgb, var(--danger) 12%, var(--bg-2)); }

.manage-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }

/* ---------- онбординг роли и анкеты (этап 1.7) ---------- */
.role-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px;
  margin: 6px 0;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform 0.16s var(--spring), border-color 0.18s ease;
}
.role-card:active { transform: scale(0.97); border-color: var(--accent); }
.role-emoji { font-size: 30px; }
.role-body { display: flex; flex-direction: column; gap: 2px; }
.role-body strong { font-size: 16px; }
.role-body small { color: var(--muted); font-size: 13px; }

.field select {
  width: 100%;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--muted) 6%, var(--bg-2));
  color: var(--text);
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 16px;
  outline: none;
  appearance: none;
}
.chip-row.wrap { flex-wrap: wrap; overflow: visible; }
