:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --gray-tag: #f3f4f6;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--primary); text-decoration: none; }
ul { list-style: none; }

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(135deg, #eff6ff 0%, #f5f6f8 60%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px 28px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }
.quick-login { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.quick-login .lb { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-grid button {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-size: 12.5px; background: #fafbfc; transition: .15s;
}
.quick-grid button:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ============ 布局 ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.sidebar .brand strong { font-size: 15px; font-weight: 600; display: block; }
.sidebar .brand span { font-size: 11.5px; color: var(--text-3); }
.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar nav .group-lb { font-size: 11px; color: var(--text-3); padding: 10px 10px 6px; letter-spacing: .5px; }
.sidebar nav button {
  display: block; width: 100%; text-align: left; padding: 9px 10px;
  border-radius: 8px; font-size: 13.5px; color: var(--text-2); margin-bottom: 2px;
}
.sidebar nav button:hover { background: #f3f4f6; color: var(--text); }
.sidebar nav button.on { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.sidebar nav button .dot {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  background: var(--red); color: #fff; border-radius: 9px; font-size: 11px;
  padding: 0 5px; float: right; margin-top: 3px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.role-switch {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; background: #fafbfc;
}
.role-switch select { border: none; background: none; font-size: 12.5px; outline: none; }
.user-chip { font-size: 12.5px; color: var(--text-2); }

.content { padding: 20px; flex: 1; }

/* ============ 组件 ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-hd { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-hd h2 { font-size: 14.5px; font-weight: 600; }
.card-hd .desc { font-size: 12px; color: var(--text-3); }
.card-bd { padding: 16px; }

.page-head { margin-bottom: 16px; display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; font-weight: 600; }
.page-head p { font-size: 12.5px; color: var(--text-2); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .lb { font-size: 12px; color: var(--text-2); }
.stat .val { font-size: 24px; font-weight: 600; margin-top: 2px; letter-spacing: -.5px; }
.stat.warn .val { color: var(--amber); }
.stat.danger .val { color: var(--red); }
.stat.ok .val { color: var(--green); }

.remind {
  background: var(--amber-soft); border: 1px solid #fde68a; color: #92400e;
  border-radius: var(--radius); padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.remind .s { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: 0 0 auto; }
.remind b { font-weight: 600; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; font-weight: 500; }
.field label .req { color: var(--red); }
.field label .hint { font-weight: 400; color: var(--text-3); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; background: #fff; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.row-inline { display: flex; gap: 10px; }
.row-inline > * { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; background: var(--primary); color: #fff;
  transition: .15s; border: 1px solid transparent;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn.ghost:hover { background: #f9fafb; border-color: var(--text-3); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.tag.pending-take { background: var(--gray-tag); color: #4b5563; }
.tag.in-progress { background: #dbeafe; color: #1e40af; }
.tag.half { background: #fef3c7; color: #92400e; }
.tag.wait-review { background: var(--purple-soft); color: var(--purple); }
.tag.completed { background: var(--green-soft); color: #15803d; }
.tag.returned { background: var(--red-soft); color: #b91c1c; }
.tag.pending { background: var(--gray-tag); color: #4b5563; }
.tag.qualified { background: var(--green-soft); color: #15803d; }
.tag.rejected { background: var(--red-soft); color: #b91c1c; }
.tag.settled { background: var(--green-soft); color: #15803d; }
.tag.unsettled { background: var(--gray-tag); color: #4b5563; }
.tag.role { background: var(--primary-soft); color: var(--primary); }
.tag.warn { background: var(--red-soft); color: #b91c1c; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #fafbfc; font-weight: 500; color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
tbody tr.sel { background: var(--primary-soft); }
td.nowrap { white-space: nowrap; }
td .money { font-weight: 600; }
.checkbox-cell { width: 40px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
td .muted { color: var(--text-3); font-size: 12px; }
.link-btn { color: var(--primary); font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.disabled { color: var(--text-3); cursor: not-allowed; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 130px; }
.filters .field label { font-size: 12px; color: var(--text-2); font-weight: 400; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border-strong);
  font-size: 12.5px; background: #fff; color: var(--text-2);
}
.chip:hover { border-color: var(--text-3); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .ico {
  width: 52px; height: 52px; border-radius: 50%; background: #f3f4f6;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
  font-size: 22px; color: var(--text-3);
}
.empty h3 { font-size: 14px; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }
.empty p { font-size: 12.5px; }

.upload-box {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 22px; text-align: center; background: #fafbfc;
}
.upload-box .plus { font-size: 22px; color: var(--text-3); }
.upload-box p { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb {
  width: 74px; height: 74px; border-radius: 8px; background: #e5e7eb; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-2);
  position: relative; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 2px; right: 4px; color: #fff; background: rgba(0,0,0,.45); border-radius: 50%; width: 16px; height: 16px; line-height: 16px; text-align: center; font-size: 11px; }

.text-material {
  background: #fafbfc; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word;
}

.account-group {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: #fafbfc;
}
.account-group .hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12.5px; color: var(--text-2); }

.qrcode-box {
  width: 108px; height: 108px; border: 1px solid var(--border); border-radius: 8px;
  background: #f3f4f6; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 12px; cursor: zoom-in; overflow: hidden;
}
.qrcode-box img { width: 100%; height: 100%; object-fit: cover; }

.share-card { background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.share-link {
  display: flex; gap: 8px; align-items: center; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; word-break: break-all;
  font-family: ui-monospace, monospace; font-size: 12px;
}
.countdown { font-size: 12.5px; color: var(--amber); }

.modal-mask {
  position: absolute; inset: 0; background: rgba(17, 24, 39, .45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 420px; box-shadow: 0 8px 24px rgba(16,24,40,.12);
}
.modal .m-hd { padding: 16px; border-bottom: 1px solid var(--border); font-size: 14.5px; font-weight: 600; }
.modal .m-bd { padding: 16px; }
.modal .m-ft { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.toast-wrap { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(17,24,39,.9); color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.demo-note {
  background: var(--primary-soft); border: 1px dashed #bfdbfe; color: #1e40af;
  border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px; margin-bottom: 16px;
}
.demo-note b { font-weight: 600; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split-3 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

@media (max-width: 900px) {
  .split, .split-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: 100%; flex: none;
    height: auto; border-right: none; border-top: 1px solid var(--border); z-index: 50;
    box-shadow: 0 -2px 8px rgba(16,24,40,.06); order: 2;
  }
  .sidebar .brand { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 6px 8px; gap: 4px; }
  .sidebar nav .group-lb { display: none; }
  .sidebar nav button { white-space: nowrap; width: auto; text-align: center; margin: 0; padding: 8px 12px; }
  .sidebar nav button .dot { display: none; }
  .main { order: 1; padding-bottom: 70px; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; height: 52px; }
  .topbar .title { font-size: 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .val { font-size: 20px; }
  .row-inline { flex-direction: column; }
  .filters .field { min-width: calc(50% - 5px); flex: 1; }
  table { min-width: 640px; font-size: 12.5px; }
  th, td { padding: 8px 10px; }
  .card-hd { padding: 12px 14px; }
  .card-bd { padding: 14px; }
  .page-head h1 { font-size: 17px; }
}
