/* ══ RESET & BASE ══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-deep:   #2A5F8F;
  --blue-mid:    #5B9EC9;
  --blue-light:  #A8D4EE;
  --blue-pale:   #E8F4FB;
  --brown-dark:  #5C3D2E;
  --brown-mid:   #7B5E52;
  --brown-light: #C9A97A;
  --brown-pale:  #F5EDE4;
  --white:       #FFFFFF;
  --text-dark:   #1A2E3B;
  --text-mid:    #4A6275;
  --text-light:  #8AABBC;
  --error:       #C0392B;
  --success:     #27AE60;
  --radius:      14px;
  --shadow:      0 8px 32px rgba(42,95,143,0.13);
  --shadow-lg:   0 16px 48px rgba(42,95,143,0.18);
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-dark);
  background: var(--blue-pale);
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

/* ══ PAGES ══ */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ══ LOGIN PAGE ══ */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(155deg, var(--blue-pale) 0%, #D6EAF8 50%, var(--brown-pale) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91,158,201,0.18) 0%, transparent 70%);
  pointer-events: none;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -80px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,169,122,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--white);
  border-radius: 24px;
  padding: 48px 44px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s cubic-bezier(.23,1,.32,1) both;
}

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

/* ══ LOGO ══ */
.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  /* padding-bottom: 28px; */
  border-bottom: 1.5px solid var(--blue-pale);
}

.logo-area.small { margin-bottom: 20px; padding-bottom: 20px; }

.logo-icon svg { display: block; }
.logo-icon.small svg { width: 40px; height: 40px; }

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-main {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--blue-deep);
  letter-spacing: 3px;
}

.logo-accent {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 400;
  color: var(--brown-mid);
  letter-spacing: 3px;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-light);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ══ FORM ══ */
.login-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.login-desc {
  font-size: 14px;
  color: var(--text-mid);
  margin-bottom: 28px;
  line-height: 1.6;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--blue-mid);
  pointer-events: none;
}

.input-prefix {
  position: absolute;
  left: 38px;
  font-size: 15px;
  color: var(--text-dark);
  font-weight: 500;
  pointer-events: none;
  z-index: 1;
}

.input-wrapper input {
  width: 100%;
  padding: 13px 14px 13px 38px;
  border: 1.5px solid var(--blue-light);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text-dark);
  background: var(--blue-pale);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}

.input-wrapper input.with-prefix {
  padding-left: 64px;
}

.input-wrapper input:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(91,158,201,0.15);
  background: var(--white);
}

.input-wrapper input::placeholder { color: var(--text-light); }

/* ══ CAPTCHA ══ */
.captcha-block {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  /* margin-bottom: 18px; */
}

.captcha-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

#captcha-canvas {
  border-radius: 10px;
  border: 1.5px solid var(--blue-light);
  background: var(--white);
  display: block;
}

.captcha-refresh {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--blue-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  transition: color 0.2s, transform 0.2s;
}

.captcha-refresh:hover { color: var(--blue-deep); transform: rotate(180deg); }
.captcha-refresh svg { width: 18px; height: 18px; }

/* ══ CONSENT ══ */
.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 22px;
  user-select: none;
}

.consent-label input[type="checkbox"] { display: none; }

.custom-check {
  width: 20px; height: 20px;
  border: 2px solid var(--blue-light);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
}

.consent-label input:checked ~ .custom-check {
  background: var(--blue-mid);
  border-color: var(--blue-mid);
}

.consent-label input:checked ~ .custom-check::after {
  content: '';
  display: block;
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.consent-text {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.5;
}

.consent-text a {
  color: var(--blue-mid);
  text-decoration: none;
}

.consent-text a:hover { text-decoration: underline; }

/* ══ BUTTONS ══ */
.btn-primary {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--blue-mid) 0%, var(--blue-deep) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 4px 16px rgba(42,95,143,0.25);
  margin-bottom: 10px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(42,95,143,0.35);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-ghost {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--blue-mid);
  border: 1.5px solid var(--blue-light);
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-bottom: 10px;
}

.btn-ghost:hover { background: var(--blue-pale); color: var(--blue-deep); }

/* ══ STEP INDICATOR ══ */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}

.step {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  background: var(--white);
  flex-shrink: 0;
  transition: all 0.3s;
}

.step.active { border-color: var(--blue-mid); color: var(--blue-mid); background: var(--blue-pale); }
.step.done   { border-color: var(--blue-mid); background: var(--blue-mid); color: white; }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--blue-light);
  transition: background 0.3s;
}

.step-line.done { background: var(--blue-mid); }

/* ══ CODE INPUTS ══ */
.code-inputs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 12px 0 20px;
}

.code-digit {
  flex: 1;
  min-width: 0;
  max-width: 52px;
  height: 52px;
  text-align: center;
  border: 2px solid var(--blue-light);
  border-radius: 12px;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-dark);
  background: var(--blue-pale);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  font-family: 'DM Sans', sans-serif;
  /* Убираем стрелки счётчика на мобильных */
  -moz-appearance: textfield;
}

.code-digit::-webkit-outer-spin-button,
.code-digit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.code-digit:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(91,158,201,0.15);
  background: var(--white);
}

/* ══ ERROR / SUCCESS ══ */
.error-msg {
  padding: 11px 14px;
  background: #FDEDEC;
  border: 1px solid #E8B4B1;
  border-radius: 10px;
  color: var(--error);
  font-size: 13px;
  margin-top: 10px;
  line-height: 1.5;
}

