:root {
  --ink: #18332f;
  --ink-2: #314d48;
  --paper: #f7f4ec;
  --surface: #fffdfa;
  --surface-2: #eef4f2;
  --line: rgba(24, 51, 47, .14);
  --blue: #245f86;
  --teal: #3f8c83;
  --copper: #bd684e;
  --gold: #c79b42;
  --rose: #a75864;
  --danger: #9d4438;
  --shadow: 0 22px 70px rgba(24, 51, 47, .13);
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  --serif: ui-serif, Georgia, "Noto Serif TC", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(120deg, rgba(63, 140, 131, .16), transparent 34%),
    linear-gradient(210deg, rgba(199, 155, 66, .12), transparent 38%),
    linear-gradient(180deg, #f7f4ec 0%, #edf4f2 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

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

button:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(36, 95, 134, .2);
  outline-offset: 2px;
}

main {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(22px, env(safe-area-inset-left)) 12px max(22px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: rgba(247, 244, 236, .86);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fffdfa;
  background: var(--ink);
  font: 800 20px var(--serif);
}

.brand strong,
.brand small {
  display: block;
}

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

.brand small {
  margin-top: 2px;
  color: #60746f;
  font-size: 11px;
}

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

.top-actions button,
.link-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255, 253, 250, .72);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.top-actions button:hover,
.link-button:hover,
.ghost-button:hover {
  border-color: rgba(36, 95, 134, .42);
  color: var(--blue);
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  border-color: rgba(157, 68, 56, .42);
  background: rgba(157, 68, 56, .06);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 22px;
  align-items: stretch;
}

.hero-copy {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 8px;
  padding: 38px;
  color: #fffdfa;
  background:
    linear-gradient(135deg, rgba(24, 51, 47, .94), rgba(36, 95, 134, .78)),
    radial-gradient(circle at 85% 22%, rgba(199, 155, 66, .36), transparent 28%);
  box-shadow: var(--shadow);
}

.eyebrow,
.card-heading p {
  margin: 0;
  color: var(--copper);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.hero-copy .eyebrow {
  color: #f4c978;
}

.hero-copy h1 {
  max-width: 780px;
  margin: 12px 0 0;
  font: 800 48px/1.12 var(--serif);
}

.lede {
  max-width: 760px;
  margin: 18px 0 0;
  color: rgba(255, 253, 250, .86);
  font-size: 17px;
  line-height: 1.8;
}

.source-note {
  max-width: 820px;
  margin-top: 26px;
  border-left: 4px solid #f4c978;
  padding-left: 14px;
  color: rgba(255, 253, 250, .76);
  line-height: 1.65;
  font-size: 13px;
}

.profile-card,
.panel,
.metrics article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, .86);
  box-shadow: var(--shadow);
}

.profile-card,
.panel {
  padding: 24px;
}

.card-heading {
  display: grid;
  gap: 7px;
  margin-bottom: 20px;
}

.card-heading h2 {
  margin: 0;
  font: 800 27px/1.18 var(--serif);
}

.profile-grid,
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label,
legend {
  color: #425b55;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, .74);
}

input,
select {
  height: 46px;
  margin-top: 8px;
  padding: 0 12px;
}

textarea {
  display: block;
  margin-top: 8px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #8a9b97;
}

.priority-field {
  min-inline-size: 0;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #516a64;
  background: rgba(255, 255, 255, .5);
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + span {
  border-color: var(--ink);
  color: #fffdfa;
  background: var(--ink);
}

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

.metrics article {
  min-width: 0;
  padding: 18px;
}

.metrics span,
.metrics small {
  display: block;
}

.metrics span {
  color: #61736f;
  font-size: 12px;
  font-weight: 900;
}

.metrics strong {
  display: block;
  margin: 8px 0 5px;
  font: 900 28px/1 var(--serif);
}

.metrics small {
  color: #6f817c;
  line-height: 1.45;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  gap: 18px;
  align-items: start;
}

.wide {
  grid-column: 1 / -1;
}

.form-actions,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.form-actions {
  margin-top: 18px;
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fffdfa;
  background: var(--copper);
  cursor: pointer;
  font-weight: 900;
}

.primary-button:hover {
  background: #a95a42;
}

.lookup-panel {
  margin-bottom: 18px;
}

.lookup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.lookup-form .primary-button {
  min-width: 138px;
}

.lookup-result {
  margin-top: 16px;
}

.lookup-empty,
.lookup-card,
.lookup-warning {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(238, 244, 242, .68);
}

.lookup-warning {
  border-color: rgba(157, 68, 56, .24);
  background: rgba(157, 68, 56, .06);
}

.lookup-empty p,
.lookup-warning p,
.lookup-card p {
  margin: 0;
  color: #526a64;
  line-height: 1.65;
}

.lookup-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.lookup-title h3 {
  margin: 0;
  font: 800 22px/1.2 var(--serif);
}

.lookup-title small {
  color: #6b7f79;
  line-height: 1.4;
}

.lookup-code {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  color: #fffdfa;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.lookup-facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.lookup-facts div,
.premium-band-list li {
  border: 1px solid rgba(24, 51, 47, .1);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 253, 250, .72);
}

.lookup-facts dt {
  color: #6c7f79;
  font-size: 12px;
  font-weight: 900;
}

.lookup-facts dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-weight: 900;
}

