/* Portfolio backtester: every colour comes from the active StonkHQ skin (CSS variables set on <html> by js/skins.js).
 * Scoped to .bt-root so it cannot restyle the site header or nav drawer. */
.bt-root {
  --bt-surface: var(--surface);
  --bt-surface2: var(--surface2);
  --bt-ink: var(--text);
  --bt-text: var(--text2);
  --bt-muted: var(--muted);
  --bt-line: var(--border);
  --bt-line-strong: var(--axis);
  --bt-brand: var(--accent-fill);
  --bt-brand-ink: var(--accent-ink);
  --bt-accent: var(--accent);
  --bt-danger: var(--down);
  --bt-success: var(--up);
  --bt-radius: 8px;
  --bt-control: 30px;
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  min-height: 100vh;
}
.bt-root *, .bt-root *::before, .bt-root *::after { box-sizing: border-box; }
.bt-root button, .bt-root input, .bt-root select, .bt-root textarea { font: inherit; }
.bt-root button { cursor: pointer; }
.bt-root button:disabled, .bt-root input:disabled, .bt-root select:disabled { cursor: not-allowed; opacity: .58; }

.bt-head { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 12px; align-items: center; padding: 10px 18px 2px; }
.bt-root .brand-block { min-width: 0; }
.bt-root .brand-block h1 { margin: 0; color: var(--text); font-family: var(--display); font-size: 20px; font-weight: 800; letter-spacing: 0; line-height: 1.12; }
.bt-root .brand-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; color: var(--muted); font-size: 12px; }
.bt-root .status-pill {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border: 1px solid var(--bt-line); border-radius: 999px;
  background: var(--bt-surface); color: var(--text2); white-space: nowrap;
}
.bt-root .toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.bt-root .btn {
  min-height: var(--bt-control); padding: 0 12px; border: 1px solid var(--bt-line-strong); border-radius: var(--bt-radius);
  background: var(--bt-surface); color: var(--bt-ink); font-weight: 700; white-space: nowrap; box-shadow: none; text-shadow: none;
}
.bt-root .btn:hover:not(:disabled) { border-color: var(--bt-brand); text-decoration: none; }
.bt-root .btn.primary { border-color: var(--bt-brand); background: var(--bt-brand); color: var(--bt-brand-ink); }
.bt-root .btn.secondary { border-color: color-mix(in srgb, var(--bt-success) 55%, var(--bt-line)); background: color-mix(in srgb, var(--bt-success) 12%, var(--bt-surface)); color: var(--bt-ink); }
.bt-root .btn.warning { border-color: color-mix(in srgb, var(--bt-accent) 55%, var(--bt-line)); background: color-mix(in srgb, var(--bt-accent) 12%, var(--bt-surface)); color: var(--bt-ink); }
.bt-root .btn.danger { border-color: color-mix(in srgb, var(--bt-danger) 55%, var(--bt-line)); background: color-mix(in srgb, var(--bt-danger) 12%, var(--bt-surface)); color: var(--bt-danger); }
.bt-root .btn.icon { display: inline-grid; place-items: center; width: var(--bt-control); padding: 0; font-size: 17px; line-height: 1; }
.bt-root .btn.small { min-height: 26px; padding: 0 8px; font-size: 12px; }

/* One column: a compact setup surface above full-width results. Only the period, the portfolios and Run are on show;
 * everything else lives in a disclosure that summarises itself while closed. */
.bt-root .layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 18px 20px; }
.bt-root .results-column { display: grid; gap: 10px; min-width: 0; }
.bt-root .setup-area { display: grid; gap: 8px; }
.bt-root .setup-card {
  border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface);
  box-shadow: var(--shadow); padding: 10px 12px; display: grid; gap: 10px;
}

