/* ============================================================
   Секретный Санта — App CSS v2 (pixel-perfect по макету)
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark:  #1a5c4a;
  --green-mid:   #2d7a5f;
  --green-light: #4caf82;
  --green-pale:  #e8f5f0;
  --red:         #e53935;
  --red-light:   #ffebee;
  --gold:        #f9a825;
  --white:       #ffffff;
  --bg:          #f2f6f4;
  --text:        #1a2e25;
  --text-muted:  #6b8c7d;
  --border:      #ddeee6;
  --shadow-sm:   0 2px 8px rgba(26,92,74,.08);
  --shadow-md:   0 4px 20px rgba(26,92,74,.13);
  --shadow-lg:   0 8px 32px rgba(26,92,74,.18);
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --sidebar-w:   200px;
  --transition:  .2s ease;
  --topbar-h:    100px; /* высота topbar с большим аватаром */
}

html, body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ============================================================
   LAYOUT — sidebar + main (2 колонки)
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh; /* iOS: динамический viewport */
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden; /* сам не скроллится */
  z-index: 100;
}

/* Только nav скроллится если пунктов много */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo img { width: 34px; height: 34px; border-radius: 10px; }
.sidebar-logo span { font-size: .92rem; font-weight: 800; color: var(--green-dark); line-height: 1.2; }

/* Пункт меню — точно как на макете */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .88rem;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--green-pale);
  color: var(--green-dark);
}
/* Активный пункт — зелёный фон, белый текст (как на макете) */
.nav-item.active {
  background: var(--green-dark);
  color: #fff;
}
.nav-item.active i { color: #fff; }
.nav-item i { width: 16px; text-align: center; font-size: .9rem; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  padding: 10px 8px 16px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* ============================================================
   TOPBAR — шапка над контентом
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.topbar-greeting { display: flex; align-items: center; gap: 12px; }
.topbar-avatar-placeholder {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--green-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--green-dark); font-weight: 800;
  border: 2px solid var(--green-light);
  flex-shrink: 0;
}
.topbar-avatar {
  width: 84px; height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--green-light);
  flex-shrink: 0;
  background: var(--green-pale);
}
.topbar-name { font-size: 1rem; font-weight: 800; color: var(--text); }
.topbar-sub  { font-size: .78rem; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-bell {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green-pale);
  border: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--green-dark);
  font-size: .95rem;
  transition: var(--transition);
}
.topbar-bell:hover { background: var(--border); }
.topbar-bell-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--red); border-radius: 50%;
  border: 2px solid var(--white);
}

/* Скролл-область контента */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 24px;
  height: 0; /* flex: 1 растянет до нужной высоты */
}
/* Режим полной высоты — контент сам управляет overflow */
.content-scroll--full {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 272px;
  gap: 20px;
  /* Занимает всю высоту content-scroll минус padding */
  height: calc(100% - 0px);
  align-items: stretch;
}

/* Основная колонка — flex, дети занимают пропорции */
.dashboard-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

/* Hero — 2/3 высоты основной колонки */
.dash-hero-wrap {
  flex: 2;
  min-height: 0;
}

/* Прогресс-бар — фиксированная высота */
.dash-progress-card {
  flex-shrink: 0;
  padding: 14px 16px;
}

/* Истории — 1/3 высоты */
.dash-stories-wrap {
  flex: 1;
  min-height: 0;
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dash-stories-wrap .stories-header {
  flex-shrink: 0;
  margin-bottom: 10px;
}
.dash-stories-wrap .stories-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  align-items: flex-start;
}
.dash-stories-wrap .stories-scroll::-webkit-scrollbar { display: none; }
.dash-stories-wrap .story-card {
  flex-shrink: 0;
  width: 120px;
}
.dash-stories-wrap .story-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.stories-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .82rem;
}

/* Мобильная правая панель — скрыта на десктопе */
.right-panel-mobile { display: none; }

/* ============================================================
   ПРАВАЯ КОЛОНКА — высота от родителя (dashboard-grid)
   ============================================================ */
