:root {
  color-scheme: light;
  --brand-red: #d92b22;
  --brand-red-dark: #ad201a;
  --teal: #006d77;
  --gold: #b77905;
  --ink: #202523;
  --muted: #65706b;
  --line: #d9dfdc;
  --surface: #ffffff;
  --surface-soft: #f3f6f4;
  --success: #18794e;
  --warning: #925d00;
  --shadow: 0 8px 24px rgba(31, 42, 37, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--surface-soft);
  font-family:
    Arial,
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-soft);
}

button,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100% - 32px, 1080px);
  min-height: 92px;
  margin: 0 auto;
}

.brand-mark {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-red);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 span {
  color: var(--brand-red);
}

.topbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

main {
  width: min(100% - 24px, 1080px);
  margin: 0 auto;
  padding: 18px 0 calc(36px + env(safe-area-inset-bottom));
}

.calculator-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand-red);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.subsidy-notice {
  margin-bottom: 20px;
  padding: 13px 14px;
  border: 1px solid #e7c66c;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #fff8e5;
  color: #5f4510;
}

.notice-title {
  margin-bottom: 4px;
  color: #493507;
  font-size: 14px;
  font-weight: 800;
}

.subsidy-notice p:last-child {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.65;
}

.panel-heading,
.results-heading,
.result-card__header,
.bank-title-row,
.rate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  align-items: flex-start;
  margin-bottom: 10px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.scope-notice {
  margin: 0 0 18px;
  color: #4f5d57;
  font-size: 12px;
  line-height: 1.6;
}

.coverage-badge,
.rank-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

#calculator-form {
  display: grid;
  gap: 18px;
}

.control-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.control-group > label,
.control-group > legend {
  display: block;
  width: 100%;
  margin-bottom: 9px;
  padding: 0;
  color: #39413d;
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: grid;
  width: 100%;
  overflow: hidden;
  border: 1px solid #cbd3cf;
  border-radius: 8px;
  background: #fff;
}

.segmented--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  display: grid;
  min-width: 0;
  min-height: 44px;
  place-items: center;
  border-right: 1px solid #cbd3cf;
  color: #46504b;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}

.segmented label:last-of-type {
  border-right: 0;
}

.segmented input:checked + label {
  background: var(--teal);
  color: #fff;
}

.segmented input:focus-visible + label {
  outline: 3px solid rgba(0, 109, 119, 0.2);
  outline-offset: -3px;
}

.amount-field {
  display: flex;
  align-items: center;
  min-height: 52px;
  border: 1px solid #b9c3be;
  border-radius: 8px;
  background: #fff;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.amount-field:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 109, 119, 0.12);
}

.amount-field > span {
  padding-left: 15px;
  color: var(--brand-red);
  font-size: 22px;
  font-weight: 800;
}

.amount-field input {
  min-width: 0;
  width: 100%;
  height: 50px;
  border: 0;
  outline: 0;
  padding: 0 14px 0 8px;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
}

.field-error {
  min-height: 18px;
  margin: 5px 0 -8px;
  color: var(--brand-red-dark);
  font-size: 12px;
}

.calculate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--brand-red);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--brand-red-dark);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background-color 160ms ease;
}

.calculate-button:hover {
  background: #c9231b;
}

.calculate-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--brand-red-dark);
}

.calculate-button:focus-visible {
  outline: 3px solid rgba(217, 43, 34, 0.22);
  outline-offset: 3px;
}

.button-symbol {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
}

.results-section {
  padding-top: 26px;
}

.results-heading {
  align-items: flex-end;
  margin-bottom: 14px;
}

.results-count {
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 13px;
}

.results-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 13px 14px;
  border-left: 4px solid var(--gold);
  background: #fff7df;
  color: #5f4510;
}

.results-summary strong {
  display: block;
  margin-bottom: 3px;
  color: #3c2c0a;
  font-size: 15px;
}

.results-summary span {
  font-size: 13px;
}

.results-summary b {
  color: var(--brand-red);
  font-size: 20px;
  white-space: nowrap;
}

