/* Shared Styles - Used across all pages */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg0: #09090b; --bg1: #0f0f12; --bg2: #141418; --bg3: #1a1a20; --bg4: #222228;
  --border: rgba(255,255,255,0.07); --border-bright: rgba(255,255,255,0.14);
  --gold: #f0b429; --gold-bg: rgba(240,180,41,0.08);
  --green: #4ade80; --blue: #7dd3fc; --purple: #c084fc;
  --red: #f87171; --orange: #fb923c;
  --text-primary: #f0ebe0; --text-secondary: #8a8070; --text-muted: #3a3830;
  --mono: 'JetBrains Mono', monospace; --display: 'Syne', sans-serif;
  --radius: 8px; --radius-lg: 14px;
}
html { font-size: 16px; }
body { font-family: var(--mono); background: var(--bg0); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 40px 40px;
}
.page { position: relative; z-index: 1; max-width: 1440px; margin: 0 auto; padding: 0 16px 48px; animation: pageEnter 0.4s ease-out; }
@keyframes pageEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── CONTEXT MENU ── */
.context-menu { position: fixed; background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius); z-index: 10000; min-width: 160px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.context-item { padding: 8px 12px; font-size: 11px; color: var(--text-secondary); cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.02); transition: all 0.15s; user-select: none; }
.context-item:last-child { border-bottom: none; }
.context-item:hover { background: var(--bg3); color: var(--text-primary); }

/* ── MODAL ── */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; }
.modal.active { display: flex; }
.modal-content { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 800px; width: 90%; max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 16px; }
.modal-close { cursor: pointer; font-size: 18px; color: var(--text-secondary); transition: color 0.15s; }
.modal-close:hover { color: var(--text-primary); }

