@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&display=swap');

.bp-scope {
  font-family: var(--bp-font);
  color: var(--bp-text);
  --bp-bg: #0a0b0f;
  --bp-surface: #12141a;
  --bp-surface2: #161922;
  --bp-border: #252833;
  --bp-surface3: #1a1d28;
  --bp-surface4: #1f222e;
  --bp-amber-rgb: 245,158,11;
  --bp-green-rgb: 34,197,94;
  --bp-blue-rgb: 59,130,246;
  --bp-red-rgb: 239,68,68;
  --bp-border-rgb: 37,40,51;
  --bp-teal: var(--forest);
  --bp-amber: #f59e0b;
  --bp-red: #ef4444;
  --bp-green: #22c55e;
  --bp-blue: #3b82f6;
  --bp-amber-bg: rgba(var(--bp-amber-rgb),0.12);
  --bp-green-bg: rgba(var(--bp-green-rgb),0.12);
  --bp-blue-bg: rgba(var(--bp-blue-rgb),0.12);
  --bp-text: var(--text-body);
  --bp-muted: var(--text-muted);
  --bp-heading: var(--ink);
  --bp-font: 'DM Sans', system-ui, sans-serif;
  --bp-mono: 'DM Mono', ui-monospace, monospace;
}

/* Light theme. This page carries its own palette rather than using the shared
   surfaces, so it needs its own override; the category colours are darkened
   because the dark-theme values (amber #f59e0b, green #22c55e, blue #3b82f6)
   all fall below 4.5:1 on a white card. */
:root[data-theme="ivory"] .bp-scope {
  --bp-bg: var(--surface);
  --bp-surface: var(--surface-raised);
  --bp-surface2: var(--cream-dark);
  --bp-border: var(--border);
  --bp-surface3: var(--surface-raised);
  --bp-surface4: var(--cream-dark);
  --bp-amber-rgb: 138,106,28;
  --bp-green-rgb: 26,110,90;
  --bp-blue-rgb: 45,95,147;
  --bp-red-rgb: 168,69,47;
  --bp-border-rgb: 233,227,216;
  --bp-amber: #8a6a1c;
  --bp-red: #a8452f;
  --bp-green: #1a6e5a;
  --bp-blue: #2d5f93;
  --bp-amber-bg: rgba(138, 106, 28, 0.12);
  --bp-green-bg: rgba(26, 110, 90, 0.12);
  --bp-blue-bg: rgba(45, 95, 147, 0.12);
}

.bp-page {
  font-family: var(--bp-font);
  background: var(--bp-bg);
  color: var(--bp-text);
  min-height: calc(100vh - 56px);
  padding: 0 32px 48px;
}

.bp-hero-mini {
  background: linear-gradient(155deg, var(--bp-bg) 0%, var(--bp-surface) 100%);
  border-bottom: 1px solid var(--bp-border);
  padding: 32px 0 28px;
  margin: 0 -32px 24px;
  padding-left: 32px;
  padding-right: 32px;
}

.bp-page-title {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  color: var(--bp-heading);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.bp-page-sub {
  font-size: 14px;
  color: var(--bp-muted);
  max-width: 640px;
  line-height: 1.6;
}

.bp-scope .bp-num {
  font-family: var(--bp-mono);
  font-variant-numeric: tabular-nums;
}

/* Currency toggle — top prominence */
.bp-currency-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.bp-currency-toggle {
  display: inline-flex;
  border-radius: 10px;
  border: 1px solid var(--bp-border);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.bp-currency-toggle button {
  font-family: var(--bp-font);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border: none;
  background: var(--bp-surface2);
  color: var(--bp-muted);
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}
.bp-currency-toggle button:hover:not(.bp-currency-active) {
  color: var(--bp-heading);
  background: var(--bp-surface3);
}
.bp-currency-toggle button.bp-currency-active {
  background: rgba(var(--forest-rgb),0.18);
  color: var(--bp-teal);
  box-shadow: inset 0 0 0 1px rgba(var(--forest-rgb),0.35);
}
.bp-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.bp-btn {
  font-family: var(--bp-font);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--bp-border);
  background: var(--bp-surface2);
  color: var(--bp-heading);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.bp-btn:hover {
  border-color: var(--bp-teal);
  background: var(--bp-surface4);
}
.bp-btn-primary {
  border-color: rgba(var(--forest-rgb),0.45);
  background: rgba(var(--forest-rgb),0.12);
  color: var(--bp-teal);
}
.bp-btn-primary:hover {
  background: rgba(var(--forest-rgb),0.22);
}

/* Tabs */
.bp-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--bp-border);
  padding-bottom: 4px;
}
.bp-tab {
  font-family: var(--bp-font);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--bp-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.bp-tab:hover {
  color: var(--bp-heading);
  background: rgba(var(--wash-rgb),0.04);
}
.bp-tab.bp-tab-active {
  color: var(--bp-teal);
  background: rgba(var(--forest-rgb),0.08);
  box-shadow: inset 0 -2px 0 var(--bp-teal);
}
.bp-panel { display: none; }
.bp-panel.bp-panel-visible { display: block; animation: bpFade 0.2s ease; }
@keyframes bpFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bp-two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: start;
}

