:root {
  color-scheme: light;
  --ink: #091b36;
  --muted: #585f6d;
  --paper: #ffffff;
  --surface: #ffffff;
  --soft: #eeeff1;
  --line: #dddde1;
  --coral: #7bc2ff;
  --blue: #2998ff;
  --blue-dark: #0162f7;
  --blue-soft: #f2f7ff;
  --gray-50: #f8f8f8;
  --green: #3dab1e;
  --shadow-1: 0 2px 8px rgba(39, 41, 55, 0.08);
  --shadow-2: 0 6px 24px rgba(39, 41, 55, 0.1);
  --shadow-3: 0 10px 40px rgba(39, 41, 55, 0.12);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: transparent;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: transparent; }
body { margin: 0; min-width: 320px; background: transparent; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button, input, select, summary { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.mortgage-app {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 5%;
  background: var(--paper);
  border: 0;
  border-radius: 0;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 24px;
  padding: 40px;
  border-radius: 32px;
  background: linear-gradient(272.9deg, #e9f1fd, #fef3f0);
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

h1, h2, p { margin-top: 0; }
h1 {
  max-width: 650px;
  margin-bottom: 10px;
  font-size: clamp(36px, 4.3vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 600;
}

.lead {
  max-width: 600px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.mode-switch {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: min(720px, 100%);
  margin-bottom: 24px;
  padding: 0;
}

.mode-caption {
  padding-left: 2px;
  font-size: 14px;
  font-weight: 600;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(105px, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border-radius: 100px;
}

.mode-button, .unit-button {
  border: 0;
  color: var(--muted);
  background: transparent;
}

.mode-button {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
}

.mode-button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 0.78fr);
  gap: 24px;
  align-items: stretch;
}

.controls, .results {
  border-radius: 32px;
  background: var(--surface);
}

.controls {
  padding: 32px;
  background: var(--gray-50);
}
.results {
  position: sticky;
  top: 16px;
  padding: 32px;
  color: #fff;
  background:
    radial-gradient(circle at 96% 3%, rgba(41, 152, 255, 0.34), transparent 31%),
    var(--ink);
  box-shadow: var(--shadow-2);
}

.control-section { margin-bottom: 22px; }
.control-section > label,
.field-head > label {
  display: block;
  margin-bottom: 9px;
  font-size: 12px;
  font-weight: 700;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-hint { color: var(--muted); font-size: 10px; }
.rate-hint {
  display: block;
  margin: 6px 2px 0;
}
.unit-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--soft);
  border-radius: 100px;
}
.unit-button {
  min-width: 34px;
  min-height: 28px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
}
.unit-button.active { color: var(--surface); background: var(--blue-dark); }

.money-input, .select-input {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.money-input:focus-within, .select-input:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(41, 152, 255, 0.14);
}

.money-input input, .select-input select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
  font-weight: 600;
}

.money-input input { padding: 13px 43px 13px 15px; }
.money-input > span {
  position: absolute;
  right: 15px;
  color: var(--muted);
  font-size: 14px;
}

.select-input select {
  min-height: 50px;
  padding: 0 36px 0 14px;
  appearance: none;
  font-size: 14px;
}
.select-input::after {
  content: "⌄";
  position: absolute;
  right: 14px;
  color: var(--muted);
  pointer-events: none;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.payment-type-section {
  margin-right: 0;
  margin-left: 0;
  padding: 0;
  border: 0;
}
.payment-type-section legend {
  margin-bottom: 9px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
}
.payment-type-legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.payment-type-info-wrap {
  position: relative;
  display: inline-flex;
}
.payment-type-info {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--blue-dark);
  border-radius: 50%;
  color: var(--blue-dark);
  background: transparent;
  font-family: Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.payment-type-info:hover,
.payment-type-info[aria-expanded="true"] {
  color: #fff;
  background: var(--blue-dark);
}
.payment-type-info:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.payment-type-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.payment-type-option {
  position: relative;
  cursor: pointer;
}
.payment-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.payment-type-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.payment-type-option input:checked + span {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px rgba(41, 152, 255, 0.12);
}
.payment-type-option input:focus-visible + span {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.payment-type-help-body {
  position: absolute;
  z-index: 30;
  top: calc(100% + 10px);
  left: 50%;
  display: block;
  width: min(430px, calc(100vw - 48px));
  padding: 13px 14px;
  border: 1px solid rgba(41, 152, 255, 0.24);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  box-shadow: var(--shadow-3);
  font-size: 10px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -4px);
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease, transform 0.16s ease;
}
.payment-type-help-body::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-top: 1px solid rgba(41, 152, 255, 0.24);
  border-left: 1px solid rgba(41, 152, 255, 0.24);
  background: #fff;
  transform: translate(-50%, 6px) rotate(45deg);
}
.payment-type-help-body span { display: block; }
.payment-type-help-body span + span { margin-top: 9px; }
.payment-type-help-body strong { color: var(--ink); }
.payment-type-info-wrap:hover .payment-type-help-body,
.payment-type-info-wrap:focus-within .payment-type-help-body,
.payment-type-info-wrap.is-open .payment-type-help-body {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.range-line { margin-top: 13px; }
.article-field-range { display: none; }
input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}
.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}
.range-labels strong { color: var(--ink); }
.down-range-labels {
  align-items: center;
  margin-top: 6px;
}
.down-range-labels strong {
  padding: 4px 8px;
  border-radius: 100px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  font-size: 9px;
  font-weight: 600;
}
.error {
  min-height: 14px;
  margin: 5px 0 -14px;
  color: #b12e25;
  font-size: 11px;
}

.advanced {
  margin-top: 3px;
}
.advanced summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--blue-dark);
  border-bottom: 2px solid var(--blue-dark);
  transform: rotate(45deg) translate(-2px, 2px);
  transition: transform 0.18s ease;
}
.advanced[open] summary {
  border-color: rgba(41, 152, 255, 0.55);
  background: var(--blue-soft);
}
.advanced[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}
.advanced summary:focus { outline: none; }
.advanced summary:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(41, 152, 255, 0.14);
}
.advanced summary span {
  padding: 5px 8px;
  border-radius: 100px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  font-size: 9px;
  font-weight: 500;
}
.advanced-body { padding: 16px 2px 2px; }
.advanced-body > label, .advanced legend {
  display: block;
  margin-bottom: 9px;
  font-size: 12px;
  font-weight: 700;
}
.advanced fieldset {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}
.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.radio-row input { margin-top: 3px; accent-color: var(--blue); }
.radio-row span, .radio-row strong, .radio-row small { display: block; }
.radio-row strong { font-size: 12px; }
.radio-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.result-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.preliminary {
  padding: 5px 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  font-size: 8px;
}
.monthly {
  display: block;
  font-size: clamp(38px, 5vw, 62px);
  line-height: 1;
  letter-spacing: -0.055em;
  font-weight: 500;
}
.income-note {
  margin: 13px 0 26px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  line-height: 1.5;
}
.income-note strong { color: #fff; font-weight: 600; }
.composition {
  padding: 18px 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
}
.composition-title {
  display: block;
  margin-bottom: 14px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
@property --principal-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.payment-donut {
  --principal-angle: 148deg;
  --principal-color: var(--blue);
  --interest-color: #7bc2ff;
  position: relative;
  display: grid;
  place-items: center;
  width: 154px;
  aspect-ratio: 1;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: conic-gradient(
    var(--principal-color) 0 var(--principal-angle),
    var(--interest-color) var(--principal-angle) 360deg
  );
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  transition: --principal-angle 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: crosshair;
}
.payment-donut.show-principal {
  --interest-color: rgba(123, 194, 255, 0.18);
}
.payment-donut.show-interest {
  --principal-color: rgba(41, 152, 255, 0.18);
}
.payment-donut.is-building {
  animation: donut-build 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.payment-donut.is-building .donut-center {
  animation: donut-center-pop 0.52s 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.payment-donut.is-waiting {
  transform: scale(0.72) rotate(-95deg);
  filter: saturate(0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.payment-donut.is-waiting .donut-center {
  transform: scale(0.55);
  opacity: 0;
}
@keyframes donut-build {
  from {
    transform: scale(0.72) rotate(-95deg);
    filter: saturate(0.55);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }
  58% { transform: scale(1.045) rotate(8deg); }
  to {
    transform: scale(1) rotate(0);
    filter: saturate(1);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  }
}
@keyframes donut-center-pop {
  from { transform: scale(0.55); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.payment-donut::before {
  content: "";
  position: absolute;
  width: 92px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #0c2443;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.donut-center {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 3px;
}
.donut-center span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 9px;
}
.donut-center strong {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}
.donut-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 10px;
}
.donut-legend button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: inherit;
}
.donut-legend button:hover,
.donut-legend button:focus-visible { color: #fff; }
.donut-legend i { width: 8px; height: 8px; border-radius: 50%; }
.donut-detail {
  min-height: 18px;
  margin: 10px 0 -8px;
  visibility: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
}
.donut-detail.is-visible { visibility: visible; }
.donut-detail strong {
  margin-left: 5px;
  color: #fff;
  font-size: 12px;
}
.principal-dot { background: var(--blue); }
.interest-dot { background: var(--coral); }
.total-dot {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}
.result-list { margin: 10px 0 18px; }
.result-list div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.result-list dt { color: rgba(255, 255, 255, 0.56); font-size: 11px; }
.result-list dd { margin: 0; text-align: right; font-size: 12px; font-weight: 600; }
.result-list .result-emphasis {
  padding: 13px 0;
}
.result-emphasis dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}
.result-emphasis dt i {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.result-list .result-emphasis dd {
  font-size: 15px;
  font-weight: 600;
}
.scenario-tip {
  margin: 0 0 19px;
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.07);
  border-left: 2px solid var(--blue);
  font-size: 11px;
  line-height: 1.5;
}
.scenario-tip strong { color: #fff; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-primary-wide { grid-column: 1 / -1; }
.primary-action, .secondary-action, .share-action {
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.primary-action { border: 1px solid var(--blue); color: #fff; background: var(--blue); }
.secondary-action { border: 1px solid rgba(255, 255, 255, 0.22); color: #fff; background: transparent; }
.share-action {
  border: 1px solid #ff806d;
  color: var(--ink);
  background: #ff806d;
}
.primary-action:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.secondary-action:hover { background: rgba(255, 255, 255, 0.08); }
.share-action:hover { background: #ff927f; border-color: #ff927f; }
.share-status {
  min-height: 14px;
  margin: 8px 0 -4px;
  color: rgba(255, 255, 255, 0.68);
  text-align: center;
  font-size: 9px;
}
.article-full-link { display: none; }
.disclaimer { margin: 12px 0 0; color: rgba(255, 255, 255, 0.38); font-size: 9px; line-height: 1.45; }

.comparison {
  margin-top: 18px;
  padding: 26px;
  border-radius: 32px;
  background: var(--gray-50);
}
.comparison-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.comparison-head h2 { margin: 0; font-size: 25px; font-weight: 500; letter-spacing: -0.03em; }
.close-comparison, .dialog-close {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 28px;
}
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.scenario-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.scenario-card.current { border-color: rgba(41, 152, 255, 0.55); background: var(--blue-soft); }
.scenario-card > span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.scenario-card h3 { margin: 8px 0 16px; font-size: 24px; font-weight: 500; }
.scenario-card dl { margin: 0; }
.scenario-card dl div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 11px; }
.scenario-card dd { margin: 0; font-weight: 600; }

.schedule-section {
  margin-top: 18px;
  padding: 30px;
  border-radius: 32px;
  background: var(--gray-50);
}
.schedule-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}
.schedule-head h2 {
  margin: 0 0 7px;
  font-size: clamp(27px, 3.4vw, 40px);
  font-weight: 500;
  letter-spacing: -0.045em;
}
.schedule-head > div:first-child > p:last-child {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 50%; }
.chart-shell {
  position: relative;
  padding: 18px 18px 14px;
  background: #fff;
  border: 1px solid var(--soft);
  border-radius: 24px;
  box-shadow: var(--shadow-1);
}
.payment-chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-grid line {
  stroke: rgba(8, 18, 37, 0.1);
  stroke-width: 1;
}
.chart-area {
  transform-box: fill-box;
  transform-origin: center bottom;
}
.payment-chart.is-updating .chart-area {
  animation: chart-rise 0.82s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.payment-chart.is-updating .chart-area-interest {
  animation-delay: 0.1s;
}
.payment-chart.is-updating .chart-cursor {
  animation: cursor-settle 0.38s 0.62s ease-out both;
}
.payment-chart.is-waiting .chart-area {
  clip-path: inset(100% 0 0 0);
  transform: translateY(16px);
}
.payment-chart.is-waiting .chart-cursor { opacity: 0; }
@keyframes chart-rise {
  from {
    clip-path: inset(100% 0 0 0);
    transform: translateY(16px);
  }
  to {
    clip-path: inset(0 0 0 0);
    transform: translateY(0);
  }
}
@keyframes cursor-settle {
  from { opacity: 0; }
  to { opacity: 1; }
}
.chart-area-principal { fill: var(--blue); fill-opacity: 0.88; }
.chart-area-interest { fill: #7bc2ff; fill-opacity: 0.82; }
.crossover-marker {
  cursor: help;
  outline: none;
}
.crossover-marker-halo {
  fill: rgba(255, 128, 109, 0.24);
  stroke: rgba(255, 255, 255, 0.88);
  stroke-width: 1;
  transform-box: fill-box;
  transform-origin: center;
  animation: crossover-pulse 2.2s ease-in-out infinite;
}
.crossover-marker-dot {
  fill: #ff806d;
  stroke: #fff;
  stroke-width: 2;
}
.crossover-marker:focus-visible .crossover-marker-halo {
  stroke: var(--ink);
  stroke-width: 2;
}
@keyframes crossover-pulse {
  0%, 100% { transform: scale(0.82); opacity: 0.58; }
  50% { transform: scale(1.16); opacity: 1; }
}
.crossover-tooltip {
  position: absolute;
  z-index: 12;
  width: min(310px, calc(100% - 32px));
  padding: 11px 12px;
  border: 1px solid rgba(255, 128, 109, 0.34);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow-3);
  font-size: 10px;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease, transform 0.16s ease;
}
.crossover-tooltip strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
}
.crossover-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, calc(-100% - 18px));
}
.chart-axis-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
}
.chart-cursor {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  pointer-events: none;
}
.chart-shell input.chart-month-control {
  display: block;
  width: calc(100% - 58px);
  margin: -4px 14px 6px 44px;
  outline: none;
}
.chart-focus {
  min-height: 18px;
  margin: 8px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}
.chart-focus strong { color: var(--ink); font-weight: 600; }
.schedule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.schedule-actions button {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  box-shadow: 0 1px 0 rgba(8, 18, 37, 0.04);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.16s ease, border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
}
.schedule-actions button:hover {
  border-color: rgba(41, 152, 255, 0.48);
  color: var(--blue-dark);
  background: var(--blue-soft);
  transform: translateY(-1px);
}
.schedule-actions button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.schedule-actions svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.schedule-actions .report-error-action { color: #d5504c; }
.schedule-actions .report-error-action svg { stroke: #ff665f; }
.schedule-actions .report-error-action:hover {
  border-color: rgba(255, 102, 95, 0.45);
  color: #b53b36;
  background: #fff5f4;
}
.schedule-action-status {
  min-height: 15px;
  margin: 6px 2px -5px;
  color: var(--green);
  font-size: 10px;
}
.schedule-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.schedule-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.schedule-table th,
.schedule-table td {
  padding: 12px 13px;
  border-bottom: 1px solid rgba(8, 18, 37, 0.09);
  text-align: right;
  font-size: 11px;
  white-space: nowrap;
}
.schedule-table th {
  color: var(--muted);
  background: rgba(8, 18, 37, 0.035);
  font-weight: 600;
}
.schedule-table th:nth-child(2),
.schedule-table td:nth-child(2) { text-align: left; }
.schedule-table tbody tr:hover { background: var(--blue-soft); }
.schedule-table .schedule-gap td {
  padding: 9px 13px;
  color: var(--muted);
  background: rgba(8, 18, 37, 0.025);
  text-align: center;
  font-size: 10px;
}
.schedule-table tfoot td {
  border-bottom: 0;
  color: var(--ink);
  background: var(--blue-soft);
  font-weight: 700;
}
.schedule-toggle {
  display: block;
  min-height: 42px;
  margin: 14px auto 0;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--blue-dark);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
}
.schedule-toggle:hover { background: var(--soft); }

.lead-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 32px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 24px 80px rgba(8, 18, 37, 0.35);
}
.lead-dialog::backdrop { background: rgba(4, 9, 19, 0.78); backdrop-filter: blur(6px); }
.lead-form { position: relative; padding: 34px; }
.lead-form h2 { margin-bottom: 8px; font-size: 29px; line-height: 1.05; letter-spacing: -0.035em; font-weight: 500; }
.lead-form > p:not(.eyebrow):not(.form-status) { margin-bottom: 24px; color: var(--muted); font-size: 13px; }
.dialog-close { position: absolute; top: 14px; right: 17px; }
.lead-form > label:not(.consent) { display: block; margin: 14px 0 7px; font-size: 11px; font-weight: 700; }
.lead-form > input {
  width: 100%;
  min-height: 50px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #fff;
}
.lead-form > input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(41, 152, 255, 0.14); }
.consent { display: flex; align-items: flex-start; gap: 9px; margin: 16px 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.consent input { margin-top: 1px; accent-color: var(--blue); }
.consent a {
  color: var(--blue-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.consent a:hover { color: var(--blue); }
.consent a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 2px;
}
.lead-form .primary-action { width: 100%; }
.form-status { min-height: 16px; margin: 10px 0 0; color: var(--green); font-size: 11px; }

@media (min-width: 901px) {
  .mortgage-app {
    max-width: 1280px;
    padding: 24px;
  }
  .app-header {
    gap: 24px;
    margin-bottom: 14px;
    padding: 22px 28px;
    border-radius: 26px;
  }
  h1 {
    max-width: 580px;
    margin-bottom: 6px;
    font-size: clamp(34px, 3.2vw, 42px);
  }
  .lead {
    max-width: 560px;
    font-size: 13px;
  }
  .mode-switch {
    grid-template-columns: 104px minmax(0, 1fr);
    width: min(660px, 100%);
    margin-bottom: 14px;
  }
  .mode-caption { font-size: 13px; }
  .mode-button {
    min-height: 44px;
    padding: 8px 16px;
    font-size: 13px;
  }
  .calculator-layout {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.76fr);
    gap: 18px;
  }
  .controls,
  .results { border-radius: 26px; }
  .controls,
  .results { padding: 22px; }
  .control-section { margin-bottom: 14px; }
  .money-input,
  .select-input { min-height: 48px; }
  .money-input input,
  .select-input select { font-size: 16px; }
  .money-input input { padding-top: 11px; padding-bottom: 11px; }
  .range-line { margin-top: 8px; }
  .advanced summary { min-height: 44px; }
  .monthly { font-size: clamp(38px, 3.6vw, 46px); }
  .income-note { margin: 8px 0 12px; }
  .composition {
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr);
    align-items: center;
    gap: 10px 18px;
    padding: 12px 0;
    text-align: left;
  }
  .composition-title {
    grid-column: 1 / -1;
    margin-bottom: 0;
    text-align: center;
  }
  .payment-donut {
    grid-row: 2 / 4;
    width: 126px;
    margin: 0;
  }
  .payment-donut::before { width: 74px; }
  .donut-center strong { font-size: 15px; }
  .donut-legend {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 4px;
  }
  .donut-legend button {
    justify-content: flex-start;
    width: 100%;
    padding: 6px 9px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.045);
  }
  .donut-legend button:hover,
  .donut-legend button:focus-visible {
    background: rgba(255, 255, 255, 0.09);
  }
  .donut-detail {
    display: grid;
    align-content: center;
    min-height: 34px;
    margin: 0;
    padding: 7px 9px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.045);
  }
  .donut-detail:not(.is-visible) {
    background: transparent;
  }
  .donut-detail strong {
    display: block;
    margin: 2px 0 0;
    font-size: 12px;
  }
  .result-list { margin: 6px 0 10px; }
  .result-list div { padding: 6px 0; }
  .result-list .result-emphasis { padding: 7px 0; }
  .scenario-tip {
    margin-bottom: 10px;
    padding: 8px 11px;
  }
  .primary-action,
  .secondary-action,
  .share-action { min-height: 44px; }
  .share-status { margin-top: 4px; }
  .disclaimer { margin-top: 7px; text-align: center; }
  .comparison,
  .schedule-section {
    margin-top: 16px;
    padding: 24px;
    border-radius: 26px;
  }
  .schedule-head { margin-bottom: 20px; }
  .schedule-head h2 { font-size: clamp(27px, 3vw, 34px); }
  .chart-shell { padding: 14px 14px 11px; }
}

@media (max-width: 820px) {
  .mortgage-app { padding: 22px; }
  .app-header { padding: 28px; border-radius: 24px; }
  .app-header { display: block; }
  .calculator-layout { grid-template-columns: 1fr; align-items: start; }
  .results { position: static; }
  .schedule-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .chart-legend { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .mortgage-app { padding: 12px; border: 0; border-radius: 0; }
  .app-header { margin-bottom: 20px; }
  .app-header { padding: 22px 18px; border-radius: 24px; }
  h1 { font-size: 34px; }
  .lead { font-size: 13px; }
  .mode-switch { display: block; width: 100%; }
  .mode-caption { display: none; }
  .mode-options { grid-template-columns: repeat(3, 1fr); }
  .mode-button { padding: 8px; font-size: 11px; }
  .controls, .results, .comparison, .schedule-section { padding: 20px; border-radius: 24px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .payment-type-options { grid-template-columns: 1fr; }
  .result-actions, .comparison-grid { grid-template-columns: 1fr; }
  .schedule-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .schedule-actions button {
    width: 100%;
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
    font-size: 10px;
  }
  #saveCalculationButton,
  #printCalculationButton,
  #pdfCalculationButton { display: none; }
  .schedule-actions .report-error-action { grid-column: auto; }
  .action-primary-wide { grid-column: auto; }
  .payment-donut { width: 166px; }
  .chart-shell { padding: 10px 8px; }
  .payment-chart { width: 100%; }
  .chart-shell input.chart-month-control {
    width: calc(100% - 48px);
    margin-right: 8px;
    margin-left: 40px;
  }
  .chart-axis-label { font-size: 11px; }
  .chart-focus {
    padding: 0 8px;
    font-size: 10px;
    line-height: 1.45;
  }
  .schedule-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  .schedule-table {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }
  .schedule-table tbody,
  .schedule-table tfoot {
    display: block;
    width: 100%;
  }
  .schedule-table thead { display: none; }
  .schedule-table tbody tr:not(.schedule-gap),
  .schedule-table tfoot tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
  }
  .schedule-table td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 11px 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    white-space: normal;
  }
  .schedule-table tbody tr:not(.schedule-gap) td:nth-child(odd) {
    border-right: 1px solid rgba(8, 18, 37, 0.08);
  }
  .schedule-table tbody tr:not(.schedule-gap) td:nth-child(-n + 2) {
    background: var(--gray-50);
  }
  .schedule-table td::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .schedule-table td:nth-child(1)::before { content: "Платёж №"; }
  .schedule-table td:nth-child(2)::before { content: "Месяц"; }
  .schedule-table td:nth-child(3)::before { content: "Сумма платежа"; }
  .schedule-table td:nth-child(4)::before { content: "Основной долг"; }
  .schedule-table td:nth-child(5)::before { content: "Проценты"; }
  .schedule-table td:nth-child(6)::before { content: "Остаток долга"; }
  .schedule-table .schedule-gap {
    display: block;
    width: 100%;
    margin: 2px 0 12px;
  }
  .schedule-table .schedule-gap td {
    display: block;
    width: 100%;
    border: 1px dashed var(--line);
    border-radius: 12px;
  }
  .schedule-table .schedule-gap td::before { display: none; }
  .schedule-table tfoot td:first-child { display: none; }
  .schedule-table tfoot td:nth-child(2) {
    grid-column: 1 / -1;
    font-size: 13px;
  }
  .schedule-table tfoot td:nth-child(2)::before { display: none; }
  .schedule-table tfoot td:nth-child(odd) {
    border-right: 1px solid rgba(8, 18, 37, 0.08);
  }
  .lead-form { padding: 28px 20px 22px; }
}

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

@media print {
  .mode-switch,
  .result-actions,
  .share-status,
  .schedule-actions,
  .schedule-action-status,
  .schedule-toggle,
  .lead-dialog { display: none !important; }
  .mortgage-app { max-width: none; padding: 0; }
  .results {
    position: static;
    color: #000;
    background: #fff;
    box-shadow: none;
  }
  .results,
  .results * { color: #000 !important; }
  .composition,
  .result-list div { border-color: #d9d9d9 !important; }
  .schedule-section { padding: 0; background: #fff; }
}

body.article-embed .mortgage-app {
  max-width: 1180px;
  padding: 14px;
  border: 1px solid rgba(9, 27, 54, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow-2);
}

body.article-embed .app-header {
  margin-bottom: 12px;
  padding: 20px 24px;
  border-radius: 20px;
}

body.article-embed .app-header .eyebrow { margin-bottom: 6px; }
body.article-embed .app-header h1 {
  margin-bottom: 5px;
  font-size: 28px;
  letter-spacing: -0.035em;
}
body.article-embed .app-header .lead {
  max-width: none;
  font-size: 12px;
}

body.article-embed .mode-switch,
body.article-embed .advanced,
body.article-embed .payment-type-section,
body.article-embed .schedule-section,
body.article-embed .comparison,
body.article-embed .rate-hint,
body.article-embed .composition,
body.article-embed .result-list,
body.article-embed .scenario-tip,
body.article-embed .share-status,
body.article-embed #compareButton,
body.article-embed #shareButton {
  display: none !important;
}

body.article-embed .calculator-layout {
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
}

body.article-embed .controls {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) minmax(190px, 1.15fr) minmax(110px, 0.65fr) minmax(110px, 0.65fr);
  align-items: end;
  gap: 12px;
  padding: 20px;
  border-radius: 20px;
}

body.article-embed .control-section { margin: 0; }
body.article-embed .control-section > label,
body.article-embed .field-head > label,
body.article-embed .payment-type-section legend {
  margin-bottom: 7px;
  font-size: 10px;
}
body.article-embed .field-hint { display: none; }
body.article-embed .article-field-range { display: block; }
body.article-embed .money-input { min-height: 48px; }
body.article-embed .money-input input {
  padding-top: 11px;
  padding-bottom: 11px;
  font-size: 16px;
}
body.article-embed .unit-switch { margin-bottom: -1px; }
body.article-embed .controls .range-line {
  position: relative;
  z-index: 2;
  margin: -9px 3px -9px;
  padding: 0 1px;
}
body.article-embed .controls .range-labels { display: none; }
body.article-embed .controls input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: ew-resize;
}
body.article-embed .controls input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    var(--blue) 0 var(--range-progress, 0%),
    #d8dce3 var(--range-progress, 0%) 100%
  );
}
body.article-embed .controls input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6.5px;
  border: 3px solid #fff;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--blue);
  box-shadow: 0 1px 5px rgba(9, 27, 54, 0.25);
}
body.article-embed .controls input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 99px;
  background: #d8dce3;
}
body.article-embed .controls input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 99px;
  background: var(--blue);
}
body.article-embed .controls input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 5px rgba(9, 27, 54, 0.25);
}
body.article-embed .error {
  position: absolute;
  margin: 3px 0 0;
}

