/* ============================================
   按鈕
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-full {
  width: 100%;
  margin-top: 8px;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* ============================================
   卡片
   ============================================ */

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 摘要卡片格狀排列 */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.summary-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-card .value {
  font-size: 20px;
  font-weight: 700;
}

.summary-card .change {
  font-size: 12px;
  margin-top: 2px;
}

.change-up   { color: var(--danger); }
.change-down { color: var(--success); }

/* ============================================
   表單
   ============================================ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  box-shadow: 0 0 0 3px rgba(200,135,74,0.15);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

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

.form-hint {
  font-size: 14px;
  color: var(--text-muted);
}

.form-hint strong {
  color: var(--text);
}

/* 金額輸入框（帶 $ 前綴）*/
.amount-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 14px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.amount-input {
  padding-left: 28px !important;
}

/* Modal 關閉按鈕 */
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   分類選擇格
   ============================================ */

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  gap: 3px;
  line-height: 1.2;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
  overflow: hidden;
}

.category-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* ============================================
   支出列表項目
   ============================================ */

.expense-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expense-item {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.expense-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.expense-info {
  flex: 1;
  min-width: 0;
}

.expense-note {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.expense-amount {
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.expense-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.action-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn.danger {
  color: var(--danger);
}

/* ============================================
   訂閱卡片
   ============================================ */

.subscription-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.sub-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sub-name {
  font-size: 16px;
  font-weight: 700;
}

.sub-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.sub-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sub-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ============================================
   標籤 Badge
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-muted   { background: var(--surface-2);     color: var(--text-muted); }
.badge-accent  { background: var(--accent-light);  color: var(--accent); }

/* ============================================
   債務卡片
   ============================================ */

.debt-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.debt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.debt-name {
  font-size: 16px;
  font-weight: 700;
}

.debt-balance {
  font-size: 20px;
  font-weight: 700;
  color: var(--danger);
}

.debt-info-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* 進度條 */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.5s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.debt-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================
   還款試算區塊
   ============================================ */

.payoff-calc {
  background: var(--accent-light);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
}

.payoff-calc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.payoff-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.payoff-input-row .form-input {
  flex: 1;
  height: 40px;
  font-size: 14px;
}

.payoff-result {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

/* ============================================
   Dashboard 區塊標題
   ============================================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  margin-top: 20px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

.section-link {
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* 即將到期訂閱列表 */
.upcoming-list {
  background: var(--surface);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.upcoming-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.upcoming-item:last-child {
  border-bottom: none;
}

.upcoming-name {
  font-size: 14px;
  font-weight: 500;
}

.upcoming-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.upcoming-amount {
  font-size: 15px;
  font-weight: 700;
}

/* ============================================
   圖表容器
   ============================================ */

.chart-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.chart-wrap {
  position: relative;
  height: 200px;
}

/* ============================================
   月份標題分隔線（支出列表）
   ============================================ */

.date-divider {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 4px 4px;
  margin-top: 4px;
}

/* ============================================
   還款紀錄時間軸
   ============================================ */

.payment-history {
  margin-top: 12px;
}

.payment-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.payment-item:last-child {
  border-bottom: none;
}

.payment-date {
  color: var(--text-muted);
  min-width: 80px;
}

.payment-amount {
  font-weight: 600;
  color: var(--success);
}

.payment-balance {
  margin-left: auto;
  color: var(--text-muted);
}