.dashboard-aside {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dashboard-aside .rp-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}
/* AI — половина высоты */
.dashboard-aside .rp-ai {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
/* Достижения — вторая половина */
.dashboard-aside .rp-achievements {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Мобильная правая панель */
.right-panel-mobile .rp-layout { display: flex; flex-direction: column; gap: 14px; width: 100%; min-width: 0; }
.right-panel-mobile .rp-ai     { flex: none; width: 100%; min-width: 0; }
.right-panel-mobile .rp-bottom { display: flex; flex-direction: column; gap: 14px; }

/* ============================================================
   HERO CARD — фон banner.png, текст поверх
   ============================================================ */
.exchange-hero {
  border-radius: var(--radius-lg);
  padding: 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: #1a5c4a;
  background-image: url('/images/banner.png');
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
}
.exchange-hero-content {
  position: relative;
  z-index: 1;
  max-width: 60%;
}
.exchange-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: .03em;
}
.exchange-hero-badge.active {
  background: rgba(76,175,130,.4);
  border-color: rgba(76,175,130,.6);
}
.exchange-hero h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 5px; }
.exchange-hero p  { font-size: .83rem; opacity: .9; margin-bottom: 14px; line-height: 1.5; }
.btn-hero {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  color: var(--green-dark);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 800;
  font-size: .85rem;
  transition: var(--transition);
  text-decoration: none;
  cursor: pointer;
}
.btn-hero:hover { background: var(--green-pale); }

/* ============================================================
   PROGRESS STEPS
   ============================================================ */
.progress-steps {
  display: flex;
  align-items: flex-start;
  position: relative;
}
.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  z-index: 1;
}
.progress-step-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  color: #aaa;
  border: 2px solid #e0e0e0;
  transition: var(--transition);
  position: relative; z-index: 2;
}
.progress-step.done .progress-step-icon {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #fff;
}
.progress-step.current .progress-step-icon {
  background: var(--white);
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 0 4px rgba(229,57,53,.12);
}
.progress-step-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  line-height: 1.3;
}
.progress-step.done .progress-step-label,
.progress-step.current .progress-step-label { color: var(--text); }
.progress-step-date { font-size: .62rem; color: var(--text-muted); text-align: center; margin-top: 2px; }
.progress-line {
  flex: 1;
  height: 2px;
  background: #e0e0e0;
  margin-top: 16px;
  position: relative; z-index: 0;
}
.progress-line.done { background: var(--green-dark); }

/* ============================================================
   TIMER BLOCK — слева от историй
   ============================================================ */
.timer-block {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timer-block-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.4;
}
.timer-block-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--red);
  letter-spacing: .01em;
  line-height: 1;
}
.timer-block-img {
  width: 100%;
  max-width: 130px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

/* ============================================================
   STORIES — горизонтальный скролл
   ============================================================ */
.stories-section { min-width: 0; }
.stories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.stories-header h3 { font-size: .95rem; font-weight: 800; }
.stories-header a  { font-size: .78rem; color: var(--green-mid); font-weight: 700; }
.stories-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.stories-scroll::-webkit-scrollbar { display: none; }
.story-card {
  flex-shrink: 0;
  width: 130px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.story-card img { width: 100%; height: 90px; object-fit: cover; }
.story-card-body { padding: 7px 9px 9px; }
.story-card-name { font-size: .75rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.story-card-caption { font-size: .7rem; color: var(--text-muted); line-height: 1.4; }

/* ============================================================
   RIGHT PANEL WIDGETS
   ============================================================ */

/* AI Widget */
.ai-widget {
  background: #c8eadb;
  border: 1px solid #a8d5c0;
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}
.ai-widget-left { display: contents; }
/* ai-widget-body: на десктопе — flex-column (картинка растёт вниз) */
.ai-widget-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
/* Десктоп: ai-widget-row — оставляем для совместимости */
.ai-widget-row {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  width: 100%;
}
.ai-widget-top  { flex-shrink: 0; min-width: 0; }
.ai-title { font-size: 1rem; font-weight: 800; color: var(--green-dark); flex-shrink: 0; }
.ai-sub   { font-size: .92rem; color: var(--text-muted); }
.ai-desc  { font-size: 1rem; font-weight: 700; color: var(--text); line-height: 1.45; }

/* Картинка — занимает свободное место */
.ai-widget-img-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  overflow: hidden;
  width: 100%;
}
.ai-widget-img {
  max-height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: right bottom;
  display: block;
}

.btn-ai {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--green-dark);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .85rem;
  font-weight: 700;
  width: 100%;
  transition: var(--transition);
  cursor: pointer;
}
.btn-ai:hover { background: var(--green-mid); }

/* Мобиль */
@media (max-width: 768px) {
  .ai-widget {
    cursor: pointer;
    gap: 8px;
    -webkit-tap-highlight-color: rgba(0,0,0,.05);
  }
  .ai-widget:active { opacity: .88; }

  /* body: flex-row — текст слева, картинка справа */
  .ai-widget-body {
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 80px;
  }
  .ai-widget-top {
    flex: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .ai-widget-img-wrap {
    flex: 1;
    min-width: 0;
    align-items: center;
    justify-content: center;
    min-height: 80px;
  }
  .ai-widget-img {
    width: 100%;
    height: auto;
    max-height: 100px;
    object-fit: contain;
    object-position: center;
  }
  .ai-btn-desktop { display: none !important; }
}

/* Progress widget */
.widget-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.widget-title {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-pale);
  color: var(--green-dark);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .75rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.xp-bar-wrap {
  background: #f0f0f0;
  border-radius: 6px;
  height: 7px;
  overflow: hidden;
  margin: 6px 0 4px;
}
/* Красный прогресс-бар — как на макете */
.xp-bar {
  height: 100%;
  background: var(--red);
  border-radius: 6px;
  transition: width .6s ease;
}
.xp-labels {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--text-muted);
}

/* Achievements widget */
.achievements-icons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.ach-icon-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--green-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  border: 1px solid var(--border);
  cursor: default;
  transition: var(--transition);
}
.ach-icon-btn:hover { transform: scale(1.08); }
.ach-icon-btn.locked { opacity: .3; filter: grayscale(1); }

