:root {
  /* neutral dark gray, monokai accents */
  --bg: #0e0e0f;
  --panel: #22242a;  /* RGB(34,36,42), chart background */
  --border: #2f3138;
  --text: #e6e6e6;
  --muted: #8a8a8c;
  --up: #89c996;     /* RGB(137,201,150) */
  --down: #ec8a82;   /* RGB(236,138,130) */
  --accent: #c6c7ca; /* light gray (selected pill) */
  --accent-fg: #15161a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;          /* the grid fills the rest and never scrolls the page */
}

.toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;   /* 4 areas evenly spread */
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tb-right { display: flex; align-items: center; gap: 12px; }

.ranges { display: flex; gap: 4px; }
.ranges button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 14px;
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
}
.ranges button:hover { background: var(--panel); color: var(--text); }
.ranges button.active { background: var(--accent); color: var(--accent-fg); }

.status {
  color: var(--muted);
  font-size: 12px;
  width: 230px;            /* fixed, so "Loading…" vs "Updated …" never reflows the toolbar */
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}
.status.stale { color: var(--down); }

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 12px;
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }

/* full-height grid: rows/cols set in JS */
.grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 8px;
}

/* highlight the chart the mouse is over */
.card:hover {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.card-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card-head .sym { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.card-head .price { font-size: 20px; font-weight: 600; margin-left: auto; }
.card-head .chg { font-size: 13px; font-weight: 600; }

.up { color: var(--up); }
.down { color: var(--down); }

.chart {
  position: relative;            /* anchor for the tooltip */
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

/* crosshair tooltip on the dotted line */
.tip {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  padding: 2px 6px;
  background: #0b0b0c;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  display: none;
  z-index: 3;
}
.tip .t { color: var(--muted); margin-left: 6px; }

/* frozen crosshair (drawn by us, not uPlot) */
.vline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed rgba(230, 230, 230, 0.5);
  pointer-events: none;
  display: none;
  z-index: 2;
}
.dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--text);
  pointer-events: none;
  display: none;
  z-index: 3;
}

/* today's static stats, Google-style 3x3 */
.stats {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px 16px;
  margin-top: 6px;
  font-size: 11px;
}
.stats .row { display: flex; justify-content: space-between; gap: 8px; }
.stats .k { color: var(--muted); }
.stats .v { color: var(--text); }

.card.empty .chart {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.uplot .u-legend { display: none; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .grid { grid-template-columns: 1fr !important; grid-template-rows: none !important; }
  .card { min-height: 300px; }
}
