/* Stock Watcher — multi-ticker dashboard. Dark trading-terminal theme. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1a2e;
  --panel: #16213e;
  --input: #0f1630;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e0e0f0;
  --muted: #8a8ab0;
  --up: #26a69a;
  --down: #ef5350;
  --grid: rgba(255, 255, 255, 0.07);
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
#brand { display: flex; align-items: center; gap: 8px; }
#logo { color: var(--up); font-size: 18px; }
#brand h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }

#watch-form { display: flex; gap: 6px; }
#ticker-input {
  width: 150px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: monospace;
  font-size: 14px;
  padding: 7px 10px;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s;
}
#ticker-input:focus { border-color: var(--up); }
#ticker-input::placeholder { color: var(--muted); }
#watch-btn {
  background: var(--up);
  color: #06211f;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
  transition: filter 0.15s;
}
#watch-btn:hover { filter: brightness(1.15); }

#chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: monospace;
  font-size: 12px;
  font-weight: 600;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--up); color: var(--up); }
.chip.active { border-color: var(--up); color: var(--up); }

/* ---------- grid ---------- */
#grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 12px;
  padding: 12px 16px 16px;
  align-content: start;
}
@media (max-width: 480px) {
  #grid { grid-template-columns: 1fr; }
}

/* ---------- panel ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 350px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panel-in 0.25s ease;
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel.removing { animation: panel-out 0.2s ease forwards; }
@keyframes panel-out {
  to { opacity: 0; transform: scale(0.97); }
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-title { display: flex; align-items: center; gap: 8px; }
.panel-sym {
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
}
.panel-price {
  font-family: monospace;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.panel-change {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.panel-change.up { color: var(--up); }
.panel-change.down { color: var(--down); }
.panel-error {
  flex: 1;
  font-size: 12px;
  color: var(--down);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-remove {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 5px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.panel-remove:hover { color: var(--down); border-color: var(--down); }

/* range buttons */
.range-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  width: 100%;
  padding-bottom: 2px;
}
.range-btn {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.range-btn:hover { color: var(--text); border-color: var(--muted); }
.range-btn.active { color: var(--up); border-color: var(--up); background: rgba(38, 166, 154, 0.12); }

/* live dot */
.live-dot {
  width: 8px;
  height: 8px;
  background: var(--up);
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
.live-dot.hidden { display: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

/* canvas wrap + canvas + tooltip */
.chart-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}
.chart-wrap canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: crosshair;
}
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 22, 48, 0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  z-index: 3;
}
.tooltip .tt-sym { font-weight: 700; letter-spacing: 1px; }
.tooltip .tt-up { color: var(--up); }
.tooltip .tt-down { color: var(--down); }
.tooltip .tt-mut { color: var(--muted); }

/* empty state */
.empty-note {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px 0;
}

#global-range {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #16213e;
  border-bottom: 1px solid #0f1630;
}
.gr-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-right: 6px;
}
.gr-btn {
  background: #0f1630;
  border: 1px solid #2a2a4a;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s;
}
.gr-btn:hover { border-color: var(--green); color: var(--text); }
.gr-btn.active { background: var(--green); color: #08111a; border-color: var(--green); }
