/* ==========================================================================
   NichaHub — Main Stylesheet
   Dark-themed marketplace for YouTube niches
   ========================================================================== */

/* SR-only: visually hidden but accessible to screen readers & crawlers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   1. CSS Reset + Custom Properties
   ========================================================================== */

:root {
  /* Colors — Background */
  --bg:             #0a0a0f;
  --bg-card:        #12121a;
  --bg-card-hover:  #1a1a25;
  --bg-surface:     #16161f;

  /* Colors — Border */
  --border:         #1e1e2e;
  --border-hover:   #2a2a3e;

  /* Colors — Text */
  --text:           #e4e4e7;
  --text-muted:     #71717a;
  --text-dim:       #52525b;

  /* Colors — Accent */
  --accent:         #6366f1;
  --accent-hover:   #818cf8;
  --accent-glow:    rgba(99, 102, 241, 0.15);

  /* Colors — Semantic */
  --green:          #22c55e;
  --orange:         #f59e0b;
  --red:            #ef4444;
  --cyan:           #06b6d4;

  /* Radius */
  --radius-lg:      12px;
  --radius-sm:      8px;

  /* Font */
  --font:           'Inter', system-ui, -apple-system, sans-serif;

  /* Shadows */
  --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:      0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:      0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow:    0 0 20px var(--accent-glow);

  /* Transitions */
  --transition:     0.2s ease;
  --transition-slow: 0.35s ease;

  /* Layout */
  --nav-height:     56px;
  --sidebar-width:  260px;
  --container-max:  1280px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-y: scroll;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--accent);
  color: #fff;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}


/* ==========================================================================
   2. Navigation Bar
   ========================================================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-height);
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(99,102,241,0.12), 0 4px 16px rgba(99,102,241,0.04);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Logo — used in HTML as .logo + .logo-icon */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  font-family: 'Syne', sans-serif;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* User info in nav */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.user-name {
  display: none; /* имя видно в кабинете, в навбаре только занимает место */
}

.nav-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}

.nav-mobile-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Dev auth buttons */
.dev-auth-buttons {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
}

/* ==========================================================================
   2b. Page Layout helpers (used across all pages)
   ========================================================================== */

.page-content {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 24px;
  padding-top: calc(var(--nav-height) + 32px);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}


/* ==========================================================================
   3. Hero Section
   ========================================================================== */


.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 120px 24px 80px;
  overflow: hidden;
  gap: 24px;
  max-width: 720px;
  margin: 0 auto;
}

.hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

/* Hero h1 (no class on element) */
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-hover);
  margin-bottom: 24px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  max-width: 720px;
  margin-bottom: 16px;
}

.hero-title .highlight,
.text-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle,
.hero-desc {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 560px;
  margin-bottom: 32px;
}

.hero-stats {
  display: flex;
  gap: 40px;
  margin-top: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  margin-bottom: 40px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.hero-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Why NichaHub ── */
.why-section {
  max-width: 900px;
  margin: 0 auto 64px;
  padding: 0 24px;
}
.why-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.why-card {
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.07) 0%, var(--bg-card) 60%);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(108, 99, 255, 0.35);
  border-radius: 16px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.why-card:hover {
  border-color: rgba(108, 99, 255, 0.5);
  border-top-color: rgba(108, 99, 255, 0.7);
  box-shadow: 0 8px 32px rgba(108, 99, 255, 0.12);
  transform: translateY(-2px);
}
.why-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(108, 99, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.why-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.why-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}
@media (max-width: 640px) {
  .why-cards { grid-template-columns: 1fr; }
}

.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}


/* ==========================================================================
   4. Catalog Layout
   ========================================================================== */

.catalog-page {
  padding-top: calc(var(--nav-height) + 16px);
}

.catalog-page .section-title {
  margin-bottom: 16px;
}

.catalog-layout {
  display: flex;
  gap: 24px;
}

.sidebar {
  flex-shrink: 0;
  align-self: flex-start;
  width: var(--sidebar-width);
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  max-height: calc(100vh - var(--nav-height) - 48px);
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.filter-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.catalog-content {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - var(--nav-height) - 80px);
}

/* Type tabs (Все / Скрытые / Открытые) */
.catalog-type-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.catalog-type-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.catalog-type-tab:hover {
  color: var(--text);
}

.catalog-type-tab.active {
  background: var(--accent);
  color: #fff;
}

/* open tab uses same active style as others */

