:root {
  --yc-yellow: #FED100;
  --yc-red: #B91C1C;
  --yc-red-dark: #991B1B;
  --bg-page: #F3F4F6;
  --text-main: #111827;
  --text-muted: #6B7280;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "Segoe UI", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  padding-bottom: 84px;
}

/* 頂部品牌列 */
.app-header {
  background-color: var(--yc-yellow);
  border-bottom: 1px solid #EAB308;
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 12px 16px;
}
.header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-badge {
  background-color: var(--yc-red);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
}
.header-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}
.header-sub {
  font-size: 11px;
  color: #374151;
  margin: 2px 0 0;
}
.env-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 99px;
  background: #1F2937;
  color: #fff;
  font-weight: 700;
}
.env-badge.is-line {
  background: #16A34A;
}

/* 主容器與卡片 */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #F3F4F6;
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.card-title::before {
  content: "";
  width: 4px;
  height: 15px;
  background: var(--yc-red);
  border-radius: 4px;
  display: inline-block;
}

/* 置頂雙核心結果卡片 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.kpi-card {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  border-top: 4px solid var(--yc-red);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
/* 淡藍色實拿卡片 */
.kpi-card.soft-blue {
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  color: #1E3A8A;
  border-top: 4px solid #2563EB;
  border-left: 1px solid #BFDBFE;
  border-right: 1px solid #BFDBFE;
  border-bottom: 1px solid #BFDBFE;
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kpi-card.soft-blue .kpi-label {
  color: #1E40AF;
}
.kpi-badge-blue {
  background: #BFDBFE;
  color: #1D4ED8;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 800;
}
.kpi-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--yc-red);
  margin: 4px 0;
}
.kpi-card.soft-blue .kpi-value {
  color: #1D4ED8;
}
.kpi-sub {
  font-size: 11px;
  color: #9CA3AF;
  margin: 0;
}
.kpi-card.soft-blue .kpi-sub {
  color: #3B82F6;
  font-weight: 700;
}

/* 可下拉展開的精算明細手風琴 */
.detail-drawer {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #DBEAFE;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.06);
  overflow: hidden;
}
.detail-toggle-btn {
  width: 100%;
  background: #F8FAFC;
  border: none;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #1E40AF;
  cursor: pointer;
}
.detail-toggle-btn:active {
  background: #EFF6FF;
}
.detail-arrow {
  transition: transform 0.2s ease;
  font-size: 11px;
}
.detail-arrow.open {
  transform: rotate(180deg);
}
.detail-body {
  padding: 12px 14px;
  border-top: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
}
.detail-group-title {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  background: #F1F5F9;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 4px;
  color: #4B5563;
}
.detail-row.total {
  border-top: 1px dashed #CBD5E1;
  margin-top: 4px;
  padding-top: 6px;
  font-weight: 800;
  color: #111827;
}
.detail-row.tax-highlight {
  color: #B91C1C;
  font-weight: 800;
}
.detail-row.cash-highlight {
  color: #1D4ED8;
  font-weight: 800;
}

/* 表單控制項 */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-label {
  font-size: 11px;
  font-weight: 700;
  color: #4B5563;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.input-box, .select-box {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  background: #F9FAFB;
  border: 1px solid #D1D5DB;
  border-radius: 10px;
  color: var(--text-main);
  outline: none;
}
.input-box:focus, .select-box:focus {
  border-color: var(--yc-red);
  background: #fff;
}
.input-highlight {
  background: #FEF2F2;
  border-color: #FECACA;
  color: var(--yc-red);
}

/* 貸款與違約金專屬區塊 */
.loan-panel {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}
.btn-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #D1D5DB;
  background: #fff;
  color: #374151;
  cursor: pointer;
}
.btn-chip.active, .btn-chip:active {
  background: var(--yc-red);
  color: #fff;
  border-color: var(--yc-red);
}
.hint-bar {
  font-size: 11px;
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
  padding: 8px 10px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.auto-hint {
  font-size: 11px;
  color: #2563EB;
  font-weight: 600;
  margin-top: 6px;
}
.hidden {
  display: none !important;
}

/* 底部固定操作列 */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #E5E7EB;
  padding: 10px 14px;
  z-index: 40;
}
.bottom-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
}
.btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #D1D5DB;
  background: #F3F4F6;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.btn-primary {
  flex: 1.6;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--yc-red);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
}
