:root {
  --ink: #102b2d;
  --ink-soft: #284244;
  --ink-muted: #6c7d7b;
  --paper: #f4f2ed;
  --surface: #ffffff;
  --surface-soft: #f8f7f3;
  --line: #dedfd8;
  --line-strong: #cfd3ca;
  --teal: #0b7770;
  --teal-dark: #075a56;
  --teal-pale: #dbeae6;
  --orange: #e98552;
  --orange-pale: #fae5d8;
  --gold: #c9a45d;
  --blue: #6689a3;
  --danger: #b54f52;
  --danger-pale: #f8e6e6;
  --sidebar: #10292b;
  --sidebar-soft: #183638;
  --sidebar-text: #dbe5e2;
  --shadow-sm: 0 2px 8px rgba(20, 42, 43, .05);
  --shadow-md: 0 12px 35px rgba(20, 42, 43, .10);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --mono: "DM Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(11, 119, 112, .22);
  outline-offset: 2px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px 20px;
  color: var(--sidebar-text);
  background:
    radial-gradient(circle at 10% 10%, rgba(65, 138, 129, .18), transparent 28%),
    var(--sidebar);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
  padding: 0 10px 31px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--sidebar);
  background: #f3efe5;
  border-radius: 12px 12px 12px 4px;
}

.brand-mark svg {
  width: 26px;
  stroke: none;
  fill: currentColor;
}

.brand-copy {
  display: flex;
  flex-direction: column;
}

.brand-copy strong {
  letter-spacing: .02em;
  font-size: 17px;
}

.brand-copy small {
  margin-top: 1px;
  color: #9eb2af;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.nav-caption {
  margin: 0 12px 9px;
  color: #718e8b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #a9bcba;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, .05);
}