/* Top bar (count + sort) */
.catalog-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.catalog-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-icon {
  width: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.catalog-topbar .form-select {
  width: auto;
  min-width: 180px;
  flex-shrink: 0;
}

/* Niches grid */
.niches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.form-select-sm {
  padding: 7px 32px 7px 12px;
  font-size: 0.8rem;
  width: auto;
  min-width: 180px;
}

.form-input-sm {
  padding: 7px 10px;
  font-size: 0.8rem;
}

.catalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.catalog-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.catalog-count {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.catalog-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-sort label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.catalog-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.catalog-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.catalog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  padding: 16px 0;
}

.catalog-pagination button,
.catalog-pagination a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition);
}

.catalog-pagination button:hover,
.catalog-pagination a:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.catalog-pagination .active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}


/* ==========================================================================
   5. Filter Sidebar
   ========================================================================== */

.filter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.filter-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-panel-reset {
  font-size: 0.75rem;
  color: var(--accent);
  cursor: pointer;
  transition: color var(--transition);
}

.filter-panel-reset:hover {
  color: var(--accent-hover);
}

/* Search input wrapper */
.filter-search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.filter-search-wrap .filter-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
  color: var(--text-dim);
}

.filter-search {
  width: 100%;
  padding: 8px 10px 8px 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text);
  transition: border-color var(--transition);
}

.filter-search::placeholder {
  color: var(--text-dim);
}

.filter-search:focus {
  border-color: var(--accent);
}

.filter-group {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

.filter-group:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.filter-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}

.filter-group-header h4,
.filter-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.filter-chevron,
.filter-group-header .chevron {
  font-size: 0.65rem;
  color: var(--text-dim);
  transition: transform var(--transition);
}

.filter-group-header.collapsed .filter-chevron,
.filter-group-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.filter-chevron.rotated {
  transform: rotate(180deg);
}

.filter-hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 600;
  font-style: normal;
  cursor: help;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: 0.7;
}

.filter-group-body {
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  max-height: 500px;
  transition: max-height var(--transition-slow), opacity var(--transition-slow), padding var(--transition-slow);
  opacity: 1;
}

.filter-group-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
}

/* Scrollable options list */
.filter-options-scroll {
  max-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Filter option — pill style */
.filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
}

.filter-option:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.filter-option.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--text);
}

.filter-option-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* Div-based checkbox — hidden in pill mode, state drives .active on parent */
.filter-checkbox {
  width: 0;
  height: 0;
  overflow: hidden;
  position: absolute;
  opacity: 0;
}

/* Range inputs */
.filter-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-range input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text);
  transition: border-color var(--transition);
}

.filter-range input[type="number"]:focus {
  border-color: var(--accent);
}

.filter-range-sep {
  color: var(--text-dim);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Toggle button group */
.filter-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.filter-toggle-btn {
  flex: 1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  border: none;
}

.filter-toggle-btn:hover {
  color: var(--text);
}

.filter-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}


/* ==========================================================================
   6. Niche Cards
   ========================================================================== */

/* ── Spinner ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.niche-card {
  background: var(--bg-card);
  background-image: linear-gradient(
    180deg,
    hsla(var(--card-hue, 240), 60%, 50%, 0.18) 0%,
    hsla(var(--card-hue, 240), 60%, 50%, 0.06) 20%,
    transparent 35%
  );
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: transform 0.25s ease, background var(--transition), border-color var(--transition), box-shadow 0.25s ease;
  position: relative;
}

.niche-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-hover);
  transform: translateY(-3px);
}

/* Card type indicators */
.niche-card.type-hidden {
  border-left: 3px solid var(--accent);
}

.niche-card.type-open {
  border-left: 3px solid var(--cyan);
}

/* Sold out state */
.niche-card.sold-out {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}

.niche-card.sold-out::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: rgba(10, 10, 15, 0.3);
  pointer-events: none;
}

.niche-card-sold-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

/* Already bought state */
.niche-card.bought {
  border-color: var(--green);
}

.niche-card-bought-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

/* Breadcrumbs */
.niche-card-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.niche-card-breadcrumbs span {
  color: var(--text-muted);
}

.niche-card-breadcrumbs .sep {
  color: var(--text-dim);
}

