:root {
  --brand: #ee929c;
  --brand-dark: #dc7481;
  --brand-soft: rgba(238, 146, 156, .1);
  --brand-border: rgba(238, 146, 156, .22);
  --text: #1f2937;
  --muted: #64748b;
  --light: #f8fafc;
  --border: #eef2f7;
  --white: #fff;
  --shadow: 0 20px 45px rgba(148, 163, 184, .22);
  --radius-xl: 24px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Noto Sans TC', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--light);
}
button, select { font: inherit; }
button { cursor: pointer; }

.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .95);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(15, 23, 42, .04);
  backdrop-filter: blur(10px);
}
.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 12px 20px rgba(238, 146, 156, .35);
}
.brand h1 { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 900; letter-spacing: -.02em; }
.brand p { margin: 3px 0 0; color: var(--brand); font-size: 10px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.guide-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid rgba(238, 146, 156, .25);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
  transition: .2s;
}
.guide-link:hover { transform: translateY(-1px); background: rgba(238, 146, 156, .16); }
.guide-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.layout {
  max-width: 1180px;
  margin: 32px auto 0;
  padding: 0 16px 48px;
  display: grid;
  grid-template-columns: minmax(320px, 5fr) minmax(0, 7fr);
  gap: 32px;
}
.form-card, .result-card, .history-card, .footer {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.form-card { padding: 32px; height: fit-content; }
.content-col { display: flex; flex-direction: column; gap: 28px; }
.card-body { padding: 32px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.section-title span { width: 6px; height: 26px; border-radius: 999px; background: var(--brand); }
h2, h3 { margin: 0; font-weight: 900; letter-spacing: -.02em; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }

.field-group, .date-picker { margin-bottom: 22px; }
.field-label, .date-label {
  display: block;
  margin: 0 0 10px 4px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 900;
}
.date-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 42px 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  color: #374151;
  background: #fff;
  appearance: none;
  outline: none;
  transition: .2s;
  font-weight: 700;
}
select:hover, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(238, 146, 156, .12); }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.seg-btn, .stage-btn {
  border: 2px solid #f1f5f9;
  background: #fff;
  color: #94a3b8;
  font-weight: 900;
  transition: .2s;
}
.seg-btn { padding: 14px 12px; border-radius: 14px; }
.seg-btn.is-active, .stage-btn.is-active {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
}
.stage-list { display: flex; flex-direction: column; gap: 10px; }
.stage-btn {
  width: 100%;
  padding: 16px 18px;
  border-radius: 18px;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
}
.stage-btn.is-active { color: #fff; background: var(--brand); border-color: var(--brand); }
.divider { height: 1px; background: #f1f5f9; margin: 30px 0; }
.calculate-btn {
  width: 100%;
  margin-top: 16px;
  padding: 18px 20px;
  border: 0;
  border-radius: 20px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 14px 26px rgba(238, 146, 156, .35);
  font-size: 20px;
  font-weight: 900;
  transition: .2s;
}
.calculate-btn:hover { background: var(--brand-dark); transform: translateY(-1px); }
.calculate-btn:active { transform: scale(.985); }

.empty-result {
  min-height: 270px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #94a3b8;
  font-weight: 900;
  line-height: 1.8;
  opacity: .72;
}
.result-note {
  display: flex;
  gap: 16px;
  padding: 22px;
  margin-top: 24px;
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  background: var(--brand-soft);
}
.result-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(238, 146, 156, .15);
  font-size: 24px;
}
.result-note strong { display: block; margin-bottom: 8px; color: var(--brand); font-size: 18px; font-weight: 900; }
.result-note p { margin: 4px 0; color: var(--brand); font-size: 14px; font-weight: 800; line-height: 1.6; }
.badge-inline { display: inline-block; padding: 2px 8px; border-radius: 7px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.table-scroll { margin-top: 24px; overflow-x: auto; border: 1px solid #f1f5f9; border-radius: 16px; }
table { width: 100%; min-width: 600px; border-collapse: collapse; text-align: left; }
th { padding: 15px; background: #f8f9fa; color: #4b5563; font-size: 14px; font-weight: 900; }
td { padding: 22px 15px; border-top: 1px solid #f1f5f9; vertical-align: middle; }
.text-center { text-align: center; }
.scheme-name { margin: 0; color: var(--brand); font-weight: 900; }
.scheme-sub { margin: 2px 0 0; color: #94a3b8; font-size: 12px; }
.amount { color: var(--brand); font-size: 26px; font-weight: 900; }
.unit { color: #94a3b8; font-size: 12px; }
.status-pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}
.muted-row .scheme-name, .muted-row .amount, .muted-row .limit-text { color: #cbd5e1; }
.muted-row .status-pill { background: transparent; color: #cbd5e1; }
.final-box {
  margin-top: 32px;
  padding: 28px;
  border: 2px solid rgba(238, 146, 156, .32);
  border-radius: 26px;
  background: var(--brand-soft);
  text-align: center;
  box-shadow: inset 0 2px 12px rgba(238, 146, 156, .08);
  animation: softPulse 3s ease-in-out infinite;
}
.final-box p { margin: 0; color: var(--brand); font-weight: 900; }
.final-price { margin: 8px 0; color: var(--brand); font-size: 50px; font-weight: 900; letter-spacing: -.04em; }
.final-price span { font-size: 24px; margin-right: 4px; }
.final-hint { font-size: 12px; opacity: .78; }

.history-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
#clearHistoryBtn { border: 0; background: transparent; color: #94a3b8; font-size: 12px; font-weight: 900; }
#clearHistoryBtn:hover { color: #e11d48; }
.history-list { max-height: 400px; overflow-y: auto; padding-right: 6px; display: flex; flex-direction: column; gap: 12px; }
.history-item {
  width: 100%;
  padding: 16px;
  border: 2px solid #f8fafc;
  border-radius: 18px;
  background: rgba(248, 250, 252, .45);
  text-align: left;
  transition: .2s;
}
.history-item:hover { background: #fff; border-color: rgba(238, 146, 156, .3); box-shadow: 0 10px 24px rgba(148, 163, 184, .16); }
.history-main { display: flex; justify-content: space-between; gap: 16px; }
.history-time { color: #94a3b8; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.history-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.history-count { color: #374151; font-size: 14px; font-weight: 900; }
.history-stage { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 8px; border: 1px solid #eef2f7; border-radius: 999px; background: #fff; color: #64748b; font-size: 10px; }
.history-money { margin: 0; color: var(--brand); font-size: 18px; font-weight: 900; text-align: right; }
.history-scheme { display: inline-block; padding: 2px 7px; border-radius: 7px; color: #059669; background: #ecfdf5; font-size: 9px; font-weight: 900; }
.history-scheme.old { color: #d97706; background: #fffbeb; }
.history-load { margin-top: 8px; color: var(--brand); font-size: 10px; font-weight: 900; opacity: 0; transition: .2s; }
.history-item:hover .history-load { opacity: 1; }
.empty-history { padding: 46px 16px; border: 2px dashed #eef2f7; border-radius: 18px; background: rgba(248, 250, 252, .55); text-align: center; }
.empty-history strong { display: block; color: #94a3b8; font-size: 14px; }
.empty-history span { display: block; margin-top: 4px; color: #cbd5e1; font-size: 10px; }
.footer { padding: 34px 20px; text-align: center; box-shadow: none; }
.footer p { margin: 0; color: #64748b; font-size: 14px; font-weight: 800; }
.footer .copyright { margin-bottom: 12px; color: #94a3b8; font-size: 12px; font-weight: 900; letter-spacing: .18em; }

.history-list::-webkit-scrollbar, .table-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
.history-list::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
.history-list::-webkit-scrollbar-track, .table-scroll::-webkit-scrollbar-track { background: transparent; }

@keyframes softPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.01); }
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-inner { align-items: flex-start; }
  .brand h1 { font-size: 17px; }
  .guide-link { display: none; }
  .layout { margin-top: 20px; gap: 22px; }
  .form-card, .card-body { padding: 22px; }
  .date-row { grid-template-columns: 1.2fr 1fr 1fr; gap: 6px; }
  select { padding-left: 10px; font-size: 14px; }
  .final-price { font-size: 40px; }
  .result-note { padding: 18px; }
}
