* {
  box-sizing: border-box;
}

:root {
  --bg: #f6f2ec;
  --bg-soft: #fbf8f4;
  --card: rgba(255, 255, 255, 0.88);
  --card-border: rgba(120, 102, 82, 0.12);
  --text: #1f2937;
  --muted: #7b7280;
  --primary: #24364d;
  --primary-deep: #182536;
  --secondary: #efe7dc;
  --accent: #d8c28a;
  --accent-soft: #f4e8bd;
  --green-bg: #dff2e2;
  --green-text: #2f6b3d;
  --yellow-bg: #f8edb7;
  --yellow-text: #7a5a10;
  --red-bg: #f7d8d8;
  --red-text: #8b2f2f;
  --gray-bg: #e5e4e2;
  --gray-text: #4b5563;
  --shadow: 0 10px 30px rgba(80, 62, 41, 0.08);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, #fffaf2 0%, transparent 25%),
    radial-gradient(circle at top right, #f4efe7 0%, transparent 20%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", Arial, sans-serif;
}

.app {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.hero {
  background: linear-gradient(135deg, #22324a 0%, #344964 55%, #5b6675 100%);
  color: white;
  border-radius: 30px;
  padding: 28px 26px;
  margin-bottom: 18px;
  box-shadow: 0 18px 38px rgba(36, 54, 77, 0.22);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 140px;
  height: 140px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.08em;
  opacity: 0.82;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 900;
}

.hero p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 15px;
  line-height: 1.75;
  max-width: 560px;
}

.card,
.score-card,
.mini-card {
  background: var(--card);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  margin-bottom: 16px;
}

.section-title {
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 14px;
  color: #152233;
}

.label {
  display: block;
  font-weight: 800;
  margin-bottom: 10px;
  font-size: 15px;
  color: #253347;
}

.input,
.textarea,
.plan-input {
  width: 100%;
  border: 1px solid #d8d2cb;
  border-radius: 18px;
  padding: 15px 16px;
  font-size: 17px;
  background: #fffdfa;
  outline: none;
  color: var(--text);
  transition: all 0.2s ease;
}

.input:focus,
.textarea:focus,
.plan-input:focus {
  border-color: #bfa876;
  box-shadow: 0 0 0 4px rgba(216, 194, 138, 0.22);
}

.btn {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 15px 18px;
  margin-top: 14px;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: white;
  box-shadow: 0 10px 24px rgba(36, 54, 77, 0.18);
}

.btn.secondary {
  background: var(--secondary);
  color: #3f342c;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button-row .btn {
  margin-top: 16px;
}

.file-info {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.score-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.member-name {
  font-size: 26px;
  font-weight: 900;
  color: #162132;
}

.score-badge {
  min-width: 112px;
  min-height: 112px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #111827;
  font-weight: 900;
  border: 5px solid rgba(0, 0, 0, 0.06);
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.18);
}

.score-badge span {
  font-size: 36px;
  line-height: 1;
}

.score-badge small {
  margin-top: 8px;
  font-size: 15px;
}

.light-green {
  background: var(--green-bg);
}

.light-yellow {
  background: var(--yellow-bg);
}

.light-red {
  background: var(--red-bg);
}

.light-gray {
  background: var(--gray-bg);
}

.light-unknown {
  background: #eceae8;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.mini-card {
  margin-bottom: 0;
  padding: 16px;
}

.mini-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}

.mini-value {
  font-size: 22px;
  font-weight: 900;
  color: #162132;
}

.hint {
  margin: -2px 0 16px;
  color: #7f766b;
  font-size: 14px;
  line-height: 1.75;
}

.plan-list {
  display: grid;
  gap: 14px;
}

.plan-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 14px;
}

.plan-row label {
  font-weight: 900;
  color: #2f3c4e;
  font-size: 16px;
}

.half-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.half-item {
  background: #fcfaf7;
  border-radius: 16px;
  padding: 13px;
  border: 1px solid #ebe3d8;
}

.half-item span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.half-item strong {
  display: block;
  font-size: 18px;
  color: #152233;
}

.textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.7;
  font-size: 15px;
  background: #fffdfa;
}

.loading {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #24364d;
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  z-index: 20;
}

.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  background: #24364d;
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  z-index: 30;
  max-width: calc(100% - 32px);
  text-align: center;
}

.hidden {
  display: none !important;
}

/* 尚缺數值表格 */
.shortfall-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.shortfall-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fffdfa;
  border: 1px solid #e6ddd2;
  border-radius: 18px;
  overflow: hidden;
}

.shortfall-table th,
.shortfall-table td {
  border: 1px solid #eee5da;
  text-align: center;
  padding: 14px 10px;
  white-space: nowrap;
}

.shortfall-table thead th {
  background: #f6efe4;
  font-size: 15px;
  font-weight: 900;
  color: #1f2937;
}

.shortfall-table tbody td {
  font-size: 16px;
  font-weight: 800;
  color: #24364d;
}

.shortfall-row-title {
  background: #fbf6ef;
  font-weight: 900;
  color: #24364d;
}

.shortfall-cell {
  min-width: 88px;
}

/* 分數顏色 */
.score-green {
  color: var(--green-text);
  background: var(--green-bg);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

.score-yellow {
  color: var(--yellow-text);
  background: var(--yellow-bg);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

.score-red {
  color: var(--red-text);
  background: var(--red-bg);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

.score-gray,
.score-unknown {
  color: var(--gray-text);
  background: var(--gray-bg);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

/* 手機版 */
@media (max-width: 520px) {
  .app {
    padding: 14px 12px 44px;
  }

  .hero {
    padding: 24px 20px;
    border-radius: 24px;
  }

  h1 {
    font-size: 27px;
  }

  .score-card {
    align-items: stretch;
  }

  .score-badge {
    min-width: 96px;
    min-height: 96px;
  }

  .grid-3,
  .half-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

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

  .shortfall-table {
    min-width: 560px;
  }
}