/* Card header */
.niche-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.niche-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.niche-card-type {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.niche-card-type.hidden {
  background: var(--accent-glow);
  color: var(--accent-hover);
}

.niche-card-type.open {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
}

/* Tags */
.niche-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Meta grid */
.niche-card-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.niche-card-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.niche-card-meta-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.niche-card-meta-value {
  font-size: 0.875rem;
  font-weight: 600;
}

/* Card footer */
.niche-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.niche-card-price {
  font-size: 1.25rem;
  font-weight: 700;
}

.niche-card-price .currency {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.niche-card-price-old {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: line-through;
  margin-left: 6px;
}

/* Card content rendered by catalog.js */
.niche-hidden-label { display: none; }
.label-hidden { color: var(--accent-hover); }
.label-open   { color: var(--cyan); }

/* === Card header with gradient strip === */
.niche-card-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  margin: -20px -20px 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  min-height: 72px;
}

.niche-card-head::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.06) 75%, transparent);
}


.niche-head-icon-bg {
  font-size: 3.2rem;
  line-height: 1;
  opacity: 0.12;
  position: absolute;
  right: 10px;
  bottom: -6px;
  pointer-events: none;
  filter: grayscale(0.3);
}

.niche-head-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
  z-index: 1;
}

.niche-head-root {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.niche-head-sub {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.3;
}

.niche-head-qs {
  color: hsla(var(--card-hue, 240), 65%, 65%, 0.9);
  font-weight: 800;
}

.niche-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 1;
  flex-shrink: 0;
}

.niche-lang-flag {
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
  background: rgba(255,255,255,0.1);
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--text);
  letter-spacing: 0.04em;
}

.niche-mystery-q {
  font-size: 1.6rem;
  font-weight: 800;
  color: hsla(var(--card-hue, 240), 65%, 65%, 0.9);
  line-height: 1;
  text-shadow: 0 0 12px hsla(var(--card-hue, 240), 70%, 60%, 0.5);
}

.niche-mystery {
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 0.85rem;
}

/* === Price zone === */
.niche-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.niche-price-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.niche-price {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.niche-price-old {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: line-through;
}

.niche-stock-inline {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 999px;
}

.niche-sold-inline {
  font-size: 0.7rem;
  color: var(--red);
  font-weight: 600;
}

/* === Competition indicator (compact) === */
.niche-comp-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}
.niche-comp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.comp-dot-low    { background: var(--green);  box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.comp-dot-medium { background: var(--orange); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.comp-dot-high   { background: var(--red);    box-shadow: 0 0 6px rgba(239,68,68,0.4); }

/* Keep old classes for backwards compat */
.niche-comp-badge { display: none; }
.comp-low, .comp-medium, .comp-high { display: none; }

/* === Meta grid (key-value pairs) === */
.niche-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.niche-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  position: relative;
}

/* Horizontal divider (bottom) — odd cells fade left, even cells fade right */
.niche-meta-cell::after {
  content: '';
  position: absolute;
  bottom: 0;
  height: 1px;
}
.niche-meta-cell:nth-child(odd)::after {
  left: 8px;
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07) 30%, rgba(255,255,255,0.07));
}
.niche-meta-cell:nth-child(even)::after {
  left: 0;
  right: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.07), rgba(255,255,255,0.07) 70%, transparent);
}

/* Vertical divider (right on odd cells) — fades at top & bottom edges */
.niche-meta-cell:nth-child(odd)::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.07);
}
.niche-meta-cell:first-child::before {
  top: 6px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.07) 30%, rgba(255,255,255,0.07));
}
.niche-meta-cell:nth-child(odd):nth-last-child(2)::before {
  bottom: 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.07) 70%, transparent);
}
.niche-meta-cell:first-child:nth-last-child(2)::before {
  top: 6px;
  bottom: 6px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.07) 20%, rgba(255,255,255,0.07) 80%, transparent);
}

/* Last row: no bottom divider */
.niche-meta-cell:last-child::after,
.niche-meta-cell:nth-last-child(2):nth-child(odd)::after {
  display: none;
}

/* Odd last cell spans full width — hide vertical divider */
.niche-meta-cell:last-child:nth-child(odd)::before {
  display: none;
}


.niche-meta-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.niche-meta-val {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

/* If odd number of cells, last one spans full width */
.niche-meta-cell:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}


/* Tags (kept for open cards) */
.niche-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.niche-meta-more {
  display: block;
  width: 100%;
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.15s;
}
.niche-meta-more:hover,
.niche-meta-more.active {
  color: var(--text-secondary);
}