/* essentials: period + dates + starting value, capped so they never stretch across the screen */
.bt-root .essentials { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.bt-root .essentials > .field { display: flex; align-items: center; gap: 6px; }
.bt-root .essentials > .field > label { white-space: nowrap; }
.bt-root .essentials input[type="date"] { width: 138px; }
.bt-root .essentials input[type="number"] { width: 96px; }
.bt-root .seg { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.bt-root .seg .btn { padding: 0 9px; }

.bt-root .port-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.bt-root .port-head h2 { margin: 0; color: var(--text); font-size: 15px; font-weight: 800; }
.bt-root .port-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bt-root .port-add .field.bare { width: auto; }
.bt-root .port-add .field.bare select { min-height: 30px; padding: 0 8px; font-size: 12px; max-width: 190px; }
.bt-root .portfolio-list, .bt-root .cashflow-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 8px; align-items: start;
}
.bt-root .port-card .item-card-header { grid-template-columns: minmax(0, 1fr) auto auto; }
.bt-root .port-name {
  min-width: 0; width: 100%; border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text); font-weight: 800; padding: 4px 6px;
}
.bt-root .port-name:hover { border-color: var(--bt-line); }
.bt-root .port-name:focus { border-color: var(--bt-brand); background: var(--input-bg); outline: none; }

/* disclosures: closed by default, with a one-line summary of what is inside */
.bt-root .disc-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; align-items: start; }
.bt-root .disc { border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); overflow: hidden; }
.bt-root .disc.open { grid-column: 1 / -1; box-shadow: var(--shadow); }
.bt-root .disc-row { grid-auto-flow: row dense; }
.bt-root .disc-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; text-align: left;
  border: 0; background: var(--bt-surface2); color: var(--text); font-weight: 800; font-size: 12px;
}
.bt-root .disc-head:hover { background: var(--wash); }
.bt-root .disc-caret { width: 0; height: 0; border-left: 6px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent; flex: none; transition: transform .18s ease; }
.bt-root .disc.open .disc-caret { transform: rotate(90deg); }
.bt-root .disc-meta { margin-left: auto; color: var(--muted); font-weight: 650; font-size: 12px; text-align: right; }
.bt-root .disc-body { padding: 10px; border-top: 1px solid var(--bt-line); }
.bt-root .disc-body > .form-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 260px)); justify-content: start; }
/* the per-portfolio rebalancing block sits inside a card, so it stays plain */
.bt-root .disc.sub { border: 0; border-top: 1px solid var(--bt-line); border-radius: 0; background: transparent; }
.bt-root .disc.sub .disc-head { background: transparent; padding: 8px 0; font-size: 12px; }
.bt-root .disc.sub .disc-head:hover { background: transparent; color: var(--bt-brand); }
.bt-root .disc.sub .disc-body { padding: 0 0 8px; border-top: 0; }
.bt-root .disc.sub.open { box-shadow: none; }

/* share & export menu */
.bt-root .menu { position: relative; }
.bt-root .menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 6px; padding: 8px; min-width: 200px;
  border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); box-shadow: var(--shadow);
}
.bt-root .menu-body .btn { width: 100%; }

.bt-root .panel { border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); box-shadow: var(--shadow); }
.bt-root .panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 12px;
  border-bottom: 1px solid var(--bt-line); background: var(--bt-surface2); border-radius: var(--bt-radius) var(--bt-radius) 0 0;
}
.bt-root .panel-header h2, .bt-root .panel-header h3 { margin: 0; color: var(--text); font-size: 15px; font-weight: 800; letter-spacing: 0; }
.bt-root .panel-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; justify-content: flex-end; }
.bt-root .panel-body { padding: 14px; }

.bt-root .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 12px; }
.bt-root .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bt-root .form-grid.single { grid-template-columns: 1fr; }
.bt-root .field { display: grid; gap: 3px; min-width: 0; }
.bt-root .field label, .bt-root .field-label { color: var(--muted); font-size: 11px; font-weight: 800; }
.bt-root .field input, .bt-root .field select, .bt-root .field textarea {
  min-height: var(--bt-control); width: 100%; min-width: 0; border: 1px solid var(--bt-line-strong); border-radius: var(--bt-radius);
  background: var(--input-bg); color: var(--text); padding: 4px 8px; outline: none;
}
.bt-root .field input:focus, .bt-root .field select:focus, .bt-root .field textarea:focus {
  border-color: var(--bt-brand); box-shadow: 0 0 0 3px var(--accent-soft);
}
.bt-root .check-row {
  display: flex; align-items: center; gap: 8px; min-height: var(--bt-control); padding: 7px 9px; border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius); background: var(--bt-surface2); color: var(--text); font-size: 13px; font-weight: 700;
}
.bt-root .check-row input { width: 16px; height: 16px; accent-color: var(--bt-brand); }
.bt-root .hint { color: var(--muted); font-size: 12px; }
.bt-root .hint code { font-family: var(--mono, ui-monospace, monospace); }
.bt-root .inline-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bt-root .mt10 { margin-top: 10px; }
.bt-root .mt12 { margin-top: 12px; }
.bt-root .portfolio-list, .bt-root .cashflow-list, .bt-root .saved-list { display: grid; gap: 10px; }

