:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1f2733;
  --ink-soft: #687486;
  --line: #e6eaf0;
  --brand: #2f6fed;
  --brand-soft: #eaf1ff;
  --green: #1faa6b;
  --green-soft: #e6f7ef;
  --orange: #e8920c;
  --orange-soft: #fdf1dd;
  --blue: #2f6fed;
  --blue-soft: #eaf1ff;
  --red: #d8453a;
  --red-soft: #fbe9e7;
  --shadow: 0 2px 10px rgba(31,39,51,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
#app { min-height: 100%; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef3fd 0%, #f6f9ff 60%, #eafaf3 100%);
  padding: 20px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(31,39,51,.12);
  padding: 32px 28px;
}
.brand { text-align: center; margin-bottom: 22px; }
.logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, #2f6fed, #1faa6b);
  color: #fff; font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px; letter-spacing: 1px;
}
.logo.small { width: 34px; height: 34px; font-size: 13px; border-radius: 9px; margin: 0; }
.brand h1 { font-size: 20px; margin: 0 0 4px; }
.brand .sub { color: var(--ink-soft); margin: 0; font-size: 13px; }

#login-form label { display: block; margin-bottom: 14px; color: var(--ink-soft); font-size: 13px; }
#login-form input {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; font-size: 14px; color: var(--ink);
  outline: none; transition: border .15s;
}
#login-form input:focus { border-color: var(--brand); }
.btn-primary {
  width: 100%; padding: 11px; border: none; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  margin-top: 4px; transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.05); }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }

.demo-accounts { margin-top: 20px; border-top: 1px dashed var(--line); padding-top: 16px; }
.demo-title { color: var(--ink-soft); font-size: 12px; margin-bottom: 8px; }
.demo-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; }
.demo-row span { color: var(--ink-soft); }
.demo-row code { background: var(--brand-soft); color: var(--brand); padding: 2px 8px; border-radius: 6px; cursor: pointer; }

/* ---------- 主框架 ---------- */
.topbar {
  height: 58px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.app-name { font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.badge { background: var(--brand-soft); color: var(--brand); padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.user-name { color: var(--ink-soft); }
.btn-ghost { border: 1px solid var(--line); background: #fff; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }

.layout { display: flex; min-height: calc(100vh - 58px); }
.sidebar { width: 200px; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 9px;
  color: var(--ink-soft); cursor: pointer; margin-bottom: 4px; font-size: 14px;
}
.sidebar .nav-item:hover { background: var(--bg); }
.sidebar .nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.content { flex: 1; padding: 22px 26px; overflow: auto; }

/* ---------- 卡片/统计 ---------- */
.page-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--panel); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat-card .num { font-size: 28px; font-weight: 800; }
.stat-card .lbl { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.stat-card.orange .num { color: var(--orange); }
.stat-card.blue .num { color: var(--blue); }
.stat-card.green .num { color: var(--green); }

.panel { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 18px 20px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; color: var(--ink-soft); font-size: 13px; margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field textarea, .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  color: var(--ink); outline: none; font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { resize: vertical; min-height: 64px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn-sm { padding: 8px 16px; border: none; border-radius: 8px; background: var(--brand); color: #fff; cursor: pointer; font-size: 13px; }
.btn-sm.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-sm:disabled { opacity: .6; cursor: not-allowed; }

.file-pick { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; text-align: center; color: var(--ink-soft); cursor: pointer; }
.file-pick:hover { border-color: var(--brand); color: var(--brand); }
.preview-img { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; display: none; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.table th { color: var(--ink-soft); font-weight: 600; background: #fafbfd; }
.table tr:hover td { background: #fafbfd; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
.cell-strong { font-weight: 600; }
.muted { color: var(--ink-soft); }

.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status.pending { background: var(--orange-soft); color: var(--orange); }
.status.purchasing { background: var(--blue-soft); color: var(--blue); }
.status.completed { background: var(--green-soft); color: var(--green); }

.price { font-weight: 700; }
.price.sale { color: var(--green); }
.price.cost { color: var(--blue); }
.price.none { color: var(--ink-soft); font-weight: 400; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,28,40,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 480px; max-width: 92vw; max-height: 90vh; overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2733; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13px; margin-bottom: 18px; }
.flow .step { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.flow .arrow { color: var(--brand); font-weight: 700; }
