body {
  font-family: Arial, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  margin: 0;
}

.container {
  max-width: 1520px;
  margin: 0 auto;
  padding: 24px;
  padding-top: calc(var(--topbar-height, 96px) + 16px);
}

.card {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-collapsible-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-collapse-btn {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0;
  width: 24px;
  height: 24px;
  line-height: 1;
  font-size: 16px;
  font-weight: 700;
}

.card-collapse-btn:hover {
  background: #cbd5e1;
}

.card-collapsed .card-collapsible-content {
  display: none;
}

.metrics {
  display: flex;
  justify-content: center;
  gap: 36px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.gauge-panel {
  position: relative;
  text-align: center;
}

.gauge-panel h3 {
  position: relative;
  display: inline-block;
  padding-right: 54px;
}

.gauge-head-icons {
  position: absolute;
  top: -1px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.top-stats {
  display: block;
}

.sticky-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background: #ffffff;
  border-bottom: 1px solid #d1d5db;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
  padding: 8px 10px;
  margin-bottom: 16px;
  box-sizing: border-box;
  width: 100%;
}

.top-actions {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 4px;
}

.compact-actions {
  gap: 8px;
  align-items: center;
}

.app-brand {
  color: #0f172a;
  font-weight: 700;
  font-size: 14px;
  margin-right: 6px;
  white-space: nowrap;
}

.app-brand small {
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
}

.compact-btn {
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.1;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
  color: #0f172a;
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: #334155;
}

.sync-indicator[hidden] {
  display: none !important;
}

.sync-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.tiny-btn {
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.1;
  background: #1e293b;
}

.tiny-btn:hover {
  background: #334155;
}

.asof-nav {
  gap: 4px;
}

.top-range {
  gap: 4px;
}

.asof-jump {
  gap: 4px;
}

.asof-jump input[type="date"] {
  padding: 4px 6px;
  font-size: 12px;
}

.asof-slider-wrap {
  margin-top: 4px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 6px 10px 8px;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.timeline-label {
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #2563eb;
}

.timeline-current {
  font-size: 12px;
  color: #0f172a;
  font-weight: 700;
}

.timeline-ends {
  margin-top: 3px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #64748b;
}

.asof-slider-wrap input[type="range"] {
  width: 100%;
  max-width: 100%;
  display: block;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

.compact-slider input[type="range"] {
  height: 24px;
}

.compact-slider {
  overflow: hidden;
}

.compact-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #334155, #475569);
}

.compact-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-top: -5px;
  background: #60a5fa;
  border: 2px solid #dbeafe;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
  cursor: ew-resize;
}

.compact-slider input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #334155, #475569);
}

.compact-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #60a5fa;
  border: 2px solid #dbeafe;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
  cursor: ew-resize;
}

.compact-slider input[type="range"]:hover::-webkit-slider-thumb,
.compact-slider input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.28);
}

.compact-slider input[type="range"]:hover::-moz-range-thumb,
.compact-slider input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.28);
}

.gauge {
  position: relative;
  width: 220px;
  height: 170px;
  margin-top: 8px;
}

.gauge-svg {
  width: 220px;
  height: 140px;
  display: block;
}

.gauge-track {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 14;
  stroke-linecap: round;
}

.gauge-progress {
  fill: none;
  stroke: var(--gauge-color);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset 450ms ease;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--gauge-color) 35%, transparent));
}

.gauge-needle {
  stroke: #475569;
  stroke-width: 3;
  stroke-linecap: round;
  transform-origin: 110px 120px;
  transition: transform 450ms ease;
}

.gauge-cap {
  fill: #f8fafc;
  stroke: #94a3b8;
  stroke-width: 3;
}

.gauge-label {
  fill: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}

.gauge-label-mid {
  fill: #334155;
}

.gauge-value {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  text-align: center;
  margin: 0;
  font-size: 32px;
  font-weight: 800;
}

.factor-gauges {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.factor-toggle-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 10px;
}

.factor-gauges-category {
  width: 100%;
  margin-bottom: 18px;
}

.factor-gauges-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}

.factor-gauges-category-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.factor-category-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.factor-category-toggle-btn {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 10px;
  line-height: 1;
  padding: 3px 7px;
  cursor: pointer;
  text-transform: lowercase;
}

.factor-category-toggle-btn:hover {
  background: #eef2ff;
  border-color: #93c5fd;
}

.factor-gauges-category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1400px) {
  .factor-gauges-category-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .factor-gauges-category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .factor-gauges-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .factor-gauges-category-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

.factor-gauge-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 8px 4px;
  text-align: center;
}

.factor-gauge-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  margin: 0 0 2px;
}

.factor-gauge-left-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.factor-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.factor-toggle-switch {
  position: relative;
  display: inline-flex;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  user-select: none;
  cursor: pointer;
}

.factor-toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.factor-toggle-slider::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: transform 120ms ease;
}

.factor-toggle-input:checked + .factor-toggle-slider {
  background: #2563eb;
  border-color: #2563eb;
}

.factor-toggle-input:checked + .factor-toggle-slider::before {
  transform: translateX(12px);
}

.factor-toggle-input:focus-visible + .factor-toggle-slider {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.factor-gauge-asof {
  font-size: 10px;
  line-height: 1.25;
  color: #64748b;
  text-align: left;
  text-transform: lowercase;
  letter-spacing: 0.01em;
}

.factor-gauge-card.factor-disabled {
  opacity: 0.72;
}

.factor-gauge-title {
  margin: 0;
  font-size: 13px;
  color: #0f172a;
  text-align: center;
}

.trend-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid transparent;
  box-sizing: border-box;
  font-family: "Segoe UI Symbol", "Segoe UI", "Noto Sans", sans-serif;
  user-select: none;
}

