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

:root {
  --bg:        #0a0b0f;
  --bg2:       #10121a;
  --bg3:       #161926;
  --border:    #1e2336;
  --accent:    #6c63ff;
  --accent2:   #ff6b6b;
  --accent3:   #00d4aa;
  --text:      #e8eaf6;
  --muted:     #5a6079;
  --gold:      #ffd700;
  --card:      #12151f;
  --shadow:    0 4px 24px rgba(108,99,255,.18);
  --radius:    14px;
  --font-head: 'Georgia', serif;
  --font-body: 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 240px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
}

/* ===================== ACCESS DENIED ===================== */
#access-denied {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 40px;
}
#access-denied.show { display: flex; }
.denied-icon { font-size: 72px; color: var(--accent2); animation: pulse 2s infinite; }
.denied-title { font-family: var(--font-head); font-size: 28px; color: var(--text); }
.denied-sub { color: var(--muted); font-size: 15px; max-width: 320px; line-height: 1.6; }
.denied-id { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 18px; color: var(--muted); font-family: monospace; font-size: 13px; }

/* ===================== LAYOUT ===================== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform .3s;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.logo-name { font-family: var(--font-head); font-size: 16px; letter-spacing: .5px; }
.logo-badge { font-size: 9px; background: var(--accent2); color: #fff; border-radius: 4px; padding: 1px 5px; margin-left: auto; font-weight: 700; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section-title { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--muted); padding: 12px 20px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  border-left: 3px solid transparent;
  color: var(--muted);
  transition: all .2s;
  font-size: 13.5px;
  user-select: none;
}
.nav-item:hover { color: var(--text); background: rgba(108,99,255,.07); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(108,99,255,.12); }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--accent); font-weight: 700; letter-spacing: 1px; }

/* ===================== MAIN ===================== */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}
.topbar-title { font-family: var(--font-head); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; padding: 4px 8px; flex-shrink: 0; }

.content { flex: 1; overflow-y: auto; padding: 16px; }

/* scrollbar */
.content::-webkit-scrollbar, .sidebar-nav::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-track, .sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb, .sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===================== PAGES ===================== */
.page { display: none; animation: fadeIn .25s ease; }
.page.active { display: block; }

/* ===================== STATS CARDS ===================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.stat-card.violet::before { background: var(--accent); }
.stat-card.red::before    { background: var(--accent2); }
.stat-card.green::before  { background: var(--accent3); }
.stat-card.gold::before   { background: var(--gold); }
.stat-icon { font-size: 20px; margin-bottom: 10px; }
.stat-card.violet .stat-icon { color: var(--accent); }
.stat-card.red    .stat-icon { color: var(--accent2); }
.stat-card.green  .stat-icon { color: var(--accent3); }
.stat-card.gold   .stat-icon { color: var(--gold); }
.stat-val { font-size: 24px; font-weight: 700; font-family: var(--font-head); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* ===================== SECTION TITLES ===================== */
.section-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.section-hdr h2 { font-family: var(--font-head); font-size: 16px; }
.section-hdr span { font-size: 12px; color: var(--muted); }
.section-hdr > div { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===================== TABLE ===================== */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-search {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.table-search input {
  flex: 1; min-width: 120px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 12px; font-size: 13px; outline: none;
}
.table-search input:focus { border-color: var(--accent); }

/* Таблица — горизонтальный скролл на мобиле */
.table-wrap > div[style*="overflow-x"],
.table-wrap > .overflow-x-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; min-width: 480px; }
th { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; letter-spacing: .5px; white-space: nowrap; }
.badge-active { background: rgba(0,212,170,.12); color: var(--accent3); }
.badge-banned  { background: rgba(255,107,107,.12); color: var(--accent2); }
.badge-new    { background: rgba(108,99,255,.15); color: var(--accent); }

.user-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-cell span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.user-mini-av { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.link-btn { background: none; border: 1px solid var(--border); color: var(--accent); border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; transition: all .15s; white-space: nowrap; }
.link-btn:hover { background: rgba(108,99,255,.15); border-color: var(--accent); }
.copy-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px; transition: color .15s; }
.copy-btn:hover { color: var(--accent); }

/* steam link cell */
.steam-cell { display: flex; align-items: center; gap: 6px; max-width: 160px; }
.steam-link-text { font-family: monospace; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

/* ===================== PRODUCT FORM ===================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
label { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.form-input, .form-select, .form-textarea {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 13.5px; outline: none;
  font-family: var(--font-body); transition: border-color .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: var(--bg3); }

.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-opt { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px; transition: all .15s; background: var(--bg3); }
.icon-opt:hover { border-color: var(--accent); }
.icon-opt.selected { border-color: var(--accent); background: rgba(108,99,255,.2); color: var(--accent); }

.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 32px; height: 32px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; transition: transform .15s; }
.color-swatch.selected { border-color: #fff; transform: scale(1.1); }
.color-swatch.custom { display: flex; align-items: center; justify-content: center; background: var(--bg3); border-color: var(--border); color: var(--muted); font-size: 14px; }

/* ===================== PRODUCT LIST ===================== */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.product-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; position: relative; transition: box-shadow .2s, transform .2s;
}
.product-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.prod-icon-area { width: 48px; height: 48px; border-radius: 12px; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 10px; }
.prod-name { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.prod-game { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.prod-price { font-size: 15px; font-weight: 700; font-family: var(--font-head); color: var(--gold); }
.prod-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.btn-sm { padding: 5px 10px; border-radius: 7px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; transition: opacity .15s; white-space: nowrap; }
.btn-edit { background: rgba(108,99,255,.18); color: var(--accent); }
.btn-del  { background: rgba(255,107,107,.13); color: var(--accent2); }
.btn-sm:hover { opacity: .8; }
.prod-badge { position: absolute; top: 10px; right: 10px; }

/* ===================== BUTTONS ===================== */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8f87ff);
  color: #fff; border: none; border-radius: 10px; padding: 10px 18px;
  font-size: 13px; font-weight: 700; cursor: pointer; letter-spacing: .3px;
  transition: opacity .15s, transform .15s; display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; font-size: 13px; cursor: pointer;
  transition: border-color .15s; display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--accent); }

