/*
  QuantInvesto Design System V3
  Scope: visual layer only. This file intentionally avoids changing IDs,
  data-step attributes, canvas names, financial logic, or JavaScript contracts.
*/

:root {
  color-scheme: light;

  --qi-bg: #f4f7f5;
  --qi-bg-soft: #eef4f1;
  --qi-surface: rgba(255, 255, 255, 0.94);
  --qi-surface-strong: #ffffff;
  --qi-surface-muted: #f8fbf9;
  --qi-border: rgba(32, 52, 44, 0.12);
  --qi-border-strong: rgba(32, 52, 44, 0.18);

  --qi-text: #15221d;
  --qi-text-soft: #3e5149;
  --qi-muted: #697a73;
  --qi-subtle: #87958f;

  --qi-green: #13734c;
  --qi-green-strong: #0c5c3b;
  --qi-green-soft: #e8f6ef;
  --qi-blue: #2e64c7;
  --qi-blue-strong: #1f4f9d;
  --qi-blue-soft: #edf4ff;
  --qi-violet: #6f4dbf;
  --qi-violet-soft: #f2efff;
  --qi-amber: #a86412;
  --qi-amber-soft: #fff5e8;
  --qi-red: #bb3d35;
  --qi-red-soft: #fff0ef;

  --qi-radius-xs: 8px;
  --qi-radius-sm: 12px;
  --qi-radius-md: 16px;
  --qi-radius-lg: 22px;
  --qi-radius-xl: 28px;

  --qi-shadow-xs: 0 4px 12px rgba(21, 34, 29, 0.05);
  --qi-shadow-sm: 0 12px 28px rgba(21, 34, 29, 0.07);
  --qi-shadow-md: 0 22px 50px rgba(21, 34, 29, 0.10);
  --qi-shadow-focus: 0 0 0 4px rgba(46, 100, 199, 0.14);

  --qi-space-1: 4px;
  --qi-space-2: 8px;
  --qi-space-3: 12px;
  --qi-space-4: 16px;
  --qi-space-5: 20px;
  --qi-space-6: 24px;
  --qi-space-8: 32px;
}

body {
  background:
    radial-gradient(circle at 12% 0%, rgba(46, 100, 199, 0.08), transparent 30%),
    radial-gradient(circle at 92% 4%, rgba(19, 115, 76, 0.08), transparent 28%),
    linear-gradient(180deg, #f7faf8 0%, var(--qi-bg) 100%);
  color: var(--qi-text);
}

.app-shell {
  padding: 22px;
}

.workspace {
  max-width: 1520px;
  gap: 22px;
}

.controls,
.results,
.step-panel,
.chart-panel,
.portfolio-lane,
.table-panel,
.analysis-results,
.advanced-results,
.monte-carlo-results,
.stress-testing-results,
.efficient-frontier-results,
.monitor-results {
  border-color: var(--qi-border);
  border-radius: var(--qi-radius-lg);
  background: var(--qi-surface);
  box-shadow: var(--qi-shadow-sm);
}

.controls {
  backdrop-filter: blur(18px);
  padding: 20px;
}

.results {
  overflow: hidden;
}

.brand {
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--qi-border);
  border-radius: var(--qi-radius-lg);
  background:
    radial-gradient(circle at 90% 0%, rgba(19, 115, 76, 0.10), transparent 30%),
    var(--qi-surface-strong);
  box-shadow: var(--qi-shadow-xs);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--qi-green), var(--qi-blue));
  box-shadow: 0 12px 24px rgba(19, 115, 76, 0.18);
}

.brand h1 {
  color: var(--qi-text);
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand p {
  color: var(--qi-muted);
  line-height: 1.45;
}

.step-nav {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--qi-border);
  border-radius: var(--qi-radius-lg);
  background: var(--qi-surface-muted);
}

.journey-nav {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.journey-nav::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 28px;
  z-index: -1;
  width: 1px;
  background: linear-gradient(180deg, rgba(19, 115, 76, 0.18), rgba(46, 100, 199, 0.08), transparent);
}

.journey-nav-head {
  display: grid;
  gap: 5px;
  padding: 4px 4px 10px;
}

.journey-nav-head strong {
  color: var(--qi-text);
  font-size: 16px;
  letter-spacing: -0.01em;
}

.journey-nav-head small {
  color: var(--qi-muted);
  line-height: 1.45;
}

.nav-section-label {
  color: var(--qi-subtle);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.journey-group {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(32, 52, 44, 0.08);
  border-radius: var(--qi-radius-md);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
}

.journey-group-title,
.advanced-nav summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  color: var(--qi-text-soft);
}