.nav-item.is-active {
  color: #fff;
  background: var(--sidebar-soft);
  box-shadow: inset 3px 0 var(--orange);
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item span {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 9px;
}

.data-status {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 13px 11px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #5ac5a7;
  box-shadow: 0 0 0 4px rgba(90, 197, 167, .12);
}

.data-status div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.data-status strong {
  color: #dce9e6;
  font-size: 11px;
}

.data-status small {
  color: #7f9996;
  font-size: 10px;
}

.icon-label-button {
  padding: 10px 11px;
  color: #849e9a;
  background: transparent;
  border: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.icon-label-button:hover {
  color: #fff;
}

.icon-label-button svg {
  width: 16px;
}

.icon-label-button span {
  font-size: 11px;
}

.main-content {
  min-width: 0;
  padding: 26px 34px 24px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow,
.panel-kicker {
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 4px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 2.3vw, 32px);
  font-weight: 600;
  letter-spacing: -.04em;
}

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.025em;
}

.top-actions {
  display: flex;
  gap: 9px;
}

.button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.button:active {
  transform: translateY(0);
}

.button svg {
  width: 16px;
  height: 16px;
}

.button-primary {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.button-primary:hover {
  background: var(--teal-dark);
}

.button-dark {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.button-large {
  min-height: 44px;
  padding-inline: 18px;
}

.request-bar {
  min-height: 72px;
  padding: 12px 12px 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin-bottom: 7px;
}

.request-icon {
  width: 38px;
  height: 38px;
  color: var(--teal);
  background: var(--teal-pale);
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.request-icon svg {
  width: 19px;
}

.request-input-wrap {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.request-input-wrap label {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.request-input-wrap input {
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
}

.request-input-wrap input::placeholder {
  color: #99a5a1;
}

.request-feedback {
  min-height: 18px;
  margin: 0 3px 13px;
  color: var(--teal-dark);
  font-size: 11px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: view-in .28s ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  min-height: 132px;
  padding: 17px 18px 15px;
  border-radius: var(--radius-md);
}

.metric-card-primary {
  color: #fff;
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 255, 255, .1), transparent 35%),
    var(--ink);
  border-color: var(--ink);
}

.metric-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
}

.metric-card-primary .metric-heading {
  color: #aec2bf;
}

.metric-icon {
  width: 28px;
  height: 28px;
  color: var(--teal);
  background: var(--teal-pale);
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.metric-card-primary .metric-icon {
  color: #e2ecea;
  background: rgba(255, 255, 255, .08);
}

.metric-icon svg {
  width: 15px;
}

.metric-value {
  display: block;
  margin-top: 9px;
  font-size: clamp(23px, 2vw, 29px);
  font-weight: 600;
  letter-spacing: -.045em;
}

.metric-card p {
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 10px;
}

.metric-card-primary p {
  color: #94aca8;
}

.positive {
  color: var(--teal);
}

.metric-card-primary .positive {
  color: #75d2b7;
}

.negative {
  color: var(--danger) !important;
}

.risk-label {
  color: var(--orange);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, .75fr);
  gap: 12px;
}

.panel {
  border-radius: var(--radius-md);
  padding: 20px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-kicker {
  margin: 0 0 5px;
}

.projection-panel,
.insight-panel {
  min-height: 370px;
}

.segmented-control {
  padding: 3px;
  display: flex;
  gap: 2px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented-control button {
  min-width: 36px;
  height: 27px;
  padding: 0 8px;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.segmented-control button.is-selected {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(17, 43, 45, .09);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: -5px 0 8px;
  color: var(--ink-muted);
  font-size: 10px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  width: 18px;
  height: 2px;
  display: block;
  background: var(--teal);
}

.legend-line.optimistic {
  background: var(--orange);
  background-image: linear-gradient(90deg, var(--orange) 60%, transparent 60%);
  background-size: 6px 100%;
}

.legend-area {
  width: 18px;
  height: 8px;
  display: block;
  background: var(--teal-pale);
}

.projection-chart {
  position: relative;
  min-height: 283px;
}

.projection-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--ink-muted);
  stroke: none;
  font-family: var(--font);
  font-size: 10px;
}

.range-area {
  fill: var(--teal-pale);
  stroke: none;
  opacity: .7;
}

.median-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
}

.optimistic-line {
  fill: none;
  stroke: var(--orange);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.chart-hit-area {
  fill: transparent;
  stroke: none;
  cursor: crosshair;
}

.hover-line {
  stroke: var(--ink-soft);
  stroke-dasharray: 3 4;
  stroke-width: 1;
  opacity: 0;
  pointer-events: none;
}

.hover-point {
  fill: var(--surface);
  stroke: var(--teal);
  stroke-width: 3;
  opacity: 0;
  pointer-events: none;
}

.chart-end-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  stroke: none;
}

.chart-end-label.median {
  fill: var(--teal-dark);
}

.chart-end-label.high {
  fill: var(--orange);
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 122px;
  padding: 9px 10px;
  color: #fff;
  background: var(--ink);
  border-radius: 7px;
  box-shadow: var(--shadow-md);
  font-size: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -110%);
  transition: opacity .1s ease;
}

.chart-tooltip.is-visible {
  opacity: 1;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip strong {
  margin-top: 2px;
  font-size: 12px;
}

.chart-note {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 9px;
}

.chart-note svg {
  width: 14px;
  flex: none;
}

.text-button {
  padding: 0;
  color: var(--teal);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  color: var(--teal-dark);
}

.donut-wrap {
  padding: 2px 0 16px;
  display: grid;
  place-items: center;
}

.donut {
  width: 155px;
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background .35s ease;
}

.donut::after {
  content: "";
  position: absolute;
  width: 99px;
  height: 99px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(17, 43, 45, .04);
}

.donut-center {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

.donut-center span {
  color: var(--ink-muted);
  font-size: 9px;
}

.donut-center strong {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 18px;
}

.allocation-legend {
  display: grid;
  gap: 10px;
}

.allocation-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 10px;
}

.allocation-item i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.allocation-item strong {
  font-family: var(--mono);
  font-size: 10px;
}

.tag,
.signal-badge,
.validation-badge {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--teal-dark);
  background: var(--teal-pale);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.scenario-list {
  display: grid;
}

.scenario-row {
  width: 100%;
  padding: 12px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.scenario-row:first-child {
  padding-top: 3px;
}

.scenario-row:last-child {
  border-bottom: 0;
}

.scenario-row:hover {
  background: linear-gradient(90deg, transparent, var(--surface-soft), transparent);
}

.scenario-symbol {
  width: 8px;
  height: 28px;
  border-radius: 4px;
  background: var(--teal);
}

.scenario-symbol.rates { background: var(--gold); }
.scenario-symbol.recession { background: var(--danger); }
.scenario-symbol.growth { background: var(--orange); }

.scenario-row span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.scenario-row strong {
  font-size: 10px;
}

.scenario-row small {
  color: var(--ink-muted);
  font-size: 9px;
}

.scenario-row b {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 10px;
}

.stress-result {
  margin-top: 11px;
  padding: 11px 12px;
  background: var(--surface-soft);
  border-radius: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stress-result[hidden] {
  display: none;
}

.stress-result div {
  display: grid;
  gap: 3px;
}

.stress-result span {
  color: var(--ink-muted);
  font-size: 9px;
}

.stress-result strong {
  font-family: var(--mono);
  font-size: 15px;
}

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  display: grid;
  place-items: center;
  font-size: 20px;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.signal-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight-row {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
}

.insight-row:first-child {
  padding-top: 1px;
}

.insight-row:last-child {
  border-bottom: 0;
}

.insight-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: var(--teal-pale);
}

.insight-icon.warning {
  color: #965a2f;
  background: var(--orange-pale);
}

.insight-icon.info {
  color: #50738e;
  background: #e2eaf0;
}

.insight-icon svg {
  width: 15px;
}

.insight-row div:last-child {
  min-width: 0;
}

.insight-row strong {
  display: block;
  margin-bottom: 3px;
  font-size: 10px;
}

.insight-row p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 9px;
  line-height: 1.55;
}

.section-intro {
  padding: 6px 2px 17px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 30px;
}

.section-intro h2 {
  font-size: 24px;
}

.section-intro p:last-child {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.6;
}

.weight-status {
  min-width: 135px;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.weight-status span {
  color: var(--ink-muted);
  font-size: 9px;
}

.weight-status strong {
  font-family: var(--mono);
  font-size: 15px;
}

.weight-status.has-error {
  color: var(--danger);
  border-color: rgba(181, 79, 82, .35);
  background: var(--danger-pale);
}

.portfolio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(270px, .65fr);
  gap: 12px;
}

.portfolio-table-panel {
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  padding: 20px 20px 0;
}

.table-responsive {
  overflow-x: auto;
}

.portfolio-table {
  width: 100%;
  border-collapse: collapse;
}

.portfolio-table th {
  padding: 10px 14px;
  color: var(--ink-muted);
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.portfolio-table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  vertical-align: middle;
  white-space: nowrap;
}

.portfolio-table tr:last-child td {
  border-bottom: 0;
}

.portfolio-table tbody tr:hover {
  background: #fbfbf8;
}

.align-right {
  text-align: right !important;
}

.asset-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--teal-dark);
  background: var(--teal-pale);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
}

.asset-cell span:last-child {
  display: grid;
  gap: 2px;
}

.asset-cell strong {
  font-size: 10px;
}

.asset-cell small {
  max-width: 170px;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 9px;
  text-overflow: ellipsis;
}

.category-pill {
  padding: 4px 7px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 9px;
}

.weight-input {
  width: 66px;
  padding: 6px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 10px;
  text-align: right;
}

.remove-asset {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ink-muted);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.remove-asset:hover {
  color: var(--danger);
  background: var(--danger-pale);
}

.remove-asset svg {
  width: 14px;
}

.table-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink-muted);
  background: var(--surface-soft);
  font-size: 9px;
}