@media (max-width: 1100px) {
  .bp-two-col {
    grid-template-columns: 1fr;
  }
}

.bp-sidebar-panel {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
@media (max-width: 1100px) {
  .bp-sidebar-panel {
    position: relative;
    top: auto;
    order: -1;
  }
}

.bp-card {
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: 14px;
  padding: 20px;
}
.bp-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bp-teal);
  margin-bottom: 14px;
}
.bp-block-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--bp-heading);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bp-border);
}

.bp-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bp-field label {
  font-size: 13px;
  color: var(--bp-muted);
  font-weight: 500;
}
.bp-field-helper {
  font-size: 11px;
  color: var(--bp-muted);
  opacity: 0.9;
  line-height: 1.4;
}
.bp-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.bp-prefix {
  position: absolute;
  left: 12px;
  font-family: var(--bp-mono);
  font-size: 13px;
  color: var(--bp-muted);
  pointer-events: none;
}
/* Higher specificity than `.bp-field input[type='number']` (whose `padding:10px 12px` shorthand
   was clobbering the left padding) so the currency prefix never sits on top of the number. */
.bp-field .bp-input-wrap.has-prefix input,
.bp-input-wrap.has-prefix input {
  padding-left: 30px;
}
.bp-field input[type='number'],
.bp-field input[type='text'] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--bp-border);
  background: var(--bp-bg);
  color: var(--bp-heading);
  font-family: var(--bp-mono);
  font-size: 14px;
}
.bp-field input:focus {
  outline: none;
  border-color: rgba(var(--forest-rgb),0.45);
  box-shadow: 0 0 0 2px rgba(var(--forest-rgb),0.12);
}

.bp-banner-income {
  background: linear-gradient(135deg, rgba(var(--forest-rgb),0.1), rgba(var(--bp-blue-rgb),0.08));
  border: 1px solid rgba(var(--forest-rgb),0.25);
  border-radius: 12px;
  padding: 16px;
  margin-top: 8px;
  font-family: var(--bp-mono);
  font-size: 14px;
  line-height: 1.7;
}

.bp-invest-highlight {
  background: rgba(var(--bp-amber-rgb),0.12);
  border: 1px solid rgba(var(--bp-amber-rgb),0.35);
  border-radius: 10px;
  padding: 14px;
  margin: 14px 0;
  font-size: 13px;
  color: var(--bp-heading);
  line-height: 1.5;
}

.mb-y { margin-top: 10px; }
.mb-gap { margin-bottom: 24px; }

/* Ring chart */
.bp-score-card {
  text-align: center;
}
.bp-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 14px;
}
.bp-ring-wrap svg {
  transform: rotate(-90deg);
  width: 160px;
  height: 160px;
}
.bp-ring-bg {
  fill: none;
  stroke: var(--bp-border);
  stroke-width: 10;
}
.bp-ring-fg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s;
}
.bp-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.bp-ring-score {
  font-family: var(--bp-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--bp-heading);
  line-height: 1;
}
.bp-ring-sub {
  font-size: 12px;
  color: var(--bp-muted);
  margin-top: 6px;
  max-width: 140px;
  line-height: 1.35;
}

/* Summary boxes 2x2 */
.bp-qgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bp-qbox {
  background: var(--bp-bg);
  border: 1px solid var(--bp-border);
  border-radius: 10px;
  padding: 12px;
  text-align: left;
}
.bp-qlabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bp-muted);
  margin-bottom: 6px;
  font-weight: 700;
}
.bp-qvalue {
  font-family: var(--bp-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--bp-heading);
}
.bp-qmeta {
  font-size: 11px;
  color: var(--bp-muted);
  margin-top: 4px;
}