.journey-group-title span,
.advanced-nav summary span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--qi-green-soft);
  color: var(--qi-green-strong);
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
}

.journey-group-title strong,
.advanced-nav summary strong {
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.step-button {
  position: relative;
  justify-content: flex-start;
  min-height: 42px;
  padding: 0 13px 0 35px;
  border-radius: 13px;
  border-color: transparent;
  background: transparent;
  color: var(--qi-text-soft);
  text-align: left;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.step-button::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(105, 122, 115, 0.42);
  transform: translateY(-50%);
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.step-button:hover {
  background: #ffffff;
  color: var(--qi-text);
  transform: translateY(-1px);
  box-shadow: var(--qi-shadow-xs);
}

.step-button.active {
  border-color: rgba(19, 115, 76, 0.18);
  background: #ffffff;
  color: var(--qi-green-strong);
  box-shadow: var(--qi-shadow-xs);
}

.step-button.active::before {
  background: var(--qi-green);
  box-shadow: 0 0 0 5px rgba(19, 115, 76, 0.12);
}

.advanced-nav {
  border-top: 0;
  padding-top: 10px;
}

.advanced-nav summary {
  cursor: pointer;
  list-style: none;
}

.advanced-nav summary::-webkit-details-marker {
  display: none;
}

.advanced-nav summary::after {
  content: "+";
  margin-left: auto;
  color: var(--qi-green-strong);
  font-size: 16px;
  font-weight: 900;
}

.advanced-nav[open] summary::after {
  content: "-";
}

.journey-subnav {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.agent-panel {
  border-color: rgba(46, 100, 199, 0.16);
  border-radius: var(--qi-radius-lg);
  background:
    radial-gradient(circle at 92% 12%, rgba(46, 100, 199, 0.12), transparent 30%),
    linear-gradient(135deg, #f4f8ff, #ffffff);
  box-shadow: var(--qi-shadow-xs);
}

.agent-panel strong {
  color: var(--qi-text);
  letter-spacing: -0.01em;
}

.plan-badge,
.source-pill,
.profile-readiness-pill {
  border-radius: 999px;
  font-weight: 900;
}

.profile-readiness-pill[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.28);
  background: var(--qi-green-soft);
  color: var(--qi-green-strong);
}

.profile-readiness-pill[data-state="warning"] {
  border-color: rgba(168, 100, 18, 0.24);
  background: var(--qi-amber-soft);
  color: var(--qi-amber);
}

.setup-decision-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--qi-border);
  border-radius: var(--qi-radius-md);
  background: #ffffff;
  box-shadow: var(--qi-shadow-xs);
}

.setup-decision-card span {
  color: var(--qi-subtle);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.setup-decision-card strong {
  color: var(--qi-text);
  font-size: 19px;
  line-height: 1.15;
}

.setup-decision-card small {
  color: var(--qi-muted);
  line-height: 1.45;
}

.setup-decision-card[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.18);
  background:
    radial-gradient(circle at 100% 0%, rgba(19, 115, 76, 0.10), transparent 30%),
    #ffffff;
}

.setup-decision-card[data-state="warning"] {
  border-color: rgba(168, 100, 18, 0.20);
  background:
    radial-gradient(circle at 100% 0%, rgba(168, 100, 18, 0.11), transparent 30%),
    #ffffff;
}

.profile-insight-grid article,
.portfolio-snapshot-grid article,
.portfolio-method-panel > div,
.portfolio-live-check article {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.profile-insight-grid article:hover,
.portfolio-snapshot-grid article:hover,
.portfolio-method-panel > div:hover,
.portfolio-live-check article:hover {
  border-color: rgba(46, 100, 199, 0.22);
  box-shadow: var(--qi-shadow-sm);
  transform: translateY(-1px);
}

.portfolio-readiness[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.22);
  background:
    radial-gradient(circle at 100% 0%, rgba(19, 115, 76, 0.12), transparent 30%),
    #ffffff;
}

.portfolio-readiness[data-state="warning"] {
  border-color: rgba(168, 100, 18, 0.24);
  background:
    radial-gradient(circle at 100% 0%, rgba(168, 100, 18, 0.12), transparent 30%),
    #ffffff;
}

.diagnosis-v2,
.risk-v2 {
  display: grid;
  gap: 18px;
}

.diagnostic-hero,
.risk-hero-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(32, 52, 44, 0.10);
  border-radius: var(--qi-radius-xl);
  background:
    radial-gradient(circle at 92% 4%, rgba(46, 100, 199, 0.14), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #f7fbf9 100%);
  box-shadow: var(--qi-shadow-md);
}

.diagnostic-hero[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.22);
}

