:root {
  --bg: #0a0d13;
  --bg-grad: radial-gradient(ellipse at top left, #11151f 0%, #0a0d13 60%);
  --panel: #111623;
  --panel-2: #161c2c;
  --panel-3: #1c2436;
  --border: #232b40;
  --border-soft: #1b2235;
  --text: #e3e8f3;
  --text-2: #c1c8d8;
  --muted: #7b859d;
  --muted-2: #5c6478;
  --accent: #4cc2ff;
  --accent-2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #4cc2ff 0%, #7c5cff 100%);
  --good: #3ddc97;
  --bad: #ff5c8a;
  --warn: #ffb547;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

body {
  display: flex;
  min-height: 100vh;
  background: var(--bg-grad);
  background-attachment: fixed;
}

code {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  background: rgba(76,194,255,0.08);
  border: 1px solid rgba(76,194,255,0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #b8e3ff;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px;
  background: rgba(17, 22, 35, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-soft);
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 0 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(76,194,255,0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 600; font-size: 14.5px; color: var(--text); letter-spacing: -0.2px; }
.brand-tag { font-size: 10.5px; color: var(--muted); margin-top: 2px; letter-spacing: 0.3px; text-transform: uppercase; }

nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 1px;
  overflow-y: auto;
}
.nav-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted-2);
  font-weight: 600;
  padding: 14px 12px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }
.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}
.nav-icon {
  display: inline-flex;
  width: 16px;
  justify-content: center;
  font-size: 12px;
  color: var(--muted-2);
  transition: color 140ms ease;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link:hover .nav-icon { color: var(--accent); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(76,194,255,0.16), rgba(124,92,255,0.10));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(76,194,255,0.25);
}
.nav-link.active .nav-icon { color: var(--accent); }

.sidebar-footer {
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.footer-line { color: var(--text-2); font-weight: 500; }
.footer-sub { color: var(--muted); }

/* ---------- Main ---------- */
.main {
  margin-left: 248px;
  flex: 1;
  padding: 0 28px 80px;
  max-width: calc(100vw - 248px);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(10, 13, 19, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 24px;
}
.topbar-grid {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(180px, 1.5fr) 138px 138px 130px auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 1200px) {
  .topbar-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
  .field-action { grid-column: span 4; }
  .field-tickers { grid-column: span 2; }
  .field-weights { grid-column: span 2; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field label .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--muted-2);
  font-size: 10px;
  padding: 1px 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
}

input, select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  width: 100%;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
input::placeholder { color: var(--muted-2); font-weight: 400; }
input:hover, select:hover { border-color: rgba(255,255,255,0.15); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-2);
  box-shadow: 0 0 0 3px rgba(76,194,255,0.18);
}
input[type="date"] {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.3px;
  color-scheme: dark;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 140ms ease;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator { opacity: 1; }
input[type="number"] {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-suffix input { padding-right: 28px; }
.input-with-suffix .suffix {
  position: absolute;
  right: 12px;
  font-size: 12px;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 500;
  pointer-events: none;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: background 140ms ease, border-color 140ms ease, transform 100ms ease, box-shadow 140ms ease;
}
button:hover { background: var(--panel-3); border-color: var(--accent); }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: #0a0d13;
  font-weight: 700;
  padding: 10px 22px;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 16px rgba(76,194,255,0.30), inset 0 1px 0 rgba(255,255,255,0.25);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
button.primary:hover {
  box-shadow: 0 8px 24px rgba(76,194,255,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
  transform: translateY(-1px);
}
button.primary:active { transform: translateY(0); }
button.primary .btn-icon {
  font-size: 9px;
  background: rgba(10,13,19,0.25);
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
}
.field-action button.primary { width: 100%; justify-content: center; }

.skipped {
  margin-top: 10px;
  font-size: 12px;
  color: var(--warn);
}

/* ---------- Sections ---------- */
.section {
  background: linear-gradient(180deg, rgba(22, 28, 44, 0.6), rgba(17, 22, 35, 0.6));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.section::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(76,194,255,0.4), rgba(124,92,255,0.4), transparent);
  opacity: 0.6;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.section h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
.section-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 400;
}

/* ---------- Metrics ---------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metrics-grid.two { grid-template-columns: 1fr 1fr; }
.metric-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
  transition: border-color 160ms ease, transform 160ms ease;
}
.metric-card:hover {
  border-color: rgba(76,194,255,0.35);
  transform: translateY(-1px);
}
.metric-card.highlight {
  border: 1px solid rgba(76,194,255,0.3);
  box-shadow: 0 0 0 1px rgba(76,194,255,0.05) inset;
}
.metric-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
}
.metric-value {
  font-size: 22px;
  font-weight: 600;
  margin-top: 6px;
  letter-spacing: -0.5px;
  font-feature-settings: "tnum";
}
.metric-value.pos { color: var(--good); }
.metric-value.neg { color: var(--bad); }

/* ---------- Charts ---------- */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}
.chart-half > div { min-height: 320px; }
@media (max-width: 1100px) {
  .chart-row { grid-template-columns: 1fr; }
}

/* ---------- Insight ---------- */
.insight {
  margin-top: 20px;
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(76,194,255,0.10), rgba(124,92,255,0.04));
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}
.insight:empty { display: none; }
.insight::before {
  content: "Insight ";
  font-weight: 600;
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-right: 6px;
}

/* ---------- Loading ---------- */
.loading {
  display: flex;
  justify-content: center;
  padding: 30px 0;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ---------- Inline inputs ---------- */
.inline-input {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.inline-input label { font-size: 12px; color: var(--muted); font-weight: 500; }
.inline-input input { width: 100px; }

/* ---------- Actions ---------- */
.actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}
th, td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  font-feature-settings: "tnum";
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  background: rgba(0,0,0,0.15);
}
tr:hover td { background: rgba(76,194,255,0.04); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bad);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-width: 400px;
}