.ach-xp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: .78rem;
  color: var(--text-muted);
}
.ach-xp-badge {
  background: var(--green-pale);
  color: var(--green-dark);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: .72rem;
  font-weight: 700;
}

/* ============================================================
   CARDS & COMMON
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  border: 1px solid var(--border);
}
.card-title {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 1.35rem; font-weight: 800; }
.page-header p  { font-size: .85rem; color: var(--text-muted); margin-top: 3px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: .7rem; font-weight: 700;
}
.badge-green  { background: #e8f5e9; color: #2e7d32; }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-yellow { background: #fff8e1; color: #f57f17; }
.badge-blue   { background: #e3f2fd; color: #1565c0; }
.badge-gray   { background: #f5f5f5; color: #757575; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: .85rem; border: none;
  transition: var(--transition); cursor: pointer; text-decoration: none;
}
.btn-primary   { background: var(--green-dark); color: #fff; }
.btn-primary:hover { background: var(--green-mid); }
.btn-secondary { background: var(--green-pale); color: var(--green-dark); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #ffcdd2; }
.btn-sm  { padding: 6px 12px; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .78rem; font-weight: 700;
  color: var(--text-muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.form-control {
  width: 100%; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-family: inherit; font-size: .88rem; color: var(--text);
  background: var(--bg); outline: none; transition: var(--transition);
}
.form-control:focus { border-color: var(--green-mid); background: var(--white); box-shadow: 0 0 0 3px rgba(45,122,95,.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint  { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card { background: var(--white); border-radius: var(--radius-md); padding: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.stat-card-value { font-size: 1.7rem; font-weight: 800; color: var(--green-dark); line-height: 1; }
.stat-card-label { font-size: .75rem; color: var(--text-muted); margin-top: 3px; font-weight: 600; }
.stat-card-icon  { font-size: 1.3rem; margin-bottom: 6px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  text-align: left; padding: 9px 12px;
  font-size: .7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); background: var(--bg);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--green-pale); }

/* Toast */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 340px; animation: toastIn .3s ease;
  border-left: 4px solid var(--green-dark);
}
.toast.error { border-left-color: var(--red); }
.toast-icon  { font-size: 1rem; flex-shrink: 0; }
.toast-text  { font-size: .85rem; font-weight: 600; flex: 1; }
.toast-close { background: none; border: none; color: var(--text-muted); font-size: .85rem; padding: 2px; cursor: pointer; }
@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }

/* Danger zone */
.danger-zone { border: 1px solid #ffcdd2; border-radius: var(--radius-md); padding: 18px; background: #fff8f8; }
.danger-zone h4 { color: var(--red); margin-bottom: 8px; }

/* Utils */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green-dark); }
.text-red   { color: var(--red); }
.fw-bold    { font-weight: 700; }
.mt-1 { margin-top: 6px; }  .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 22px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 22px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.section-title { font-size: .95rem; font-weight: 800; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }

/* ============================================================
   CHAT
   ============================================================ */
