/* Wealth calculators (/calculators) — 7 Oct 2026. Builds on landing.css (lp-*).
   Series colours: the validated 8-slot categorical palette, one fixed slot per
   instrument (colour follows the instrument, never its rank). Dark is the site
   default; light steps under [data-bs-theme="light"]. */
.calc-root {
  --cs1: #3987e5; --cs2: #d95926; --cs3: #199e70; --cs4: #c98500;
  --cs5: #d55181; --cs6: #008300; --cs7: #9085e9; --cs8: #e66767;
  --c-inv: #5b5b63;
}
[data-bs-theme="light"] .calc-root {
  --cs1: #2a78d6; --cs2: #eb6834; --cs3: #1baf7a; --cs4: #eda100;
  --cs5: #e87ba4; --cs6: #008300; --cs7: #4a3aa7; --cs8: #e34948;
  --c-inv: #c4c4cc;
}

/* tabs */
.calc-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px; margin-bottom: 18px;
  background: var(--ds-surface-raised); border: 1px solid var(--ds-border); border-radius: 14px;
  scrollbar-width: thin;
}
.calc-tab {
  flex: none; border: 0; background: transparent; color: var(--ds-text-secondary);
  font-size: .86rem; font-weight: 600; padding: 9px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.calc-tab:hover { color: var(--ds-text); background: var(--ds-bg-subtle); }
.calc-tab.active { color: #fff; background: linear-gradient(135deg, var(--ds-primary), var(--ds-info)); }

/* cards + text */
.calc-card {
  background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: 16px;
  padding: 18px 20px; margin-bottom: 16px;
}
.calc-h2 { font-size: 1.25rem; font-weight: 800; margin: 0 0 4px; color: var(--ds-text); }
.calc-h3 { font-size: 1rem; font-weight: 700; margin: 0 0 8px; color: var(--ds-text); }
.calc-lead { font-size: .88rem; color: var(--ds-text-secondary); margin: 0 0 14px; line-height: 1.55; }
.calc-note { font-weight: 400; font-size: .72rem; color: var(--ds-text-muted); line-height: 1.35; margin-top: 2px; }
details.calc-card summary { cursor: pointer; font-weight: 600; color: var(--ds-text); }

/* form */
.calc-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 14px; margin-bottom: 16px; }
.calc-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.calc-field span { font-size: .76rem; font-weight: 600; color: var(--ds-text-secondary); }

/* tables */
.calc-table { margin: 0; font-size: .84rem; color: var(--ds-text); }
.calc-table th { font-size: .72rem; font-weight: 700; color: var(--ds-text-secondary); white-space: nowrap; }
.calc-table td, .calc-table th { background: transparent !important; color: inherit; border-color: var(--ds-border); vertical-align: middle; }
.calc-cmp td:first-child { min-width: 170px; max-width: 250px; white-space: normal; }
.calc-cmp td, .calc-cmp th { padding-inline: 6px; }
.calc-rate { max-width: 86px; }

/* keys, risk chips */
.calc-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; flex: none; }
.calc-key.dash { height: 3px; border-radius: 2px; vertical-align: 3px; background: repeating-linear-gradient(90deg, var(--ds-text-muted) 0 4px, transparent 4px 7px) !important; }
.cs1 { background: var(--cs1); } .cs2 { background: var(--cs2); } .cs3 { background: var(--cs3); } .cs4 { background: var(--cs4); }
.cs5 { background: var(--cs5); } .cs6 { background: var(--cs6); } .cs7 { background: var(--cs7); } .cs8 { background: var(--cs8); }
.cinv { background: var(--c-inv); }
.cgain { background: linear-gradient(90deg, var(--cs1) 0 33%, var(--cs3) 33% 66%, var(--cs2) 66%); }
.calc-risk { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--ds-border); color: var(--ds-text); }
.calc-risk::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.calc-risk.r0::before { background: var(--ds-success); }
.calc-risk.r1::before { background: color-mix(in srgb, var(--ds-success) 55%, var(--ds-warning, #f59e0b)); }
.calc-risk.r2::before { background: var(--ds-warning, #f59e0b); }
.calc-risk.r3::before { background: var(--ds-danger); }
.calc-scen { font-size: .8rem; color: var(--ds-text-secondary); margin: 12px 0 0; }
.calc-warn { font-size: .78rem; color: var(--ds-text-secondary); }
.calc-warn div { margin-top: 6px; }
.calc-warn:empty { display: none; }

/* stats */
.calc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.calc-stats:empty { display: none; }
.calc-stat { border: 1px solid var(--ds-border); border-radius: 12px; padding: 10px 12px; background: var(--ds-surface-raised); }
.calc-stat .k { font-size: .72rem; color: var(--ds-text-secondary); font-weight: 600; }
.calc-stat .v { font-size: 1.15rem; font-weight: 800; color: var(--ds-text); margin-top: 2px; }
.calc-stat .sub { font-size: .7rem; color: var(--ds-text-muted); }
.calc-stat.hero { border-color: color-mix(in srgb, var(--ds-primary) 55%, var(--ds-border)); background: color-mix(in srgb, var(--ds-primary) 10%, var(--ds-surface-raised)); }
.calc-stat.hero .v { font-size: 1.4rem; }

/* mix */
.calc-mixgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px 16px; margin-bottom: 14px; }
.calc-mixrow { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .84rem; color: var(--ds-text); }
.calc-mixrow .nm { flex: 1; }
.calc-mixrow input { max-width: 80px; }
.calc-mixtotal.ok { color: var(--ds-success); }
.calc-mixtotal.bad { color: var(--ds-danger); }

/* legend + charts */
.calc-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.calc-leg {
  display: inline-flex; align-items: center; font-size: .76rem; font-weight: 600; color: var(--ds-text-muted);
  border: 1px solid var(--ds-border); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.calc-leg.on { color: var(--ds-text); background: var(--ds-surface-raised); }
.calc-leg:not(.on) .calc-key { opacity: .35; }
.calc-leg:disabled { cursor: default; opacity: 1; }
.calc-chart { position: relative; }
.calc-svg { display: block; width: 100%; height: auto; overflow: visible; }
.calc-grid { stroke: var(--ds-border); stroke-width: 1; stroke-dasharray: 2 4; }
.calc-axis { stroke: var(--ds-border-strong, var(--ds-border)); stroke-width: 1; }
.calc-tick { fill: var(--ds-text-muted); font: 500 11px var(--ds-font, system-ui, sans-serif); }
.calc-label { fill: var(--ds-text-secondary); font: 600 12px var(--ds-font, system-ui, sans-serif); }
.calc-val { fill: var(--ds-text); font: 700 12px var(--ds-font, system-ui, sans-serif); }
.calc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; background: none; }
.calc-line.cs1 { stroke: var(--cs1); } .calc-line.cs2 { stroke: var(--cs2); } .calc-line.cs3 { stroke: var(--cs3); } .calc-line.cs4 { stroke: var(--cs4); }
.calc-line.cs5 { stroke: var(--cs5); } .calc-line.cs6 { stroke: var(--cs6); } .calc-line.cs7 { stroke: var(--cs7); } .calc-line.cs8 { stroke: var(--cs8); }
.calc-line.cinv { stroke: var(--ds-text-muted); }
.calc-line.calc-dash { stroke-dasharray: 6 5; stroke-width: 1.5; }
.calc-bar.cs1 { fill: var(--cs1); } .calc-bar.cs2 { fill: var(--cs2); } .calc-bar.cs3 { fill: var(--cs3); } .calc-bar.cs4 { fill: var(--cs4); }
.calc-bar.cs5 { fill: var(--cs5); } .calc-bar.cs6 { fill: var(--cs6); } .calc-bar.cs7 { fill: var(--cs7); } .calc-bar.cs8 { fill: var(--cs8); }
.calc-inv { fill: var(--c-inv); }
.calc-guide { stroke: var(--ds-text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.calc-dot { stroke: var(--ds-surface); stroke-width: 2; }
.calc-dot.cs1 { fill: var(--cs1); } .calc-dot.cs2 { fill: var(--cs2); } .calc-dot.cs3 { fill: var(--cs3); } .calc-dot.cs4 { fill: var(--cs4); }
.calc-dot.cs5 { fill: var(--cs5); } .calc-dot.cs6 { fill: var(--cs6); } .calc-dot.cs7 { fill: var(--cs7); } .calc-dot.cs8 { fill: var(--cs8); }
.calc-dot.cinv { fill: var(--ds-text-muted); }
.calc-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--ds-surface-raised); color: var(--ds-text); border: 1px solid var(--ds-border);
  border-radius: 10px; padding: 8px 10px; font-size: .76rem; line-height: 1.6; box-shadow: var(--ds-shadow-md);
}

/* learn + disclaimer */
.calc-learn { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.calc-learn-ic { font-size: 1.5rem; color: var(--ds-primary); display: block; margin-bottom: 8px; }
.calc-disclaimer {
  max-width: 980px; margin: 0 auto; font-size: .74rem; line-height: 1.55; color: var(--ds-text-muted);
  border: 1px solid var(--ds-border); background: var(--ds-surface-raised); border-radius: 12px; padding: 12px 16px;
}
@media (max-width: 860px) {
  .calc-learn { grid-template-columns: 1fr; }
  .calc-card { padding: 14px; }
  .calc-form { grid-template-columns: 1fr 1fr; }
}
/* phones/tablets: one card per row (same idea as design-system .table-stack) */
@media (max-width: 991.98px) {
  .calc-table.table-stack thead { display: none; }
  .calc-table.table-stack, .calc-table.table-stack tbody, .calc-table.table-stack tr,
  .calc-table.table-stack td { display: block; width: 100%; }
  .calc-table.table-stack tr {
    border: 1px solid var(--ds-border); border-radius: 12px; margin-bottom: 10px; padding: 8px 12px;
    background: var(--ds-surface-raised);
  }
  .calc-table.table-stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    border: 0 !important; padding: 3px 0 !important; text-align: right !important; max-width: none !important;
  }
  .calc-table.table-stack td[data-label]::before {
    content: attr(data-label); color: var(--ds-text-muted); font-size: .74rem; text-align: left; flex: 1 1 auto;
  }
  .calc-table.table-stack td.stack-title { justify-content: flex-start; text-align: left !important; font-weight: 600; padding-bottom: 6px !important; }
  .calc-table.table-stack td > div { text-align: right; }
  .calc-table.table-stack td.stack-title > div { text-align: left; }
  .calc-rate { margin-left: auto; }
}