/* Allocation bars */
.bp-bar-row {
  margin-bottom: 12px;
}
.bp-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12px;
}
.bp-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--bp-border);
  color: var(--bp-muted);
}
.bp-badge-fine {
  border-color: rgba(var(--forest-rgb),0.4);
  color: var(--bp-teal);
}
.bp-badge-watch {
  border-color: rgba(var(--bp-amber-rgb),0.5);
  color: var(--bp-amber);
}
.bp-badge-high {
  border-color: rgba(var(--bp-red-rgb),0.55);
  color: var(--bp-red);
}
.bp-badge-great {
  border-color: rgba(var(--bp-green-rgb),0.5);
  color: var(--bp-green);
}
.bp-track {
  height: 8px;
  background: var(--bp-bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--bp-border);
}
.bp-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.bp-flags {
  font-size: 12px;
  line-height: 1.65;
}
.bp-flag {
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--bp-border);
  background: rgba(var(--wash-rgb),0.02);
}
.bp-flag-pos {
  border-color: rgba(var(--bp-green-rgb),0.35);
  background: rgba(var(--bp-green-rgb),0.06);
}

/* Dashboard */
.bp-dash-grid6 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .bp-dash-grid6 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 520px) {
  .bp-dash-grid6 {
    grid-template-columns: 1fr;
  }
}

.bp-stat-card {
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: 12px;
  padding: 16px;
}
.bp-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bp-muted);
  font-weight: 700;
  margin-bottom: 8px;
}
.bp-stat-value {
  font-family: var(--bp-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--bp-heading);
}
.bp-stat-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--bp-muted);
}
.bp-stat-inv-good {
  color: var(--bp-green);
}
.bp-stat-inv-warn {
  color: var(--bp-amber);
}

.bp-waterfall {
  border: 1px solid var(--bp-border);
  border-radius: 14px;
  padding: 20px;
  background: var(--bp-surface);
  margin-bottom: 24px;
}
.bp-wf-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(var(--bp-border-rgb),0.7);
}
.bp-wf-row:last-child {
  border-bottom: none;
}
.bp-wf-label {
  color: var(--bp-muted);
  padding-right: 12px;
}
.bp-wf-value {
  font-family: var(--bp-mono);
  color: var(--bp-heading);
  font-weight: 500;
}
.bp-highlight-teal {
  background: rgba(var(--forest-rgb),0.1);
  border: 1px solid rgba(var(--forest-rgb),0.35);
  border-radius: 10px;
  padding: 12px !important;
  margin: 8px 0;
}
.bp-highlight-blue {
  background: rgba(var(--bp-blue-rgb),0.1);
  border: 1px solid rgba(var(--bp-blue-rgb),0.35);
  border-radius: 10px;
  padding: 12px !important;
  margin: 8px 0;
}
.bp-waterfall-note {
  font-size: 12px;
  color: var(--bp-muted);
  margin-top: 6px;
  font-style: italic;
}

.bp-callout-tip {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--bp-border);
  background: rgba(var(--wash-rgb),0.02);
  font-size: 13px;
  color: var(--bp-text);
  line-height: 1.6;
}

.bp-ef-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 800px) {
  .bp-ef-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

.bp-ef-box {
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--bp-border);
  background: var(--bp-bg);
}
.bp-ef-status {
  display: inline-block;
  margin-top: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--bp-border);
}

.bp-ef-explain {
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.65;
}

/* Accordions master categories */
.bp-master {
  border-radius: 12px;
  border: 1px solid var(--bp-border);
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--bp-surface);
}
.bp-master-h {
  width: 100%;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  border: none;
  cursor: pointer;
  font-family: var(--bp-font);
  text-align: left;
  transition: filter 0.2s;
}
.bp-master-h:hover {
  filter: brightness(1.08);
}
.bp-master--fixed .bp-master-h {
  background: var(--bp-amber-bg);
  color: var(--bp-heading);
  border-bottom: 1px solid rgba(var(--bp-amber-rgb),0.3);
}
.bp-master--inv .bp-master-h {
  background: var(--bp-green-bg);
  border-bottom: 1px solid rgba(var(--bp-green-rgb),0.35);
}
.bp-master--life .bp-master-h {
  background: var(--bp-blue-bg);
  border-bottom: 1px solid rgba(var(--bp-blue-rgb),0.35);
}
.bp-master-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bp-master-meta {
  font-size: 12px;
  color: var(--bp-muted);
  font-family: var(--bp-mono);
}
.bp-master-body {
  padding: 0 16px 16px;
  display: none;
}
.bp-master.bp-acc-open .bp-master-body {
  display: block;
}
.bp-subtable {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.bp-subtable th,
.bp-subtable td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--bp-border);
  text-align: left;
}
.bp-subtable td:last-child,
.bp-subtable th:last-child {
  text-align: right;
}
.bp-teal-row td {
  color: var(--bp-teal);
  font-weight: 600;
}
.bp-blue-row td {
  color: var(--bp-blue);
  font-weight: 600;
}

