:root {
  color-scheme: dark;
  --bg-canvas: #111317;
  --bg-tile: #181B20;
  --border-tile: #242830;
  --text-primary: #F3F4F6;
  --text-muted: #9CA3AF;
  --lime: #A3E635;
  --lemon: #FACC15;
  --coral: #F87171;
  --grad-accent: linear-gradient(135deg, #A3E635 0%, #FACC15 100%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #2A2F37 transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #2A2F37; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #3F4652; }
body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-tile);
  background: rgba(17, 19, 23, 0.94);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}

.pulse-wrap {
  position: relative;
  width: 10px;
  height: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  transition: background 0.2s ease;
}
.pulse-dot.online { background: var(--lime); }
.pulse-dot.offline { background: var(--coral); }

.pulse-ring {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}
.pulse-ring.ping-online {
  border: 2px solid var(--lime);
  animation: radar-ping 0.95s ease-out;
}
.pulse-ring.ping-offline {
  border: 2px solid var(--coral);
  animation: radar-ping 0.95s ease-out;
}
@keyframes radar-ping {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(2.8); opacity: 0; }
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border-tile);
  background: var(--bg-tile);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover { color: var(--lime); border-color: rgba(163, 230, 53, 0.45); }
.icon-btn.spin svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  top: 58px;
  right: 20px;
  background: var(--bg-tile);
  border: 1px solid var(--border-tile);
  color: var(--lime);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 60;
}
.toast.show { opacity: 1; }

.container { max-width: 1380px; margin: 0 auto; padding: 16px 16px 86px; }
.page { display: none; }
.page.active { display: block; }

.bento-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.tile {
  background: var(--bg-tile);
  border: 1px solid var(--border-tile);
  border-radius: 14px;
  padding: 16px;
}
.span-12 { grid-column: span 12; }
.span-6 { grid-column: span 6; }
@media (max-width: 980px) { .span-6 { grid-column: span 12; } }

.tile-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}
.tile-title {
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}
@media (max-width: 780px) { .kpi-strip { grid-template-columns: repeat(2, minmax(120px, 1fr)); } }
.kpi-box {
  background: #12151A;
  border: 1px solid var(--border-tile);
  border-radius: 10px;
  padding: 10px 12px;
}
.kpi-lbl { color: var(--text-muted); font-size: 0.71rem; margin-bottom: 3px; }
.kpi-val { font-size: 1.04rem; font-weight: 700; }

.pos { color: var(--lime); }
.neg { color: var(--coral); }
.grad-text {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero-ticker { font-size: 1.45rem; font-weight: 800; letter-spacing: 0.02em; }
.hero-meta { color: var(--text-muted); font-size: 0.82rem; }
.hero-levels { display: flex; gap: 14px; font-size: 0.82rem; font-weight: 600; align-items: center; flex-wrap: wrap; }

.chart-box { width: 100%; height: 410px; border-radius: 10px; overflow: hidden; }
.eq-chart-box { width: 100%; height: 300px; border-radius: 10px; overflow: hidden; }

.empty-state {
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-tile);
  border-radius: 10px;
  gap: 6px;
}
.empty-state strong { color: var(--text-primary); font-size: 0.98rem; font-weight: 600; }
.empty-state span { font-size: 0.78rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.81rem; }
th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-tile);
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--lime); }
td { padding: 8px 10px; border-bottom: 1px solid rgba(36, 40, 48, 0.7); white-space: nowrap; }
tr:last-child td { border-bottom: none; }

.ctrl-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}
.pill-btn {
  background: #12151A;
  color: var(--text-muted);
  border: 1px solid var(--border-tile);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.pill-btn.active {
  background: var(--grad-accent);
  color: #111317;
  border-color: transparent;
}
.inp, select, input[type="date"], input[type="number"], input[type="text"] {
  background-color: #14171C;
  color: var(--text-primary);
  border: 1px solid #2A2F37;
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 0.75rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.inp:focus, select:focus, input:focus {
  outline: none;
  border-color: #A3E635;
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

.filter-drawer {
  display: none;
  margin-bottom: 10px;
}
.filter-drawer.open { display: flex; }

.filter-btn-wrap { position: relative; display: inline-flex; }
.filter-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--grad-accent);
  color: #111317;
  font-size: 0.64rem;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
}
.filter-badge.show { display: inline-flex; }
.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 12px;
  background: #12151A;
  border: 1px solid var(--border-tile);
  border-radius: 9px;
  margin-bottom: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.summary-strip b { color: var(--text-primary); }

.res-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: #12151A;
  border: 1px solid var(--border-tile);
  color: var(--lime);
}

.floating-dock {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 50;
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(24, 27, 32, 0.92);
  border: 1px solid var(--border-tile);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.dock-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dock-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.dock-btn.active { background: var(--grad-accent); color: #111317; }
