:root {
  --bg: #06090f;
  --bg2: #0a0f1a;
  --panel: rgba(14, 20, 32, 0.82);
  --panel-border: rgba(100, 160, 255, 0.10);
  --panel-hover: rgba(100, 160, 255, 0.04);
  --text: #e8eef8;
  --muted: #7a8fad;
  --green: #2cff9f;
  --green-dim: rgba(44, 255, 159, 0.12);
  --yellow: #ffd84d;
  --yellow-dim: rgba(255, 216, 77, 0.12);
  --red: #ff5f77;
  --red-dim: rgba(255, 95, 119, 0.12);
  --blue: #66b3ff;
  --blue-dim: rgba(102, 179, 255, 0.10);
  --cyan: #5ef5e8;
  --glow: 0 0 40px rgba(102, 179, 255, 0.06);
  --radius: 14px;
}

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

body {
  background:
    radial-gradient(ellipse at 10% 0%, rgba(0, 100, 255, 0.07), transparent 40%),
    radial-gradient(ellipse at 90% 5%, rgba(44, 255, 159, 0.04), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  background: rgba(6, 9, 15, 0.88);
  border-bottom: 1px solid var(--panel-border);
  padding: 16px 24px 14px;
}

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

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
}

.live-tag {
  font-size: 11px;
  font-weight: 700;
  background: var(--green-dim);
  color: var(--green);
  padding: 2px 8px;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: 0.08em;
}

.subline {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.pulse-wrap {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(44, 255, 159, 0.06);
}

.pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px rgba(44, 255, 159, 0.7);
  animation: pulse-anim 2s infinite ease-in-out;
}

.pulse.delayed {
  background: var(--yellow);
  box-shadow: 0 0 16px rgba(255, 216, 77, 0.7);
}

.pulse.stale, .pulse.unknown {
  background: var(--red);
  box-shadow: 0 0 16px rgba(255, 95, 119, 0.7);
  animation: none;
}

@keyframes pulse-anim {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
}

.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 12px;
  flex: 1 1 100px;
  min-width: 95px;
}

.stat .label {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.stat .value {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.thoughts-panel {
  margin: 10px 24px;
  background: linear-gradient(135deg, rgba(14, 20, 32, 0.9), rgba(20, 28, 44, 0.85));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--glow), inset 0 1px 0 rgba(102, 179, 255, 0.04);
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

.thoughts-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--panel-border);
}

.thoughts-icon {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(94, 245, 232, 0.5);
  animation: thought-pulse 3s infinite ease-in-out;
}

@keyframes thought-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(94, 245, 232, 0.5); }
  50% { opacity: 0.4; box-shadow: 0 0 3px rgba(94, 245, 232, 0.2); }
}

.thoughts-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-transform: uppercase;
}

.thoughts-cursor {
  display: inline-block;
  width: 2px;
  height: 12px;
  background: var(--cyan);
  animation: blink-cursor 1s steps(1) infinite;
  margin-left: auto;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.thoughts-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 24px;
}

.thought-line {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
  padding: 3px 0 3px 12px;
  border-left: 2px solid rgba(94, 245, 232, 0.12);
  opacity: 0.88;
}

.thought-line.highlight {
  color: var(--cyan);
  border-left-color: var(--cyan);
}

.thought-line.position {
  border-left-color: var(--green);
}

.thought-line.caution {
  border-left-color: var(--yellow);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px 24px 30px;
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-height: 160px;
  box-shadow: var(--glow);
  overflow: hidden;
}

.panel-scanner { grid-column: span 2; }
.panel-positions { grid-column: span 2; }

.panel h2 {
  font-size: 12px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-body { max-height: 500px; overflow-y: auto; }
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 4px; }

.feed-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 13px;
}
.feed-item:last-child { border-bottom: none; }
.feed-item .feed-time { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.feed-item .feed-text { margin-top: 2px; }

.scanner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.scanner-table th {
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
  white-space: nowrap;
}
.scanner-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  white-space: nowrap;
}
.scanner-table tr:hover { background: var(--panel-hover); }

.positions-table, .history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.positions-table th, .history-table th {
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
  white-space: nowrap;
}
.positions-table td, .history-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  white-space: nowrap;
}
.positions-table tr:hover, .history-table tr:hover { background: var(--panel-hover); }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-green { background: var(--green-dim); color: var(--green); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-muted { background: rgba(122,143,173,0.1); color: var(--muted); }

.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }
.mono { font-family: 'JetBrains Mono', monospace; }

.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.perf-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.perf-card .perf-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.perf-card .perf-value {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.campaign-card {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.campaign-card:last-child { border-bottom: none; }
.campaign-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.campaign-events {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 13px;
}
.source-row:last-child { border-bottom: none; }

.score-bar {
  width: 40px;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px 0;
  font-size: 13px;
}

.footer {
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  border-top: 1px solid var(--panel-border);
  background: rgba(6, 9, 15, 0.6);
}

@media (max-width: 1000px) {
  .grid { grid-template-columns: 1fr; }
  .panel-feed { grid-row: auto; }
  .panel-scanner { grid-column: auto; }
  .status-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
