/* ============================================================
   Kaspi Data Explorer - 蝉妈妈风格 UI
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --sidebar-width: 220px;
  --sidebar-bg: #001529;
  --sidebar-hover: #002140;
  --sidebar-active: #2878FF;
  --header-height: 56px;
  --primary: #2878FF;
  --primary-light: #e8f2ff;
  --accent: #FF6B35;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e8e8e8;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --gold: #f5a623;
  --silver: #a0aab4;
  --bronze: #c99a6b;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo img { width: 32px; height: 32px; border-radius: 6px; }

.sidebar-logo .logo-text {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-logo .logo-version {
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  transition: var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-nav a:hover {
  color: #fff;
  background: var(--sidebar-hover);
}

.sidebar-nav a.active {
  color: #fff;
  background: rgba(40,120,255,0.15);
  border-left-color: var(--sidebar-active);
}

.sidebar-nav a .nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.3);
  font-size: 11px;
}

/* --- Main Content --- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* --- Header --- */
.header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 999;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.header-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.header-breadcrumb .separator { color: var(--text-muted); }

/* --- Language Switch --- */
.lang-switch {
  display: flex;
  gap: 2px;
  background: #f0f2f5;
  border-radius: 6px;
  padding: 2px;
}

.lang-btn {
  background: none;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: var(--transition);
  font-weight: 500;
}

.lang-btn:hover { background: #e8e8e8; }

.lang-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- Auth Buttons (Header) --- */
.auth-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- User Menu --- */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: var(--transition);
}

.user-avatar-btn:hover { background: #f5f5f5; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

.username {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrow { font-size: 10px; color: var(--text-muted); }

/* --- User Dropdown --- */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  z-index: 1001;
  display: none;
  overflow: hidden;
  animation: fadeInDown 0.15s ease;
}

.user-dropdown.show { display: block; }

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.dropdown-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.dropdown-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.dropdown-item:hover {
  background: #f5f7fa;
  color: var(--primary);
}

/* --- Buttons (Header small) --- */
.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: #1a6ae6;
}

/* --- Page Content --- */
.page-content {
  padding: 24px;
}

/* --- KPI Cards --- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: default;
}

.kpi-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.kpi-icon.blue { background: #e8f2ff; color: #2878FF; }
.kpi-icon.green { background: #e6f7e6; color: #52c41a; }
.kpi-icon.orange { background: #fff3e0; color: #FF6B35; }
.kpi-icon.purple { background: #f3e8ff; color: #9333ea; }
.kpi-icon.teal { background: #e0f7f4; color: #0d9488; }

.kpi-info { flex: 1; }

.kpi-info .kpi-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kpi-info .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

/* --- Chart Containers --- */
.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-card .chart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-card .chart-body {
  padding: 16px 20px;
  min-height: 280px;
  position: relative;
}

.chart-card .chart-body canvas {
  max-height: 280px;
}

/* --- Table Card --- */
.table-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-card .table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-card .table-body {
  overflow-x: auto;
}

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: #fafafa;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.data-table .product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-table .product-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: #f5f5f5;
}

.data-table .product-name {
  font-weight: 500;
  color: var(--text);
}

.data-table .product-link {
  color: var(--primary);
  text-decoration: none;
}

.data-table .product-link:hover { text-decoration: underline; }

.data-table .category-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-size: 12px;
}

.data-table .price-cell { font-weight: 600; white-space: nowrap; }