body.article-embed .results {
  position: static;
  top: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 190px;
  padding: 22px;
  border-radius: 20px;
}
body.article-embed .result-topline { margin-bottom: 7px; }
body.article-embed .monthly { font-size: 42px; }
body.article-embed .income-note {
  margin: 10px 0 18px;
  font-size: 10px;
}
body.article-embed .result-actions {
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
body.article-embed .action-primary-wide { grid-column: auto; }
body.article-embed .primary-action,
body.article-embed .article-full-link {
  min-height: 44px;
  padding: 10px 13px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
body.article-embed .article-full-link {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}
body.article-embed .article-full-link:hover { background: rgba(255, 255, 255, 0.08); }
body.article-embed .disclaimer {
  margin-top: 9px;
  font-size: 7px;
}

@media (max-width: 1050px) {
  body.article-embed .controls { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  body.article-embed .calculator-layout { grid-template-columns: 1fr; }
  body.article-embed .results { min-height: 0; }
}

@media (max-width: 520px) {
  body.article-embed .mortgage-app {
    padding: 8px;
    border-radius: 22px;
  }
  body.article-embed .app-header {
    padding: 18px;
    border-radius: 18px;
  }
  body.article-embed .app-header h1 { font-size: 25px; }
  body.article-embed .controls {
    grid-template-columns: 1fr;
    padding: 16px;
    border-radius: 18px;
  }
  body.article-embed .results {
    padding: 20px;
    border-radius: 18px;
  }
}
