/* ============================================================
   估值表 — 公共样式 (V7.37)
   所有页面共享的基础样式，每个页面通过 <link> 引入
   ============================================================ */

/* ── 基础重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 全局变量 ── */
:root {
  --font-stack: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --bg: #f5f6f8;
  --card-bg: #fff;
  --text: #333;
  --text-secondary: #888;
  --text-heading: #222;
  --border: #efeff0;
  --border-light: #e5e7eb;
  --green: #22c55e;
  --green-hover: #16a34a;
  --red: #ef4444;
  --red-hover: #dc2626;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.06);
  --transition: all .15s ease;
}

/* ── 文档基础 ── */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

/* ── 页面头部（基础骨架，各页面自行扩展布局） ── */
.page-header {
  background: var(--card-bg);
  padding: 14px 16px 10px;
  border-radius: var(--radius);
  max-width: 600px;
  margin: 10px auto 0;
}

.page-header h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-heading);
}

.header-actions { display: flex; gap: 8px; }

/* ── 按钮基础 ── */
.btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  font-family: inherit;
}

.btn:active { transform: scale(.97); }

.btn-back {
  background: var(--green);
  color: #fff;
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

.btn-back:hover { background: var(--green-hover); }

.btn-save { background: var(--blue); color: #fff; }
.btn-save:hover { background: var(--blue-hover); }
.btn-save:disabled { background: #a3a3a3; cursor: not-allowed; }

.btn-add {
  background: var(--red);
  color: #fff;
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

.btn-add:hover { background: var(--red-hover); }

.btn-del { background: var(--red); color: #fff; }
.btn-del:hover { background: var(--red-hover); }

.btn-cancel { background: #e5e5e5; color: #555; }
.btn-cancel:hover { background: #d4d4d4; }

/* ── 容器 ── */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 0;
}

/* ── 分组标题 ── */
.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.group-header:first-child { padding-top: 0; }
.group-header .group-name { text-transform: uppercase; letter-spacing: .5px; }
.group-header .group-count { font-weight: 400; color: #bbb; margin-left: 4px; }

/* ── Toast 通知 ── */
#toastContainer {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  animation: toastIn .25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  pointer-events: auto;
}

.toast-ok  { background: var(--green); }
.toast-err { background: var(--red); }
.toast-warn { background: #f59e0b; }

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

/* ── 通用弹窗 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--card-bg);
  border-radius: 14px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h4 { font-size: 15px; font-weight: 600; }

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: #f5f5f5;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: #e8e8e8; color: #555; }

.modal-body { padding: 18px; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid #f0f0f0;
}

/* ── 通用工具类 ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-secondary); }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

/* ── 移动端响应式 ── */
@media (max-width: 480px) {
  /* 手机端按钮大小与 V7.37 保持一致 */
  .btn, button {
    padding: 7px 16px;
    font-size: 12.5px;
  }

  .btn-back, .btn-add {
    padding: 6px 16px;
    font-size: 13px;
  }

  /* 页面头部在窄屏优化 */
  .page-header {
    padding: 12px 12px 8px;
    margin: 6px 6px 0;
    border-radius: 6px;
  }

  .page-header h1 {
    font-size: 15px;
  }

  .container {
    padding: 8px 0;
  }

  /* 表格/网格在窄屏降为一列卡片 */
  .fund-item, .fund-row {
    padding: 10px 12px;
  }

  /* 弹窗在窄屏全宽 */
  .modal-box {
    width: 95%;
    max-width: none;
    border-radius: 12px 12px 0 0;
    align-self: flex-end;
  }

  /* Toast 在顶部不溢出 */
  .toast {
    max-width: 90vw;
    white-space: normal;
    text-align: center;
  }
}