.premium-band-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.premium-band-list span {
  display: block;
  color: #6b7f79;
  font-size: 12px;
  font-weight: 900;
}

.premium-band-list strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.lookup-card .form-actions {
  margin-top: 16px;
}

.lookup-help {
  margin-top: 14px;
  color: #4f665f;
  line-height: 1.65;
}

.lookup-help summary {
  cursor: pointer;
  font-weight: 900;
}

.lookup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.forecast-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 8px;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 12px 10px;
  background:
    linear-gradient(180deg, transparent 0 24%, rgba(24, 51, 47, .06) 24% 25%, transparent 25% 49%, rgba(24, 51, 47, .06) 49% 50%, transparent 50% 74%, rgba(24, 51, 47, .06) 74% 75%, transparent 75%),
    rgba(238, 244, 242, .64);
  overflow-x: auto;
}

.bar-wrap {
  min-width: 28px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  align-items: end;
}

.bar {
  width: 100%;
  min-height: 3px;
  height: var(--height);
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--teal), var(--blue));
}

.bar.over-budget {
  background: linear-gradient(180deg, var(--rose), var(--copper));
}

.bar-label {
  color: #64756f;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.forecast-table {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.forecast-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  color: #405a54;
  font-size: 13px;
}

.forecast-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(24, 51, 47, .08);
  overflow: hidden;
}

.forecast-fill {
  height: 100%;
  width: var(--width);
  background: var(--teal);
}

.forecast-fill.over-budget {
  background: var(--copper);
}

.panel {
  margin-top: 18px;
}

.policy-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed rgba(24, 51, 47, .22);
  border-radius: 8px;
  padding: 28px;
  color: #60736e;
  background: rgba(255, 255, 255, .44);
  line-height: 1.7;
}

.policy-card,
.catalog-card,
.recommend-card,
.replacement-box:not(:empty) {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .58);
}

.policy-card {
  min-width: 0;
  display: grid;
  gap: 13px;
  padding: 16px;
}

.policy-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.policy-card h3 {
  margin: 0;
  font: 800 19px/1.25 var(--serif);
}

.tag {
  width: fit-content;
  border-radius: 999px;
  padding: 6px 9px;
  color: #fffdfa;
  background: var(--blue);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.tag.medical { background: var(--teal); }
.tag.critical { background: var(--rose); }
.tag.life { background: var(--blue); }
.tag.accident { background: var(--gold); color: #2d2511; }
.tag.disability { background: #6e6aa8; }
.tag.longcare { background: #627a4d; }
.tag.savings { background: #7c6a56; }

.policy-card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.policy-card dt {
  color: #788884;
  font-size: 11px;
  font-weight: 900;
}

.policy-card dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-weight: 800;
}

.policy-note {
  margin: 0;
  color: #59706a;
  line-height: 1.6;
  font-size: 13px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-actions button {
  flex: 1;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, .72);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.card-actions button:hover {
  border-color: rgba(36, 95, 134, .42);
  color: var(--blue);
}

.analysis-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.score-panel {
  display: grid;
  align-content: start;
}

.score-ring {
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  margin: 8px auto 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 58%, transparent 59%),
    conic-gradient(var(--teal) var(--score-angle, 0deg), rgba(24, 51, 47, .1) 0);
}

.score-ring span {
  font: 900 42px/1 var(--serif);
}

.summary-text {
  margin: 0;
  color: #4e6761;
  line-height: 1.75;
}

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

.gap-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
}

.gap-name {
  color: var(--ink);
  font-weight: 900;
}

.gap-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(24, 51, 47, .09);
}

.gap-fill {
  height: 100%;
  width: var(--width);
  border-radius: inherit;
  background: var(--gap-color, var(--teal));
}

.gap-detail {
  min-width: 112px;
  color: #5f726d;
  font-size: 12px;
  text-align: right;
}

.cancer-layout {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.cancer-form {
  min-width: 0;
}

.cancer-result {
  display: grid;
  gap: 14px;
}

.underwriting-summary,
.insurance-option,
.restriction-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .58);
}

.underwriting-summary {
  padding: 16px;
}

.underwriting-summary h3 {
  margin: 0;
  font: 800 22px/1.2 var(--serif);
}

.underwriting-summary p {
  margin: 9px 0 0;
  color: #516a64;
  line-height: 1.65;
}

.insurable-list,
.restriction-list {
  display: grid;
  gap: 10px;
}

.insurance-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
}

