/* ===== CSS VARIABLES ===== */
:root {
  --bg: #0b0e14;
  --bg-secondary: #11161f;
  --bg-tertiary: #1a1f2b;
  --bg-card: #131824;
  --border: #232936;
  --border-hover: #2d3548;
  --text: #c9d1d9;
  --text-secondary: #6e7681;
  --text-muted: #484f58;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-glow: rgba(249,115,22,0.15);
  --green: #3fb950;
  --green-dim: #2ea043;
  --green-glow: rgba(47,185,64,0.12);
  --red: #f85149;
  --blue: #58a6ff;
  --steam: #1b2838;
  --steam-accent: #66c0f4;
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 18px;
  box-shadow: 0 4px 14px rgba(249,115,22,0.25);
}

.brand-text h1 { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 0.3px; }
.brand-text span { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1.2px; }

.nav-section { margin-bottom: 6px; }
.nav-label {
  font-size: 10px; text-transform: uppercase; color: var(--text-secondary);
  letter-spacing: 1.5px; padding: 14px 20px 8px; font-weight: 700;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; margin: 2px 12px;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-secondary); font-size: 13.5px;
  transition: all 0.15s ease; text-decoration: none;
  border: 1px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.03); color: var(--text); border-color: var(--border); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(249,115,22,0.12), rgba(249,115,22,0.04));
  color: var(--accent); font-weight: 600;
  border-color: rgba(249,115,22,0.25);
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.65; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
}

.user-card {
  margin: auto 14px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color 0.15s;
}
.user-card:hover { border-color: var(--border-hover); }

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info h4 { font-size: 13px; color: #fff; }
.user-info span { font-size: 11px; color: var(--text-secondary); }

.steam-login-btn {
  margin: 0 14px 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px;
  background: linear-gradient(135deg, #1b2838, #2a475e);
  border: 1px solid #3d6a8c;
  border-radius: var(--radius);
  color: var(--steam-accent);
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
}
.steam-login-btn:hover {
  border-color: var(--steam-accent);
  box-shadow: 0 0 16px rgba(102,192,244,0.15);
  transform: translateY(-1px);
}
.steam-login-btn svg { width: 18px; height: 18px; }

.support-box {
  margin: 0 14px 14px;
  background: linear-gradient(135deg, rgba(249,115,22,0.12), rgba(251,146,60,0.05));
  border: 1px solid rgba(249,115,22,0.25);
  border-radius: var(--radius);
  padding: 16px;
}
.support-box h4 { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.support-box p { font-size: 11px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 10px; }
.support-btn {
  width: 100%; padding: 9px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all 0.15s; letter-spacing: 0.3px;
}
.support-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(249,115,22,0.3); }

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 28px 32px;
  max-width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}

.search-wrap {
  flex: 1; max-width: 520px; position: relative;
}
.search-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted);
}
.search-wrap input {
  width: 100%; padding: 11px 14px 11px 42px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 14px; outline: none;
  transition: all 0.15s;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-wrap input::placeholder { color: var(--text-muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text); transition: all 0.15s;
}
.btn:hover { background: var(--bg-tertiary); border-color: var(--border-hover); }
.btn-green {
  background: var(--green-glow); border-color: rgba(47,185,64,0.3);
  color: var(--green); font-size: 12px;
}
.btn-green:hover { background: rgba(47,185,64,0.2); }
.btn-refresh:hover { color: var(--accent); border-color: var(--accent); }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 {
  font-size: 20px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 10px;
}
.page-header h2 svg { color: var(--accent); }

/* ===== SITE SELECTOR ===== */
.site-selector-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.site-selector-group {
  display: flex; flex-direction: column; gap: 6px;
}
.site-selector-group label {
  font-size: 11px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600;
}
.site-selector-group select {
  padding: 10px 36px 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 13.5px; outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236e7681' stroke-width='2'%3E%3Cpath d='M2 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: all 0.15s; min-width: 160px;
}
.site-selector-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.site-selector-group select option {
  background: var(--bg-secondary); color: var(--text); padding: 8px;
}

/* ===== FILTER CHIPS ===== */
.filters-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.filter-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s; font-weight: 500;
}
.filter-chip:hover { border-color: var(--border-hover); color: var(--text); }
.filter-chip.active {
  background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(249,115,22,0.08));
  border-color: rgba(249,115,22,0.4);
  color: var(--accent); font-weight: 600;
}

/* ===== TABLE ===== */
.table-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left; padding: 14px 16px;
  color: var(--text-secondary); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
  white-space: nowrap;
}
thead th:first-child { padding-left: 24px; width: 40px; }
thead th:last-child { padding-right: 24px; }

tbody tr {
  border-bottom: 1px solid rgba(48,54,61,0.4);
  transition: background 0.1s;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }

tbody td {
  padding: 14px 16px; vertical-align: middle;
  color: var(--text); white-space: nowrap;
}
tbody td:first-child { padding-left: 24px; color: var(--text-secondary); font-weight: 700; font-size: 12px; }
tbody td:last-child { padding-right: 24px; }

.item-cell { display: flex; align-items: center; gap: 12px; }
.item-img {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; border: 1px solid var(--border);
  flex-shrink: 0; overflow: hidden;
}
.item-img img { width: 100%; height: 100%; object-fit: cover; }