/* Checklist */
.bp-check-grid {
  display: grid;
  gap: 12px;
}
.bp-check {
  border: 1px solid var(--bp-border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bp-surface);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.bp-check-ico {
  font-size: 18px;
  flex-shrink: 0;
}
.bp-check strong {
  color: var(--bp-heading);
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}
.bp-check p {
  font-size: 12px;
  color: var(--bp-muted);
  line-height: 1.55;
}

/* What-if */
.bp-scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 800px) {
  .bp-scenario-grid {
    grid-template-columns: 1fr;
  }
}

.bp-scenario {
  background: var(--bp-surface);
  border: 1px solid var(--bp-border);
  border-radius: 14px;
  padding: 18px;
}
.bp-scenario h3 {
  font-size: 15px;
  color: var(--bp-heading);
  margin-bottom: 14px;
  font-weight: 700;
}
.bp-out {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.65;
}
.bp-out .bp-good {
  color: var(--bp-green);
  font-family: var(--bp-mono);
}
.bp-out .bp-bad {
  color: var(--bp-red);
  font-family: var(--bp-mono);
}

.bp-muted-sm {
  font-size: 11px;
  color: var(--bp-muted);
  margin-top: 8px;
}

body.bp-has-page .main-content {
  background: var(--bp-bg);
}

/* ── Checklist: principle line + current-status line ── */
.bp-check-mean { font-size: 12px; color: var(--bp-muted); line-height: 1.55; margin: 0 0 4px; }
.bp-check-now { font-size: 11.5px; color: var(--bp-muted); opacity: 0.8; line-height: 1.5; margin: 0; }
.bp-check-now strong { color: var(--bp-heading); font-weight: 600; }

/* ── AI spending summary card (Dashboard) ── */
.bp-ai-card {
  background: linear-gradient(135deg, rgba(var(--forest-rgb),0.08), rgba(var(--bp-blue-rgb),0.06));
  border: 1px solid rgba(var(--forest-rgb),0.28);
  border-radius: 14px; padding: 18px 20px; margin: 0 0 22px;
}
.bp-ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bp-ai-icon { font-size: 18px; }
.bp-ai-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--bp-muted); }
.bp-ai-headline { font-size: 16px; font-weight: 700; color: var(--bp-heading); margin: 2px 0 10px; }
.bp-ai-card p { font-size: 13.5px; line-height: 1.65; color: var(--bp-muted); margin: 0 0 10px; }
.bp-ai-card p strong, .bp-ai-card li strong { color: var(--bp-heading); font-weight: 600; }
.bp-ai-recs-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--bp-muted); margin: 6px 0 6px; }
.bp-ai-recs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.bp-ai-recs li { font-size: 13.5px; line-height: 1.6; color: var(--bp-muted); padding-left: 20px; position: relative; }
.bp-ai-recs li::before { content: '→'; position: absolute; left: 0; color: var(--bp-teal, #00d4aa); font-weight: 700; }

/* ── Scenarios panel (Save / Load / PDF, like other tabs) ── */
.bp-scenarios-panel {
  margin: -8px 0 18px; border: 1px solid var(--bp-border); border-radius: 12px;
  background: var(--bp-surface); padding: 14px 16px;
}
.bp-scenarios-panel[hidden] { display: none; }
.bp-scenarios-panel .bp-section-title { margin-bottom: 10px; }
.bp-scn-empty { font-size: 12.5px; color: var(--bp-muted); }
.bp-scn-list { display: flex; flex-direction: column; gap: 8px; }
.bp-scn-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--bp-border); border-radius: 9px; padding: 9px 12px; background: var(--bp-bg);
}
.bp-scn-name { font-weight: 600; color: var(--bp-heading); font-size: 13.5px; }
.bp-scn-meta { font-size: 11.5px; color: var(--bp-muted); }
.bp-scn-spacer { flex: 1 1 auto; }
.bp-scn-item .bp-btn { padding: 5px 12px; font-size: 12px; }
.bp-scenario-name-input {
  flex: 0 1 200px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--bp-border);
  background: var(--bp-bg); color: var(--bp-heading); font-size: 13px; font-family: inherit;
}

/* Mobile: iOS Safari auto-zooms inputs with font-size < 16px on focus. */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}