.portfolio-side {
  display: grid;
  align-content: start;
  gap: 12px;
}

.risk-bars {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.risk-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
}

.risk-bar-row span,
.risk-bar-row strong {
  font-size: 9px;
}

.risk-bar-row strong {
  font-family: var(--mono);
}

.bar-track {
  height: 6px;
  grid-column: 1 / -1;
  border-radius: 99px;
  background: var(--surface-soft);
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width .3s ease;
}

.quality-list {
  margin-top: 15px;
  display: grid;
}

.quality-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.quality-row:last-child {
  border-bottom: 0;
}

.quality-check {
  width: 18px;
  height: 18px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: var(--teal-pale);
  border-radius: 50%;
}

.quality-check.warning {
  color: #975d37;
  background: var(--orange-pale);
}

.quality-check svg {
  width: 11px;
}

.quality-row div {
  display: grid;
  gap: 2px;
}

.quality-row strong {
  font-size: 9px;
}

.quality-row small {
  color: var(--ink-muted);
  font-size: 8px;
  line-height: 1.45;
}

.simulation-layout {
  display: grid;
  grid-template-columns: minmax(330px, .8fr) minmax(0, 1.25fr);
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 15px;
}

.field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
}

.field > span,
.code-field > span,
.factor-guide > span {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
}

