:root {
  --canvas: #f3f7fb;
  --panel: #fff;
  --ink: #0c213b;
  --muted: #586b82;
  --line: #d5e1ec;
  --navy: #123f73;
  --navy-dark: #082f5a;
  --blue: #116dcc;
  --blue-dark: #0752a2;
  --blue-soft: #edf6ff;
  --green: #087c50;
  --green-soft: #e9f8f1;
  --red: #c4332a;
  --red-soft: #fff0ee;
  --amber: #8b6100;
  --amber-soft: #fff8e6;
  --shadow: 0 12px 34px rgba(12, 33, 59, .08);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; min-height: 100%; overflow-x: hidden; }
html { font-size: 16px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus, select:focus { outline: 3px solid rgba(17,109,204,.22); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.step-label { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { width: 1.25em; height: 1.25em; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; padding-left: 260px; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 260px; min-width: 0; display: flex; flex-direction: column; padding: 26px 18px 20px; color: #fff; background: linear-gradient(165deg,#10477f 0%,#082f5a 100%); overflow-y: auto; }
.platform-brand { display: flex; align-items: center; gap: 12px; padding: 8px 3px 22px; color: #fff; text-decoration: none; }
.platform-brand img { width: 48px; height: 48px; flex: 0 0 auto; transform: translateY(3px); }
.platform-brand > span { padding-top: 3px; }
.platform-brand strong { display: block; font-size: 24px; font-weight: 900; line-height: 1.04; letter-spacing: -.025em; }
.platform-brand strong span { color: #b7a7ff; }
.platform-brand small { display: block; margin-top: 5px; color: #c3d9ee; font-size: 11px; line-height: 1.2; }
.brand { display: flex; align-items: center; gap: 13px; padding: 0 3px 24px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand > div { min-width: 0; }
.brand strong { display: block; font-size: 17px; line-height: 1.2; }
.brand small { display: block; margin-top: 4px; color: #c3d9ee; font-size: 12px; }
.side-nav { display: grid; gap: 9px; margin-top: 26px; }
.side-link { min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid transparent; border-radius: 10px; color: #dcebf8; background: transparent; text-align: left; font-size: 14px; font-weight: 700; }
.side-link > span { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.36); border-radius: 7px; font-size: 15px; }
.side-link:hover { background: rgba(255,255,255,.08); }
.side-link.active { color: #fff; border-color: rgba(255,255,255,.1); background: linear-gradient(105deg,#1762ba,#0c79dc); box-shadow: 0 9px 22px rgba(0,25,58,.25); }
.mobile-nav-toggle { display: none; width: 44px; height: 44px; margin-left: auto; place-items: center; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.26); border-radius: 10px; color: #fff; background: rgba(255,255,255,.08); font-size: 20px; }
.side-note { margin-top: auto; padding: 16px; border: 1px solid rgba(255,255,255,.18); border-radius: 12px; background: rgba(255,255,255,.07); }
.side-note strong { font-size: 13px; }
.side-note p { margin: 8px 0 0; color: #d2e3f3; font-size: 12px; line-height: 1.5; }
.tool-suite-label { margin: 22px 4px 0; color: #9fc4e7; font-size: 10px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.tool-suite-nav { display: flex; flex-direction: column; gap: 9px; margin-top: 9px; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,.14); }
.tool-suite-link { position: relative; color: #e5f0fb; text-decoration: none; }
.tool-suite-link .tool-nav-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; border: 0; border-radius: 0; font-size: inherit; }
.tool-suite-link .tool-nav-icon .ui-icon { width: 25px; height: 25px; }
.tool-suite-link .tool-nav-text { width: auto; height: auto; min-width: 0; display: block; overflow-wrap: anywhere; border: 0; border-radius: 0; font-size: inherit; }
.tool-suite-link:not(.active):hover { color: #fff; }
.tool-suite-link .tool-nav-status { margin-left: auto; color: #9fc4e7; font-size: 9px; font-weight: 700; white-space: nowrap; }
.tool-suite-link.active .tool-nav-status { color: #d7efff; }
.calculator-subnav { width: calc(100% - 14px); display: grid; gap: 9px; margin: 5px 0 13px 14px; padding-left: 11px; border-left: 1px solid rgba(255,255,255,.16); }
.calculator-subnav .side-link { min-height: 50px; padding-inline: 11px; }

.workspace { min-width: 0; }
.workspace-header { border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); }
.workspace-header-inner { width: min(1380px,calc(100% - 40px)); min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 22px; margin: 0 auto; }
.title-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.workspace-header h1 { margin: 0; font-size: clamp(26px,2.1vw,34px); line-height: 1.15; letter-spacing: -.025em; }
.workspace-header p { margin: 7px 0 0; color: var(--muted); font-size: 15px; }
.workspace-header p:empty { display: none; }
.workspace-header-actions { display: flex; align-items: center; gap: 10px; }
.header-action { min-height: 46px; padding-inline: 16px; white-space: nowrap; }
.year-badge { min-height: 34px; display: inline-flex; align-items: center; padding: 5px 12px; border: 1px solid #c5dbef; border-radius: 9px; color: var(--blue-dark); background: var(--blue-soft); font-size: 13px; font-weight: 800; white-space: nowrap; }
.outline-button { min-height: 46px; display: inline-flex; align-items: center; gap: 7px; padding: 10px 17px; border: 1px solid #c3d3e2; border-radius: 10px; color: var(--navy); background: #fff; font-size: 14px; font-weight: 800; white-space: nowrap; }
.outline-button:hover { border-color: #99bad8; background: #f8fbfe; }

main { width: min(1380px,calc(100% - 40px)); margin: 16px auto 30px; }
.app-view { display: none; scroll-margin-top: 24px; }
.app-view.active { display: block; animation: viewIn .18s ease; }
.app-view + .app-view { margin-top: 16px; }
.app-view.is-stale .page-card { opacity: .72; }
@keyframes viewIn { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.input-strip { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: stretch; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.step-block { min-width: 0; margin: 0; padding: 18px 22px; border: 0; }
.step-block + .step-block { border-left: 1px solid var(--line); }
.step-block legend, .step-block h2 { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--ink); font-size: 18px; font-weight: 800; }
.step-block > p { margin: 9px 0 13px 31px; color: var(--muted); font-size: 13px; }
.step-number { width: 24px; height: 24px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--blue); font-size: 12px; }
.document-step { display: flex; flex-direction: column; justify-content: flex-start; }
.document-options { flex: 0 0 auto; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: stretch; gap: 12px; margin-top: auto; margin-bottom: auto; }
.document-options label, .segmented label { min-width: 0; }
.document-options input, .segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.document-options label > span { min-height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 9px 6px; border: 1px solid #cfdae6; border-radius: 11px; color: #4d6076; background: #fff; text-align: center; }
.document-options label > span:hover { border-color: #91bae1; background: #fbfdff; }
.document-options input:checked + span { border-color: #55a0e9; color: var(--blue-dark); background: #f1f7ff; box-shadow: inset 0 0 0 1px #d3e8fb; }
.document-options input:focus-visible + span, .segmented input:focus-visible + span { outline: 3px solid rgba(17,109,204,.2); }
.doc-icon { display: block; margin-bottom: 5px; font-size: 24px; font-weight: 400; }
.doc-icon .ui-icon { margin: 0 auto; }
.document-options strong { font-size: 16px; }
.document-options small { margin-top: 2px; font-size: 14px; }
.document-step h2, .value-step h2, .rule-step h2 { margin-bottom: 13px; }
.combined-value-grid { display: grid; grid-template-columns: minmax(240px,.9fr) minmax(360px,1.1fr); gap: 18px; align-items: start; }
.combined-field { min-width: 0; display: flex; flex-direction: column; align-self: start; justify-content: flex-start; }
.combined-options { min-width: 0; display: grid; grid-template-columns: 1fr; gap: 8px; align-items: start; align-content: start; }
.combined-option { min-width: 0; }
.field-caption { display: block; margin: 0 0 7px; color: #52657b; font-size: 13px; font-weight: 800; }
.comparison-link { min-width: 0; grid-column: 1/-1; display: block; padding: 11px 14px; border: 1px solid #d5e3ef; border-radius: 10px; color: var(--muted); background: #f5f9fc; }
.comparison-link strong { display: block; color: var(--ink); font-size: 14px; line-height: 1.35; }
.comparison-link p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.simulation-controls { display: grid; grid-template-columns: 1fr; gap: 8px 10px; margin-top: 0; padding-top: 0; border-top: 0; }
.simulation-controls label { min-width: 0; display: grid; gap: 4px; color: #52657b; font-size: 11px; font-weight: 800; line-height: 1.25; }
.simulation-controls select, .simulation-controls input { min-width: 0; min-height: 36px; padding: 6px 8px; border: 1px solid #c4d3e1; border-radius: 8px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 650; }
.simulation-controls input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; accent-color: var(--blue); }
.simulation-controls small { color: var(--muted); font-size: 10px; font-weight: 600; }
.control-summary { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.money-field { min-height: 56px; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; border: 1px solid #c4d3e1; border-radius: 11px; background: #fff; }
.money-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(17,109,204,.12); }
.money-field > span { padding-left: 15px; color: #52647a; font-size: 17px; font-weight: 800; }
.money-field input { width: 100%; min-width: 0; min-height: 54px; padding: 10px 14px 10px 9px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 25px; font-weight: 850; }
.field-error { min-height: 17px; display: block; color: var(--red); font-size: 12px; }
.segmented-field { min-width: 0; margin: 8px 0 0; padding: 0; border: 0; }
.segmented { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 5px; border-radius: 11px; background: #eaf1f7; }
.segmented label > span { min-width: 0; min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 8px; border: 1px solid transparent; border-radius: 8px; color: #51657a; text-align: center; font-size: 13px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; word-break: normal; }
.segmented input:checked + span { border-color: #91c0ec; color: var(--blue-dark); background: #fff; box-shadow: 0 3px 9px rgba(16,35,61,.08); }
.compact-select { display: grid; gap: 6px; margin-top: 12px; color: #50637a; font-size: 13px; font-weight: 750; }
input, select { min-width: 0; }
select { width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid #c4d3e1; border-radius: 10px; color: var(--ink); background: #fff; font-size: 14px; font-weight: 650; }

.comparison-board { margin-top: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; transition: opacity .15s ease; }
.comparison-board.is-stale { opacity: .66; }
.comparison-heading { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 20px; border-bottom: 1px solid var(--line); background: #fbfdff; }
.comparison-heading h2 { margin: 0; font-size: 27px; }
.decision-text { max-width: 600px; text-align: right; }
.decision-text strong { display: block; font-size: 17px; }
.decision-text span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.impact-badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.impact-badge.favorable { color: var(--green); background: var(--green-soft); }
.impact-badge.adverse { color: var(--red); background: var(--red-soft); }
.impact-badge.neutral { color: var(--blue-dark); background: var(--blue-soft); }
.comparison-grid-header, .comparison-row { display: grid; grid-template-columns: minmax(200px,1.25fr) repeat(4,minmax(120px,1fr)); }
.comparison-grid-header { min-height: 44px; align-items: center; color: #31445b; background: #f0f5fa; font-size: 14px; font-weight: 850; }
.comparison-grid-header span { padding: 10px 18px; text-align: right; }
.comparison-grid-header span:first-child { text-align: left; }
.comparison-grid-header span:nth-child(2) { color: var(--blue-dark); }
.comparison-grid-header span:nth-child(3) { color: var(--green); }
.comparison-grid-header span:nth-child(4), .comparison-grid-header span:nth-child(5) { color: #536981; }
.comparison-row { min-height: 64px; align-items: stretch; border-top: 1px solid #e3eaf1; }
.comparison-row:first-child { border-top: 0; }
.comparison-cell { min-width: 0; display: flex; align-items: center; justify-content: flex-end; padding: 12px 18px; border-left: 1px solid #e3eaf1; text-align: right; font-size: 18px; font-weight: 750; }
.comparison-cell:first-child { justify-content: flex-start; border-left: 0; text-align: left; font-weight: 700; }
.comparison-cell::before { display: none; }
.comparison-row.key-row { position: relative; color: inherit; background: #fff; box-shadow: none; }
.comparison-row.key-row .comparison-cell { font-size: 18px; font-weight: 750; }
.comparison-delta.favorable { color: var(--green); }
.comparison-delta.adverse { color: var(--red); }
.comparison-delta.neutral { color: #43556b; }
.comparison-percent { color: #536981; font-size: 20px !important; font-weight: 900 !important; }
.loading-row { padding: 28px; color: var(--muted); text-align: center; font-size: 14px; }

.management-panel { margin-top: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 5px 0 0; font-size: 23px; }
.section-heading p { max-width: 560px; margin: 0; color: var(--muted); font-size: 14px; text-align: right; }
.management-grid { display: grid; grid-template-columns: 1.3fr 1fr repeat(3,.65fr); gap: 14px; }
.chart-card, .kpi-card { min-width: 0; border: 1px solid #e1eaf3; border-radius: 12px; background: #fbfdff; }
.chart-card { padding: 18px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title h3 { margin: 0; font-size: 17px; }
.card-title > span { color: var(--muted); font-size: 12px; }
.metric-pill { padding: 4px 8px; border-radius: 999px; font-size: 12px !important; font-weight: 850; }
.metric-pill.favorable { color: var(--green); background: var(--green-soft); }
.metric-pill.adverse { color: var(--red); background: var(--red-soft); }
.metric-pill.neutral { color: var(--blue-dark); background: var(--blue-soft); }
.bar-chart { display: grid; gap: 12px; margin-top: 15px; }
.bar-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 9px; align-items: center; }
.bar-year { color: var(--muted); font-size: 12px; font-weight: 750; }
.bar-track { height: 13px; overflow: hidden; border-radius: 999px; background: #e3ebf3; }
.bar-fill { height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg,#1675d2,#49a0ed); transition: width .35s ease; }
.bar-row.target .bar-fill { background: linear-gradient(90deg,#0d8958,#48b989); }
.bar-value { font-size: 13px; font-weight: 800; white-space: nowrap; }
.allocation-content { display: flex; align-items: center; gap: 16px; margin-top: 13px; }
.donut { --share: 0%; width: 96px; height: 96px; display: grid; place-content: center; flex: 0 0 auto; position: relative; border-radius: 50%; text-align: center; background: conic-gradient(var(--green) var(--share),#dce7f0 0); }
.donut::after { position: absolute; inset: 12px; border-radius: 50%; background: #fff; content: ""; }
.donut strong, .donut span { position: relative; z-index: 1; }
.donut strong { font-size: 18px; }
.donut span { color: var(--muted); font-size: 11px; }
.allocation-legend { display: grid; gap: 8px; min-width: 0; }
.legend-item { display: grid; grid-template-columns: 9px 1fr; gap: 7px; align-items: center; color: var(--muted); font-size: 13px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.legend-dot.cost { background: #dce7f0; }
.legend-item strong { display: block; color: var(--ink); font-size: 14px; }
.kpi-card { display: flex; flex-direction: column; justify-content: center; padding: 15px; }
.kpi-card > span { color: var(--muted); font-size: 13px; line-height: 1.3; }
.kpi-card strong { display: block; margin-top: 8px; font-size: 24px; line-height: 1; }
.kpi-card small { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.kpi-card.featured { color: #fff; border-color: var(--blue-dark); background: linear-gradient(145deg,#0d5ead,#0a417b); }
.kpi-card.featured > span, .kpi-card.featured small { color: #d8eaff; }

.essential-taxes-panel { margin-top: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.essential-heading { align-items: flex-end; margin-bottom: 14px; }
.essential-heading h2 { margin: 5px 0 0; font-size: 21px; }
.essential-heading p { margin-top: 5px; text-align: left; }
.essential-note { padding: 7px 10px; border-radius: 999px; color: var(--amber); background: var(--amber-soft); font-size: 12px; font-weight: 700; }
.essential-years { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 16px; }
.essential-year-card { min-width: 0; padding: 17px; border: 1px solid #d8e4ef; border-radius: 13px; background: #fbfdff; }
.essential-year-card.target-year-card { border-color: #bfe3d2; background: #fcfffd; }
.essential-year-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: -17px -17px 13px; padding: 12px 17px; border-bottom: 1px solid #d8e4ef; border-radius: 12px 12px 0 0; background: #edf6ff; }
.essential-year-card.target-year-card > header { border-bottom-color: #bfe3d2; background: #e9f8f1; }
.essential-year-card h3 { margin: 2px 0 0; font-size: 20px; }
.year-kicker { display: flex; align-items: center; gap: 8px; color: var(--blue-dark); font-size: 18px; font-weight: 850; }
.target-year-card .year-kicker { font-size: 20px; }
.stage-number { width: 24px; height: 24px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--blue); font-size: 12px; line-height: 1; }
.target-year-card .stage-number { background: var(--green); }
.year-caption { color: var(--muted); font-size: 13px; }
.regime-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-bottom: 11px; }
.regime-grid label { display: grid; gap: 6px; color: #52657b; font-size: 15px; font-weight: 800; }
.regime-grid select { min-height: 44px; font-size: 15px; }
.invoice-values-help { margin: 0 0 12px; padding: 9px 11px; border: 1px solid #d5e3ef; border-radius: 9px; color: var(--muted); background: #f5f9fc; font-size: 12px; line-height: 1.4; }
.essential-tax-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.source-tax-grid, .target-tax-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.essential-tax-card { min-width: 0; display: flex; flex-direction: column; padding: 14px; border: 1px solid #d5e2ed; border-radius: 11px; background: #fff; }
.service-pis-cofins-group { grid-column: 1/-1; display: grid; gap: 12px; }
.service-pis-cofins-cards { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.service-rate-card .essential-rate-readonly { min-height: 50px; border: 1px solid #c4d3e1; background: #fff; }
.service-credit-row { width: 100%; }
.service-credit-row .essential-check { width: 100%; }
.service-primary-card { grid-column: 1; }
.essential-tax-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.essential-tax-title h4 { margin: 0; font-size: 17px; }
.essential-tax-title span { color: var(--muted); font-size: 11px; text-align: right; }
.essential-tax-fields { display: grid; grid-template-columns: 1fr; gap: 11px; align-items: stretch; margin-top: 13px; }
.essential-rate { display: grid; gap: 5px; color: #52657b; font-size: 13px; font-weight: 750; }
.essential-rate-label { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; line-height: 1.25; }
.essential-rate-label .essential-lock-note { flex: 0 0 100%; }
.essential-rate input { width: 100%; min-height: 50px; padding: 8px 10px; border: 1px solid #c4d3e1; border-radius: 8px; color: var(--ink); background: #fff; font-size: 20px; font-weight: 800; }
.essential-rate input[readonly] { color: #405875; background: #f4f7fa; cursor: not-allowed; }
.essential-rate-readonly { display: grid; gap: 2px; min-height: 40px; align-content: center; padding: 6px 8px; border-radius: 8px; color: var(--muted); background: #f4f7fa; font-size: 10px; }
.essential-rate-readonly strong { color: var(--ink); font-size: 20px; }
.essential-check { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #d4e1ed; border-radius: 8px; color: var(--navy); background: #f8fbfe; font-size: 14px; font-weight: 800; line-height: 1.25; }
.essential-check span { min-width: 0; }
.essential-check input { width: 24px; height: 24px; flex: 0 0 auto; accent-color: var(--blue); }
.essential-check.is-locked { justify-content: flex-start; color: #52657b; background: #f4f7fa; }
.essential-check.is-locked .essential-lock-note { margin-left: auto; }
.essential-lock-note { color: var(--muted); font-size: 10px; font-weight: 750; line-height: 1.25; white-space: normal; }
.essential-no-credit { min-height: 40px; display: flex; align-items: center; color: var(--muted); font-size: 12px; font-weight: 700; }
.combined-tax-card { justify-content: flex-start; }
.combined-tax-card .essential-tax-title { justify-content: center; text-align: center; }
.combined-rates { width: 100%; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 14px; color: var(--muted); font-size: 13px; text-align: left; }
.combined-rates > span { min-width: 0; display: grid; gap: 5px; padding: 9px 10px; border: 1px solid #c4d3e1; border-radius: 8px; background: #fff; }
.combined-rates > span small { color: #52657b; font-size: 12px; font-weight: 750; line-height: 1.25; }
.combined-rates b { display: block; margin-top: 0; color: var(--ink); font-size: 20px; font-weight: 800; }
.invoice-amount-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.invoice-amount-grid .essential-rate { min-width: 0; }
.invoice-amount-field { margin-top: 0; }
.invoice-amount-field input, .credit-amount-field input { min-height: 42px; padding: 7px 9px; font-size: 15px; }
.invoice-amount-field input::placeholder, .credit-amount-field input::placeholder { color: #8293a6; font-size: 12px; font-weight: 600; }
.invoice-amount-field small, .credit-amount-field small { color: var(--muted); font-size: 10px; font-weight: 700; }
.combined-credit { margin-top: 14px; }
.combined-credit .essential-check { width: 100%; justify-content: flex-start; white-space: normal; }
.credit-input-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.credit-input-grid.single-credit { grid-template-columns: 1fr; }
.credit-input-grid .combined-credit { margin-top: 0; }
.retentions-box { grid-column: 1/-1; margin-top: 12px; padding: 12px; border: 1px solid #d5e3ef; border-radius: 10px; background: #f5f9fc; }
.retentions-box > strong, .retentions-box > small { display: block; }
.retentions-box > strong { color: var(--navy); font-size: 13px; }
.retentions-box > small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.retention-grid { margin-top: 9px; }
.credit-amount-field { margin-top: 10px; }
.essential-rate-source { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.target-tax-grid .essential-check { white-space: normal; }
.essential-footnote { margin: 12px 1px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.impact-section { display: block; margin-top: 16px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.impact-title { min-width: 0; display: grid; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); gap: 24px; align-items: end; padding-bottom: 15px; border-bottom: 1px solid #e5edf4; }
.impact-title h2 { margin: 4px 0 0; font-size: 25px; }
.impact-title p { max-width: none; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.impact-breakdown { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) auto minmax(0,1fr); gap: 10px; align-items: center; margin-top: 16px; }
.impact-step { min-width: 0; min-height: 94px; display: grid; grid-template-columns: 1fr auto; gap: 11px; align-items: center; padding: 14px 15px; border: 1px solid var(--line); border-radius: 11px; background: #fbfdff; }
.impact-step > div { min-width: 0; display: grid; gap: 3px; }
.impact-step span { color: var(--navy); font-size: 14px; font-weight: 800; line-height: 1.3; }
.impact-step small { color: #71839a; font-size: 12px; line-height: 1.4; }
.impact-step strong { font-size: 18px; white-space: nowrap; }
.impact-step.favorable { border-color: #b9dfcf; background: var(--green-soft); }
.impact-step.favorable strong { color: var(--green); }
.impact-step.adverse { border-color: #efc3be; background: var(--red-soft); }
.impact-step.adverse strong { color: var(--red); }
.impact-step.neutral strong { color: #586a80; }
.impact-step.final { border-width: 2px; }
.impact-operator { color: var(--blue-dark); font-size: 23px; font-weight: 850; }
.impact-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; margin-top: 14px; }
.impact-detail-card { min-width: 0; padding: 14px 15px; border: 1px solid #dce7f1; border-radius: 11px; background: #f8fbfe; }
.impact-detail-card.result { border-color: #b9dfcf; background: var(--green-soft); }
.impact-detail-kicker { display: block; color: var(--blue-dark); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.impact-detail-card h3 { margin: 5px 0 6px; color: var(--navy); font-size: 15px; }
.impact-detail-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.impact-takeaway { margin: 13px 0 0; padding: 12px 14px; border-left: 4px solid var(--blue); border-radius: 8px; color: var(--navy); background: var(--blue-soft); font-size: 14px; font-weight: 800; line-height: 1.45; }

.action-row { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 11px; margin-top: 15px; }
.primary-action, .secondary-action { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 17px; border-radius: 10px; font-size: 14px; font-weight: 850; }
.primary-action { border: 0; color: #fff; background: linear-gradient(105deg,var(--blue-dark),#087bdc); box-shadow: 0 8px 19px rgba(17,109,204,.22); }
.primary-action:hover { filter: brightness(.97); }
.primary-action:disabled { opacity: .6; cursor: wait; }
.primary-action.compact { width: auto; min-width: 190px; margin: 0; }
.secondary-action { border: 1px solid #c4d3e1; color: var(--navy); background: #fff; }
.secondary-action:hover { border-color: #91b3d2; background: #f8fbfe; }
.status { min-height: 20px; margin: 7px 3px 0; color: var(--muted); font-size: 12px; }
.status.error { color: var(--red); }
.trust-strip { min-height: 45px; display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 5px; padding: 10px 14px; border-radius: 10px; color: #495e76; background: #e9f2fb; font-size: 12px; text-align: center; }
.trust-strip > span:first-child { color: var(--blue); font-size: 18px; }

.page-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow); }
.page-card-header, .page-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 24px; }
.page-card-header { border-bottom: 1px solid var(--line); background: #fbfdff; }
.page-card-header h2 { margin: 5px 0 0; font-size: 27px; }
.page-card-header p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.page-card-body { min-width: 0; padding: 22px 24px 28px; }
.page-card-footer { position: sticky; bottom: 0; z-index: 4; justify-content: flex-end; border-top: 1px solid var(--line); background: rgba(251,252,254,.97); backdrop-filter: blur(8px); }
.compact-page-header { min-height: 82px; padding-block: 15px; }
.compact-page-header p { margin-top: 5px; font-size: 14px; }
.back-action { min-width: 180px; }
.tab-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; padding: 6px; border-radius: 12px; background: #eaf1f7; }
.tab-list button { min-height: 48px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 15px; font-weight: 800; }
.tab-list button.active { color: var(--navy); background: #fff; box-shadow: 0 4px 12px rgba(16,35,61,.09); }
.settings-intro { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 20px; }
.settings-intro h3 { margin: 0; font-size: 22px; }
.settings-intro p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.expert-switch { display: inline-flex; align-items: center; gap: 9px; color: var(--navy); font-size: 13px; font-weight: 750; }
.expert-switch input, .rule-toggle input, .check-line input { width: 20px; height: 20px; min-height: 0; flex: 0 0 auto; accent-color: var(--blue); }
.legal-note { margin: 16px 0 0; padding: 13px 15px; border: 1px solid #ebd895; border-radius: 10px; color: var(--amber); background: var(--amber-soft); font-size: 13px; line-height: 1.5; }
.settings-section { margin-top: 25px; }
.settings-heading { display: flex; align-items: baseline; gap: 10px; margin-bottom: 11px; }
.settings-heading h3 { margin: 0; font-size: 19px; }
.settings-heading span { color: var(--muted); font-size: 13px; }
.rule-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.rule-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.rule-card.disabled { background: #f7f9fb; }
.rule-card.advanced-rule { display: none; }
.expert-enabled .rule-card.advanced-rule { display: block; }
.rule-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rule-toggle { min-width: 0; display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; }
.rule-toggle span { min-width: 0; overflow-wrap: anywhere; }
.rule-badge { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; color: var(--muted); background: #edf2f7; font-size: 11px; font-weight: 800; }
.rule-badge.info { color: #705600; background: #fff3c9; }
.rule-fields { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(190px,1fr); gap: 12px; margin-top: 14px; }
.rule-fields label, .expert-fields label { display: grid; gap: 6px; color: #4e6279; font-size: 13px; font-weight: 750; }
.rule-fields input, .rule-fields select, .expert-fields input, .expert-fields select { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #c4d3e1; border-radius: 9px; background: #fff; font-size: 14px; }
.custom-credit.hidden { display: none; }
.rule-help { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.rule-technical { display: none; margin-top: 13px; border-top: 1px dashed var(--line); }
.expert-enabled .rule-technical { display: block; }
.rule-technical > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 10px 0 0; color: var(--blue-dark); cursor: pointer; list-style: none; font-size: 13px; font-weight: 800; }
.rule-technical > summary::-webkit-details-marker { display: none; }
.rule-technical > summary::before { width: 22px; height: 22px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--blue-dark); background: var(--blue-soft); content: "+"; font-size: 16px; font-weight: 600; }
.rule-technical[open] > summary::before { content: "−"; }
.rule-technical > summary small { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; }
.expert-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 10px; padding: 13px; border: 1px solid #dce7f1; border-radius: 10px; background: #f8fbfe; }
.expert-wide { grid-column: 1/-1; }
.base-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.base-edit-btn { min-width: 94px; min-height: 44px; padding: 8px 11px; border: 1px solid #b8d0e5; border-radius: 9px; color: var(--navy); background: var(--blue-soft); font-size: 12px; font-weight: 800; }
.check-line { min-height: 46px; display: flex !important; justify-content: flex-start; align-items: center; gap: 9px !important; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--navy) !important; background: #fff; }
.expert-fields .check-line input { width: 20px; height: 20px; min-height: 20px; padding: 0; }
.empty-list { padding: 16px; border: 1px dashed #c7d4e0; border-radius: 11px; color: var(--muted); text-align: center; font-size: 13px; }

.report-scenario-title { margin: 20px 0 0; font-size: 22px; }
.report-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 14px; }
.report-summary div { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #f9fbfd; }
.report-summary span { display: block; color: var(--muted); font-size: 12px; }
.report-summary strong { display: block; margin-top: 5px; font-size: 17px; }
.report-section { margin-top: 25px; }
.report-section h3 { margin: 0 0 11px; font-size: 18px; }
.memory-collapsible { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.memory-collapsible > summary { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 17px; color: var(--navy); background: #f9fbfd; cursor: pointer; list-style: none; }
.memory-collapsible > summary::-webkit-details-marker { display: none; }
.memory-collapsible > summary::after { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--blue-dark); background: var(--blue-soft); content: "+"; font-size: 20px; font-weight: 500; }
.memory-collapsible[open] > summary::after { content: "−"; }
.memory-collapsible > summary span { display: block; font-size: 17px; font-weight: 800; }
.memory-collapsible > summary small { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 500; text-align: right; }
.memory-detail-body { margin: 0; padding: 14px; border-top: 1px solid var(--line); }
.memory-collapsible .report-lines { gap: 8px; }
.memory-collapsible .memory-equations { padding: 14px; }
.memory-collapsible .assumption-list, .memory-collapsible .neutral-rule-list { padding: 14px; }
.report-lines { display: grid; gap: 8px; }
.report-line { display: grid; grid-template-columns: minmax(150px,1.4fr) repeat(3,minmax(105px,.7fr)); gap: 11px; align-items: center; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; }
.report-line strong { font-size: 14px; }
.report-line span { color: var(--muted); font-size: 13px; }
.report-line strong small { display: block; margin-top: 4px; color: var(--amber); font-size: 11px; font-weight: 700; }
.report-line span b { color: var(--ink); font-size: 14px; }
.report-line .right { text-align: right; }
.report-line.info { border-color: #ead9a1; background: #fffdf4; }
.memory-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.memory-section-heading h3 { margin-bottom: 0; }
.memory-section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.memory-equations { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.memory-equation { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: #f9fbfd; }
.memory-equation.primary { border-color: #acd0ef; background: var(--blue-soft); }
.memory-equation > span { display: block; font-size: 15px; font-weight: 800; }
.memory-equation > small { display: block; min-height: 36px; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.memory-equation > div { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px 10px; align-items: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.memory-equation code { min-width: 0; color: #435870; font-family: inherit; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.memory-equation > div b { color: var(--blue-dark); font-size: 16px; }
.memory-equation > div strong { grid-column: 1/-1; color: var(--navy); font-size: 20px; }
.assumption-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.assumption-list article { padding: 13px 14px; border-left: 3px solid #9ab8d4; border-radius: 9px; background: #f4f7fa; }
.assumption-list strong { display: block; color: var(--navy); font-size: 13px; }
.assumption-list article.legal-rule { border-left-color: var(--blue); background: var(--blue-soft); }
.assumption-list article.warning-rule { border-left-color: var(--amber); background: var(--amber-soft); }
.assumption-list span { display: block; margin-top: 4px; color: #4e6279; font-size: 12px; line-height: 1.45; }
.neutral-rule-list { display: flex; flex-wrap: wrap; gap: 8px; }
.neutral-rule-list > span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: #50637a; background: #f7f9fb; }
.neutral-rule-list b { font-size: 12px; }
.neutral-rule-list small { color: var(--muted); font-size: 10px; }
.technical-memory { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbfd; }
.technical-heading { align-items: center; margin-bottom: 0; }
.technical-heading .secondary-action { min-width: 190px; }
.raw-memory-panel { margin-top: 14px; }
.memory-list { margin: 0; padding: 17px 18px 17px 39px; border-radius: 11px; color: #445970; background: #f3f7fa; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.memory-list li + li { margin-top: 5px; }
.help-body { display: grid; gap: 24px; }
.help-summary { padding: 18px 20px; border-left: 4px solid var(--blue); border-radius: 11px; background: var(--blue-soft); }
.help-summary strong { font-size: 17px; }
.help-summary p { margin: 6px 0 0; color: #445b73; font-size: 14px; line-height: 1.55; }
.help-disclosure > summary, .help-checklist h3 { margin: 0; font-size: 19px; font-weight: 800; }
.help-disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--ink); cursor: pointer; list-style: none; }
.help-disclosure > summary::-webkit-details-marker { display: none; }
.help-disclosure > summary::after { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--blue-dark); background: var(--blue-soft); content: "+"; font-size: 20px; font-weight: 500; }
.help-disclosure[open] > summary { margin-bottom: 12px; }
.help-disclosure[open] > summary::after { content: "−"; }
.help-checklist h3 { margin-bottom: 12px; }
.help-content { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.help-content article { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbfd; }
.help-content article > span { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--blue); font-size: 14px; font-weight: 850; }
.help-content strong { font-size: 16px; }
.help-content p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.help-content b { color: var(--ink); }
.help-checklist { padding: 18px 20px; border: 1px solid #ebd895; border-radius: 12px; background: var(--amber-soft); }
.help-checklist ul { display: grid; gap: 8px; margin: 0; padding-left: 22px; color: #5e5237; font-size: 14px; line-height: 1.5; }

dialog { width: min(760px,calc(100% - 24px)); max-width: none; max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 28px 90px rgba(7,31,55,.32); overflow: hidden; }
dialog::backdrop { background: rgba(6,24,43,.62); backdrop-filter: blur(3px); }
.dialog-shell { max-height: calc(100vh - 24px); display: grid; grid-template-rows: auto minmax(0,1fr) auto; background: #fff; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 21px; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 5px 0 0; font-size: 23px; }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--line); background: #fbfcfe; }
.dialog-body { min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 20px 21px 24px; }
.icon-button { width: 42px; height: 42px; flex: 0 0 auto; border: 0; border-radius: 10px; color: var(--navy); background: #edf3f7; font-size: 25px; }
.component-rows { display: grid; gap: 9px; margin: 17px 0 12px; }
.component-row { display: grid; grid-template-columns: minmax(0,1fr) 130px auto; gap: 9px; }
.component-row button { min-height: 44px; border: 0; border-radius: 9px; color: var(--red); background: var(--red-soft); font-weight: 750; }

@media (max-width: 1400px) {
  .input-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .target-tax-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .combined-value-grid { grid-template-columns: minmax(0,.84fr) minmax(0,1.16fr); gap: 12px; }
  .segmented label > span { padding: 7px 5px; font-size: 12px; }
}

@media (max-width: 1260px) {
  .app-shell { padding-left: 225px; }
  .sidebar { width: 225px; padding-inline: 14px; }
  .brand strong { font-size: 15px; }
  .management-grid { grid-template-columns: repeat(3,1fr); }
  .chart-card { grid-column: span 1; }
  .allocation-card { grid-column: span 2; }
}

@media (max-width: 1360px) {
  .app-shell { padding-left: 232px; }
  .sidebar { width: 232px; padding: 20px 14px 17px; }
  .brand { gap: 10px; padding-bottom: 19px; }
  .brand strong { font-size: 15px; }
  .brand small { font-size: 11px; }
  .side-nav { gap: 7px; }
  .side-link { min-height: 47px; gap: 9px; padding: 9px 10px; font-size: 13px; }
  .side-link > span { width: 25px; height: 25px; }
  .tool-suite-link .tool-nav-icon { width: 25px; height: 25px; }
  .tool-suite-link .tool-nav-icon .ui-icon { width: 22px; height: 22px; }
  .tool-suite-label { margin-top: 18px; font-size: 9px; }
  .side-note { padding: 13px; }
  .workspace-header-inner { width: min(1380px,calc(100% - 28px)); min-height: 82px; }
  .workspace-header h1 { font-size: clamp(25px,2vw,30px); }
  .header-action, .outline-button { min-height: 42px; padding-inline: 13px; font-size: 13px; }
  main { width: min(1380px,calc(100% - 28px)); margin-top: 12px; }
}

@media (max-width: 1000px) {
  .app-shell { padding-left: 0; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 17px; overflow: visible; }
  .brand { padding-bottom: 12px; }
  .side-nav { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; margin-top: 12px; }
  .tool-suite-nav { display: flex; }
  .calculator-subnav { width: auto; margin: 5px 0 13px; padding-left: 0; border-left: 0; }
  .side-link { min-height: 43px; justify-content: center; padding: 8px; text-align: center; font-size: 12px; }
  .side-link > span { display: none; }
  .side-note { display: none; }
  .workspace-header-inner { width: calc(100% - 40px); min-height: 86px; padding: 16px 0; }
  main { width: min(100% - 24px,1440px); margin-top: 12px; }
  .input-strip { grid-template-columns: 1fr; }
  .step-block + .step-block { border-left: 0; border-top: 1px solid var(--line); }
  .management-grid { grid-template-columns: repeat(2,1fr); }
  .allocation-card { grid-column: span 1; }
  .essential-years { grid-template-columns: 1fr; }
  .target-tax-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .impact-title { grid-template-columns: 1fr; gap: 10px; }
  .impact-details { grid-template-columns: 1fr; }
  .rule-list { grid-template-columns: 1fr; }
  .help-content { grid-template-columns: 1fr; }
  .memory-equations { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  body { font-size: 14px; }
  .sidebar { position: sticky; top: 0; z-index: 20; padding: 12px 16px; box-shadow: 0 8px 24px rgba(7,31,55,.18); }
  .brand { padding: 0; border-bottom: 0; }
  .brand strong { font-size: 16px; }
  .brand small { margin-top: 2px; font-size: 11px; }
  .mobile-nav-toggle { display: grid; }
  .side-nav { display: none; grid-template-columns: 1fr; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.14); }
  .calculator-subnav { width: calc(100% - 10px); margin: 0 0 4px 10px; padding-top: 0; padding-left: 9px; border-top: 0; border-left: 1px solid rgba(255,255,255,.16); }
  .sidebar.nav-open .side-nav { display: grid; }
  .sidebar.nav-open .tool-suite-nav { display: flex; }
  .sidebar.nav-open .tool-suite-label { display: block; }
  .tool-suite-nav { padding-block: 12px; border-top: 1px solid rgba(255,255,255,.14); border-bottom: 1px solid rgba(255,255,255,.14); }
  .side-link { min-height: 46px; justify-content: flex-start; gap: 10px; padding: 9px 12px; text-align: left; font-size: 13px; }
  .side-link > span { width: 24px; height: 24px; display: grid; }
  .workspace-header-inner { width: calc(100% - 32px); min-height: 0; align-items: stretch; flex-direction: column; gap: 13px; padding-block: 14px; }
  .workspace-header-actions { width: 100%; display: grid; grid-template-columns: 1fr; gap: 8px; }
  .header-action, .outline-button { width: 100%; justify-content: center; min-width: 0; white-space: normal; }
  .header-action { min-height: 44px; padding-inline: 11px; font-size: 13px; }
  .workspace-header h1 { font-size: 23px; }
  .workspace-header p, .year-badge { display: none; }
  body[data-current-view="settings"] .workspace-header-inner { min-height: 74px; padding-block: 13px; }
  .title-line { gap: 8px; }
  .outline-button { min-height: 44px; padding: 8px 11px; }
  main { width: calc(100% - 16px); margin-top: 8px; }
  .step-block { padding: 17px 18px; }
  .document-options { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .combined-value-grid { grid-template-columns: 1fr; gap: 12px; }
  .simulation-controls { grid-template-columns: 1fr; }
  .combined-options { grid-template-columns: 1fr; }
  .comparison-link { grid-column: auto; }
  .comparison-heading, .section-heading, .page-card-header, .settings-intro, .settings-heading, .memory-section-heading { align-items: flex-start; flex-direction: column; }
  .decision-text, .section-heading p { text-align: left; }
  .comparison-grid-header { display: none; }
  .comparison-row { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 8px 10px; }
  .comparison-cell { min-height: 50px; display: block; padding: 7px 6px; border: 0; text-align: left; font-size: 13px; }
  .comparison-cell:first-child { grid-column: 1/-1; min-height: 36px; padding-bottom: 3px; border-bottom: 1px solid #e3eaf1; font-size: 14px; }
  .comparison-cell::before { display: block; margin-bottom: 4px; color: var(--muted); content: attr(data-label); font-size: 10px; font-weight: 700; text-transform: uppercase; }
  .comparison-row.key-row .comparison-cell { font-size: 14px; }
  .comparison-percent { font-size: 16px !important; }
  .management-panel { padding: 16px; }
  .management-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .management-grid > .chart-card { grid-column: 1/-1; }
  .management-grid > .kpi-card.featured { grid-column: 1/-1; }
  .essential-taxes-panel { padding: 16px; }
  .essential-year-card { padding: 13px; }
  .essential-tax-grid, .target-tax-grid, .regime-grid { grid-template-columns: 1fr; }
  .service-pis-cofins-cards { grid-template-columns: 1fr; }
  .credit-input-grid { grid-template-columns: 1fr; }
  .essential-year-card > header { flex-direction: column; gap: 4px; margin: -13px -13px 13px; padding: 11px 13px; }
  .impact-breakdown { grid-template-columns: 1fr; }
  .impact-operator { display: none; }
  .impact-section { padding: 17px 16px; }
  .action-row { grid-template-columns: 1fr; }
  .trust-strip { align-items: flex-start; flex-wrap: wrap; }
  .page-card-header, .page-card-footer, .page-card-body { padding: 16px; }
  .compact-page-header { min-height: 72px; padding-block: 12px; }
  .back-action { min-width: 0; width: 100%; }
  .rule-fields, .expert-fields, .help-content { grid-template-columns: 1fr; }
  .rule-technical > summary small { display: none; }
  .report-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .expert-wide { grid-column: auto; }
  .report-line { grid-template-columns: 1fr 1fr; }
  .report-line strong { grid-column: 1/-1; }
  .report-line .right { text-align: left; }
  .assumption-list { grid-template-columns: 1fr; }
  .memory-collapsible > summary { min-height: 62px; align-items: flex-start; padding: 13px 14px; }
  .memory-collapsible > summary span { font-size: 16px; }
  .memory-collapsible > summary small { display: none; }
  .memory-detail-body { padding: 10px; }
  .help-disclosure > summary { min-height: 58px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #f9fbfd; }
  .help-disclosure[open] > summary { margin-bottom: 10px; }
  .technical-heading .secondary-action { width: 100%; }
  dialog { width: calc(100% - 12px); max-height: calc(100vh - 12px); border-radius: 13px; }
  .dialog-shell { max-height: calc(100vh - 12px); }
  .component-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