.chat-layout { display: flex; height: calc(100vh - 120px); height: calc(100dvh - 120px); background: var(--white); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.chat-list { width: 260px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.chat-list-header { padding: 16px; font-size: .95rem; font-weight: 800; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-list-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: var(--transition); text-decoration: none; color: inherit; min-width: 0; }
.chat-list-item:hover, .chat-list-item.active { background: var(--green-pale); }
.chat-list-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--green-pale); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; border: 2px solid var(--border); }
.chat-list-info { flex: 1; min-width: 0; }
.chat-list-name { font-weight: 700; font-size: .85rem; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.chat-list-preview { font-size: .72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.chat-list-time { font-size: .65rem; color: var(--text-muted); }
.chat-unread { background: var(--green-dark); color: #fff; font-size: .65rem; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.chat-window { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-window-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.chat-window-title { font-weight: 800; font-size: .9rem; }
.chat-window-sub { font-size: .72rem; color: var(--text-muted); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; max-width: 72%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green-pale); display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; align-self: flex-end; }
.msg-bubble { background: var(--green-pale); border-radius: 14px 14px 14px 4px; padding: 9px 12px; font-size: .85rem; line-height: 1.5; color: var(--text); word-break: break-word; }
.msg.mine .msg-bubble { background: var(--green-dark); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg-time { font-size: .62rem; color: var(--text-muted); margin-top: 3px; }
.msg.mine .msg-time { color: rgba(255,255,255,.55); text-align: right; }
.chat-input-area { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }
.chat-input { flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; font-family: inherit; font-size: .85rem; resize: none; outline: none; max-height: 110px; transition: var(--transition); background: var(--bg); }
.chat-input:focus { border-color: var(--green-mid); background: var(--white); }
.chat-send-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--green-dark); color: #fff; border: none; display: flex; align-items: center; justify-content: center; font-size: .9rem; flex-shrink: 0; transition: var(--transition); }
.chat-send-btn:hover { background: var(--green-mid); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); gap: 8px; font-size: .88rem; }
.chat-empty i { font-size: 2.2rem; opacity: .35; }

/* ============================================================
   PAIR CARDS
   ============================================================ */
.pair-card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; }
.pair-card-header { background: linear-gradient(135deg, var(--green-dark), var(--green-mid)); color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 10px; }
.pair-card-header i { font-size: 1.2rem; }
.pair-card-header h3 { font-size: .95rem; font-weight: 800; }
.pair-card-body { padding: 18px; }
.pair-field { margin-bottom: 14px; }
.pair-field:last-child { margin-bottom: 0; }
.pair-field-label { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 4px; }
.pair-field-value { font-size: .88rem; color: var(--text); line-height: 1.5; background: var(--bg); border-radius: var(--radius-sm); padding: 9px 12px; border: 1px solid var(--border); }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%); padding: 20px; }
.auth-card { background: var(--white); border-radius: var(--radius-xl); padding: 32px 28px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; justify-content: center; }
.auth-logo img { width: 40px; height: 40px; border-radius: 10px; }
.auth-logo span { font-size: 1.1rem; font-weight: 800; color: var(--green-dark); }
.auth-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.auth-sub { font-size: .82rem; color: var(--text-muted); margin-bottom: 22px; }

/* Admin overrides */
.admin-form-card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-sm); padding: 22px; max-width: 580px; }
.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   BOTTOM NAV (mobile)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; padding: 6px 0; }
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 10px; color: var(--text-muted); font-size: .62rem; font-weight: 700;
  border-radius: var(--radius-sm); transition: var(--transition); position: relative; text-decoration: none;
}
.bottom-nav-item.active { color: var(--green-dark); }
.bottom-nav-item i { font-size: 1.05rem; }
.bottom-nav-badge {
  position: absolute; top: 1px; right: 4px;
  background: var(--red); color: #fff; font-size: .58rem; font-weight: 700;
  min-width: 15px; height: 15px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* Mobile menu button — не используется */
.mobile-menu-btn { display: none; }

/* Sidebar overlay */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
.sidebar-overlay.active { display: block; }

/* Кастомная модалка подтверждения */
.app-confirm { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9999; align-items: center; justify-content: center; padding: 20px; }
.app-confirm.open { display: flex; }
.app-confirm__box { background: var(--white); border-radius: var(--radius-lg); padding: 22px; max-width: 380px; width: 100%; box-shadow: var(--shadow-lg); }
.app-confirm__text { font-size: .95rem; line-height: 1.5; margin-bottom: 18px; color: var(--text); }
.app-confirm__actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Планшет — убираем правую колонку дашборда */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-aside { display: none; }
  .right-panel-mobile { display: block; }
}

