:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1f2630;
  --panel-3: #27313d;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ecf0f5;
  --muted: #9ca8b6;
  --accent: #4ade80;
  --accent-2: #38bdf8;
  --warning: #f59e0b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 25%),
    radial-gradient(circle at top right, rgba(74, 222, 128, 0.1), transparent 30%),
    linear-gradient(180deg, #0a0f15 0%, #0f1720 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.78);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #1f9d55, #175cd3);
  box-shadow: var(--shadow);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-subtitle,
.sidebar-label,
.league-label,
.crumbs,
.meta-label,
.table th,
.search-results button small {
  color: var(--muted);
}

.brand-subtitle {
  font-size: 0.9rem;
}

.sidebar-search {
  position: relative;
}

.sidebar-search input,
.toolbar input,
.toolbar select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
}

.search-results {
  position: absolute;
  z-index: 20;
  inset: calc(100% + 8px) 0 auto;
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 14px;
  background: #0f1720;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.search-results.hidden {
  display: none;
}

.search-results button {
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.search-results button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.search-results button.is-active {
  background: rgba(56, 189, 248, 0.18);
  outline: 1px solid rgba(56, 189, 248, 0.35);
}

.sidebar-group {
  margin-top: 28px;
}

.sidebar-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  margin-bottom: 10px;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 13px 14px;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
  margin-bottom: 6px;
}

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

.content {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar-main {
  flex: 1;
  min-width: 0;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.crumbs {
  font-size: 0.95rem;
}

#topbar-tools {
  margin-top: 18px;
}

.league-card {
  min-width: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.league-card strong {
  font-size: 1.4rem;
}

.league-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.freshness-badge.live {
  color: #d1fae5;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.12);
}

.freshness-badge.reconnecting {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
}

.freshness-badge.stale {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
}

.freshness-badge.connecting {
  color: #cbd5f5;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.12);
}

.league-updated {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  border: 1px solid var(--border);
  background: rgba(20, 26, 34, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
}

.stat-card strong {
  display: block;
  font-size: 1.5rem;
  margin-top: 6px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.currency-toolbar select:disabled {
  opacity: 0.9;
  cursor: not-allowed;
}

.table-card {
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 15px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.table th {
  text-align: left;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.item-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.exchange-value-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1;
}

.exchange-value-inline > span {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.exchange-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  overflow: hidden;
  vertical-align: middle;
}

.exchange-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
}

.exchange-icon-tier {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 9px;
  padding: 0 1px;
  border-radius: 4px 0 0 0;
  background: rgba(8, 12, 18, 0.82);
  color: #ffffff;
  font-size: 0.42rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.exchange-icon-fallback {
  font-size: 0.85rem;
  color: var(--muted);
}

.item-link:hover {
  color: var(--accent-2);
}

.item-cell,
.item-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-cell {
  flex-wrap: wrap;
}

.item-detail-header {
  justify-content: space-between;
  margin-bottom: 10px;
}

.copy-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.copy-button:hover {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.12);
}

.copy-button.is-copied {
  color: var(--accent);
  border-color: rgba(74, 222, 128, 0.55);
  background: rgba(74, 222, 128, 0.14);
}

.copy-button svg {
  width: 14px;
  height: 14px;
}

.rate-value {
  font-size: 1.2rem;
  font-weight: 700;
}

.subtext {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.profit-positive {
  color: var(--accent);
  font-weight: 700;
}

.trend-positive {
  color: var(--accent);
  font-weight: 700;
}

.trend-negative {
  color: #f87171;
  font-weight: 700;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.stack {
  display: grid;
  gap: 18px;
}

.item-timeline {
  display: grid;
  gap: 12px;
}

.timeline-entry {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.timeline-entry h4 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.timeline-entry p {
  margin: 6px 0;
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .hero-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .league-card {
    width: 100%;
  }
}
