* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 50%, #e0f2f1 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.container {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 40px 36px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

h1 {
  font-size: 26px;
  font-weight: 600;
  color: #2e7d5e;
  text-align: center;
  margin-bottom: 4px;
}

.subtitle {
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 28px;
}

/* ---- entry row ---- */
.entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.entry-row input {
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.entry-row input:focus {
  border-color: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.entry-row .input-name {
  flex: 1;
  min-width: 0;
}

.entry-row .input-amount {
  width: 120px;
  flex-shrink: 0;
}

.entry-row .btn-delete {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #fee2e2;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.entry-row .btn-delete:hover {
  background: #fecaca;
  transform: scale(1.05);
}

/* ---- buttons ---- */
.btn-add {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  background: transparent;
  color: #64748b;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  margin-bottom: 16px;
}

.btn-add:hover {
  border-color: #4ade80;
  color: #2e7d5e;
  background: #f0fdf4;
}

.btn-confirm {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #4ade80, #2dd4bf);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(74, 222, 128, 0.3);
}

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

.btn-confirm:active {
  transform: translateY(0);
}

/* ---- results ---- */
.results {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1.5px solid #e2e8f0;
}

.results[hidden] {
  display: none;
}

.results h2 {
  font-size: 18px;
  font-weight: 600;
  color: #2e7d5e;
  margin-bottom: 14px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 15px;
}

.result-item.receive {
  background: #f0fdf4;
  color: #166534;
}

.result-item.pay {
  background: #fff7ed;
  color: #9a3412;
}

.result-item.balanced {
  background: #f8fafc;
  color: #64748b;
}

.result-item .amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- transfer details ---- */
.transfer-section {
  margin-top: 20px;
}

.transfer-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 10px;
}

.transfer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 10px;
  background: #f8fafc;
  margin-bottom: 6px;
  font-size: 14px;
  color: #334155;
}

.transfer-item .arrow {
  color: #94a3b8;
  font-size: 16px;
}

.transfer-item .transfer-amount {
  margin-left: auto;
  font-weight: 600;
  color: #2e7d5e;
  font-variant-numeric: tabular-nums;
}

/* ============ mobile ============ */

/* 小手机 ( < 400px ) 让每行换行列布局 */
@media (max-width: 400px) {
  body {
    padding: 16px 12px;
  }

  .container {
    padding: 24px 16px;
    border-radius: 18px;
  }

  h1 {
    font-size: 22px;
  }

  .entry-row {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
  }

  .entry-row .input-name {
    flex: 1 1 calc(100% - 46px);  /* 留出删除按钮位置 */
    min-width: 0;
  }

  .entry-row .input-amount {
    width: 100%;
  }

  .entry-row .btn-delete {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .entry-row input {
    padding: 12px 14px;
    font-size: 16px;  /* 防止 iOS 自动缩放 */
  }

  .btn-add,
  .btn-confirm {
    padding: 14px;
    font-size: 16px;
  }

  .btn-confirm {
    padding: 16px;
  }

  .result-item {
    padding: 12px 14px;
    font-size: 14px;
  }

  .transfer-item {
    padding: 10px 14px;
    font-size: 13px;
  }

  .results h2 {
    font-size: 16px;
  }
}

/* 小平板 ~ 手机横屏 */
@media (min-width: 401px) and (max-width: 640px) {
  body {
    padding: 24px 16px;
  }

  .container {
    padding: 28px 20px;
  }

  .entry-row input {
    font-size: 16px;  /* 防止 iOS 自动缩放 */
  }

  .entry-row .input-amount {
    width: 110px;
  }

  .btn-confirm {
    padding: 15px;
  }
}

/* 触摸设备去掉 hover（避免点击后 stuck） */
@media (hover: none) {
  .entry-row .btn-delete:hover {
    background: #fee2e2;
    transform: none;
  }

  .btn-add:hover {
    border-color: #cbd5e1;
    color: #64748b;
    background: transparent;
  }

  .btn-confirm:hover {
    opacity: 1;
    transform: none;
  }
}

/* ---- error ---- */
.error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 14px;
  text-align: center;
}