/* ── HEADER ── */
header { display: flex; align-items: center; justify-content: space-between; padding: 20px 0 18px; gap: 14px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.logo { font-family: var(--display); font-size: clamp(20px,4vw,28px); font-weight: 800; color: var(--gold); letter-spacing: -1px; line-height: 1; }
.logo-sub { font-family: var(--mono); font-size: 10px; color: var(--text-secondary); letter-spacing: 0.5px; margin-top: 3px; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status-pill { display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg2); color: var(--text-secondary); white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.status-pill.live .status-dot { background: var(--green); animation: pulse 2s infinite; }
.status-pill.live { color: var(--text-primary); }
.status-pill.error .status-dot { background: var(--red); }
.status-pill.loading .status-dot { background: var(--gold); animation: pulse 0.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:0.25} }

.refresh-btn { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; padding: 6px 14px; border: 1px solid var(--border-bright); border-radius: var(--radius); background: var(--bg2); color: var(--text-primary); cursor: pointer; transition: all 0.15s; }
.refresh-btn:hover { background: var(--bg4); border-color: var(--gold); color: var(--gold); }
.refresh-btn:active { transform: scale(0.97); }
.refresh-btn.spinning .r-icon { display: inline-block; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.countdown { font-size: 10px; color: var(--text-secondary); background: var(--bg3); padding: 1px 6px; border-radius: 4px; min-width: 28px; text-align: center; }
.auto-wrap { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-secondary); }
.toggle-track { width: 32px; height: 18px; border-radius: 9px; background: var(--bg4); border: 1px solid var(--border-bright); position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.toggle-track.on { background: var(--gold); border-color: var(--gold); }
.toggle-track::after { content:''; position:absolute; width:12px; height:12px; background:var(--bg1); border-radius:50%; top:2px; left:2px; transition:left 0.2s; }
.toggle-track.on::after { left: 16px; }

/* ── NAV TABS ── */
.nav-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.nav-tab { font-family: var(--mono); font-size: 12px; padding: 10px 18px; cursor: pointer; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; transition: all 0.15s; user-select: none; text-decoration: none; }
.nav-tab:hover { color: var(--text-primary); }
.nav-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── FILTER PANEL ── */
.filter-panel { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 14px; overflow: hidden; }
.filter-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; cursor: pointer; user-select: none; border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.filter-header.open { border-bottom-color: var(--border); }
.filter-header-left { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.filter-chevron { font-size: 10px; transition: transform 0.2s; }
.filter-chevron.open { transform: rotate(180deg); }
.filter-body { padding: 14px 16px; display: none; }
.filter-body.open { display: block; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-label { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.5px; }
.filter-input { font-family: var(--mono); font-size: 12px; background: var(--bg3); color: var(--text-primary); border: 1px solid var(--border-bright); border-radius: var(--radius); padding: 6px 8px; outline: none; transition: border-color 0.15s; width: 100%; }
.filter-input:focus { border-color: var(--gold); }
select.filter-input option { background: var(--bg3); }

/* ── TABLE ── */
.table-wrap { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-scroll { overflow-x: auto; overflow-y: auto; max-height: calc(100vh - 440px); min-height: 240px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead { position: sticky; top: 0; z-index: 3; }
thead tr { background: var(--bg2); }
thead th { text-align: left; padding: 9px 12px; font-size: 10px; letter-spacing: 0.6px; color: var(--text-secondary); font-weight: 400; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; transition: color 0.15s; }
thead th:hover { color: var(--gold); }
thead th.sorted { color: var(--gold); }
tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr.blacklisted { opacity: 0.35; }
tbody tr.pinned { background: rgba(240,180,41,0.05); }
tbody tr.pinned:hover { background: rgba(240,180,41,0.09); }
tbody td { padding: 8px 12px; vertical-align: middle; }

.rank-badge { display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;font-size:10px;font-weight:600;border-radius:5px; }
.rank-1{background:var(--gold);color:#000} .rank-2{background:#9ca3af;color:#000} .rank-3{background:#b97c3a;color:#000} .rank-n{background:var(--bg3);color:var(--text-secondary)}

.cat-pill { display: inline-block; font-size: 9px; padding: 2px 6px; border-radius: 3px; font-weight: 500; white-space: nowrap; }
.cat-farming{background:rgba(74,222,128,0.12);color:#4ade80}
.cat-mining{background:rgba(125,211,252,0.12);color:#7dd3fc}
.cat-combat{background:rgba(248,113,113,0.12);color:#f87171}
.cat-woods{background:rgba(134,239,172,0.12);color:#86efac}
.cat-oddities{background:rgba(192,132,252,0.12);color:#c084fc}

.action-btn { font-size: 10px; padding: 3px 7px; border-radius: 4px; border: 1px solid var(--border-bright); background: transparent; cursor: pointer; color: var(--text-secondary); font-family: var(--mono); transition: all 0.15s; margin-left: 4px; }
.action-btn:hover { border-color: var(--gold); color: var(--gold); }
.action-btn.pin-active { border-color: var(--gold); color: var(--gold); background: var(--gold-bg); }
.action-btn.bl-active { border-color: var(--red); color: var(--red); background: rgba(248,113,113,0.08); }

/* ── STAT CARDS ── */
.stats-row { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-bottom: 16px; }
@media(max-width:900px){ .stats-row { grid-template-columns: repeat(3,1fr); } }
@media(max-width:560px){ .stats-row { grid-template-columns: repeat(2,1fr); } }
.stat-card { background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; animation: fadeUp 0.35s ease both; }
@keyframes fadeUp { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }
.stat-label { font-size: 9px; color: var(--text-secondary); letter-spacing: 0.9px; text-transform: uppercase; }
.stat-val { font-size: clamp(16px,2.5vw,22px); font-weight: 600; color: var(--gold); line-height: 1.15; }
.stat-val.sm { font-size: clamp(12px,1.8vw,14px); padding-top: 3px; }

/* ── EMPTY / ERROR ── */
.empty-state { padding: 60px 24px; text-align: center; color: var(--text-muted); font-size: 13px; line-height: 2; }
.empty-state .big { font-size: 26px; margin-bottom: 10px; }
.empty-state a { color: var(--gold); text-decoration: none; cursor: pointer; }
footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 10px; color: var(--text-muted); }
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text-secondary); }

/* ── CHART CONTAINER ── */
.chart-container { width: 100%; height: 350px; margin-bottom: 16px; }
.chart-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; font-size: 10px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── COMPETITOR BADGE ── */
.competitor-badge { display: inline-block; padding: 2px 6px; border-radius: 3px; font-size: 9px; font-weight: 600; margin-left: 4px; }
.competitor-low { background: rgba(74,222,128,0.15); color: #4ade80; }
.competitor-medium { background: rgba(240,180,41,0.15); color: #f0b429; }
.competitor-high { background: rgba(248,113,113,0.15); color: #f87171; }

/* ── RESPONSIVE ── */
@media(max-width:1300px){ .c-tax,.c-score{display:none} }
@media(max-width:1050px){ .c-buy,.c-sell{display:none} }
@media(max-width:820px) { .c-sellvol,.c-margin{display:none} }
@media(max-width:640px) { .c-buyvol{display:none} }
@media(max-width:500px) { .c-pct,.c-cat{display:none} }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg1); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