.data-table .price-cny {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.data-table .rating-stars {
  color: var(--warning);
  font-size: 13px;
}

.data-table .rating-value {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 4px;
}

/* --- Rank Badges --- */
.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.rank-badge.gold { background: linear-gradient(135deg, #f5a623, #f7c752); }
.rank-badge.silver { background: linear-gradient(135deg, #a0aab4, #c8d0d8); }
.rank-badge.bronze { background: linear-gradient(135deg, #c99a6b, #dbb284); }
.rank-badge.normal { background: #e8e8e8; color: var(--text-secondary); }

/* --- Search & Filter --- */
.search-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

.search-input-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.search-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(40,120,255,0.1);
}

.btn-search {
  height: 44px;
  padding: 0 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-search:hover { background: #1a6ae0; }

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-tags .filter-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: 4px;
}

.filter-tag {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.filter-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-tag.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-tag select {
  border: none;
  background: transparent;
  font-size: 13px;
  color: inherit;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  padding-right: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

/* --- Product List (Hot) --- */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.product-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid #f0f0f0;
  transition: var(--transition);
  cursor: pointer;
}

.product-item:hover {
  background: #fafafa;
}

.product-item .item-rank { width: 36px; flex-shrink: 0; }

.product-item .item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #f5f5f5;
  flex-shrink: 0;
}

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

.product-item .item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.product-item .item-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.product-item .item-price {
  text-align: right;
  flex-shrink: 0;
}

.product-item .item-price .price-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.product-item .item-price .price-cny {
  font-size: 12px;
  color: var(--text-muted);
}

.product-item .item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

/* --- Category Grid --- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.category-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}

.category-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.category-card .cat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.category-card .cat-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.category-card .cat-name-ru {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.category-card .cat-stats {
  display: flex;
  gap: 16px;
}

.category-card .cat-stat {
  text-align: center;
}

.category-card .cat-stat .stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.category-card .cat-stat .stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 20px 0;
}

.pagination .page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pagination .page-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination .page-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 8px;
}

/* --- Product Detail --- */
.detail-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.detail-image {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 1;
  object-fit: contain;
  background: #fafafa;
}

.detail-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.detail-title-ru {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.detail-meta .meta-label {
  width: 60px;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.detail-meta .meta-value {
  font-size: 14px;
  color: var(--text);
}

.detail-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0;
}

.detail-price .cny {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
}

/* --- Scraper Page --- */
.scraper-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
}

.scraper-controls {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.scraper-controls h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.scraper-log {
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: var(--radius);
  padding: 16px;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.8;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover { background: #1a6ae0; }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 4px 12px; font-size: 12px; }

.btn-block { display: flex; width: 100%; }

/* --- Form Elements --- */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(40,120,255,0.1);
}

select.form-control { cursor: pointer; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* --- Loading --- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  gap: 8px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Utility --- */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.font-bold { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* --- Section Title --- */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

/* --- Keygen Page --- */
.keygen-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

.keygen-form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.keygen-history-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.keygen-result {
  background: #f0fff4;
  border: 1px solid #b7eb8f;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  word-break: break-all;
  font-family: monospace;
  font-size: 13px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- RC3 Search UX --- */
.search-input-enhanced { position: relative; flex: 1; }
.search-hints {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
}
.search-hint-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f5f5f5;
}
.search-hint-item:hover { background: #f0f7ff; }
.search-meta-row { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.search-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.search-chip {
  border: 1px solid var(--border);
  background: #fafafa;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-chip:hover, .search-chip.hot { border-color: var(--primary); color: var(--primary); }
.search-correction {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fffbe6;
  border-radius: var(--radius);
  font-size: 13px;
}
.btn-link-sm {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  padding: 0 4px;
}
.search-history-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.empty-recommendations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.empty-recommendations h4 { grid-column: 1 / -1; margin: 0 0 8px; font-size: 14px; }
.rec-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  font-size: 12px;
}
.rec-card img { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; }
.rec-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-price { font-weight: 600; color: var(--primary); }

/* --- RC3 Quality Dashboard --- */
.quality-dashboard .quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 16px 20px 20px;
}
.quality-dim { display: flex; flex-direction: column; gap: 6px; }
.quality-dim-label { font-size: 12px; color: #666; }
.quality-bar {
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}
.quality-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2878FF, #00C6FF);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.quality-pct { font-size: 13px; font-weight: 600; color: var(--primary); }
.quality-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #e6f4ff;
  color: var(--primary);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* --- RC3 Mobile Nav --- */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: 20px;
  cursor: pointer;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}
.sidebar-overlay.open { display: block; }

/* --- Responsive --- */
@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-nav-toggle { display: block; }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 1000;
    transition: left 0.25s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar .logo-text, .sidebar .logo-version,
  .sidebar-nav a span, .sidebar-footer { display: block; }
  .sidebar-nav a { justify-content: flex-start; padding: 12px 16px; }
  .main-wrapper { margin-left: 0; }
  .header { padding-left: 56px; }
  .kpi-row { grid-template-columns: 1fr; }
  .scraper-layout, .keygen-layout { grid-template-columns: 1fr; }
  .product-item { flex-wrap: wrap; }
  .item-info { min-width: 0; flex: 1 1 100%; }
  .search-bar { flex-direction: column; }
  .btn-search { width: 100%; }
}

/* --- Auth Pages --- */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - var(--header-height) - 48px);
  padding: 24px;
}

.auth-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  font-size: 40px;
  margin-bottom: 12px;
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form .form-group {
  margin-bottom: 16px;
}

.auth-form .form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: var(--transition);
  background: #fff;
}

.auth-form .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(40,120,255,0.12);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}
.input-with-btn .form-control {
  flex: 1;
}
.input-with-btn .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.required { color: var(--danger); margin-left: 2px; }

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* --- Google Sign-In Button --- */
.google-login-section {
  margin-bottom: 16px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  border-color: #c0c4c8;
}

.btn-google:active {
  background: #e8eaed;
}

.google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #fff;
  color: #4285f4;
  font-weight: 700;
  font-size: 16px;
  border-radius: 2px;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 14px;
}

/* --- Profile Page --- */
.profile-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.profile-card { max-width: 320px; }

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 16px;
}

.avatar-xl {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #00C6FF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
}

.profile-form .form-group {
  margin-bottom: 14px;
}

.profile-form .form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: var(--transition);
}

.profile-form .form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(40,120,255,0.12);
}

.profile-form textarea.form-control {
  resize: vertical;
  min-height: 72px;
}

/* --- Toggle Switch --- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: all 0.3s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* --- Scheduler Info --- */
#scheduler-info { margin-top: 12px; }
#scheduler-info div { margin-bottom: 4px; }
#scheduler-info span { font-weight: 500; }

/* --- Misc --- */
.btn-block {
  width: 100%;
}

/* --- Responsive: Profile --- */
@media (max-width: 900px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }
  .profile-card { max-width: 100%; }
}

/* --- Multi-platform badge (KASPI default; OZON/WB via data-platform) --- */
.platform-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}
.platform-badge.platform-kaspi {
  background: #e6f4ff;
  color: #1677ff;
}
.platform-badge.platform-ozon {
  background: #f0f5ff;
  color: #2f54eb;
}
.platform-badge.platform-wb {
  background: #fff0f6;
  color: #c41d7f;
}