/* ══ DASHBOARD HEADER ══ */
.dashboard-header {
  background: linear-gradient(90deg, var(--blue-deep) 0%, #1a3f5f 100%);
  padding: 0 28px;
  /* height: 68px; */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(26,63,95,0.3);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  /* flex-shrink: 0; */
  flex: 1; 
  width: 100%;
}

.header-bs {
  flex: 1;
  width: 100%;
  display: none;
}

.header-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  letter-spacing: 2px;
  color: white;
}

.header-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-basis: 100%;  
  flex-grow: 0;
  flex-shrink: 0;
  overflow: hidden;
  margin: 10px 12px;
  flex-wrap: wrap;
}

.header-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  flex-shrink: 0;
}

.header-chip svg {
  width: 14px; height: 14px;
  opacity: 0.8;
  flex-shrink: 0;
}

.email-chip { overflow: hidden; }
.email-chip span { overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.4);
  color: white;
  padding: 7px 18px;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ══ DASHBOARD MAIN ══ */
.dashboard-main {
  padding: 40px 32px;
  max-width: 1000px;
  margin: 0 auto;
  animation: slideUp 0.4s ease both;
}

.welcome-block {
  position: relative;
  margin-bottom: 36px;
  padding-bottom: 20px;
  overflow: hidden;
}

.wave-deco {
  position: absolute;
  bottom: 0; left: -20px; right: -20px;
  height: 60px;
  opacity: 0.7;
}

.welcome-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 38px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.welcome-title span { color: var(--blue-deep); }

.welcome-sub {
  font-size: 15px;
  color: var(--text-mid);
}

/* ══ STATS CHIPS ══ */
.stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--blue-light);
  border-radius: 22px;
  padding: 8px 16px 8px 12px;
  box-shadow: 0 2px 8px rgba(42,95,143,0.08);
  transition: box-shadow 0.2s, transform 0.2s;
}

/* Чипы с визитами — вертикальные, чтобы вместить даты */
.stat-chip--visits {
  align-items: flex-start;
  flex-wrap: wrap;
  border-radius: 16px;
  padding: 10px 16px 10px 12px;
}

.stat-chip--visits svg {
  margin-top: 2px;
}

.stat-chip--visits .stat-label,
.stat-chip--visits .stat-value {
  flex-shrink: 0;
}

.stat-chip:hover {
  box-shadow: 0 4px 14px rgba(42,95,143,0.14);
  transform: translateY(-1px);
}

.stat-chip svg {
  width: 16px;
  height: 16px;
  color: var(--blue-mid);
  flex-shrink: 0;
}

.stat-chip--bonus { border-color: var(--brown-light); }
.stat-chip--bonus svg { color: var(--brown-mid); }
.stat-chip--bonus .stat-value { color: var(--brown-dark); }

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-deep);
  white-space: nowrap;
}

.stat-dates {
  display: block;
  width: 100%;
  /* Отступ слева = иконка (16px) + gap (8px) */
  padding-left: 24px;
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.6;
  margin-top: 3px;
  white-space: normal;
}

.stat-dates:empty { display: none; }

/* ══ CARDS GRID ══ */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.dashboard-card {
  background: var(--white);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.promo-card::before { background: linear-gradient(90deg, var(--blue-mid), var(--blue-light)); }
.info-card::before  { background: linear-gradient(90deg, var(--brown-mid), var(--brown-light)); }

.dashboard-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.card-icon-wrap { margin-bottom: 18px; }

.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 10px;
}

.card-desc {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.65;
  margin-bottom: 22px;
}

.btn-promo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-deep));
  color: white;
  border: none;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(42,95,143,0.25);
}

.btn-promo svg { width: 18px; height: 18px; }
.btn-promo:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(42,95,143,0.35); }
.btn-promo:active { transform: translateY(0); }
.btn-promo:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.promo-result { margin-top: 14px; }

.promo-success {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: #EAFAF1;
  border: 1px solid #A9DFBF;
  border-radius: 10px;
  color: var(--success);
  font-size: 14px;
  font-weight: 500;
}

.promo-success svg { width: 22px; height: 22px; flex-shrink: 0; }

/* ══ INFO CARD ══ */
.info-list { margin-bottom: 16px; }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--blue-pale);
}

.info-row:last-child { border-bottom: none; }

.info-day { font-size: 14px; color: var(--text-mid); }
.info-time { font-size: 14px; font-weight: 500; color: var(--blue-deep); }
.info-row.holiday .info-time { color: var(--brown-mid); }

.card-note {
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ══ PROMO SENT STATE ══ */
.promo-sent-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 0;
  gap: 14px;
}

.promo-sent-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--success);
}

.promo-sent-desc {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.65;
}

/* ══ LOADING SPINNER ══ */
.btn-primary.loading::after,
.btn-promo.loading::after {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ══ RESPONSIVE ══ */
@media (max-width: 720px) {
  .login-card { padding: 32px 24px; }
  .cards-grid { grid-template-columns: 1fr; }
  .dashboard-main { padding: 24px 16px; }
  .welcome-title { font-size: 28px; }
  /* .header-user-info { display: none; } */
  .dashboard-header { padding: 0 16px; gap: 12px; }
  /* .header-bs { display: none; }
  .header-logo { flex: 1; width: 100%; } */
}

@media (max-width: 350px) {
  .captcha-block { flex-direction: column; align-items: stretch; }
}