:root {
  --background: #f6f7f4;
  --foreground: #16211a;
  --muted: #657064;
  --panel: #ffffff;
  --line: #dce3da;
  --green: #2f7d4a;
  --green-soft: #dff1e5;
  --red: #b9403c;
  --red-soft: #ffe3df;
  --blue: #305f9f;
  --blue-soft: #e3edfb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(47, 125, 74, 0.08), transparent 34rem),
    var(--background);
  color: var(--foreground);
  font-family: Arial, "Noto Sans TC", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 18px;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

button.secondary {
  background: #26352b;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--foreground);
  min-height: 40px;
  padding: 8px 10px;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 20px 0 24px;
}

.eyebrow {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 8px;
}

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

h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.02;
  margin-bottom: 14px;
}

h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.subtitle {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(100%, 390px);
}

.hero-actions span {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(22, 33, 26, 0.06);
}

.metrics article {
  min-height: 104px;
  padding: 18px;
}

.metrics span,
.check span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metrics strong {
  font-size: clamp(20px, 2.5vw, 29px);
  line-height: 1.1;
}

.panel {
  padding: 20px;
  margin-top: 14px;
}

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

.section-title p {
  color: var(--muted);
  line-height: 1.6;
  max-width: 560px;
  margin-bottom: 0;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check {
  border-radius: 6px;
  padding: 12px;
}

.check strong {
  font-size: 24px;
}

.check.ok,
.signal.hold {
  background: var(--green-soft);
  color: #205f38;
}

.check.warn,
.signal.sell {
  background: var(--red-soft);
  color: var(--red);
}

.signal.buy {
  background: var(--blue-soft);
  color: var(--blue);
}

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

.holding-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.holding-card > div {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
}

.holding-card strong {
  font-size: 21px;
}

.holding-card span {
  color: var(--muted);
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel .section-title {
  padding: 20px 20px 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

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

th {
  background: #eef4ed;
  color: #33463b;
  font-size: 13px;
}

th:first-child,
td:first-child {
  text-align: left;
}

td:first-child {
  display: grid;
  gap: 3px;
}

td:first-child span {
  color: var(--muted);
  font-size: 13px;
}

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

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

.cash-row {
  background: #faf8f1;
}

.beta-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.beta-panel p {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0;
}

.beta-panel .signal,
.metrics .signal {
  border-radius: 8px;
}

.beta-panel .signal {
  min-width: 180px;
  padding: 20px;
  text-align: center;
  font-size: 24px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 2px 0;
}

@media (max-width: 900px) {
  .hero,
  .section-title,
  .beta-panel,
  footer {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: start;
  }

  .hero-actions span {
    text-align: left;
  }

  .metrics,
  .input-grid,
  .holdings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 12px;
  }

  .metrics,
  .input-grid,
  .holdings,
  .holding-card {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .table-panel {
    padding: 0;
  }

  .table-panel .section-title {
    padding: 16px 16px 0;
  }

  button {
    width: 100%;
  }
}
