:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6fa;
  --sidebar: #111827;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  min-width: 1100px;
}
a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
h1, h2, h3, h4, p { margin: 0; }
#app { min-height: 100vh; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 15% 10%, #1e40af 0%, transparent 60%), linear-gradient(135deg, #0f172a, #1e293b 70%);
}
.login-card {
  width: 400px;
  background: #fff;
  border-radius: 14px;
  padding: 38px 36px 32px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .45);
}
.login-card h1 { font-size: 22px; letter-spacing: .5px; }
.login-card .sub { color: var(--muted); font-size: 12px; margin: 8px 0 26px; letter-spacing: 1px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; height: 42px; margin-top: 8px; font-size: 15px; }
.login-tip { margin-top: 20px; font-size: 12px; color: var(--muted); line-height: 1.9; border-top: 1px dashed var(--line); padding-top: 14px; }
.login-brand { margin-top: 14px; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.8; }
.login-brand a { color: #64748b; text-decoration: none; }
.login-brand a:hover { color: var(--blue); }
.login-icp { margin-top: 4px; font-size: 12px; color: var(--muted); }
.login-icp a { color: #64748b; text-decoration: none; }
.login-icp a:hover { color: var(--blue); text-decoration: underline; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: 220px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.logo {
  padding: 20px 20px 18px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  border-bottom: 1px solid #1f2937;
}
.logo small { display: block; color: #64748b; font-size: 11px; font-weight: 400; letter-spacing: 2px; margin-top: 4px; }
.nav { flex: 1; overflow-y: auto; padding: 10px; }
.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: #cbd5e1;
  text-decoration: none;
  margin-bottom: 2px;
  transition: .15s;
}
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav .group { padding: 16px 12px 6px; color: #64748b; font-size: 11px; letter-spacing: 2px; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid #1f2937; color: #64748b; font-size: 11px; line-height: 1.8; }
.sidebar-foot a { color: #94a3b8; text-decoration: none; }
.sidebar-foot a:hover { color: #e2e8f0; }

.main { flex: 1; margin-left: 220px; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .crumb b { color: var(--ink); font-weight: 600; }
.topbar .who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #dbeafe; color: var(--blue-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.content { padding: 22px 24px 44px; }

/* ---------- 页头 / 卡片 ---------- */
.page-head { margin-bottom: 16px; }
.page-head h2 { font-size: 20px; }
.page-head .desc { color: var(--muted); font-size: 12px; margin-top: 5px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.card-head h3 { font-size: 15px; }
.card-body { padding: 16px; }
.section-title { font-size: 15px; margin: 22px 0 10px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); cursor: pointer;
  white-space: nowrap; transition: .15s;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--blue); padding: 0 6px; height: 26px; }
.btn.link.danger-text { color: var(--red); }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span2 { grid-column: span 2; }
.field label { font-size: 13px; color: #374151; font-weight: 600; }
.field .req { color: var(--red); }
.field .hint { font-size: 11px; color: var(--muted); }
.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: .15s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }
.input.num { text-align: right; }
.search { width: 220px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.toolbar .input { width: auto; }
.toolbar .search { width: 210px; }
.toolbar select.input { min-width: 128px; }
.filter-label { font-size: 12px; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  background: #f8fafc;
  color: #4b5563;
  font-weight: 600;
  font-size: 12px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.tbl tbody tr:hover { background: #fafcff; }
.tbl .empty { text-align: center; color: var(--muted); padding: 46px 0; }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; }
.green { color: var(--green); font-weight: 600; }
.red { color: var(--red); }
.up { color: var(--green); }
.down { color: var(--red); }
.thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); background: #f8fafc; display: block; }
.thumb-none { width: 38px; height: 38px; border-radius: 6px; border: 1px dashed #d1d5db; color: #9ca3af; font-size: 10px; display: flex; align-items: center; justify-content: center; background: #fafafa; }
.thumb-lg { width: 120px; height: 120px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #f8fafc; display: block; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; line-height: 18px; background: #f1f5f9; color: #475569; white-space: nowrap; }
.tag.ok { background: #dcfce7; color: #15803d; }
.tag.warn { background: #fef3c7; color: #b45309; }
.tag.danger { background: #fee2e2; color: #b91c1c; }
.tag.blue { background: #dbeafe; color: #1d4ed8; }
.tag.gray { background: #f1f5f9; color: #64748b; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 16px; color: var(--muted); font-size: 12px; }
.pager .btn { height: 28px; padding: 0 10px; }

/* ---------- 统计卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 8px; letter-spacing: .3px; }
.stat .foot { color: var(--muted); font-size: 12px; margin-top: 6px; }
.stat .value.blue { color: var(--blue); }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 20px; overflow: auto;
}
.modal { background: #fff; border-radius: 10px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); max-width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-head .x { border: none; background: none; font-size: 22px; line-height: 1; color: #9ca3af; cursor: pointer; padding: 0 2px; }
.modal-head .x:hover { color: var(--ink); }
.modal-body { padding: 18px; max-height: 68vh; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.confirm { line-height: 1.7; padding: 4px 2px; }

/* ---------- 提示 ---------- */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  min-width: 200px; max-width: 520px;
  padding: 9px 16px; border-radius: 6px;
  background: #111827; color: #fff; font-size: 13px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .25);
  transition: .3s; text-align: center;
}
.toast.err { background: #b91c1c; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------- 明细编辑器 ---------- */
.items-editor { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.items-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; background: #f8fafc; border-bottom: 1px solid var(--line); font-weight: 600; }
.items-editor .tbl td { padding: 7px 8px; }
.items-editor .tbl th { padding: 8px; }
.items-editor .tbl select { min-width: 230px; }
.items-editor .tbl .input { height: 30px; }
.items-editor .tbl .num { width: 90px; }
.items-total { padding: 11px 14px; text-align: right; border-top: 1px solid var(--line); background: #f8fafc; }
.items-total b { color: var(--red); font-size: 17px; margin-left: 4px; }
.pay-summary { margin-top: 12px; padding: 10px 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; color: #4b5563; }
.pay-summary b { color: var(--ink); margin: 0 3px; }

/* ---------- 详情 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px; padding: 4px 0 16px; }
.detail-grid .item .k { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.detail-grid .item .v { font-weight: 600; word-break: break-all; }

/* ---------- 图片上传 ---------- */
.image-field { display: flex; align-items: center; gap: 12px; }
.image-ops { display: flex; gap: 6px; }

/* ---------- 空状态 ---------- */
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin-bottom: 8px; }

/* ---------- 登录页字段修正 ---------- */
.login-card .input { height: 40px; }
.login-card .field label { font-weight: 500; color: #4b5563; }

/* ---------- 概览页 ---------- */
.list-line { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.list-line:last-child { border-bottom: none; }
.list-line .name { font-weight: 500; }
.list-line .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.list-line .val { font-weight: 600; }