.results-list {
  display: grid;
  gap: 12px;
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(31, 42, 37, 0.05);
}

.result-card__header {
  padding: 15px;
  border-bottom: 1px solid #e3e8e5;
}

.bank-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.bank-copy {
  min-width: 0;
}

.bank-mark {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.bank-title-row {
  justify-content: flex-start;
  gap: 8px;
}

.bank-name {
  overflow-wrap: anywhere;
  margin-bottom: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.rank-badge {
  padding: 3px 6px;
  background: #fff0ed;
  color: var(--brand-red);
}

.bank-full-name {
  overflow-wrap: anywhere;
  margin: 4px 0 0;
  color: #46504b;
  font-size: 12px;
  line-height: 1.35;
}

.activity-period {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.coverage-badge {
  padding: 5px 8px;
  background: #e8f3f3;
  color: var(--teal);
}

.payment-highlight {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 15px;
  background: #fafcfb;
}

.payment-highlight span,
.payment-highlight small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.actual-payment {
  display: block;
  margin-top: 4px;
  color: var(--brand-red);
  font-size: 27px;
  line-height: 1.1;
}

.installment-payment {
  min-width: 102px;
  text-align: right;
}

.installment-payment strong {
  display: inline-block;
  margin-top: 4px;
  font-size: 18px;
}

.installment-payment small {
  display: inline-block;
  margin-left: 3px;
}

.saving-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 6px 15px 12px;
}

.saving-grid > div {
  min-width: 0;
  padding: 12px 8px;
  border-bottom: 1px solid #e6ebe8;
}

.saving-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.saving-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.saving-grid dd {
  overflow-wrap: anywhere;
  margin: 5px 0 0;
  color: var(--success);
  font-size: 16px;
  font-weight: 800;
}

.saving-grid > div:last-child dd {
  color: var(--brand-red);
}

.rate-row {
  align-items: flex-start;
  padding: 11px 15px;
  border-top: 1px solid #e6ebe8;
  color: #4d5852;
  font-size: 12px;
}

.benefit-tier {
  max-width: 66%;
  color: var(--warning);
  text-align: right;
}

.activity-limit {
  padding: 13px 15px 14px;
  border-top: 1px solid #e6ebe8;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.activity-limit p {
  margin-bottom: 0;
}

.activity-limit__title {
  margin-bottom: 4px !important;
  color: #46504b;
  font-size: 13px;
  font-weight: 800;
}

.empty-state {
  padding: 38px 20px;
  border: 1px dashed #b9c3be;
  background: var(--surface);
  text-align: center;
}

.empty-state__mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 13px;
  place-items: center;
  border: 2px solid #9aa7a1;
  border-radius: 50%;
  color: #7d8983;
  font-size: 20px;
  font-weight: 800;
}

.empty-state h3 {
  margin-bottom: 7px;
  font-size: 17px;
}

.empty-state p {
  max-width: 500px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.page-footer {
  margin-top: 28px;
  padding: 20px 18px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: left;
}

.page-footer h2 {
  margin-bottom: 10px;
  color: #39413d;
  font-size: 15px;
}

.page-footer ol {
  margin: 0;
  padding-left: 20px;
}

.page-footer li {
  padding-left: 3px;
}

.page-footer li + li {
  margin-top: 5px;
}

@media (min-width: 720px) {
  .topbar__inner {
    min-height: 104px;
  }

  h1 {
    font-size: 26px;
  }

  .topbar p {
    font-size: 14px;
  }

  main {
    padding-top: 24px;
  }

  .calculator-panel {
    padding: 24px;
  }

  .subsidy-notice {
    padding: 14px 16px;
  }

  #calculator-form {
    grid-template-columns: 1fr 1.35fr 1.2fr auto;
    align-items: end;
    gap: 14px;
  }

  .field-error {
    position: absolute;
  }

  .calculate-button {
    min-width: 176px;
    margin-bottom: 0;
  }

  .results-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-card:first-child {
    border-color: #e8c35b;
    box-shadow: 0 8px 24px rgba(117, 82, 7, 0.1);
  }
}

@media (min-width: 1040px) {
  .results-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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