.bt-root .item-card { border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); }
.bt-root .item-card-header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 5px 6px 5px 8px;
  border-bottom: 1px solid var(--bt-line); background: var(--bt-surface2); border-radius: var(--bt-radius) var(--bt-radius) 0 0;
}
.bt-root .item-title { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; min-width: 0; }
.bt-root .item-title strong { color: var(--text); overflow-wrap: anywhere; }
.bt-root .item-body { display: grid; gap: 8px; padding: 8px; }
.bt-root .asset-grid { display: grid; gap: 4px; }
.bt-root .asset-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 26px; gap: 4px; align-items: end; }
.bt-root .asset-row .field { gap: 2px; }
.bt-root .asset-row input { text-transform: uppercase; }
/* holdings: one header row, slim rows, and a long list scrolls inside its card instead of stretching the page */
.bt-root .asset-head { display: grid; grid-template-columns: minmax(0, 1fr) 76px 26px; gap: 4px; padding: 0 2px; color: var(--muted); font-size: 11px; font-weight: 800; }
.bt-root .asset-head span:nth-child(2) { text-align: right; padding-right: 8px; }
.bt-root .asset-grid.holdings { max-height: 262px; overflow-y: auto; scrollbar-width: thin; margin-top: -4px; }
.bt-root .holdings input {
  width: 100%; min-width: 0; height: 28px; border: 1px solid var(--bt-line-strong); border-radius: 6px;
  background: var(--input-bg); color: var(--text); padding: 3px 7px; outline: none;
}
.bt-root .holdings input[type="number"] { text-align: right; }
.bt-root .holdings input:focus { border-color: var(--bt-brand); box-shadow: 0 0 0 2px var(--accent-soft); }
.bt-root .asset-row .btn.icon { width: 26px; min-height: 26px; font-size: 15px; }
.bt-root .item-card-header .btn.icon { width: 26px; min-height: 26px; font-size: 14px; }

.bt-root .tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border: 1px solid var(--bt-line); border-radius: 999px;
  background: var(--bt-surface2); color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap;
}
.bt-root .tag.good { border-color: color-mix(in srgb, var(--bt-success) 55%, var(--bt-line)); background: color-mix(in srgb, var(--bt-success) 13%, var(--bt-surface)); color: var(--bt-success); }
.bt-root .tag.bad { border-color: color-mix(in srgb, var(--bt-danger) 55%, var(--bt-line)); background: color-mix(in srgb, var(--bt-danger) 13%, var(--bt-surface)); color: var(--bt-danger); }
.bt-root .tag.warn { border-color: color-mix(in srgb, var(--bt-accent) 55%, var(--bt-line)); background: color-mix(in srgb, var(--bt-accent) 13%, var(--bt-surface)); color: var(--bt-accent); }

.bt-root .tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--bt-line); background: var(--bt-surface2); }
.bt-root .tab {
  min-height: 26px; padding: 0 9px; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface);
  color: var(--text2); font-size: 12px; font-weight: 800;
}
.bt-root .tab:hover { border-color: var(--bt-brand); }
.bt-root .tab.active { border-color: var(--bt-brand); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 -2px 0 var(--bt-brand); }

.bt-root .results-empty { padding: 18px 14px; color: var(--muted); font-weight: 700; text-align: center; }
.bt-root .result-body { display: grid; gap: 10px; padding: 10px; }
.bt-root .metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; position: relative; }
.bt-root .metric-strip .stat { padding: 8px 12px; }
.bt-root .metric-strip .stat .v { font-size: 20px; }
/* value and drawdown share a row so the summary fits on one screen */
.bt-root .chart-pair { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px; align-items: stretch; }
.bt-root .chart-pair .fxchart { display: flex; }
.bt-root .chart-pair .fxchart > .card { flex: 1; }
.bt-root .metric-strip .stat { min-width: 0; }

