:root {
  --app-bg: #f4f6fb;
  --panel: #ffffff;
  --panel-muted: #f9fafb;
  --panel-alt: #f6f7fb;
  --panel-hover: #eef2f7;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --page-bg: radial-gradient(circle at top left, #dfe8ff, transparent 60%),
    radial-gradient(circle at bottom right, #ffe6d3, transparent 55%);
}

.theme-dark {
  --app-bg: #0b1020;
  --panel: #111827;
  --panel-muted: #0f172a;
  --panel-alt: #0f1a2a;
  --panel-hover: #1f2a3d;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #1f2937;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --page-bg: radial-gradient(circle at top left, rgba(30, 64, 175, 0.35), transparent 60%),
    radial-gradient(circle at bottom right, rgba(124, 45, 18, 0.4), transparent 55%);
}

body {
  background: var(--app-bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.page-bg {
  position: fixed;
  inset: 0;
  background: var(--page-bg);
  z-index: 0;
}

.container {
  z-index: 1;
}

.status-card {
  background: var(--panel);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.bazaar-panel {
  background: var(--panel);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.bazaar-status .badge {
  font-size: 0.75rem;
  font-weight: 600;
}

.ws-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.2);
}

.ws-dot-green {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.ws-dot-orange {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25);
}

.ws-dot-red {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25);
}

.ws-dot-blink {
  animation: ws-blink 0.6s ease-in-out infinite;
}

@keyframes ws-blink {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.bazaar-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.bazaar-controls .form-control {
  flex: 1;
}

.bazaar-controls .form-select {
  width: 180px;
}

.nav-select {
  min-width: 180px;
}

.bazaar-meta {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.bazaar-dropdown {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  background: var(--panel-muted);
}

.bazaar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  transition: background 0.15s ease;
}

.bazaar-item:nth-child(even) {
  background: var(--panel-alt);
}

.bazaar-item:last-child {
  border-bottom: none;
}

.bazaar-item:hover {
  background: var(--panel-hover);
}

.bazaar-thumb {
  width: 58px;
  height: 58px;
  border-radius: 0.75rem;
  background: #eef2ff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.bazaar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bazaar-thumb-fallback {
  font-weight: 700;
  color: #64748b;
}

.bazaar-details {
  flex: 1;
  min-width: 0;
}

.bazaar-name {
  font-weight: 600;
  color: var(--text);
}

.bazaar-id {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.bazaar-price {
  font-weight: 700;
  color: #0f766e;
  white-space: nowrap;
}

.bazaar-update {
  white-space: nowrap;
}

.bazaar-chart {
  white-space: nowrap;
}

.bazaar-chart.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.bazaar-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
}

.bazaar-tooltip {
  position: absolute;
  left: 80px;
  top: 100%;
  transform: translateY(6px);
  opacity: 0;
  pointer-events: none;
  background: #1f2937;
  color: #f8fafc;
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
  max-width: 320px;
  font-size: 0.75rem;
  line-height: 1.3;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
  z-index: 10;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.bazaar-item:hover .bazaar-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.chart-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 20;
}

.chart-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 1.5rem;
}

.chart-card {
  background: var(--panel);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
  width: min(900px, 100%);
  box-shadow: var(--shadow);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.chart-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.chart-subtitle {
  font-size: 0.85rem;
}

.chart-canvas {
  width: 100%;
  height: 360px;
  position: relative;
}

.toast-host {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 50;
}

.toast-card {
  background: #111827;
  color: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.3);
  font-weight: 600;
  font-size: 0.85rem;
}

.logs-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 80;
}

.logs-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.logs-modal-card {
  background: var(--panel);
  border-radius: 1rem;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.card {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.text-muted {
  color: var(--text-muted) !important;
}

.spinner-lg {
  width: 4rem;
  height: 4rem;
}

.revives-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.revives-status {
  margin-bottom: 0.75rem;
}

.chart-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  pointer-events: none;
  white-space: nowrap;
  transform: translateY(-6px);
}

.training-legend span {
  font-weight: 700;
}

.legend-strength {
  color: #ef4444;
}

.legend-speed {
  color: #facc15;
}

.legend-defense {
  color: #22c55e;
}

.legend-dexterity {
  color: #3b82f6;
}

.legend-divider {
  font-weight: 500;
  color: var(--text-muted);
}

.crime-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.crime-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.crime-legend-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  display: inline-block;
}

@media (max-width: 768px) {
  .chart-card canvas {
    width: 100%;
    height: 240px;
  }

  .chart-canvas {
    height: 240px;
  }
}

@media (max-width: 768px) {
  .bazaar-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .bazaar-price {
    font-size: 0.85rem;
  }
}
