:root {
  --invest-canvas: #f4f6f2;
  --invest-surface: #ffffff;
  --invest-surface-muted: #eef2ed;
  --invest-line: #d9e1db;
  --invest-line-strong: #c4d0c7;
  --invest-ink: #13241d;
  --invest-muted: #66736c;
  --invest-accent: #276749;
  --invest-accent-soft: #e4efe8;
  --invest-navy: #1d3540;
  --invest-amber: #a36316;
  --invest-amber-soft: #fbf1de;
  --invest-red: #a63d35;
  --invest-red-soft: #faece9;
}

.investments-page { background: var(--invest-canvas); color: var(--invest-ink); }
.investments-page button,
.investments-page input,
.investments-page select { font: inherit; }
.investments-page button:focus-visible,
.investments-page input:focus-visible,
.investments-page select:focus-visible,
.investments-page a:focus-visible { outline: 3px solid rgba(39, 103, 73, 0.24); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.investments-skip-link { position: fixed; top: 12px; left: 12px; z-index: 600; padding: 9px 12px; border-radius: 8px; background: var(--invest-navy); color: #fff; transform: translateY(-160%); }
.investments-skip-link:focus { transform: translateY(0); }

.investments-workspace { width: min(100%, 1480px); margin-inline: auto; padding: 28px 34px 68px; }
.investments-intro { padding: 0 2px 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.investments-eyebrow,
.investment-section-heading p,
.investment-panel-heading p,
.investment-dialog header p,
.dialog-eyebrow { margin: 0 0 6px; color: var(--invest-accent); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.investments-intro h1 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: clamp(31px, 3.4vw, 42px); line-height: 1.08; text-wrap: balance; }
.investments-intro > div:first-child > p:last-child { max-width: 72ch; margin: 8px 0 0; color: var(--invest-muted); font-size: 13px; line-height: 1.6; text-wrap: pretty; }
.investments-intro-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.investment-button { min-height: 38px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.investment-button.primary { border: 1px solid var(--invest-accent); background: var(--invest-accent); color: #fff; }
.investment-button.secondary { border: 1px solid var(--invest-line); background: var(--invest-surface); color: var(--invest-muted); }
.investment-button.secondary:hover { border-color: var(--invest-line-strong); color: var(--invest-ink); }

.investment-summary { margin-bottom: 14px; display: grid; grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr)); gap: 10px; }
.investment-summary article { min-height: 112px; padding: 18px 20px; display: grid; align-content: center; border: 1px solid var(--invest-line); border-radius: 13px; background: var(--invest-surface); }
.investment-summary .investment-summary-primary { border-color: var(--invest-navy); background: var(--invest-navy); color: #fff; }
.investment-summary span { color: var(--invest-muted); font-size: 10px; font-weight: 650; }
.investment-summary-primary span { color: rgba(255,255,255,.56); }
.investment-summary strong { margin-top: 7px; font-family: 'Montserrat', sans-serif; font-size: clamp(21px, 2vw, 27px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.investment-summary strong.positive { color: var(--invest-accent); }
.investment-summary strong.negative { color: var(--invest-red); }
.investment-summary-primary strong.positive,
.investment-summary-primary strong.negative { color: #fff; }
.investment-summary p { margin: 5px 0 0; color: var(--invest-muted); font-size: 9px; line-height: 1.45; text-wrap: pretty; }
.investment-summary-primary p { color: rgba(255,255,255,.53); }

.investment-account-strip { margin-bottom: 14px; padding: 17px; border: 1px solid var(--invest-line); border-radius: 13px; background: var(--invest-surface); }
.investment-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.investment-section-heading.compact { margin-bottom: 12px; }
.investment-section-heading h2,
.investment-panel-heading h2 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: 17px; line-height: 1.25; text-wrap: balance; }
.investment-section-heading > span,
.investment-section-heading div > span,
.investment-panel-heading div > span { color: var(--invest-muted); font-size: 9px; }
.investment-account-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.investment-account-card { min-width: 0; padding: 13px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; border: 1px solid var(--invest-line); border-radius: 10px; background: var(--invest-surface-muted); }
.investment-account-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: #fff; color: var(--invest-accent); font-size: 16px; }
.investment-account-copy { min-width: 0; }
.investment-account-copy strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.investment-account-copy span { display: block; margin-top: 2px; overflow: hidden; color: var(--invest-muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.investment-account-value { grid-column: 1 / -1; padding-top: 9px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-top: 1px solid var(--invest-line); }
.investment-account-value b { font-size: 13px; font-variant-numeric: tabular-nums; }
.investment-account-value span { color: var(--invest-muted); font-size: 8px; font-variant-numeric: tabular-nums; }

.investment-analysis-grid { margin-bottom: 14px; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .55fr); gap: 14px; align-items: stretch; }
.investment-panel { min-width: 0; border: 1px solid var(--invest-line); border-radius: 13px; background: var(--invest-surface); }
.performance-panel { padding: 19px 20px 15px; }
.risk-panel { padding: 19px; background: #f9faf8; }
.investment-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.investment-range-switch,
.allocation-tabs { display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--invest-line); border-radius: 8px; background: var(--invest-surface-muted); }
.investment-range-switch button,
.allocation-tabs button { min-height: 28px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--invest-muted); font-size: 9px; font-weight: 700; }
.investment-range-switch button[aria-pressed="true"],
.allocation-tabs button[aria-pressed="true"] { background: #fff; color: var(--invest-accent); box-shadow: 0 1px 3px rgba(19,36,29,.08); }
.investment-chart-legend { margin-top: 15px; display: flex; align-items: center; gap: 16px; color: var(--invest-muted); font-size: 9px; }
.investment-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.investment-chart-legend i { width: 18px; height: 2px; display: block; background: var(--invest-accent); }
.investment-chart-legend .basis-line { height: 1px; background: #97a49d; }
.investment-chart-shell { min-height: 262px; margin-top: 6px; overflow: hidden; }
.investment-chart-shell svg { width: 100%; height: 262px; display: block; overflow: visible; }
.investment-grid-line { stroke: #e3e9e5; stroke-width: 1; }
.investment-axis-label { fill: #7a8780; font-size: 9px; }
.investment-value-area { fill: rgba(39,103,73,.08); }
.investment-value-line { fill: none; stroke: var(--invest-accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.investment-basis-line { fill: none; stroke: #97a49d; stroke-width: 1.4; stroke-dasharray: 5 5; stroke-linecap: round; }
.investment-chart-dot { fill: #fff; stroke: var(--invest-accent); stroke-width: 2; }
.investment-chart-note { margin: 6px 0 0; display: flex; gap: 6px; color: var(--invest-muted); font-size: 8px; line-height: 1.5; text-wrap: pretty; }
.investment-chart-note i { flex: 0 0 auto; color: var(--invest-accent); }

.risk-count { min-width: 31px; height: 31px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: var(--invest-amber-soft); color: var(--invest-amber); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.risk-list { margin-top: 15px; display: grid; gap: 7px; }
.risk-item { padding: 11px; display: grid; grid-template-columns: auto 1fr; gap: 9px; border: 1px solid var(--invest-line); border-radius: 9px; background: #fff; }
.risk-item > i { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--invest-amber-soft); color: var(--invest-amber); }
.risk-item.high > i { background: var(--invest-red-soft); color: var(--invest-red); }
.risk-item.good > i { background: var(--invest-accent-soft); color: var(--invest-accent); }
.risk-item strong { display: block; font-size: 10px; line-height: 1.35; }
.risk-item p { margin: 3px 0 0; color: var(--invest-muted); font-size: 8px; line-height: 1.45; text-wrap: pretty; }

.investment-allocation-grid { margin-bottom: 14px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: 14px; align-items: stretch; }
.allocation-panel,
.rebalance-panel { padding: 19px; }
.allocation-heading { align-items: flex-start; }
.allocation-tabs { max-width: 100%; overflow-x: auto; }
.allocation-tabs button { flex: 0 0 auto; }
.allocation-total { margin-top: 17px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.allocation-total span { color: var(--invest-muted); font-size: 9px; }
.allocation-total strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.allocation-stack { height: 10px; margin-top: 9px; display: flex; overflow: hidden; border-radius: 999px; background: var(--invest-surface-muted); }
.allocation-stack i { min-width: 2px; height: 100%; display: block; }
.allocation-breakdown { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.allocation-row { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; }
.allocation-row > i { width: 8px; height: 8px; display: block; border-radius: 2px; }
.allocation-row span { overflow: hidden; color: var(--invest-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.allocation-row strong { font-size: 9px; font-variant-numeric: tabular-nums; }
.investment-icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--invest-line); border-radius: 8px; background: var(--invest-surface-muted); color: var(--invest-muted); }
.investment-icon-button:hover { color: var(--invest-accent); }
.rebalance-list { margin-top: 14px; display: grid; gap: 0; }
.rebalance-row { padding: 9px 0; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; border-top: 1px solid var(--invest-line); }
.rebalance-row:first-child { border-top: 0; }
.rebalance-row strong { font-size: 9px; }
.rebalance-row span { margin-top: 3px; display: block; color: var(--invest-muted); font-size: 8px; }
.rebalance-row b { color: var(--invest-accent); font-size: 9px; font-variant-numeric: tabular-nums; text-align: right; }
.rebalance-row b.sell { color: var(--invest-amber); }
.rebalance-note { margin: 11px 0 0; color: var(--invest-muted); font-size: 8px; line-height: 1.45; }

.holdings-panel { overflow: hidden; }
.holdings-heading { padding: 18px 20px 14px; align-items: center; }
.holdings-search { width: min(310px, 100%); min-height: 36px; padding: 0 10px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--invest-line); border-radius: 8px; background: var(--invest-surface-muted); color: var(--invest-muted); }
.holdings-search:focus-within { border-color: var(--invest-accent); background: #fff; }
.holdings-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--invest-ink); font-size: 10px; }
.holdings-table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; border-top: 1px solid var(--invest-line); }
.holdings-table-wrap table { width: 100%; min-width: 720px; border-collapse: collapse; }
.holdings-table-wrap th { padding: 10px 12px; background: #f8faf8; color: var(--invest-muted); font-size: 8px; font-weight: 700; text-align: left; white-space: nowrap; }
.holdings-table-wrap td { padding: 12px; border-top: 1px solid var(--invest-line); font-size: 9px; vertical-align: middle; }
.holdings-table-wrap tbody tr:first-child td { border-top: 0; }
.holding-name { min-width: 155px; }
.holding-name strong { display: block; font-size: 10px; }
.holding-name span,
.holding-account span,
.holding-allocation span { margin-top: 2px; display: block; color: var(--invest-muted); font-size: 8px; }
.holding-account { min-width: 125px; }
.holding-value,
.holding-return,
.holding-weight { font-variant-numeric: tabular-nums; white-space: nowrap; }
.holding-return.positive { color: var(--invest-accent); }
.holding-return.negative { color: var(--invest-red); }
.holding-actions { display: flex; justify-content: flex-end; gap: 4px; }
.holding-actions button { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--invest-line); border-radius: 7px; background: #fff; color: var(--invest-muted); }
.holding-actions button:hover { color: var(--invest-accent); }
.holding-actions button.danger:hover { border-color: #edc9c5; background: var(--invest-red-soft); color: var(--invest-red); }
.holdings-empty { min-height: 190px; padding: 28px; place-items: center; align-content: center; text-align: center; }
.holdings-empty:not([hidden]) { display: grid; }
.holdings-empty i { color: var(--invest-accent); font-size: 26px; }
.holdings-empty h3 { margin: 7px 0 0; font-family: 'Montserrat', sans-serif; font-size: 16px; }
.holdings-empty p { margin: 4px 0 12px; color: var(--invest-muted); font-size: 9px; }
.holdings-empty button { min-height: 35px; padding: 0 11px; border: 0; border-radius: 8px; background: var(--invest-accent); color: #fff; font-size: 10px; font-weight: 700; }
.holdings-status { min-height: 28px; margin: 0; padding: 8px 20px; border-top: 1px solid var(--invest-line); color: var(--invest-muted); font-size: 8px; }

.investment-privacy-note { margin-top: 14px; padding: 13px 15px; display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--invest-line); border-radius: 11px; background: #fff; color: var(--invest-muted); }
.investment-privacy-note i { color: var(--invest-accent); }
.investment-privacy-note p { margin: 0; font-size: 8px; line-height: 1.55; text-wrap: pretty; }
.investment-privacy-note strong { color: var(--invest-ink); }

.investment-dialog { width: min(720px, calc(100vw - 30px)); max-height: min(720px, calc(100dvh - 30px)); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--invest-line-strong); border-radius: 16px; background: #fff; color: var(--invest-ink); box-shadow: 0 22px 52px rgba(19,36,29,.22); }
.investment-dialog::backdrop { background: rgba(17,35,27,.3); }
.investment-dialog > form { max-height: min(720px, calc(100dvh - 30px)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.investment-dialog header { padding: 17px 19px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--invest-line); }
.investment-dialog header h2,
.danger-dialog h2 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: 19px; text-wrap: balance; }
.investment-dialog header button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--invest-line); border-radius: 50%; background: var(--invest-surface-muted); color: var(--invest-muted); }
.investment-dialog-body { padding: 19px; overflow-y: auto; }
.holding-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.holding-form-grid label,
.targets-form label { min-width: 0; display: grid; gap: 6px; }
.holding-form-grid label > span,
.targets-form label > span { color: var(--invest-ink); font-size: 9px; font-weight: 650; }
.holding-form-grid input,
.holding-form-grid select,
.targets-form input { width: 100%; min-width: 0; min-height: 39px; padding: 0 10px; border: 1px solid var(--invest-line); border-radius: 8px; background: #fff; color: var(--invest-ink); font-size: 10px; }
.holding-form-grid .span-2 { grid-column: 1 / -1; }
.investment-form-help { margin: 13px 0 0; color: var(--invest-muted); font-size: 8px; line-height: 1.5; text-wrap: pretty; }
.investment-form-error { min-height: 16px; margin: 7px 0 0; color: var(--invest-red); font-size: 9px; }
.investment-dialog footer { padding: 12px 19px max(12px, env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--invest-line); }
.investment-dialog footer button { min-height: 37px; padding: 0 12px; border-radius: 8px; font-size: 10px; font-weight: 700; }
.dialog-secondary { border: 1px solid var(--invest-line); background: #fff; color: var(--invest-muted); }
.dialog-primary { border: 0; background: var(--invest-accent); color: #fff; }
.dialog-danger { border: 0; background: var(--invest-red); color: #fff; }
.compact-dialog { width: min(520px, calc(100vw - 30px)); }
.targets-form { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.target-input-shell { display: flex; align-items: center; border: 1px solid var(--invest-line); border-radius: 8px; overflow: hidden; }
.target-input-shell input { border: 0; border-radius: 0; }
.target-input-shell span { padding-right: 10px; color: var(--invest-muted); font-size: 10px; }
.connection-copy,
.danger-dialog .investment-dialog-body > p:last-child { margin: 0; color: var(--invest-muted); font-size: 10px; line-height: 1.6; text-wrap: pretty; }
.connection-options { margin-top: 15px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.connection-options span { min-height: 80px; padding: 12px; display: grid; place-items: center; align-content: center; gap: 6px; border: 1px solid var(--invest-line); border-radius: 9px; background: var(--invest-surface-muted); color: var(--invest-muted); font-size: 8px; text-align: center; }
.connection-options i { color: var(--invest-accent); font-size: 19px; }
.danger-dialog > footer { padding: 12px 19px max(12px, env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--invest-line); }

.investment-toast { position: fixed; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 500; max-width: min(360px, calc(100vw - 28px)); padding: 10px 13px; border-radius: 8px; background: var(--invest-ink); color: #fff; font-size: 9px; opacity: 0; pointer-events: none; transform: translateY(7px); transition: opacity 160ms ease-out, transform 160ms ease-out; }
.investment-toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1160px) {
  .investments-workspace { padding-inline: 24px; }
  .investment-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .investment-account-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .investment-analysis-grid,
  .investment-allocation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .investments-intro { align-items: flex-start; flex-direction: column; }
  .investments-intro-actions { justify-content: flex-start; }
  .allocation-heading { flex-direction: column; }
  .allocation-tabs { width: 100%; }
  .holdings-heading { align-items: flex-start; flex-direction: column; }
  .holdings-search { width: 100%; }
}

@media (max-width: 760px) {
  .investments-workspace { padding: 23px 15px 50px; }
  .investment-summary,
  .investment-account-list { grid-template-columns: 1fr; }
  .investment-summary article { min-height: 98px; }
  .investment-range-switch { max-width: 100%; overflow-x: auto; }
  .investment-panel-heading { flex-direction: column; }
  .investment-section-heading.compact { align-items: flex-start; flex-direction: column; }
  .allocation-breakdown { grid-template-columns: 1fr; }
  .holding-form-grid,
  .targets-form { grid-template-columns: 1fr; }
  .holding-form-grid .span-2 { grid-column: auto; }
  .connection-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .investment-toast { transition: none; }
}