/* ---------- Explanations ---------- */
.explanations { background: linear-gradient(180deg, rgba(28, 36, 54, 0.4), rgba(17, 22, 35, 0.4)); }
.explain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 4px;
}
.explain-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.explain-card:hover {
  border-color: rgba(76,194,255,0.3);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}
.explain-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: linear-gradient(135deg, rgba(76,194,255,0.18), rgba(124,92,255,0.18));
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(76,194,255,0.25);
}
.explain-card h3 {
  margin: 12px 0 10px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}
.explain-card p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}
.explain-card strong { color: var(--text); font-weight: 600; }
.explain-card ul {
  margin: 6px 0 10px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
}
.explain-card li { margin-bottom: 5px; }
.explain-card li strong { color: var(--accent); }
.explain-disclaimer {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted-2);
  letter-spacing: 0.2px;
}

/* ---------- How It Works ---------- */
.how-it-works { background: linear-gradient(180deg, rgba(28, 36, 54, 0.4), rgba(17, 22, 35, 0.4)); }
.hiw-callout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 20px;
  background: linear-gradient(90deg, rgba(76,194,255,0.10), rgba(124,92,255,0.06));
  border: 1px solid rgba(76,194,255,0.25);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-2);
  margin-bottom: 26px;
}
.hiw-callout strong { color: var(--text); display: block; margin-bottom: 4px; font-weight: 600; }
.hiw-callout em { color: var(--accent); font-style: normal; font-weight: 600; }
.hiw-callout-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #0a0d13;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(76,194,255,0.3);
}

.hiw-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 30px 0 14px;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hiw-section-title::before {
  content: "";
  width: 3px;
  height: 16px;
  background: var(--accent-grad);
  border-radius: 2px;
}

.hiw-pipeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.hiw-pipeline::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 18px;
  bottom: 18px;
  width: 2px;
  background: linear-gradient(180deg, rgba(76,194,255,0.5), rgba(124,92,255,0.5), rgba(124,92,255,0.05));
}
.hiw-pipeline li {
  display: flex;
  gap: 18px;
  padding: 12px 0;
  position: relative;
}
.hiw-step-num {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px solid var(--accent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(10,13,19,1);
}
.hiw-step-body { flex: 1; padding-top: 4px; }
.hiw-step-body h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.hiw-step-body p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}