/* ===================== TOAST ===================== */
.toast-container { position: fixed; bottom: 16px; right: 16px; left: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; font-size: 13px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4); animation: slideIn .3s ease;
  pointer-events: all;
}
.toast.success { border-left: 3px solid var(--accent3); }
.toast.error   { border-left: 3px solid var(--accent2); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast i { font-size: 15px; flex-shrink: 0; }
.toast.success i { color: var(--accent3); }
.toast.error   i { color: var(--accent2); }
.toast.info    i { color: var(--accent); }

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 500;
  display: none; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%; max-width: 100%; max-height: 90vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-family: var(--font-head); font-size: 17px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-footer button { flex: 1; min-width: 0; justify-content: center; }

/* ===================== EMPTY STATE ===================== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state i { font-size: 40px; margin-bottom: 14px; opacity: .4; display: block; }
.empty-state p { font-size: 14px; }

/* ===================== RESPONSIVE SIDEBAR ===================== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }

@media (max-width: 768px) {
  body { overflow: hidden; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 40px rgba(0,0,0,.5); }
  .sidebar-overlay.open { display: block; }
  .mobile-menu-btn { display: flex; }
  .main { width: 100%; }

  /* Контент */
  .content { padding: 12px; }

  /* Статистика — 2 колонки на телефоне */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-val { font-size: 20px; }

  /* Заголовки секций */
  .section-hdr { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-hdr > div { width: 100%; }
  .section-hdr > div .btn-primary,
  .section-hdr > div .btn-secondary,
  .section-hdr > div select { flex: 1; justify-content: center; }

  /* Форма товара */
  .form-grid { grid-template-columns: 1fr; }
  .table-wrap > div { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap[style*="padding"] { padding: 14px !important; }

  /* Фильтры пользователей */
  .table-search { flex-wrap: wrap; }
  .table-search input { width: 100%; min-width: unset; }
  .table-search select { flex: 1; font-size: 12px; padding: 6px 8px; }

  /* Таблицы */
  table { min-width: 560px; }
  th, td { padding: 10px 10px; font-size: 12px; }

  /* Кнопки в таблице */
  .link-btn { padding: 3px 8px; font-size: 10px; }

  /* Товары */
  .products-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .product-item { padding: 12px; }
  .prod-name { font-size: 12px; }
  .prod-actions { gap: 4px; }
  .btn-sm { padding: 4px 8px; font-size: 11px; }

  /* Модал — снизу вверх */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 85vh; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer button { flex: 1 1 auto; font-size: 12px; padding: 9px 12px; }

  /* Табы */
  .tabs { gap: 3px; }
  .tab { font-size: 12px; padding: 8px 6px; }

  /* Топбар */
  .topbar { padding: 0 12px; height: 52px; }
  .topbar-title { font-size: 16px; }

  /* Тосты */
  .toast-container { bottom: 12px; right: 12px; left: 12px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-val { font-size: 18px; }
  .stat-label { font-size: 9px; }
  .products-grid { grid-template-columns: 1fr; }
  .modal-footer button { font-size: 11px; padding: 8px 10px; }
}

/* ===================== ANIMATIONS ===================== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ===================== TABS ===================== */
.tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; text-align: center; padding: 9px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); transition: all .2s; }
.tab.active { background: var(--accent); color: #fff; }

/* ===================== LOADING ===================== */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--border) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===================== МОБИЛЬНЫЕ ТАБЛИЦЫ ===================== */
@media (max-width: 768px) {

  /* Дашборд — скрываем Username и Steam */
  #page-dashboard .table-wrap table thead tr th:nth-child(3),
  #page-dashboard .table-wrap table thead tr th:nth-child(4),
  #page-dashboard .table-wrap table tbody tr td:nth-child(3),
  #page-dashboard .table-wrap table tbody tr td:nth-child(4) {
    display: none;
  }

  /* Пользователи — скрываем Username и Steam ссылку */
  #page-users table thead tr th:nth-child(3),
  #page-users table thead tr th:nth-child(4),
  #page-users table tbody tr td:nth-child(3),
  #page-users table tbody tr td:nth-child(4) {
    display: none;
  }

  /* Убираем min-width у таблиц внутри этих страниц */
  #page-dashboard .table-wrap table,
  #page-users table {
    min-width: unset;
    width: 100%;
  }

  /* Кнопка "Управлять" — только иконка */
  #page-users .link-btn {
    padding: 6px 8px;
    font-size: 13px;
  }
  #page-users .link-btn i {
    margin: 0;
  }
  #page-users .link-btn::after {
    content: none;
  }
}

@media (max-width: 768px) {
  .btn-label-text { display: none; }
}

@media (max-width: 768px) {
  /* Дашборд — скрываем "Был" (6-я колонка) тоже */
  #page-dashboard .table-wrap table thead tr th:nth-child(6),
  #page-dashboard .table-wrap table tbody tr td:nth-child(6) {
    display: none;
  }
}