/* Мобильный */
@media (max-width: 768px) {
  /* Sidebar — выезжает слева */
  .sidebar {
    position: fixed;
    left: -100%; top: 0; bottom: 0;
    width: 240px;
    transition: left .28s ease;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }

  /* Убираем sidebar из grid */
  .app-layout { grid-template-columns: 1fr; }

  /* Контент */
  .content-scroll { padding: 12px 14px calc(80px + env(safe-area-inset-bottom, 0px)); }

  /* Topbar */
  .topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; }
  .topbar-avatar { width: 63px; height: 63px; }

  /* Bottom nav */
  .bottom-nav { display: block; }

  /* Mobile menu btn */
  .mobile-menu-btn { display: flex; }

  /* Hero */
  .exchange-hero { background-size: cover; }

  /* Timer+stories — вертикально */
  .timer-stories-row { grid-template-columns: 1fr; }
  .timer-block { flex-direction: row; align-items: center; gap: 14px; }
  .timer-block-img { display: none; }

  /* Progress labels */
  .progress-step-label { font-size: .6rem; }
  .progress-step-date  { font-size: .58rem; }

  /* Chat */
  .chat-layout { height: calc(100vh - 80px); height: calc(100dvh - 80px); border-radius: 0; }
  .chat-list { display: none; }
  .chat-list.show { display: flex; position: fixed; inset: 0; z-index: 300; width: 100%; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .exchange-hero h2 { font-size: 1.05rem; }
  .timer-block-value { font-size: 1.1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   PROFILE PAGE
   ============================================================ */

/* Двухколоночная сетка на десктопе */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* Статус анкеты */
.profile-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.profile-status--ok   { background: #e8f5e9; color: #2e7d32; }
.profile-status--warn { background: #fff8e1; color: #f57f17; }

/* Подсказка внутри карточки */
.profile-hint {
  background: var(--green-pale);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  color: var(--green-dark);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* Строка уведомления */
.notif-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.notif-row:last-of-type { border-bottom: none; }
.notif-row-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.notif-row-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green-pale); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; flex-shrink: 0;
}
.notif-row-title { font-weight: 700; font-size: .88rem; }
.notif-row-sub   { font-size: .75rem; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  width: 42px; height: 24px;
  background: #ccc; border-radius: 12px;
  transition: var(--transition); position: relative;
}
.toggle-switch input:checked + .toggle-track { background: var(--green-dark); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track .toggle-thumb { left: 21px; }

/* Кнопки Telegram */
.btn-unlink-tg {
  background: none; border: none; color: var(--red);
  font-size: .72rem; font-weight: 700; cursor: pointer;
  padding: 0; text-decoration: underline;
}
.btn-link-tg {
  display: inline-flex; align-items: center; gap: 4px;
  background: #e3f2fd; color: #1565c0;
  border-radius: 20px; padding: 2px 10px;
  font-size: .72rem; font-weight: 700; text-decoration: none;
  transition: var(--transition);
}
.btn-link-tg:hover { background: #bbdefb; }

/* Мобильные табы — скрыты на десктопе */
.profile-tabs { display: none; }

/* ============================================================
   PROFILE — мобильная адаптация
   ============================================================ */
@media (max-width: 768px) {
  .profile-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Показываем табы */
  .profile-tabs {
    display: flex;
    gap: 0;
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
  }
  .profile-tab {
    flex: 1;
    padding: 11px 8px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .profile-tab.active {
    background: var(--green-dark);
    color: #fff;
  }

  /* На мобиле все колонки скрыты по умолчанию */
  .profile-col { display: none !important; }
  /* Показываем только активную */
  .profile-col.active { display: block !important; }
}

@media (min-width: 769px) {
  /* На десктопе оба столбца всегда видны */
  .profile-col { display: block !important; }
  .profile-tabs { display: none !important; }
}

/* ============================================================
   SIDEBAR TIMER
   ============================================================ */
.sidebar-timer {
  margin: 0 8px 12px;
  background: var(--green-pale);
  border-radius: var(--radius-md);
  padding: 14px 12px 0;
  text-align: center;
  border: 1px solid var(--border);
}
.sidebar-timer-img {
  width: 100%;
  max-height: 110px;
  object-fit: contain;
  display: block;
  margin-top: 8px;
}
.sidebar-timer-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  line-height: 1.3;
}
.sidebar-timer-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--red);
  letter-spacing: .01em;
  line-height: 1;
}

/* На десктопе скрываем таймер-блок в основном контенте */
.sidebar-timer-hidden { display: none; }

/* На мобиле — показываем в контенте, скрываем в сайдбаре */
@media (max-width: 768px) {
  .sidebar-timer { display: none; }
  .sidebar-timer-hidden { display: flex; }
}

/* ============================================================
/* ============================================================
   HERO — пустое состояние (нет обмена)
   ============================================================ */
.exchange-hero--empty {
  /* Используем тот же banner.png, просто другой оттенок */
  background-color: #2d5a4a;
}

/* ============================================================
   MOBILE — dashboard
   ============================================================ */
@media (max-width: 768px) {
  /* Разрешаем скролл страницы на мобиле */
  html, body { overflow: auto; height: auto; }
  .app-layout { height: auto; overflow: visible; }
  .main-content { height: auto; overflow: visible; }
  .content-scroll { height: auto; overflow: visible; padding: 12px 14px 80px; }

  .dashboard-grid {
    height: auto;
    grid-template-columns: 1fr;
  }
  .dashboard-main { gap: 12px; overflow: visible; }
  .dash-hero-wrap { flex: none; min-height: 150px; }
  .dash-stories-wrap { flex: none; min-height: 160px; }
  .exchange-hero { height: auto; min-height: 150px; background-size: cover; }
  .exchange-hero-content { max-width: 75%; }
  .exchange-hero h2 { font-size: 1.05rem; }
  .dash-stories-wrap .story-card     { width: 95px; }
  .dash-stories-wrap .story-card img { height: 65px; }
  .dashboard-aside { position: static; height: auto; }
}

/* ============================================================
   RIGHT PANEL — достижения (без прогресса)
   ============================================================ */
.rp-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}
.rp-ai          { flex: 1; min-height: 0; }
.rp-achievements { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* Сетка мини-иконок: 3 колонки × 4 ряда = 12 */
.rp-ach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
/* Ячейка — flex-контейнер, центрирует круг */
.rp-ach-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
/* Круг вписывается в меньшую сторону ячейки */
.rp-ach-item-inner {
  /* aspect-ratio + max-height: круг не выходит за высоту ряда */
  aspect-ratio: 1 / 1;
  height: 100%;
  max-width: 100%;
  border-radius: 50%;
  background: var(--green-pale);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: var(--transition);
}
.rp-ach-item:hover .rp-ach-item-inner { transform: scale(1.06); }
.rp-ach-item--locked .rp-ach-item-inner { opacity: .3; filter: grayscale(1); }
.rp-ach-img  { width: 100%; height: 100%; object-fit: cover; }
.rp-ach-emoji { font-size: clamp(.6rem, 1.4vw, 1.1rem); line-height: 1; }

/* ============================================================
   СТРАНИЦА ДОСТИЖЕНИЙ — 2 ряда × 5, вертикальные карточки
   ============================================================ */
.ach-page-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.ach-page-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.ach-page-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  min-height: 0;
}
.ach-page-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.ach-page-card--locked { opacity: .5; }

/* Блок изображения — 70% высоты карточки */
.ach-page-img-wrap {
  position: relative;
  width: 100%;
  flex: 7;
  min-height: 0;
  background: var(--green-pale);
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden;
}
/* Изображение по высоте блока, ширина авто — персонаж во весь рост */
.ach-page-img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
}
.ach-page-emoji { font-size: 2.5rem; line-height: 1; margin-bottom: 8px; }
.ach-page-lock {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.3rem;
}

/* Текст — 30% высоты карточки */
.ach-page-info {
  flex: 3;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
.ach-page-name {
  font-weight: 800;
  font-size: .78rem;
  margin-bottom: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ach-page-desc {
  font-size: .66rem;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ach-page-date {
  font-size: .63rem;
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Мобиль */
@media (max-width: 768px) {
  /* Правая панель */
  .rp-ach-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
  }
  .rp-ach-emoji { font-size: 1rem; }

  /* Достижения — 2 колонки, обычный скролл */
  .ach-page-wrap { height: auto; overflow: visible; }
  .ach-page-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: none;
    gap: 10px;
    flex: none;
    overflow: visible;
  }
  .ach-page-img-wrap {
    flex: none;
    aspect-ratio: 2/3;
    height: auto;
  }
  .ach-page-img { height: 100%; width: auto; max-width: 100%; }
  .ach-page-info { flex: none; }
  .ach-page-name { font-size: .8rem; white-space: normal; }
  .ach-page-desc { font-size: .7rem; }
}

/* ============================================================
   MOBILE — порядок блоков на главной
   hero(1) → прогресс(2) → таймер(3) → AI(4) → истории(5) → достижения(6)
   ============================================================ */
@media (max-width: 768px) {
  .dashboard-main { display: flex; flex-direction: column; }

  .dash-hero-wrap      { order: 1; }
  .dash-progress-card  { order: 2; }
  .dash-order-timer    { order: 3; }
  .dash-order-ai       { order: 4; }
  .dash-order-stories  { order: 5; }
  /* достижения внутри right-panel-mobile идут последними автоматически */
}

/* ============================================================
   AI MODAL
   ============================================================ */
.ai-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* Блокируем скролл фона на iOS */
  overscroll-behavior: contain;
  touch-action: none;
}
.ai-modal-overlay.open { display: flex; }

.ai-modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.ai-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-modal-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1rem;
}
.ai-modal-help {
  background: none; border: none;
  color: var(--text-muted); font-size: 1rem; cursor: pointer;
  padding: 2px; transition: var(--transition);
}
.ai-modal-help:hover { color: var(--green-dark); }
.ai-modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 1.1rem; cursor: pointer;
  padding: 4px; transition: var(--transition);
}
.ai-modal-close:hover { color: var(--red); }

