:root {
  --red: #ae1f46;
  --red-dark: #861733;
  --text: #20242a;
  --muted: #68717d;
  --line: #d7dce3;
  --page: #f4f5f7;
  --white: #fff;
  --success: #256849;
  --success-bg: #edf8f2;
  --warning: #825307;
  --warning-bg: #fff6de;
  --danger: #9d2932;
  --danger-bg: #fff0f1;
  --info: #155f8d;
  --info-bg: #edf7fc;
}

* { box-sizing: border-box; }
html { background: var(--page); color: var(--text); }
body { margin: 0; font: 14px/1.35 Arial, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #1c6fa8; outline-offset: 1px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: #1c6fa8;
  outline-width: 1px;
  outline-offset: 0;
  box-shadow: 0 0 0 1px rgba(28, 111, 168, .25);
}

.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 10; padding: .65rem .9rem; color: #fff; background: #111; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.app-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 1rem; max-width: 1280px; min-height: 58px; margin: 0 auto; padding: .4rem .75rem; }
.brand-logo { display: block; width: 108px; height: auto; }
.brand-copy { padding-left: .85rem; border-left: 1px solid var(--line); }
.brand-copy h1 { margin: 0; font-size: 1.05rem; }
.brand-copy p { margin: .05rem 0 0; color: var(--muted); font-size: .74rem; }

