* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', Arial, sans-serif; background: #f5f5f5; color: #222; font-size: 14px; }

/* -- Header -- */
header {
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
header h1 { font-size: 17px; }
header p  { font-size: 12px; color: #888; }

.header-status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: #888; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; transition: background .3s; }
.dot.ready   { background: #22c55e; }
.dot.loading { background: #f59e0b; animation: pulse .8s infinite alternate; }
.dot.error   { background: #ef4444; }
@keyframes pulse { to { opacity: .4; } }

/* -- Tabs -- */
.tabs { background: white; border-bottom: 1px solid #ddd; display: flex; padding: 0 24px; }
.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  color: #666;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  margin-bottom: -1px;
  font-family: inherit;
  transition: color .2s;
}
.tab-btn:hover  { color: #222; }
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

/* -- Controls bar -- */
.controls-bar {
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.control-label { font-size: 12px; color: #666; font-weight: bold; }
.control-value { font-size: 12px; color: #222; font-weight: 600; min-width: 32px; }

.controls-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  border: 1px solid #c7d7ff;
  background: #f0f4ff;
  color: #2563eb;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity .2s;
  user-select: none;
}
.chip:hover { opacity: .7; }
.chip.disabled { opacity: .35; text-decoration: line-through; }

.ticker-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  width: 80px;
  font-family: inherit;
}
.ticker-input:focus { border-color: #2563eb; outline: none; }

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.btn-small:hover { background: #f5f5f5; }

.inline-select {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  font-family: inherit;
  background: white;
  cursor: pointer;
}
.inline-select:focus { border-color: #2563eb; outline: none; }

.inline-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  width: 60px;
  font-family: inherit;
}
.inline-input:focus { border-color: #2563eb; outline: none; }

.window-group { display: flex; gap: 3px; }
.win-btn {
  padding: 3px 9px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  color: #555;
  transition: all .15s;
}
.win-btn.active { background: #2563eb; color: white; border-color: #2563eb; }

.btn-load {
  margin-left: auto;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: bold;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-load:hover    { background: #1d4ed8; }
.btn-load:disabled { background: #93c5fd; cursor: not-allowed; }

/* -- Layout -- */
.main { padding: 20px 24px 40px; }
.panel { display: none; }
.panel.active { display: block; }

.section-title { font-size: 15px; font-weight: bold; margin-bottom: 4px; }
.section-desc  { font-size: 12px; color: #666; margin-bottom: 16px; line-height: 1.6; }

/* -- KPI row -- */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.kpi-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 18px;
  min-width: 120px;
  flex: 1;
}
.kpi-label { font-size: 11px; color: #888; font-weight: bold; margin-bottom: 4px; text-transform: uppercase; }
.kpi-value { font-size: 20px; font-weight: bold; color: #111; }
.kpi-value.green { color: #16a34a; }
.kpi-value.red   { color: #dc2626; }
.kpi-value.blue  { color: #2563eb; }

/* -- Cards -- */
.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}
.card-header {
  padding: 11px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title    { font-size: 13px; font-weight: bold; }
.card-subtitle { font-size: 11px; color: #888; margin-left: auto; }
.card-body     { padding: 16px; }

/* -- Grids -- */
.grid-2   { display: grid; grid-template-columns: 1fr 1fr;     gap: 16px; margin-bottom: 16px; }
.grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr;     gap: 16px; margin-bottom: 16px; }

.chart-wrap { width: 100%; overflow: hidden; position: relative; }
svg.chart   { width: 100%; display: block; }

.empty { text-align: center; padding: 40px 20px; color: #aaa; font-size: 13px; }

/* -- Tables -- */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.stats-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
}
.stats-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.stats-table tr:hover td { background: #f8faff; }
.stats-table .ticker-cell { font-weight: 700; }
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table .pos { color: #16a34a; }
.stats-table .neg { color: #dc2626; }

/* -- Tooltip -- */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(0,0,0,.82);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  transition: opacity .15s;
}
.tooltip.visible { opacity: 1; }

/* -- Legend -- */
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #555; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* -- Toggle label -- */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] { cursor: pointer; }

/* -- Range input -- */
input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  outline: none;
  width: 120px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
}

@media (max-width: 900px) {
  .grid-2, .grid-2-1, .grid-3 { grid-template-columns: 1fr; }
}