.niche-card.card-expanded {
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

/* Analysis badge */
.niche-pre-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-bottom: 3px;
}

.niche-analysis-badge {
  font-size: 0.68rem;
  color: var(--accent-hover);
}

.niche-demo-wrap {
  margin-bottom: 8px;
}

.niche-demo-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  border-radius: 6px;
  padding: 3px 8px;
  letter-spacing: 0.01em;
}

.niche-date {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.niche-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.niche-footer-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.niche-footer-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.niche-stock-line {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-left: auto;
}

.niche-stock {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Sold out state */
.niche-card-sold {
  opacity: 0.5;
  pointer-events: none;
}

/* Open niche card specifics */
/* open card styles removed — open cards now use same design as hidden */

.niche-open-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.niche-footer-open {
  border-top: 1px solid var(--border);
}

.btn-yt-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: #c4302b;
  transition: background var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-yt-link:hover {
  background: #e03e38;
}


/* ==========================================================================
   7. Purchase Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

/* Auth Modal */
.auth-modal {
  max-width: 400px;
  text-align: center;
  padding: 40px 32px 32px;
  position: relative;
  overflow: hidden;
}


.auth-modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.auth-modal-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}


.auth-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.auth-modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 28px;
  line-height: 1.5;
}

.auth-widget-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}


.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Option cards — grid layout: title+desc left, price right */
.modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

.modal-option {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 16px;
  row-gap: 4px;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 10px;
}

.modal-option:hover {
  border-color: var(--accent);
  background: rgba(99,102,241,0.06);
}

.modal-option.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.modal-option-title {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.modal-option-desc {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-option-price {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

/* Fallback code section */
.modal-fallback {
  display: flex;
  flex-direction: column;
}

.modal-fallback-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-fallback-code {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-fallback-code input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text);
}

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.modal-footer .btn {
  flex: 1;
}

/* Fallback toggle & content */
.modal-fallback-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px 0 4px;
  transition: color var(--transition);
  background: none;
  border: none;
}

.modal-fallback-toggle:hover {
  color: var(--text-muted);
}

.modal-fallback-toggle::after {
  content: '▾';
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.3s ease;
  display: inline-block;
}

.modal-fallback-toggle.open::after {
  transform: rotate(180deg);
}

.modal-fallback-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin-top 0.3s ease;
}

.modal-fallback-content.show {
  max-height: 400px;
  opacity: 1;
  margin-top: 12px;
}

.modal-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent-hover);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-step-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.copy-inline-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 2px;
  opacity: 0.6;
  transition: opacity 0.15s;
  vertical-align: middle;
}
.copy-inline-btn:hover { opacity: 1; }

.modal-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.modal-code {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-hover);
  letter-spacing: 0.1em;
  text-align: center;
}

.modal-code-ttl {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}

.modal-sub {
  font-size: 0.85rem;
  margin: 0;
}


/* ==========================================================================
   8. Cabinet (User Dashboard)
   ========================================================================== */

.cabinet {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 24px;
  padding-top: calc(var(--nav-height) + 32px);
}

.cabinet-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px 32px;
  background: linear-gradient(135deg, var(--bg-card) 0%, #0f0f1a 100%);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.cabinet-header::before {
  content: '';
  position: absolute;
  top: -40px;
  left: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.cabinet-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-glow), rgba(99,102,241,0.25));
  border: 2px solid var(--accent);
  box-shadow: 0 0 20px rgba(99,102,241,0.3), inset 0 0 12px rgba(99,102,241,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-hover);
  flex-shrink: 0;
  overflow: hidden;
}

.cabinet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cabinet-info {
  flex: 1;
  min-width: 0;
}

.cabinet-info h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.cabinet-info .text-muted {
  font-size: 0.85rem;
  margin: 0;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.cabinet-user-info {
  flex: 1;
}

.cabinet-user-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.cabinet-user-email {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.cabinet-user-stats {
  display: flex;
  gap: 24px;
}

.cabinet-user-stat {
  text-align: center;
}

.cabinet-user-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.cabinet-user-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cabinet-section {
  margin-bottom: 32px;
}

.cabinet-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cabinet-section-title .count {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent-hover);
}

/* Purchased cards */
.cabinet-purchased-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.cabinet-purchased-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition);
}

.cabinet-purchased-card:hover {
  border-color: var(--border-hover);
}

.cabinet-purchased-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.cabinet-purchased-card-title {
  font-size: 1rem;
  font-weight: 600;
}