.hiw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) { .hiw-grid { grid-template-columns: 1fr; } }
.hiw-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
}
.hiw-card h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--good);
}
.hiw-card-x h4 { color: var(--bad); }
.hiw-check, .hiw-cross {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
}
.hiw-check li, .hiw-cross li {
  position: relative;
  padding: 5px 0 5px 24px;
}
.hiw-check li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 5px;
  color: var(--good);
  font-weight: 700;
}
.hiw-cross li::before {
  content: "✕";
  position: absolute;
  left: 0; top: 5px;
  color: var(--bad);
  font-weight: 700;
}

.hiw-example {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-2);
}
.hiw-example > p { margin: 0 0 12px; }
.hiw-example ol {
  margin: 0;
  padding-left: 18px;
}
.hiw-example li { margin-bottom: 8px; }
.hiw-example li strong { color: var(--accent); }
.hiw-example-bottom {
  margin-top: 14px !important;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-style: italic;
  font-size: 12.5px;
}

.hiw-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.hiw-stack-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.hiw-stack-item span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 600;
  background: rgba(76,194,255,0.10);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--accent);
}

/* ---------- Plotly tweaks ---------- */
.js-plotly-plot .plotly .modebar { background: transparent !important; }
.js-plotly-plot .plotly .modebar-btn { color: var(--muted) !important; }