.bt-root .chart-wrap { min-height: 340px; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); padding: 10px; }
.bt-root .chart-wrap.short { min-height: 250px; }
.bt-root canvas { display: block; width: 100%; height: 320px; }
.bt-root .chart-wrap.short canvas { height: 230px; }

.bt-root .table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); }
.bt-root table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: 12px; }
.bt-root th, .bt-root td { padding: 5px 8px; border-bottom: 1px solid var(--bt-line); text-align: right; white-space: nowrap; }
.bt-root th:first-child, .bt-root td:first-child { text-align: left; position: sticky; left: 0; background: inherit; z-index: 1; }
.bt-root th { background: var(--bt-surface2); color: var(--text); font-size: 12px; font-weight: 800; }
.bt-root td { color: var(--text2); }
.bt-root tbody tr:nth-child(even) { background: var(--wash); }
.bt-root tbody tr:hover { background: var(--accent-soft); }
.bt-root .negative { color: var(--bt-danger); }
.bt-root .positive { color: var(--bt-success); }

.bt-root .subgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bt-root .control-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.bt-root .control-row .field { width: min(220px, 100%); }
.bt-root .notice {
  padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--bt-accent) 50%, var(--bt-line)); border-radius: var(--bt-radius);
  background: color-mix(in srgb, var(--bt-accent) 10%, var(--bt-surface)); color: var(--text); font-size: 12px; font-weight: 700;
}
.bt-root .notice.quiet { padding: 0 2px; border: 0; background: none; color: var(--muted); font-weight: 600; }
.bt-root .error-box {
  display: grid; gap: 5px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--bt-danger) 55%, var(--bt-line)); border-radius: var(--bt-radius);
  background: color-mix(in srgb, var(--bt-danger) 11%, var(--bt-surface)); color: var(--text); font-size: 13px; font-weight: 700;
}
.bt-root .heat-cell { color: #fff; font-weight: 800; text-align: center; text-shadow: 0 1px 1px rgba(0, 0, 0, .35); }
.bt-root .section-title { margin-bottom: 8px; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); }
.bt-root .pie-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.bt-root .pie-box { display: grid; gap: 7px; justify-items: center; padding: 10px; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); }
.bt-root .pie-box canvas { width: 180px; height: 180px; }

/* full-width charts would be very squat at the narrow-column height */
@media (min-width: 1200px) {
  .bt-root .chart-wrap { min-height: 420px; }
  .bt-root canvas { height: 400px; }
  .bt-root .chart-wrap.short { min-height: 300px; }
  .bt-root .chart-wrap.short canvas { height: 280px; }
}
@media (max-width: 1100px) {
  .bt-root .chart-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .bt-head { grid-template-columns: 1fr; padding: 12px; }
  .bt-root .toolbar { justify-content: stretch; }
  .bt-root .toolbar .btn { flex: 1 1 auto; }
  .bt-root .layout { padding: 12px; }
  .bt-root .setup-toggle { margin-left: 0; }
  .bt-root .form-grid, .bt-root .form-grid.three, .bt-root .subgrid, .bt-root .essentials,
  .bt-root .disc-body > .form-grid,
  .bt-root .portfolio-list, .bt-root .cashflow-list { grid-template-columns: 1fr; }
  .bt-root .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bt-root .chart-pair { grid-template-columns: minmax(0, 1fr); }
  .bt-root canvas { height: 260px; }
}
@media (max-width: 460px) {
  .bt-root .metric-strip { grid-template-columns: 1fr; }
  .bt-root .item-card-header { grid-template-columns: 1fr; }
  .bt-root .panel-actions { justify-content: flex-start; }
}
.bt-noscript { padding: 18px; }


/* ---- juice, all gated on the site-wide Effects dial (html[data-fx]) ---- */
html[data-fx="full"] .bt-root .result-body > * { animation: vault-rise .5s cubic-bezier(.16, .9, .25, 1) backwards; }
html[data-fx="full"] .bt-root .result-body > *:nth-child(2) { animation-delay: .05s; }
html[data-fx="full"] .bt-root .result-body > *:nth-child(3) { animation-delay: .1s; }
html[data-fx="full"] .bt-root .result-body > *:nth-child(n+4) { animation-delay: .15s; }
html[data-fx="full"] .bt-root .item-card, html[data-fx="full"] .bt-root .disc { animation: vault-rise .45s cubic-bezier(.16, .9, .25, 1) backwards; }
html[data-fx="full"] .bt-root .btn.primary:active { transform: translateY(1px) scale(.985); }
.bt-root .btn.primary { transition: transform .12s ease, filter .12s ease; }
.bt-root .btn.primary:hover { filter: brightness(1.06); }

