/* ===== 全局重置 ===== */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { font-size:16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: #f0f4f8;
  color: #333;
  padding-top: 52px;
  padding-bottom: 64px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
input, button, textarea { font-family: inherit; font-size: inherit; }

/* ===== 顶部栏 ===== */
.topbar {
  position: fixed; top:0; left:0; right:0; z-index:100;
  height: 52px;
  background: linear-gradient(135deg, #1f9bf0, #1485d4);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(31,155,240,.3);
}

/* ===== 主内容区 ===== */
#app { max-width: 600px; margin: 0 auto; padding: 12px; }
.page { display: none; }
.page.active { display: block; }

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-title {
  font-size: 16px; font-weight: 600; margin-bottom: 14px;
  color: #1485d4;
}

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 14px; font-weight: 500;
  margin-bottom: 6px; color: #555;
}
.required { color: #e74c3c; }
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="tel"] {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 16px; /* 16px 防止 iOS 缩放 */
  transition: border-color .2s;
  -webkit-appearance: none;
}
.form-group input:focus { border-color: #1f9bf0; outline: none; }

/* 图片上传区 */
.img-upload-area {
  position: relative;
  width: 100%; height: 160px;
  border: 2px dashed #b8d8f0;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  background: #eaf4fd;
}
.img-placeholder { text-align: center; color: #88aacc; }
.img-placeholder span { font-size: 36px; display: block; margin-bottom: 4px; }
.img-placeholder small { font-size: 12px; }
.img-preview { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.img-remove-btn {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  border: none; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* 单选组 */
.radio-group { display: flex; gap: 12px; }
.radio-item {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 16px; border: 1.5px solid #ddd; border-radius: 8px;
  cursor: pointer; font-size: 14px;
  transition: all .2s;
}
.radio-item:has(input:checked) {
  border-color: #1f9bf0; background: #eaf4fd; color: #1485d4;
}
.radio-item input { accent-color: #1f9bf0; }
.condition-note { margin-top: 8px; }

/* ===== 按钮 ===== */
.btn-primary, .btn-secondary, .btn-danger, .btn-text {
  border: none; border-radius: 8px; padding: 11px 20px;
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: opacity .2s;
}
.btn-primary { background: #1f9bf0; color: #fff; }
.btn-secondary { background: #e8e8e8; color: #555; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-text { background: transparent; color: #1f9bf0; font-size: 14px; padding: 4px 8px; }
.btn-primary:active, .btn-secondary:active, .btn-danger:active { opacity: .8; }
.btn-block { width: 100%; }

/* ===== 录入计数条 ===== */
.input-counter-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #eaf4fd; border-radius: 8px; padding: 10px 14px;
  margin-bottom: 12px; font-size: 14px; color: #1485d4;
}
.input-counter-bar strong { font-size: 18px; margin: 0 2px; }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.filter-btn {
  flex: 1; padding: 10px; border: 1.5px solid #ddd;
  background: #fff; border-radius: 8px; font-size: 14px;
  cursor: pointer; transition: all .2s; color: #666;
}
.filter-btn.active {
  border-color: #1f9bf0; background: #1f9bf0; color: #fff;
}

/* ===== 搜索栏 ===== */
.search-bar { margin-bottom: 12px; }
.search-bar input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 16px; /* 16px 防止 iOS 缩放 */
  background: #fff;
  transition: border-color .2s;
  -webkit-appearance: none;
}
.search-bar input:focus { border-color: #1f9bf0; outline: none; }

/* ===== 图片网格 ===== */
.img-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.grid-item {
  background: #fff; border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  position: relative; cursor: pointer;
  transition: transform .15s;
}
.grid-item:active { transform: scale(.97); }
.grid-item-img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  background: #eaf4fd; display: block;
}
.grid-item-img-placeholder {
  width: 100%; aspect-ratio: 3/4;
  background: #eaf4fd; display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #b0c4d8;
}
.grid-item-info { padding: 8px 10px; }
.grid-item-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grid-item-meta { font-size: 12px; color: #888; margin-top: 2px; }

/* 选中态（卖出页） */
.grid-item.selected {
  outline: 3px solid #1f9bf0; outline-offset: -3px;
}
.grid-item.selected::after {
  content: '✓'; position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #1f9bf0; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; z-index: 2;
}

/* 品相标签 */
.condition-badge {
  position: absolute; top: 6px; left: 6px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; color: #fff;
  z-index: 1; line-height: 1.4;
}
.condition-badge.mint { background: rgba(39,174,96,.88); }   /* 无损 绿 */
.condition-badge.damaged { background: rgba(230,126,34,.88); } /* 有损 橙 */

/* ===== 已售卡片 ===== */
.sold-card {
  background: #fff; border-radius: 10px; padding: 14px;
  margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sold-card-header { display: flex; justify-content: space-between; align-items: center; }
.sold-card-name { font-size: 15px; font-weight: 500; }
.sold-card-meta { font-size: 13px; color: #888; margin-top: 4px; }
.sold-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.sold-card-actions button {
  padding: 6px 14px; border: none; border-radius: 6px;
  font-size: 13px; cursor: pointer;
}
.btn-edit { background: #eaf4fd; color: #1485d4; }
.btn-delete { background: #fdeaea; color: #e74c3c; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center; padding: 40px 20px; color: #aaa;
}
.empty-state span { font-size: 40px; display: block; margin-bottom: 8px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ===== 自定义弹窗 ===== */
.modal-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(0,0,0,.45); z-index: 500;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px;
  padding: 24px 20px 16px;
  width: 100%; max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  animation: modalIn .2s ease;
}
.modal-box-lg { max-width: 460px; max-height: 80vh; overflow-y: auto; }
@keyframes modalIn { from { transform: scale(.9); opacity:0; } to { transform: scale(1); opacity:1; } }
.modal-text { font-size: 16px; line-height: 1.5; text-align: center; margin-bottom: 20px; color: #333; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; text-align: center; color: #1485d4; }
.modal-btns {
  display: flex; gap: 10px; justify-content: center;
}
.modal-btns button { min-width: 100px; }

/* ===== 卖出弹窗内容 ===== */
.sell-dialog-content { margin-bottom: 16px; }
.sell-dialog-item {
  background: #f8f9fa; border-radius: 8px; padding: 12px;
  margin-bottom: 10px;
}
.sell-dialog-item-name { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.sell-dialog-item-row { display: flex; gap: 8px; align-items: center; }
.sell-dialog-item-row label { font-size: 13px; color: #666; width: 70px; flex-shrink: 0; }
.sell-dialog-item-row input {
  flex: 1; padding: 8px 10px; border: 1.5px solid #ddd;
  border-radius: 6px; font-size: 15px;
}
.sell-dialog-item-row input:focus { border-color: #1f9bf0; outline: none; }

/* ===== 卖出页提交按钮 ===== */
.sell-submit-btn { position: sticky; bottom: 0; margin-top: 12px; }

/* ===== 记录页 ===== */
.record-card {
  background: #fff; border-radius: 10px; margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); overflow: hidden;
}
.record-header {
  padding: 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.record-date { font-size: 14px; font-weight: 500; }
.record-summary { font-size: 13px; color: #888; margin-top: 3px; }
.record-expand-icon { font-size: 12px; color: #aaa; transition: transform .2s; }
.record-card.expanded .record-expand-icon { transform: rotate(180deg); }
.record-detail {
  display: none; padding: 0 14px 14px;
  border-top: 1px solid #eee; margin-top: 0;
}
.record-card.expanded .record-detail { display: block; padding-top: 12px; }
.record-item-line {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 4px 0; color: #555;
}
.record-fee-group { margin-top: 10px; }
.record-fee-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.record-fee-row label { font-size: 13px; color: #666; width: 70px; flex-shrink: 0; }
.record-fee-row input {
  flex: 1; padding: 8px 10px; border: 1.5px solid #ddd;
  border-radius: 6px; font-size: 15px;
}
.record-fee-row input:focus { border-color: #1f9bf0; outline: none; }
.record-totals {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed #ddd;
}
.record-total-row {
  display: flex; justify-content: space-between;
  font-size: 14px; padding: 3px 0;
}
.record-confirm-btn { margin-top: 12px; }

/* ===== 盈亏上色 ===== */
.up { color: #e74c3c; font-weight: 600; }      /* 盈利 红 */
.neg { color: #27ae60; font-weight: 600; }     /* 亏损 绿 */

/* ===== 统计区 ===== */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: #fff; border-radius: 10px; padding: 16px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); text-align: center;
}
.stat-label { font-size: 12px; color: #999; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value.small { font-size: 17px; }

/* ===== 关于 ===== */
.about-section { text-align: center; padding: 20px; font-size: 13px; color: #aaa; }
.muted { font-size: 12px; color: #bbb; margin-top: 4px; }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: 64px; background: #fff;
  display: flex; box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  max-width: 600px; margin: 0 auto;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; color: #999;
  transition: color .2s;
}
.tab-item.active { color: #1f9bf0; }
.tab-icon { font-size: 20px; }
.tab-label { font-size: 11px; }

/* ===== 详情弹窗 ===== */
.detail-dialog { max-width: 380px; }
.detail-img { width: 100%; border-radius: 8px; margin-bottom: 12px; max-height: 280px; object-fit: cover; }
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; border-bottom: 1px solid #f0f0f0; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: #888; }
.detail-value { font-weight: 500; }
