:root {
  color-scheme: light;
  --bg: #f2f5f1;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --surface-warm: #fff8ec;
  --ink: #17201d;
  --muted: #60706a;
  --line: #d8dfda;
  --green: #23796a;
  --blue: #2d67c8;
  --red: #b74343;
  --amber: #b36b20;
  --violet: #6657b8;
  --shadow: 0 18px 42px rgb(23 32 29 / 8%);
  --shadow-soft: 0 10px 26px rgb(23 32 29 / 7%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 280px),
    var(--bg);
  color: var(--ink);
  font-family: Arial, "Noto Sans HK", "Microsoft JhengHei", sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 78px;
  height: 56px;
  object-fit: contain;
  border: 1px solid rgb(216 223 218 / 80%);
  border-radius: 8px;
  background: #111816;
  padding: 5px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.brand span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 15px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-nav a {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  border-color: var(--ink);
  color: var(--ink);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 64px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy,
.calculator-panel,
.summary-card,
.advanced-panel,
.results-section,
.formula-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.hero-copy {
  display: grid;
  min-height: 360px;
  align-content: space-between;
  padding: clamp(24px, 4vw, 44px);
  border-color: #cad8d0;
  background:
    linear-gradient(135deg, rgb(238 244 241 / 96%), rgb(255 255 255 / 94%)),
    var(--surface);
}

.hero-logo-strip {
  display: inline-flex;
  width: min(430px, 100%);
  min-height: 168px;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px;
  border: 1px solid #d2ddd7;
  border-radius: 8px;
  background: rgb(255 255 255 / 72%);
  padding: 12px 18px;
}

.hero-logo-strip img {
  display: block;
  width: min(390px, 100%);
  max-height: 154px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(36px, 5vw, 62px);
}

h2 {
  font-size: clamp(23px, 2.4vw, 32px);
}

.hero-copy p:not(.eyebrow) {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.hero-stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.hero-stat-row span {
  display: grid;
  min-height: 74px;
  align-content: center;
  border: 1px solid #d2ddd7;
  border-radius: 8px;
  background: rgb(255 255 255 / 72%);
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.hero-stat-row strong {
  color: var(--ink);
  font-size: 23px;
  line-height: 1.1;
}

.calculator-panel {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  justify-content: center;
  padding: clamp(20px, 3vw, 32px);
  border-color: #cfd9d4;
  box-shadow: var(--shadow);
}

.panel-kicker {
  margin: 0 0 16px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.amount-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.amount-input-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  padding: 14px 16px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.amount-input-wrap:focus-within {
  border-color: var(--green);
  outline: 3px solid rgb(47 127 111 / 16%);
  background: #fff;
}

.amount-input-wrap span {
  color: var(--muted);
  font-size: 24px;
  font-weight: 800;
}

.amount-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: 0;
}

.form-error {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ghost-button,
.reset-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 800;
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.ghost-button:hover,
.reset-button:hover,
.ghost-button:focus-visible,
.reset-button:focus-visible {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--ink);
  color: #fff;
  transform: translateY(-1px);
}

.panel-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.summary-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-top: 4px solid var(--green);
}

.summary-card:nth-child(2) {
  border-top-color: var(--blue);
}

.summary-card:nth-child(3) {
  border-top-color: var(--amber);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.18;
}

.summary-card:nth-child(2) strong {
  color: var(--blue);
}

.summary-card:nth-child(3) strong {
  color: var(--amber);
}

.advanced-panel {
  margin: 18px 0;
  padding: 0;
}

.advanced-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  list-style: none;
}

.advanced-panel summary::-webkit-details-marker {
  display: none;
}

.advanced-panel summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.advanced-panel summary strong {
  font-size: 20px;
}

.advanced-panel summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.rate-editor {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 20px;
}

.rate-field {
  display: grid;
  gap: 6px;
}

.rate-field label {
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.rate-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 800;
}

.rate-field input:focus {
  border-color: var(--green);
  outline: 3px solid rgb(47 127 111 / 16%);
}

.reset-button {
  margin: 0 20px 20px;
}

.results-section,
.formula-note {
  margin-top: 18px;
  padding: clamp(20px, 3vw, 30px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading p:not(.eyebrow) {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
}

.section-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 900;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
}

caption {
  height: 1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
  clip: rect(1px, 1px, 1px, 1px);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #eef4f1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  box-shadow: inset 0 -1px 0 var(--line);
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover td {
  background: #f7fbf9;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: center;
}

td:first-child {
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

th:first-child {
  z-index: 2;
  background: #eef4f1;
}

td:nth-child(2),
th:nth-child(2) {
  text-align: right;
  border-right: 1px solid var(--line);
}

tr:nth-child(5n) td {
  border-bottom: 4px solid #9baaa3;
}

tr:last-child td {
  border-bottom: 0;
  background: var(--surface-warm);
  font-weight: 800;
}

tr:last-child td:first-child {
  background: var(--surface-warm);
}

.principal-cell {
  color: var(--muted);
}

.highlight-column {
  color: var(--red);
  font-weight: 800;
}

.best-column {
  color: var(--green);
  font-weight: 800;
}

.formula-note {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 1fr);
  gap: 24px;
  border-left: 5px solid var(--amber);
}

.formula-note h2 {
  font-size: 22px;
}

.formula-note p {
  margin: 0;
  color: var(--muted);
}

.assumption-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.assumption-grid p {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

@media (max-width: 960px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
  }

  .hero-band,
  .summary-grid,
  .formula-note,
  .assumption-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .calculator-panel {
    min-height: auto;
  }

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

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .page-shell,
  .site-header {
    width: min(100% - 20px, 1180px);
  }

  .page-shell {
    padding-top: 12px;
  }

  .top-nav a {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  .hero-copy,
  .calculator-panel,
  .results-section,
  .formula-note {
    padding: 18px;
  }

  .advanced-panel summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .advanced-panel summary small {
    margin-left: 0;
  }

  .rate-editor {
    grid-template-columns: 1fr;
  }

  .summary-card strong {
    font-size: 26px;
  }

  .hero-stat-row {
    grid-template-columns: 1fr;
  }
}
