:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #172124;
  --muted: #607079;
  --line: #d9e0dd;
  --brand: #1f5f74;
  --accent: #1b7f6e;
  --amber: #a66216;
  --danger: #9c2f2f;
  --soft: #eef5f2;
  --shadow: 0 18px 45px rgba(27, 47, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.brand p,
.brand h1,
.notes h2,
.notes p {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.2;
}

.tagline {
  color: var(--brand);
  font-weight: 700;
  white-space: nowrap;
}

main {
  padding: 22px 28px 36px;
}

.controls,
.summary,
.notes {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

label span,
.summary span {
  color: var(--muted);
  font-size: 13px;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

select:disabled {
  color: var(--muted);
  background: #f2f4f3;
}

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

.summary div {
  padding: 14px 16px;
  background: #fbfcfb;
}

.summary strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.recommendation {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(300px, 1.05fr);
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.recommendation-copy,
.recommendation-metrics,
.recommendation-reasons {
  background: var(--panel);
  padding: 16px;
}

.recommendation-copy span,
.recommendation-metrics span {
  color: var(--muted);
  font-size: 13px;
}

.recommendation-copy h2,
.recommendation-reasons h3 {
  margin: 4px 0 0;
}

.recommendation-copy h2 {
  color: var(--brand);
  font-size: 22px;
  line-height: 1.25;
}

.recommendation-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.recommendation-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.recommendation-metrics div {
  min-width: 0;
}

.recommendation-metrics strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.recommendation-reasons {
  grid-column: 1 / -1;
}

.recommendation-reasons h3 {
  color: var(--ink);
  font-size: 16px;
}

.recommendation-reasons ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 10px 0 0;
  padding-left: 18px;
}

.recommendation-reasons li {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.table-area {
  margin-top: 18px;
}

.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.table-toolbar span {
  color: var(--muted);
  font-size: 13px;
}

.table-toolbar h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
}

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

.table-actions button {
  min-height: 38px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--brand);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.table-actions button:hover,
.table-actions button:focus-visible {
  background: #16495a;
  border-color: #16495a;
  outline: none;
}

.table-actions button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.table-scroll {
  max-height: calc(100vh - 280px);
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  padding: 12px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
  line-height: 1.45;
  background: #fff;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #eaf2ef;
  color: #18353b;
  text-align: left;
  font-size: 13px;
}

.product-col {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  background: #f8fbfa;
}

th.product-col {
  z-index: 6;
  background: #dfece8;
}

tr.is-recommended td,
tr.is-recommended th.product-col {
  background: #f4f8ed;
}

.company {
  color: var(--brand);
  font-weight: 800;
  font-size: 15px;
}

.product {
  margin-top: 4px;
  font-weight: 700;
}

.source {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.money {
  display: inline-block;
  color: #0f5d50;
  font-weight: 800;
}

.premium {
  color: var(--amber);
  font-weight: 800;
}

.terms-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.terms-link:hover,
.terms-link:focus-visible {
  background: var(--brand);
  color: #ffffff;
  outline: none;
}

.missing {
  color: var(--danger);
  font-weight: 900;
  font-size: 18px;
}

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

.note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.warning {
  color: var(--danger);
  font-weight: 700;
}

.notes {
  margin-top: 18px;
  padding: 16px;
}

.notes h2 {
  font-size: 17px;
  margin-bottom: 8px;
}

.notes p + p {
  margin-top: 8px;
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tagline {
    white-space: normal;
  }

  main {
    padding: 16px;
  }

  .controls,
  .summary,
  .recommendation,
  .recommendation-metrics,
  .recommendation-reasons ul {
    grid-template-columns: 1fr;
  }

  .recommendation-reasons {
    grid-column: auto;
  }

  .table-scroll {
    max-height: none;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions {
    justify-content: flex-start;
  }
}
