:root {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #233e5b;
  background: #f0f2f4;
  font-synthesis: none;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
.app-shell { width: min(1280px, calc(100% - 48px)); margin: 32px auto; }
.app-header {
  padding: 16px;
  border: 1px solid #294765;
  border-radius: 15px;
  background: linear-gradient(110deg, #091524, #102740 65%, #1b3b60);
  box-shadow: 0 8px 20px #142d461a;
  color: #f2f6fb;
}
.header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; min-height: 64px; }
.identity { display: flex; align-items: center; gap: 14px; padding: 0 0 12px; }
.identity-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid #8092a5;
  border-radius: 15px;
  background: #0a192b;
  box-shadow: inset 0 0 0 5px #152d46;
  color: #d8c18b;
  font-family: Georgia, serif;
  font-size: 28px;
}
.app-name { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .2px; }
.app-subtitle { margin: 2px 0 0; color: #c1cbd7; font-size: 12px; font-weight: 600; }
.version { padding: 4px 10px; border: 1px solid #49617b; border-radius: 20px; background: #ffffff0a; color: #d8e4f1; font-size: 11px; font-weight: 700; white-space: nowrap; }
nav { display: flex; gap: 8px; }
.nav-item { min-width: 0; width: 140px; padding: 10px 24px; border: 1px solid #4477a9; border-radius: 8px; background: #ffffff08; color: #eef5ff; text-align: center; text-decoration: none; font-size: 13px; font-weight: 700; box-shadow: inset 0 0 0 1px #3a679144; }
.nav-item:hover { background: #2b507a; }
.nav-item:focus-visible { outline: 3px solid #c9dcf4; outline-offset: 3px; }
main { margin-top: 12px; }
.content-panel { padding: 22px; border: 1px solid #dfe5ed; border-radius: 10px; background: #fff; box-shadow: 0 3px 12px #142d4605; }
h1 { margin: 0; font-size: 20px; line-height: 1.3; }
.description { margin: 10px 0 24px; color: #657b94; font-size: 13px; }
.placeholder { padding: 34px 28px; border: 1px solid #dce5f0; border-radius: 8px; background: #f7f9fc; }
.status-label { display: inline-block; padding: 4px 9px; border: 1px solid #d6e2f0; border-radius: 5px; background: #edf3fb; color: #476585; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
h2 { margin: 16px 0 8px; font-size: 18px; font-weight: 600; }
.placeholder p { max-width: 640px; margin: 0; color: #657b94; font-size: 13px; }

.data-status { margin-bottom: 24px; }
.data-status > h2 { margin: 0 0 14px; }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.data-card { padding: 20px; border: 1px solid #dce5f0; border-radius: 8px; background: #f7f9fc; }
.data-card h3 { margin: 0 0 10px; font-size: 15px; }
.data-card p { margin: 8px 0 0; font-size: 13px; }
.connection-state { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.connected { background: #e9f8ef; color: #226443; }
.unavailable { background: #f4ede4; color: #80571e; }
.data-count { font-weight: 700; }
.metadata-note, .data-card .metadata-note { color: #657b94; font-size: 11px; }
.access-status { font-size: 13px; margin: 16px 0 4px; }
.simulation-setup { padding: 16px; border: 1px solid #dce5f0; border-radius: 8px; background: #f7f9fc; }
.risk-model { margin-bottom: 24px; padding: 20px; border: 1px solid #dce5f0; border-radius: 8px; background: #f7f9fc; }
.risk-model h2 { margin: 0 0 14px; }
.risk-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
.risk-details dt { font-size: 12px; color: #657b94; }
.risk-details dd { margin: 4px 0 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.risk-model .primary-button { margin-top: 6px; }
.simulation-setup h2 { margin: 0 0 12px; }
.setup-grid { display: grid; grid-template-columns: minmax(250px, 1fr) 180px 140px 165px; gap: 12px 16px; align-items: end; }
.setup-field { display: flex; flex-direction: column; gap: 6px; }
.setup-field[hidden] { display: none; }
.setup-field label { font-size: 13px; font-weight: 600; }
.setup-field input, .setup-field select { width: 100%; min-width: 0; min-height: 42px; padding: 9px 10px; border: 1px solid #bbcbdc; border-radius: 6px; background: #fff; color: #233e5b; font: inherit; font-size: 14px; }
.field-help { margin: 0; color: #657b94; font-size: 12px; }
.primary-button { margin-top: 22px; padding: 11px 24px; border: 1px solid #2264c6; border-radius: 7px; background: #216ce1; color: white; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.primary-button:hover { background: #1b59bc; }
.primary-button:disabled { opacity: .6; cursor: default; }
.setup-field input:focus-visible, .setup-field select:focus-visible, .primary-button:focus-visible { outline: 3px solid #8bb6ec; outline-offset: 2px; }
.form-message { margin: 12px 0 0; color: #476585; font-size: 13px; }
.form-message:empty { display: none; }
.entry-audit { margin-top: 24px; padding: 20px; border: 1px solid #dce5f0; border-radius: 8px; }
.audit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.audit-grid dt { font-size: 12px; color: #657b94; }
.audit-grid dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.audit-table-wrap { overflow-x: auto; }
.entry-audit table { width: 100%; border-collapse: collapse; font-size: 13px; }
.entry-audit th, .entry-audit td { padding: 10px; text-align: left; border-bottom: 1px solid #dce5f0; white-space: nowrap; }
.result-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 14px; }
.result-summary dt { font-size: 12px; color: #657b94; }
.result-summary dd { margin: 4px 0 0; font-weight: 600; }
#entry-inspector { margin-top: 24px; border-top: 1px solid #dce5f0; padding-top: 12px; }
#audit-trade-date { max-width: 100%; margin: 8px; padding: 8px; font: inherit; }
summary, .audit-view { cursor: pointer; color: #22599a; font-weight: 600; }
summary { padding: 12px 0; }
.audit-view { padding: 7px 12px; border: 1px solid #bbcbdc; border-radius: 5px; background: #f7f9fc; }
.valuation-provenance { font-size: 12px; overflow-wrap: anywhere; }
summary:focus-visible, .audit-view:focus-visible { outline: 3px solid #8bb6ec; outline-offset: 2px; }
.capital-chart { margin: 24px 0; }
.capital-chart figcaption { font-weight: 600; }
.capital-chart figcaption span { display: block; font-size: 12px; font-weight: 400; color: #657b94; }
.capital-chart svg { display: block; width: 100%; height: auto; margin-top: 12px; }
.capital-chart text { font: 12px "Segoe UI", sans-serif; fill: #476585; }
.chart-grid { stroke: #e2e8f0; }
.capital-line { stroke: #216ce1; stroke-width: 2; vector-effect: non-scaling-stroke; }
.capital-point { fill: #216ce1; }
.mobile-chart-axis { display: none; }
.result-summary small { display: block; font-weight: 400; }
.incomplete-notice { padding: 12px; background: #fff5e5; color: #80571e; }
#daily-audit { table-layout: fixed; width: 100%; font-size: 12px; }
#daily-audit th, #daily-audit td { padding: 5px; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
#daily-audit th { font-size: 11px; line-height: 1.3; background: #f7f9fc; }
#daily-audit td { font-variant-numeric: tabular-nums; }
#daily-audit small { display: block; font-size: 10px; color: #657b94; }
#daily-audit .date-col { width: 9%; }
#daily-audit .position-col { width: 9%; }
#daily-audit .qty-col { width: 4%; }
#daily-audit .result-col { width: 10%; }
#daily-audit .target-col { width: 7%; }
#daily-audit .recovery-col { width: 7%; }
#daily-audit .audit-col { width: 6%; }
#daily-audit .audit-view { padding: 5px; font-size: 11px; }
#daily-audit .loss { color: #a12635; font-weight: 600; }
#daily-audit .win { color: #226443; font-weight: 600; }
@media (max-width: 800px) {
  #daily-audit, #daily-audit tbody, #daily-audit tr, #daily-audit td { display: block; width: 100%; }
  #daily-audit colgroup, #daily-audit thead { display: none; }
  #daily-audit tr { margin: 12px 0; padding: 10px; border: 1px solid #dce5f0; border-radius: 6px; }
  #daily-audit td { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 5px; border: 0; }
  #daily-audit td::before { content: attr(data-label); font-weight: 600; color: #657b94; }
  .capital-chart svg { height: 180px; }
  .capital-chart svg text { display: none; }
  .mobile-chart-axis { display: block; font-size: 11px; color: #476585; }
  .chart-date-axis { display: flex; justify-content: space-between; gap: 8px; }
}
@media (max-width: 600px) {
  .risk-details { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
  .simulation-setup { padding: 18px; }
  .data-grid { grid-template-columns: 1fr; }
  .app-shell { width: calc(100% - 24px); margin: 12px auto; }
  .app-header { padding: 16px 12px 12px; }
  .header-top { flex-wrap: wrap; gap: 12px; padding-bottom: 24px; }
  .identity { padding: 0; }
  .identity-mark { width: 56px; height: 56px; font-size: 32px; }
  .nav-item { width: 100%; }
  nav { width: 100%; }
  .content-panel { padding: 18px; }
  .placeholder { padding: 24px 18px; }
}
.candidate-table-wrap { max-height: 32rem; overflow: auto; }
.daily-update { margin: 16px 0; padding: 16px; border: 1px solid #dce5f0; border-radius: 9px; }
.update-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.update-heading h2 { margin: 0; font-size: 14px; }
.update-heading a { font-size: 12px; }
.daily-update dd { overflow-wrap: anywhere; }
.selected-candidate { background: #e7f3eb; font-weight: 700; }
.config-strip, .result-context, .chart-legend { font-size: 12px; color: #476585; }
.config-strip { margin: 8px 0 0; }
.result-context { line-height: 1.8; }
#run-progress { margin-top: 16px; padding-top: 12px; border-top: 1px solid #dce5f0; }
#progress-bar { width: 100%; height: 12px; accent-color: #216ce1; }
.progress-metrics { font-size: 13px; font-variant-numeric: tabular-nums; }
.stop-button { padding: 9px 18px; border: 1px solid #a12635; border-radius: 7px; background: #fff1f2; color: #8f2030; font-weight: 700; cursor: pointer; }
.stop-button:disabled { opacity: .6; cursor: default; }
.stop-button:focus-visible { outline: 3px solid #8bb6ec; }
.capital-chart { position: relative; }
.chart-tooltip { position: absolute; z-index: 2; pointer-events: none; max-width: 100%; width: max-content; padding: 10px 12px; border-radius: 6px; background: #102740; color: white; box-shadow: 0 3px 12px #142d4633; font-size: 12px; }
.chart-tooltip div:first-child { font-weight: 700; margin-bottom: 4px; }
.chart-legend span { display: block; color: #657b94; font-size: 11px; }
.point-hit-area { fill: transparent; stroke: none; cursor: pointer; }
.chart-hit:focus { outline: none; }
.active-point .point-hit-area, .chart-hit:focus-visible .point-hit-area { stroke: #476585; stroke-width: 1.5; }
.max-loss-marker { fill: #a12635; stroke: white; stroke-width: 1; }
.loss-marker { fill: #af6b12; stroke: white; stroke-width: 1; }
.black-swan-marker { fill: #632f88; stroke: white; stroke-width: 1; }

/* Compact page chrome and setup; financial content remains unchanged. */
.nav-item[aria-current="page"] { background: #203f64; border-color: #75a7dc; }
.data-status { margin-top: 16px; margin-bottom: 16px; }
.data-card h2 { margin: 0 0 8px; font-size: 14px; }
.risk-model { margin-bottom: 0; }
.entry-field { grid-column: 1; }
.exit-field { grid-column: 1; }
.timeframe-field { grid-column: 2 / 4; }
.run-field { grid-column: 4; margin: 0; min-height: 42px; padding: 9px 12px; }
.custom-date { grid-row: 3; }
#simulation-form > .field-help { margin-top: 8px; }
#progress-state { margin: 0 0 4px; font-size: 13px; }
.progress-metrics { margin: 4px 0 8px; }
#entry-inspector { margin-top: 16px; padding-top: 0; }
#entry-disclosure > summary { padding: 9px 0; font-size: 14px; }
#entry-disclosure[open] > summary { margin-bottom: 4px; }
#daily-audit { border-collapse: separate; border-spacing: 0; }
#daily-audit th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 #bbcbdc; }
#daily-audit time { white-space: nowrap; }
@media (max-width: 1100px) {
  .setup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-field, .exit-field, .timeframe-field, .run-field { grid-column: auto; }
  .custom-date { grid-row: auto; }
}
@media (max-width: 600px) {
  .setup-grid { grid-template-columns: 1fr; }
  .setup-field, .run-field { grid-column: 1; }
  .header-top { align-items: center; padding-bottom: 12px; }
  .identity-mark { width: 40px; height: 40px; font-size: 26px; }
  .identity { gap: 10px; }
  .app-subtitle { font-size: 10px; }
  .nav-item { flex: 1; width: auto; }
}
