:root {
  color-scheme: light;
  --ink: #172f29;
  --muted: #53685f;
  --line: #d5ddd3;
  --paper: #fffefa;
  --wash: #f6f5ef;
  --forest: #173f35;
  --accent: #236650;
  --expenses: #8ec8ae;
  --savings: #f1c77b;
  --loan_repayments: #edaa8d;
  --investment: #8cc5db;
  --other: #c5addb;
  --unused: #39594f;
  --serif: 'Baskervville', Georgia, serif;
  --sans: 'DM Sans', 'Segoe UI', Arial, sans-serif;
  font: 400 16px/1.5 var(--sans);
  color: var(--ink);
  background: var(--wash);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
:focus-visible { outline: 3px solid #327e64; outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 66px; padding: 10px max(calc((100% - 1184px) / 2), 5vw);
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-size: 23px; font-weight: 640; letter-spacing: -1.3px; }
.brand strong { color: var(--accent); }
.brand-mark { width: 33px; height: 33px; border-radius: 9px; background: var(--forest); display: flex; align-items: end; justify-content: center; gap: 2px; padding: 8px; }
.brand-mark i { background: var(--expenses); width: 4px; height: 8px; border-radius: 2px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:last-child { height: 18px; background: var(--savings); }
.completion { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.completion span { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); }
progress { appearance: none; width: 74px; height: 5px; border: 0; border-radius: 8px; overflow: hidden; color: var(--accent); background: #e0e5da; }
progress::-webkit-progress-bar { background: #e0e5da; } progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
main { width: min(90%, 1184px); margin: auto; padding-bottom: 64px; }
.intro { padding: clamp(25px,4vw,52px) 0 27px; }
.intro h1 { font: 400 clamp(46px,5.5vw,76px)/1.06 var(--serif); letter-spacing: -.06em; }
.intro em { color: #316b56; font-weight: 400; }
.workspace { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(0,1fr); gap: clamp(16px,2vw,28px); align-items: start; }
.panel, .budget-card { border-radius: 20px; }
.panel { border: 1px solid var(--line); background: var(--paper); box-shadow: 0 4px 18px #233c2b06; }
.form-panel, .result-card { padding: clamp(20px,2.4vw,33px); }
.panel-heading, .allocation-heading, .budget-foot, .compare-values, .compare-label, .allocation-summary-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h2 { font: 400 29px/1.15 var(--serif); letter-spacing: -.045em; }
.text-button { border: 1px solid #c8d7c9; border-radius: 99px; background: #f3f6ef; color: #255b44; padding: 7px 13px; font-size: 13px; font-weight: 650; }
.text-button span { margin-left: 4px; }
.text-button:hover { background: #e7efe3; }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.text-button-secondary { background: transparent; }
.text-button:disabled { opacity: .55; cursor: default; background: transparent; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 23px 0 0; padding: 16px 0 0; min-width: 0; }
legend { color: var(--accent); font-weight: 700; padding: 0 12px 0 0; font-size: 15px; }
.field-grid, .allocation-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px 18px; }
.allocation-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
form label { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; position: relative; gap: 5px; color: #344a40; font-size: 13px; font-weight: 600; }
form label small { font-weight: 400; color: var(--muted); line-height: 1.15; }
input, select { color: var(--ink); min-width: 0; width: 100%; height: 44px; border: 1px solid #c8d2c8; border-radius: 8px; background: #fff; padding: 0 12px; font-size: 15px; }
select:required:invalid { color: var(--muted); }
input:hover, select:hover { border-color: #839c8c; }
.unit { position: absolute; bottom: 11px; left: 12px; color: var(--muted); font-size: 14px; font-weight: 400; pointer-events: none; }
.unit + input { padding-left: 29px; }
label:has([name="Investment_Experience_Years"]) .unit { left: auto; right: 25px; }
input[name="Investment_Experience_Years"] { padding: 0 64px 0 12px; }
.allocation-heading { margin: 24px 0 0; font-size: 15px; font-weight: 650; }
.allocation-status, .profile-tags span, .check-status { background: #eff2eb; color: var(--muted); padding: 4px 9px; font-size: 12px; border-radius: 7px; font-weight: 550; }
.allocation-status.is-invalid, .review .check-status { background: #fff0de; color: #7b4521; }
.allocation-status.is-valid { background: #e2f1e6; color: #22603d; }
.sebi-budget { margin-top: 24px; padding: 19px; border: 1px solid #d7dfce; border-radius: 13px; background: #f2f5ec; }
h3 { font-size: 16px; line-height: 1.4; }
.sebi-budget p, .empty-result p, .match-summary p, .investment-check p, .performance-limits p { font-size: 14px; color: var(--muted); line-height: 1.55; }
.sebi-budget p { margin: 8px 0 14px; }
.sebi-budget p:last-child { margin-bottom: 0; }
#sebi-budget-total { margin: 14px 0 0; color: var(--forest); font-weight: 650; }
#sebi-budget-total.budget-mismatch { color: #784523; }
.budget-breakdown { display: grid; gap: 5px; margin-top: 12px; }
.budget-breakdown div, .preview-legend div { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
dd, td, .compare-values, .segment-count { font-variant-numeric: tabular-nums; }
.budget-breakdown dd { font-weight: 650; }
.primary-button { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; margin: 22px 0 0; padding: 9px 16px; border: 0; border-radius: 10px; background: var(--forest); color: #fff; font-weight: 650; }
.primary-button span + span { font-size: 21px; color: #e7cd9b; }
.primary-button:hover { background: #215643; }
.primary-button:disabled { cursor: wait; opacity: .7; }
.portfolio-option { display: inline-flex; }
form label.portfolio-option { flex-direction: row; justify-content: flex-start; align-items: center; gap: 8px; margin-top: 15px; }
.portfolio-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.field-note, .example-feedback { margin-top: 8px; font-size: 13px; color: var(--muted); }
.example-feedback .text-button { padding: 2px 9px; margin-left: 4px; }
.mobile-budget-status { display: none; }
#allocation-help { margin-bottom: 12px; }
#allocation-error { margin-bottom: 0; }
.privacy-note { margin-top: 10px; text-align: center; color: var(--muted); font-size: 12px; }
.form-error { margin: 14px 0; background: #fff1df; color: #783d21; padding: 10px 12px; border-radius: 7px; font-size: 14px; }
.results-column { display: grid; align-content: start; gap: 16px; min-width: 0; }
.budget-card { overflow: hidden; background: var(--forest); color: #f9fbf3; padding: clamp(19px,2.5vw,34px); }
.form-panel > .budget-card { margin-top: 18px; }
.match-card { scroll-margin-top: 12px; }
.compare-caption { font-size: 12px; color: var(--muted); }
.preview-status { color: #dcebe4; font-size: 13px; margin-top: 8px; }
.preview-status.has-error { color: #ffe5ba; }
form label .budget-field-error { color: #853722; }
input[aria-invalid="true"] { border-color: #ad5b40; }
.budget-card h2 { color: #fcf6e7; }
.budget-visual { display: grid; grid-template-columns: minmax(100px,1fr) minmax(132px,1.15fr); gap: clamp(12px,1.7vw,23px); align-items: center; margin: 27px 0; }
.budget-donut { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--unused); }
.budget-donut > div { display: grid; place-content: center; text-align: center; width: 77%; height: 77%; border-radius: inherit; background: var(--forest); }
.budget-donut strong { font: 400 clamp(20px,2.4vw,32px)/1.05 var(--serif); overflow-wrap: anywhere; }
.budget-donut span { color: #c3d5c8; font-size: 12px; }
.preview-legend { display: grid; gap: 8px; }
.preview-legend div { gap: 5px; }
.preview-legend dt { display: flex; align-items: center; gap: 7px; color: #e1e9e0; }
.preview-legend i, .allocation-legend i { width: 8px; height: 8px; border-radius: 100%; flex: none; }
.preview-legend dd { font-weight: 650; }
.budget-foot { border-top: 1px solid #466558; padding-top: 15px; font-size: 13px; color: #c9d8cc; }
.budget-foot strong { color: #fff5db; font-size: 21px; font-weight: 550; }
.empty-result { border-style: dashed; background: transparent; box-shadow: none; }
.empty-result h2 { font-size: 24px; }
.empty-result p { margin-top: 7px; }
.model-groups { padding: 15px 20px; }
summary { font-size: 14px; font-weight: 650; }
summary::marker { color: var(--accent); }
.segment-item { display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); padding: 12px 0 3px; margin-top: 10px; }
.segment-swatch { width: 5px; height: 30px; border-radius: 6px; background: var(--expenses); }
.segment-item:nth-child(2) .segment-swatch { background: var(--savings); }
.segment-item:nth-child(3) .segment-swatch { background: var(--other); }
.segment-item:nth-child(4) .segment-swatch { background: var(--investment); }
.segment-info { flex: 1; }
.segment-info strong, .segment-info span { display: block; }
.segment-info strong { font-size: 14px; }
.segment-info span, .segment-count, .loading { font-size: 12px; color: var(--muted); }
.results-column:not(.is-editing) .match-card { order: -1; }
.match-card .text-button { flex: none; }
#profile-title, #report-title, #sebi-budget-total { scroll-margin-top: 16px; }
.report-matches { display: grid; gap: 8px; margin: 18px 0 8px; }
.report-matches div { padding: 12px 15px; border-radius: 10px; background: #e7efe4; border-left: 4px solid #4e8367; }
.report-matches .budget-match { background: #f8efde; border-color: #bd9654; }
.report-matches span, .report-matches small { display: block; font-size: 12px; color: #495c4e; }
.report-matches strong { display: block; font: 400 23px/1.2 var(--serif); margin: 2px 0; }
.match-subtitle, .analysis-intro, .distance-note, .method-details p { font-size: 13px; color: var(--muted); }
.match-summary, .performance-limits { display: flex; gap: 9px; align-items: baseline; margin: 18px 0; }
.summary-icon, .limits-icon { color: var(--accent); font-weight: 700; }
.result-card .sebi-budget { padding: 14px; }
.sebi-budget table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.sebi-budget th, .sebi-budget td { text-align: right; border-bottom: 1px solid var(--line); padding: 6px 3px; }
.sebi-budget th:first-child { text-align: left; }
.sebi-budget th { font-weight: 600; }
.result-card .sebi-budget p { font-size: 12px; }
.analysis-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f1f3ec; margin: 20px 0 16px; }
.analysis-tab { border: 0; border-radius: 6px; padding: 8px 3px; background: transparent; font-size: 13px; color: var(--muted); }
.analysis-tab.is-active { background: var(--forest); color: white; }
.insight-grid, .group-average-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.insight-tile, .investment-metrics article, .group-average-grid p { background: #f3f5ed; padding: 10px; border-radius: 8px; min-width: 0; }
.insight-icon { color: var(--accent); }
.insight-tile span:last-child, .investment-metrics small, .investment-metrics span, .group-average-grid span { display: block; font-size: 12px; color: var(--muted); }
.insight-tile strong, .investment-metrics strong, .group-average-grid strong { font-size: 16px; overflow-wrap: anywhere; }
.narrative-list, .investment-check-grid, .comparison-list, .pattern-list { display: grid; gap: 10px; margin: 14px 0; }
.narrative-list p { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.narrative-list p > span { flex: none; color: var(--accent); font-weight: 700; }
.allocation-summary, .method-details, .investment-check, .compare-row, .pattern-row { border-top: 1px solid var(--line); padding-top: 12px; }
.allocation-summary-head, .compare-label, .pattern-row { font-size: 13px; }
.allocation-legend, .profile-tags { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; }
.allocation-legend span { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.allocation-bar { display: flex; overflow: hidden; height: 9px; border-radius: 8px; margin-top: 8px; }
.alloc-equity { background: #518465; } .alloc-fd { background: #a8bd90; } .alloc-debt { background: #d1ad6d; }
.profile-tags { margin: 14px 0; }
.investment-metrics { display: grid; gap: 6px; }
.investment-check h3, .group-averages h3 { font-size: 14px; margin-bottom: 6px; }
.investment-check p { margin-top: 6px; }
.compare-values, .compare-label > span { font-size: 12px; color: var(--muted); }
.compare-track, .pattern-track { height: 5px; background: #e6eadf; border-radius: 5px; position: relative; margin: 8px 0; }
.compare-bar, .pattern-track span { display: block; height: 100%; border-radius: inherit; background: #9fba9c; }
.compare-marker { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 1px solid white; }
.pattern-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px 6px; }
.pattern-track { grid-column: 1 / -1; }
.method-details { margin-top: 16px; }
.method-details p { margin-top: 8px; }
@media (min-width: 961px) and (min-height: 680px) {
  .results-column:has(.empty-result):not(:has(details[open])) { position: sticky; top: 18px; }
}
@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 16px; }
  .budget-visual { grid-template-columns: 1fr; }
  .budget-donut { width: 120px; justify-self: center; }
}
@media (max-width: 760px) {
  main { width: min(94%,600px); }
  .workspace { grid-template-columns: 1fr; }
  .budget-visual { grid-template-columns: minmax(96px,.85fr) minmax(132px,1.15fr); }
  .budget-donut { width: min(100%,150px); }
  .intro { padding: 24px 0 17px; }
  .results-column { gap: 12px; }
  .mobile-budget-status {
    display: block; position: sticky; top: 0; z-index: 1; margin: 10px 0 0; padding: 8px 10px;
    background: #f8efde; color: #704525; border: 1px solid #e4d3b6; border-radius: 8px; font-size: 13px;
  }
  .mobile-budget-status.is-balanced { background: #e2f1e6; color: #22603d; border-color: #cadfcf; }
  #sebi-budget-total, form input, form select { scroll-margin-top: 60px; }
}
@media (max-width: 480px) {
  .topbar { padding: 9px 4%; min-height: 56px; }
  .brand { font-size: 20px; }
  .completion { gap: 5px; font-size: 12px; }
  progress { width: 37px; }
  .form-panel, .result-card, .budget-card { padding: 18px; }
  .panel, .budget-card { border-radius: 14px; }
  .field-grid { gap: 13px 10px; }
  input, select { font-size: 16px; padding-left: 8px; }
  .allocation-grid { gap: 7px; }
  .allocation-heading { align-items: flex-start; flex-wrap: wrap; }
  .sebi-budget { padding: 13px; }
}
@media (max-width: 359px) {
  .field-grid { grid-template-columns: 1fr; }
  .budget-visual { grid-template-columns: 1fr; }
}
