:root {
  --ink: #12211c;
  --muted: #66736d;
  --line: #dfe6e2;
  --canvas: #f4f7f5;
  --white: #ffffff;
  --green: #08734d;
  --green-dark: #045239;
  --green-soft: #e8f5ee;
  --amber: #eaa21a;
  --amber-soft: #fff8e7;
  --navy: #152842;
  --blue: #377cb6;
  --teal: #228f91;
  --danger: #b5473b;
  --shadow: 0 10px 30px rgba(26, 52, 42, .06);
  font-family: "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { color: inherit; }
.topbar { height: 68px; display: grid; grid-template-columns: 300px 1fr auto; align-items: center; padding: 0 28px; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand { font: 800 21px/1 Manrope, sans-serif; text-decoration: none; color: var(--ink); letter-spacing: -.04em; }
.brand span { color: var(--green); }
.topbar-title { font: 700 18px/1 Manrope, sans-serif; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; background: white; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.app-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); max-width: 1600px; margin: 0 auto; min-height: calc(100vh - 68px); }
.input-rail { padding: 28px; border-right: 1px solid var(--line); background: var(--white); }
.rail-heading { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 25px; }
h1, h2, h3, h4, p { margin: 0; }
.rail-heading h1 { font: 700 18px/1.2 Manrope, sans-serif; margin-bottom: 7px; }
.rail-heading p { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 11px; font-weight: 700; white-space: nowrap; }
.live-dot i { width: 7px; height: 7px; background: #1ba66f; border-radius: 50%; box-shadow: 0 0 0 4px #dcf5e9; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 11.5px; font-weight: 700; margin-bottom: 7px; }
.field small { color: var(--muted); font-size: 9px; font-weight: 500; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--ink); background: white; transition: border .2s, box-shadow .2s; }
.field > input, .field > select { height: 43px; padding: 0 12px; font-size: 12.5px; }
.field > select { padding-right: 34px; cursor: pointer; text-overflow: ellipsis; }
.field > select:disabled { cursor: wait; color: var(--muted); background: var(--canvas); }
.inventory-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -9px 0 16px; }
.inventory-meta > span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inventory-meta > span i { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #9aa69f; }
.inventory-meta > span.loading i { background: var(--amber); animation: inventory-pulse 1.1s ease-in-out infinite; }
.inventory-meta > span.ready { color: var(--green); }
.inventory-meta > span.ready i { background: #1ba66f; }
.inventory-meta > span.error { color: var(--danger); }
.inventory-meta > span.error i { background: var(--danger); }
.inventory-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.inventory-actions a, .inventory-meta button { display: inline-flex; align-items: center; gap: 4px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--muted); font-size: 9px; font-weight: 700; text-decoration: none; cursor: pointer; }
.inventory-actions a:hover,
.inventory-meta button:hover { color: var(--green); border-color: #a8c8bb; }
.inventory-meta button svg { width: 11px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.selected-availability { margin: -10px 0 16px; padding: 7px 9px; border-radius: 7px; background: var(--green-soft); color: var(--green-dark); font-size: 9.5px; font-weight: 700; }
.selected-availability.unavailable { background: #fff1ef; color: var(--danger); }
.valuation-status { margin: -10px 0 16px; padding: 7px 9px; border: 1px solid #efd08c; border-radius: 7px; background: var(--amber-soft); color: #966000; font-size: 9.5px; font-weight: 800; }
.inventory-help { margin: -10px 0 16px; color: var(--danger); font-size: 9px; line-height: 1.45; }
@keyframes inventory-pulse { 50% { opacity: .35; transform: scale(.75); } }
.money-input, .suffix-input { height: 43px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: white; transition: border .2s, box-shadow .2s; }
.money-input b, .suffix-input b { color: var(--muted); font-size: 11px; padding-left: 11px; }
.money-input input, .suffix-input input { height: 100%; border: 0; padding: 0 10px 0 7px; font-size: 13px; font-weight: 600; }
.suffix-input input { padding-left: 11px; }
.suffix-input b { padding: 0 10px 0 0; white-space: nowrap; font-weight: 500; }
.editable .money-input, .editable .suffix-input { border-color: #ebc778; background: var(--amber-soft); box-shadow: inset 3px 0 0 var(--amber); }
.editable input { background: transparent; }
.money-input:focus-within, .suffix-input:focus-within, .field > input:focus, .field > select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 115, 77, .12); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.target-field { padding-top: 2px; }
.assumptions { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 6px; }
.assumptions summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 15px 0; font-size: 12px; font-weight: 700; }
.assumptions summary::-webkit-details-marker { display: none; }
.assumptions summary svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .2s; }
.assumptions[open] summary svg { transform: rotate(180deg); }
.assumption-grid { padding-bottom: 13px; }
.assumption-grid label { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; color: var(--muted); font-size: 11px; }
.assumption-grid label span { display: flex; align-items: center; color: var(--ink); }
.assumption-grid input { width: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 5px; text-align: right; font-size: 11px; }
.rail-note { display: flex; gap: 9px; margin-top: 22px; color: var(--muted); }
.rail-note svg { width: 17px; min-width: 17px; fill: none; stroke: var(--green); stroke-width: 1.7; }
.rail-note p { font-size: 10.5px; line-height: 1.5; }
.workspace { padding: 24px; min-width: 0; }
.hero-panel, .scenario-panel, .breakdown, .advisor-panel { background: var(--white); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.hero-panel { padding: 22px 24px 20px; }
.hero-topline { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.section-label { display: block; color: var(--green); font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; margin-bottom: 5px; }
.hero-topline h2 { font: 700 22px/1.1 Manrope, sans-serif; letter-spacing: -.03em; }
.property-name { color: var(--muted); font-size: 11.5px; padding-top: 6px; max-width: 360px; text-align: right; }
.headline-metrics { display: grid; grid-template-columns: 1.3fr 1fr 1fr .8fr; gap: 24px; margin: 22px 0 20px; }
.headline-metrics article { position: relative; }
.headline-metrics article + article::before { content: ""; position: absolute; left: -12px; top: 2px; height: 50px; width: 1px; background: var(--line); }
.headline-metrics span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.headline-metrics strong { display: block; font: 700 clamp(26px, 3vw, 42px)/1 Manrope, sans-serif; letter-spacing: -.05em; color: var(--navy); }
.headline-metrics strong.emerald { color: var(--green); }
.headline-metrics small { display: block; color: var(--muted); margin-top: 8px; font-size: 10.5px; }
.portion-metric { padding-right: 4px; }
.loan-metric strong { font-size: clamp(22px, 2.2vw, 31px); }
.allocation-head { display: flex; gap: 5px; align-items: baseline; font-size: 11px; font-weight: 700; margin-bottom: 9px; }
.allocation-head b { color: var(--muted); font-weight: 500; }
.allocation-bar { height: 23px; display: flex; overflow: hidden; border-radius: 6px; background: var(--canvas); }
.allocation-segment { min-width: 2px; height: 100%; transition: flex-basis .35s ease; position: relative; }
.allocation-segment:not(:last-child) { border-right: 2px solid white; }
.allocation-segment span { position: absolute; inset: 0; display: grid; place-items: center; color: white; font-size: 9px; font-weight: 700; }
.allocation-legend { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 12px; }
.legend-item { min-width: 0; }
.legend-item span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-item i { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.legend-item strong { display: block; font-size: 10px; margin: 4px 0 0 13px; }
.scenario-panel { margin-top: 16px; overflow: hidden; }
.scenario-tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.scenario-tab { appearance: none; border: 0; border-right: 1px solid var(--line); background: #fbfcfb; padding: 14px 15px 12px; cursor: pointer; text-align: left; position: relative; transition: background .2s; }
.scenario-tab:last-child { border-right: 0; }
.scenario-tab:hover { background: #f3f8f5; }
.scenario-tab.active { background: white; box-shadow: inset 0 3px 0 var(--green); }
.scenario-tab strong { display: block; font: 700 20px/1 Manrope, sans-serif; margin-bottom: 10px; }
.scenario-tab dl { margin: 0; }
.scenario-tab dl div { display: flex; justify-content: space-between; gap: 8px; font-size: 9.5px; margin-top: 5px; color: var(--muted); }
.scenario-tab dd { margin: 0; color: var(--ink); font-weight: 600; }
.scenario-tab .cash-value { color: var(--green); }
.scenario-tab .portion-row { margin: 0 0 8px; padding: 7px 8px; border-radius: 6px; background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.scenario-tab .portion-row dd { color: var(--green-dark); }
.trend-area { padding: 18px 20px 12px; }
.trend-heading, .breakdown-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.trend-heading h3, .breakdown-heading h3 { font: 700 16px/1.2 Manrope, sans-serif; }
.trend-key { display: flex; gap: 18px; color: var(--muted); font-size: 9.5px; }
.trend-key span { display: flex; align-items: center; gap: 6px; }
.trend-key i { width: 14px; height: 2px; background: var(--green); }
.trend-key i.profit { background: var(--navy); }
.chart-wrap { width: 100%; height: 205px; margin-top: 4px; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.breakdown { margin-top: 16px; padding: 20px; }
.text-button { border: 0; background: none; color: var(--green); font-size: 10.5px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 5px; }
.text-button svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.flow-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 18px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.flow-step { padding: 16px; position: relative; min-width: 0; }
.flow-step + .flow-step { border-left: 1px solid var(--line); }
.flow-step header { display: flex; align-items: center; gap: 8px; margin-bottom: 15px; }
.flow-step header > span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 8px; font-weight: 800; }
.flow-step h4 { font: 700 12px/1 Manrope, sans-serif; }
.flow-step dl { margin: 0; }
.flow-step dl div { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9.5px; margin: 9px 0; }
.flow-step dd { color: var(--ink); font-weight: 600; margin: 0; text-align: right; }
.flow-step .total { border-top: 1px solid var(--line); padding-top: 10px; color: var(--ink); font-weight: 700; }
.flow-step .total dd { color: var(--green); }
.commission-step header > span { background: #fff3dc; color: #bd7700; }
.commission-step .total dd { color: #c47a00; }
.net-step { background: #fbfdfc; }
.net-step header > span { background: #e9eef4; color: var(--navy); }
.net-step .total { background: var(--green-soft); margin: 12px -6px -4px; padding: 11px 6px; border-radius: 6px; }
.advisor-panel { margin-top: 16px; padding: 16px 20px; display: grid; grid-template-columns: 1.15fr 1.5fr .75fr .75fr; align-items: center; gap: 20px; }
.advisor-copy { display: flex; align-items: center; gap: 10px; }
.advisor-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: var(--canvas); }
.advisor-icon svg { width: 18px; fill: none; stroke: var(--ink); stroke-width: 1.6; }
.advisor-copy span, .advisor-payout span, .advisor-base span { display: block; font-size: 10.5px; font-weight: 700; }
.advisor-copy small { display: block; color: var(--muted); font-size: 9px; margin-top: 3px; }
.advisor-panel label { font-size: 9px; font-weight: 700; }
.advisor-panel select { width: 100%; display: block; margin-top: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 30px 9px 10px; background: white; color: var(--ink); font-size: 10.5px; }
.advisor-payout strong { display: block; color: #bd7700; font: 700 20px/1.2 Manrope, sans-serif; margin-top: 5px; }
.advisor-base { border-left: 1px solid var(--line); padding-left: 20px; }
.advisor-base strong { display: block; font: 700 15px/1.2 Manrope, sans-serif; margin-top: 5px; }
dialog { width: min(660px, calc(100vw - 32px)); border: 0; border-radius: 16px; padding: 24px; box-shadow: 0 24px 80px rgba(8, 31, 23, .25); color: var(--ink); }
dialog::backdrop { background: rgba(10, 25, 20, .48); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { font: 700 22px/1.2 Manrope, sans-serif; }
.dialog-intro { color: var(--muted); font-size: 11px; margin: 12px 0 18px; }
.commission-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.commission-row { display: grid; grid-template-columns: 1fr 80px 120px; gap: 12px; align-items: center; padding: 11px 13px; font-size: 11px; }
.commission-row + .commission-row { border-top: 1px solid var(--line); }
.commission-row.header { background: var(--canvas); color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.commission-row span:nth-child(n+2) { text-align: right; }
.commission-row strong { color: var(--green); text-align: right; }
@media (max-width: 1120px) {
  .topbar { grid-template-columns: 250px 1fr auto; }
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .input-rail { padding: 22px 18px; }
  .workspace { padding: 18px; }
  .allocation-legend { grid-template-columns: repeat(3, 1fr); }
  .flow-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-step:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .flow-step:nth-child(4) { border-top: 1px solid var(--line); }
  .advisor-panel { grid-template-columns: 1fr 1.5fr 1fr; }
  .advisor-base { display: none; }
}
@media (max-width: 780px) {
  .topbar { height: 60px; grid-template-columns: 1fr auto; padding: 0 16px; }
  .topbar-title { display: none; }
  .app-shell { display: block; }
  .input-rail { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px 16px; }
  .workspace { padding: 12px; }
  .headline-metrics { grid-template-columns: 1fr 1fr; }
  .headline-metrics article:nth-child(3)::before { display: none; }
  .headline-metrics article:nth-child(n+3) { border-top: 1px solid var(--line); padding-top: 15px; }
  .property-name { display: none; }
  .allocation-legend { grid-template-columns: repeat(2, 1fr); }
  .scenario-tabs { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .scenario-tab { min-width: 155px; scroll-snap-align: start; }
  .trend-heading { align-items: flex-start; flex-direction: column; }
  .chart-wrap { overflow-x: auto; overscroll-behavior-inline: contain; }
  .chart-wrap svg { min-width: 650px; }
  .flow-grid { grid-template-columns: 1fr; }
  .flow-step + .flow-step { border-left: 0; border-top: 1px solid var(--line); }
  .advisor-panel { grid-template-columns: 1fr; }
  .advisor-base { display: block; border-left: 0; padding-left: 0; }
  .breakdown-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
  .hero-panel { padding: 18px 15px; }
  .headline-metrics { gap: 18px; }
  .headline-metrics strong { font-size: 25px; }
  .allocation-legend { grid-template-columns: 1fr 1fr; }
  .trend-area, .breakdown { padding: 16px 14px; }
  .chart-wrap { height: 180px; }
  .commission-row { grid-template-columns: 1fr 55px 90px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
@media print {
  .topbar { position: static; }
  .print-button, .text-button { display: none; }
  .app-shell { display: block; }
  .input-rail { display: none; }
  .workspace { padding: 12px 0; }
  .hero-panel, .scenario-panel, .breakdown, .advisor-panel { box-shadow: none; break-inside: avoid; }
}