.ai-help-card {
  background: var(--green-pale);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .85rem;
  line-height: 1.6;
  margin: 0 20px;
}
.ai-help-card ol { padding-left: 18px; margin-top: 6px; }
.ai-help-card li { margin-bottom: 4px; }

.ai-modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-tab {
  flex: 1; padding: 10px; background: none; border: none;
  font-family: inherit; font-size: .88rem; font-weight: 700;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
  border-bottom: 2px solid transparent;
}
.ai-tab.active { color: var(--green-dark); border-bottom-color: var(--green-dark); }

/* Таб генерации — flex-column: чат растёт, форма внизу */
#aiTabGenerate {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Диалог сообщений */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overscroll-behavior: contain;
}
.ai-chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
  padding: 20px 0;
  flex: 1;
}
.ai-chat-welcome-icon { font-size: 2.5rem; }

/* Сообщение пользователя */
.ai-msg-user {
  align-self: flex-end;
  background: var(--green-dark);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 9px 13px;
  max-width: 80%;
  font-size: .85rem;
  line-height: 1.5;
  word-break: break-word;
}
/* Сообщение AI */
.ai-msg-bot {
  align-self: flex-start;
  background: var(--green-pale);
  color: var(--text);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 13px;
  max-width: 90%;
  font-size: .85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg-bot.error {
  background: var(--red-light);
  color: var(--red);
}
/* Анимация печатания */
.ai-msg-typing {
  display: flex; gap: 4px; align-items: center; padding: 12px 14px;
}
.ai-msg-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  animation: typing .9s infinite;
}
.ai-msg-typing span:nth-child(2) { animation-delay: .2s; }
.ai-msg-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* Форма внизу */
.ai-modal-form {
  flex-shrink: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

.ai-tab-content { flex: 1; overflow-y: auto; min-height: 0; }

/* Счётчик попыток */
.ai-attempts-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: .78rem;
}
.ai-attempts-label { color: var(--text-muted); font-weight: 600; }
.ai-attempts-dots  { display: flex; gap: 5px; }
.ai-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border);
}
.ai-dot.used  { background: var(--red); }
.ai-dot.avail { background: var(--green-light); }
.ai-attempts-count { margin-left: auto; font-weight: 700; color: var(--text); }

