:root {
  --bg: #000000;
  --bg-2: #0a0d12;
  --bg-3: #141923;
  --grid: #1a1f2a;
  --border: #1f242f;
  --text: #d6dae3;
  --text-dim: #6b7280;
  --accent: #3b82f6;
  --bid: #22c55e;
  --ask: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-columns: 260px 1fr;
  font: 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

aside#sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
aside header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 8px;
}
aside header h1 { font-size: 18px; margin: 0; letter-spacing: 1px; }
aside header .sub { color: var(--text-dim); font-size: 11px; }

#search {
  margin: 10px 12px;
  padding: 8px 10px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; outline: none;
}
#search:focus { border-color: var(--accent); }

#securities { list-style: none; margin: 0; padding: 0 4px 12px; overflow-y: auto; flex: 1; }
#securities li {
  padding: 7px 12px; border-radius: 4px; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
}
#securities li:hover { background: var(--bg-3); }
#securities li.active { background: #1e293b; }
#securities li .code { font-weight: 600; font-size: 12px; }
#securities li .name { color: var(--text-dim); font-size: 11px; }

main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }

#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2); gap: 12px;
}
.ticker-info #ticker-code { font-weight: 700; font-size: 16px; margin-right: 10px; }
.ticker-info #ticker-name { color: var(--text-dim); font-size: 12px; margin-right: 14px; }
.ticker-info #ticker-meta { color: var(--text-dim); font-size: 11px; }

.controls { display: flex; gap: 12px; align-items: center; }
.controls label {
  display: flex; gap: 6px; align-items: center;
  color: var(--text-dim); font-size: 11px;
}
.controls input, .controls select {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 7px; font-size: 12px; font-family: inherit;
  outline: none; color-scheme: dark;
}
.controls button {
  background: var(--accent); border: none; color: white;
  padding: 6px 14px; border-radius: 4px; cursor: pointer;
  font-size: 12px; font-weight: 500;
}
.controls button:hover { filter: brightness(1.1); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: ui-monospace, Menlo, monospace;
  cursor: default;
}
.status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #6b7280;
}
.status.idle .dot { background: #6b7280; }
.status.fresh .dot { background: var(--bid); box-shadow: 0 0 6px var(--bid); }
.status.running .dot {
  background: #facc15;
  box-shadow: 0 0 6px #facc15;
  animation: pulse 1.2s ease-in-out infinite;
}
.status.error .dot { background: var(--ask); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#chart-wrap {
  position: relative;
  min-height: 0;
  background: var(--bg);
}
#chart { width: 100%; height: 100%; display: block; }

#tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(8, 12, 20, 0.96);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 9px;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  display: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
#tooltip strong { color: #fff; }
#tooltip .row { display: flex; justify-content: space-between; gap: 14px; }
#tooltip .bid { color: var(--bid); }
#tooltip .ask { color: var(--ask); }
