/* QuantFin Platform, custom UI matching the landing brand */

:root {
  --bg: #060818;
  --bg-2: #0a0f1f;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #e9edf5;
  --text-dim: #aab3c5;
  --muted: #7a8499;
  --brand: #3282b8;
  --brand-2: #5fd0ff;
  --accent: #ff7a1a;
  --pos: #4ade80;
  --neg: #f87171;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1180px;
  --pad: 24px;
  --t: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 90% -10%, rgba(50, 130, 184, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(255, 122, 26, 0.05), transparent 60%),
    linear-gradient(180deg, #08091a, #060818 60%);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle trading-floor grid background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 85%);
  opacity: .45;
  pointer-events: none;
}

/* Bloomberg-style ticker tape */
.pf-tape {
  position: sticky;
  top: 0;
  z-index: 60;
  height: 28px;
  background: #000;
  border-bottom: 1px solid #181818;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.pf-tape-track {
  display: flex;
  gap: 28px;
  white-space: nowrap;
  width: max-content;
  animation: pfTapeScroll 90s linear infinite;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  padding-left: 16px;
  color: #d0d0d0;
}
.pf-tape-item { color: #d0d0d0; }
.pf-tape-item b { color: var(--accent); font-weight: 700; margin-right: 6px; letter-spacing: .08em; }
.pf-tape-item i { font-style: normal; margin-left: 6px; font-weight: 600; }
.pf-tape-item .up { color: var(--pos); }
.pf-tape-item .down { color: var(--neg); }
@keyframes pfTapeScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) { .pf-tape-track { animation: none; } }

h1, h2, h3 {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--text);
}

h1 { font-size: clamp(28px, 4.5vw, 44px); margin: 0 0 10px; }
h2 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 12px; }
h3 { font-size: 17px; margin: 0 0 14px; font-weight: 600; }

p { margin: 0 0 10px; color: var(--text-dim); }
.muted { color: var(--muted); font-size: 13px; }
.micro { font-size: 12px; color: var(--muted); }

a { color: var(--brand-2); text-decoration: none; }
a:hover { color: var(--text); }

/* Nav */
.pf-nav {
  position: sticky;
  top: 28px;
  z-index: 50;
  background: rgba(6, 8, 24, 0.85);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px var(--pad);
}
.pf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: "Space Grotesk", system-ui;
  font-weight: 700;
  font-size: 17px;
}
.pf-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  overflow: hidden;
  display: inline-block;
  flex-shrink: 0;
}
.pf-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-brand-name { color: var(--text); }
.pf-brand-sub {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  border-left: 1px solid var(--border-2);
  padding-left: 10px;
  margin-left: 4px;
}
.pf-nav-tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand-2);
  padding: 6px 12px;
  border: 1px solid rgba(95, 208, 255, 0.3);
  border-radius: 999px;
  background: rgba(95, 208, 255, 0.08);
}
.pf-nav-back {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #051528;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13.5px;
}
.pf-nav-back:hover { filter: brightness(1.08); color: #051528; }

/* Main */
.pf-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 32px var(--pad) 60px;
}

/* Hero */
.pf-hero {
  margin-bottom: 28px;
}
.pf-kicker {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  color: var(--brand-2);
  margin: 0 0 12px;
  font-weight: 600;
}
.pf-lede {
  font-size: 16px;
  color: var(--text-dim);
  max-width: 60ch;
}

/* Card */
.pf-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 18px;
}
.pf-card-head h2 { margin-bottom: 4px; }
.pf-card-head p { font-size: 14px; }

/* Form */
.pf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.pf-field {
  display: grid;
  gap: 6px;
}
.pf-field label,
.pf-field > span:first-child {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.pf-field input,
.pf-field select {
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  font: inherit;
  outline: none;
  transition: border-color .15s var(--t);
}
.pf-field input:focus,
.pf-field select:focus { border-color: var(--brand-2); }
.pf-hint { color: var(--muted); font-size: 12px; }

/* Slider styling */
.pf-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  padding: 6px 0;
  margin: 0;
  height: 24px;
  width: 100%;
}
.pf-field input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand) 70%, var(--border-2));
  border-radius: 999px;
  border: 1px solid var(--border);
}
.pf-field input[type="range"]::-moz-range-track {
  height: 6px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand) 70%, var(--border-2));
  border-radius: 999px;
  border: 1px solid var(--border);
}
.pf-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-2);
  border: 2px solid #051528;
  box-shadow: 0 0 0 4px rgba(95, 208, 255, 0.18);
  margin-top: -7px;
  cursor: pointer;
}
.pf-field input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-2);
  border: 2px solid #051528;
  box-shadow: 0 0 0 4px rgba(95, 208, 255, 0.18);
  cursor: pointer;
}
.pf-slider-val {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-2);
  background: rgba(95, 208, 255, 0.12);
  border: 1px solid rgba(95, 208, 255, 0.3);
  letter-spacing: 0;
  text-transform: none;
}

.pf-section {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 22px;
}
.pf-section-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.pf-group {
  margin-top: 18px;
}
.pf-group:first-child { margin-top: 6px; }

.pf-tickers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pf-detect-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.pf-detect-field .pf-btn {
  width: 100%;
  justify-content: center;
}