/* Кнопка вставки пожеланий */
.ai-insert-wishes {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 5px;
  background: var(--green-pale); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 10px;
  font-size: .75rem; font-weight: 700; color: var(--green-dark);
  cursor: pointer; transition: var(--transition);
}
.ai-insert-wishes:hover { background: var(--border); }
.ai-insert-wishes:disabled { opacity: .4; cursor: default; }

/* Бюджет */
.ai-budget-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ai-budget-option {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: .78rem; font-weight: 600;
  transition: var(--transition);
}
.ai-budget-option:has(input:checked) {
  background: var(--green-pale); border-color: var(--green-mid); color: var(--green-dark);
}
.ai-budget-option input[type=radio] { display: none; }
.ai-budget-custom input[type=number] {
  width: 55px; border: none; background: none;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  outline: none; color: var(--text);
}

/* История */
.ai-history-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.ai-history-item:last-child { border-bottom: none; }
.ai-history-meta {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-muted); margin-bottom: 6px;
}
.ai-history-prompt {
  font-size: .82rem; font-weight: 700; margin-bottom: 6px; color: var(--text);
}
.ai-history-response {
  font-size: .8rem; color: var(--text-muted);
  white-space: pre-wrap; line-height: 1.5;
  max-height: 120px; overflow: hidden;
}
.ai-history-response.expanded { max-height: none; }
.ai-history-expand {
  font-size: .75rem; color: var(--green-mid); font-weight: 700;
  cursor: pointer; background: none; border: none; padding: 4px 0;
}