/* ---- charts from the shared layer: the .card inside fills the slot, the page frame is the card's own ---- */
.bt-root .fxchart { min-width: 0; }
.bt-root .fxchart .card { margin: 0; }
.bt-root .disc:not(.open) .disc-body { display: none; }
.bt-root .menu:not(.open) .menu-body { display: none; }
/* let wide tables scroll inside their own box instead of widening the page on phones */
.bt-root .panel, .bt-root .result-body, .bt-root .subgrid > *, .bt-root .chart-pair > * { min-width: 0; }

/* ---- consolidated layout: a centred column, one setup card, chips for the folded extras ---- */
.bt-root .app-shell { max-width: 1320px; margin: 0 auto; }
.bt-root .brand-block { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.bt-root .brand-block h1 { font-size: 18px; }
.bt-root .brand-meta { margin-top: 0; gap: 6px; }
.bt-root .status-pill { min-height: 20px; padding: 1px 8px; font-size: 11px; }
.bt-root .setup-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
/* Save & load menu in the header */
.bt-root .save-menu .menu-body { min-width: 380px; gap: 10px; padding: 10px; }
.bt-root .menu-group { display: grid; gap: 6px; }
.bt-root .menu-group + .menu-group { border-top: 1px solid var(--bt-line); padding-top: 10px; }
.bt-root .menu-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.bt-root .menu-group .form-grid { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: end; }
@media (max-width: 460px) { .bt-root .save-menu .menu-body { min-width: 0; width: calc(100vw - 32px); right: -8px; } }
.bt-root .results-column > .panel > .tabs { border-radius: var(--bt-radius) var(--bt-radius) 0 0; }
.bt-root .section-title { margin: 0 0 4px; border: 0; background: none; padding: 0 2px; }
.bt-root .section-title h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bt-root .port-card .item-card-header { gap: 4px; }
.bt-root .port-card .item-card-header .tag { min-height: 18px; padding: 0 6px; font-size: 11px; }
.bt-root .port-card .panel-actions { gap: 3px; flex-wrap: nowrap; }
.bt-root .item-card-header .btn.icon { width: 24px; min-height: 24px; font-size: 13px; }
.bt-root .port-name { text-overflow: ellipsis; }

/* summary: the comparison table beside the stacked value / drawdown charts */
.bt-root .summary-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 10px; align-items: start; }
.bt-root .summary-charts { display: grid; gap: 10px; min-width: 0; }
.bt-root .summary-table { position: relative; min-width: 0; }
.bt-root .compare-table { min-width: 0; }
.bt-root .compare-table th:not(:first-child) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.bt-root .compare-table td.best { font-weight: 800; color: var(--text); background: var(--accent-soft); }
@media (max-width: 1100px) { .bt-root .summary-grid { grid-template-columns: minmax(0, 1fr); } }
.bt-root .tabs .fxc-badge { margin-left: auto; }
/* setup bar: dates on the first line; cashflows / glidepath / advanced + add-portfolio on the second */
.bt-root .setup-bar > .essentials { flex-basis: 100%; }
.bt-root .menu-group .inline-row { flex-wrap: nowrap; }