/* ==================== Trade Signals ==================== */
.signals-section { background: linear-gradient(180deg, rgba(91,141,239,0.04) 0%, transparent 60%); border-color: rgba(91,141,239,0.25); }
.live-pill {
  display: inline-block; padding: 2px 8px; margin-left: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  background: rgba(16,185,129,0.15); color: #10b981;
  border: 1px solid rgba(16,185,129,0.4); border-radius: 999px;
  vertical-align: middle; position: relative; top: -2px;
}
.live-pill::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  background: #10b981; border-radius: 50%; margin-right: 5px;
  box-shadow: 0 0 6px #10b981;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.asof { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.signals-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
}
.sig-chip {
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px; padding: 14px 16px;
}
.sig-chip-num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.sig-chip-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 6px; }
.sig-chip.sig-buy { border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.06); }
.sig-chip.sig-buy .sig-chip-num { color: #10b981; }
.sig-chip.sig-sell { border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.06); }
.sig-chip.sig-sell .sig-chip-num { color: #ef4444; }
.sig-chip.sig-hold .sig-chip-num { color: #a5aec3; }
.sig-chip.sig-total .sig-chip-num { color: #5b8def; }

.signals-cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 24px;
}
@media (max-width: 1100px) { .signals-cards { grid-template-columns: 1fr; } }

.sig-card {
  background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 16px; position: relative; overflow: hidden;
}
.sig-card.v-buy  { border-left: 3px solid #10b981; }
.sig-card.v-sell { border-left: 3px solid #ef4444; }
.sig-card.v-hold { border-left: 3px solid #6b7280; }

.sig-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.sig-card-ticker { font-size: 22px; font-weight: 700; letter-spacing: 0.04em; }
.sig-card-price { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.sig-card-verdict {
  text-align: right; font-size: 18px; font-weight: 800; letter-spacing: 0.05em;
  padding: 6px 12px; border-radius: 8px;
}
.sig-card-verdict.v-buy { background: rgba(16,185,129,0.15); color: #10b981; }
.sig-card-verdict.v-sell { background: rgba(239,68,68,0.15); color: #ef4444; }
.sig-card-verdict.v-hold { background: rgba(107,114,128,0.18); color: #9ca3af; }
.sig-card-score { font-size: 10px; font-weight: 600; opacity: 0.85; margin-top: 2px; letter-spacing: 0.05em; }

.sig-meter { height: 4px; background: rgba(255,255,255,0.05); border-radius: 2px; margin: 4px 0 14px; overflow: hidden; }
.sig-meter-fill { height: 100%; transition: width 0.4s; }
.sig-meter-fill.v-buy  { background: linear-gradient(90deg, #10b981, #34d399); }
.sig-meter-fill.v-sell { background: linear-gradient(90deg, #ef4444, #f87171); }
.sig-meter-fill.v-hold { background: linear-gradient(90deg, #6b7280, #9ca3af); }

.sig-card-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; margin-bottom: 12px;
}
.sig-card-grid > div { font-size: 11px; }
.sig-card-grid span { display: block; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; margin-bottom: 2px; }
.sig-card-grid b { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.sig-rationale { font-size: 12px; color: #c7cdd9; line-height: 1.6; margin: 10px 0; padding: 10px 12px; background: rgba(0,0,0,0.2); border-radius: 6px; }
.sig-rationale .muted { color: var(--muted); }

.sig-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.sig-levels .lvl { background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.05); border-radius: 6px; padding: 8px 10px; }
.sig-levels .lvl span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px; }
.sig-levels .lvl b { font-size: 13px; font-variant-numeric: tabular-nums; }
.sig-levels .lvl-stop b { color: #ef4444; }
.sig-levels .lvl-target b { color: #10b981; }

.sig-forecast { font-size: 12px; color: var(--muted); padding-top: 10px; border-top: 1px dashed rgba(255,255,255,0.08); }
.sig-forecast b { color: var(--text); }
.sig-forecast b.pos { color: #10b981; }
.sig-forecast b.neg { color: #ef4444; }

.pos { color: #10b981; }
.neg { color: #ef4444; }

.signals-table-wrap { overflow-x: auto; margin-bottom: 24px; }
.sig-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: rgba(0,0,0,0.15); border-radius: 8px; overflow: hidden;
}
.sig-table th {
  text-align: left; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); padding: 10px 10px;
  background: rgba(255,255,255,0.03); border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sig-table td { padding: 10px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); font-variant-numeric: tabular-nums; }
.sig-table tr:last-child td { border-bottom: none; }
.sig-table .t-tk { font-weight: 700; letter-spacing: 0.04em; }
.t-verdict { padding: 3px 8px; border-radius: 4px; font-weight: 700; font-size: 11px; letter-spacing: 0.05em; }
.t-verdict.v-buy { background: rgba(16,185,129,0.15); color: #10b981; }
.t-verdict.v-sell { background: rgba(239,68,68,0.15); color: #ef4444; }
.t-verdict.v-hold { background: rgba(107,114,128,0.15); color: #9ca3af; }

.pair-block { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; padding: 16px; margin-bottom: 18px; }
.pair-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pair-name { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; }
.pair-meta { font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.pair-signal { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; }
.pair-signal.v-buy { background: rgba(16,185,129,0.15); color: #10b981; }
.pair-signal.v-hold { background: rgba(107,114,128,0.15); color: #9ca3af; }
.pair-explain { font-size: 11px; color: var(--muted); line-height: 1.6; margin-top: 10px; }
.pair-empty { color: var(--muted); font-size: 12px; padding: 16px; text-align: center; background: rgba(0,0,0,0.15); border-radius: 8px; }

.signals-disclaimer { font-size: 10.5px; color: var(--muted); margin-top: 14px; padding: 10px 14px; background: rgba(0,0,0,0.2); border-radius: 6px; border-left: 2px solid rgba(245,158,11,0.5); line-height: 1.5; }

@media (max-width: 800px) {
  .signals-summary { grid-template-columns: repeat(2, 1fr); }
  .sig-card-grid { grid-template-columns: repeat(2, 1fr); }
  .sig-levels { grid-template-columns: repeat(2, 1fr); }
}

.explain-tag.tag-signals { background: rgba(16,185,129,0.12); color: #10b981; border-color: rgba(16,185,129,0.35); }
.sidebar-footer .footer-line { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.sidebar-footer .footer-sub { color: var(--text); font-weight: 600; font-size: 12.5px; margin-top: 2px; letter-spacing: 0.02em; }

/* ==================== Ticker Picker ==================== */
.ticker-picker {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 38px; padding: 5px 8px;
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; cursor: text;
  transition: border-color 0.15s;
}
.ticker-picker:focus-within { border-color: rgba(91,141,239,0.5); box-shadow: 0 0 0 2px rgba(91,141,239,0.12); }
.ticker-chips { display: contents; }
#ticker-search {
  flex: 1; min-width: 140px; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13px; font-family: inherit; padding: 4px 2px;
}
.t-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 4px;
  background: rgba(91,141,239,0.10); border: 1px solid rgba(91,141,239,0.28);
  border-radius: 6px; font-size: 11.5px; font-weight: 600;
  color: var(--text); white-space: nowrap;
}
.t-chip-logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px; overflow: hidden;
  flex: 0 0 auto;
}
.t-chip-logo.has-logo { background: #fff !important; }
.t-chip-logo img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; padding: 1px; box-sizing: border-box; }
.t-chip-fallback {
  font-size: 10px; font-weight: 800; line-height: 1; letter-spacing: 0;
}
.t-chip-sym { letter-spacing: 0.04em; }
.t-chip-x {
  width: 16px; height: 16px; padding: 0; line-height: 1;
  border: none; border-radius: 4px; cursor: pointer;
  background: rgba(255,255,255,0.06); color: var(--muted);
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}
.t-chip-x:hover { background: rgba(239,68,68,0.25); color: #ef4444; }

.ticker-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  max-height: 360px; overflow-y: auto;
  background: #0f1320; border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  padding: 4px;
}
.dd-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; }
.dd-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  transition: background 0.1s;
}
.dd-row:hover { background: rgba(91,141,239,0.10); }
.dd-row.dd-picked { background: rgba(16,185,129,0.08); }
.dd-logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; overflow: hidden; flex: 0 0 auto;
}
.dd-logo.has-logo { background: #fff !important; }
.dd-logo img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; padding: 2px; box-sizing: border-box; }
.dd-fallback { font-size: 13px; font-weight: 800; }
.dd-info { flex: 1; min-width: 0; }
.dd-row-top { display: flex; align-items: center; gap: 8px; }
.dd-sym { font-weight: 700; font-size: 12.5px; letter-spacing: 0.04em; }
.dd-exchange {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  letter-spacing: 0.06em;
}
.dd-exchange.ex-nasdaq { background: rgba(16,185,129,0.15); color: #10b981; }
.dd-exchange.ex-nyse { background: rgba(91,141,239,0.18); color: #5b8def; }
.dd-name {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-sector { font-size: 10px; color: var(--muted); margin-right: 8px; flex: 0 0 auto; }
.dd-add { font-size: 16px; color: #5b8def; font-weight: 700; flex: 0 0 auto; width: 18px; text-align: center; }
.dd-row.dd-picked .dd-add { color: #10b981; }

/* ==================== Signal card logos ==================== */
.sig-card-id { display: flex; gap: 12px; align-items: flex-start; }
.sig-card-logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.sig-card-logo.has-logo { background: #fff !important; }
.sig-card-logo img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; padding: 4px; box-sizing: border-box; }
.sig-card-logo-fb { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.sig-card-name { font-size: 11px; color: var(--muted); margin: 2px 0 2px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig-card-ex {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  letter-spacing: 0.06em; vertical-align: 2px;
}
.sig-card-ex.ex-nasdaq { background: rgba(16,185,129,0.15); color: #10b981; }
.sig-card-ex.ex-nyse { background: rgba(91,141,239,0.18); color: #5b8def; }

/* Table row logos */
.t-row-logo-wrap {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px; overflow: hidden; margin-right: 8px;
  vertical-align: middle;
}
.t-row-logo-wrap.has-logo { background: #fff !important; }
.t-row-logo-wrap img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; padding: 1px; box-sizing: border-box; }
.t-row-logo-fb { font-size: 10px; font-weight: 800; line-height: 1; }

/* As-of pills */
.asof { display: flex; gap: 6px; align-items: center; }
.asof-pill {
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.08em; background: rgba(255,255,255,0.05); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.asof-pill.asof-live { background: rgba(16,185,129,0.12); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.asof-pill.asof-live::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #10b981; margin-right: 5px; box-shadow: 0 0 6px #10b981;
  animation: pulse 1.6s ease-in-out infinite;
}

/* ==================== Trade plan card ==================== */
.sig-trade-plan {
  margin-top: 12px; padding: 12px; border-radius: 8px;
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.06);
}
.sig-trade-head {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 10px; padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255,255,255,0.07);
}
.sig-direction {
  font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.1em;
}
.sig-dir-long { background: rgba(16,185,129,0.18); color: #10b981; }
.sig-dir-short { background: rgba(239,68,68,0.18); color: #ef4444; }
.sig-dir-neutral { background: rgba(148,163,184,0.18); color: #94a3b8; }
.sig-conviction {
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.sig-conv-high { background: rgba(91,141,239,0.18); color: #5b8def; }
.sig-conv-medium { background: rgba(245,158,11,0.15); color: #f59e0b; }
.sig-conv-low { background: rgba(148,163,184,0.12); color: #94a3b8; }
.sig-horizon {
  margin-left: auto; font-size: 10px; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.lvl i {
  display: block; font-size: 9.5px; color: var(--muted);
  font-style: normal; margin-top: 2px; letter-spacing: 0.04em;
}
.sig-sizing {
  margin-top: 10px; padding: 10px;
  background: rgba(91,141,239,0.06); border: 1px solid rgba(91,141,239,0.18);
  border-radius: 6px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.sig-sizing > span:first-child { font-size: 10px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.sig-sizing > b { font-size: 16px; font-weight: 700; color: #5b8def; font-variant-numeric: tabular-nums; }
.sig-sizing-sub { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }

/* ==================== Footer & legal ==================== */
.app-footer {
  margin-top: 48px; padding: 24px 28px 32px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.20);
}
.footer-disclaimer {
  font-size: 11px; color: var(--muted); line-height: 1.6;
  max-width: 980px; margin: 0 auto 16px;
}
.footer-disclaimer strong {
  color: #f59e0b; letter-spacing: 0.08em; font-weight: 800; margin-right: 6px;
}
.footer-links {
  text-align: center; margin-bottom: 12px;
  font-size: 12px;
}
.footer-links a {
  color: var(--text); text-decoration: none; transition: color 0.15s;
  font-weight: 600;
}
.footer-links a:hover { color: #5b8def; }
.footer-sep { color: var(--muted); margin: 0 10px; }
.footer-credit {
  text-align: center; font-size: 10.5px; color: var(--muted);
  letter-spacing: 0.04em;
}

.legal-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.legal-card {
  position: relative;
  max-width: 720px; max-height: 80vh; overflow-y: auto;
  background: #0f1320; border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px; padding: 32px 36px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.legal-card h2 {
  margin: 0 0 16px; font-size: 18px; font-weight: 700;
  color: var(--text); letter-spacing: 0.02em;
}
.legal-card p {
  margin: 0 0 12px; font-size: 13px; line-height: 1.65;
  color: var(--muted);
}
.legal-card p b { color: var(--text); font-weight: 600; }
.legal-close {
  position: absolute; top: 12px; right: 14px;
  width: 28px; height: 28px; border: none; border-radius: 6px;
  background: rgba(255,255,255,0.06); color: var(--muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}
.legal-close:hover { background: rgba(239,68,68,0.18); color: #ef4444; }

/* ==================== Portfolio size + Quant branding ==================== */
.input-with-suffix .prefix {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--muted); pointer-events: none;
  font-weight: 600;
}
.field-portfolio .input-with-suffix { position: relative; }
.field-portfolio .input-with-suffix input { padding-left: 22px; }

.quant-subtitle {
  margin: 4px 0 14px; font-size: 12px; color: var(--muted); line-height: 1.55;
  max-width: 1100px;
}

.quant-allocation-summary { margin-bottom: 16px; }
.qalloc-card {
  padding: 14px 18px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(91,141,239,0.10), rgba(91,141,239,0.03));
  border: 1px solid rgba(91,141,239,0.25);
}
.qalloc-card.qalloc-empty {
  background: linear-gradient(135deg, rgba(148,163,184,0.08), rgba(148,163,184,0.02));
  border-color: rgba(148,163,184,0.20);
}
.qalloc-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}
.qalloc-tag {
  font-size: 10px; font-weight: 800; letter-spacing: 0.14em;
  color: #5b8def; padding: 4px 8px;
  background: rgba(91,141,239,0.15); border-radius: 4px;
}
.qalloc-sub { font-size: 12px; color: var(--muted); }
.qalloc-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;
}
.qalloc-cell {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; background: rgba(0,0,0,0.20); border-radius: 6px;
}
.qalloc-cell > span { font-size: 10px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.qalloc-cell > b { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.qalloc-cell > i { font-style: normal; font-size: 11px; color: var(--muted); }
.qalloc-cell.qalloc-risk > b { color: #f59e0b; }