.diagnostic-hero[data-state="watch"] {
  border-color: rgba(46, 100, 199, 0.22);
}

.diagnostic-hero[data-state="warning"] {
  border-color: rgba(168, 100, 18, 0.26);
}

.diagnostic-hero h3,
.risk-hero-card h3 {
  max-width: 820px;
  color: var(--qi-text);
  letter-spacing: -0.025em;
  overflow-wrap: normal;
  word-break: normal;
}

.diagnostic-score {
  min-width: 220px;
  border: 1px solid var(--qi-border);
  border-radius: var(--qi-radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--qi-shadow-sm);
}

.diagnostic-score[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.24);
  background: linear-gradient(180deg, #ffffff, var(--qi-green-soft));
}

.diagnostic-score[data-state="watch"] {
  border-color: rgba(46, 100, 199, 0.24);
  background: linear-gradient(180deg, #ffffff, var(--qi-blue-soft));
}

.diagnostic-score[data-state="warning"] {
  border-color: rgba(168, 100, 18, 0.26);
  background: linear-gradient(180deg, #ffffff, var(--qi-amber-soft));
}

.diagnostic-score strong {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.diagnostic-context-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.diagnostic-context-strip article,
.risk-threshold-panel {
  min-width: 0;
  border: 1px solid var(--qi-border);
  border-radius: var(--qi-radius-lg);
  background: #ffffff;
  box-shadow: var(--qi-shadow-xs);
}

.diagnostic-context-strip article {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.diagnostic-context-strip span,
.risk-threshold-copy span {
  color: var(--qi-subtle);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnostic-context-strip strong,
.risk-threshold-copy strong {
  color: var(--qi-text);
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.16;
}

.diagnostic-context-strip small,
.risk-threshold-copy small,
.risk-threshold-labels small {
  color: var(--qi-muted);
  line-height: 1.42;
}

.diagnostic-grid article {
  min-width: 0;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.diagnostic-grid article:hover {
  border-color: rgba(46, 100, 199, 0.22);
  box-shadow: var(--qi-shadow-sm);
  transform: translateY(-1px);
}

.risk-emotion-card {
  min-width: 230px;
  border-color: rgba(46, 100, 199, 0.18);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--qi-shadow-sm);
}

.risk-threshold-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.risk-threshold-panel[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.22);
  background:
    radial-gradient(circle at 100% 0%, rgba(19, 115, 76, 0.10), transparent 30%),
    #ffffff;
}

.risk-threshold-panel[data-state="warning"] {
  border-color: rgba(187, 61, 53, 0.22);
  background:
    radial-gradient(circle at 100% 0%, rgba(187, 61, 53, 0.10), transparent 30%),
    #ffffff;
}

.risk-threshold-copy {
  display: grid;
  gap: 6px;
}

.risk-threshold-meter {
  position: relative;
  height: 14px;
  overflow: visible;
  border-radius: 999px;
  background: linear-gradient(90deg, #e8f6ef 0%, #fff5e8 58%, #fff0ef 100%);
}

.risk-threshold-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--qi-green), var(--qi-amber), var(--qi-red));
  transition: width 0.22s ease;
}

.risk-threshold-meter i {
  position: absolute;
  top: -7px;
  left: 0%;
  width: 3px;
  height: 28px;
  border-radius: 999px;
  background: var(--qi-text);
  box-shadow: 0 0 0 4px rgba(21, 34, 29, 0.08);
  transform: translateX(-50%);
  transition: left 0.22s ease;
}

.risk-threshold-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.chart-series-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 10px 0 2px;
}

.chart-series-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--qi-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--qi-text-soft);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  box-shadow: var(--qi-shadow-xs);
}

.chart-series-legend i {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--series-color, var(--qi-muted));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-color, var(--qi-muted)) 18%, transparent);
}

.simulation-status-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: center;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(32, 52, 44, 0.1);
  border-radius: var(--qi-radius-xl);
  background:
    radial-gradient(circle at 8% 0%, rgba(46, 100, 199, 0.1), transparent 32%),
    linear-gradient(135deg, #ffffff 0%, #f7fbf8 100%);
  box-shadow: var(--qi-shadow-md);
}