.cabinet-purchased-card-date {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Competitor items */
.cabinet-competitors {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cabinet-competitor-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.cabinet-competitor-item:hover {
  border-color: var(--border-hover);
}

.cabinet-competitor-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
  flex-shrink: 0;
}

.cabinet-competitor-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cabinet-competitor-info {
  flex: 1;
  min-width: 0;
}

.cabinet-competitor-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cabinet-competitor-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Analysis section */
.cabinet-analysis {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.cabinet-analysis-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.cabinet-analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.cabinet-analysis-item {
  padding: 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.cabinet-analysis-item-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cabinet-analysis-item-value {
  font-size: 1.125rem;
  font-weight: 700;
}

/* Triggers */
.cabinet-triggers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cabinet-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.cabinet-trigger:hover {
  border-color: var(--border-hover);
}

.cabinet-trigger-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.cabinet-trigger-icon.green {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.cabinet-trigger-icon.orange {
  background: rgba(245, 158, 11, 0.15);
  color: var(--orange);
}

.cabinet-trigger-icon.red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.cabinet-trigger-info {
  flex: 1;
}

.cabinet-trigger-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.cabinet-trigger-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cabinet-trigger-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.cabinet-trigger-toggle.active {
  background: var(--accent);
}

.cabinet-trigger-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text);
  border-radius: 50%;
  transition: transform var(--transition);
}

.cabinet-trigger-toggle.active::after {
  transform: translateX(20px);
}

/* Purchase cards (cabinet.js renders these) */
.purchase-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

.purchase-card:hover {
  border-color: var(--border-hover);
}

.purchase-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.purchase-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.niche-breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.niche-breadcrumb span {
  color: var(--text-dim);
  margin: 0 2px;
}

.purchase-niche-name {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.purchase-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.purchase-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.purchase-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.competitors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.competitor-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.competitor-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.competitor-thumb-empty {
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-dim);
}

.competitor-info {
  flex: 1;
  min-width: 0;
}

.competitor-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent-hover);
  text-decoration: none;
}

.competitor-name:hover {
  text-decoration: underline;
}

.competitor-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.analysis-block {
  margin-bottom: 12px;
}

.analysis-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.analysis-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.6;
}

.analysis-triggers {
  list-style: disc;
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.8;
}

.purchase-upgrade {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.purchase-card-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.niche-tag {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}


/* ==========================================================================
   9. Tags
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag-green {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.tag-orange {
  background: rgba(245, 158, 11, 0.12);
  color: var(--orange);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.tag-red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.tag-accent {
  background: var(--accent-glow);
  color: var(--accent-hover);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.tag-cyan {
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
}


/* ==========================================================================
   10. Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 24px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.03);
}

.btn-outline.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn-success:hover:not(:disabled) {
  background: #16a34a;
  border-color: #16a34a;
}

.btn-icon {
  padding: 10px;
}

.btn-icon.btn-sm {
  padding: 7px;
}


/* ==========================================================================
   11. Form Elements
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.form-label .required {
  color: var(--red);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-dim);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-light, #444);
  box-shadow: none;
}

/* Number input spinners — dark theme */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Page loader spinner */
.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loaderSpin 0.7s linear infinite;
  margin: 0 auto;
}

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

/* Date picker: dark icon + dark popup */
.form-input[type="date"],
.form-input[type="datetime-local"],
.form-input[type="time"] {
  color-scheme: dark;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-card);
  color: var(--text);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.form-error {
  font-size: 0.75rem;
  color: var(--red);
}

.form-input-group {
  display: flex;
  align-items: stretch;
}

.form-input-group .form-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.form-input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}


/* ==========================================================================
   12. Utility Classes
   ========================================================================== */

.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-green  { color: var(--green); }
.text-orange { color: var(--orange); }
.text-red    { color: var(--red); }
.text-cyan   { color: var(--cyan); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.75rem; }
.text-lg     { font-size: 1.125rem; }
.text-xl     { font-size: 1.25rem; }
.text-bold   { font-weight: 700; }

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mt-5  { margin-top: 24px; }
.mt-6  { margin-top: 32px; }
.mt-8  { margin-top: 48px; }