.option-status {
  min-width: 88px;
  height: fit-content;
  border-radius: 999px;
  padding: 7px 9px;
  color: #fffdfa;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.option-status.good {
  background: var(--teal);
}

.option-status.review {
  background: var(--gold);
  color: #2d2511;
}

.option-status.hard {
  background: var(--rose);
}

.option-status.blocked {
  background: var(--danger);
}

.insurance-option h4,
.restriction-item h4 {
  margin: 0;
  font: 800 18px/1.25 var(--serif);
}

.insurance-option p,
.restriction-item p {
  margin: 6px 0 0;
  color: #526963;
  line-height: 1.6;
}

.restriction-item {
  padding: 14px;
  border-color: rgba(189, 104, 78, .24);
  background: rgba(189, 104, 78, .06);
}

.budget-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--blue);
  background: rgba(36, 95, 134, .08);
  font-size: 12px;
  font-weight: 900;
}

.replacement-box {
  margin-bottom: 14px;
  padding: 0;
}

.replacement-box:not(:empty) {
  padding: 14px;
  border-color: rgba(189, 104, 78, .3);
  background: rgba(189, 104, 78, .07);
}

.replacement-box h3,
.catalog-head h3 {
  margin: 4px 0 0;
  font: 800 22px/1.2 var(--serif);
}

.replacement-box p {
  margin: 8px 0 0;
  color: #5e4f4a;
  line-height: 1.65;
}

.recommendation-plan {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.recommend-card,
.catalog-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.recommend-card h3,
.catalog-card h4 {
  margin: 0;
  font: 800 20px/1.2 var(--serif);
}

.recommend-card p,
.catalog-card p {
  margin: 0;
  color: #516a64;
  line-height: 1.62;
}

.recommend-meta,
.catalog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border-radius: 999px;
  padding: 7px 9px;
  color: #31534d;
  background: rgba(63, 140, 131, .12);
  font-size: 12px;
  font-weight: 900;
}

.catalog-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.catalog-head small {
  max-width: 420px;
  color: #6b7f79;
  line-height: 1.5;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.catalog-card {
  align-content: start;
}

.heat {
  display: grid;
  gap: 7px;
}

.heat-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(24, 51, 47, .08);
}

.heat-fill {
  height: 100%;
  width: var(--width);
  background: linear-gradient(90deg, var(--gold), var(--copper));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  width: min(520px, calc(100% - 32px));
  transform: translate(-50%, 18px);
  border-radius: 8px;
  padding: 13px 16px;
  color: #fffdfa;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  text-align: center;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1080px) {
  .hero,
  .workbench,
  .analysis-grid,
  .cancer-layout {
    grid-template-columns: 1fr;
  }

  .metrics,
  .policy-list,
  .recommendation-plan,
  .lookup-facts {
    grid-template-columns: repeat(2, 1fr);
  }

  .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 720px) {
  main {
    width: calc(100% - 22px);
    padding-top: 14px;
  }

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

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .top-actions button {
    padding: 0 8px;
  }

  .hero-copy {
    min-height: auto;
    padding: 26px;
  }

  .hero-copy h1 {
    font-size: 36px;
  }

  .lede {
    font-size: 15px;
  }

  .profile-card,
  .panel {
    padding: 18px;
  }

  .profile-grid,
  .form-grid,
  .lookup-form,
  .lookup-facts,
  .metrics,
  .policy-list,
  .recommendation-plan,
  .premium-band-list,
  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .lookup-title {
    flex-direction: column;
  }

  .insurance-option {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .section-head,
  .catalog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions button,
  .section-head button,
  .section-head .link-button,
  .lookup-form .primary-button,
  .lookup-actions button {
    width: 100%;
  }

  .forecast-chart {
    min-height: 210px;
  }

  .gap-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .gap-detail {
    text-align: left;
  }
}