.item-name {
  font-weight: 600; color: #fff; font-size: 13.5px;
  cursor: pointer; transition: color 0.15s;
  user-select: all;
}
.item-name:hover { color: var(--accent); }
.item-name.copied::after {
  content: ' copied!';
  color: var(--green);
  font-size: 11px;
  margin-left: 6px;
  animation: fadeOut 1.5s forwards;
}
@keyframes fadeOut {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.item-site-link {
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.item-site-link:hover { color: var(--accent); text-decoration: underline; }
.item-site-link svg { width: 10px; height: 10px; opacity: 0.6; }

.price { font-weight: 600; font-family: 'SF Mono', 'Courier New', monospace; font-size: 13px; }
.profit-pos { color: var(--green); font-weight: 700; }
.profit-neg { color: var(--red); font-weight: 700; }
.updated { color: var(--text-secondary); font-size: 12px; }

.star {
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
  font-size: 17px; user-select: none;
}
.star:hover, .star.fav { color: #fbbf24; text-shadow: 0 0 8px rgba(251,191,36,0.3); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 5px; padding: 18px;
  border-top: 1px solid var(--border);
}
.page-btn {
  min-width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  font-size: 13px; cursor: pointer; transition: all 0.15s;
  padding: 0 10px; font-weight: 500;
}
.page-btn:hover { background: var(--bg-tertiary); color: var(--text); border-color: var(--border-hover); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.results-info {
  padding: 0 20px 14px;
  font-size: 12px; color: var(--text-secondary);
}

/* ===== INVENTORY GRID ===== */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-top: 20px;
}
.inv-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
}
.inv-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.inv-card .inv-img {
  width: 100%; height: 120px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; font-size: 48px;
}
.inv-card .inv-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.inv-card .inv-name {
  font-size: 12.5px; font-weight: 600; color: #fff;
  margin-bottom: 6px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 32px;
  cursor: pointer; transition: color 0.15s;
}
.inv-card .inv-name:hover { color: var(--accent); }
.inv-card .inv-rpot {
  font-size: 15px; font-weight: 700; color: var(--accent);
  font-family: monospace; margin-bottom: 4px;
}
.inv-card .inv-market {
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 8px;
}
.inv-card .inv-profit {
  display: inline-block;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.inv-profit.pos { background: var(--green-glow); color: var(--green); }
.inv-profit.neg { background: rgba(248,81,73,0.12); color: var(--red); }

.inv-rarity {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.rarity-common { background: #b0c3d9; }
.rarity-uncommon { background: #5e98d9; }
.rarity-rare { background: #4b69ff; }
.rarity-mythical { background: #8847ff; }
.rarity-legendary { background: #d32ce6; }
.rarity-ancient { background: #eb4b4b; }
.rarity-contraband { background: #ffae00; }

/* ===== PRICE CHECK ===== */
.price-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; margin-top: 20px;
}
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.15s;
}
.site-card:hover { border-color: var(--border-hover); }
.site-card h4 {
  font-size: 14px; color: #fff; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.site-card .site-url {
  font-size: 11px; color: var(--text-secondary); margin-bottom: 16px;
  text-decoration: none; display: inline-block;
}
.site-card .site-url:hover { color: var(--accent); text-decoration: underline; }
.site-card .price-big {
  font-size: 26px; font-weight: 700; color: #fff;
  font-family: 'SF Mono', monospace;
}
.site-card .price-diff { font-size: 12px; margin-top: 6px; font-weight: 600; }
.site-card .best-badge {
  margin-top: 10px; font-size: 11px; color: var(--green);
  font-weight: 700; display: flex; align-items: center; gap: 4px;
}

/* ===== COMPARE ===== */
.compare-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr auto auto auto;
  gap: 16px; align-items: end;
}
.form-group label {
  display: block; font-size: 11px; color: var(--text-secondary);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.form-group select, .form-group input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 14px; outline: none;
  transition: all 0.15s;
}
.form-group select:focus, .form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.btn-primary {
  padding: 11px 28px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 700;
  cursor: pointer; height: fit-content; letter-spacing: 0.3px;
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(249,115,22,0.3); transform: translateY(-1px); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: none; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(6px);
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  padding: 28px;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 85vh; overflow-y: auto;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 { font-size: 18px; margin-bottom: 20px; color: #fff; }
.modal-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.modal-row:last-child { border-bottom: none; }
.modal-label { color: var(--text-secondary); }
.modal-value { font-weight: 700; font-family: monospace; font-size: 14px; }
.modal-close {
  margin-top: 24px; width: 100%;
  padding: 12px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background 0.15s;
}
.modal-close:hover { background: var(--accent-hover); }

/* ===== SECTIONS ===== */
.section { display: none; animation: fadeIn 0.2s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state svg {
  width: 64px; height: 64px; margin-bottom: 16px;
  color: var(--text-muted); opacity: 0.5;
}
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px; z-index: 300;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; align-items: center; gap: 10px;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== SPINNER ===== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; max-width: 100vw; padding: 16px; }
  .compare-form { grid-template-columns: 1fr; }
  .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
.auth-loader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.auth-loader-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #ff7a3d;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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