.field-full {
  grid-column: 1 / -1;
}

.input-prefix,
.input-suffix {
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.input-prefix:focus-within,
.input-suffix:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 119, 112, .09);
}

.input-prefix span,
.input-suffix span {
  padding-inline: 11px;
  color: var(--ink-muted);
  font-size: 11px;
}

.input-prefix span {
  border-right: 1px solid var(--line);
}

.input-suffix span {
  border-left: 1px solid var(--line);
}

.input-prefix input,
.input-suffix input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 11px;
}

.range-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.range-value strong {
  font-family: var(--mono);
  font-size: 15px;
}

.range-value span {
  color: var(--ink-muted);
  font-size: 9px;
}

.range {
  width: 100%;
  height: 4px;
  accent-color: var(--teal);
  cursor: pointer;
}

.risk-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.risk-selector label {
  position: relative;
  cursor: pointer;
}

.risk-selector input {
  position: absolute;
  opacity: 0;
}

.risk-selector span {
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 650;
  transition: border-color .15s ease, background .15s ease;
}

.risk-selector small {
  color: var(--ink-muted);
  font-size: 8px;
  font-weight: 400;
}

.risk-selector input:checked + span {
  border-color: var(--teal);
  background: var(--teal-pale);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.advanced-toggle {
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.advanced-toggle > button {
  width: 100%;
  padding: 14px 0 0;
  border: 0;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.advanced-toggle > button svg {
  width: 16px;
  transition: transform .2s ease;
}

.advanced-toggle > button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.advanced-fields {
  padding-top: 15px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.advanced-fields[hidden] {
  display: none;
}

.field select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 10px;
}

.outcome-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 17px;
}

.outcome-summary > div {
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  gap: 2px;
}

.outcome-summary .featured {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.outcome-summary span,
.outcome-summary small {
  color: var(--ink-muted);
  font-size: 8px;
}

.outcome-summary .featured span,
.outcome-summary .featured small {
  color: #a9bcba;
}

.outcome-summary strong {
  font-family: var(--mono);
  font-size: 14px;
}

.distribution-chart {
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 16px 8px 24px;
  position: relative;
  border-bottom: 1px solid var(--line);
}

.distribution-chart::after {
  content: "Valore finale simulato →";
  position: absolute;
  right: 6px;
  bottom: 5px;
  color: var(--ink-muted);
  font-size: 8px;
}

.distribution-bar {
  flex: 1;
  min-width: 2px;
  height: var(--height);
  background: var(--teal-pale);
  border-radius: 2px 2px 0 0;
}

.distribution-bar.is-central {
  background: var(--teal);
}

.goal-probability {
  padding-top: 19px;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
}

.probability-gauge {
  position: relative;
  width: 120px;
  height: 70px;
}

.probability-gauge svg {
  width: 100%;
  height: 100%;
}

.gauge-track,
.gauge-fill {
  fill: none;
  stroke-width: 9;
}

.gauge-track {
  stroke: var(--surface-soft);
}

.gauge-fill {
  stroke: var(--orange);
  stroke-dasharray: 157;
  stroke-dashoffset: 82;
  transition: stroke-dashoffset .45s ease;
}

.probability-gauge strong {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 18px;
}

.goal-probability > div:last-child span {
  font-size: 10px;
  font-weight: 700;
}

.goal-probability p {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 9px;
  line-height: 1.5;
}

.strategy-grid {
  display: grid;
  grid-template-columns: minmax(300px, .72fr) minmax(360px, 1fr);
  gap: 12px;
}

.comparison-panel {
  grid-column: 1 / -1;
}

.strategy-options {
  display: grid;
  gap: 8px;
}

.strategy-card {
  position: relative;
  min-height: 72px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.strategy-card > input {
  position: absolute;
  opacity: 0;
}

.strategy-check {
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.strategy-check::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
}

.strategy-card:has(input:checked) {
  border-color: var(--teal);
  background: rgba(219, 234, 230, .42);
}

.strategy-card input:checked ~ .strategy-check {
  border-color: var(--teal);
}

.strategy-card input:checked ~ .strategy-check::after {
  background: var(--teal);
}

.strategy-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-pale);
  display: grid;
  place-items: center;
}

.strategy-icon svg {
  width: 16px;
}

.strategy-card > span:last-child {
  display: grid;
  gap: 3px;
}

.strategy-card strong {
  font-size: 10px;
}

.strategy-card small {
  color: var(--ink-muted);
  font-size: 8px;
  line-height: 1.45;
}

.formula-panel {
  display: flex;
  flex-direction: column;
}

.validation-badge.is-invalid {
  color: var(--danger);
  background: var(--danger-pale);
}

.code-field {
  display: grid;
  gap: 7px;
}

.code-field textarea {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: #f8faf8;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  resize: vertical;
}

.factor-guide {
  margin-top: 11px;
  display: grid;
  gap: 7px;
}

.factor-guide div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.factor-guide button {
  padding: 5px 7px;
  color: var(--teal-dark);
  background: var(--teal-pale);
  border: 0;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 8px;
  cursor: pointer;
}

.constraint-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.algorithm-note {
  margin-top: auto;
  padding-top: 17px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink-muted);
}

.algorithm-note svg {
  width: 15px;
  flex: none;
}

.algorithm-note p {
  margin: 0;
  font-size: 8px;
  line-height: 1.55;
}

.mini-legend {
  display: flex;
  gap: 13px;
  color: var(--ink-muted);
  font-size: 9px;
}

.mini-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.mini-legend .current {
  background: var(--line-strong);
}

.mini-legend .proposed {
  background: var(--teal);
}

.comparison-chart {
  display: grid;
  gap: 12px;
}

.comparison-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 45px;
  gap: 12px;
  align-items: center;
}

