@font-face {
  font-family: "Comparison TC";
  src: url("./tc-regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Comparison TC";
  src: url("./tc-bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

:root {
  font-family: "Comparison TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: #182e2a;
  background: #f5f6f2;
  font-synthesis: none;
  --muted: #4d615b;
  --border: #dce5df;
  --accent: #1a574a;
  --surface: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, p, dl, dd { margin: 0; }
button, input { font: inherit; }

.shell { width: min(1060px, calc(100% - 48px)); margin-inline: auto; }

.hero {
  color: #fff;
  background-color: #123a35;
  background-image: radial-gradient(ellipse at 85% 8%, #286356 0%, transparent 58%);
  border-bottom: 4px solid #b3c5a2;
}

.hero-inner { padding-block: 48px 43px; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.35rem); line-height: 1.16; letter-spacing: .035em; }
.hero p { margin-top: 10px; color: #dfede6; line-height: 1.7; }
main.shell { flex: 1 0 auto; padding-block: 28px 52px; }

.site-footer {
  padding-block: 16px;
  border-top: 1px solid var(--border);
  background: #edf4ee;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.7;
}

.panel { padding: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; }
h2 { font-size: 1.35rem; line-height: 1.45; letter-spacing: .025em; }
.settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 184px;
  grid-template-areas: "heading advisor" "form advisor";
  grid-template-rows: auto 1fr;
  gap: 16px 24px;
}

.settings h2 { grid-area: heading; }
#calculator { grid-area: form; min-width: 0; }
.advisor-contact {
  grid-area: advisor;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #edf4ee;
  border-radius: 12px;
}

.advisor-portrait {
  display: block;
  width: 112px;
  height: 112px;
  object-fit: cover;
  border: 1px solid #dce5df;
  border-radius: 50%;
  background: #fff;
}

.advisor-contact .contact-button { min-height: 44px; padding: 6px 12px; white-space: nowrap; }
#copy-status { min-height: 1.25em; text-align: center; font-size: .78rem; color: var(--muted); }
#copy-status code { color: #18493e; user-select: all; }
.clipboard-source { position: fixed; inset: 0 auto auto 0; opacity: 0; pointer-events: none; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.fields label { display: grid; gap: 7px; min-width: 0; font-weight: 700; }
.input-wrap { position: relative; display: block; }
.unit { position: absolute; top: 50%; right: 13px; transform: translateY(-50%); color: var(--muted); font-weight: 400; pointer-events: none; }

input {
  width: 100%;
  min-height: 48px;
  padding: 8px 38px 8px 12px;
  appearance: textfield;
  color: #182e2a;
  background: #fbfcfa;
  border: 1px solid #aabcb2;
  border-radius: 9px;
  font-size: 1.0625rem;
  font-variant-numeric: tabular-nums;
}

input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }
input::placeholder { color: #677a72; font-weight: 400; }

.bank-setting {
  margin-top: 18px;
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  background: #edf4ee;
  border-radius: 9px;
}

.bank-quote, .bank-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.bank-quote { font-size: .93rem; }
.bank-quote strong { font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.bank-meta { color: var(--muted); font-size: .84rem; }
.bank-meta a { color: #23554a; text-underline-offset: 3px; }

.primary, .secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.45;
}

.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #12483c; }
.primary:disabled { opacity: .65; cursor: wait; }
.secondary { background: #fff; color: #18493e; border-color: #aabcb2; }
.secondary:hover { background: #edf4ee; }
:focus-visible { outline: 3px solid #2e7666; outline-offset: 3px; }
.calculate { margin-top: 18px; }

.results { margin-top: 20px; }
.result-heading { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; }
.result-heading p { color: var(--muted); font-size: .875rem; }

.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.total { border-radius: 11px; border: 1px solid var(--border); background: #f7faf7; padding: 13px; }
.total dt { font-size: .875rem; color: var(--muted); }
.total dd { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.45; overflow-wrap: anywhere; }
.total.difference { background: #155447; border-color: #155447; color: #fff; }
.total.difference dt { color: #e1f0e7; }

.table-heading { display: flex; flex-wrap: wrap; gap: 3px 9px; justify-content: space-between; align-items: baseline; margin-block: 25px 10px; }
.table-heading h3 { font-size: 1.12rem; }
.table-heading p { color: var(--muted); font-size: .84rem; }
.scroll-hint { display: none; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; }

table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .915rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th, td { padding: 10px 12px; text-align: right; }
thead th { color: #153d33; background: #e8f0e9; font-size: .885rem; }
thead th span { display: block; margin-top: 1px; font-size: .79rem; font-weight: 400; color: #385950; }
th:nth-child(-n+3), td:nth-child(-n+3) { text-align: center; }
tbody tr { --row-bg: #fff; }
tbody tr:nth-child(even) { --row-bg: #f6f9f6; }
tbody :is(th, td) { background: var(--row-bg); border-top: 1px solid #e5ebe7; }
tr > :first-child { position: sticky; left: 0; border-right: 1px solid #e0e8e2; }
tbody tr:last-child { --row-bg: #e2eee3; font-weight: 700; }
.negative { color: #923e37; }

.assumptions { margin-top: 13px; color: var(--muted); font-size: .875rem; line-height: 1.7; }
.export-actions { margin-top: 16px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; }
#export-status, #share-status { color: var(--muted); font-size: .875rem; line-height: 1.6; }

dialog {
  width: min(760px, calc(100% - 24px));
  max-height: min(870px, calc(100dvh - 30px));
  padding: 0;
  background: #fff;
  color: #182e2a;
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 10px 42px #112a2460;
}

dialog::backdrop { background: #10251ecc; }
.dialog-inner { padding: 17px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
#share-status { margin-block: 8px 10px; }
.report-image { display: block; width: 100%; height: auto; background: #f7faf7; border: 1px solid var(--border); border-radius: 7px; }

@media (max-width: 820px) {
  .scroll-hint { display: inline; }
}

@media (max-width: 720px) {
  .shell { width: calc(100% - 28px); }
  .hero-inner { padding-block: 32px 30px; }
  .hero h1 { font-size: clamp(1.8rem, 8vw, 2.1rem); }
  .hero p { font-size: .92rem; }
  main.shell { padding-block: 14px 34px; }
  .panel { padding: 16px; border-radius: 14px; }
  .settings {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "heading advisor" "form form";
    align-items: center;
    gap: 14px;
  }
  .advisor-contact { min-width: 128px; padding: 7px 9px; gap: 4px; }
  .advisor-portrait { width: 70px; height: 70px; }
  .advisor-contact .contact-button { font-size: .875rem; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .fields label:first-child { grid-column: 1 / -1; }
  .bank-setting { padding: 10px 12px; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .total { padding: 9px; }
  .total dd { font-size: clamp(1rem, 5vw, 1.45rem); }
  .calculate, #export { width: 100%; }
}