.pf-events {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}
.pf-event {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s var(--t), background .15s var(--t), transform .15s var(--t);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  align-items: center;
}
.pf-event:hover {
  border-color: var(--border-2);
  transform: translateX(2px);
}
.pf-event.is-active {
  border-color: rgba(95, 208, 255, 0.5);
  background: rgba(95, 208, 255, 0.08);
}
.pf-event-title {
  margin: 0;
  font-weight: 600;
  color: var(--text);
  font-size: 14.5px;
}
.pf-event-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  grid-column: 1 / -1;
}
.pf-event-impact {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.pf-event-impact.critical { color: #f87171; background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.35); }
.pf-event-impact.high     { color: #ff7a1a; background: rgba(255, 122, 26, 0.10); border-color: rgba(255, 122, 26, 0.35); }
.pf-event-impact.medium   { color: #c7a55a; background: rgba(199, 165, 90, 0.10); border-color: rgba(199, 165, 90, 0.35); }
.pf-event-impact.low      { color: #aab3c5; background: rgba(170, 179, 197, 0.10); border-color: rgba(170, 179, 197, 0.30); }

.pf-selected {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(95, 208, 255, 0.35);
  background: linear-gradient(135deg, rgba(95, 208, 255, 0.10), rgba(255, 122, 26, 0.04));
}
.pf-selected h4 {
  margin: 0 0 8px;
  color: var(--brand-2);
  font-size: 13px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.pf-selected p { margin: 4px 0; font-size: 14px; }
.pf-selected .pf-selected-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0;
}
.pf-selected-cell {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.pf-selected-cell-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.pf-selected-cell-value {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-top: 4px;
}
.pf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s var(--t), background .15s var(--t);
  user-select: none;
}
.pf-chip:hover { border-color: var(--border-2); }
.pf-chip input { accent-color: var(--brand-2); }
.pf-chip:has(input:checked) {
  background: rgba(95, 208, 255, 0.12);
  border-color: rgba(95, 208, 255, 0.45);
  color: var(--brand-2);
}

.pf-custom {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pf-custom input {
  flex: 1;
  min-width: 200px;
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  font: inherit;
  font-family: var(--mono);
}
.pf-custom input:focus { border-color: var(--brand-2); outline: none; }

/* Buttons */
.pf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform .12s var(--t), filter .15s var(--t), box-shadow .15s var(--t);
  white-space: nowrap;
}
.pf-btn:active { transform: translateY(1px); }
.pf-btn:disabled { opacity: .6; cursor: not-allowed; }

.pf-btn-primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #051528;
  border-color: rgba(95, 208, 255, 0.5);
  box-shadow: 0 10px 30px rgba(50, 130, 184, 0.30);
}
.pf-btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 14px 40px rgba(95, 208, 255, 0.40);
}

.pf-btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-2);
}
.pf-btn-ghost:hover:not(:disabled) { border-color: var(--brand-2); color: var(--brand-2); }

.pf-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pf-status {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pf-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-2);
  box-shadow: 0 0 10px var(--brand-2);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}

/* Results */
.pf-results { margin-top: 24px; }
.pf-results-head { margin-bottom: 14px; }

.pf-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.pf-kpis-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
  margin-bottom: 0;
}
.pf-kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface);
}
.pf-kpi-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.pf-kpi-value {
  font-family: "Space Grotesk", system-ui;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.pf-kpi-value.pos { color: var(--pos); }
.pf-kpi-value.neg { color: var(--neg); }

/* Tabs */
.pf-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.pf-tab {
  padding: 9px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s var(--t), color .15s var(--t);
}
.pf-tab:hover { color: var(--text); }
.pf-tab.is-active {
  background: rgba(95, 208, 255, 0.14);
  color: var(--brand-2);
}

.pf-tabpane { display: none; }
.pf-tabpane.is-active { display: block; }

/* Table */
.pf-table-wrap { overflow-x: auto; }
.pf-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.pf-table th, .pf-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.pf-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
}
.pf-table td.num { text-align: right; }
.pf-table td.pos { color: var(--pos); }
.pf-table td.neg { color: var(--neg); }
.pf-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.pf-table td .pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill.yes { background: rgba(74, 222, 128, 0.14); color: var(--pos); border: 1px solid rgba(74, 222, 128, 0.3); }
.pill.no { background: rgba(122, 132, 153, 0.14); color: var(--muted); border: 1px solid var(--border); }

/* Chart container */
.pf-chart {
  width: 100%;
  min-height: 360px;
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

/* AI output */
.pf-ai-output {
  margin-top: 14px;
  padding: 16px 18px;
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14.5px;
  white-space: pre-wrap;
  min-height: 60px;
  color: var(--text-dim);
}
.pf-ai-output:empty::before {
  content: "Click Generate to get a market interpretation of these results.";
  color: var(--muted);
}

/* Footer */
.pf-foot {
  margin: 50px 0 0;
  padding: 22px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.pf-foot p { color: var(--muted); margin: 4px 0; }

/* Responsive */
@media (max-width: 768px) {
  :root { --pad: 16px; }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-kpis { grid-template-columns: 1fr 1fr; }
  .pf-kpis-row { grid-template-columns: 1fr; }
  .pf-nav { padding: 12px var(--pad); top: 26px; }
  .pf-tape { height: 26px; }
  .pf-tape-track { font-size: 10.5px; gap: 22px; }
  .pf-brand-sub, .pf-nav-tag { display: none; }
  .pf-main { padding: 22px var(--pad) 40px; }
  .pf-card { padding: 18px 16px; }
  .pf-chart { min-height: 320px; }
  .pf-actions .pf-btn { width: 100%; justify-content: center; }
  .pf-event { grid-template-columns: 1fr; }
  .pf-event-impact { justify-self: start; }
  .pf-table { font-size: 12px; }
  .pf-table th, .pf-table td { padding: 8px 10px; }
  .pf-field input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -8px; }
  .pf-field input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; }
}

@media (max-width: 420px) {
  .pf-kpis { grid-template-columns: 1fr; }
  .pf-selected .pf-selected-grid { grid-template-columns: 1fr; }
}