.page { max-width: 1280px; margin: .55rem auto 2rem; padding: 0 .75rem; }
.stage-indicator { margin-bottom: .5rem; padding: .35rem .6rem; background: var(--white); border: 1px solid var(--line); border-radius: 3px; }
.stage-list { display: flex; align-items: center; margin: 0; padding: 0; list-style: none; }
.stage-step { display: flex; flex: 1; align-items: center; gap: .35rem; min-width: 0; color: var(--muted); font-size: .76rem; }
.stage-step:not(:last-child)::after { content: ""; flex: 1; min-width: 16px; height: 1px; margin: 0 .55rem; background: var(--line); }
.stage-number { display: grid; place-items: center; flex: 0 0 21px; height: 21px; border: 1px solid #adb5c0; border-radius: 50%; font-size: .7rem; font-weight: 700; }
.stage-label { min-width: 0; font-weight: 700; white-space: nowrap; }
.stage-label small { display: block; font-size: .62rem; font-weight: 400; }
.stage-step.current { color: var(--red-dark); }
.stage-step.current .stage-number { color: #fff; background: var(--red); border-color: var(--red); }
.stage-step.complete { color: var(--success); }
.stage-step.complete .stage-number { color: #fff; background: var(--success); border-color: var(--success); }
.stage-step.skipped { color: #8a929d; }
.stage-step.skipped .stage-number { background: #f2f3f5; border-style: dashed; }
.stage-mobile { display: none; }

.panel { margin-bottom: .55rem; background: var(--white); border: 1px solid var(--line); border-radius: 3px; }
.panel-header { padding: .5rem .75rem; background: #f5f6f8; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 1rem; }
.panel-body { padding: .65rem .75rem; }
.section-title { margin: .7rem 0 .4rem; font-size: .92rem; }
.section-title:first-child { margin-top: 0; }
.divider { height: 1px; margin: .7rem 0; background: var(--line); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: .55rem .8rem; }
.grid.customer-grid { grid-template-columns: minmax(300px, 1.25fr) minmax(290px, 1fr) minmax(280px, 1.05fr); }
.grid.identity-derived { grid-template-columns: repeat(4, 165px); margin-top: .55rem; }
.grid.identity-derived .field { width: 165px; max-width: 100%; }
.grid.credit-main { grid-template-columns: 170px minmax(280px, 420px) 110px; }
.grid.credit-secondary { grid-template-columns: 360px 300px minmax(240px, 1fr); margin-top: .55rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: .18rem; min-width: 0; }
.field label, legend { color: #343a43; font-weight: 700; }
.field-short { max-width: 130px; }
.field-date { max-width: 165px; }
.birth-date-control { display: flex; position: relative; min-width: 0; }
.birth-date-control #birthDate { flex: 1; min-width: 0; width: 100%; border-radius: 2px 0 0 2px; }
.birth-date-picker-button { display: grid; place-items: center; position: relative; z-index: 1; flex: 0 0 32px; min-height: 32px; padding: 0; color: var(--text); background: #fff; border: 1px solid #aeb6c1; border-left: 0; border-radius: 0 2px 2px 0; cursor: pointer; }
.birth-date-picker-button:hover { color: var(--red-dark); background: #fff8fa; }
.birth-date-picker-button:focus-visible { outline: 2px solid #1c6fa8; outline-offset: 2px; }
.birth-date-picker-button svg { width: 17px; height: 17px; }
.birth-date-native-picker { position: absolute; top: 0; right: 0; width: 32px; height: 32px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.field-age { max-width: 165px; }
.field-age label { white-space: nowrap; }
.field-age input, .field-age-days input { width: 100%; font-variant-numeric: tabular-nums; }
.field-age-days label { white-space: nowrap; }
.field-insured-amount { max-width: 300px; }
.field-insured-amount .money-output { width: 100%; }
.required { color: var(--red); }
.hint { margin: .3rem 0 0; color: var(--muted); font-size: .74rem; }
.error { min-height: 1em; margin: 0; color: var(--danger); font-size: .74rem; font-weight: 650; }
.field:not(.has-error) .error:empty { display: none; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
input, select, textarea { width: 100%; min-height: 32px; padding: .3rem .45rem; color: var(--text); background: #fff; border: 1px solid #aeb6c1; border-radius: 2px; }
textarea { min-height: 72px; resize: vertical; }
input[readonly] { color: #58616d; background: #f5f6f8; }
.package-control { height: 32px; padding-right: 1.6rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%2323262b' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; }
.package-control::placeholder { color: #757575; opacity: 1; }
select.package-control:has(option[value=""]:checked) { color: #757575; }
select.package-control option:not([value=""]):not(:disabled) { color: var(--text); }
.editable-package-control { position: relative; }
.editable-package-toggle { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 2rem; padding: 0; background: transparent; border: 0; border-radius: 0 2px 2px 0; }
.editable-package-options { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; max-height: 220px; overflow-y: auto; background: #fff; border: 1px solid #767676; border-radius: 0; }
.editable-package-options [role="option"], .editable-package-options .hint { margin: 0; padding: 2px .45rem; line-height: 20px; }
.editable-package-options .hint { color: #757575; font-size: inherit; }
.editable-package-options [role="option"] { cursor: pointer; }
.editable-package-options [role="option"][aria-disabled="false"]:hover, .editable-package-options [aria-selected="true"] { color: HighlightText; background: Highlight; }
.editable-package-options [aria-disabled="true"] { color: GrayText; cursor: not-allowed; }
@supports (appearance: base-select) {
  select.package-control, select.package-control::picker(select) { appearance: base-select; }
  select.package-control::picker-icon, select.package-control option::checkmark { display: none; }
  select.package-control::picker(select) { min-width: anchor-size(width); max-height: 220px; margin: 0; padding: 0; color: var(--text); background: #fff; border: 1px solid #767676; border-radius: 0; box-shadow: none; font: inherit; }
  select.package-control option { min-height: 0; margin: 0; padding: 2px .45rem; border: 0; line-height: 20px; cursor: pointer; }
  select.package-control option:not(:disabled):is(:hover, :focus-visible, :checked) { color: HighlightText; background: Highlight; }
  select.package-control option:disabled { color: GrayText; cursor: not-allowed; }
}
[aria-invalid="true"] { border-color: var(--danger); }
.identity-control { display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: .35rem; min-width: 0; }
.credit-number-control { display: flex; min-width: 0; }
.credit-number-prefix { display: inline-flex; align-items: center; flex: none; padding: .3rem .45rem; border: 1px solid #aeb6c1; border-right: 0; border-radius: 2px 0 0 2px; background: #f5f6f8; font-variant-numeric: tabular-nums; }
.credit-number-control input { min-width: 0; flex: 1; border-radius: 0 2px 2px 0; font-variant-numeric: tabular-nums; }
.credit-number-control:focus-within .credit-number-prefix { border-color: #1c6fa8; }
.numeric input { text-align: left; font-variant-numeric: tabular-nums; }
.money-output { display: flex; align-items: center; justify-content: flex-start; min-height: 32px; padding: .3rem .5rem; color: #58616d; background: #f5f6f8; border: 1px solid #aeb6c1; font-variant-numeric: tabular-nums; }
.radio-row { display: flex; flex-wrap: wrap; gap: .8rem; min-height: 30px; align-items: center; }
.radio-row label, .check-row { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.radio-row input, .check-row input { width: 18px; min-height: 18px; margin: 0; }

.process-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.button { max-width: 100%; min-height: 32px; padding: .35rem .65rem; border: 1px solid transparent; border-radius: 3px; font-weight: 700; overflow-wrap: anywhere; }
.button.primary { color: #fff; background: var(--red); }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { color: var(--text); background: #fff; border-color: #bfc6d0; }
.button.secondary:hover { background: #fff8fa; border-color: var(--red); }
.button.link { min-height: auto; padding: .2rem; color: var(--red-dark); background: transparent; border: 0; }
.button.danger { color: var(--danger); background: #fff; border-color: #dfadb2; }
.button.small { min-height: 27px; padding: .2rem .45rem; font-size: .75rem; }
.actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.actions.between { justify-content: space-between; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.case-continuity { margin-bottom: .65rem; padding-bottom: .65rem; border-bottom: 1px solid var(--line); }
.case-continuity .inline-actions { margin-top: 0; }

.credit-editor { margin-top: .75rem; padding: .6rem; background: #fafbfc; border: 1px solid var(--line); }
.credit-editor .section-title { margin-bottom: .6rem; }
.credit-list { display: grid; gap: .35rem; margin-top: .55rem; }
.credit { display: grid; grid-template-columns: minmax(160px, 1fr) 120px 125px minmax(180px, 1.2fr) auto; align-items: center; gap: .45rem; padding: .42rem .55rem; background: #fafbfc; border: 1px solid var(--line); border-radius: 3px; }
.credit span { display: block; color: var(--muted); font-size: .72rem; }
.credit strong { display: block; font-size: .82rem; overflow-wrap: anywhere; }
.credit-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.total { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .55rem; padding: .45rem .6rem; background: #f5f6f8; border-left: 3px solid var(--red); }
.total span { color: var(--muted); }
.total strong { font-size: .95rem; font-variant-numeric: tabular-nums; }

.questions { display: grid; gap: .45rem; }
.question { padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 3px; }
.question legend { margin-bottom: .3rem; }
.question-supplement { display: block; margin-top: .15rem; }
.question-prompt, .subsection-intro { margin: .15rem 0 .35rem; font-weight: 700; }
.conditional-fields { margin-top: .5rem; }
.subsection { margin-top: .5rem; border: 1px solid var(--line); border-radius: 3px; }
.subsection summary { padding: .5rem .65rem; color: #343a43; background: #f7f8f9; font-weight: 700; cursor: pointer; }
.subsection[open] summary { border-bottom: 1px solid var(--line); }
.subsection-body { display: grid; gap: .45rem; padding: .55rem; }
.health-metrics { grid-template-columns: repeat(3, 145px); }
.health-metrics input { text-align: left; font-variant-numeric: tabular-nums; }
.metric-note { margin-top: .4rem; }
.value-with-select { display: grid; grid-template-columns: minmax(80px, .55fr) minmax(130px, 1fr); gap: .35rem; }
.full-row { grid-column: 1 / -1; }
.insurer-contact { margin: .4rem 0 0; color: var(--danger); font-size: .76rem; font-weight: 700; }
.manual-opinion { margin-top: .5rem; padding: .5rem .6rem; color: var(--danger); background: var(--danger-bg); border: 1px solid #e2abb0; font-weight: 700; }
.health-validity { margin: .65rem 0 0; color: #d00000; font-weight: 700; }
.health-legal { margin: .35rem 0 0; color: #343a43; line-height: 1.45; text-align: justify; white-space: pre-line; }
.message { display: grid; grid-template-columns: 18px 1fr; gap: .45rem; margin-top: .45rem; padding: .45rem .55rem; border: 1px solid; border-radius: 3px; }
.message > div { min-width: 0; overflow-wrap: anywhere; }
.message strong { display: block; }
.message p { margin: .12rem 0 0; }
.message.info { color: var(--info); background: var(--info-bg); border-color: #acd3e8; }
.message.warning { color: var(--warning); background: var(--warning-bg); border-color: #e8c87d; }
.message.danger { color: var(--danger); background: var(--danger-bg); border-color: #e2abb0; }
.message.success { color: var(--success); background: var(--success-bg); border-color: #add7c0; }

.case-summary { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem 1rem; margin-bottom: .55rem; padding: .4rem .55rem; color: var(--muted); background: #f7f8f9; border: 1px solid var(--line); }
.case-summary > * { min-width: 0; overflow-wrap: anywhere; }
.case-summary .button { margin-left: auto; }
.review-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.review-table th, .review-table td { padding: .38rem .45rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.review-table th, .review-table td { overflow-wrap: anywhere; }
.review-table th { width: 31%; color: var(--muted); font-weight: 600; }
.review-credits { margin: .6rem 0; }
.review-declaration { margin: .6rem 0; border: 1px solid var(--line); }
.review-declaration summary { padding: .45rem .55rem; background: #f7f8f9; font-weight: 700; cursor: pointer; }
.review-declaration[open] summary { border-bottom: 1px solid var(--line); }
.review-declaration-body { padding: 0 .35rem .35rem; }
.review-declaration .review-table th { width: 55%; }
.review-confirmation { padding: .55rem; background: #f8f8f9; border: 1px solid var(--line); }
.generation-result { margin-top: .6rem; padding: .55rem; border: 1px solid var(--line); }
.generation-action { margin-top: .45rem; }
.generation-actions { margin-top: .45rem; }
.generation-actions .button { text-decoration: none; }

@media (max-width: 960px) {
  .grid, .grid.customer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.identity-derived { grid-template-columns: repeat(2, minmax(0, 165px)); }
  .customer-grid .field:first-child { grid-column: 1 / -1; }
  .grid.credit-main { grid-template-columns: 150px minmax(180px, 420px) 120px; }
  .grid.credit-secondary { grid-template-columns: minmax(220px, 360px) 300px; }
  .health-metrics { grid-template-columns: repeat(3, minmax(115px, 145px)); }
  .credit-secondary .refinancing-field { grid-column: 1 / -1; }
  .credit { grid-template-columns: 1fr 110px 120px auto; }
  .credit-package { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .header-inner { align-items: flex-start; flex-direction: column; gap: .35rem; }
  .brand-copy { padding: .25rem 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .stage-list { display: none; }
  .stage-mobile { display: flex; justify-content: space-between; gap: .75rem; color: var(--muted); font-size: .78rem; }
  .stage-mobile strong { color: var(--red-dark); }
  .grid, .grid.customer-grid, .grid.identity-derived, .grid.credit-main, .grid.credit-secondary, .grid.two, .health-metrics { grid-template-columns: 1fr; }
  .health-metrics .field { max-width: 180px; }
  .grid.identity-derived .field, .field-short, .field-date, .field-age, .field-insured-amount { width: 100%; max-width: none; }
  .credit { grid-template-columns: 1fr 1fr; }
  .credit-package, .credit-actions { grid-column: 1 / -1; }
  .total { align-items: flex-start; flex-direction: column; }
  .actions .button { flex: 1; }
  .case-summary .button { flex-basis: 100%; margin-left: 0; text-align: left; }
  .review-table th, .review-table td { display: block; width: 100%; }
  .review-table th { padding-bottom: 0; border-bottom: 0; }
  .review-declaration .review-table th { width: 100%; }
}

@media (max-width: 480px) {
  .page { padding: 0 .45rem; }
  .panel-body, .panel-header { padding-right: .55rem; padding-left: .55rem; }
  .process-actions .button, .case-continuity .button { flex: 1 1 100%; }
  .credit-actions .button { flex: 1 1 auto; }
  .message { grid-template-columns: 16px minmax(0, 1fr); }
}