/* allocation: chart/table switch, SVG donuts, sortable table */
.bt-root .view-toggle { display: inline-flex; justify-self: start; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); overflow: hidden; }
.bt-root .view-toggle .btn { border: 0; border-radius: 0; background: var(--bt-surface); }
.bt-root .view-toggle .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.bt-root .pie-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.bt-root .donut { display: block; width: 210px; height: 210px; overflow: visible; }
.bt-root .donut text { text-anchor: middle; pointer-events: none; }
.bt-root .donut-a { fill: var(--text); font-size: 15px; font-weight: 800; }
.bt-root .donut-b { fill: var(--text2); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bt-root .donut-c { fill: var(--muted); font-size: 9.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bt-root table.sortable th { padding: 0; }
.bt-root table.sortable th button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 5px 8px; cursor: pointer; text-align: inherit; }
.bt-root table.sortable th[aria-sort="ascending"], .bt-root table.sortable th[aria-sort="descending"] { color: var(--accent); }
/* long lists fold away until asked for */
.bt-root details.fold { border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); }
.bt-root details.fold > summary { padding: 7px 10px; cursor: pointer; color: var(--text); font-size: 12px; font-weight: 800; }
.bt-root details.fold[open] > summary { border-bottom: 1px solid var(--bt-line); }
.bt-root details.fold > .table-wrap, .bt-root details.fold > table { border: 0; border-radius: 0; }
/* interactive SVG chart cards (vizCard) */
.bt-root .viz { min-width: 0; }
.bt-root .viz .card { margin: 0; }
.bt-root .viz-tip i { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.bt-root .viz-plot { position: relative; }
.bt-root .viz-plot svg { display: block; }
.bt-root .viz-plot text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.bt-root .viz-plot .viz-xtitle { fill: var(--text2); font-weight: 700; }
.bt-root .viz-grid line { stroke: var(--grid); stroke-width: 1; }
.bt-root .viz-grid line.zero { stroke: var(--axis); }
.bt-root .viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.bt-root .viz-fit { stroke-width: 2.5; }
.bt-root .viz-dots circle { opacity: .45; }
.bt-root .viz-ring { fill: none; stroke: var(--text); stroke-width: 1.5; }
.bt-root .viz-tip {
  position: absolute; z-index: 5; min-width: 150px; padding: 7px 9px; pointer-events: none; border: 1px solid var(--bt-line);
  border-radius: 8px; background: var(--bt-surface); box-shadow: var(--shadow); color: var(--text2); font-size: 12px;
}
.bt-root .viz-tip > div { display: flex; align-items: center; gap: 6px; }
.bt-root .viz-tip b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.bt-root .viz-tip .viz-tip-head { display: block; margin-bottom: 3px; color: var(--text); font-weight: 800; }
.bt-root .viz-table { max-height: 420px; }
.bt-root .viz-empty { padding: 30px; text-align: center; color: var(--muted); }

/* allocation donuts: 1.5x, centred */
.bt-root .pie-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.bt-root .pie-grid .pie-box { width: 345px; }
.bt-root .donut { width: 315px; height: 315px; }

/* ---- heatmap cards: bevelled squares with the value on them; hover pops, click squishes + bursts ---- */
.bt-root .heat-card { margin: 0; }
.bt-root .heat-wrap { position: relative; padding: 4px 2px 2px; }
.bt-root .heat-grid { display: grid; gap: 4px; align-items: center; }
.bt-root .heat-col, .bt-root .heat-row { color: var(--muted); font-size: 11px; font-weight: 700; }
.bt-root .heat-col { text-align: center; }
.bt-root .heat-row { padding-right: 6px; text-align: right; white-space: nowrap; }
.bt-root .heat-sq {
  position: relative; height: 30px; border: 0; border-radius: 6px; cursor: pointer; color: var(--text);
  font: 700 12px/1 var(--font); font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .1);
  transition: transform .14s cubic-bezier(.2, .9, .3, 1.4), box-shadow .14s ease, filter .14s ease;
}
.bt-root .heat-sq.up { background: color-mix(in srgb, var(--up) var(--s), var(--bt-surface)); }
.bt-root .heat-sq.down { background: color-mix(in srgb, var(--down) var(--s), var(--bt-surface)); }
.bt-root .heat-sq.deep { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .35); }
.bt-root .heat-sq:hover, .bt-root .heat-sq:focus-visible {
  z-index: 2; transform: scale(1.18); outline: none; filter: brightness(1.08) saturate(1.2);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25), 0 0 0 2px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.bt-root .heat-empty { height: 30px; }