/* Мобиль */
@media (max-width: 768px) {
  .ai-modal-overlay { padding: 0; align-items: flex-end; }
  .ai-modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
  }
}

/* ============================================================
   AUTH PAGES — login / register
   ============================================================ */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  padding: 20px;
  /* Новогодний паттерн */
  background-image:
    linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex; align-items: center; gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
}
.auth-logo img { width: 40px; height: 40px; border-radius: 10px; }
.auth-logo span { font-size: 1.1rem; font-weight: 800; color: var(--green-dark); }

.auth-title { font-size: 1.3rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.auth-sub   { font-size: .85rem; color: var(--text-muted); text-align: center; margin-bottom: 22px; }

/* Алерты */
.auth-alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600;
  margin-bottom: 16px;
}
.auth-alert--error   { background: var(--red-light); color: var(--red); }
.auth-alert--success { background: #e8f5e9; color: #2e7d32; }

/* Поле ввода с иконкой */
.auth-input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.auth-input-icon {
  position: absolute; left: 12px;
  color: var(--text-muted); font-size: .9rem;
  pointer-events: none;
}
.auth-input {
  padding-left: 36px !important;
  padding-right: 40px !important;
}
.auth-eye {
  position: absolute; right: 10px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: .9rem; padding: 4px;
  transition: var(--transition);
}
.auth-eye:hover { color: var(--green-dark); }

/* Чекбокс согласия */
.auth-privacy { margin-bottom: 18px; }
.auth-checkbox-label {
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; font-size: .85rem; line-height: 1.5;
  color: var(--text);
}
.auth-checkbox-label input[type=checkbox] { display: none; }
.auth-checkbox-box {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  border: 2px solid var(--border); border-radius: 4px;
  background: var(--bg); transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.auth-checkbox-label input:checked + .auth-checkbox-box {
  background: var(--green-dark); border-color: var(--green-dark);
}
.auth-checkbox-label input:checked + .auth-checkbox-box::after {
  content: '✓'; color: #fff; font-size: .75rem; font-weight: 800;
}
.auth-link-btn {
  background: none; border: none; padding: 0;
  color: var(--green-mid); font-weight: 700; font-size: .85rem;
  cursor: pointer; text-decoration: underline; font-family: inherit;
}

/* Ссылки внизу */
.auth-links {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 18px;
  font-size: .85rem; color: var(--text-muted);
}
.auth-links a { color: var(--green-mid); font-weight: 700; }
.auth-links-sep { color: var(--border); }
.auth-back {
  display: block; text-align: center; margin-top: 14px;
  font-size: .8rem; color: var(--text-muted);
  text-decoration: none; transition: var(--transition);
}
.auth-back:hover { color: var(--green-dark); }

/* Модалка политики */
.privacy-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 2000;
  align-items: center; justify-content: center; padding: 16px;
}
.privacy-overlay.open { display: flex; }
.privacy-modal {
  background: var(--white); border-radius: var(--radius-xl);
  width: 100%; max-width: 600px; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.privacy-modal-head {
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  color: #fff; padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; font-size: .95rem; flex-shrink: 0;
}
.privacy-close {
  background: rgba(255,255,255,.2); border: none; border-radius: 50%;
  width: 32px; height: 32px; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; transition: var(--transition);
}
.privacy-close:hover { background: rgba(255,255,255,.35); }
.privacy-modal-body {
  padding: 22px 24px; overflow-y: auto; flex: 1;
  font-size: .88rem; line-height: 1.65; color: var(--text);
}
.privacy-modal-body h3 {
  font-size: .95rem; font-weight: 800; color: var(--green-dark);
  margin: 18px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.privacy-modal-body h3:first-child { margin-top: 0; }
.privacy-modal-body ul { padding-left: 0; list-style: none; }
.privacy-modal-body li {
  padding-left: 20px; position: relative;
  margin-bottom: 5px; color: var(--text-muted);
}
.privacy-modal-body li::before {
  content: '✓'; position: absolute; left: 0;
  color: var(--green-mid); font-weight: 800;
}
.privacy-modal-foot {
  padding: 16px 24px; border-top: 1px solid var(--border);
  text-align: center; flex-shrink: 0;
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px 22px; }
  .privacy-overlay { padding: 0; align-items: flex-end; }
  .privacy-modal { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 92vh; }
}

/* Инфо-блок на auth страницах */
.auth-info {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--green-pale);
  border-left: 3px solid var(--green-mid);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  color: var(--green-dark);
  line-height: 1.5;
  margin-bottom: 18px;
}