.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 4px; }
.mb-2  { margin-bottom: 8px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-5  { margin-bottom: 24px; }
.mb-6  { margin-bottom: 32px; }
.mb-8  { margin-bottom: 48px; }

/* Pixel-based margin utilities (used in HTML) */
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 24px; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.d-flex      { display: flex; }
.d-grid      { display: grid; }
.d-block     { display: block; }
.d-none      { display: none; }
.flex-wrap    { flex-wrap: wrap; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }

.rounded    { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }

.overflow-hidden { overflow: hidden; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* ==========================================================================
   13. Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  animation: toast-in 0.3s ease forwards;
}

.toast.removing {
  animation: toast-out 0.25s ease forwards;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.toast-message {
  flex: 1;
}

.toast-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-dim);
  flex-shrink: 0;
  cursor: pointer;
  transition: color var(--transition);
}

.toast-close:hover {
  color: var(--text);
}

.toast-success {
  border-left: 3px solid var(--green);
}

.toast-success .toast-icon {
  color: var(--green);
}

.toast-error {
  border-left: 3px solid var(--red);
}

.toast-error .toast-icon {
  color: var(--red);
}

.toast-warning {
  border-left: 3px solid var(--orange);
}

.toast-warning .toast-icon {
  color: var(--orange);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-info .toast-icon {
  color: var(--accent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}


/* ==========================================================================
   14. Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .cabinet-header {
    flex-wrap: wrap;
  }

  .cabinet-user-stats {
    width: 100%;
    justify-content: flex-start;
    margin-top: 8px;
  }
}

@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
  }

  /* Nav */
  .nav {
    padding: 0 16px;
  }

  .nav-links {
    display: none;
  }

  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 4px;
  }

  .nav-links.mobile-open .nav-link {
    width: 100%;
    padding: 12px 16px;
  }

  .nav-mobile-toggle {
    display: flex;
  }

  .user-name {
    display: none;
  }

  /* Hero */
  .hero {
    padding: 96px 16px 48px;
  }

  .hero-stats {
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Catalog */
  .catalog-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .niches-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    border-radius: var(--radius-sm);
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .catalog-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Cabinet */
  .cabinet {
    padding: 16px;
    padding-top: calc(var(--nav-height) + 16px);
  }

  .cabinet-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cabinet-purchased-grid {
    grid-template-columns: 1fr;
  }

  .cabinet-analysis-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Modal */
  .modal {
    padding: 20px;
    margin: 16px;
  }

  /* Toast */
  .toast-container {
    right: 16px;
    left: 16px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.75rem;
  }

  .hero-stats {
    flex-direction: column;
    gap: 12px;
  }

  .niche-card-meta {
    grid-template-columns: 1fr;
  }

  .cabinet-analysis-grid {
    grid-template-columns: 1fr;
  }

  .modal-option {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-option-price {
    align-self: flex-end;
  }
}

/* ==========================================================================
   Success Purchase Celebration
   ========================================================================== */

.success-modal {
  max-width: 400px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.success-icon {
  font-size: 64px;
  margin-bottom: 8px;
  animation: successBounce 0.6s ease;
}
@keyframes successBounce {
  0%   { transform: scale(0); opacity: 0; }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}
.success-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  top: -10px;
  animation: confettiFall 1.8s ease-out forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(350px) rotate(720deg); opacity: 0; }
}

/* ── Quick Edit Modal (Admin) ─────────────────── */

.card-edit-btn {
  display: none;
  width: 22px; height: 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
  line-height: 1;
}
.niche-card:hover .card-edit-btn { display: flex; }
.card-edit-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.qe-modal {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
}
.qe-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.qe-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 16px; padding: 4px; line-height: 1;
}
.qe-close:hover { color: var(--text); }

.qe-status-row {
  display: flex; gap: 8px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.qe-status-btn {
  flex: 1; padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer; font-size: 13px;
  transition: all 0.15s;
}
.qe-status-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.qe-section { padding: 14px 24px; border-bottom: 1px solid var(--border); }
.qe-section-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 10px;
}
.qe-price-grid,
.qe-filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qe-field { display: flex; flex-direction: column; gap: 4px; }
.qe-field-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.qe-check-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; color: var(--text);
  padding-top: 18px;
}
.qe-footer {
  display: flex; gap: 8px;
  padding: 14px 24px;
  background: var(--bg-card);
  position: sticky; bottom: 0;
  border-top: 1px solid var(--border);
}

/* Site footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  margin-top: 48px;
}
.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.site-footer-links {
  display: flex;
  gap: 20px;
}
.site-footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition);
}
.site-footer-links a:hover {
  color: var(--text-muted);
}