.bt-root [data-heat="heat-correlation"] .heat-sq, .bt-root [data-heat="heat-beta"] .heat-sq { height: 64px; font-size: 16px; }
.bt-root .heat-tip {
  position: absolute; z-index: 6; padding: 5px 9px; pointer-events: none; white-space: nowrap; border: 1px solid var(--bt-line);
  border-radius: 8px; background: var(--bt-surface); box-shadow: var(--shadow); color: var(--text); font-size: 12px; font-weight: 700;
}
html[data-fx="full"] .bt-root .heat-sq { animation: heat-in .45s cubic-bezier(.16, .9, .25, 1) backwards; animation-delay: calc(min(var(--i), 220) * 4ms); }
html[data-fx] .bt-root .heat-sq.pop, .bt-root .heat-sq.pop { animation: heat-pop .34s cubic-bezier(.2, .9, .3, 1.6); }
@keyframes heat-in { from { opacity: 0; transform: scale(.6); } }
@keyframes heat-pop { 0% { transform: scale(1.18); } 40% { transform: scale(.86); } 100% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .bt-root .heat-sq { animation: none !important; transition: none; } }

/* ---- setup: settings tabs, one panel at a time ---- */
.bt-root .setup-tabs { display: inline-flex; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); overflow: hidden; background: var(--bt-surface); }
.bt-root .setup-tab {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 12px; border: 0; border-right: 1px solid var(--bt-line);
  background: none; color: var(--text2); font-size: 12px; font-weight: 800;
}
.bt-root .setup-tab:last-child { border-right: 0; }
.bt-root .setup-tab:hover { background: var(--wash); color: var(--text); }
.bt-root .setup-tab.on { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 -2px 0 var(--bt-brand); }
.bt-root .tab-meta { padding: 0 6px; border-radius: 999px; background: var(--bt-surface2); color: var(--muted); font-size: 11px; font-weight: 700; }
.bt-root .add-portfolio { margin-left: auto; border-color: var(--bt-brand); background: var(--accent-soft); }
.bt-root .setup-panel { display: grid; gap: 10px; padding: 10px 12px 12px; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface2); }
.bt-root .setup-panel-head { display: flex; align-items: center; justify-content: space-between; }
.bt-root .setup-panel-head h3 { margin: 0; color: var(--text); font-size: 13px; font-weight: 800; }
.bt-root .setup-panel-head .btn.icon { width: 26px; min-height: 26px; }
/* advanced: three groups with labels beside short inputs */
.bt-root .adv-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.bt-root .adv-group { display: grid; gap: 7px; align-content: start; padding: 10px; border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface); }
.bt-root .adv-group h4 { margin: 0 0 2px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.bt-root .adv-group > .field { grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 8px; }
.bt-root .adv-group > .field > label { color: var(--text2); font-size: 12px; font-weight: 700; }
.bt-root .adv-group > .btn { justify-self: start; }
/* on/off switches */
.bt-root .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text2); font-size: 12px; font-weight: 700; cursor: pointer; }
.bt-root .switch {
  appearance: none; flex: none; position: relative; width: 34px; height: 20px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--bt-line-strong); transition: background .15s ease;
}
.bt-root .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bt-surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s ease;
}
.bt-root .switch:checked { background: var(--bt-brand); }
.bt-root .switch:checked::after { transform: translateX(14px); }
.bt-root .switch:focus-visible { outline: 2px solid var(--bt-brand); outline-offset: 2px; }
/* cashflows: one compact row per flow */
.bt-root .flow-list { display: grid; gap: 6px; }
.bt-root .flow-row {
  display: flex; flex-wrap: wrap; align-items: end; gap: 6px 10px; padding: 8px 10px;
  border: 1px solid var(--bt-line); border-radius: var(--bt-radius); background: var(--bt-surface);
}
.bt-root .flow-row > .field { width: 130px; }
.bt-root .flow-row > .field:has(input[type="text"]) { width: 200px; }
.bt-root .flow-row .switch-row { min-height: var(--bt-control); }
.bt-root .flow-row > .btn.icon { margin-left: auto; width: 26px; min-height: 26px; }
.bt-root .flow-kind { align-self: center; min-width: 72px; color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.bt-root .setup-panel[data-panel="glide"] .form-grid { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 10px; }
.bt-root .setup-panel[data-panel="glide"] .form-grid > .field { width: 200px; }
/* portfolio cards: tools and rebalancing directly under the name */
.bt-root .card-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.bt-root .card-tools .disc.sub { margin-left: auto; border-top: 0; }
.bt-root .card-tools .disc.sub > .disc-head { padding: 3px 0; gap: 5px; }
.bt-root .card-tools .disc.sub .disc-meta { margin-left: 0; }
.bt-root .card-tools .disc.sub.open { flex-basis: 100%; margin-left: 0; }
@media (max-width: 760px) { .bt-root .add-portfolio { margin-left: 0; } .bt-root .adv-group > .field { grid-template-columns: 1fr; } }
.bt-root .card-tools .disc.sub .disc-body .form-grid { grid-template-columns: 1fr; gap: 5px; }
.bt-root .card-tools .disc.sub .disc-body .field { grid-template-columns: minmax(0, 1fr) 128px; align-items: center; gap: 6px; }
.bt-root .card-tools .disc.sub .disc-body .field > label { color: var(--text2); font-size: 11.5px; font-weight: 700; }

/* ---- juicy allocation donuts: glossy tube slices on a soft shadow; hover pops a slice out and glows it,
   click squishes + bursts; slices sweep in and a glint runs round once ---- */
.bt-root .donut .slice {
  cursor: pointer; outline: none; transform-box: view-box; transform-origin: 50% 50%;
  transition: transform .2s cubic-bezier(.2, .9, .3, 1.5), opacity .15s ease;
}
.bt-root .donut .slice-fill { stroke: var(--bt-surface); stroke-width: 1.5; }
.bt-root .donut .slice.whole .slice-fill { stroke: none; }
.bt-root .donut .slice-gloss, .bt-root .donut .slice-label, .bt-root .donut-glint { pointer-events: none; }
.bt-root .donut .slice-glow { opacity: 0; transition: opacity .18s ease; }
.bt-root .donut.active .slice:not(.hot) { opacity: .42; }
.bt-root .donut .slice.hot { transform: translate(var(--dx), var(--dy)) scale(1.045); }
.bt-root .donut .slice.hot .slice-glow { opacity: .85; }
.bt-root .donut .slice-label {
  fill: #fff; font-size: 10px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: rgba(0, 0, 0, .45); stroke-width: 2.4px; stroke-linejoin: round;
}
.bt-root .donut .slice-label.sub { font-size: 8px; font-weight: 700; }
.bt-root .donut-well { fill: var(--bt-surface); }
.bt-root .donut-glint { fill: none; stroke: #fff; opacity: 0; transform-box: view-box; transform-origin: 50% 50%; transform: rotate(-90deg); }
html[data-fx="full"] .bt-root .donut .slice { animation: slice-in .55s cubic-bezier(.2, .9, .3, 1.35) backwards; animation-delay: calc(min(var(--i), 30) * 28ms); }
html[data-fx="full"] .bt-root .donut .slice-label { animation: label-in .3s ease backwards; animation-delay: calc(min(var(--i), 30) * 28ms + .35s); }
html[data-fx="full"] .bt-root .donut-glint { animation: donut-glint 1.1s ease-in-out backwards; animation-delay: calc(min(var(--n), 30) * 28ms + .45s); }
html[data-fx="full"] .bt-root .donut-a.tick { animation: donut-tick .26s cubic-bezier(.2, .9, .3, 1.6); }
.bt-root .donut .slice.pop { animation: slice-pop .36s cubic-bezier(.2, .9, .3, 1.6); }
@keyframes slice-in { from { opacity: 0; transform: rotate(-35deg) scale(.55); } }
@keyframes label-in { from { opacity: 0; } }
@keyframes donut-glint {
  0% { opacity: 0; stroke-dashoffset: 0; }
  20% { opacity: .38; }
  80% { opacity: .38; }
  100% { opacity: 0; stroke-dashoffset: calc(var(--lap) * -1px); }
}
@keyframes donut-tick { from { opacity: .2; transform: translateY(3px); } }
@keyframes slice-pop {
  0% { transform: translate(var(--dx), var(--dy)) scale(1.045); }
  40% { transform: translate(calc(var(--dx) * .3), calc(var(--dy) * .3)) scale(.93); }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.045); }
}
@media (prefers-reduced-motion: reduce) {
  .bt-root .donut .slice, .bt-root .donut .slice-label, .bt-root .donut-a { animation: none !important; transition: none; }
  .bt-root .donut-glint { display: none; }
}