.comparison-row > span {
  overflow: hidden;
  font-size: 9px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dual-bar {
  display: grid;
  gap: 3px;
}

.dual-bar i {
  display: block;
  height: 6px;
  border-radius: 99px;
  transition: width .3s ease;
}

.dual-bar .bar-current {
  background: var(--line-strong);
}

.dual-bar .bar-proposed {
  background: var(--teal);
}

.comparison-row strong {
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.app-footer {
  padding: 22px 2px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink-muted);
  font-size: 8px;
}

.app-footer p {
  margin: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 25px;
  background: rgba(7, 26, 28, .52);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(620px, 100%);
  max-height: min(730px, calc(100vh - 50px));
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(6, 25, 27, .25);
  overflow-y: auto;
  animation: modal-in .2s ease both;
}

.modal-small {
  width: min(470px, 100%);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 17px;
}

.search-field {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.search-field:focus-within {
  border-color: var(--teal);
}

.search-field svg {
  width: 17px;
  color: var(--ink-muted);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 11px;
}

.asset-results {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.asset-result {
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  text-align: left;
  cursor: pointer;
}

.asset-result:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.asset-result > span:nth-child(2) {
  display: grid;
  gap: 2px;
}

.asset-result strong {
  font-size: 10px;
}

.asset-result small {
  color: var(--ink-muted);
  font-size: 8px;
}

.asset-result > span:last-child {
  color: var(--teal);
  font-size: 9px;
  font-weight: 700;
}

.empty-results {
  padding: 30px 10px;
  color: var(--ink-muted);
  font-size: 10px;
  text-align: center;
}

.export-options {
  display: grid;
  gap: 8px;
}

.export-options > button {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  text-align: left;
  cursor: pointer;
}

.export-options > button:hover {
  border-color: var(--teal);
  background: rgba(219, 234, 230, .32);
}

.export-icon {
  width: 35px;
  height: 35px;
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-pale);
  display: grid;
  place-items: center;
}

.export-icon svg,
.export-options > button > svg {
  width: 16px;
}

.export-options > button > span:nth-child(2) {
  display: grid;
  gap: 2px;
}

.export-options strong {
  font-size: 10px;
}

.export-options small {
  color: var(--ink-muted);
  font-size: 8px;
}

.source-card {
  margin-bottom: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.source-card.is-active {
  border-color: var(--teal);
  background: rgba(219, 234, 230, .32);
}

.source-card.is-disabled {
  opacity: .6;
}

.source-radio {
  width: 15px;
  height: 15px;
  border: 1px solid var(--teal);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--surface);
  background: var(--teal);
}

.source-card div {
  display: grid;
  gap: 2px;
}

.source-card strong {
  font-size: 10px;
}

.source-card small {
  color: var(--ink-muted);
  font-size: 8px;
}

.modal-note {
  margin: 14px 0 0;
  padding: 11px;
  color: var(--ink-muted);
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 9px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  min-width: 260px;
  padding: 13px 15px;
  color: #fff;
  background: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 9px;
  animation: toast-in .25s ease both;
}

.toast[hidden] {
  display: none;
}

.toast svg {
  width: 17px;
  color: #79d0b6;
}

.toast span {
  font-size: 10px;
  font-weight: 650;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 208px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 13px;
  }

  .main-content {
    padding-inline: 22px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .portfolio-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .allocation-panel,
  .scenario-panel {
    min-height: auto;
  }

  .allocation-panel {
    display: grid;
    grid-template-columns: auto minmax(170px, 1fr);
    align-items: center;
    gap: 0 25px;
  }

  .allocation-panel .panel-header {
    grid-column: 1 / -1;
  }

  .portfolio-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 15px 16px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
  }

  .brand {
    padding: 0;
  }

  .sidebar-nav {
    display: flex;
    justify-content: flex-end;
    overflow-x: auto;
  }

  .nav-caption,
  .sidebar-foot {
    display: none;
  }

  .nav-item {
    width: auto;
    padding: 9px 10px;
    white-space: nowrap;
  }

  .nav-item.is-active {
    box-shadow: inset 0 -3px var(--orange);
  }

  .nav-item span {
    font-size: 10px;
  }

  .nav-item svg {
    width: 16px;
  }

  .main-content {
    padding: 22px 16px;
  }

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

  .comparison-panel {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .sidebar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .brand {
    justify-content: center;
  }

  .sidebar-nav {
    justify-content: flex-start;
  }

  .nav-item span {
    display: none;
  }

  .nav-item {
    flex: 1;
    justify-content: center;
  }

  .topbar,
  .section-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .top-actions .button {
    width: 100%;
  }

  .top-actions {
    flex-direction: column;
  }

  .request-bar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .request-bar .button {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .dashboard-grid {
    display: block;
  }

  .dashboard-grid > .panel {
    margin-bottom: 12px;
  }

  .panel {
    padding: 16px;
  }

  .allocation-panel {
    display: block;
  }

  .form-grid,
  .advanced-fields,
  .constraint-grid,
  .portfolio-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .risk-selector {
    grid-template-columns: minmax(0, 1fr);
  }

  .outcome-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .goal-probability {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .comparison-row {
    grid-template-columns: 90px minmax(0, 1fr) 39px;
    gap: 7px;
  }

  .app-footer,
  .table-footer {
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .top-actions,
  .request-bar,
  .request-feedback,
  .segmented-control,
  .text-button,
  .app-footer {
    display: none !important;
  }

  .main-content {
    max-width: none;
    padding: 0;
  }

  .view {
    display: none !important;
  }

  #view-quadro {
    display: block !important;
  }

  .metric-card,
  .panel {
    break-inside: avoid;
    box-shadow: none;
  }

  .metric-card-primary {
    color: var(--ink);
    background: #fff;
    border-color: var(--line);
  }

  .metric-card-primary .metric-heading,
  .metric-card-primary p {
    color: var(--ink-muted);
  }
}