.simulation-status-panel[data-state="ok"] {
  border-color: rgba(19, 115, 76, 0.2);
  background:
    radial-gradient(circle at 8% 0%, rgba(25, 137, 91, 0.13), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #f3fbf7 100%);
}

.simulation-status-panel[data-state="warning"] {
  border-color: rgba(189, 91, 31, 0.22);
  background:
    radial-gradient(circle at 8% 0%, rgba(216, 134, 53, 0.14), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #fff8ee 100%);
}

.simulation-status-panel > div:first-child {
  min-width: 0;
}

.simulation-status-panel span:first-child {
  display: inline-flex;
  margin-bottom: 6px;
  color: var(--qi-subtle);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.simulation-status-panel strong {
  display: block;
  color: var(--qi-text);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.simulation-status-panel small {
  display: block;
  max-width: 820px;
  margin-top: 8px;
  color: var(--qi-text-soft);
  font-size: 13px;
  line-height: 1.55;
}

.simulation-status-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.simulation-status-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid var(--qi-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--qi-text-soft);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  box-shadow: var(--qi-shadow-xs);
}

.scenario-plus-guidance {
  margin-bottom: 18px;
}

.benchmark-comparison-chart-panel[data-secondary="true"],
.benchmark-results-shell .chart-panel[data-secondary="true"] {
  opacity: 0.72;
}

@media (max-width: 980px) {
  .diagnostic-context-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .simulation-status-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .simulation-status-pills {
    justify-content: flex-start;
  }
}

button.primary,
.primary {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--qi-green), var(--qi-green-strong));
  color: #ffffff;
  box-shadow: 0 14px 26px rgba(19, 115, 76, 0.22);
}

button.primary:hover,
.primary:hover {
  filter: brightness(0.96);
  transform: translateY(-1px);
}

button.secondary,
.secondary {
  border-color: var(--qi-border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--qi-text-soft);
  box-shadow: var(--qi-shadow-xs);
}

button.secondary:hover,
.secondary:hover {
  border-color: rgba(46, 100, 199, 0.22);
  color: var(--qi-blue-strong);
}

input,
select,
textarea {
  border-color: var(--qi-border-strong);
  border-radius: var(--qi-radius-sm);
  background: #ffffff;
  color: var(--qi-text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(46, 100, 199, 0.42);
  box-shadow: var(--qi-shadow-focus);
}

legend,
.eyebrow,
.table-title span,
.chart-title span,
.lane-title span,
.metric-grid span,
.analysis-grid span,
.diagnostic-grid span {
  color: var(--qi-subtle);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-title,
.section-header,
.profile-hero-card,
.portfolio-hero-card,
.diagnostic-hero,
.risk-hero-card,
.historical-hero-card {
  border-radius: var(--qi-radius-xl);
  box-shadow: var(--qi-shadow-md);
}

.table-title h3,
.profile-hero-card h3,
.portfolio-hero-card h3,
.diagnostic-hero h3,
.risk-hero-card h3,
.historical-hero-card h3 {
  letter-spacing: -0.025em;
}

.metric-grid article,
.analysis-grid article,
.diagnostic-grid article,
.monte-carlo-grid article,
.stress-testing-grid article,
.efficient-frontier-grid article,
.portfolio-live-check article,
.action-dashboard article,
.journey-guidance-grid article,
.frontier-guidance-grid article,
.robustness-guidance-grid article {
  border-color: var(--qi-border);
  border-radius: var(--qi-radius-md);
  background: var(--qi-surface-strong);
  box-shadow: var(--qi-shadow-xs);
}

.chart-panel {
  padding: 18px;
}

.chart-title strong,
.lane-title strong {
  color: var(--qi-text);
  letter-spacing: -0.01em;
}

.chart-guidance,
.section-intro,
.field-note,
.profile-section label small,
.metric-grid small,
.analysis-grid small,
.diagnostic-grid small {
  color: var(--qi-muted);
}

canvas,
#frontier-chart {
  background: linear-gradient(180deg, #ffffff, #fbfdfc);
  border: 1px solid rgba(32, 52, 44, 0.08);
  border-radius: var(--qi-radius-md);
}

table {
  border-radius: var(--qi-radius-md);
  overflow: hidden;
}

th {
  background: var(--qi-surface-muted);
  color: var(--qi-text-soft);
  font-size: 12px;
  letter-spacing: 0.02em;
}

td {
  color: var(--qi-text-soft);
}

.technical-drawer-panel,
.explain-cloud {
  border-color: var(--qi-border);
  border-radius: var(--qi-radius-lg);
  box-shadow: var(--qi-shadow-md);
}

.qi-v3-component-note {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .workspace {
    gap: 14px;
  }

  .controls,
  .results {
    border-radius: var(--qi-radius-lg);
  }
}

@media (max-width: 560px) {
  .brand,
  .agent-panel,
  .step-nav,
  .table-title,
  .chart-panel {
    border-radius: var(--qi-radius-md);
  }

  .step-button {
    min-height: 40px;
  }
}