.factor-gauge-icons {
  position: static;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hint-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  line-height: 1;
  background: transparent;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.hint-trigger:hover {
  transform: none;
}

.hint-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.hint-popover {
  position: absolute;
  right: 8px;
  top: 30px;
  z-index: 12;
  width: min(280px, calc(100vw - 40px));
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

.gauge-hint-popover {
  top: 26px;
  right: 0;
}

.gauge-trend-explain-popover {
  top: 26px;
  right: 0;
}

.factor-gauge-card .gauge-hint-popover,
.factor-gauge-card .gauge-trend-explain-popover {
  top: 38px;
}

.trend-explain-popover {
  white-space: pre-line;
}

.trend-explain-trigger {
  cursor: help;
}

.trend-up {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

.trend-down {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
}

.trend-flat {
  color: #334155;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.trend-na {
  color: #64748b;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.info-icon {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #93c5fd;
}

.hint-trigger.info-icon:hover {
  color: #1e40af;
  background: #bfdbfe;
  border-color: #60a5fa;
}

.factor-gauge-sub {
  margin: -2px 0 2px;
  font-size: 11px;
  color: #64748b;
}

.gauge-tick-minor {
  stroke: #64748b;
  stroke-width: 1.2;
  opacity: 0.85;
}

.gauge-tick-major {
  stroke: #94a3b8;
  stroke-width: 1.8;
  opacity: 0.95;
}

.gauge.bull {
  --gauge-color: #22c55e;
}

.gauge.bear {
  --gauge-color: #ef4444;
}

@media (max-width: 980px) {
  .metrics {
    gap: 12px;
  }
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hint {
  color: #64748b;
  font-size: 12px;
  margin-top: 8px;
}

button {
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

.rangeBtn {
  background: #64748b;
}

.rangeBtn:hover {
  background: #475569;
}

input[type="date"],
input[type="range"],
select {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px;
}

.chart-section .chart-guide-inline {
  margin: 0 0 10px;
}

.chart-section .chart-guide-hint {
  margin-top: 0;
  margin-bottom: 0;
}

.chart-section .chart-interaction-hint {
  margin-top: 8px;
  margin-bottom: 0;
}

.chart-controls-row {
  align-items: flex-end;
}

.prob-scale-fixed {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.2;
}

.chart-layer-picker-row {
  margin-top: 8px;
  gap: 8px;
  align-items: center;
}

.factor-picker-row,
.ticker-picker-row {
  flex-wrap: nowrap;
}

#factorDropdown {
  width: 180px;
}

.chart-layer-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
}

.chart-layer-picker-row input[type="text"] {
  min-width: 220px;
}

.ticker-search-modern {
  position: relative;
  flex: 0 0 250px;
  width: 250px;
  min-width: 180px;
  max-width: 250px;
}

.ticker-search-modern input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.ticker-suggestions-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}

.ticker-suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #0f172a;
  text-align: left;
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
}

.ticker-suggestion-item:hover {
  background: #eef2ff;
}

.ticker-suggestion-symbol {
  font-weight: 700;
  color: #1e293b;
}

.ticker-suggestion-name {
  font-size: 12px;
  color: #64748b;
}

.selected-layers-chips {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.layer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  background: #eef2ff;
  color: #1e293b;
  padding: 3px 8px;
  font-size: 12px;
}

.layer-chip-remove {
  border: 0;
  background: transparent;
  color: #334155;
  padding: 0 2px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.layer-chip-remove:hover {
  color: #b91c1c;
  background: transparent;
}

.layers-modal-open-btn {
  background: #334155;
}

.layers-modal-open-btn:hover {
  background: #1e293b;
}

.layers-summary-chip {
  display: inline-block;
  max-width: min(420px, 100%);
  padding: 6px 10px;
  font-size: 12px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 420px;
  margin-top: 8px;
}

.chart-tools-floating {
  position: absolute;
  right: 8px;
  top: -30px;
  display: inline-flex;
  gap: 6px;
  z-index: 24;
}

.chart-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.96);
  color: #334155;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.chart-icon-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

@media (max-width: 820px) {
  .ticker-search-modern {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    flex-basis: 100%;
  }
}

#addCustomOverlayBtn {
  flex-shrink: 0;
  margin-left: 10px;
}

.chart-icon-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

#historyChart {
  width: 100% !important;
  height: 100% !important;
  max-height: 100%;
  display: block;
}

.modal-layers {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 440px;
  width: calc(100vw - 32px);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
}

.modal-layers::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.modal-layers-inner {
  padding: 20px 22px;
}

.modal-layers-inner h4 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: #0f172a;
}

.modal-layers-lead {
  margin: 0 0 14px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.45;
}

.modal-layers-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

.show-select-layers {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 0;
  max-height: min(50vh, 320px);
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.45;
  padding: 6px 8px;
}

.show-select-layers option {
  padding: 3px 4px;
}

.chart-layers-help {
  margin: 10px 0 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.chart-layers-help kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

.modal-layers-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.modal-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
}

.modal-btn-primary {
  background: #2563eb;
  color: #fff;
}

.modal-btn-primary:hover {
  background: #1d4ed8;
}

.modal-btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.modal-btn-secondary:hover {
  background: #cbd5e1;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px;
  text-align: left;
}

tr.factor-category-row td {
  background: #f8fafc;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.factor-category-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.factor-id {
  font-size: 11px;
  color: #64748b;
  font-family: ui-monospace, monospace;
}

.factor-name {
  font-size: 13px;
  color: #0f172a;
}

