:root {
  --bg: #0a0f0a;
  --card: #0d120d;
  --border: #1a2f1a;
  --primary: #00ff41;
  --primary-dim: #00aa2a;
  --muted: #3a5f3a;
  --text: #b8e6b8;
  --error: #ff4141;
  --warning: #ffaa00;
}

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

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 255, 65, 0.08), transparent),
    linear-gradient(rgba(0, 255, 65, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 50px 50px, 50px 50px;
  background-attachment: fixed;
}

/* Scanline effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to bottom, transparent, var(--primary), transparent);
  opacity: 0.1;
  animation: scanline 8s linear infinite;
  pointer-events: none;
  z-index: 1000;
}

@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100vh);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--card);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 18, 13, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 100;
}

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

.logo-icon {
  width: 40px;
  height: 40px;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: bold;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.3), inset 0 0 15px rgba(0, 255, 65, 0.1);
  text-shadow: 0 0 10px var(--primary);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
}

.logo-sub {
  font-size: 0.625rem;
  color: var(--muted);
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.market-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
}

.status-dot.open {
  background: var(--primary);
  animation: pulse 2s infinite;
  box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.clock {
  font-size: 0.875rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

/* Market Ticker */
.ticker-container {
  background: rgba(13, 18, 13, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.ticker-track {
  display: flex;
  width: max-content;
  animation: marquee 40s linear infinite;
}

@keyframes marquee {
  0% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(-25%);
  }
}

.ticker-track:hover {
  animation-play-state: paused;
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.ticker-symbol {
  color: var(--muted);
}

.ticker-price {
  font-weight: 600;
}

.ticker-change {
  font-size: 0.625rem;
}

.ticker-change.positive {
  color: var(--primary);
}

.ticker-change.negative {
  color: var(--error);
}

/* Main Layout */
.main {
  display: grid;
  grid-template-columns: 280px 1fr 380px;
  gap: 1rem;
  padding: 1rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 1400px) {
  .main {
    grid-template-columns: 260px 1fr 340px;
  }
}

@media (max-width: 1200px) {
  .main {
    grid-template-columns: 1fr 1fr;
    overflow-y: auto;
  }
  .sidebar {
    grid-column: 1 / -1;
    max-height: 250px;
  }
  .terminal {
    min-height: 400px;
  }
  .detail-panel {
    min-height: 400px;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0.5rem 1rem;
  }
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  .logo-text {
    font-size: 1rem;
  }
  .header-right {
    gap: 0.75rem;
  }
  .market-status {
    font-size: 0.625rem;
  }
  .clock {
    font-size: 0.75rem;
  }
  .main {
    grid-template-columns: 1fr;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .sidebar {
    max-height: 200px;
  }
  .terminal {
    min-height: 350px;
  }
  .detail-panel {
    min-height: 350px;
  }
}

/* Sidebar - Stock Cards */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-header {
  font-size: 0.625rem;
  color: var(--muted);
  letter-spacing: 2px;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stock-card {
  background: rgba(13, 18, 13, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.stock-card:hover,
.stock-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.15), 0 0 60px rgba(0, 255, 65, 0.05);
  transform: translateX(4px);
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.stock-symbol {
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
}

.stock-name {
  font-size: 0.625rem;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-price {
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stock-change {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.stock-change.positive {
  color: var(--primary);
}

.stock-change.negative {
  color: var(--error);
}

.remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.stock-card:hover .remove-btn {
  opacity: 1;
}

.remove-btn:hover {
  color: var(--error);
}

/* Terminal */
.terminal {
  background: rgba(13, 18, 13, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 0 40px rgba(0, 255, 65, 0.05), inset 0 0 60px rgba(0, 0, 0, 0.3);
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0, 255, 65, 0.05), rgba(0, 255, 65, 0.01));
  flex-shrink: 0;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
}

.terminal-dot:nth-child(1) {
  background: #ff5f56;
}

.terminal-dot:nth-child(2) {
  background: #ffbd2e;
}

.terminal-dot:nth-child(3) {
  background: #27ca40;
}

.terminal-title {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.terminal-logs {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  font-size: 0.8125rem;
  min-height: 0;
}

.log-line {
  margin-bottom: 2px;
  line-height: 1.5;
  word-break: break-word;
}

.log-line.info {
  color: var(--text);
}

.log-line.success {
  color: var(--primary);
}

.log-line.error {
  color: var(--error);
}

.log-line.warning {
  color: var(--warning);
}

.log-line.system {
  color: var(--primary-dim);
}

.log-timestamp {
  color: var(--muted);
  font-size: 0.6875rem;
  margin-right: 0.5rem;
}

.terminal-input-container {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.terminal-prompt {
  color: var(--primary);
  margin-right: 0.5rem;
  font-weight: 600;
  text-shadow: 0 0 10px var(--primary);
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
}

.terminal-input::placeholder {
  color: var(--muted);
}

/* Detail Panel */
.detail-panel {
  background: rgba(13, 18, 13, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.03);
}

.detail-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.detail-symbol {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
}

.detail-name {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.detail-exchange {
  font-size: 0.625rem;
  color: var(--primary-dim);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.detail-price-section {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-top: 0.75rem;
}

.detail-price {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail-change {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.detail-change.positive {
  color: var(--primary);
}

.detail-change.negative {
  color: var(--error);
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  margin: 1rem;
  border: 1px solid var(--border);
}

.stat-item {
  background: var(--card);
  padding: 0.75rem;
}

.stat-label {
  font-size: 0.625rem;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Chart */
.chart-container {
  padding: 1rem;
}

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

.chart-timeframes {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.timeframe-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.375rem 0.75rem;
  font-family: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.timeframe-btn:hover,
.timeframe-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

.chart-svg {
  width: 100%;
  height: 200px;
}

.chart-line {
  fill: none;
  stroke-width: 2;
}

.chart-line.positive {
  stroke: var(--primary);
}

.chart-line.negative {
  stroke: var(--error);
}

.chart-area {
  opacity: 0.1;
}

.chart-area.positive {
  fill: var(--primary);
}

.chart-area.negative {
  fill: var(--error);
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.quick-btn {
  background: rgba(0, 255, 65, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.375rem 0.75rem;
  font-family: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quick-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.2);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted);
  text-align: center;
  height: 100%;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Code styling */
code {
  background: rgba(0, 255, 65, 0.1);
  padding: 0.125rem 0.375rem;
  border-radius: 2px;
  font-family: inherit;
  color: var(--primary);
}

/* PWA Install prompt */
@media (display-mode: standalone) {
  .header {
    padding-top: env(safe-area-inset-top, 0.75rem);
  }
}
